@khanacademy/perseus 0.2.0 → 0.2.1
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 +8 -0
- package/dist/es/index.js +2 -10
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +2 -10
- package/dist/index.js.map +1 -1
- package/package.json +13 -3
- package/src/README.md +33 -5
- package/src/jipt-paragraphs.js +6 -6
- package/src/multi-items/multi-renderer.jsx +1 -0
- package/src/perseus-markdown.jsx +5 -7
- package/src/pure-markdown.js +2 -1
- package/src/renderer.jsx +1 -0
- package/src/util/graphie.js +1 -0
- package/src/util/interactive.js +1 -0
- package/src/widgets/__stories__/unit.stories.jsx +45 -0
- package/src/widgets/__stories__/video-transcript-link.stories.jsx +24 -0
- package/src/widgets/__tests__/renderQuestion.jsx +1 -0
- package/src/widgets/passage/passage-markdown.jsx +1 -1
- package/src/widgets/unit.jsx +2 -1
- package/README.md +0 -3
package/dist/index.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@khanacademy/kas"),t=require("@khanacademy/math-input"),n=require("@khanacademy/wonder-blocks-i18n"),o=require("classnames"),s=require("react"),i=require("underscore"),r=require("prop-types"),a=require("simple-markdown"),l=require("aphrodite"),c=require("react-dom"),p=require("jquery"),d=require("@khanacademy/kmath"),u=require("create-react-class"),h=require("mathquill"),f=require("@khanacademy/wonder-blocks-color"),m=require("@khanacademy/wonder-blocks-core");require("intersection-observer");var g=require("@khanacademy/wonder-blocks-spacing"),v=require("@khanacademy/wonder-blocks-tooltip"),y=require("@khanacademy/wonder-blocks-dropdown"),b=require("@khanacademy/wonder-blocks-popover"),x=require("@khanacademy/wonder-blocks-link");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function C(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var k=C(e),S=C(n),E=w(o),_=C(s),T=w(s),M=w(i),I=w(r),P=w(a),N=w(c),A=C(c),R=w(p),F=w(u),O=w(h),D=w(f),L=w(g),B=w(v),z=w(x),q={major:11,minor:0},H={major:0,minor:1};function W(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U(){return U=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},U.apply(this,arguments)}const G=e=>{let{path:t,width:n,height:o,style:s={},title:i}=e;return _.createElement("svg",{role:"img","aria-hidden":!i,style:{verticalAlign:"middle",...s},width:"".concat(n/o,"em"),height:"1em",viewBox:"0 0 ".concat(n," ").concat(o)},!!i&&_.createElement("title",null,i),_.createElement("path",{d:t,fill:"currentColor"}))};G.propTypes={path:I.default.string.isRequired,height:I.default.number.isRequired,width:I.default.number.isRequired,style:I.default.object,title:I.default.string};const V="'Proxima Nova Semibold',sans-serif",j="#FFFFFF",Y="#BABEC2",$="#888D93",X="#21242c",K={defaultBoxSize:400,defaultBoxSizeSmall:288};var Z=Object.freeze({__proto__:null,baseFontFamily:"'Proxima Nova',sans-serif",boldFontFamily:V,green:"#76A005",kaGreen:"#71B307",blue:"#1C758A",gray:"#AAAAAA",red:"#FFBABA",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",learnstormBlue:"#4898FC",white:j,gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:Y,gray68:$,gray41:"#626569",gray25:"#3B3e40",gray17:X,black:"#000000",warning1:"#F86700",warning3:"#C75300",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1280px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1279px",tableBackgroundAccent:"#F9F9F9",gtpBlue:"#4c00ff",gtpIncorrectColor:"#babec2",gtpCorrectColor:"#ffbe26",satBlue:"#0084CE",satSelectedBackgroundColor:"#E4F3F9",satActiveBackgroundColor:"#D0EDF4",satCorrectColor:"#009900",satCorrectBorderColor:"#00CC00",satCorrectBackgroundColor:"#E4F7E4",satIncorrectColor:"#990000",satIncorrectBorderColor:"#CC5252",satIncorrectBackgroundColor:"#F2EBEB",zIndexScratchPad:1,zIndexAboveScratchpad:2,zIndexInteractiveComponent:3,zIndexCurrentlyDragging:4,zIndexCalculator:5,phoneMargin:16,negativePhoneMargin:-16,hintBorderWidth:4,baseUnitPx:16,interactiveSizes:K,circleSize:24,radioMarginWidth:2,warningColor:"#f86700",warningColorHover:"#df5c00",warningColorActive:"#c75300",publishBlockingErrorColor:"#be2612",radioBorderColor:"#BABEC2",checkedColor:"#71B307",articleMaxWidthInPx:688,articleMaxWidthTableInPx:512});const J={path:"M6 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0-9a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z",height:12,width:12};class Q extends _.Component{constructor(){super(...arguments),W(this,"_positionTimeout",void 0),W(this,"state",{tooltipAbove:!0}),W(this,"getPosition",(()=>{const e=N.default.findDOMNode(this).getBoundingClientRect();this.setState({tooltipAbove:e.top>100})})),W(this,"renderLink",(e=>{const t=this.state.tooltipAbove;let n,o,s;return 1===this.props.severity?(n=ee.indicatorError,o="Error",s=ee.publishBlockingError):2===this.props.severity?(n=ee.indicatorWarning,o="Warning",s=ee.warning):(n=ee.indicatorGuideline,o="Recommendation",s=ee.warning),_.createElement("a",{href:"https://khanacademy.org/r/linter-rules#".concat(this.props.ruleName),target:"lint-help-window",className:l.css(e)},_.createElement("span",{className:l.css(ee.indicator,n)},1===this.props.severity&&_.createElement(G,J)),_.createElement("div",{className:l.css(ee.tooltip,t&&ee.tooltipAbove)},this.props.message.split("\n\n").map(((e,t)=>_.createElement("p",{key:t,className:l.css(ee.tooltipParagraph)},_.createElement("span",{className:l.css(s)},o,":"," "),e))),_.createElement("div",{className:l.css(ee.tail,t&&ee.tailAbove)})))}))}componentDidMount(){this._positionTimeout=window.setTimeout(this.getPosition)}componentWillUnmount(){window.clearTimeout(this._positionTimeout)}render(){const{children:e,inline:t,blockHighlight:n,insideTable:o}=this.props;return o?t?_.createElement("span",{"data-lint-inside-table":"true"},e):_.createElement("div",{"data-lint-inside-table":"true"},e):n?_.createElement("span",{className:l.css(ee.lintContainer,ee.lintContainerBlock)},this.renderLink(ee.radioWidgetHoverTarget),_.createElement("span",null,e)):t?_.createElement("span",{className:l.css(ee.lintContainer)},this.renderLink(ee.inlineHoverTarget),_.createElement("span",null,e)):_.createElement("div",{className:l.css(ee.lintContainer)},this.renderLink(ee.hoverTarget),_.createElement("div",null,e))}}W(Q,"propTypes",{children:I.default.node,inline:I.default.bool,message:I.default.string.isRequired,ruleName:I.default.string.isRequired,insideTable:I.default.bool.isRequired,blockHighlight:I.default.bool,severity:I.default.number});const ee=l.StyleSheet.create({lintContainer:{position:"relative"},lintContainerBlock:{display:"block"},hoverTarget:{position:"absolute",top:0,right:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ div":{outline:"1px solid #f86700"},":hover ~ div div[data-lint-inside-table]":{outline:"1px solid #f86700"},":hover ~ div span[data-lint-inside-table]":{backgroundColor:"#f86700",color:j}},inlineHoverTarget:{float:"right",position:"relative",marginRight:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ span":{backgroundColor:"#f86700",color:j}},radioWidgetHoverTarget:{position:"absolute",left:-40,display:"block",width:24,height:24,minWidth:264,":hover > span":{backgroundColor:"#df5c00"},":hover > div":{display:"block",padding:8,width:280},":hover > div > div":{left:8},":hover ~ span":{backgroundColor:"#f86700",color:j}},indicator:{alignItems:"center",borderRadius:4,color:"white",display:"flex",fontSize:12,height:8,justifyContent:"center",margin:8,width:8},indicatorError:{backgroundColor:"#be2612",borderRadius:8,height:16,width:16},indicatorWarning:{backgroundColor:"#f86700"},indicatorGuideline:{backgroundColor:"#ffbe26"},tooltip:{position:"absolute",right:-12,display:"none",zIndex:1e3,color:j,backgroundColor:X,opacity:.9,fontFamily:"'Proxima Nova',sans-serif",fontSize:"12px",lineHeight:"15px",width:"320px",borderRadius:"4px"},tooltipAbove:{bottom:32},tail:{position:"absolute",top:-12,right:16,width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:"12px solid #21242c"},tailAbove:{bottom:-12,borderBottom:"none",borderTop:"12px solid #21242c",top:"auto"},tooltipParagraph:{margin:12},warning:{color:"#f86700",fontFamily:V},publishBlockingError:{color:"#be2612"}});let te=null;const ne=()=>{if(te)return te;throw new Error(["Perseus has not been provided required dependencies.","setDependencies(dependencies) must be called first.","Make sure Perseus is being imported from javascript/perseus/perseus.js."].join("\n"))};var oe=Object.freeze({__proto__:null,setDependencies:e=>{te=e},getDependencies:ne});const se=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"}),ie={log:(e,t)=>{ne().Log.log(e,t)},error:(e,t,n)=>{ne().Log.error(e,t,n)}};class re extends Error{constructor(e,t,n){super(e),W(this,"kind",void 0),W(this,"metadata",void 0),this.kind=t,this.metadata=null==n?void 0:n.metadata}}const ae={cleanMath:function(e){return"string"==typeof e?e.replace(/\+\s*-/g,"- ").replace(/-\s*-/g,"+ ").replace(/\^1/g,""):e},bound:function(e){return 0===e?e:e<0?-ae.bound(-e):Math.max(1e-6,Math.min(e,1e20))},factorial:function(e){return e<=1?e:e*ae.factorial(e-1)},getGCD:function(e,t){if(arguments.length>2){const t=[].slice.call(arguments,1);return ae.getGCD(e,ae.getGCD(...t))}let n;for(e=Math.abs(e),t=Math.abs(t);t;)n=e%t,e=t,t=n;return e},getLCM:function(e,t){if(arguments.length>2){const t=[].slice.call(arguments,1);return ae.getLCM(e,ae.getLCM(...t))}return Math.abs(e*t)/ae.getGCD(e,t)},primes:[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97],isPrime:function(e){if(e<=1)return!1;if(e<101)return!!R.default.grep(ae.primes,(function(t,n){return Math.abs(t-e)<=.5})).length;if(e<=1||e>2&&e%2==0)return!1;for(let t=3,n=Math.sqrt(e);t<=n;t+=2)if(e%t==0)return!1;return!0},getPrimeFactorization:function(e){if(1===e)return[];if(ae.isPrime(e))return[e];const t=Math.sqrt(e);for(let n=2;n<=t;n++)if(e%n==0)return R.default.merge(ae.getPrimeFactorization(n),ae.getPrimeFactorization(e/n))},roundToNearest:function(e,t){return Math.round(t/e)*e},roundTo:function(e,t){const n=Math.pow(10,e).toFixed(5);return Math.round((t*n).toFixed(5))/n},toFixedApprox:function(e,t){const n=e.toFixed(t);return d.number.equal(+n,e)?n:"\\approx "+n},roundToApprox:function(e,t){const n=ae.roundTo(t,e);return d.number.equal(n,e)?String(n):ae.toFixedApprox(e,t)},toFraction:function(e,t){if(null==t&&(t=Math.pow(2,-46)),e<0||e>1){let n=e%1;n+=n<0?1:0;const o=ae.toFraction(n,t);return o[0]+=Math.round(e-n)*o[1],o}if(Math.abs(Math.round(Number(e))-e)<=t)return[Math.round(e),1];let n=0,o=1,s=1,i=1,r=1,a=2;for(;;){if(Math.abs(Number(r/a)-e)<=t)return[r,a];r/a<e?(n=r,o=a):(s=r,i=a),r=n+s,a=o+i}},getNumericFormat:function(e){if((e=(e=R.default.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1")).match(/^[+-]?\d+$/))return"integer";if(e.match(/^[+-]?\d+\s+\d+\s*\/\s*\d+$/))return"mixed";const t=e.match(/^[+-]?(\d+)\s*\/\s*(\d+)$/);return t?parseFloat(t[1])>parseFloat(t[2])?"improper":"proper":e.replace(/[,. ]/g,"").match(/^\d+$/)?"decimal":e.match(/(pi?|\u03c0|t(?:au)?|\u03c4|pau)/)?"pi":null},toNumericString:function(e,t){if(null==e)return"";if(0===e)return"0";if("percent"===t)return 100*e+"%";if("pi"===t){const t=d.number.toFraction(e/Math.PI),n=Math.abs(t[0]),o=t[1];if(d.number.isInteger(n)){return(e<0?"-":"")+(1===n?"":n)+"π"+(1===o?"":"/"+o)}}if(M.default(["proper","improper","mixed","fraction"]).contains(t)){const n=d.number.toFraction(e),o=Math.abs(n[0]),s=n[1],i=e<0?"-":"";if(1===s)return i+o;if("mixed"===t){const e=o%s,t=(o-e)/s;return i+(t?t+" ":"")+e+"/"+s}return i+o+"/"+s}return String(e)}},le=Math.pow(2,-42),ce={APPROXIMATED_PI_ERROR:S._("Your answer is close, but you may have approximated pi. Enter your answer as a multiple of pi, like <code>12\\ \\text{pi}</code> or <code>2/3\\ \\text{pi}</code>"),EXTRA_SYMBOLS_ERROR:S._("We could not understand your answer. Please check your answer for extra text or symbols."),NEEDS_TO_BE_SIMPLFIED_ERROR:S._("Your answer is almost correct, but it needs to be simplified."),MISSING_PERCENT_ERROR:S._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end."),MULTIPLICATION_SIGN_ERROR:S._("I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign."),WRONG_CASE_ERROR:S._("Your answer includes use of a variable with the wrong case."),WRONG_LETTER_ERROR:S._("Your answer includes a wrong variable letter.")},pe={predicate:{defaultForms:"integer, proper, improper, mixed, decimal",createValidatorFunctional:function(e,t){let n;t=M.default.extend({simplify:"required",ratio:!1,forms:pe.predicate.defaultForms},t),n=M.default.isArray(t.forms)?t.forms:t.forms.split(/\s*,\s*/),void 0===t.inexact&&(t.maxError=0),t.maxError=+t.maxError+le,M.default.contains(n,"percent")&&(n=M.default.without(n,"percent"),n.push("percent"));const o=function(e){const n=(e=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").replace(/(^\s*)|(\s*$)/gi,"")).match(/^([+-]?\d+)\s*\/\s*([+-]?\d+)$/),o=e.match(/^([+-]?)\\frac\{([+-]?\d+)\}\{([+-]?\d+)\}$/),s=parseInt(e,10);if(n||o){let e,s,i=!0;return n?(e=parseFloat(n[1]),s=parseFloat(n[2])):(e=parseFloat(o[2]),"-"===o[1]&&(e<0&&(i=!1),e=-e),s=parseFloat(o[3])),i=i&&s>0&&(t.ratio||1!==s)&&1===ae.getGCD(e,s),[{value:e/s,exact:i}]}return isNaN(s)||""+s!==e?[]:[{value:s,exact:!0}]},s={integer:function(e){const t=s.decimal(e),n=s.decimal(e,1);return null!=t[0].value&&t[0].value===n[0].value||null!=t[1].value&&t[1].value===n[1].value?t:[]},proper:function(e){return R.default.map(o(e),(function(e){return Math.abs(e.value)<1?[e]:[]}))},improper:function(e){return R.default.map(o(e),(function(e){return Math.abs(e.value)>=1?[e]:[]}))},pi:function(e){let t,n=[];if(t=(e=e.replace(/\u2212/,"-")).match(/^([+-]?)\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=[{value:parseFloat(t[1]+"1"),exact:!0}];else if(t=e.match(/^([+-]?\s*\d+\s*(?:\/\s*[+-]?\s*\d+)?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=o(t[1]);else if(t=e.match(/^([+-]?)\s*(\d+)\s*([+-]?\d+)\s*\/\s*([+-]?\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i)){const e=parseFloat(t[1]+"1"),o=parseFloat(t[2]),s=parseFloat(t[3]),i=parseFloat(t[4]);n=[{value:e*(o+s/i),exact:s<i&&1===ae.getGCD(s,i)}]}else if(t=e.match(/^([+-]?\s*\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\s*\d+))?$/i))n=o(t[1]+"/"+t[3]);else if(t=e.match(/^([+-]?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\d+))?$/i))n=o(t[1]+"1/"+t[3]);else if("0"===e)n=[{value:0,exact:!0}];else{if(!(t=e.match(/^(.+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))){n=M.default.reduce(pe.predicate.defaultForms.split(/\s*,\s*/),(function(t,n){return t.concat(s[n](e))}),[]);let t=!1;const o=parseFloat(e);if(isNaN(o)||o===parseInt(e))e.match(/\/\s*7/)&&(t=!0);else{const e=Math.PI/12,n=e*Math.round(o/e);Math.abs(o-n)<.01&&(t=!0)}return t&&M.default.each(n,(function(e){e.piApprox=!0})),n}n=s.decimal(t[1])}let i=Math.PI;return e.match(/\\?tau|t|\u03c4/)&&(i=2*Math.PI),e.match(/pau/)&&(i=1.5*Math.PI),R.default.each(n,(function(e,t){t.value*=i})),n},coefficient:function(e){let t=[];return""===(e=e.replace(/\u2212/,"-"))?t=[{value:1,exact:!0}]:"-"===e&&(t=[{value:-1,exact:!0}]),t},log:function(e){let t,n=[];return(t=(e=(e=e.replace(/\u2212/,"-")).replace(/[ \(\)]/g,"")).match(/^log\s*(\S+)\s*$/i))?n=s.decimal(t[1]):"0"===e&&(n=[{value:0,exact:!0}]),n},percent:function(e){e=R.default.trim(e);let t=!1;e.indexOf("%")===e.length-1&&(e=R.default.trim(e.substring(0,e.length-1)),t=!0);const n=s.decimal(e);return R.default.each(n,(function(e,n){n.exact=t,n.value=n.value/100})),n},mixed:function(e){const t=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?)(\d+)\s+(\d+)\s*\/\s*(\d+)$/);if(t){const e=parseFloat(t[1]+"1"),n=parseFloat(t[2]),o=parseFloat(t[3]),s=parseFloat(t[4]);return[{value:e*(n+o/s),exact:o<s&&1===ae.getGCD(o,s)}]}return[]},decimal:function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e10;const o=function(e){const o=(e=R.default.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?(?:\d{1,3}(?:[, ]?\d{3})*\.?|\d{0,3}(?:[, ]?\d{3})*\.(?:\d{3}[, ]?)*\d{1,3}))$/),s=e.match(/^0[0,]*,/);if(o&&!s){let e=parseFloat(o[1].replace(/[, ]/g,""));return void 0===t.inexact&&(e=Math.round(e*n)/n),e}},s=function(e){return e=e.replace(/([\.,])/g,(function(e,t){return"."===t?",":"."})),o(e)};return[{value:o(e),exact:!0},{value:s(e),exact:!0}]}};return function(o){const i=null!=t.fallback?""+t.fallback:"",r={empty:""===(o=R.default.trim(o)||i),correct:!1,message:null,guess:o};if(R.default.each(n,(function(n,i){const a=s[i](o);for(let n=0,o=a.length;n<o;n++){const o=a[n].value,s=a[n].exact,l=a[n].piApprox;if(e(o,t.maxError))return s||"optional"===t.simplify?(r.correct=!0,r.message=t.message||null,r.empty=!1):"percent"===i?(r.empty=!0,r.message=ce.MISSING_PERCENT_ERROR):("enforced"!==t.simplify&&(r.empty=!0),r.message=ce.NEEDS_TO_BE_SIMPLFIED_ERROR),!1;l&&e(o,Math.abs(.001*o))&&(r.empty=!0,r.message=ce.APPROXIMATED_PI_ERROR)}})),!1===r.correct){let e=!1;if(M.default.each(s,(function(t){M.default.any(t(o),(function(e){return null!=e.value&&!M.default.isNaN(e.value)}))&&(e=!0)})),!e)return r.empty=!0,r.message=ce.EXTRA_SYMBOLS_ERROR,r}return r}}},number:{convertToPredicate:function(e,t){const n=parseFloat(R.default.trim(e));return[function(e,t){return Math.abs(e-n)<t},R.default.extend({},t,{type:"predicate"})]},createValidatorFunctional:function(e,t){return pe.predicate.createValidatorFunctional(...pe.number.convertToPredicate(e,t))}},expression:{parseSolution:function(e,t){let n=k.parse(e,t);if(!n.parsed)throw new re("The provided solution ("+e+") didn't parse.",se.InvalidInput);if(t.simplified&&!n.expr.isSimplified())throw new re("The provided solution ("+e+") isn't fully expanded and simplified.",se.InvalidInput);return n=n.expr,n},createValidatorFunctional:function(e,t){return function(n){const o={empty:!1,correct:!1,message:null,guess:n,ungraded:!1};if(!n)return o.empty=!0,o;const s=k.parse(n,t);if(!s.parsed)return o.empty=!0,o;"string"==typeof e&&(e=pe.expression.parseSolution(e,t));const i=k.compare(s.expr,e,t);if(i.equal)o.correct=!0;else if(i.wrongVariableNames||i.wrongVariableCase)o.ungraded=!0,o.message=i.wrongVariableCase?ce.WRONG_CASE_ERROR:ce.WRONG_LETTER_ERROR,o.suppressAlmostThere=!0;else if(i.message)o.message=i.message;else{const s=k.parse(n.replace(/[xX]/g,"*"),t);if(s.parsed){const n=k.compare(s.expr,e,t);n.equal?(o.ungraded=!0,o.message=ce.MULTIPLICATION_SIGN_ERROR):n.message&&(o.message=n.message+" Also, I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign.")}}return o}}}};let de=!1;const ue=/^web\+graphie:/,he=/^file\+graphie:/,fe=function(e,t,n){return Array.isArray(e)?M.default.map(e,(function(e){return fe(e,t)})):t.call(n,e)};const me=/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/,ge=new RegExp(me.source+"$"),ve=function(e){let t=e;return function(){let e=t;return e=e+2127912214+(e<<12)&4294967295,e=4294967295&(3345072700^e^e>>>19),e=e+374761393+(e<<5)&4294967295,e=4294967295&(e+3550635116^e<<9),e=e+4251993797+(e<<3)&4294967295,e=4294967295&(3042594569^e^e>>>16),(t=268435455&e)/268435456}};const ye="x".split(/(.)/g).length?function(e,t){return e.split(t)}:function(e,t){const n=[];let o,s=t.lastIndex=0;for(;o=t.exec(e);){const t=o;n.push(e.slice(s,t.index)),n.push(...t.slice(1)),s=t.index+t[0].length}return n.push(e.slice(s)),n};function be(e,t){const n=e*t,o=e,s=Math.pow(10,Math.floor(Math.log(o)/Math.LN10)),i=Math.floor(o/s);return n<25?e:n<50?5===i?e:e/2:1===i?e/2:2===i?e/4:5===i?e/5:void 0}function xe(e,t){return t/(e[1]-e[0])}function we(e,t){let n=Math.pow(10,Math.floor(Math.log(e/t)/Math.LN10));const o=t/e*n;return o<=.15?n*=10:o<=.35?n*=5:o<=.75&&(n*=2),n}const Ce=(e,t)=>{const n=t[1]-t[0],o=n/e;return o<=10?e:o<=20?2*e:we(n,10)};const ke={UNSAFE_componentWillMount:function(){const e={};M.default.each(this.deprecatedProps,(function(t,n){M.default.has(this.props,n)&&M.default.extend(e,t(this.props))}),this),M.default.isEmpty(e)||(M.default.extend(this.props,e),setTimeout(this.props.onChange,0,e))}};function Se(e,t){return"number"==typeof e&&"number"==typeof t?Math.abs(e-t)<1e-9:e===t}const Ee={pointerDown:!1,currentTouchIdentifier:null};function _e(e){return Te(e)?Ie(e):e}function Te(e){return ue.test(e)||he.test(e)}function Me(e){return e.replace(ue,"https:").replace(he,"file:")}function Ie(e){return Me(e)+".svg"}const Pe={getWordBeforeCursor:function(e){const t=e.value,n=e.selectionStart-1,o=Math.max(t.lastIndexOf("\n",n),t.lastIndexOf(" ",n))+1;return{string:t.substring(o,n+1),pos:{start:o,end:n}}},moveCursor:function(e,t){e.selectionStart=t,e.selectionEnd=t}},Ne=ve(4294967295&(new Date).getTime()),Ae={inputPathsEqual:function(e,t){return null==e||null==t?null==e==(null==t):e.length===t.length&&e.every(((e,n)=>t[n]===e))},nestedMap:fe,rWidgetRule:me,rTypeFromWidgetId:/^([a-z-]+) ([0-9]+)$/,rWidgetParts:ge,snowman:"☃",noScore:{type:"points",earned:0,total:0,message:null},seededRNG:ve,shuffle:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=M.default.clone(e);if(!o.length||M.default.all(o,(function(e){return M.default.isEqual(e,o[0])})))return o;let s;s="function"==typeof t?t:ve(t);do{for(let e=o.length;e>0;e--){const t=Math.floor(s()*e),n=o[t];o[t]=o[e-1],o[e-1]=n}}while(n&&M.default.isEqual(e,o));return o},split:ye,combineScores:function(e,t){let n;if("points"===e.type&&"points"===t.type)return n=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"points",earned:e.earned+t.earned,total:e.total+t.total,message:n};if("points"===e.type&&"invalid"===t.type)return t;if("invalid"===e.type&&"points"===t.type)return e;if("invalid"===e.type&&"invalid"===t.type)return n=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"invalid",message:n};throw new re("PerseusScore with unknown type encountered",se.InvalidInput,{metadata:{scoreA:JSON.stringify(e),scoreB:JSON.stringify(t)}})},keScoreFromPerseusScore:function(e,t,n){if("points"===e.type)return{empty:!1,correct:e.earned>=e.total,message:e.message,guess:t,state:n};if("invalid"===e.type)return{empty:!0,correct:!1,message:e.message,suppressAlmostThere:e.suppressAlmostThere,guess:t,state:n};throw new re("Invalid score type: "+e.type,se.InvalidInput,{metadata:{score:JSON.stringify(e),guess:JSON.stringify(t),state:JSON.stringify(n)}})},firstNumericalParse:function(e){let t;return pe.predicate.createValidatorFunctional((function(e){return t=e,!0}),{simplify:"optional",inexact:!0,forms:"integer, proper, improper, pi, log, mixed, decimal"})(e),t},stringArrayOfSize:function(e){return M.default(e).times((function(){return""}))},gridDimensionConfig:function(e,t,n,o){const s=xe(t,n);return{scale:s,tickStep:e/o,unityLabel:e*s>30}},getGridStep:function(e,t,n){return M.default(2).times((function(o){const s=xe(e[o],n);return be(t[o],s)}))},snapStepFromGridStep:function(e){return[e[0]/2,e[1]/2]},scaleFromExtent:xe,tickStepFromExtent:function(e,t){const n=e[1]-e[0];let o;return o=15<n&&n<=20?23:n>100||n<5?10:16,we(n,o*(t/500))},gridStepFromTickStep:be,tickStepFromNumTicks:we,constrainedTickStepsFromTickSteps:function(e,t){return[Ce(e[0],t[0]),Ce(e[1],t[1])]},DeprecationMixin:ke,eq:Se,deepEq:function e(t,n){if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return!1;for(let o=0;o<t.length;o++)if(!e(t[o],n[o]))return!1;return!0}return!Array.isArray(t)&&!Array.isArray(n)&&("function"==typeof t&&"function"==typeof n?Se(t,n):"function"!=typeof t&&"function"!=typeof n&&("object"==typeof t&&"object"==typeof n&&t&&n?t===n||M.default.all(t,(function(t,o){return e(n[o],t)}))&&M.default.all(n,(function(n,o){return e(t[o],n)})):!("object"==typeof t&&t||"object"==typeof n&&n)&&Se(t,n)))},parseQueryString:function(e){e=e||window.location.search.substring(1);const t={},n=/\+/g,o=/([^&=]+)=?([^&]*)/g,s=function(e){return decodeURIComponent(e.replace(n," "))};let i;for(;i=o.exec(e);){const e=i;t[s(e[1])]=s(e[2])}return t},updateQueryString:function(e,t,n){n=encodeURIComponent(n);const o=new RegExp("([?&])"+t+"=.*?(&|$)","i"),s=-1!==e.indexOf("?")?"&":"?";return e.match(o)?e.replace(o,"$1"+t+"="+n+"$2"):e+s+t+"="+n},strongEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/['()!]/g,window.escape).replace(/\*/g,"%2A")},widgetShouldHighlight:function(e){if(!e)return!1;switch(e.type){case"measurer":case"protractor":return!0;default:return!1}},scoreIsEmpty:function(e){return"invalid"===e.type&&(!e.message||0===e.message.length)},touchHandlers:Ee,resetTouchHandlers:function(){Object.assign(Ee,{pointerDown:!1,currentTouchIdentifier:null})},extractPointerLocation:function(e){let t;if(Ee.pointerDown){if(null!=Ee.currentTouchIdentifier){const n=e.changedTouches?e.changedTouches.length:0;for(let o=0;o<n;o++)e.changedTouches[o].identifier===Ee.currentTouchIdentifier&&(t=e.changedTouches[o])}else t=e;const n="touchend"===e.type||"touchcancel"===e.type;t&&n&&(Ee.pointerDown=!1,Ee.currentTouchIdentifier=null)}else Ee.pointerDown=!0,e.changedTouches?(t=e.changedTouches[0],Ee.currentTouchIdentifier=t.identifier):t=e;if(t)return{left:t.pageX,top:t.pageY}},supportsPassiveEvents:()=>{try{const e=Object.defineProperty({},"passive",{get:function(){de=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(e){}return de},captureScratchpadTouchStart:function(e){e.stopPropagation()},getImageSize:function(e,t){const n=new Image;n.onload=function(){var e;0===n.width&&0===n.height?(null===(e=document.body)||void 0===e||e.appendChild(n),M.default.defer((function(){var e;t(n.clientWidth,n.clientHeight),null===(e=document.body)||void 0===e||e.removeChild(n)}))):t(n.width,n.height)},n.src=_e(e)},getRealImageUrl:_e,isLabeledSVG:Te,getBaseUrl:Me,getSvgUrl:Ie,getDataUrl:function(e){return Me(e)+"-data.json"},textarea:Pe,unescapeMathMode:e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e,random:Ne},Re=(e,t,n)=>{const o=e.length;let s=0;if(n){if(t.inline)return null;for(;s<o&&" "===e[s];)s++}if(!(s<o&&"$"===e[s]))return null;s++;const i=s;let r=0;for(;s<o;){const t=e[s];if("\\"===t)s++;else{if(r<=0&&"$"===t){let t=s+1;if(n){const n=/^(?: *\n){2,}/.exec(e.slice(t));t=n?t+n[0].length:null}return t?[e.substring(0,t),e.substring(i,s)]:null}if("{"===t)r++;else if("}"===t)r--;else if("\n"===t&&"\n"===e[s-1])return null}s++}return null},Fe=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n("+P.default.defaultRules.nptable.match.regex.source.substring(1)+")"),Oe=P.default.blockRegex(/^(crwdns.*)\n\s*\n/),De={...P.default.defaultRules,columns:{order:-2,match:P.default.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:(e,t,n)=>({col1:t(e[1],n),col2:t(e[2],n)})},crowdinId:{order:-1,match:(e,t,n)=>t.isJipt?Oe(e,t,n):null,parse:(e,t,n)=>({id:e[1]})},titledTable:{order:P.default.defaultRules.nptable.order-.5,match:P.default.blockRegex(Fe),parse:(e,t,n)=>{const o=P.default.parseInline(t,e[1],n),s=e.slice(2);return{title:o,table:P.default.defaultRules.nptable.parse(s,t,n)}}},widget:{order:P.default.defaultRules.link.order-.75,match:P.default.inlineRegex(Ae.rWidgetRule),parse:(e,t,n)=>({id:e[1],widgetType:e[2]})},blockMath:{order:P.default.defaultRules.codeBlock.order+.5,match:(e,t)=>Re(e,t,!0),parse:(e,t,n)=>({content:e[1]})},math:{order:P.default.defaultRules.link.order-.25,match:(e,t)=>Re(e,t,!1),parse:(e,t,n)=>({content:e[1]})},unescapedDollar:{order:P.default.defaultRules.link.order-.24,match:P.default.inlineRegex(/^(?!\\)\$/),parse:(e,t,n)=>({})},fence:{...P.default.defaultRules.fence,parse:(e,t,n)=>{const o=P.default.defaultRules.fence.parse(e,t,n);return"alt"===o.lang?{type:"codeBlock",lang:"alt",content:t(o.content+"\n\n",n)}:o}},blockQuote:{...P.default.defaultRules.blockQuote,match:P.default.blockRegex(/^ *>[^\n]+(\n( *>)?[^\n]+)*\n{2,}/)},list:{...P.default.defaultRules.list,match:(e,t,n)=>t.isJipt?null:P.default.defaultRules.list.match(e,t,n)},lint:{order:1e3,match:e=>null,parse:(e,t,n)=>({})}};P.default.parserFor(De);const Le={...De,columns:{...De.columns,react:(e,t,n)=>_.createElement("div",{className:"perseus-two-columns",key:n.key},_.createElement("div",{className:"perseus-column"},_.createElement("div",{className:"perseus-column-content"},t(e.col1,n))),_.createElement("div",{className:"perseus-column"},_.createElement("div",{className:"sat-header-grafting-area"}),_.createElement("div",{className:"perseus-column-content"},_.createElement("div",{className:"sat-skill-subscore-grafting-area"}),t(e.col2,n),_.createElement("div",{className:"sat-grafting-area"}))))},crowdinId:{...De.crowdinId,react:(e,t,n)=>e.id},table:{...De.table,react:function(e,t,n){const o=P.default.defaultRules.table.react(e,t,n);return n.isMobile?_.cloneElement(o,{tabIndex:0}):o}},titledTable:{...De.titledTable,react:(e,t,n)=>{let o;if(e.table)if("lint"===e.table.type){var s;o="table"===(null===(s=e.table.content)||void 0===s?void 0:s.type)?Le.lint.react({...e.table,content:{...e,table:e.table.content}},t,{...n,unwrapTitledTableContents:!0}):Le.lint.react(e.table,t,n)}else{const s=P.default.defaultRules.table.react(e.table,t,n),i=_.createElement("caption",{key:"caption",className:"perseus-table-title"},t(e.title,n));o=_.cloneElement(s,null,[i,...s.props.children])}else o="//invalid table//";return n.unwrapTitledTableContents?o:_.createElement("div",{className:"perseus-titled-table",key:n.key},o)}},widget:{...De.widget,react:(e,t,n)=>_.createElement("em",{key:n.key},S.doNotTranslate("[Widget: ",e.id,"]"))},blockMath:{...De.blockMath,react:(e,t,n)=>{const{TeX:o}=ne();return _.createElement(o,{key:n.key},e.content)}},math:{...De.math,react:(e,t,n)=>{const{TeX:o}=ne();return _.createElement(o,{key:n.key},e.content)}},unescapedDollar:{...De.unescapedDollar,react:(e,t,n)=>"$"},link:{...De.link,react:function(e,t,n){const o=P.default.defaultRules.link.react(e,t,n),s=o.props.href;let i=null;!!s&&s.match(/https?:\/\/[^\/]*khanacademy.org|^\//)||(i="noopener noreferrer");const r={...o.props,target:"_blank",href:s,rel:i};return n.baseElements&&n.baseElements.Link?n.baseElements.Link(r):_.cloneElement(o,r)}},codeBlock:{...De.codeBlock,react:(e,t,n)=>"alt"===e.lang?_.createElement("div",{key:n.key,className:"perseus-markdown-alt perseus-sr-only"},t(e.content,n)):P.default.defaultRules.codeBlock.react(e,t,n)},lint:{...De.lint,react:(e,t,n)=>_.createElement(Q,{message:e.message,ruleName:e.ruleName,inline:Be(e.content),blockHighlight:e.blockHighlight,insideTable:e.insideTable,severity:e.severity},t(e.content,n))}};function Be(e){return!!(e&&e.type&&ze.hasOwnProperty(e.type))}const ze={text:!0,math:!0,unescapedDollar:!0,link:!0,img:!0,strong:!0,u:!0,em:!0,del:!0,code:!0},qe=P.default.parserFor(Le),He=(e,t)=>qe(e+"\n\n",{...t,inline:!1}),We=(e,t)=>{M.default.isArray(e)?M.default.each(e,(e=>We(e,t))):M.default.isObject(e)&&(t(e),"table"===e.type?(We(e.header,t),We(e.cells,t)):"list"===e.type?We(e.items,t):"titledTable"===e.type?We(e.table,t):"columns"===e.type?(We(e.col1,t),We(e.col2,t)):M.default.isArray(e.content)&&We(e.content,t))},Ue=e=>{if(M.default.isArray(e))return M.default.flatten(M.default.map(e,Ue));if(e.content&&M.default.isString(e.content))return-1!==e.type.toLowerCase().indexOf("code")?["",e.content,""]:[e.content.replace(/\s+/g," ")];const t=M.default.chain(e).values().flatten().filter((e=>null!=e&&M.default.has(e,"type"))).value();if(!t.length)return[];const n=Ue(t);if("paragraph"===e.type&&n.length){n[0]=n[0].replace(/^\s+/,"");const e=n.length-1;n[e]=n[e].replace(/\s+$/,"")}return n};var Ge={characterCount:e=>{const t=He(e);return Ue(t).join("").length},traverseContent:We,parse:He,parseInline:(e,t)=>qe(e,{...t,inline:!0}),reactFor:P.default.reactFor,ruleOutput:P.default.ruleOutput(Le,"react"),basicOutput:P.default.reactFor(P.default.ruleOutput(Le,"react")),sanitizeUrl:P.default.sanitizeUrl};class Ve{static parse(e){return new je(e).parse()}match(e){throw new re("Selector subclasses must implement match()",se.NotAllowed)}toString(){return"Unknown selector class"}}class je{constructor(e){W(this,"tokens",void 0),W(this,"tokenIndex",void 0),e=e.trim().replace(/\s+/g," "),this.tokens=e.match(je.TOKENS)||[],this.tokenIndex=0}nextToken(){return this.tokens[this.tokenIndex]||""}consume(){this.tokenIndex++}isIdentifier(){const e=this.tokens[this.tokenIndex][0];return e>="a"&&e<="z"||e>="A"&&e<="Z"}skipSpace(){for(;" "===this.nextToken();)this.consume()}parse(){const e=this.parseTreeSelector();let t=this.nextToken();if(!t)return e;const n=[e];for(;t;){if(","!==t)throw new Ye("Expected comma");this.consume(),n.push(this.parseTreeSelector()),t=this.nextToken()}return new $e(n)}parseTreeSelector(){this.skipSpace();let e=this.parseNodeSelector();for(;;){const t=this.nextToken();if(!t||","===t)break;if(" "===t)this.consume(),e=new Je(e,this.parseNodeSelector());else if(">"===t)this.consume(),e=new Qe(e,this.parseNodeSelector());else if("+"===t)this.consume(),e=new et(e,this.parseNodeSelector());else{if("~"!==t)throw new Ye("Unexpected token: "+t);this.consume(),e=new tt(e,this.parseNodeSelector())}}return e}parseNodeSelector(){this.skipSpace();const e=this.nextToken();if("*"===e)return this.consume(),new Xe;if(this.isIdentifier())return this.consume(),new Ke(e);throw new Ye("Expected node type")}}W(je,"TOKENS",void 0),je.TOKENS=/([a-zA-Z][\w-]*)|(\d+)|[^\s]|(\s(?=[a-zA-Z\*]))/g;class Ye extends Error{constructor(e){super(e)}}class $e extends Ve{constructor(e){super(),W(this,"selectors",void 0),this.selectors=e}match(e){for(let t=0;t<this.selectors.length;t++){const n=this.selectors[t].match(e);if(n)return n}return null}toString(){let e="";for(let t=0;t<this.selectors.length;t++)e+=t>0?", ":"",e+=this.selectors[t].toString();return e}}class Xe extends Ve{match(e){return[e.currentNode()]}toString(){return"*"}}class Ke extends Ve{constructor(e){super(),W(this,"type",void 0),this.type=e}match(e){const t=e.currentNode();return t.type===this.type?[t]:null}toString(){return this.type}}class Ze extends Ve{constructor(e,t){super(),W(this,"left",void 0),W(this,"right",void 0),this.left=e,this.right=t}}class Je extends Ze{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t)for(e=e.clone();e.hasParent();){e.goToParent();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" "+this.right.toString()}}class Qe extends Ze{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t&&e.hasParent()){(e=e.clone()).goToParent();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" > "+this.right.toString()}}class et extends Ze{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t&&e.hasPreviousSibling()){(e=e.clone()).goToPreviousSibling();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" + "+this.right.toString()}}class tt extends Ze{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t)for(e=e.clone();e.hasPreviousSibling();){e.goToPreviousSibling();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" ~ "+this.right.toString()}}class nt{constructor(e,t,n,o,s,i){var r=this;if(W(this,"name",void 0),W(this,"severity",void 0),W(this,"selector",void 0),W(this,"pattern",void 0),W(this,"lint",void 0),W(this,"applies",void 0),W(this,"message",void 0),!n&&!o)throw new re("Lint rules must have a selector or pattern",se.InvalidInput,{metadata:{name:e}});this.name=e||"unnamed rule",this.severity=t||nt.Severity.BULK_WARNING,this.selector=n||nt.DEFAULT_SELECTOR,this.pattern=o||null,"function"==typeof s?(this.lint=s,this.message=null):(this.lint=function(){return r._defaultLintFunction(...arguments)},this.message=s),this.applies=i||function(){return!0}}static makeRule(e){return new nt(e.name,e.severity,e.selector?Ve.parse(e.selector):null,nt.makePattern(e.pattern),e.lint||e.message,e.applies)}check(e,t,n,o){const s=this.selector.match(t);if(!s)return null;let i;if(i=this.pattern?n.match(this.pattern):nt.FakePatternMatch(n,n,0),!i)return null;try{const e=this.lint(t,n,s,i,o);return e?"string"==typeof e?{rule:this.name,severity:this.severity,message:e,start:0,end:n.length}:{rule:this.name,severity:this.severity,message:e.message,start:e.start,end:e.end}:null}catch(e){return{rule:"lint-rule-failure",message:"Exception in rule ".concat(this.name,": ").concat(e.message,"\nStack trace:\n").concat(e.stack),start:0,end:n.length}}}_defaultLintFunction(e,t,n,o,s){return{message:this.message||"",start:o.index,end:o.index+o[0].length}}static makePattern(e){if(!e)return null;if(e instanceof RegExp)return e;if("/"===e[0]){const t=e.lastIndexOf("/"),n=e.substring(1,t),o=e.substring(t+1);return new RegExp(n,o)}return new RegExp(e)}static FakePatternMatch(e,t,n){const o=[t];return o.index=n,o.input=e,o}}W(nt,"DEFAULT_SELECTOR",void 0),W(nt,"Severity",{ERROR:1,WARNING:2,GUIDELINE:3,BULK_WARNING:4}),nt.DEFAULT_SELECTOR=Ve.parse("text");const ot=/\/\/([^\/]+)/;var st=nt.makeRule({name:"absolute-url",severity:nt.Severity.GUIDELINE,selector:"link, image",lint:function(e,t,n,o){const s=function(e){if(!e)return"";const t=e.match(ot);return t?t[1]:""}(n[0].target);if("khanacademy.org"===s||s.endsWith(".khanacademy.org"))return"Don't use absolute URLs:\nWhen linking to KA content or images, omit the\nhttps://www.khanacademy.org URL prefix.\nUse a relative URL beginning with / instead."}}),it=nt.makeRule({name:"blockquoted-math",severity:nt.Severity.WARNING,selector:"blockQuote math, blockQuote blockMath",message:"Blockquoted math:\nmath should not be indented."}),rt=nt.makeRule({name:"blockquoted-widget",severity:nt.Severity.WARNING,selector:"blockQuote widget",message:"Blockquoted widget:\nwidgets should not be indented."}),at=nt.makeRule({name:"double-spacing-after-terminal",severity:nt.Severity.BULK_WARNING,selector:"paragraph",pattern:/[.!\?] {2}/i,message:"Use a single space after a sentence-ending period, or\nany other kind of terminal punctuation."}),lt=nt.makeRule({name:"extra-content-spacing",selector:"paragraph",pattern:/\s+$/,applies:function(e){return"article"===e.contentType},message:"No extra whitespace at the end of content blocks."}),ct=nt.makeRule({name:"heading-level-1",severity:nt.Severity.WARNING,selector:"heading",lint:function(e,t,n,o){if(1===n[0].level)return"Don't use level-1 headings:\nBegin headings with two or more # characters."}}),pt=nt.makeRule({name:"heading-level-skip",severity:nt.Severity.WARNING,selector:"heading ~ heading",lint:function(e,t,n,o){const s=n[1],i=n[0];if(s.level>i.level+1)return"Skipped heading level:\nthis heading is level ".concat(s.level," but\nthe previous heading was level ").concat(i.level)}}),dt=nt.makeRule({name:"heading-sentence-case",severity:nt.Severity.GUIDELINE,selector:"heading",pattern:/^\W*[a-z]/,message:"First letter is lowercase:\nthe first letter of a heading should be capitalized."});const ut={and:!0,nor:!0,but:!0,the:!0,for:!0};var ht=nt.makeRule({name:"heading-title-case",severity:nt.Severity.GUIDELINE,selector:"heading",pattern:/[^\s:]\s+[A-Z]+[a-z]/,locale:"en",lint:function(e,t,n,o){let s=t.trim().split(/\s+/);if(s.shift(),s=s.filter((e=>e.length>2&&!ut.hasOwnProperty(e))),s.length>=3&&s.every((e=>function(e){const t=e[0];return t===t.toUpperCase()}(e))))return"Title-case heading:\nThis heading appears to be in title-case, but should be sentence-case.\nOnly capitalize the first letter and proper nouns."}}),ft=nt.makeRule({name:"image-alt-text",severity:nt.Severity.WARNING,selector:"image",lint:function(e,t,n,o){const s=n[0];return s.alt&&s.alt.trim()?s.alt.length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(s.alt.length," characters long."):void 0:"Images should have alt text:\nfor accessibility, all images should have alt text.\nSpecify alt text inside square brackets after the !."}}),mt=nt.makeRule({name:"image-in-table",severity:nt.Severity.BULK_WARNING,selector:"table image",message:"Image in table:\ndo not put images inside of tables."}),gt=nt.makeRule({name:"image-spaces-around-urls",severity:nt.Severity.ERROR,selector:"image",lint:function(e,t,n,o,s){const i=n[0].target;if(s&&s.content){const e=s.content.indexOf(i);if(-1===e)return;if("("!==s.content[e-1]||")"!==s.content[e+i.length])return"Whitespace before or after image url:\nFor images, don't include any space or newlines after '(' or before ')'.\nWhitespace in image URLs causes translation difficulties."}}}),vt=nt.makeRule({name:"image-widget",severity:nt.Severity.WARNING,selector:"widget",lint:function(e,t,n,o,s){if("image"!==e.currentNode().widgetType)return;const i=s&&s.widgets&&s.widgets[e.currentNode().id];if(!i)return;const r=i.options.alt;return r?r.trim().length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(r.trim().length," characters long."):i.options.caption&&i.options.caption.match(/[^\\]\$/)?"No math in image captions:\nDon't include math expressions in image captions.":void 0:'Images should have alt text:\nfor accessibility, all images should have a text description.\nAdd a description in the "Alt Text" box of the image widget.'}}),yt=nt.makeRule({name:"link-click-here",severity:nt.Severity.WARNING,selector:"link",pattern:/click here/i,message:'Inappropriate link text:\nDo not use the words "click here" in links.'}),bt=nt.makeRule({name:"long-paragraph",severity:nt.Severity.GUIDELINE,selector:"paragraph",pattern:/^.{501,}/,lint:function(e,t,n,o){return"Paragraph too long:\nThis paragraph is ".concat(t.length," characters long.\nShorten it to 500 characters or fewer.")}}),xt=nt.makeRule({name:"math-adjacent",severity:nt.Severity.WARNING,selector:"blockMath+blockMath",message:"Adjacent math blocks:\ncombine the blocks between \\begin{align} and \\end{align}"}),wt=nt.makeRule({name:"math-align-extra-break",severity:nt.Severity.WARNING,selector:"blockMath",pattern:/(\\{2,})\s*\\end{align}/,message:"Extra space at end of block:\nDon't end an align block with backslashes"}),Ct=nt.makeRule({name:"math-align-linebreaks",severity:nt.Severity.WARNING,selector:"blockMath",pattern:/\\begin{align}[\s\S]*\\\\[\s\S]+\\end{align}/,lint:function(e,t,n,o){let s=o[0];for(;s.length;){const e=s.indexOf("\\\\");if(-1===e)return null;s=s.substring(e+2);const t=s.match(/^\s*\\\\\s*(?!\\\\)/);if(!t)return"Use four backslashes between lines of an align block";s=s.substring(t[0].length)}}}),kt=nt.makeRule({name:"math-empty",severity:nt.Severity.WARNING,selector:"math, blockMath",pattern:/^$/,message:"Empty math: don't use $$ in your markdown."}),St=nt.makeRule({name:"math-font-size",severity:nt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\(tiny|Tiny|small|large|Large|LARGE|huge|Huge|scriptsize|normalsize)\s*{/,message:"Math font size:\nDon't change the default font size with \\Large{} or similar commands"}),Et=nt.makeRule({name:"math-frac",severity:nt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\frac[ {]/,message:"Use \\dfrac instead of \\frac in your math expressions."}),_t=nt.makeRule({name:"math-nested",severity:nt.Severity.ERROR,selector:"math, blockMath",pattern:/\\text{[^$}]*\$[^$}]*\$[^}]*}/,message:"Nested math:\nDon't nest math expressions inside \\text{} blocks"}),Tt=nt.makeRule({name:"math-starts-with-space",severity:nt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/^\s*(~|\\qquad|\\quad|\\,|\\;|\\:|\\ |\\!|\\enspace|\\phantom)/,message:"Math starts with space:\nmath should not be indented. Do not begin math expressions with\nLaTeX space commands like ~, \\;, \\quad, or \\phantom"}),Mt=nt.makeRule({name:"math-text-empty",severity:nt.Severity.WARNING,selector:"math, blockMath",pattern:/\\text{\s*}/,message:"Empty \\text{} block in math expression"}),It=nt.makeRule({name:"math-without-dollars",severity:nt.Severity.GUIDELINE,pattern:/\\\w+{[^}]*}|{|}/,message:"This looks like LaTeX:\ndid you mean to put it inside dollar signs?"}),Pt=nt.makeRule({name:"nested-lists",severity:nt.Severity.WARNING,selector:"list list",message:"Nested lists:\nnested lists are hard to read on mobile devices;\ndo not use additional indentation."}),Nt=nt.makeRule({name:"profanity",pattern:/\b(shit|piss|fuck|cunt|cocksucker|motherfucker|tits)\b/i,message:"Avoid profanity"}),At=nt.makeRule({name:"table-missing-cells",severity:nt.Severity.WARNING,selector:"table",lint:function(e,t,n,o){const s=n[0],i=s.header.length,r=s.cells.map((e=>e.length));for(let e=0;e<r.length;e++)if(r[e]!==i)return"Table rows don't match header:\nThe table header has ".concat(i," cells, but\nRow ").concat(e+1," has ").concat(r[e]," cells.")}}),Rt=nt.makeRule({name:"unbalanced-code-delimiters",severity:nt.Severity.ERROR,pattern:/[`~]+/,message:"Unbalanced code delimiters:\ncode blocks should begin and end with the same type and number of delimiters"}),Ft=[st,it,rt,at,lt,ct,pt,dt,ht,ft,mt,yt,bt,xt,wt,Ct,kt,St,Et,_t,Tt,Mt,Pt,At,nt.makeRule({name:"unescaped-dollar",severity:nt.Severity.ERROR,selector:"unescapedDollar",message:"Unescaped dollar sign:\nDollar signs must appear in pairs or be escaped as \\$"}),nt.makeRule({name:"widget-in-table",severity:nt.Severity.BULK_WARNING,selector:"table widget",message:"Widget in table:\ndo not put widgets inside of tables."}),Nt,It,Rt,gt,vt];class Ot{constructor(e){W(this,"root",void 0),this.root=e}static isNode(e){return e&&"object"==typeof e&&"string"==typeof e.type}static isTextNode(e){return Ot.isNode(e)&&"text"===e.type&&"string"==typeof e.content}traverse(e){this._traverse(this.root,new Dt(this.root),e)}_traverse(e,t,n){let o="";if(Ot.isNode(e)){const s=e;t._containers.push(s),t._ancestors.push(s),"string"==typeof s.content&&(o=s.content);Object.keys(s).forEach((e=>{if("type"===e)return;const i=s[e];i&&"object"==typeof i&&(t._indexes.push(e),o+=this._traverse(i,t,n),t._indexes.pop())})),t._currentNode=t._ancestors.pop(),t._containers.pop(),n(s,t,o)}else if(Array.isArray(e)){const s=e;t._containers.push(s);let i=0;for(;i<s.length;)t._indexes.push(i),o+=this._traverse(s[i],t,n),i=t._indexes.pop()+1;t._containers.pop()}return o}}class Dt{constructor(e){W(this,"root",void 0),W(this,"_currentNode",void 0),W(this,"_containers",void 0),W(this,"_indexes",void 0),W(this,"_ancestors",void 0),this.root=e,this._currentNode=null,this._containers=new Lt,this._indexes=new Lt,this._ancestors=new Lt}currentNode(){return this._currentNode||this.root}parent(){return this._ancestors.top()}ancestors(){return this._ancestors.values()}nextSibling(){const e=this._containers.top();if(!e||!Array.isArray(e))return null;const t=this._indexes.top();return e.length>t+1?e[t+1]:null}previousSibling(){const e=this._containers.top();if(!e||!Array.isArray(e))return null;const t=this._indexes.top();return t>0?e[t-1]:null}removeNextSibling(){const e=this._containers.top();if(e&&Array.isArray(e)){const t=this._indexes.top();if(e.length>t+1)return e.splice(t+1,1)[0]}return null}replace(){const e=this._containers.top();if(!e)throw new re("Can't replace the root of the tree",se.Internal);for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];if(Array.isArray(e)){const t=this._indexes.top();e.splice(t,1,...n),this._indexes.pop(),this._indexes.push(t+n.length-1)}else{const t=this._indexes.top();0===n.length?delete e[t]:1===n.length?e[t]=n[0]:e[t]=n}}hasPreviousSibling(){return Array.isArray(this._containers.top())&&this._indexes.top()>0}goToPreviousSibling(){if(!this.hasPreviousSibling())throw new re("goToPreviousSibling(): node has no previous sibling",se.Internal);this._currentNode=this.previousSibling();const e=this._indexes.pop();this._indexes.push(e-1)}hasParent(){return 0!==this._ancestors.size()}goToParent(){if(!this.hasParent())throw new re("goToParent(): node has no ancestor",se.NotAllowed);for(this._currentNode=this._ancestors.pop();this._containers.size()&&this._containers.top()[this._indexes.top()]!==this._currentNode;)this._containers.pop(),this._indexes.pop()}clone(){const e=new Dt(this.root);return e._currentNode=this._currentNode,e._containers=this._containers.clone(),e._indexes=this._indexes.clone(),e._ancestors=this._ancestors.clone(),e}equals(e){return this.root===e.root&&this._currentNode===e._currentNode&&this._containers.equals(e._containers)&&this._indexes.equals(e._indexes)&&this._ancestors.equals(e._ancestors)}}class Lt{constructor(e){W(this,"stack",void 0),this.stack=e?e.slice(0):[]}push(e){this.stack.push(e)}pop(){return this.stack.pop()}top(){return this.stack[this.stack.length-1]}values(){return this.stack.slice(0)}size(){return this.stack.length}toString(){return this.stack.toString()}clone(){return new Lt(this.stack)}equals(e){if(!e||!e.stack||e.stack.length!==this.stack.length)return!1;for(let t=0;t<this.stack.length;t++)if(this.stack[t]!==e.stack[t])return!1;return!0}}const Bt=Ft.filter((e=>e.severity<nt.Severity.BULK_WARNING));var zt={runLinter:function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Bt;const s=[],i=new Ot(e);i.traverse(((e,t,n)=>{if(Ot.isTextNode(e)){let n=t.nextSibling();for(;Ot.isTextNode(n);)e.content+=n.content,t.removeNextSibling(),n=t.nextSibling()}}));let r=[],a=!1;return i.traverse(((e,i,l)=>{const c=[],p=o.filter((e=>e.applies(t))),d=[...t.stack];d.push(e.type);const u={...t,stack:d.join(".")};if(p.forEach((t=>{const o=t.check(e,i,l,u);o&&((o.start||o.end)&&(o.target=l.substring(o.start,o.end)),s.push(o),n&&c.push(o))})),n&&("table"===e.type?(r.length&&c.push(...r),a=!1,r=[]):a||(a=i.ancestors().some((e=>"table"===e.type))),a&&c.length&&r.push(...c),c.length))if(c.sort(((e,t)=>e.severity-t.severity)),"text"!==e.type||c.length>1)i.replace({type:"lint",content:e,message:c.map((e=>e.message)).join("\n\n"),ruleName:c[0].rule,blockHighlight:u.blockHighlight,insideTable:a,severity:c[0].severity});else{const t=e.content,n=c[0],o=n.start||0,s=n.end||t.length,r=t.substring(0,o),l=t.substring(o,s),p=t.substring(s),d=[];r&&d.push({type:"text",content:r}),d.push({type:"lint",content:{type:"text",content:l},message:n.message,ruleName:n.rule,insideTable:a,severity:n.severity}),p&&d.push({type:"text",content:p}),i.replace(...d)}})),s},parse:Ge.parse,pushContextStack:function(e,t){const n=e.stack||[];return{...e,stack:n.concat(t)}},rules:Bt};const qt=I.default.shape({contentType:I.default.string,highlightLint:I.default.bool,paths:I.default.arrayOf(I.default.string),stack:I.default.arrayOf(I.default.string)}),Ht={contentType:"",highlightLint:!1,paths:[],stack:[]},Wt={};function Ut(e){if(!Wt[e]){const t=R.default("<span>").text(e).appendTo("body");Wt[e]=t.width()+5,t.remove()}return Wt[e]}class Gt extends _.Component{constructor(){super(...arguments),W(this,"state",{items:this.props.options.concat("")}),W(this,"onChange",((e,t)=>{let n=M.default.clone(this.state.items);n[e]=t.target.value,e===n.length-1&&(n=n.concat("")),this.setState({items:n}),this.props.onChange(M.default.compact(n))})),W(this,"onKeyDown",((e,t)=>{const n=t.nativeEvent.keyCode;if(8===n&&""===this.state.items[e]){t.preventDefault();const n=M.default.clone(this.state.items),o=0===e?0:e-1;e!==n.length-1||0!==e&&""===n[o]?(n.splice(e,1),this.setState({items:n},(function(){N.default.findDOMNode(this.refs["input_"+o]).focus()}))):N.default.findDOMNode(this.refs["input_"+o]).focus()}else if(8===n&&1===this.state.items[e].length&&e===this.state.items.length-2){t.preventDefault();const n=M.default.clone(this.state.items);n.splice(e,1),this.setState({items:n}),this.props.onChange(M.default.compact(n))}else if(13===n){t.preventDefault();const n=M.default.clone(this.state.items),o=e+1;e===n.length-2?N.default.findDOMNode(this.refs["input_"+o]).focus():(n.splice(o,0,""),this.setState({items:n},(function(){N.default.findDOMNode(this.refs["input_"+o]).focus()})))}}))}UNSAFE_componentWillReceiveProps(e){this.setState({items:e.options.concat("")})}render(){const e=["perseus-text-list-editor","perseus-clearfix","layout-"+this.props.layout].join(" "),t=M.default.map(this.state.items,(function(e,t){return _.createElement("li",{key:t},_.createElement("input",{ref:"input_"+t,type:"text",value:e,onChange:this.onChange.bind(this,t),onKeyDown:this.onKeyDown.bind(this,t),style:{width:Ut(e)}}))}),this);return _.createElement("ul",{className:e},t)}}W(Gt,"propTypes",{options:I.default.array,layout:I.default.string,onChange:I.default.func.isRequired}),W(Gt,"defaultProps",{options:[],layout:"horizontal"});const Vt=[];class jt extends _.Component{render(){return _.createElement("div",null,this.props.showTitle&&_.createElement("div",{style:{fontSize:14}},"Tags:"),_.createElement(Gt,{options:this.props.value||Vt,layout:"vertical",onChange:this.props.onChange}))}}W(jt,"propTypes",{value:I.default.arrayOf(I.default.string),onChange:I.default.func.isRequired,showTitle:I.default.bool.isRequired}),W(jt,"defaultProps",{value:Vt,showTitle:!0});const Yt={propTypes:I.default.shape({isArticle:I.default.bool.isRequired,satStyling:I.default.bool.isRequired,onInputError:I.default.func.isRequired,onFocusChange:I.default.func.isRequired,staticRender:I.default.bool.isRequired,GroupMetadataEditor:I.default.func.isRequired,showAlignmentOptions:I.default.bool.isRequired,readOnly:I.default.bool.isRequired,answerableCallback:I.default.func,getAnotherHint:I.default.func,interactionCallback:I.default.func,groupAnnotator:I.default.func.isRequired,imagePlaceholder:I.default.node,widgetPlaceholder:I.default.node,baseElements:I.default.shape({Link:I.default.func}),imagePreloader:I.default.func,trackInteraction:I.default.func,customKeypad:I.default.bool,nativeKeypadProxy:I.default.func,isMobile:I.default.bool,setDrawingAreaAvailable:I.default.func,useDraftEditor:I.default.bool,styling:I.default.shape({radioStyleVersion:I.default.oneOf(["intermediate","final"])}),hintProgressColor:I.default.string,canScrollPage:I.default.bool,inModal:I.default.bool,crossOutEnabled:I.default.bool,editorChangeDelay:I.default.number}).isRequired,defaults:{isArticle:!1,isMobile:!1,satStyling:!1,onInputError:function(){},onFocusChange:function(){},staticRender:!1,GroupMetadataEditor:jt,showAlignmentOptions:!1,readOnly:!1,groupAnnotator:function(){return null},baseElements:{Link:e=>_.createElement("a",e)},setDrawingAreaAvailable:function(){},useDraftEditor:!1,styling:{radioStyleVersion:"final"},canScrollPage:!1,inModal:!1,crossOutEnabled:!1,editorChangeDelay:0}},$t={RENDERER:"perseus-renderer",TWO_COLUMN_RENDERER:"perseus-renderer-two-columns",RESPONSIVE_RENDERER:"perseus-renderer-responsive",INPUT:"perseus-input",FOCUSED:"perseus-focused",RADIO:{OPTION:"perseus-radio-option",SELECTED:"perseus-radio-selected",OPTION_CONTENT:"perseus-radio-option-content"},INTERACTIVE:"perseus-interactive",CORRECT:"perseus-correct",INCORRECT:"perseus-incorrect",UNANSWERED:"perseus-unanswered",MOBILE:"perseus-mobile"},Xt={assetStatuses:{},setAssetStatus:(e,t)=>{}},Kt=_.createContext(Xt);function Zt(e,t){const n=window.scrollX,o=window.scrollY,s=document.querySelector("meta[name=viewport]");s?s.setAttribute("content",e):R.default("head").append('<meta name="viewport" content="'.concat(e,'">')),document.body.style.opacity=.9999,setTimeout((()=>{document.body.style.opacity=1,window.scrollTo(n,o),t&&setTimeout(t,0)}),0)}function Jt(){}function Qt(e,t){this._fullHeight=this._fullWidth=this._overlay=null,this._targetImage=e,this._enableMobilePinch=t,this._$body=R.default(document.body)}R.default.fn.emulateTransitionEnd=function(e){let t=!1;const n=this;R.default(this).one("bsTransitionEnd",(function(){t=!0}));return setTimeout((function(){t||R.default(n).trigger(R.default.support.transition.end)}),e),this},R.default((function(){R.default.support.transition=function(){const e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(const n in t)if(void 0!==e.style[n])return{end:t[n]};return!1}(),R.default.support.transition&&(R.default.event.special.bsTransitionEnd={bindType:R.default.support.transition.end,delegateType:R.default.support.transition.end,handle:function(e){if(R.default(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})),Jt.prototype._initialize=function(e){this._$document||(this._activeZoom=this._initialScrollPosition=this._initialTouchPosition=this._touchMoveListener=null,this._$document=R.default(document),this._$window=R.default(window),this._$body=R.default(document.body),this._boundClick=R.default.proxy(this._clickHandler,this),this._enableMobilePinch=e)},Jt.prototype.handleZoomClick=function(e,t){this._initialize(t);const n=e.target;if(n&&"IMG"===n.tagName&&!this._$body.hasClass("zoom-overlay-open"))return e.metaKey||e.ctrlKey?window.open(e.target.src,"_blank"):void(!t&&n.width>=window.innerWidth-Qt.getOffset()||(this._activeZoomClose(!0),t?Zt("width=device-width, initial-scale=1, minimum-scale=1",(()=>this._zoom(n))):this._zoom(n),t||(this._$window.on("scroll.zoom",R.default.proxy(this._scrollHandler,this)),this._$document.on("keyup.zoom",R.default.proxy(this._keyHandler,this)),this._$document.on("touchstart.zoom",R.default.proxy(this._touchStart,this))),document.addEventListener("click",this._boundClick,!0),e.stopPropagation()))},Jt.prototype._zoom=function(e){this._activeZoom=new Qt(e,this._enableMobilePinch),this._activeZoom.zoomImage()},Jt.prototype._activeZoomClose=function(e){this._activeZoom&&(e?(this._activeZoom.dispose(),this._disposeActiveZoom()):Zt("width=device-width, initial-scale=1, minimum-scale=1,\n maximum-scale=1",(()=>{this._activeZoom&&(this._activeZoom.close(),this._disposeActiveZoom())})))},Jt.prototype._disposeActiveZoom=function(){this._$window.off(".zoom"),this._$document.off(".zoom"),document.removeEventListener("click",this._boundClick,!0),this._activeZoom=null},Jt.prototype._scrollHandler=function(e){null===this._initialScrollPosition&&(this._initialScrollPosition=window.scrollY);const t=this._initialScrollPosition-window.scrollY;Math.abs(t)>=40&&this._activeZoomClose()},Jt.prototype._keyHandler=function(e){27===e.keyCode&&this._activeZoomClose()},Jt.prototype._clickHandler=function(e){e.stopPropagation(),e.preventDefault(),this._activeZoomClose()},Jt.prototype._touchStart=function(e){this._initialTouchPosition=e.originalEvent.touches[0].pageY,R.default(e.target).on("touchmove.zoom",R.default.proxy(this._touchMove,this))},Jt.prototype._touchMove=function(e){Math.abs(e.originalEvent.touches[0].pageY-this._initialTouchPosition)>10&&(this._activeZoomClose(),R.default(e.target).off("touchmove.zoom"))},Qt._OFFSET=80,Qt._MAX_WIDTH=2560,Qt._MAX_HEIGHT=4096,Qt.getOffset=function(e){return e?0:Qt._OFFSET},Qt.prototype.getOffset=function(){return Qt.getOffset(this._enableMobilePinch)},Qt.prototype.zoomImage=function(){const e=document.createElement("img"),t=R.default(e);e.onload=function(){this._fullHeight=Number(e.height),this._fullWidth=Number(e.width);const n=this._imageOffset=R.default(this._targetImage).offset(),o=this._left=n.left-R.default(window).scrollLeft(),s=this._top=n.top-R.default(window).scrollTop();t.css({left:o,top:s,width:this._targetImage.width,height:this._targetImage.height}),this._zoomOriginal()}.bind(this),e.src=this._targetImage.src,this.$zoomedImage=t},Qt.prototype._zoomOriginal=function(){var e,t,n;this.$zoomedImage.addClass("zoom-img").attr("data-action","zoom-out"),R.default(this._targetImage).css("visibility","hidden"),this._backdrop=document.createElement("div"),this._backdrop.className="zoom-backdrop",null===(e=document.body)||void 0===e||e.appendChild(this._backdrop),this._overlay=document.createElement("div"),this._overlay.className="zoom-overlay",null===(t=document.body)||void 0===t||t.appendChild(this._overlay),null===(n=this._overlay)||void 0===n||n.appendChild(this.$zoomedImage[0]),this._calculateZoom(),this._triggerAnimation()},Qt.prototype._calculateZoom=function(){const e=this._fullWidth,t=this._fullHeight,n=window.innerHeight-this.getOffset(),o=window.innerWidth-this.getOffset(),s=e/this._targetImage.width,i=e/t,r=o/n;this._imgScaleFactor=e<o&&t<n?s:i<r?n/t*s:o/(null!=e?e:0)*s},Qt.prototype._triggerAnimation=function(){const e=R.default(window).scrollTop()+window.innerHeight/2,t=R.default(window).scrollLeft()+window.innerWidth/2,n=this._imgScaleFactor,o=this._imageOffset.top+this._targetImage.height/2,s=this._imageOffset.left+this._targetImage.width/2;this._translateY=(e-o)/n,this._translateX=(t-s)/n,this._zoomedInTransformString="\n scale(".concat(n,")\n translate3d(").concat(this._translateX,"px, ").concat(this._translateY,"px, 0)\n "),this.$zoomedImage.css({transform:this._zoomedInTransformString}).addClass("zoom-transition").one(R.default.support.transition.end,R.default.proxy(this._onZoomInFinish,this)).emulateTransitionEnd(300),this._$body.addClass("zoom-overlay-open")},Qt.prototype._onZoomInFinish=function(){const e=this._targetImage.height*this._imgScaleFactor,t=this._targetImage.width*this._imgScaleFactor;let n=0,o=0,s=0,i=0,r=0,a=0;t<window.innerWidth?(n="50%",s=-t/2):r=(t-window.innerWidth)/2,e<window.innerHeight?(o="50%",i=-e/2):a=(e-window.innerHeight)/2,this.$zoomedImage.css({height:e,left:n,marginLeft:s,marginTop:i,top:o,transform:"",width:t}).removeClass("zoom-transition"),R.default(this._overlay).scrollLeft(r).scrollTop(a)},Qt.prototype.close=function(){this._$body.removeClass("zoom-overlay-open").addClass("zoom-overlay-transitioning"),this.$zoomedImage.css({height:this._targetImage.height,left:this._left,marginLeft:0,marginTop:0,top:this._top,transform:this._zoomedInTransformString,width:this._targetImage.width}).removeClass("zoom-transition"),R.default(this._overlay).scrollLeft(0).scrollTop(0),setTimeout((()=>{this.$zoomedImage.css({transform:"scale(1)"}).addClass("zoom-transition").one(R.default.support.transition.end,R.default.proxy(this.dispose,this)).emulateTransitionEnd(300)}),10)},Qt.prototype.dispose=function(){this.$zoomedImage&&this.$zoomedImage[0].parentNode&&(this.$zoomedImage.remove(),this.$zoomedImage=null,this._overlay.parentNode.removeChild(this._overlay),this._backdrop.parentNode.removeChild(this._backdrop),this._$body.removeClass("zoom-overlay-transitioning")),R.default(this._targetImage).css("visibility","visible"),this._targetImage.focus()};const en=new Jt,tn=F.default({displayName:"FixedToResponsive",propTypes:{width:I.default.number.isRequired,height:I.default.number.isRequired,className:I.default.string,constrainHeight:I.default.bool,allowFullBleed:I.default.bool},getDefaultProps:function(){return{className:"",constrainHeight:!1,allowFullBleed:!1}},getInitialState:function(){return{viewportHeight:null,viewportWidth:null}},componentDidMount:function(){this._isMounted=!0,window.innerHeight<480?setTimeout(this._cacheViewportSize,800):this._cacheViewportSize()},componentWillUnmount:function(){this._isMounted=!1},_cacheViewportSize:function(){this._isMounted&&this.setState({viewportHeight:Math.max(480,window.innerHeight),viewportWidth:window.innerWidth})},render:function(){const e=this.props.width/this.props.height,t=_.createElement("div",{style:{paddingBottom:100*(1/e).toFixed(4)+"%"}});let{width:n,height:o}=this.props;if(this.props.constrainHeight&&this.state.viewportHeight){const t=2/3*this.state.viewportHeight;this.props.height>=t&&(o=t,n=t*e)}const s={maxWidth:n,maxHeight:o},i=E.default("fixed-to-responsive",this.props.className),r=_.createElement("div",{className:i,style:s},t,this.props.children);return this.props.allowFullBleed&&this.state.viewportWidth&&n>=this.state.viewportWidth?_.createElement("div",{style:{marginLeft:-16,marginRight:-16}},r):r}});function nn(e,t){return e+":"+t}const on={_fireEvent:function(e,t,n){M.default.invoke(e,"call",this,t,n)},_applyConstraints:function(e,t,n){let o=!1;return M.default.reduce(this.state.constraints,((e,s)=>{if(!1===e)return!1;if(o)return e;const i=s.call(this,e,t,{onSkipRemaining:()=>{o=!0},...n});if(!1===i)return!1;if(d.point.is(i,2))return i;if(!0===i||null==i)return e;throw new re("Constraint returned invalid result: "+i,se.Internal)}),e,this)},draw:function(){const e=this.cloneState();on._fireEvent.call(this,this.state.draw,e,this.prevState),this.prevState=e},listen:function(e,t,n){this._listenerMap=this._listenerMap||{};const o=nn(e,t),s=this._listenerMap[o]=this._listenerMap[o]||this.state[e].length;this.state[e][s]=n},unlisten:function(e,t){this._listenerMap=this._listenerMap||{};const n=nn(e,t),o=this._listenerMap[n];if(void 0!==o){this.state[e].splice(o,1),delete this._listenerMap[n];const t=M.default.keys(this._listenerMap);M.default.each(t,(function(t){(function(e){return e.split(":")[0]})(t)===e&&this._listenerMap[t]>o&&this._listenerMap[t]--}),this)}}};let sn=null;let rn=null;const an={assert:function(e,t){if(!e)throw new re("Assertion Error"+(t?": "+t:""),se.Internal)},createGettersFor:function(e,t){M.default.each(M.default.keys(t),(function(t){void 0===e.prototype[t]&&(e.prototype[t]=function(){return this.state[t]})}))},addMovableHelperMethodsTo:function(e){M.default.each(on,(function(t,n){void 0===e.prototype[n]&&(e.prototype[n]=t)}))},arrayify:function(e){return null==e?[]:M.default.isArray(e)?M.default.filter(M.default.flatten(e),M.default.identity):[e]},normalizeOptions:function(e,t){const n=M.default.clone(t);return M.default.each(e,(function(e){const o=t[e];if(void 0!==o){const t=an.arrayify(o);n[e]=t}})),n},getPrefixedTransform:function(){return sn=sn||function(){const e=document.createElement("div");let t=null;return M.default.each(["transform","msTransform","MozTransform","WebkitTransform","OTransform"],(function(n){void 0!==e.style[n]&&(t=n)})),t}(),sn},getCanUse3dTransform:function(){return null==rn&&(rn=function(){const e=document.createElement("div"),t=an.getPrefixedTransform();return e.style[t]="translateZ(0px)",!!e.style[t]}()),rn}};var ln="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function cn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pn={exports:{}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@khanacademy/kas"),t=require("@khanacademy/math-input"),n=require("@khanacademy/wonder-blocks-i18n"),s=require("classnames"),o=require("react"),i=require("underscore"),r=require("prop-types"),a=require("@khanacademy/simple-markdown"),l=require("aphrodite"),c=require("react-dom"),p=require("jquery"),d=require("@khanacademy/kmath"),h=require("create-react-class"),u=require("mathquill"),f=require("@khanacademy/wonder-blocks-color"),m=require("@khanacademy/wonder-blocks-typography");require("intersection-observer");var g=require("@khanacademy/wonder-blocks-core"),v=require("@khanacademy/wonder-blocks-spacing"),b=require("@khanacademy/wonder-blocks-tooltip"),y=require("@khanacademy/wonder-blocks-dropdown"),x=require("@khanacademy/wonder-blocks-button"),C=require("lodash.debounce"),w=require("@khanacademy/wonder-blocks-popover"),k=require("@khanacademy/wonder-blocks-progress-spinner"),S=require("@khanacademy/wonder-blocks-layout"),E=require("@khanacademy/wonder-blocks-link");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function M(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var T=M(e),I=M(n),P=_(s),A=M(o),N=_(i),R=_(r),F=_(a),D=_(c),O=M(c),L=_(p),B=_(h),z=_(u),q=_(f),H=_(v),W=_(b),U=_(x),G=_(C),V=_(E),j={major:11,minor:0},Y={major:0,minor:1};function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $(){return $=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},$.apply(this,arguments)}const K=e=>{let{path:t,width:n,height:s,style:o={},title:i}=e;return A.createElement("svg",{role:"img","aria-hidden":!i,style:{verticalAlign:"middle",...o},width:"".concat(n/s,"em"),height:"1em",viewBox:"0 0 ".concat(n," ").concat(s)},!!i&&A.createElement("title",null,i),A.createElement("path",{d:t,fill:"currentColor"}))};K.propTypes={path:R.default.string.isRequired,height:R.default.number.isRequired,width:R.default.number.isRequired,style:R.default.object,title:R.default.string};const Z="'Proxima Nova Semibold',sans-serif",J="#FFFFFF",Q="#BABEC2",ee="#888D93",te="#21242c",ne={defaultBoxSize:400,defaultBoxSizeSmall:288};var se=Object.freeze({__proto__:null,baseFontFamily:"'Proxima Nova',sans-serif",boldFontFamily:Z,green:"#76A005",kaGreen:"#71B307",blue:"#1C758A",gray:"#AAAAAA",red:"#FFBABA",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",learnstormBlue:"#4898FC",white:J,gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:Q,gray68:ee,gray41:"#626569",gray25:"#3B3e40",gray17:te,black:"#000000",warning1:"#F86700",warning3:"#C75300",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1280px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1279px",tableBackgroundAccent:"#F9F9F9",gtpBlue:"#4c00ff",gtpIncorrectColor:"#babec2",gtpCorrectColor:"#ffbe26",satBlue:"#0084CE",satSelectedBackgroundColor:"#E4F3F9",satActiveBackgroundColor:"#D0EDF4",satCorrectColor:"#009900",satCorrectBorderColor:"#00CC00",satCorrectBackgroundColor:"#E4F7E4",satIncorrectColor:"#990000",satIncorrectBorderColor:"#CC5252",satIncorrectBackgroundColor:"#F2EBEB",zIndexScratchPad:1,zIndexAboveScratchpad:2,zIndexInteractiveComponent:3,zIndexCurrentlyDragging:4,zIndexCalculator:5,phoneMargin:16,negativePhoneMargin:-16,hintBorderWidth:4,baseUnitPx:16,interactiveSizes:ne,circleSize:24,radioMarginWidth:2,warningColor:"#f86700",warningColorHover:"#df5c00",warningColorActive:"#c75300",publishBlockingErrorColor:"#be2612",radioBorderColor:"#BABEC2",checkedColor:"#71B307",articleMaxWidthInPx:688,articleMaxWidthTableInPx:512});const oe={path:"M6 11a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm0-9a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z",height:12,width:12};class ie extends A.Component{constructor(){super(...arguments),X(this,"_positionTimeout",void 0),X(this,"state",{tooltipAbove:!0}),X(this,"getPosition",(()=>{const e=D.default.findDOMNode(this).getBoundingClientRect();this.setState({tooltipAbove:e.top>100})})),X(this,"renderLink",(e=>{const t=this.state.tooltipAbove;let n,s,o;return 1===this.props.severity?(n=re.indicatorError,s="Error",o=re.publishBlockingError):2===this.props.severity?(n=re.indicatorWarning,s="Warning",o=re.warning):(n=re.indicatorGuideline,s="Recommendation",o=re.warning),A.createElement("a",{href:"https://khanacademy.org/r/linter-rules#".concat(this.props.ruleName),target:"lint-help-window",className:l.css(e)},A.createElement("span",{className:l.css(re.indicator,n)},1===this.props.severity&&A.createElement(K,oe)),A.createElement("div",{className:l.css(re.tooltip,t&&re.tooltipAbove)},this.props.message.split("\n\n").map(((e,t)=>A.createElement("p",{key:t,className:l.css(re.tooltipParagraph)},A.createElement("span",{className:l.css(o)},s,":"," "),e))),A.createElement("div",{className:l.css(re.tail,t&&re.tailAbove)})))}))}componentDidMount(){this._positionTimeout=window.setTimeout(this.getPosition)}componentWillUnmount(){window.clearTimeout(this._positionTimeout)}render(){const{children:e,inline:t,blockHighlight:n,insideTable:s}=this.props;return s?t?A.createElement("span",{"data-lint-inside-table":"true"},e):A.createElement("div",{"data-lint-inside-table":"true"},e):n?A.createElement("span",{className:l.css(re.lintContainer,re.lintContainerBlock)},this.renderLink(re.radioWidgetHoverTarget),A.createElement("span",null,e)):t?A.createElement("span",{className:l.css(re.lintContainer)},this.renderLink(re.inlineHoverTarget),A.createElement("span",null,e)):A.createElement("div",{className:l.css(re.lintContainer)},this.renderLink(re.hoverTarget),A.createElement("div",null,e))}}X(ie,"propTypes",{children:R.default.node,inline:R.default.bool,message:R.default.string.isRequired,ruleName:R.default.string.isRequired,insideTable:R.default.bool.isRequired,blockHighlight:R.default.bool,severity:R.default.number});const re=l.StyleSheet.create({lintContainer:{position:"relative"},lintContainerBlock:{display:"block"},hoverTarget:{position:"absolute",top:0,right:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ div":{outline:"1px solid #f86700"},":hover ~ div div[data-lint-inside-table]":{outline:"1px solid #f86700"},":hover ~ div span[data-lint-inside-table]":{backgroundColor:"#f86700",color:J}},inlineHoverTarget:{float:"right",position:"relative",marginRight:-40,display:"block",width:24,height:24,":hover > span":{backgroundColor:"#df5c00"},":hover div":{display:"block"},":hover ~ span":{backgroundColor:"#f86700",color:J}},radioWidgetHoverTarget:{position:"absolute",left:-40,display:"block",width:24,height:24,minWidth:264,":hover > span":{backgroundColor:"#df5c00"},":hover > div":{display:"block",padding:8,width:280},":hover > div > div":{left:8},":hover ~ span":{backgroundColor:"#f86700",color:J}},indicator:{alignItems:"center",borderRadius:4,color:"white",display:"flex",fontSize:12,height:8,justifyContent:"center",margin:8,width:8},indicatorError:{backgroundColor:"#be2612",borderRadius:8,height:16,width:16},indicatorWarning:{backgroundColor:"#f86700"},indicatorGuideline:{backgroundColor:"#ffbe26"},tooltip:{position:"absolute",right:-12,display:"none",zIndex:1e3,color:J,backgroundColor:te,opacity:.9,fontFamily:"'Proxima Nova',sans-serif",fontSize:"12px",lineHeight:"15px",width:"320px",borderRadius:"4px"},tooltipAbove:{bottom:32},tail:{position:"absolute",top:-12,right:16,width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:"12px solid #21242c"},tailAbove:{bottom:-12,borderBottom:"none",borderTop:"12px solid #21242c",top:"auto"},tooltipParagraph:{margin:12},warning:{color:"#f86700",fontFamily:Z},publishBlockingError:{color:"#be2612"}});let ae=null;const le=()=>{if(ae)return ae;throw new Error(["Perseus has not been provided required dependencies.","setDependencies(dependencies) must be called first.","Make sure Perseus is being imported from javascript/perseus/perseus.js."].join("\n"))};var ce=Object.freeze({__proto__:null,setDependencies:e=>{ae=e},getDependencies:le});const pe=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"}),de={log:(e,t)=>{le().Log.log(e,t)},error:(e,t,n)=>{le().Log.error(e,t,n)}};class he extends Error{constructor(e,t,n){super(e),X(this,"kind",void 0),X(this,"metadata",void 0),this.kind=t,this.metadata=null==n?void 0:n.metadata}}const ue={cleanMath:function(e){return"string"==typeof e?e.replace(/\+\s*-/g,"- ").replace(/-\s*-/g,"+ ").replace(/\^1/g,""):e},bound:function(e){return 0===e?e:e<0?-ue.bound(-e):Math.max(1e-6,Math.min(e,1e20))},factorial:function(e){return e<=1?e:e*ue.factorial(e-1)},getGCD:function(e,t){if(arguments.length>2){const t=[].slice.call(arguments,1);return ue.getGCD(e,ue.getGCD(...t))}let n;for(e=Math.abs(e),t=Math.abs(t);t;)n=e%t,e=t,t=n;return e},getLCM:function(e,t){if(arguments.length>2){const t=[].slice.call(arguments,1);return ue.getLCM(e,ue.getLCM(...t))}return Math.abs(e*t)/ue.getGCD(e,t)},primes:[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97],isPrime:function(e){if(e<=1)return!1;if(e<101)return!!L.default.grep(ue.primes,(function(t,n){return Math.abs(t-e)<=.5})).length;if(e<=1||e>2&&e%2==0)return!1;for(let t=3,n=Math.sqrt(e);t<=n;t+=2)if(e%t==0)return!1;return!0},getPrimeFactorization:function(e){if(1===e)return[];if(ue.isPrime(e))return[e];const t=Math.sqrt(e);for(let n=2;n<=t;n++)if(e%n==0)return L.default.merge(ue.getPrimeFactorization(n),ue.getPrimeFactorization(e/n))},roundToNearest:function(e,t){return Math.round(t/e)*e},roundTo:function(e,t){const n=Math.pow(10,e).toFixed(5);return Math.round((t*n).toFixed(5))/n},toFixedApprox:function(e,t){const n=e.toFixed(t);return d.number.equal(+n,e)?n:"\\approx "+n},roundToApprox:function(e,t){const n=ue.roundTo(t,e);return d.number.equal(n,e)?String(n):ue.toFixedApprox(e,t)},toFraction:function(e,t){if(null==t&&(t=Math.pow(2,-46)),e<0||e>1){let n=e%1;n+=n<0?1:0;const s=ue.toFraction(n,t);return s[0]+=Math.round(e-n)*s[1],s}if(Math.abs(Math.round(Number(e))-e)<=t)return[Math.round(e),1];let n=0,s=1,o=1,i=1,r=1,a=2;for(;;){if(Math.abs(Number(r/a)-e)<=t)return[r,a];r/a<e?(n=r,s=a):(o=r,i=a),r=n+o,a=s+i}},getNumericFormat:function(e){if((e=(e=L.default.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1")).match(/^[+-]?\d+$/))return"integer";if(e.match(/^[+-]?\d+\s+\d+\s*\/\s*\d+$/))return"mixed";const t=e.match(/^[+-]?(\d+)\s*\/\s*(\d+)$/);return t?parseFloat(t[1])>parseFloat(t[2])?"improper":"proper":e.replace(/[,. ]/g,"").match(/^\d+$/)?"decimal":e.match(/(pi?|\u03c0|t(?:au)?|\u03c4|pau)/)?"pi":null},toNumericString:function(e,t){if(null==e)return"";if(0===e)return"0";if("percent"===t)return 100*e+"%";if("pi"===t){const t=d.number.toFraction(e/Math.PI),n=Math.abs(t[0]),s=t[1];if(d.number.isInteger(n)){return(e<0?"-":"")+(1===n?"":n)+"π"+(1===s?"":"/"+s)}}if(N.default(["proper","improper","mixed","fraction"]).contains(t)){const n=d.number.toFraction(e),s=Math.abs(n[0]),o=n[1],i=e<0?"-":"";if(1===o)return i+s;if("mixed"===t){const e=s%o,t=(s-e)/o;return i+(t?t+" ":"")+e+"/"+o}return i+s+"/"+o}return String(e)}},fe=Math.pow(2,-42),me={APPROXIMATED_PI_ERROR:I._("Your answer is close, but you may have approximated pi. Enter your answer as a multiple of pi, like <code>12\\ \\text{pi}</code> or <code>2/3\\ \\text{pi}</code>"),EXTRA_SYMBOLS_ERROR:I._("We could not understand your answer. Please check your answer for extra text or symbols."),NEEDS_TO_BE_SIMPLFIED_ERROR:I._("Your answer is almost correct, but it needs to be simplified."),MISSING_PERCENT_ERROR:I._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end."),MULTIPLICATION_SIGN_ERROR:I._("I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign."),WRONG_CASE_ERROR:I._("Your answer includes use of a variable with the wrong case."),WRONG_LETTER_ERROR:I._("Your answer includes a wrong variable letter.")},ge={predicate:{defaultForms:"integer, proper, improper, mixed, decimal",createValidatorFunctional:function(e,t){let n;t=N.default.extend({simplify:"required",ratio:!1,forms:ge.predicate.defaultForms},t),n=N.default.isArray(t.forms)?t.forms:t.forms.split(/\s*,\s*/),void 0===t.inexact&&(t.maxError=0),t.maxError=+t.maxError+fe,N.default.contains(n,"percent")&&(n=N.default.without(n,"percent"),n.push("percent"));const s=function(e){const n=(e=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").replace(/(^\s*)|(\s*$)/gi,"")).match(/^([+-]?\d+)\s*\/\s*([+-]?\d+)$/),s=e.match(/^([+-]?)\\frac\{([+-]?\d+)\}\{([+-]?\d+)\}$/),o=parseInt(e,10);if(n||s){let e,o,i=!0;return n?(e=parseFloat(n[1]),o=parseFloat(n[2])):(e=parseFloat(s[2]),"-"===s[1]&&(e<0&&(i=!1),e=-e),o=parseFloat(s[3])),i=i&&o>0&&(t.ratio||1!==o)&&1===ue.getGCD(e,o),[{value:e/o,exact:i}]}return isNaN(o)||""+o!==e?[]:[{value:o,exact:!0}]},o={integer:function(e){const t=o.decimal(e),n=o.decimal(e,1);return null!=t[0].value&&t[0].value===n[0].value||null!=t[1].value&&t[1].value===n[1].value?t:[]},proper:function(e){return L.default.map(s(e),(function(e){return Math.abs(e.value)<1?[e]:[]}))},improper:function(e){return L.default.map(s(e),(function(e){return Math.abs(e.value)>=1?[e]:[]}))},pi:function(e){let t,n=[];if(t=(e=e.replace(/\u2212/,"-")).match(/^([+-]?)\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=[{value:parseFloat(t[1]+"1"),exact:!0}];else if(t=e.match(/^([+-]?\s*\d+\s*(?:\/\s*[+-]?\s*\d+)?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))n=s(t[1]);else if(t=e.match(/^([+-]?)\s*(\d+)\s*([+-]?\d+)\s*\/\s*([+-]?\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i)){const e=parseFloat(t[1]+"1"),s=parseFloat(t[2]),o=parseFloat(t[3]),i=parseFloat(t[4]);n=[{value:e*(s+o/i),exact:o<i&&1===ue.getGCD(o,i)}]}else if(t=e.match(/^([+-]?\s*\d+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\s*\d+))?$/i))n=s(t[1]+"/"+t[3]);else if(t=e.match(/^([+-]?)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)\s*(?:\/\s*([+-]?\d+))?$/i))n=s(t[1]+"1/"+t[3]);else if("0"===e)n=[{value:0,exact:!0}];else{if(!(t=e.match(/^(.+)\s*\*?\s*(\\?pi|p|\u03c0|\\?tau|t|\u03c4|pau)$/i))){n=N.default.reduce(ge.predicate.defaultForms.split(/\s*,\s*/),(function(t,n){return t.concat(o[n](e))}),[]);let t=!1;const s=parseFloat(e);if(isNaN(s)||s===parseInt(e))e.match(/\/\s*7/)&&(t=!0);else{const e=Math.PI/12,n=e*Math.round(s/e);Math.abs(s-n)<.01&&(t=!0)}return t&&N.default.each(n,(function(e){e.piApprox=!0})),n}n=o.decimal(t[1])}let i=Math.PI;return e.match(/\\?tau|t|\u03c4/)&&(i=2*Math.PI),e.match(/pau/)&&(i=1.5*Math.PI),L.default.each(n,(function(e,t){t.value*=i})),n},coefficient:function(e){let t=[];return""===(e=e.replace(/\u2212/,"-"))?t=[{value:1,exact:!0}]:"-"===e&&(t=[{value:-1,exact:!0}]),t},log:function(e){let t,n=[];return(t=(e=(e=e.replace(/\u2212/,"-")).replace(/[ \(\)]/g,"")).match(/^log\s*(\S+)\s*$/i))?n=o.decimal(t[1]):"0"===e&&(n=[{value:0,exact:!0}]),n},percent:function(e){e=L.default.trim(e);let t=!1;e.indexOf("%")===e.length-1&&(e=L.default.trim(e.substring(0,e.length-1)),t=!0);const n=o.decimal(e);return L.default.each(n,(function(e,n){n.exact=t,n.value=n.value/100})),n},mixed:function(e){const t=e.replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?)(\d+)\s+(\d+)\s*\/\s*(\d+)$/);if(t){const e=parseFloat(t[1]+"1"),n=parseFloat(t[2]),s=parseFloat(t[3]),o=parseFloat(t[4]);return[{value:e*(n+s/o),exact:s<o&&1===ue.getGCD(s,o)}]}return[]},decimal:function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e10;const s=function(e){const s=(e=L.default.trim(e)).replace(/\u2212/,"-").replace(/([+-])\s+/g,"$1").match(/^([+-]?(?:\d{1,3}(?:[, ]?\d{3})*\.?|\d{0,3}(?:[, ]?\d{3})*\.(?:\d{3}[, ]?)*\d{1,3}))$/),o=e.match(/^0[0,]*,/);if(s&&!o){let e=parseFloat(s[1].replace(/[, ]/g,""));return void 0===t.inexact&&(e=Math.round(e*n)/n),e}},o=function(e){return e=e.replace(/([\.,])/g,(function(e,t){return"."===t?",":"."})),s(e)};return[{value:s(e),exact:!0},{value:o(e),exact:!0}]}};return function(s){const i=null!=t.fallback?""+t.fallback:"",r={empty:""===(s=L.default.trim(s)||i),correct:!1,message:null,guess:s};if(L.default.each(n,(function(n,i){const a=o[i](s);for(let n=0,s=a.length;n<s;n++){const s=a[n].value,o=a[n].exact,l=a[n].piApprox;if(e(s,t.maxError))return o||"optional"===t.simplify?(r.correct=!0,r.message=t.message||null,r.empty=!1):"percent"===i?(r.empty=!0,r.message=me.MISSING_PERCENT_ERROR):("enforced"!==t.simplify&&(r.empty=!0),r.message=me.NEEDS_TO_BE_SIMPLFIED_ERROR),!1;l&&e(s,Math.abs(.001*s))&&(r.empty=!0,r.message=me.APPROXIMATED_PI_ERROR)}})),!1===r.correct){let e=!1;if(N.default.each(o,(function(t){N.default.any(t(s),(function(e){return null!=e.value&&!N.default.isNaN(e.value)}))&&(e=!0)})),!e)return r.empty=!0,r.message=me.EXTRA_SYMBOLS_ERROR,r}return r}}},number:{convertToPredicate:function(e,t){const n=parseFloat(L.default.trim(e));return[function(e,t){return Math.abs(e-n)<t},L.default.extend({},t,{type:"predicate"})]},createValidatorFunctional:function(e,t){return ge.predicate.createValidatorFunctional(...ge.number.convertToPredicate(e,t))}},expression:{parseSolution:function(e,t){let n=T.parse(e,t);if(!n.parsed)throw new he("The provided solution ("+e+") didn't parse.",pe.InvalidInput);if(t.simplified&&!n.expr.isSimplified())throw new he("The provided solution ("+e+") isn't fully expanded and simplified.",pe.InvalidInput);return n=n.expr,n},createValidatorFunctional:function(e,t){return function(n){const s={empty:!1,correct:!1,message:null,guess:n,ungraded:!1};if(!n)return s.empty=!0,s;const o=T.parse(n,t);if(!o.parsed)return s.empty=!0,s;"string"==typeof e&&(e=ge.expression.parseSolution(e,t));const i=T.compare(o.expr,e,t);if(i.equal)s.correct=!0;else if(i.wrongVariableNames||i.wrongVariableCase)s.ungraded=!0,s.message=i.wrongVariableCase?me.WRONG_CASE_ERROR:me.WRONG_LETTER_ERROR,s.suppressAlmostThere=!0;else if(i.message)s.message=i.message;else{const o=T.parse(n.replace(/[xX]/g,"*"),t);if(o.parsed){const n=T.compare(o.expr,e,t);n.equal?(s.ungraded=!0,s.message=me.MULTIPLICATION_SIGN_ERROR):n.message&&(s.message=n.message+" Also, I'm a computer. I only understand multiplication if you use an asterisk (*) as the multiplication sign.")}}return s}}}};let ve=!1;const be=/^web\+graphie:/,ye=/^file\+graphie:/,xe=function(e,t,n){return Array.isArray(e)?N.default.map(e,(function(e){return xe(e,t)})):t.call(n,e)};const Ce=/^\[\[\u2603 (([a-z-]+) ([0-9]+))\]\]/,we=new RegExp(Ce.source+"$"),ke=function(e){let t=e;return function(){let e=t;return e=e+2127912214+(e<<12)&4294967295,e=4294967295&(3345072700^e^e>>>19),e=e+374761393+(e<<5)&4294967295,e=4294967295&(e+3550635116^e<<9),e=e+4251993797+(e<<3)&4294967295,e=4294967295&(3042594569^e^e>>>16),(t=268435455&e)/268435456}};const Se="x".split(/(.)/g).length?function(e,t){return e.split(t)}:function(e,t){const n=[];let s,o=t.lastIndex=0;for(;s=t.exec(e);){const t=s;n.push(e.slice(o,t.index)),n.push(...t.slice(1)),o=t.index+t[0].length}return n.push(e.slice(o)),n};function Ee(e,t){const n=e*t,s=e,o=Math.pow(10,Math.floor(Math.log(s)/Math.LN10)),i=Math.floor(s/o);return n<25?e:n<50?5===i?e:e/2:1===i?e/2:2===i?e/4:5===i?e/5:void 0}function _e(e,t){return t/(e[1]-e[0])}function Me(e,t){let n=Math.pow(10,Math.floor(Math.log(e/t)/Math.LN10));const s=t/e*n;return s<=.15?n*=10:s<=.35?n*=5:s<=.75&&(n*=2),n}const Te=(e,t)=>{const n=t[1]-t[0],s=n/e;return s<=10?e:s<=20?2*e:Me(n,10)};const Ie={UNSAFE_componentWillMount:function(){const e={};N.default.each(this.deprecatedProps,(function(t,n){N.default.has(this.props,n)&&N.default.extend(e,t(this.props))}),this),N.default.isEmpty(e)||(N.default.extend(this.props,e),setTimeout(this.props.onChange,0,e))}};function Pe(e,t){return"number"==typeof e&&"number"==typeof t?Math.abs(e-t)<1e-9:e===t}const Ae={pointerDown:!1,currentTouchIdentifier:null};function Ne(e){return Re(e)?De(e):e}function Re(e){return be.test(e)||ye.test(e)}function Fe(e){return e.replace(be,"https:").replace(ye,"file:")}function De(e){return Fe(e)+".svg"}const Oe={getWordBeforeCursor:function(e){const t=e.value,n=e.selectionStart-1,s=Math.max(t.lastIndexOf("\n",n),t.lastIndexOf(" ",n))+1;return{string:t.substring(s,n+1),pos:{start:s,end:n}}},moveCursor:function(e,t){e.selectionStart=t,e.selectionEnd=t}},Le=ke(4294967295&(new Date).getTime()),Be={inputPathsEqual:function(e,t){return null==e||null==t?null==e==(null==t):e.length===t.length&&e.every(((e,n)=>t[n]===e))},nestedMap:xe,rWidgetRule:Ce,rTypeFromWidgetId:/^([a-z-]+) ([0-9]+)$/,rWidgetParts:we,snowman:"☃",noScore:{type:"points",earned:0,total:0,message:null},seededRNG:ke,shuffle:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=N.default.clone(e);if(!s.length||N.default.all(s,(function(e){return N.default.isEqual(e,s[0])})))return s;let o;o="function"==typeof t?t:ke(t);do{for(let e=s.length;e>0;e--){const t=Math.floor(o()*e),n=s[t];s[t]=s[e-1],s[e-1]=n}}while(n&&N.default.isEqual(e,s));return s},split:Se,combineScores:function(e,t){let n;if("points"===e.type&&"points"===t.type)return n=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"points",earned:e.earned+t.earned,total:e.total+t.total,message:n};if("points"===e.type&&"invalid"===t.type)return t;if("invalid"===e.type&&"points"===t.type)return e;if("invalid"===e.type&&"invalid"===t.type)return n=e.message&&t.message&&e.message!==t.message?null:e.message||t.message,{type:"invalid",message:n};throw new he("PerseusScore with unknown type encountered",pe.InvalidInput,{metadata:{scoreA:JSON.stringify(e),scoreB:JSON.stringify(t)}})},keScoreFromPerseusScore:function(e,t,n){if("points"===e.type)return{empty:!1,correct:e.earned>=e.total,message:e.message,guess:t,state:n};if("invalid"===e.type)return{empty:!0,correct:!1,message:e.message,suppressAlmostThere:e.suppressAlmostThere,guess:t,state:n};throw new he("Invalid score type: "+e.type,pe.InvalidInput,{metadata:{score:JSON.stringify(e),guess:JSON.stringify(t),state:JSON.stringify(n)}})},firstNumericalParse:function(e){let t;return ge.predicate.createValidatorFunctional((function(e){return t=e,!0}),{simplify:"optional",inexact:!0,forms:"integer, proper, improper, pi, log, mixed, decimal"})(e),t},stringArrayOfSize:function(e){return N.default(e).times((function(){return""}))},gridDimensionConfig:function(e,t,n,s){const o=_e(t,n);return{scale:o,tickStep:e/s,unityLabel:e*o>30}},getGridStep:function(e,t,n){return N.default(2).times((function(s){const o=_e(e[s],n);return Ee(t[s],o)}))},snapStepFromGridStep:function(e){return[e[0]/2,e[1]/2]},scaleFromExtent:_e,tickStepFromExtent:function(e,t){const n=e[1]-e[0];let s;return s=15<n&&n<=20?23:n>100||n<5?10:16,Me(n,s*(t/500))},gridStepFromTickStep:Ee,tickStepFromNumTicks:Me,constrainedTickStepsFromTickSteps:function(e,t){return[Te(e[0],t[0]),Te(e[1],t[1])]},DeprecationMixin:Ie,eq:Pe,deepEq:function e(t,n){if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(!e(t[s],n[s]))return!1;return!0}return!Array.isArray(t)&&!Array.isArray(n)&&("function"==typeof t&&"function"==typeof n?Pe(t,n):"function"!=typeof t&&"function"!=typeof n&&("object"==typeof t&&"object"==typeof n&&t&&n?t===n||N.default.all(t,(function(t,s){return e(n[s],t)}))&&N.default.all(n,(function(n,s){return e(t[s],n)})):!("object"==typeof t&&t||"object"==typeof n&&n)&&Pe(t,n)))},parseQueryString:function(e){e=e||window.location.search.substring(1);const t={},n=/\+/g,s=/([^&=]+)=?([^&]*)/g,o=function(e){return decodeURIComponent(e.replace(n," "))};let i;for(;i=s.exec(e);){const e=i;t[o(e[1])]=o(e[2])}return t},updateQueryString:function(e,t,n){n=encodeURIComponent(n);const s=new RegExp("([?&])"+t+"=.*?(&|$)","i"),o=-1!==e.indexOf("?")?"&":"?";return e.match(s)?e.replace(s,"$1"+t+"="+n+"$2"):e+o+t+"="+n},strongEncodeURIComponent:function(e){return encodeURIComponent(e).replace(/['()!]/g,window.escape).replace(/\*/g,"%2A")},widgetShouldHighlight:function(e){if(!e)return!1;switch(e.type){case"measurer":case"protractor":return!0;default:return!1}},scoreIsEmpty:function(e){return"invalid"===e.type&&(!e.message||0===e.message.length)},touchHandlers:Ae,resetTouchHandlers:function(){Object.assign(Ae,{pointerDown:!1,currentTouchIdentifier:null})},extractPointerLocation:function(e){let t;if(Ae.pointerDown){if(null!=Ae.currentTouchIdentifier){const n=e.changedTouches?e.changedTouches.length:0;for(let s=0;s<n;s++)e.changedTouches[s].identifier===Ae.currentTouchIdentifier&&(t=e.changedTouches[s])}else t=e;const n="touchend"===e.type||"touchcancel"===e.type;t&&n&&(Ae.pointerDown=!1,Ae.currentTouchIdentifier=null)}else Ae.pointerDown=!0,e.changedTouches?(t=e.changedTouches[0],Ae.currentTouchIdentifier=t.identifier):t=e;if(t)return{left:t.pageX,top:t.pageY}},supportsPassiveEvents:()=>{try{const e=Object.defineProperty({},"passive",{get:function(){ve=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(e){}return ve},captureScratchpadTouchStart:function(e){e.stopPropagation()},getImageSize:function(e,t){const n=new Image;n.onload=function(){var e;0===n.width&&0===n.height?(null===(e=document.body)||void 0===e||e.appendChild(n),N.default.defer((function(){var e;t(n.clientWidth,n.clientHeight),null===(e=document.body)||void 0===e||e.removeChild(n)}))):t(n.width,n.height)},n.src=Ne(e)},getRealImageUrl:Ne,isLabeledSVG:Re,getBaseUrl:Fe,getSvgUrl:De,getDataUrl:function(e){return Fe(e)+"-data.json"},textarea:Oe,unescapeMathMode:e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e,random:Le},ze=(e,t,n)=>{const s=e.length;let o=0;if(n){if(t.inline)return null;for(;o<s&&" "===e[o];)o++}if(!(o<s&&"$"===e[o]))return null;o++;const i=o;let r=0;for(;o<s;){const t=e[o];if("\\"===t)o++;else{if(r<=0&&"$"===t){let t=o+1;if(n){const n=/^(?: *\n){2,}/.exec(e.slice(t));t=n?t+n[0].length:null}return t?[e.substring(0,t),e.substring(i,o)]:null}if("{"===t)r++;else if("}"===t)r--;else if("\n"===t&&"\n"===e[o-1])return null}o++}return null},qe=new RegExp("^\\|\\| +(.*) +\\|\\| *\\n("+F.default.defaultRules.nptable.match.regex.source.substring(1)+")"),He=F.default.blockRegex(/^(crwdns.*)\n\s*\n/),We={...F.default.defaultRules,columns:{order:-2,match:F.default.blockRegex(/^([\s\S]*\n\n)={5,}\n\n([\s\S]*)/),parse:(e,t,n)=>({col1:t(e[1],n),col2:t(e[2],n)})},crowdinId:{order:-1,match:(e,t,n)=>t.isJipt?He(e,t,n):null,parse:(e,t,n)=>({id:e[1]})},titledTable:{order:F.default.defaultRules.nptable.order-.5,match:F.default.blockRegex(qe),parse:(e,t,n)=>{const s=F.default.parseInline(t,e[1],n),o=e.slice(2);return{title:s,table:F.default.defaultRules.nptable.parse(o,t,n)}}},widget:{order:F.default.defaultRules.link.order-.75,match:F.default.inlineRegex(Be.rWidgetRule),parse:(e,t,n)=>({id:e[1],widgetType:e[2]})},blockMath:{order:F.default.defaultRules.codeBlock.order+.5,match:(e,t)=>ze(e,t,!0),parse:(e,t,n)=>({content:e[1]})},math:{order:F.default.defaultRules.link.order-.25,match:(e,t)=>ze(e,t,!1),parse:(e,t,n)=>({content:e[1]})},unescapedDollar:{order:F.default.defaultRules.link.order-.24,match:F.default.inlineRegex(/^(?!\\)\$/),parse:(e,t,n)=>({})},fence:{...F.default.defaultRules.fence,parse:(e,t,n)=>{const s=F.default.defaultRules.fence.parse(e,t,n);return"alt"===s.lang?{type:"codeBlock",lang:"alt",content:t(s.content+"\n\n",n)}:s}},blockQuote:{...F.default.defaultRules.blockQuote,match:F.default.blockRegex(/^ *>[^\n]+(\n( *>)?[^\n]+)*\n{2,}/)},list:{...F.default.defaultRules.list,match:(e,t,n)=>t.isJipt?null:F.default.defaultRules.list.match(e,t,n)},lint:{order:1e3,match:e=>null,parse:(e,t,n)=>({})}};F.default.parserFor(We);const Ue={...We,columns:{...We.columns,react:(e,t,n)=>A.createElement("div",{className:"perseus-two-columns",key:n.key},A.createElement("div",{className:"perseus-column"},A.createElement("div",{className:"perseus-column-content"},t(e.col1,n))),A.createElement("div",{className:"perseus-column"},A.createElement("div",{className:"sat-header-grafting-area"}),A.createElement("div",{className:"perseus-column-content"},A.createElement("div",{className:"sat-skill-subscore-grafting-area"}),t(e.col2,n),A.createElement("div",{className:"sat-grafting-area"}))))},crowdinId:{...We.crowdinId,react:(e,t,n)=>e.id},table:{...We.table,react:function(e,t,n){const s=F.default.defaultRules.table.react(e,t,n);return n.isMobile?A.cloneElement(s,{tabIndex:0}):s}},titledTable:{...We.titledTable,react:(e,t,n)=>{let s;if(e.table)if("lint"===e.table.type){var o;s="table"===(null===(o=e.table.content)||void 0===o?void 0:o.type)?Ue.lint.react({...e.table,content:{...e,table:e.table.content}},t,{...n,unwrapTitledTableContents:!0}):Ue.lint.react(e.table,t,n)}else{const o=F.default.defaultRules.table.react(e.table,t,n),i=A.createElement("caption",{key:"caption",className:"perseus-table-title"},t(e.title,n));s=A.cloneElement(o,null,[i,...o.props.children])}else s="//invalid table//";return n.unwrapTitledTableContents?s:A.createElement("div",{className:"perseus-titled-table",key:n.key},s)}},widget:{...We.widget,react:(e,t,n)=>A.createElement("em",{key:n.key},I.doNotTranslate("[Widget: ",e.id,"]"))},blockMath:{...We.blockMath,react:(e,t,n)=>{const{TeX:s}=le();return A.createElement(s,{key:n.key},e.content)}},math:{...We.math,react:(e,t,n)=>{const{TeX:s}=le();return A.createElement(s,{key:n.key},e.content)}},unescapedDollar:{...We.unescapedDollar,react:(e,t,n)=>"$"},link:{...We.link,react:function(e,t,n){const s=F.default.defaultRules.link.react(e,t,n),o=s.props.href;let i=null;!!o&&o.match(/https?:\/\/[^\/]*khanacademy.org|^\//)||(i="noopener noreferrer");const r={...s.props,target:"_blank",href:o,rel:i};return n.baseElements&&n.baseElements.Link?n.baseElements.Link(r):A.cloneElement(s,r)}},codeBlock:{...We.codeBlock,react:(e,t,n)=>"alt"===e.lang?A.createElement("div",{key:n.key,className:"perseus-markdown-alt perseus-sr-only"},t(e.content,n)):F.default.defaultRules.codeBlock.react(e,t,n)},lint:{...We.lint,react:(e,t,n)=>A.createElement(ie,{message:e.message,ruleName:e.ruleName,inline:Ge(e.content),blockHighlight:e.blockHighlight,insideTable:e.insideTable,severity:e.severity},t(e.content,n))}};function Ge(e){return!!(e&&e.type&&Ve.hasOwnProperty(e.type))}const Ve={text:!0,math:!0,unescapedDollar:!0,link:!0,img:!0,strong:!0,u:!0,em:!0,del:!0,code:!0},je=F.default.parserFor(Ue),Ye=(e,t)=>je(e+"\n\n",{...t,inline:!1}),Xe=(e,t)=>{N.default.isArray(e)?N.default.each(e,(e=>Xe(e,t))):N.default.isObject(e)&&(t(e),"table"===e.type?(Xe(e.header,t),Xe(e.cells,t)):"list"===e.type?Xe(e.items,t):"titledTable"===e.type?Xe(e.table,t):"columns"===e.type?(Xe(e.col1,t),Xe(e.col2,t)):N.default.isArray(e.content)&&Xe(e.content,t))},$e=e=>{if(N.default.isArray(e))return N.default.flatten(N.default.map(e,$e));if(e.content&&N.default.isString(e.content))return-1!==e.type.toLowerCase().indexOf("code")?["",e.content,""]:[e.content.replace(/\s+/g," ")];const t=N.default.chain(e).values().flatten().filter((e=>null!=e&&N.default.has(e,"type"))).value();if(!t.length)return[];const n=$e(t);if("paragraph"===e.type&&n.length){n[0]=n[0].replace(/^\s+/,"");const e=n.length-1;n[e]=n[e].replace(/\s+$/,"")}return n};var Ke={characterCount:e=>{const t=Ye(e);return $e(t).join("").length},traverseContent:Xe,parse:Ye,parseInline:(e,t)=>je(e,{...t,inline:!0}),reactFor:F.default.reactFor,ruleOutput:F.default.ruleOutput(Ue,"react"),basicOutput:F.default.reactFor(F.default.ruleOutput(Ue,"react")),sanitizeUrl:F.default.sanitizeUrl};class Ze{static parse(e){return new Je(e).parse()}match(e){throw new he("Selector subclasses must implement match()",pe.NotAllowed)}toString(){return"Unknown selector class"}}class Je{constructor(e){X(this,"tokens",void 0),X(this,"tokenIndex",void 0),e=e.trim().replace(/\s+/g," "),this.tokens=e.match(Je.TOKENS)||[],this.tokenIndex=0}nextToken(){return this.tokens[this.tokenIndex]||""}consume(){this.tokenIndex++}isIdentifier(){const e=this.tokens[this.tokenIndex][0];return e>="a"&&e<="z"||e>="A"&&e<="Z"}skipSpace(){for(;" "===this.nextToken();)this.consume()}parse(){const e=this.parseTreeSelector();let t=this.nextToken();if(!t)return e;const n=[e];for(;t;){if(","!==t)throw new Qe("Expected comma");this.consume(),n.push(this.parseTreeSelector()),t=this.nextToken()}return new et(n)}parseTreeSelector(){this.skipSpace();let e=this.parseNodeSelector();for(;;){const t=this.nextToken();if(!t||","===t)break;if(" "===t)this.consume(),e=new ot(e,this.parseNodeSelector());else if(">"===t)this.consume(),e=new it(e,this.parseNodeSelector());else if("+"===t)this.consume(),e=new rt(e,this.parseNodeSelector());else{if("~"!==t)throw new Qe("Unexpected token: "+t);this.consume(),e=new at(e,this.parseNodeSelector())}}return e}parseNodeSelector(){this.skipSpace();const e=this.nextToken();if("*"===e)return this.consume(),new tt;if(this.isIdentifier())return this.consume(),new nt(e);throw new Qe("Expected node type")}}X(Je,"TOKENS",void 0),Je.TOKENS=/([a-zA-Z][\w-]*)|(\d+)|[^\s]|(\s(?=[a-zA-Z\*]))/g;class Qe extends Error{constructor(e){super(e)}}class et extends Ze{constructor(e){super(),X(this,"selectors",void 0),this.selectors=e}match(e){for(let t=0;t<this.selectors.length;t++){const n=this.selectors[t].match(e);if(n)return n}return null}toString(){let e="";for(let t=0;t<this.selectors.length;t++)e+=t>0?", ":"",e+=this.selectors[t].toString();return e}}class tt extends Ze{match(e){return[e.currentNode()]}toString(){return"*"}}class nt extends Ze{constructor(e){super(),X(this,"type",void 0),this.type=e}match(e){const t=e.currentNode();return t.type===this.type?[t]:null}toString(){return this.type}}class st extends Ze{constructor(e,t){super(),X(this,"left",void 0),X(this,"right",void 0),this.left=e,this.right=t}}class ot extends st{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t)for(e=e.clone();e.hasParent();){e.goToParent();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" "+this.right.toString()}}class it extends st{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t&&e.hasParent()){(e=e.clone()).goToParent();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" > "+this.right.toString()}}class rt extends st{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t&&e.hasPreviousSibling()){(e=e.clone()).goToPreviousSibling();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" + "+this.right.toString()}}class at extends st{constructor(e,t){super(e,t)}match(e){const t=this.right.match(e);if(t)for(e=e.clone();e.hasPreviousSibling();){e.goToPreviousSibling();const n=this.left.match(e);if(n)return n.concat(t)}return null}toString(){return this.left.toString()+" ~ "+this.right.toString()}}class lt{constructor(e,t,n,s,o,i){var r=this;if(X(this,"name",void 0),X(this,"severity",void 0),X(this,"selector",void 0),X(this,"pattern",void 0),X(this,"lint",void 0),X(this,"applies",void 0),X(this,"message",void 0),!n&&!s)throw new he("Lint rules must have a selector or pattern",pe.InvalidInput,{metadata:{name:e}});this.name=e||"unnamed rule",this.severity=t||lt.Severity.BULK_WARNING,this.selector=n||lt.DEFAULT_SELECTOR,this.pattern=s||null,"function"==typeof o?(this.lint=o,this.message=null):(this.lint=function(){return r._defaultLintFunction(...arguments)},this.message=o),this.applies=i||function(){return!0}}static makeRule(e){return new lt(e.name,e.severity,e.selector?Ze.parse(e.selector):null,lt.makePattern(e.pattern),e.lint||e.message,e.applies)}check(e,t,n,s){const o=this.selector.match(t);if(!o)return null;let i;if(i=this.pattern?n.match(this.pattern):lt.FakePatternMatch(n,n,0),!i)return null;try{const e=this.lint(t,n,o,i,s);return e?"string"==typeof e?{rule:this.name,severity:this.severity,message:e,start:0,end:n.length}:{rule:this.name,severity:this.severity,message:e.message,start:e.start,end:e.end}:null}catch(e){return{rule:"lint-rule-failure",message:"Exception in rule ".concat(this.name,": ").concat(e.message,"\nStack trace:\n").concat(e.stack),start:0,end:n.length}}}_defaultLintFunction(e,t,n,s,o){return{message:this.message||"",start:s.index,end:s.index+s[0].length}}static makePattern(e){if(!e)return null;if(e instanceof RegExp)return e;if("/"===e[0]){const t=e.lastIndexOf("/"),n=e.substring(1,t),s=e.substring(t+1);return new RegExp(n,s)}return new RegExp(e)}static FakePatternMatch(e,t,n){const s=[t];return s.index=n,s.input=e,s}}X(lt,"DEFAULT_SELECTOR",void 0),X(lt,"Severity",{ERROR:1,WARNING:2,GUIDELINE:3,BULK_WARNING:4}),lt.DEFAULT_SELECTOR=Ze.parse("text");const ct=/\/\/([^\/]+)/;var pt=lt.makeRule({name:"absolute-url",severity:lt.Severity.GUIDELINE,selector:"link, image",lint:function(e,t,n,s){const o=function(e){if(!e)return"";const t=e.match(ct);return t?t[1]:""}(n[0].target);if("khanacademy.org"===o||o.endsWith(".khanacademy.org"))return"Don't use absolute URLs:\nWhen linking to KA content or images, omit the\nhttps://www.khanacademy.org URL prefix.\nUse a relative URL beginning with / instead."}}),dt=lt.makeRule({name:"blockquoted-math",severity:lt.Severity.WARNING,selector:"blockQuote math, blockQuote blockMath",message:"Blockquoted math:\nmath should not be indented."}),ht=lt.makeRule({name:"blockquoted-widget",severity:lt.Severity.WARNING,selector:"blockQuote widget",message:"Blockquoted widget:\nwidgets should not be indented."}),ut=lt.makeRule({name:"double-spacing-after-terminal",severity:lt.Severity.BULK_WARNING,selector:"paragraph",pattern:/[.!\?] {2}/i,message:"Use a single space after a sentence-ending period, or\nany other kind of terminal punctuation."}),ft=lt.makeRule({name:"extra-content-spacing",selector:"paragraph",pattern:/\s+$/,applies:function(e){return"article"===e.contentType},message:"No extra whitespace at the end of content blocks."}),mt=lt.makeRule({name:"heading-level-1",severity:lt.Severity.WARNING,selector:"heading",lint:function(e,t,n,s){if(1===n[0].level)return"Don't use level-1 headings:\nBegin headings with two or more # characters."}}),gt=lt.makeRule({name:"heading-level-skip",severity:lt.Severity.WARNING,selector:"heading ~ heading",lint:function(e,t,n,s){const o=n[1],i=n[0];if(o.level>i.level+1)return"Skipped heading level:\nthis heading is level ".concat(o.level," but\nthe previous heading was level ").concat(i.level)}}),vt=lt.makeRule({name:"heading-sentence-case",severity:lt.Severity.GUIDELINE,selector:"heading",pattern:/^\W*[a-z]/,message:"First letter is lowercase:\nthe first letter of a heading should be capitalized."});const bt={and:!0,nor:!0,but:!0,the:!0,for:!0};var yt=lt.makeRule({name:"heading-title-case",severity:lt.Severity.GUIDELINE,selector:"heading",pattern:/[^\s:]\s+[A-Z]+[a-z]/,locale:"en",lint:function(e,t,n,s){let o=t.trim().split(/\s+/);if(o.shift(),o=o.filter((e=>e.length>2&&!bt.hasOwnProperty(e))),o.length>=3&&o.every((e=>function(e){const t=e[0];return t===t.toUpperCase()}(e))))return"Title-case heading:\nThis heading appears to be in title-case, but should be sentence-case.\nOnly capitalize the first letter and proper nouns."}}),xt=lt.makeRule({name:"image-alt-text",severity:lt.Severity.WARNING,selector:"image",lint:function(e,t,n,s){const o=n[0];return o.alt&&o.alt.trim()?o.alt.length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(o.alt.length," characters long."):void 0:"Images should have alt text:\nfor accessibility, all images should have alt text.\nSpecify alt text inside square brackets after the !."}}),Ct=lt.makeRule({name:"image-in-table",severity:lt.Severity.BULK_WARNING,selector:"table image",message:"Image in table:\ndo not put images inside of tables."}),wt=lt.makeRule({name:"image-spaces-around-urls",severity:lt.Severity.ERROR,selector:"image",lint:function(e,t,n,s,o){const i=n[0].target;if(o&&o.content){const e=o.content.indexOf(i);if(-1===e)return;if("("!==o.content[e-1]||")"!==o.content[e+i.length])return"Whitespace before or after image url:\nFor images, don't include any space or newlines after '(' or before ')'.\nWhitespace in image URLs causes translation difficulties."}}}),kt=lt.makeRule({name:"image-widget",severity:lt.Severity.WARNING,selector:"widget",lint:function(e,t,n,s,o){if("image"!==e.currentNode().widgetType)return;const i=o&&o.widgets&&o.widgets[e.currentNode().id];if(!i)return;const r=i.options.alt;return r?r.trim().length<8?"Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ".concat(r.trim().length," characters long."):i.options.caption&&i.options.caption.match(/[^\\]\$/)?"No math in image captions:\nDon't include math expressions in image captions.":void 0:'Images should have alt text:\nfor accessibility, all images should have a text description.\nAdd a description in the "Alt Text" box of the image widget.'}}),St=lt.makeRule({name:"link-click-here",severity:lt.Severity.WARNING,selector:"link",pattern:/click here/i,message:'Inappropriate link text:\nDo not use the words "click here" in links.'}),Et=lt.makeRule({name:"long-paragraph",severity:lt.Severity.GUIDELINE,selector:"paragraph",pattern:/^.{501,}/,lint:function(e,t,n,s){return"Paragraph too long:\nThis paragraph is ".concat(t.length," characters long.\nShorten it to 500 characters or fewer.")}}),_t=lt.makeRule({name:"math-adjacent",severity:lt.Severity.WARNING,selector:"blockMath+blockMath",message:"Adjacent math blocks:\ncombine the blocks between \\begin{align} and \\end{align}"}),Mt=lt.makeRule({name:"math-align-extra-break",severity:lt.Severity.WARNING,selector:"blockMath",pattern:/(\\{2,})\s*\\end{align}/,message:"Extra space at end of block:\nDon't end an align block with backslashes"}),Tt=lt.makeRule({name:"math-align-linebreaks",severity:lt.Severity.WARNING,selector:"blockMath",pattern:/\\begin{align}[\s\S]*\\\\[\s\S]+\\end{align}/,lint:function(e,t,n,s){let o=s[0];for(;o.length;){const e=o.indexOf("\\\\");if(-1===e)return null;o=o.substring(e+2);const t=o.match(/^\s*\\\\\s*(?!\\\\)/);if(!t)return"Use four backslashes between lines of an align block";o=o.substring(t[0].length)}}}),It=lt.makeRule({name:"math-empty",severity:lt.Severity.WARNING,selector:"math, blockMath",pattern:/^$/,message:"Empty math: don't use $$ in your markdown."}),Pt=lt.makeRule({name:"math-font-size",severity:lt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\(tiny|Tiny|small|large|Large|LARGE|huge|Huge|scriptsize|normalsize)\s*{/,message:"Math font size:\nDon't change the default font size with \\Large{} or similar commands"}),At=lt.makeRule({name:"math-frac",severity:lt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/\\frac[ {]/,message:"Use \\dfrac instead of \\frac in your math expressions."}),Nt=lt.makeRule({name:"math-nested",severity:lt.Severity.ERROR,selector:"math, blockMath",pattern:/\\text{[^$}]*\$[^$}]*\$[^}]*}/,message:"Nested math:\nDon't nest math expressions inside \\text{} blocks"}),Rt=lt.makeRule({name:"math-starts-with-space",severity:lt.Severity.GUIDELINE,selector:"math, blockMath",pattern:/^\s*(~|\\qquad|\\quad|\\,|\\;|\\:|\\ |\\!|\\enspace|\\phantom)/,message:"Math starts with space:\nmath should not be indented. Do not begin math expressions with\nLaTeX space commands like ~, \\;, \\quad, or \\phantom"}),Ft=lt.makeRule({name:"math-text-empty",severity:lt.Severity.WARNING,selector:"math, blockMath",pattern:/\\text{\s*}/,message:"Empty \\text{} block in math expression"}),Dt=lt.makeRule({name:"math-without-dollars",severity:lt.Severity.GUIDELINE,pattern:/\\\w+{[^}]*}|{|}/,message:"This looks like LaTeX:\ndid you mean to put it inside dollar signs?"}),Ot=lt.makeRule({name:"nested-lists",severity:lt.Severity.WARNING,selector:"list list",message:"Nested lists:\nnested lists are hard to read on mobile devices;\ndo not use additional indentation."}),Lt=lt.makeRule({name:"profanity",pattern:/\b(shit|piss|fuck|cunt|cocksucker|motherfucker|tits)\b/i,message:"Avoid profanity"}),Bt=lt.makeRule({name:"table-missing-cells",severity:lt.Severity.WARNING,selector:"table",lint:function(e,t,n,s){const o=n[0],i=o.header.length,r=o.cells.map((e=>e.length));for(let e=0;e<r.length;e++)if(r[e]!==i)return"Table rows don't match header:\nThe table header has ".concat(i," cells, but\nRow ").concat(e+1," has ").concat(r[e]," cells.")}}),zt=lt.makeRule({name:"unbalanced-code-delimiters",severity:lt.Severity.ERROR,pattern:/[`~]+/,message:"Unbalanced code delimiters:\ncode blocks should begin and end with the same type and number of delimiters"}),qt=[pt,dt,ht,ut,ft,mt,gt,vt,yt,xt,Ct,St,Et,_t,Mt,Tt,It,Pt,At,Nt,Rt,Ft,Ot,Bt,lt.makeRule({name:"unescaped-dollar",severity:lt.Severity.ERROR,selector:"unescapedDollar",message:"Unescaped dollar sign:\nDollar signs must appear in pairs or be escaped as \\$"}),lt.makeRule({name:"widget-in-table",severity:lt.Severity.BULK_WARNING,selector:"table widget",message:"Widget in table:\ndo not put widgets inside of tables."}),Lt,Dt,zt,wt,kt];class Ht{constructor(e){X(this,"root",void 0),this.root=e}static isNode(e){return e&&"object"==typeof e&&"string"==typeof e.type}static isTextNode(e){return Ht.isNode(e)&&"text"===e.type&&"string"==typeof e.content}traverse(e){this._traverse(this.root,new Wt(this.root),e)}_traverse(e,t,n){let s="";if(Ht.isNode(e)){const o=e;t._containers.push(o),t._ancestors.push(o),"string"==typeof o.content&&(s=o.content);Object.keys(o).forEach((e=>{if("type"===e)return;const i=o[e];i&&"object"==typeof i&&(t._indexes.push(e),s+=this._traverse(i,t,n),t._indexes.pop())})),t._currentNode=t._ancestors.pop(),t._containers.pop(),n(o,t,s)}else if(Array.isArray(e)){const o=e;t._containers.push(o);let i=0;for(;i<o.length;)t._indexes.push(i),s+=this._traverse(o[i],t,n),i=t._indexes.pop()+1;t._containers.pop()}return s}}class Wt{constructor(e){X(this,"root",void 0),X(this,"_currentNode",void 0),X(this,"_containers",void 0),X(this,"_indexes",void 0),X(this,"_ancestors",void 0),this.root=e,this._currentNode=null,this._containers=new Ut,this._indexes=new Ut,this._ancestors=new Ut}currentNode(){return this._currentNode||this.root}parent(){return this._ancestors.top()}ancestors(){return this._ancestors.values()}nextSibling(){const e=this._containers.top();if(!e||!Array.isArray(e))return null;const t=this._indexes.top();return e.length>t+1?e[t+1]:null}previousSibling(){const e=this._containers.top();if(!e||!Array.isArray(e))return null;const t=this._indexes.top();return t>0?e[t-1]:null}removeNextSibling(){const e=this._containers.top();if(e&&Array.isArray(e)){const t=this._indexes.top();if(e.length>t+1)return e.splice(t+1,1)[0]}return null}replace(){const e=this._containers.top();if(!e)throw new he("Can't replace the root of the tree",pe.Internal);for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];if(Array.isArray(e)){const t=this._indexes.top();e.splice(t,1,...n),this._indexes.pop(),this._indexes.push(t+n.length-1)}else{const t=this._indexes.top();0===n.length?delete e[t]:1===n.length?e[t]=n[0]:e[t]=n}}hasPreviousSibling(){return Array.isArray(this._containers.top())&&this._indexes.top()>0}goToPreviousSibling(){if(!this.hasPreviousSibling())throw new he("goToPreviousSibling(): node has no previous sibling",pe.Internal);this._currentNode=this.previousSibling();const e=this._indexes.pop();this._indexes.push(e-1)}hasParent(){return 0!==this._ancestors.size()}goToParent(){if(!this.hasParent())throw new he("goToParent(): node has no ancestor",pe.NotAllowed);for(this._currentNode=this._ancestors.pop();this._containers.size()&&this._containers.top()[this._indexes.top()]!==this._currentNode;)this._containers.pop(),this._indexes.pop()}clone(){const e=new Wt(this.root);return e._currentNode=this._currentNode,e._containers=this._containers.clone(),e._indexes=this._indexes.clone(),e._ancestors=this._ancestors.clone(),e}equals(e){return this.root===e.root&&this._currentNode===e._currentNode&&this._containers.equals(e._containers)&&this._indexes.equals(e._indexes)&&this._ancestors.equals(e._ancestors)}}class Ut{constructor(e){X(this,"stack",void 0),this.stack=e?e.slice(0):[]}push(e){this.stack.push(e)}pop(){return this.stack.pop()}top(){return this.stack[this.stack.length-1]}values(){return this.stack.slice(0)}size(){return this.stack.length}toString(){return this.stack.toString()}clone(){return new Ut(this.stack)}equals(e){if(!e||!e.stack||e.stack.length!==this.stack.length)return!1;for(let t=0;t<this.stack.length;t++)if(this.stack[t]!==e.stack[t])return!1;return!0}}const Gt=qt.filter((e=>e.severity<lt.Severity.BULK_WARNING));var Vt={runLinter:function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Gt;const o=[],i=new Ht(e);i.traverse(((e,t,n)=>{if(Ht.isTextNode(e)){let n=t.nextSibling();for(;Ht.isTextNode(n);)e.content+=n.content,t.removeNextSibling(),n=t.nextSibling()}}));let r=[],a=!1;return i.traverse(((e,i,l)=>{const c=[],p=s.filter((e=>e.applies(t))),d=[...t.stack];d.push(e.type);const h={...t,stack:d.join(".")};if(p.forEach((t=>{const s=t.check(e,i,l,h);s&&((s.start||s.end)&&(s.target=l.substring(s.start,s.end)),o.push(s),n&&c.push(s))})),n&&("table"===e.type?(r.length&&c.push(...r),a=!1,r=[]):a||(a=i.ancestors().some((e=>"table"===e.type))),a&&c.length&&r.push(...c),c.length))if(c.sort(((e,t)=>e.severity-t.severity)),"text"!==e.type||c.length>1)i.replace({type:"lint",content:e,message:c.map((e=>e.message)).join("\n\n"),ruleName:c[0].rule,blockHighlight:h.blockHighlight,insideTable:a,severity:c[0].severity});else{const t=e.content,n=c[0],s=n.start||0,o=n.end||t.length,r=t.substring(0,s),l=t.substring(s,o),p=t.substring(o),d=[];r&&d.push({type:"text",content:r}),d.push({type:"lint",content:{type:"text",content:l},message:n.message,ruleName:n.rule,insideTable:a,severity:n.severity}),p&&d.push({type:"text",content:p}),i.replace(...d)}})),o},parse:Ke.parse,pushContextStack:function(e,t){const n=e.stack||[];return{...e,stack:n.concat(t)}},rules:Gt};const jt=R.default.shape({contentType:R.default.string,highlightLint:R.default.bool,paths:R.default.arrayOf(R.default.string),stack:R.default.arrayOf(R.default.string)}),Yt={contentType:"",highlightLint:!1,paths:[],stack:[]},Xt={};function $t(e){if(!Xt[e]){const t=L.default("<span>").text(e).appendTo("body");Xt[e]=t.width()+5,t.remove()}return Xt[e]}class Kt extends A.Component{constructor(){super(...arguments),X(this,"state",{items:this.props.options.concat("")}),X(this,"onChange",((e,t)=>{let n=N.default.clone(this.state.items);n[e]=t.target.value,e===n.length-1&&(n=n.concat("")),this.setState({items:n}),this.props.onChange(N.default.compact(n))})),X(this,"onKeyDown",((e,t)=>{const n=t.nativeEvent.keyCode;if(8===n&&""===this.state.items[e]){t.preventDefault();const n=N.default.clone(this.state.items),s=0===e?0:e-1;e!==n.length-1||0!==e&&""===n[s]?(n.splice(e,1),this.setState({items:n},(function(){D.default.findDOMNode(this.refs["input_"+s]).focus()}))):D.default.findDOMNode(this.refs["input_"+s]).focus()}else if(8===n&&1===this.state.items[e].length&&e===this.state.items.length-2){t.preventDefault();const n=N.default.clone(this.state.items);n.splice(e,1),this.setState({items:n}),this.props.onChange(N.default.compact(n))}else if(13===n){t.preventDefault();const n=N.default.clone(this.state.items),s=e+1;e===n.length-2?D.default.findDOMNode(this.refs["input_"+s]).focus():(n.splice(s,0,""),this.setState({items:n},(function(){D.default.findDOMNode(this.refs["input_"+s]).focus()})))}}))}UNSAFE_componentWillReceiveProps(e){this.setState({items:e.options.concat("")})}render(){const e=["perseus-text-list-editor","perseus-clearfix","layout-"+this.props.layout].join(" "),t=N.default.map(this.state.items,(function(e,t){return A.createElement("li",{key:t},A.createElement("input",{ref:"input_"+t,type:"text",value:e,onChange:this.onChange.bind(this,t),onKeyDown:this.onKeyDown.bind(this,t),style:{width:$t(e)}}))}),this);return A.createElement("ul",{className:e},t)}}X(Kt,"propTypes",{options:R.default.array,layout:R.default.string,onChange:R.default.func.isRequired}),X(Kt,"defaultProps",{options:[],layout:"horizontal"});const Zt=[];class Jt extends A.Component{render(){return A.createElement("div",null,this.props.showTitle&&A.createElement("div",{style:{fontSize:14}},"Tags:"),A.createElement(Kt,{options:this.props.value||Zt,layout:"vertical",onChange:this.props.onChange}))}}X(Jt,"propTypes",{value:R.default.arrayOf(R.default.string),onChange:R.default.func.isRequired,showTitle:R.default.bool.isRequired}),X(Jt,"defaultProps",{value:Zt,showTitle:!0});const Qt={propTypes:R.default.shape({isArticle:R.default.bool.isRequired,satStyling:R.default.bool.isRequired,onInputError:R.default.func.isRequired,onFocusChange:R.default.func.isRequired,staticRender:R.default.bool.isRequired,GroupMetadataEditor:R.default.func.isRequired,showAlignmentOptions:R.default.bool.isRequired,readOnly:R.default.bool.isRequired,answerableCallback:R.default.func,getAnotherHint:R.default.func,interactionCallback:R.default.func,groupAnnotator:R.default.func.isRequired,imagePlaceholder:R.default.node,widgetPlaceholder:R.default.node,baseElements:R.default.shape({Link:R.default.func}),imagePreloader:R.default.func,trackInteraction:R.default.func,customKeypad:R.default.bool,nativeKeypadProxy:R.default.func,isMobile:R.default.bool,setDrawingAreaAvailable:R.default.func,useDraftEditor:R.default.bool,styling:R.default.shape({radioStyleVersion:R.default.oneOf(["intermediate","final"])}),hintProgressColor:R.default.string,canScrollPage:R.default.bool,inModal:R.default.bool,crossOutEnabled:R.default.bool,editorChangeDelay:R.default.number}).isRequired,defaults:{isArticle:!1,isMobile:!1,satStyling:!1,onInputError:function(){},onFocusChange:function(){},staticRender:!1,GroupMetadataEditor:Jt,showAlignmentOptions:!1,readOnly:!1,groupAnnotator:function(){return null},baseElements:{Link:e=>A.createElement("a",e)},setDrawingAreaAvailable:function(){},useDraftEditor:!1,styling:{radioStyleVersion:"final"},canScrollPage:!1,inModal:!1,crossOutEnabled:!1,editorChangeDelay:0}},en={RENDERER:"perseus-renderer",TWO_COLUMN_RENDERER:"perseus-renderer-two-columns",RESPONSIVE_RENDERER:"perseus-renderer-responsive",INPUT:"perseus-input",FOCUSED:"perseus-focused",RADIO:{OPTION:"perseus-radio-option",SELECTED:"perseus-radio-selected",OPTION_CONTENT:"perseus-radio-option-content"},INTERACTIVE:"perseus-interactive",CORRECT:"perseus-correct",INCORRECT:"perseus-incorrect",UNANSWERED:"perseus-unanswered",MOBILE:"perseus-mobile"},tn={assetStatuses:{},setAssetStatus:(e,t)=>{}},nn=A.createContext(tn);function sn(e,t){const n=window.scrollX,s=window.scrollY,o=document.querySelector("meta[name=viewport]");o?o.setAttribute("content",e):L.default("head").append('<meta name="viewport" content="'.concat(e,'">')),document.body.style.opacity=.9999,setTimeout((()=>{document.body.style.opacity=1,window.scrollTo(n,s),t&&setTimeout(t,0)}),0)}function on(){}function rn(e,t){this._fullHeight=this._fullWidth=this._overlay=null,this._targetImage=e,this._enableMobilePinch=t,this._$body=L.default(document.body)}L.default.fn.emulateTransitionEnd=function(e){let t=!1;const n=this;L.default(this).one("bsTransitionEnd",(function(){t=!0}));return setTimeout((function(){t||L.default(n).trigger(L.default.support.transition.end)}),e),this},L.default((function(){L.default.support.transition=function(){const e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(const n in t)if(void 0!==e.style[n])return{end:t[n]};return!1}(),L.default.support.transition&&(L.default.event.special.bsTransitionEnd={bindType:L.default.support.transition.end,delegateType:L.default.support.transition.end,handle:function(e){if(L.default(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})),on.prototype._initialize=function(e){this._$document||(this._activeZoom=this._initialScrollPosition=this._initialTouchPosition=this._touchMoveListener=null,this._$document=L.default(document),this._$window=L.default(window),this._$body=L.default(document.body),this._boundClick=L.default.proxy(this._clickHandler,this),this._enableMobilePinch=e)},on.prototype.handleZoomClick=function(e,t){this._initialize(t);const n=e.target;if(n&&"IMG"===n.tagName&&!this._$body.hasClass("zoom-overlay-open"))return e.metaKey||e.ctrlKey?window.open(e.target.src,"_blank"):void(!t&&n.width>=window.innerWidth-rn.getOffset()||(this._activeZoomClose(!0),t?sn("width=device-width, initial-scale=1, minimum-scale=1",(()=>this._zoom(n))):this._zoom(n),t||(this._$window.on("scroll.zoom",L.default.proxy(this._scrollHandler,this)),this._$document.on("keyup.zoom",L.default.proxy(this._keyHandler,this)),this._$document.on("touchstart.zoom",L.default.proxy(this._touchStart,this))),document.addEventListener("click",this._boundClick,!0),e.stopPropagation()))},on.prototype._zoom=function(e){this._activeZoom=new rn(e,this._enableMobilePinch),this._activeZoom.zoomImage()},on.prototype._activeZoomClose=function(e){this._activeZoom&&(e?(this._activeZoom.dispose(),this._disposeActiveZoom()):sn("width=device-width, initial-scale=1, minimum-scale=1,\n maximum-scale=1",(()=>{this._activeZoom&&(this._activeZoom.close(),this._disposeActiveZoom())})))},on.prototype._disposeActiveZoom=function(){this._$window.off(".zoom"),this._$document.off(".zoom"),document.removeEventListener("click",this._boundClick,!0),this._activeZoom=null},on.prototype._scrollHandler=function(e){null===this._initialScrollPosition&&(this._initialScrollPosition=window.scrollY);const t=this._initialScrollPosition-window.scrollY;Math.abs(t)>=40&&this._activeZoomClose()},on.prototype._keyHandler=function(e){27===e.keyCode&&this._activeZoomClose()},on.prototype._clickHandler=function(e){e.stopPropagation(),e.preventDefault(),this._activeZoomClose()},on.prototype._touchStart=function(e){this._initialTouchPosition=e.originalEvent.touches[0].pageY,L.default(e.target).on("touchmove.zoom",L.default.proxy(this._touchMove,this))},on.prototype._touchMove=function(e){Math.abs(e.originalEvent.touches[0].pageY-this._initialTouchPosition)>10&&(this._activeZoomClose(),L.default(e.target).off("touchmove.zoom"))},rn._OFFSET=80,rn._MAX_WIDTH=2560,rn._MAX_HEIGHT=4096,rn.getOffset=function(e){return e?0:rn._OFFSET},rn.prototype.getOffset=function(){return rn.getOffset(this._enableMobilePinch)},rn.prototype.zoomImage=function(){const e=document.createElement("img"),t=L.default(e);e.onload=function(){this._fullHeight=Number(e.height),this._fullWidth=Number(e.width);const n=this._imageOffset=L.default(this._targetImage).offset(),s=this._left=n.left-L.default(window).scrollLeft(),o=this._top=n.top-L.default(window).scrollTop();t.css({left:s,top:o,width:this._targetImage.width,height:this._targetImage.height}),this._zoomOriginal()}.bind(this),e.src=this._targetImage.src,this.$zoomedImage=t},rn.prototype._zoomOriginal=function(){var e,t,n;this.$zoomedImage.addClass("zoom-img").attr("data-action","zoom-out"),L.default(this._targetImage).css("visibility","hidden"),this._backdrop=document.createElement("div"),this._backdrop.className="zoom-backdrop",null===(e=document.body)||void 0===e||e.appendChild(this._backdrop),this._overlay=document.createElement("div"),this._overlay.className="zoom-overlay",null===(t=document.body)||void 0===t||t.appendChild(this._overlay),null===(n=this._overlay)||void 0===n||n.appendChild(this.$zoomedImage[0]),this._calculateZoom(),this._triggerAnimation()},rn.prototype._calculateZoom=function(){const e=this._fullWidth,t=this._fullHeight,n=window.innerHeight-this.getOffset(),s=window.innerWidth-this.getOffset(),o=e/this._targetImage.width,i=e/t,r=s/n;this._imgScaleFactor=e<s&&t<n?o:i<r?n/t*o:s/(null!=e?e:0)*o},rn.prototype._triggerAnimation=function(){const e=L.default(window).scrollTop()+window.innerHeight/2,t=L.default(window).scrollLeft()+window.innerWidth/2,n=this._imgScaleFactor,s=this._imageOffset.top+this._targetImage.height/2,o=this._imageOffset.left+this._targetImage.width/2;this._translateY=(e-s)/n,this._translateX=(t-o)/n,this._zoomedInTransformString="\n scale(".concat(n,")\n translate3d(").concat(this._translateX,"px, ").concat(this._translateY,"px, 0)\n "),this.$zoomedImage.css({transform:this._zoomedInTransformString}).addClass("zoom-transition").one(L.default.support.transition.end,L.default.proxy(this._onZoomInFinish,this)).emulateTransitionEnd(300),this._$body.addClass("zoom-overlay-open")},rn.prototype._onZoomInFinish=function(){const e=this._targetImage.height*this._imgScaleFactor,t=this._targetImage.width*this._imgScaleFactor;let n=0,s=0,o=0,i=0,r=0,a=0;t<window.innerWidth?(n="50%",o=-t/2):r=(t-window.innerWidth)/2,e<window.innerHeight?(s="50%",i=-e/2):a=(e-window.innerHeight)/2,this.$zoomedImage.css({height:e,left:n,marginLeft:o,marginTop:i,top:s,transform:"",width:t}).removeClass("zoom-transition"),L.default(this._overlay).scrollLeft(r).scrollTop(a)},rn.prototype.close=function(){this._$body.removeClass("zoom-overlay-open").addClass("zoom-overlay-transitioning"),this.$zoomedImage.css({height:this._targetImage.height,left:this._left,marginLeft:0,marginTop:0,top:this._top,transform:this._zoomedInTransformString,width:this._targetImage.width}).removeClass("zoom-transition"),L.default(this._overlay).scrollLeft(0).scrollTop(0),setTimeout((()=>{this.$zoomedImage.css({transform:"scale(1)"}).addClass("zoom-transition").one(L.default.support.transition.end,L.default.proxy(this.dispose,this)).emulateTransitionEnd(300)}),10)},rn.prototype.dispose=function(){this.$zoomedImage&&this.$zoomedImage[0].parentNode&&(this.$zoomedImage.remove(),this.$zoomedImage=null,this._overlay.parentNode.removeChild(this._overlay),this._backdrop.parentNode.removeChild(this._backdrop),this._$body.removeClass("zoom-overlay-transitioning")),L.default(this._targetImage).css("visibility","visible"),this._targetImage.focus()};const an=new on,ln=B.default({displayName:"FixedToResponsive",propTypes:{width:R.default.number.isRequired,height:R.default.number.isRequired,className:R.default.string,constrainHeight:R.default.bool,allowFullBleed:R.default.bool},getDefaultProps:function(){return{className:"",constrainHeight:!1,allowFullBleed:!1}},getInitialState:function(){return{viewportHeight:null,viewportWidth:null}},componentDidMount:function(){this._isMounted=!0,window.innerHeight<480?setTimeout(this._cacheViewportSize,800):this._cacheViewportSize()},componentWillUnmount:function(){this._isMounted=!1},_cacheViewportSize:function(){this._isMounted&&this.setState({viewportHeight:Math.max(480,window.innerHeight),viewportWidth:window.innerWidth})},render:function(){const e=this.props.width/this.props.height,t=A.createElement("div",{style:{paddingBottom:100*(1/e).toFixed(4)+"%"}});let{width:n,height:s}=this.props;if(this.props.constrainHeight&&this.state.viewportHeight){const t=2/3*this.state.viewportHeight;this.props.height>=t&&(s=t,n=t*e)}const o={maxWidth:n,maxHeight:s},i=P.default("fixed-to-responsive",this.props.className),r=A.createElement("div",{className:i,style:o},t,this.props.children);return this.props.allowFullBleed&&this.state.viewportWidth&&n>=this.state.viewportWidth?A.createElement("div",{style:{marginLeft:-16,marginRight:-16}},r):r}});function cn(e,t){return e+":"+t}const pn={_fireEvent:function(e,t,n){N.default.invoke(e,"call",this,t,n)},_applyConstraints:function(e,t,n){let s=!1;return N.default.reduce(this.state.constraints,((e,o)=>{if(!1===e)return!1;if(s)return e;const i=o.call(this,e,t,{onSkipRemaining:()=>{s=!0},...n});if(!1===i)return!1;if(d.point.is(i,2))return i;if(!0===i||null==i)return e;throw new he("Constraint returned invalid result: "+i,pe.Internal)}),e,this)},draw:function(){const e=this.cloneState();pn._fireEvent.call(this,this.state.draw,e,this.prevState),this.prevState=e},listen:function(e,t,n){this._listenerMap=this._listenerMap||{};const s=cn(e,t),o=this._listenerMap[s]=this._listenerMap[s]||this.state[e].length;this.state[e][o]=n},unlisten:function(e,t){this._listenerMap=this._listenerMap||{};const n=cn(e,t),s=this._listenerMap[n];if(void 0!==s){this.state[e].splice(s,1),delete this._listenerMap[n];const t=N.default.keys(this._listenerMap);N.default.each(t,(function(t){(function(e){return e.split(":")[0]})(t)===e&&this._listenerMap[t]>s&&this._listenerMap[t]--}),this)}}};let dn=null;let hn=null;const un={assert:function(e,t){if(!e)throw new he("Assertion Error"+(t?": "+t:""),pe.Internal)},createGettersFor:function(e,t){N.default.each(N.default.keys(t),(function(t){void 0===e.prototype[t]&&(e.prototype[t]=function(){return this.state[t]})}))},addMovableHelperMethodsTo:function(e){N.default.each(pn,(function(t,n){void 0===e.prototype[n]&&(e.prototype[n]=t)}))},arrayify:function(e){return null==e?[]:N.default.isArray(e)?N.default.filter(N.default.flatten(e),N.default.identity):[e]},normalizeOptions:function(e,t){const n=N.default.clone(t);return N.default.each(e,(function(e){const s=t[e];if(void 0!==s){const t=un.arrayify(s);n[e]=t}})),n},getPrefixedTransform:function(){return dn=dn||function(){const e=document.createElement("div");let t=null;return N.default.each(["transform","msTransform","MozTransform","WebkitTransform","OTransform"],(function(n){void 0!==e.style[n]&&(t=n)})),t}(),dn},getCanUse3dTransform:function(){return null==hn&&(hn=function(){const e=document.createElement("div"),t=un.getPrefixedTransform();return e.style[t]="translateZ(0px)",!!e.style[t]}()),hn}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function fn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mn={exports:{}};
|
|
2
2
|
/*!
|
|
3
3
|
* Raphael 1.5.2 - JavaScript Vector Library
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
|
|
6
6
|
* Licensed under the MIT (http://raphaeljs.com/license.html) license.
|
|
7
|
-
*/!function(){var e;function t(){if(t.is(arguments[0],I)){for(var e=arguments[0],n=qe[u](t,e.splice(0,3+t.is(e[0],T))),o=n.set(),i=0,r=e[b];i<r;i++){var l=e[i]||{};s[a](l.type)&&o[A](n[l.type]().attr(l))}return o}return qe[u](t,arguments)}e="".trim?function(e,t,n){e.setAttribute(t,String(n).trim())}:function(e,t,n){e.setAttribute(t,String(n))},t.version="1.5.2";var n,o=/[, ]+/,s={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},i=/\{(\d+)\}/g,r="prototype",a="hasOwnProperty",l=document,c=window,p={was:Object[r][a].call(c,"Raphael"),is:c.Raphael},d=function(){this.customAttributes={}},u="apply",h="createTouch"in l,f="",m=" ",g=String,v="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend".split(m),y={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},b="length",x=g[r].toLowerCase,w=Math,C=w.max,k=w.min,S=w.abs,E=w.pow,_=w.PI,T="number",M="string",I="array",P="fill",N=Object[r].toString,A="push",R=/^url\(['"]?([^\)]+?)['"]?\)$/i,F=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,O={NaN:1,Infinity:1,"-Infinity":1},D=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,L=w.round,B=parseFloat,z=parseInt,q=" progid:DXImageTransform.Microsoft",H=g[r].toUpperCase,W={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},U={along:"along",blur:T,"clip-rect":"csv",cx:T,cy:T,fill:"colour","fill-opacity":T,"font-size":T,height:T,opacity:T,path:"path",r:T,rotation:"csv",rx:T,ry:T,scale:"csv",stroke:"colour","stroke-opacity":T,"stroke-width":T,translation:"csv",width:T,x:T,y:T},G="replace",V=/^(from|to|\d+%?)$/,j=/\s*,\s*/,Y={hs:1,rg:1},$=/,?([achlmqrstvxz]),?/gi,X=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/gi,K=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/gi,Z=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,J=function(e,t){return e.key-t.key};if(t.type=c.SVGAngle||l.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML","VML"==t.type){var Q,ee=l.createElement("div");if(ee.innerHTML='<v:shape adj="1"/>',(Q=ee.firstChild).style.behavior="url(#default#VML)",!Q||"object"!=typeof Q.adj)return t.type=null;ee=null}function te(){for(var e=[],t=0;t<32;t++)e[t]=(~~(16*w.random())).toString(16);return e[12]=4,e[16]=(3&e[16]|8).toString(16),"r-"+e.join("")}t.svg=!(t.vml="VML"==t.type),d[r]=t[r],n=d[r],t._id=0,t._oid=0,t.fn={},t.is=function(e,t){return"finite"==(t=x.call(t))?!O[a](+e):"null"==t&&null===e||t==typeof e||"object"==t&&e===Object(e)||"array"==t&&Array.isArray&&Array.isArray(e)||N.call(e).slice(8,-1).toLowerCase()==t},t.angle=function(e,n,o,s,i,r){if(null==i){var a=e-o,l=n-s;return a||l?(180*(a<0)+180*w.atan(-l/-a)/_+360)%360:0}return t.angle(e,n,i,r)-t.angle(o,s,i,r)},t.rad=function(e){return e%360*_/180},t.deg=function(e){return 180*e/_%360},t.snapTo=function(e,n,o){if(o=t.is(o,"finite")?o:10,t.is(e,I)){for(var s=e.length;s--;)if(S(e[s]-n)<=o)return e[s]}else{var i=n%(e=+e);if(i<o)return n-i;if(i>e-o)return n-i+e}return n},t.setWindow=function(e){l=(c=e).document};var ne=function(e){if(t.vml){var n,o=/^\s+|\s+$/g;try{var s=new ActiveXObject("htmlfile");s.write("<body>"),s.close(),n=s.body}catch(e){n=createPopup().document.body}var i=n.createTextRange();ne=re((function(e){try{n.style.color=g(e)[G](o,f);var t=i.queryCommandValue("ForeColor");return"#"+("000000"+(t=(255&t)<<16|65280&t|(16711680&t)>>>16).toString(16)).slice(-6)}catch(e){return"none"}}))}else{var r=l.createElement("i");r.title="Raphaël Colour Picker",r.style.display="none",l.body.appendChild(r),ne=re((function(e){return r.style.color=e,l.defaultView.getComputedStyle(r,f).getPropertyValue("color")}))}return ne(e)},oe=function(){return"hsb("+[this.h,this.s,this.b]+")"},se=function(){return"hsl("+[this.h,this.s,this.l]+")"},ie=function(){return this.hex};function re(e,t,n){return function o(){var s=Array[r].slice.call(arguments,0),i=s.join("►"),l=o.cache=o.cache||{},c=o.count=o.count||[];return l[a](i)||(c[b]>=1e3&&delete l[c.shift()],c[A](i),l[i]=e[u](t,s)),n?n(l[i]):l[i]}}t.hsb2rgb=function(e,n,o,s){return t.is(e,"object")&&"h"in e&&"s"in e&&"b"in e&&(o=e.b,n=e.s,s=(e=e.h).o),t.hsl2rgb(e,n,o/2,s)},t.hsl2rgb=function(e,n,o,s){t.is(e,"object")&&"h"in e&&"s"in e&&"l"in e&&(o=e.l,n=e.s,e=e.h),(e>1||n>1||o>1)&&(e/=360,n/=100,o/=100);var i,r,a,l={},c=["r","g","b"];if(n){r=2*o-(i=o<.5?o*(1+n):o+n-o*n);for(var p=0;p<3;p++)(a=e+1/3*-(p-1))<0&&a++,a>1&&a--,l[c[p]]=6*a<1?r+6*(i-r)*a:2*a<1?i:3*a<2?r+(i-r)*(2/3-a)*6:r}else l={r:o,g:o,b:o};return l.r*=255,l.g*=255,l.b*=255,l.hex="#"+(16777216|l.b|l.g<<8|l.r<<16).toString(16).slice(1),t.is(s,"finite")&&(l.opacity=s),l.toString=ie,l},t.rgb2hsb=function(e,n,o){if(null==n&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(o=e.b,n=e.g,e=e.r),null==n&&t.is(e,M)){var s=t.getRGB(e);e=s.r,n=s.g,o=s.b}(e>1||n>1||o>1)&&(e/=255,n/=255,o/=255);var i,r=C(e,n,o),a=k(e,n,o);if(a==r)return{h:0,s:0,b:r,toString:oe};var l=r-a;return i=e==r?(n-o)/l:n==r?2+(o-e)/l:4+(e-n)/l,(i/=6)<0&&i++,i>1&&i--,{h:i,s:l/r,b:r,toString:oe}},t.rgb2hsl=function(e,n,o){if(null==n&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(o=e.b,n=e.g,e=e.r),null==n&&t.is(e,M)){var s=t.getRGB(e);e=s.r,n=s.g,o=s.b}(e>1||n>1||o>1)&&(e/=255,n/=255,o/=255);var i,r,a=C(e,n,o),l=k(e,n,o),c=(a+l)/2;if(l==a)r={h:0,s:0,l:c};else{var p=a-l;i=e==a?(n-o)/p:n==a?2+(o-e)/p:4+(e-n)/p,(i/=6)<0&&i++,i>1&&i--,r={h:i,s:c<.5?p/(a+l):p/(2-a-l),l:c}}return r.toString=se,r},t._path2string=function(){return this.join(",")[G]($,"$1")},t.getRGB=re((function(e){if(!e||(e=g(e)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if("none"==e)return{r:-1,g:-1,b:-1,hex:"none"};!Y[a](e.toLowerCase().substring(0,2))&&"#"!=e.charAt()&&(e=ne(e));var n,o,s,i,r,l,c=e.match(F);return c?(c[2]&&(s=z(c[2].substring(5),16),o=z(c[2].substring(3,5),16),n=z(c[2].substring(1,3),16)),c[3]&&(s=z((r=c[3].charAt(3))+r,16),o=z((r=c[3].charAt(2))+r,16),n=z((r=c[3].charAt(1))+r,16)),c[4]&&(l=c[4].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),o=B(l[1]),"%"==l[1].slice(-1)&&(o*=2.55),s=B(l[2]),"%"==l[2].slice(-1)&&(s*=2.55),"rgba"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100)),c[5]?(l=c[5].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),o=B(l[1]),"%"==l[1].slice(-1)&&(o*=2.55),s=B(l[2]),"%"==l[2].slice(-1)&&(s*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(n/=360),"hsba"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100),t.hsb2rgb(n,o,s,i)):c[6]?(l=c[6].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),o=B(l[1]),"%"==l[1].slice(-1)&&(o*=2.55),s=B(l[2]),"%"==l[2].slice(-1)&&(s*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(n/=360),"hsla"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100),t.hsl2rgb(n,o,s,i)):((c={r:n,g:o,b:s}).hex="#"+(16777216|s|o<<8|n<<16).toString(16).slice(1),t.is(i,"finite")&&(c.opacity=i),c)):{r:-1,g:-1,b:-1,hex:"none",error:1}}),t),t.getColor=function(e){var t=this.getColor.start=this.getColor.start||{h:0,s:1,b:e||.75},n=this.hsb2rgb(t.h,t.s,t.b);return t.h+=.075,t.h>1&&(t.h=0,t.s-=.2,t.s<=0&&(this.getColor.start={h:0,s:1,b:t.b})),n.hex},t.getColor.reset=function(){delete this.start},t.parsePathString=re((function(e){if(!e)return null;var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},o=[];return t.is(e,I)&&t.is(e[0],I)&&(o=le(e)),o[b]||g(e)[G](X,(function(e,t,s){var i=[],r=x.call(t);for(s[G](K,(function(e,t){t&&i[A](+t)})),"m"==r&&i[b]>2&&(o[A]([t].concat(i.splice(0,2))),r="l",t="m"==t?"l":"L");i[b]>=n[r]&&(o[A]([t].concat(i.splice(0,n[r]))),n[r]););})),o.toString=t._path2string,o})),t.findDotsAtSegment=function(e,t,n,o,s,i,r,a,l){var c=1-l,p=E(c,3)*e+3*E(c,2)*l*n+3*c*l*l*s+E(l,3)*r,d=E(c,3)*t+3*E(c,2)*l*o+3*c*l*l*i+E(l,3)*a,u=e+2*l*(n-e)+l*l*(s-2*n+e),h=t+2*l*(o-t)+l*l*(i-2*o+t),f=n+2*l*(s-n)+l*l*(r-2*s+n),m=o+2*l*(i-o)+l*l*(a-2*i+o),g=(1-l)*e+l*n,v=(1-l)*t+l*o,y=(1-l)*s+l*r,b=(1-l)*i+l*a,x=90-180*w.atan((u-f)/(h-m))/_;return(u>f||h<m)&&(x+=180),{x:p,y:d,m:{x:u,y:h},n:{x:f,y:m},start:{x:g,y:v},end:{x:y,y:b},alpha:x}};var ae=re((function(e){if(!e)return{x:0,y:0,width:0,height:0};for(var t,n=0,o=0,s=[],i=[],r=0,a=(e=ge(e))[b];r<a;r++)if("M"==(t=e[r])[0])n=t[1],o=t[2],s[A](n),i[A](o);else{var l=me(n,o,t[1],t[2],t[3],t[4],t[5],t[6]);s=s.concat(l.min.x,l.max.x),i=i.concat(l.min.y,l.max.y),n=t[5],o=t[6]}var c=k[u](0,s),p=k[u](0,i);return{x:c,y:p,width:C[u](0,s)-c,height:C[u](0,i)-p}})),le=function(e){var n=[];t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));for(var o=0,s=e[b];o<s;o++){n[o]=[];for(var i=0,r=e[o][b];i<r;i++)n[o][i]=e[o][i]}return n.toString=t._path2string,n},ce=re((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var n=[],o=0,s=0,i=0,r=0,a=0;"M"==e[0][0]&&(i=o=e[0][1],r=s=e[0][2],a++,n[A](["M",o,s]));for(var l=a,c=e[b];l<c;l++){var p=n[l]=[],d=e[l];if(d[0]!=x.call(d[0]))switch(p[0]=x.call(d[0]),p[0]){case"a":p[1]=d[1],p[2]=d[2],p[3]=d[3],p[4]=d[4],p[5]=d[5],p[6]=+(d[6]-o).toFixed(3),p[7]=+(d[7]-s).toFixed(3);break;case"v":p[1]=+(d[1]-s).toFixed(3);break;case"m":i=d[1],r=d[2];default:for(var u=1,h=d[b];u<h;u++)p[u]=+(d[u]-(u%2?o:s)).toFixed(3)}else{p=n[l]=[],"m"==d[0]&&(i=d[1]+o,r=d[2]+s);for(var f=0,m=d[b];f<m;f++)n[l][f]=d[f]}var g=n[l][b];switch(n[l][0]){case"z":o=i,s=r;break;case"h":o+=+n[l][g-1];break;case"v":s+=+n[l][g-1];break;default:o+=+n[l][g-2],s+=+n[l][g-1]}}return n.toString=t._path2string,n}),0,le),pe=re((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var n=[],o=0,s=0,i=0,r=0,a=0;"M"==e[0][0]&&(i=o=+e[0][1],r=s=+e[0][2],a++,n[0]=["M",o,s]);for(var l=a,c=e[b];l<c;l++){var p=n[l]=[],d=e[l];if(d[0]!=H.call(d[0]))switch(p[0]=H.call(d[0]),p[0]){case"A":p[1]=d[1],p[2]=d[2],p[3]=d[3],p[4]=d[4],p[5]=d[5],p[6]=+(d[6]+o),p[7]=+(d[7]+s);break;case"V":p[1]=+d[1]+s;break;case"H":p[1]=+d[1]+o;break;case"M":i=+d[1]+o,r=+d[2]+s;default:for(var u=1,h=d[b];u<h;u++)p[u]=+d[u]+(u%2?o:s)}else for(var f=0,m=d[b];f<m;f++)n[l][f]=d[f];switch(p[0]){case"Z":o=i,s=r;break;case"H":o=p[1];break;case"V":s=p[1];break;case"M":i=n[l][n[l][b]-2],r=n[l][n[l][b]-1];default:o=n[l][n[l][b]-2],s=n[l][n[l][b]-1]}}return n.toString=t._path2string,n}),null,le),de=function(e,t,n,o){return[e,t,n,o,n,o]},ue=function(e,t,n,o,s,i){var r=1/3,a=2/3;return[r*e+a*n,r*t+a*o,r*s+a*n,r*i+a*o,s,i]},he=function(e,t,n,o,s,i,r,a,l,c){var p,d=120*_/180,u=_/180*(+s||0),h=[],f=re((function(e,t,n){return{x:e*w.cos(n)-t*w.sin(n),y:e*w.sin(n)+t*w.cos(n)}}));if(c)T=c[0],M=c[1],k=c[2],E=c[3];else{e=(p=f(e,t,-u)).x,t=p.y;var m=(e-(a=(p=f(a,l,-u)).x))/2,g=(t-(l=p.y))/2,v=m*m/(n*n)+g*g/(o*o);v>1&&(n*=v=w.sqrt(v),o*=v);var y=n*n,x=o*o,C=(i==r?-1:1)*w.sqrt(S((y*x-y*g*g-x*m*m)/(y*g*g+x*m*m))),k=C*n*g/o+(e+a)/2,E=C*-o*m/n+(t+l)/2,T=w.asin(((t-E)/o).toFixed(9)),M=w.asin(((l-E)/o).toFixed(9));(T=e<k?_-T:T)<0&&(T=2*_+T),(M=a<k?_-M:M)<0&&(M=2*_+M),r&&T>M&&(T-=2*_),!r&&M>T&&(M-=2*_)}var I=M-T;if(S(I)>d){var P=M,N=a,A=l;M=T+d*(r&&M>T?1:-1),a=k+n*w.cos(M),l=E+o*w.sin(M),h=he(a,l,n,o,s,0,r,N,A,[M,P,k,E])}I=M-T;var R=w.cos(T),F=w.sin(T),O=w.cos(M),D=w.sin(M),L=w.tan(I/4),B=4/3*n*L,z=4/3*o*L,q=[e,t],H=[e+B*F,t-z*R],W=[a+B*D,l-z*O],U=[a,l];if(H[0]=2*q[0]-H[0],H[1]=2*q[1]-H[1],c)return[H,W,U].concat(h);for(var G=[],V=0,j=(h=[H,W,U].concat(h).join().split(","))[b];V<j;V++)G[V]=V%2?f(h[V-1],h[V],u).y:f(h[V],h[V+1],u).x;return G},fe=function(e,t,n,o,s,i,r,a,l){var c=1-l;return{x:E(c,3)*e+3*E(c,2)*l*n+3*c*l*l*s+E(l,3)*r,y:E(c,3)*t+3*E(c,2)*l*o+3*c*l*l*i+E(l,3)*a}},me=re((function(e,t,n,o,s,i,r,a){var l,c=s-2*n+e-(r-2*s+n),p=2*(n-e)-2*(s-n),d=e-n,h=(-p+w.sqrt(p*p-4*c*d))/2/c,f=(-p-w.sqrt(p*p-4*c*d))/2/c,m=[t,a],g=[e,r];return S(h)>"1e12"&&(h=.5),S(f)>"1e12"&&(f=.5),h>0&&h<1&&(l=fe(e,t,n,o,s,i,r,a,h),g[A](l.x),m[A](l.y)),f>0&&f<1&&(l=fe(e,t,n,o,s,i,r,a,f),g[A](l.x),m[A](l.y)),c=i-2*o+t-(a-2*i+o),d=t-o,h=(-(p=2*(o-t)-2*(i-o))+w.sqrt(p*p-4*c*d))/2/c,f=(-p-w.sqrt(p*p-4*c*d))/2/c,S(h)>"1e12"&&(h=.5),S(f)>"1e12"&&(f=.5),h>0&&h<1&&(l=fe(e,t,n,o,s,i,r,a,h),g[A](l.x),m[A](l.y)),f>0&&f<1&&(l=fe(e,t,n,o,s,i,r,a,f),g[A](l.x),m[A](l.y)),{min:{x:k[u](0,g),y:k[u](0,m)},max:{x:C[u](0,g),y:C[u](0,m)}}})),ge=re((function(e,t){for(var n=pe(e),o=t&&pe(t),s={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},r=function(e,t){if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C"].concat(he[u](0,[t.x,t.y].concat(e.slice(1))));break;case"S":e=["C",t.x+(t.x-(t.bx||t.x)),t.y+(t.y-(t.by||t.y))].concat(e.slice(1));break;case"T":t.qx=t.x+(t.x-(t.qx||t.x)),t.qy=t.y+(t.y-(t.qy||t.y)),e=["C"].concat(ue(t.x,t.y,t.qx,t.qy,e[1],e[2]));break;case"Q":t.qx=e[1],t.qy=e[2],e=["C"].concat(ue(t.x,t.y,e[1],e[2],e[3],e[4]));break;case"L":e=["C"].concat(de(t.x,t.y,e[1],e[2]));break;case"H":e=["C"].concat(de(t.x,t.y,e[1],t.y));break;case"V":e=["C"].concat(de(t.x,t.y,t.x,e[1]));break;case"Z":e=["C"].concat(de(t.x,t.y,t.X,t.Y))}return e},a=function(e,t){if(e[t][b]>7){e[t].shift();for(var s=e[t];s[b];)e.splice(t++,0,["C"].concat(s.splice(0,6)));e.splice(t,1),p=C(n[b],o&&o[b]||0)}},l=function(e,t,s,i,r){e&&t&&"M"==e[r][0]&&"M"!=t[r][0]&&(t.splice(r,0,["M",i.x,i.y]),s.bx=0,s.by=0,s.x=e[r][1],s.y=e[r][2],p=C(n[b],o&&o[b]||0))},c=0,p=C(n[b],o&&o[b]||0);c<p;c++){n[c]=r(n[c],s),a(n,c),o&&(o[c]=r(o[c],i)),o&&a(o,c),l(n,o,s,i,c),l(o,n,i,s,c);var d=n[c],h=o&&o[c],f=d[b],m=o&&h[b];s.x=d[f-2],s.y=d[f-1],s.bx=B(d[f-4])||s.x,s.by=B(d[f-3])||s.y,i.bx=o&&(B(h[m-4])||i.x),i.by=o&&(B(h[m-3])||i.y),i.x=o&&h[m-2],i.y=o&&h[m-1]}return o?[n,o]:n}),null,le),ve=re((function(e){for(var n=[],o=0,s=e[b];o<s;o++){var i={},r=e[o].match(/^([^:]*):?([\d\.]*)/);if(i.color=t.getRGB(r[1]),i.color.error)return null;i.color=i.color.hex,r[2]&&(i.offset=r[2]+"%"),n[A](i)}for(o=1,s=n[b]-1;o<s;o++)if(!n[o].offset){for(var a=B(n[o-1].offset||0),l=0,c=o+1;c<s;c++)if(n[c].offset){l=n[c].offset;break}l||(l=100,c=s);for(var p=((l=B(l))-a)/(c-o+1);o<c;o++)a+=p,n[o].offset=a+"%"}return n})),ye=function(e,n,o,s){var i;return t.is(e,M)||t.is(e,"object")?(i=t.is(e,M)?l.getElementById(e):e).tagName?null==n?{container:i,width:i.style.pixelWidth||i.offsetWidth,height:i.style.pixelHeight||i.offsetHeight}:{container:i,width:n,height:o}:void 0:{container:1,x:e,y:n,width:o,height:s}},be=function(e,t){var n=this;for(var o in t)if(t[a](o)&&!(o in e))switch(typeof t[o]){case"function":!function(t){e[o]=e===n?t:function(){return t[u](n,arguments)}}(t[o]);break;case"object":e[o]=e[o]||{},be.call(this,e[o],t[o]);break;default:e[o]=t[o]}},xe=function(e,t){e==t.top&&(t.top=e.prev),e==t.bottom&&(t.bottom=e.next),e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next)},we=function(e,t){t.top!==e&&(xe(e,t),e.next=null,e.prev=t.top,t.top.next=e,t.top=e)},Ce=function(e,t){t.bottom!==e&&(xe(e,t),e.next=t.bottom,e.prev=null,t.bottom.prev=e,t.bottom=e)},ke=function(e,t,n){xe(e,n),t==n.top&&(n.top=e),t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e},Se=function(e,t,n){xe(e,n),t==n.bottom&&(n.bottom=e),t.prev&&(t.prev.next=e),e.prev=t.prev,t.prev=e,e.next=t},Ee=function(e){return function(){throw new Error("Raphaël: you are calling to method “"+e+"” of removed object")}};if(t.pathToRelative=ce,t.svg){n.svgns="http://www.w3.org/2000/svg",n.xlink="http://www.w3.org/1999/xlink",L=function(e){return+e+.5*(~~e===e)};var _e=function(t,o){if(!o)return(t=l.createElementNS(n.svgns,t)).style.webkitTapHighlightColor="rgba(0,0,0,0)",t;for(var s in o)o[a](s)&&e(t,s,g(o[s]))};t.toString=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var Te=function(e,t){var n=_e("path");t.canvas&&t.canvas.appendChild(n);var o=new Ae(n,t);return o.type="path",Pe(o,{fill:"none",stroke:"#000",path:e}),o},Me=function(e,t,n){var o="linear",s=.5,i=.5,r=e.style;if(t=(t=g(t)[G](Z,(function(e,t,n){if(o="radial",t&&n){s=B(t);var r=2*((i=B(n))>.5)-1;E(s-.5,2)+E(i-.5,2)>.25&&(i=w.sqrt(.25-E(s-.5,2))*r+.5)&&.5!=i&&(i=i.toFixed(5)-1e-5*r)}return f}))).split(/\s*\-\s*/),"linear"==o){var a=t.shift();if(a=-B(a),isNaN(a))return null;var c=[0,0,w.cos(a*_/180),w.sin(a*_/180)],p=1/(C(S(c[2]),S(c[3]))||1);c[2]*=p,c[3]*=p,c[2]<0&&(c[0]=-c[2],c[2]=0),c[3]<0&&(c[1]=-c[3],c[3]=0)}var d=ve(t);if(!d)return null;var u=e.getAttribute(P);(u=u.match(/^url\(#(.*)\)$/))&&n.defs.removeChild(l.getElementById(u[1]));var h=_e(o+"Gradient");h.id=te(),_e(h,"radial"==o?{fx:s,fy:i}:{x1:c[0],y1:c[1],x2:c[2],y2:c[3]}),n.defs.appendChild(h);for(var m=0,v=d[b];m<v;m++){var y=_e("stop");_e(y,{offset:d[m].offset?d[m].offset:m?"100%":"0%","stop-color":d[m].color||"#fff"}),h.appendChild(y)}return _e(e,{fill:"url(#"+h.id+")",opacity:1,"fill-opacity":1}),r.fill=f,r.opacity=1,r.fillOpacity=1,1},Ie=function(e){var n=e.getBBox();_e(e.pattern,{patternTransform:t.format("translate({0},{1})",n.x,n.y)})},Pe=function(n,s){var i={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},r=n.node,c=n.attrs,p=n.rotate(),d=function(e,t){if(t=i[x.call(t)]){for(var n=e.attrs["stroke-width"]||"1",o={round:n,square:n,butt:0}[e.attrs["stroke-linecap"]||s["stroke-linecap"]]||0,a=[],l=t[b];l--;)a[l]=t[l]*n+(l%2?1:-1)*o;_e(r,{"stroke-dasharray":a.join(",")})}};s[a]("rotation")&&(p=s.rotation);var u=g(p).split(o);for(var h in u.length-1?(u[1]=+u[1],u[2]=+u[2]):u=null,B(p)&&n.rotate(0,!0),s)if(s[a](h)){if(!W[a](h))continue;var v=s[h];switch(c[h]=v,h){case"blur":n.blur(v);break;case"rotation":n.rotate(v,!0);break;case"href":case"title":case"target":var y=r.parentNode;if("a"!=x.call(y.tagName)){var w=_e("a");y.insertBefore(w,r),w.appendChild(r),y=w}"target"==h&&"blank"==v?y.setAttributeNS(n.paper.xlink,"show","new"):y.setAttributeNS(n.paper.xlink,h,v);break;case"cursor":r.style.cursor=v;break;case"clip-rect":var C=g(v).split(o);if(4==C[b]){n.clip&&n.clip.parentNode.parentNode.removeChild(n.clip.parentNode);var k=_e("clipPath"),S=_e("rect");k.id=te(),_e(S,{x:C[0],y:C[1],width:C[2],height:C[3]}),k.appendChild(S),n.paper.defs.appendChild(k),_e(r,{"clip-path":"url(#"+k.id+")"}),n.clip=S}if(!v){var E=l.getElementById(r.getAttribute("clip-path")[G](/(^url\(#|\)$)/g,f));E&&E.parentNode.removeChild(E),_e(r,{"clip-path":f}),delete n.clip}break;case"path":"path"==n.type&&_e(r,{d:v?c.path=pe(v):"M0,0"});break;case"width":if(e(r,h,v),!c.fx)break;h="x",v=c.x;case"x":c.fx&&(v=-c.x-(c.width||0));case"rx":if("rx"==h&&"rect"==n.type)break;case"cx":u&&("x"==h||"cx"==h)&&(u[1]+=v-c[h]),e(r,h,v),n.pattern&&Ie(n);break;case"height":if(e(r,h,v),!c.fy)break;h="y",v=c.y;case"y":c.fy&&(v=-c.y-(c.height||0));case"ry":if("ry"==h&&"rect"==n.type)break;case"cy":u&&("y"==h||"cy"==h)&&(u[2]+=v-c[h]),e(r,h,v),n.pattern&&Ie(n);break;case"r":"rect"==n.type?_e(r,{rx:v,ry:v}):e(r,h,v);break;case"src":"image"==n.type&&r.setAttributeNS(n.paper.xlink,"href",v);break;case"stroke-width":r.style.strokeWidth=v,e(r,h,v),c["stroke-dasharray"]&&d(n,c["stroke-dasharray"]);break;case"stroke-dasharray":d(n,v);break;case"translation":var _=g(v).split(o);_[0]=+_[0]||0,_[1]=+_[1]||0,u&&(u[1]+=_[0],u[2]+=_[1]),gt.call(n,_[0],_[1]);break;case"scale":_=g(v).split(o),n.scale(+_[0]||1,+_[1]||+_[0]||1,isNaN(B(_[2]))?null:+_[2],isNaN(B(_[3]))?null:+_[3]);break;case P:var T=g(v).match(R);if(T){k=_e("pattern");var M=_e("image");k.id=te(),_e(k,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1}),_e(M,{x:0,y:0}),M.setAttributeNS(n.paper.xlink,"href",T[1]),k.appendChild(M);var I=l.createElement("img");I.style.cssText="position:absolute;left:-9999em;top-9999em",I.onload=function(){_e(k,{width:this.offsetWidth,height:this.offsetHeight}),_e(M,{width:this.offsetWidth,height:this.offsetHeight}),l.body.removeChild(this),n.paper.safari()},l.body.appendChild(I),I.src=T[1],n.paper.defs.appendChild(k),r.style.fill="url(#"+k.id+")",_e(r,{fill:"url(#"+k.id+")"}),n.pattern=k,n.pattern&&Ie(n);break}var N=t.getRGB(v);if(N.error){if(({circle:1,ellipse:1}[a](n.type)||"r"!=g(v).charAt())&&Me(r,v,n.paper)){c.gradient=v,c.fill="none";break}}else delete s.gradient,delete c.gradient,!t.is(c.opacity,"undefined")&&t.is(s.opacity,"undefined")&&_e(r,{opacity:c.opacity}),!t.is(c["fill-opacity"],"undefined")&&t.is(s["fill-opacity"],"undefined")&&_e(r,{"fill-opacity":c["fill-opacity"]});N[a]("opacity")&&_e(r,{"fill-opacity":N.opacity>1?N.opacity/100:N.opacity});case"stroke":N=t.getRGB(v),e(r,h,N.hex),"stroke"==h&&N[a]("opacity")&&_e(r,{"stroke-opacity":N.opacity>1?N.opacity/100:N.opacity});break;case"gradient":({circle:1,ellipse:1}[a](n.type)||"r"!=g(v).charAt())&&Me(r,v,n.paper);break;case"opacity":c.gradient&&!c[a]("stroke-opacity")&&_e(r,{"stroke-opacity":v>1?v/100:v});case"fill-opacity":if(c.gradient){var A=l.getElementById(r.getAttribute(P)[G](/^url\(#|\)$/g,f));if(A){var F=A.getElementsByTagName("stop");e(F[F[b]-1],"stop-opacity",v)}break}default:"font-size"==h&&(v=z(v,10)+"px");var O=h[G](/(\-.)/g,(function(e){return H.call(e.substring(1))}));r.style[O]=v,e(r,h,v)}}Ne(n,s),u?n.rotate(u.join(m)):B(p)&&n.rotate(p,!0)},Ne=function(e,n){if("text"==e.type&&(n[a]("text")||n[a]("font")||n[a]("font-size")||n[a]("x")||n[a]("y"))){var o=e.attrs,s=e.node,i=s.firstChild?z(l.defaultView.getComputedStyle(s.firstChild,f).getPropertyValue("font-size"),10):10;if(n[a]("text")){for(o.text=n.text;s.firstChild;)s.removeChild(s.firstChild);for(var r=g(n.text).split("\n"),c=0,p=r[b];c<p;c++)if(r[c]){var d=_e("tspan");c&&_e(d,{dy:1.2*i,x:o.x}),d.appendChild(l.createTextNode(r[c])),s.appendChild(d)}}else for(c=0,p=(r=s.getElementsByTagName("tspan"))[b];c<p;c++)c&&_e(r[c],{dy:1.2*i,x:o.x});_e(s,{y:o.y});var u=e.getBBox(),h=o.y-(u.y+u.height/2);h&&t.is(h,"finite")&&_e(s,{y:o.y+h})}},Ae=function(e,n){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.paper=n,this.attrs=this.attrs||{},this.transformations=[],this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1},!n.bottom&&(n.bottom=this),this.prev=n.top,n.top&&(n.top.next=this),n.top=this,this.next=null},Re=Ae[r];Ae[r].rotate=function(e,n,s){if(this.removed)return this;if(null==e)return this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(m):this._.rt.deg;var i=this.getBBox();return(e=g(e).split(o))[b]-1&&(n=B(e[1]),s=B(e[2])),e=B(e[0]),null!=n&&!1!==n?this._.rt.deg=e:this._.rt.deg+=e,null==s&&(n=null),this._.rt.cx=n,this._.rt.cy=s,n=null==n?i.x+i.width/2:n,s=null==s?i.y+i.height/2:s,this._.rt.deg?(this.transformations[0]=t.format("rotate({0} {1} {2})",this._.rt.deg,n,s),this.clip&&_e(this.clip,{transform:t.format("rotate({0} {1} {2})",-this._.rt.deg,n,s)})):(this.transformations[0]=f,this.clip&&_e(this.clip,{transform:f})),_e(this.node,{transform:this.transformations.join(m)}),this},Ae[r].hide=function(){return!this.removed&&(this.node.style.display="none"),this},Ae[r].show=function(){return!this.removed&&(this.node.style.display=""),this},Ae[r].remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this)delete this[e];this.removed=!0}},Ae[r].getBBox=function(){if(this.removed)return this;if("path"==this.type)return ae(this.attrs.path);if("none"==this.node.style.display){this.show();var e=!0}var t={};try{t=this.node.getBBox()}catch(e){}finally{t=t||{}}if("text"==this.type){t={x:t.x,y:1/0,width:0,height:0};for(var n=0,o=this.node.getNumberOfChars();n<o;n++){var s=this.node.getExtentOfChar(n);s.y<t.y&&(t.y=s.y),s.y+s.height-t.y>t.height&&(t.height=s.y+s.height-t.y),s.x+s.width-t.x>t.width&&(t.width=s.x+s.width-t.x)}}return e&&this.hide(),t},Ae[r].attr=function(e,n){if(this.removed)return this;if(null==e){var o={};for(var s in this.attrs)this.attrs[a](s)&&(o[s]=this.attrs[s]);return this._.rt.deg&&(o.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(o.scale=this.scale()),o.gradient&&"none"==o.fill&&(o.fill=o.gradient)&&delete o.gradient,o}if(null==n&&t.is(e,M))return"translation"==e?gt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(null==n&&t.is(e,I)){for(var i={},r=0,l=e.length;r<l;r++)i[e[r]]=this.attr(e[r]);return i}if(null!=n){var c={};c[e]=n}else null!=e&&t.is(e,"object")&&(c=e);for(var p in this.paper.customAttributes)if(this.paper.customAttributes[a](p)&&c[a](p)&&t.is(this.paper.customAttributes[p],"function")){var d=this.paper.customAttributes[p].apply(this,[].concat(c[p]));for(var u in this.attrs[p]=c[p],d)d[a](u)&&(c[u]=d[u])}return Pe(this,c),this},Ae[r].toFront=function(){if(this.removed)return this;this.node.parentNode.appendChild(this.node);var e=this.paper;return e.top!=this&&we(this,e),this},Ae[r].toBack=function(){return this.removed||this.node.parentNode.firstChild!=this.node&&(this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild),Ce(this,this.paper),this.paper),this},Ae[r].insertAfter=function(e){if(this.removed)return this;var t=e.node||e[e.length-1].node;return t.nextSibling?t.parentNode.insertBefore(this.node,t.nextSibling):t.parentNode.appendChild(this.node),ke(this,e,this.paper),this},Ae[r].insertBefore=function(e){if(this.removed)return this;var t=e.node||e[0].node;return t.parentNode.insertBefore(this.node,t),Se(this,e,this.paper),this},Ae[r].blur=function(e){var t=this;if(0!=+e){var n=_e("filter"),o=_e("feGaussianBlur");t.attrs.blur=e,n.id=te(),_e(o,{stdDeviation:+e||1.5}),n.appendChild(o),t.paper.defs.appendChild(n),t._blur=n,_e(t.node,{filter:"url(#"+n.id+")"})}else t._blur&&(t._blur.parentNode.removeChild(t._blur),delete t._blur,delete t.attrs.blur),t.node.removeAttribute("filter")};var Fe=function(e,t,n,o){var s=_e("circle");e.canvas&&e.canvas.appendChild(s);var i=new Ae(s,e);return i.attrs={cx:t,cy:n,r:o,fill:"none",stroke:"#000"},i.type="circle",_e(s,i.attrs),i},Oe=function(e,t,n,o,s,i){var r=_e("rect");e.canvas&&e.canvas.appendChild(r);var a=new Ae(r,e);return a.attrs={x:t,y:n,width:o,height:s,r:i||0,rx:i||0,ry:i||0,fill:"none",stroke:"#000"},a.type="rect",_e(r,a.attrs),a},De=function(e,t,n,o,s){var i=_e("ellipse");e.canvas&&e.canvas.appendChild(i);var r=new Ae(i,e);return r.attrs={cx:t,cy:n,rx:o,ry:s,fill:"none",stroke:"#000"},r.type="ellipse",_e(i,r.attrs),r},Le=function(e,t,n,o,s,i){var r=_e("image");_e(r,{x:n,y:o,width:s,height:i,preserveAspectRatio:"none"}),r.setAttributeNS(e.xlink,"href",t),e.canvas&&e.canvas.appendChild(r);var a=new Ae(r,e);return a.attrs={x:n,y:o,width:s,height:i,src:t},a.type="image",a},Be=function(e,t,n,o){var s=_e("text");_e(s,{x:t,y:n,"text-anchor":"middle"}),e.canvas&&e.canvas.appendChild(s);var i=new Ae(s,e);return i.attrs={x:t,y:n,"text-anchor":"middle",text:o,font:W.font,stroke:"none",fill:"#000"},i.type="text",Pe(i,i.attrs),i},ze=function(t,n){return this.width=t||this.width,this.height=n||this.height,e(this.canvas,"width",this.width),e(this.canvas,"height",this.height),this},qe=function(){var e=ye[u](0,arguments),n=e&&e.container,o=e.x,s=e.y,i=e.width,r=e.height;if(!n)throw new Error("SVG container not found.");var a=_e("svg");return o=o||0,s=s||0,_e(a,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:i=i||512,height:r=r||342}),1==n?(a.style.cssText="position:absolute;left:"+o+"px;top:"+s+"px",l.body.appendChild(a)):n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),(n=new d).width=i,n.height=r,n.canvas=a,be.call(n,n,t.fn),n.clear(),n};n.clear=function(){for(var e=this.canvas;e.firstChild;)e.removeChild(e.firstChild);this.bottom=this.top=null,(this.desc=_e("desc")).appendChild(l.createTextNode("Created with Raphaël")),e.appendChild(this.desc),e.appendChild(this.defs=_e("defs"))},n.remove=function(){for(var e in this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Ee(e)}}if(t.vml){var He,We={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},Ue=/([clmz]),?([^clmz]*)/gi,Ge=/ progid:\S+Blur\([^\)]+\)/g,Ve=/-?[^,\s-]+/g,je="1000 1000",Ye=10,$e={path:1,rect:1};function wt(e,n,o,s,i){return i?t.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",e+i,n,o-2*i,i,-i,s-2*i,2*i-o,2*i-s):t.format("M{0},{1}l{2},0,0,{3},{4},0z",e,n,o,s,-o)}t.toString=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version},Te=function(e,t){var n=He("group");n.style.cssText="position:absolute;left:0;top:0;width:"+t.width+"px;height:"+t.height+"px",n.coordsize=t.coordsize,n.coordorigin=t.coordorigin;var o=He("shape"),s=o.style;s.width=t.width+"px",s.height=t.height+"px",o.coordsize=je,o.coordorigin=t.coordorigin,n.appendChild(o);var i=new Ae(o,n,t),r={fill:"none",stroke:"#000"};return e&&(r.path=e),i.type="path",i.path=[],i.Path=f,Pe(i,r),t.canvas.appendChild(n),i},Pe=function(e,n){e.attrs=e.attrs||{};var s,i=e.node,r=e.attrs,c=i.style,p=(n.x!=r.x||n.y!=r.y||n.width!=r.width||n.height!=r.height||n.r!=r.r)&&"rect"==e.type,d=e;for(var u in n)n[a](u)&&(r[u]=n[u]);if(p&&(r.path=wt(r.x,r.y,r.width,r.height,r.r),e.X=r.x,e.Y=r.y,e.W=r.width,e.H=r.height),n.href&&(i.href=n.href),n.title&&(i.title=n.title),n.target&&(i.target=n.target),n.cursor&&(c.cursor=n.cursor),"blur"in n&&e.blur(n.blur),(n.path&&"path"==e.type||p)&&(i.path=function(e){var t=/[ahqstv]/gi,n=pe;if(g(e).match(t)&&(n=ge),t=/[clmz]/g,n==pe&&!g(e).match(t)){var o=g(e)[G](Ue,(function(e,t,n){var o=[],s="m"==x.call(t),i=We[t];return n[G](Ve,(function(e){s&&2==o[b]&&(i+=o+We["m"==t?"l":"L"],o=[]),o[A](L(e*Ye))})),i+o}));return o}var s,i,r=n(e);o=[];for(var a=0,l=r[b];a<l;a++){s=r[a],"z"==(i=x.call(r[a][0]))&&(i="x");for(var c=1,p=s[b];c<p;c++)i+=L(s[c]*Ye)+(c!=p-1?",":f);o[A](i)}return o.join(m)}(r.path)),null!=n.rotation&&e.rotate(n.rotation,!0),n.translation&&(s=g(n.translation).split(o),gt.call(e,s[0],s[1]),null!=e._.rt.cx&&(e._.rt.cx+=+s[0],e._.rt.cy+=+s[1],e.setBox(e.attrs,s[0],s[1]))),n.scale&&(s=g(n.scale).split(o),e.scale(+s[0]||1,+s[1]||+s[0]||1,+s[2]||null,+s[3]||null)),"clip-rect"in n){var h=g(n["clip-rect"]).split(o);if(4==h[b]){h[2]=+h[2]+ +h[0],h[3]=+h[3]+ +h[1];var v=i.clipRect||l.createElement("div"),y=v.style,w=i.parentNode;y.clip=t.format("rect({1}px {2}px {3}px {0}px)",h),i.clipRect||(y.position="absolute",y.top=0,y.left=0,y.width=e.paper.width+"px",y.height=e.paper.height+"px",w.parentNode.insertBefore(v,w),v.appendChild(w),i.clipRect=v)}n["clip-rect"]||i.clipRect&&(i.clipRect.style.clip=f)}if("image"==e.type&&n.src&&(i.src=n.src),"image"==e.type&&n.opacity&&(i.filterOpacity=q+".Alpha(opacity="+100*n.opacity+")",c.filter=(i.filterMatrix||f)+(i.filterOpacity||f)),n.font&&(c.font=n.font),n["font-family"]&&(c.fontFamily='"'+n["font-family"].split(",")[0][G](/^['"]+|['"]+$/g,f)+'"'),n["font-size"]&&(c.fontSize=n["font-size"]),n["font-weight"]&&(c.fontWeight=n["font-weight"]),n["font-style"]&&(c.fontStyle=n["font-style"]),null!=n.opacity||null!=n["stroke-width"]||null!=n.fill||null!=n.stroke||null!=n["stroke-width"]||null!=n["stroke-opacity"]||null!=n["fill-opacity"]||null!=n["stroke-dasharray"]||null!=n["stroke-miterlimit"]||null!=n["stroke-linejoin"]||null!=n["stroke-linecap"]){var S=(i=e.shape||i).getElementsByTagName(P)&&i.getElementsByTagName(P)[0],E=!1;if(!S&&(E=S=He(P)),"fill-opacity"in n||"opacity"in n){var _=((+r["fill-opacity"]+1||2)-1)*((+r.opacity+1||2)-1)*((+t.getRGB(n.fill).o+1||2)-1);_=k(C(_,0),1),S.opacity=_}if(n.fill&&(S.on=!0),null!=S.on&&"none"!=n.fill||(S.on=!1),S.on&&n.fill){var T=n.fill.match(R);T?(S.src=T[1],S.type="tile"):(S.color=t.getRGB(n.fill).hex,S.src=f,S.type="solid",t.getRGB(n.fill).error&&(d.type in{circle:1,ellipse:1}||"r"!=g(n.fill).charAt())&&Me(d,n.fill)&&(r.fill="none",r.gradient=n.fill))}E&&i.appendChild(S);var M=i.getElementsByTagName("stroke")&&i.getElementsByTagName("stroke")[0],I=!1;!M&&(I=M=He("stroke")),(n.stroke&&"none"!=n.stroke||n["stroke-width"]||null!=n["stroke-opacity"]||n["stroke-dasharray"]||n["stroke-miterlimit"]||n["stroke-linejoin"]||n["stroke-linecap"])&&(M.on=!0),("none"==n.stroke||null==M.on||0==n.stroke||0==n["stroke-width"])&&(M.on=!1);var N=t.getRGB(n.stroke);M.on&&n.stroke&&(M.color=N.hex),_=((+r["stroke-opacity"]+1||2)-1)*((+r.opacity+1||2)-1)*((+N.o+1||2)-1);var F=.75*(B(n["stroke-width"])||1);if(_=k(C(_,0),1),null==n["stroke-width"]&&(F=r["stroke-width"]),n["stroke-width"]&&(M.weight=F),F&&F<1&&(_*=F)&&(M.weight=1),M.opacity=_,n["stroke-linejoin"]&&(M.joinstyle=n["stroke-linejoin"]||"miter"),M.miterlimit=n["stroke-miterlimit"]||8,n["stroke-linecap"]&&(M.endcap="butt"==n["stroke-linecap"]?"flat":"square"==n["stroke-linecap"]?"square":"round"),n["stroke-dasharray"]){var O={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};M.dashstyle=O[a](n["stroke-dasharray"])?O[n["stroke-dasharray"]]:f}I&&i.appendChild(M)}if("text"==d.type)switch(c=d.paper.span.style,r.font&&(c.font=r.font),r["font-family"]&&(c.fontFamily=r["font-family"]),r["font-size"]&&(c.fontSize=r["font-size"]),r["font-weight"]&&(c.fontWeight=r["font-weight"]),r["font-style"]&&(c.fontStyle=r["font-style"]),d.node.string&&(d.paper.span.innerHTML=g(d.node.string)[G](/</g,"<")[G](/&/g,"&")[G](/\n/g,"<br>")),d.W=r.w=d.paper.span.offsetWidth,d.H=r.h=d.paper.span.offsetHeight,d.X=r.x,d.Y=r.y+L(d.H/2),r["text-anchor"]){case"start":d.node.style["v-text-align"]="left",d.bbx=L(d.W/2);break;case"end":d.node.style["v-text-align"]="right",d.bbx=-L(d.W/2);break;default:d.node.style["v-text-align"]="center"}},Me=function(e,t){e.attrs=e.attrs||{},e.attrs;var n,o="linear",s=".5 .5";if(e.attrs.gradient=t,t=(t=g(t)[G](Z,(function(e,t,n){return o="radial",t&&n&&(t=B(t),n=B(n),E(t-.5,2)+E(n-.5,2)>.25&&(n=w.sqrt(.25-E(t-.5,2))*(2*(n>.5)-1)+.5),s=t+m+n),f}))).split(/\s*\-\s*/),"linear"==o){var i=t.shift();if(i=-B(i),isNaN(i))return null}var r=ve(t);if(!r)return null;if(!(n=(e=e.shape||e.node).getElementsByTagName(P)[0]||He(P)).parentNode&&e.appendChild(n),r[b]){n.on=!0,n.method="none",n.color=r[0].color,n.color2=r[r[b]-1].color;for(var a=[],l=0,c=r[b];l<c;l++)r[l].offset&&a[A](r[l].offset+m+r[l].color);n.colors&&(n.colors.value=a[b]?a.join():"0% "+n.color),"radial"==o?(n.type="gradientradial",n.focus="100%",n.focussize=s,n.focusposition=s):(n.type="gradient",n.angle=(270-i)%360)}return 1},(Re=(Ae=function(e,n,o){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.X=0,this.Y=0,this.attrs={},this.Group=n,this.paper=o,this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1},!o.bottom&&(o.bottom=this),this.prev=o.top,o.top&&(o.top.next=this),o.top=this,this.next=null})[r]).rotate=function(e,t,n){return this.removed?this:null==e?this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(m):this._.rt.deg:((e=g(e).split(o))[b]-1&&(t=B(e[1]),n=B(e[2])),e=B(e[0]),null!=t?this._.rt.deg=e:this._.rt.deg+=e,null==n&&(t=null),this._.rt.cx=t,this._.rt.cy=n,this.setBox(this.attrs,t,n),this.Group.style.rotation=this._.rt.deg,this)},Re.setBox=function(e,t,n){if(this.removed)return this;var o=this.Group.style,s=this.shape&&this.shape.style||this.node.style;for(var i in e=e||{})e[a](i)&&(this.attrs[i]=e[i]);t=t||this._.rt.cx,n=n||this._.rt.cy;var r,l,c,p,d=this.attrs;switch(this.type){case"circle":r=d.cx-d.r,l=d.cy-d.r,c=p=2*d.r;break;case"ellipse":r=d.cx-d.rx,l=d.cy-d.ry,c=2*d.rx,p=2*d.ry;break;case"image":r=+d.x,l=+d.y,c=d.width||0,p=d.height||0;break;case"text":this.textpath.v=["m",L(d.x),", ",L(d.y-2),"l",L(d.x)+1,", ",L(d.y-2)].join(f),r=d.x-L(this.W/2),l=d.y-this.H/2,c=this.W,p=this.H;break;case"rect":case"path":if(this.attrs.path){var u=ae(this.attrs.path);r=u.x,l=u.y,c=u.width,p=u.height}else r=0,l=0,c=this.paper.width,p=this.paper.height;break;default:r=0,l=0,c=this.paper.width,p=this.paper.height}n=null==n?l+p/2:n;var h,m=(t=null==t?r+c/2:t)-this.paper.width/2,g=n-this.paper.height/2;o.left!=(h=m+"px")&&(o.left=h),o.top!=(h=g+"px")&&(o.top=h),this.X=$e[a](this.type)?-m:r,this.Y=$e[a](this.type)?-g:l,this.W=c,this.H=p,$e[a](this.type)?(s.left!=(h=-m*Ye+"px")&&(s.left=h),s.top!=(h=-g*Ye+"px")&&(s.top=h)):"text"==this.type?(s.left!=(h=-m+"px")&&(s.left=h),s.top!=(h=-g+"px")&&(s.top=h)):(o.width!=(h=this.paper.width+"px")&&(o.width=h),o.height!=(h=this.paper.height+"px")&&(o.height=h),s.left!=(h=r-m+"px")&&(s.left=h),s.top!=(h=l-g+"px")&&(s.top=h),s.width!=(h=c+"px")&&(s.width=h),s.height!=(h=p+"px")&&(s.height=h))},Re.hide=function(){return!this.removed&&(this.Group.style.display="none"),this},Re.show=function(){return!this.removed&&(this.Group.style.display="block"),this},Re.getBBox=function(){return this.removed?this:$e[a](this.type)?ae(this.attrs.path):{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}},Re.remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this.Group.parentNode.removeChild(this.Group),this.shape&&this.shape.parentNode.removeChild(this.shape),this)delete this[e];this.removed=!0}},Re.attr=function(e,n){if(this.removed)return this;if(null==e){var o={};for(var s in this.attrs)this.attrs[a](s)&&(o[s]=this.attrs[s]);return this._.rt.deg&&(o.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(o.scale=this.scale()),o.gradient&&"none"==o.fill&&(o.fill=o.gradient)&&delete o.gradient,o}if(null==n&&t.is(e,"string"))return"translation"==e?gt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(this.attrs&&null==n&&t.is(e,I)){var i,r={};for(s=0,i=e[b];s<i;s++)r[e[s]]=this.attr(e[s]);return r}var l;if(null!=n&&((l={})[e]=n),null==n&&t.is(e,"object")&&(l=e),l){for(var c in this.paper.customAttributes)if(this.paper.customAttributes[a](c)&&l[a](c)&&t.is(this.paper.customAttributes[c],"function")){var p=this.paper.customAttributes[c].apply(this,[].concat(l[c]));for(var d in this.attrs[c]=l[c],p)p[a](d)&&(l[d]=p[d])}l.text&&"text"==this.type&&(this.node.string=l.text),Pe(this,l),l.gradient&&({circle:1,ellipse:1}[a](this.type)||"r"!=g(l.gradient).charAt())&&Me(this,l.gradient),(!$e[a](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this},Re.toFront=function(){return!this.removed&&this.Group.parentNode.appendChild(this.Group),this.paper.top!=this&&we(this,this.paper),this},Re.toBack=function(){return this.removed||this.Group.parentNode.firstChild!=this.Group&&(this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild),Ce(this,this.paper)),this},Re.insertAfter=function(e){return this.removed||(e.constructor==bt&&(e=e[e.length-1]),e.Group.nextSibling?e.Group.parentNode.insertBefore(this.Group,e.Group.nextSibling):e.Group.parentNode.appendChild(this.Group),ke(this,e,this.paper)),this},Re.insertBefore=function(e){return this.removed||(e.constructor==bt&&(e=e[0]),e.Group.parentNode.insertBefore(this.Group,e.Group),Se(this,e,this.paper)),this},Re.blur=function(e){var n=this.node.runtimeStyle,o=n.filter;o=o.replace(Ge,f),0!=+e?(this.attrs.blur=e,n.filter=o+m+q+".Blur(pixelradius="+(+e||1.5)+")",n.margin=t.format("-{0}px 0 0 -{0}px",L(+e||1.5))):(n.filter=o,n.margin=0,delete this.attrs.blur)},Fe=function(e,t,n,o){var s=He("group"),i=He("oval");i.style,s.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",s.coordsize=je,s.coordorigin=e.coordorigin,s.appendChild(i);var r=new Ae(i,s,e);return r.type="circle",Pe(r,{stroke:"#000",fill:"none"}),r.attrs.cx=t,r.attrs.cy=n,r.attrs.r=o,r.setBox({x:t-o,y:n-o,width:2*o,height:2*o}),e.canvas.appendChild(s),r},Oe=function(e,t,n,o,s,i){var r=wt(t,n,o,s,i),a=e.path(r),l=a.attrs;return a.X=l.x=t,a.Y=l.y=n,a.W=l.width=o,a.H=l.height=s,l.r=i,l.path=r,a.type="rect",a},De=function(e,t,n,o,s){var i=He("group"),r=He("oval");r.style,i.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",i.coordsize=je,i.coordorigin=e.coordorigin,i.appendChild(r);var a=new Ae(r,i,e);return a.type="ellipse",Pe(a,{stroke:"#000"}),a.attrs.cx=t,a.attrs.cy=n,a.attrs.rx=o,a.attrs.ry=s,a.setBox({x:t-o,y:n-s,width:2*o,height:2*s}),e.canvas.appendChild(i),a},Le=function(e,t,n,o,s,i){var r=He("group"),a=He("image");r.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",r.coordsize=je,r.coordorigin=e.coordorigin,a.src=t,r.appendChild(a);var l=new Ae(a,r,e);return l.type="image",l.attrs.src=t,l.attrs.x=n,l.attrs.y=o,l.attrs.w=s,l.attrs.h=i,l.setBox({x:n,y:o,width:s,height:i}),e.canvas.appendChild(r),l},Be=function(e,n,o,s){var i=He("group"),r=He("shape"),a=r.style,l=He("path");l.style;var c=He("textpath");i.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",i.coordsize=je,i.coordorigin=e.coordorigin,l.v=t.format("m{0},{1}l{2},{1}",L(10*n),L(10*o),L(10*n)+1),l.textpathok=!0,a.width=e.width,a.height=e.height,c.string=g(s),c.on=!0,r.appendChild(c),r.appendChild(l),i.appendChild(r);var p=new Ae(c,i,e);return p.shape=r,p.textpath=l,p.type="text",p.attrs.text=s,p.attrs.x=n,p.attrs.y=o,p.attrs.w=1,p.attrs.h=1,Pe(p,{font:W.font,stroke:"none",fill:"#000"}),p.setBox(),e.canvas.appendChild(i),p},ze=function(e,t){var n=this.canvas.style;return e==+e&&(e+="px"),t==+t&&(t+="px"),n.width=e,n.height=t,n.clip="rect(0 "+e+" "+t+" 0)",this},l.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!l.namespaces.rvml&&l.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),He=function(e){return l.createElement("<rvml:"+e+' class="rvml">')}}catch(Ct){He=function(e){return l.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}qe=function(){var e=ye[u](0,arguments),n=e.container,o=e.height,s=e.width,i=e.x,r=e.y;if(!n)throw new Error("VML container not found.");var a=new d,c=a.canvas=l.createElement("div"),p=c.style;return i=i||0,r=r||0,(s=s||512)==+s&&(s+="px"),(o=o||342)==+o&&(o+="px"),a.width=1e3,a.height=1e3,a.coordsize="10000 10000",a.coordorigin="0 0",a.span=l.createElement("span"),a.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",c.appendChild(a.span),p.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",s,o),1==n?(l.body.appendChild(c),p.left=i+"px",p.top=r+"px",p.position="absolute"):n.firstChild?n.insertBefore(c,n.firstChild):n.appendChild(c),be.call(a,a,t.fn),a},n.clear=function(){this.canvas.innerHTML=f,this.span=l.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},n.remove=function(){for(var e in this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Ee(e);return!0}}var Xe=navigator.userAgent.match(/Version\/(.*?)\s/);"Apple Computer, Inc."==navigator.vendor&&(Xe&&Xe[1]<4||"iP"==navigator.platform.slice(0,2))?n.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});c.setTimeout((function(){e.remove()}))}:n.safari=function(){};for(var Ke=function(){this.returnValue=!1},Ze=function(){return this.originalEvent.preventDefault()},Je=function(){this.cancelBubble=!0},Qe=function(){return this.originalEvent.stopPropagation()},et=l.addEventListener?function(e,t,n,o){var s=h&&y[t]?y[t]:t,i=function(s){if(h&&y[a](t))for(var i=0,r=s.targetTouches&&s.targetTouches.length;i<r;i++)if(s.targetTouches[i].target==e){var l=s;(s=s.targetTouches[i]).originalEvent=l,s.preventDefault=Ze,s.stopPropagation=Qe;break}return n.call(o,s)};return e.addEventListener(s,i,!1),function(){return e.removeEventListener(s,i,!1),!0}}:l.attachEvent?function(e,t,n,o){var s=function(e){return(e=e||c.event).preventDefault=e.preventDefault||Ke,e.stopPropagation=e.stopPropagation||Je,n.call(o,e)};return e.attachEvent("on"+t,s),function(){return e.detachEvent("on"+t,s),!0}}:void 0,tt=[],nt=function(e){for(var t,n=e.clientX,o=e.clientY,s=l.documentElement.scrollTop||l.body.scrollTop,i=l.documentElement.scrollLeft||l.body.scrollLeft,r=tt.length;r--;){if(t=tt[r],h){for(var a,c=e.touches.length;c--;)if((a=e.touches[c]).identifier==t.el._drag.id){n=a.clientX,o=a.clientY,(e.originalEvent?e.originalEvent:e).preventDefault();break}}else e.preventDefault();n+=i,o+=s,t.move&&t.move.call(t.move_scope||t.el,n-t.el._drag.x,o-t.el._drag.y,n,o,e)}},ot=function(e){t.unmousemove(nt).unmouseup(ot);for(var n,o=tt.length;o--;)(n=tt[o]).el._drag={},n.end&&n.end.call(n.end_scope||n.start_scope||n.move_scope||n.el,e);tt=[]},st=v[b];st--;)!function(e){t[e]=Ae[r][e]=function(n,o){return t.is(n,"function")&&(this.events=this.events||[],this.events.push({name:e,f:n,unbind:et(this.shape||this.node||l,e,n,o||this)})),this},t["un"+e]=Ae[r]["un"+e]=function(t){for(var n=this.events,o=n[b];o--;)if(n[o].name==e&&n[o].f==t)return n[o].unbind(),n.splice(o,1),!n.length&&delete this.events,this;return this}}(v[st]);function it(){return this.x+m+this.y}Re.hover=function(e,t,n,o){return this.mouseover(e,n).mouseout(t,o||n)},Re.unhover=function(e,t){return this.unmouseover(e).unmouseout(t)},Re.drag=function(e,n,o,s,i,r){return this._drag={},this.mousedown((function(a){(a.originalEvent||a).preventDefault();var c=l.documentElement.scrollTop||l.body.scrollTop,p=l.documentElement.scrollLeft||l.body.scrollLeft;this._drag.x=a.clientX+p,this._drag.y=a.clientY+c,this._drag.id=a.identifier,n&&n.call(i||s||this,a.clientX+p,a.clientY+c,a),!tt.length&&t.mousemove(nt).mouseup(ot),tt.push({el:this,move:e,end:o,move_scope:s,start_scope:i,end_scope:r})})),this},Re.undrag=function(e,n,o){for(var s=tt.length;s--;)tt[s].el==this&&tt[s].move==e&&tt[s].end==o&&tt.splice(s++,1);!tt.length&&t.unmousemove(nt).unmouseup(ot)},n.circle=function(e,t,n){return Fe(this,e||0,t||0,n||0)},n.rect=function(e,t,n,o,s){return Oe(this,e||0,t||0,n||0,o||0,s||0)},n.ellipse=function(e,t,n,o){return De(this,e||0,t||0,n||0,o||0)},n.path=function(e){return e&&!t.is(e,M)&&!t.is(e[0],I)&&(e+=f),Te(t.format[u](t,arguments),this)},n.image=function(e,t,n,o,s){return Le(this,e||"about:blank",t||0,n||0,o||0,s||0)},n.text=function(e,t,n){return Be(this,e||0,t||0,g(n))},n.set=function(e){return arguments[b]>1&&(e=Array[r].splice.call(arguments,0,arguments[b])),new bt(e)},n.setSize=ze,n.top=n.bottom=null,n.raphael=t,Re.resetScale=function(){if(this.removed)return this;this._.sx=1,this._.sy=1,this.attrs.scale="1 1"},Re.scale=function(t,n,o,s){if(this.removed)return this;if(null==t&&null==n)return{x:this._.sx,y:this._.sy,toString:it};!+(n=n||t)&&(n=t);var i,r,a=this.attrs;if(0!=t){var l=this.getBBox(),c=l.x+l.width/2,p=l.y+l.height/2,d=S(t/this._.sx),u=S(n/this._.sy);o=+o||0==o?o:c,s=+s||0==s?s:p;var h=this._.sx>0,g=this._.sy>0,v=~~(t/S(t)),y=~~(n/S(n)),x=d*v,w=u*y,C=this.node.style,k=o+S(c-o)*x*(c>o==h?1:-1),E=s+S(p-s)*w*(p>s==g?1:-1),_=t*v>n*y?u:d;switch(this.type){case"rect":case"image":var T=a.width*d,M=a.height*u;this.attr({height:M,r:a.r*_,width:T,x:k-T/2,y:E-M/2});break;case"circle":case"ellipse":this.attr({rx:a.rx*d,ry:a.ry*u,r:a.r*_,cx:k,cy:E});break;case"text":this.attr({x:k,y:E});break;case"path":for(var I=ce(a.path),P=!0,N=h?x:d,A=g?w:u,R=0,F=I[b];R<F;R++){var O=I[R],D=H.call(O[0]);if("M"!=D||!P)if(P=!1,"A"==D)O[I[R][b]-2]*=N,O[I[R][b]-1]*=A,O[1]*=d,O[2]*=u,O[5]=+(v+y?!!+O[5]:!+O[5]);else if("H"==D)for(var L=1,B=O[b];L<B;L++)O[L]*=N;else if("V"==D)for(L=1,B=O[b];L<B;L++)O[L]*=A;else for(L=1,B=O[b];L<B;L++)O[L]*=L%2?N:A}var z=ae(I);i=k-z.x-z.width/2,r=E-z.y-z.height/2,I[0][1]+=i,I[0][2]+=r,this.attr({path:I})}!(this.type in{text:1,image:1})||1==v&&1==y?this.transformations?(this.transformations[2]=f,e(this.node,"transform",this.transformations.join(m)),a.fx=0,a.fy=0):(this.node.filterMatrix=f,C.filter=(this.node.filterMatrix||f)+(this.node.filterOpacity||f)):this.transformations?(this.transformations[2]="scale(".concat(v,",",y,")"),e(this.node,"transform",this.transformations.join(m)),i=-1==v?-a.x-(T||0):a.x,r=-1==y?-a.y-(M||0):a.y,this.attr({x:i,y:r}),a.fx=v-1,a.fy=y-1):(this.node.filterMatrix=q+".Matrix(M11=".concat(v,", M12=0, M21=0, M22=",y,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')"),C.filter=(this.node.filterMatrix||f)+(this.node.filterOpacity||f)),a.scale=[t,n,o,s].join(m),this._.sx=t,this._.sy=n}return this},Re.clone=function(){if(this.removed)return null;var e=this.attr();return delete e.scale,delete e.translation,this.paper[this.type]().attr(e)};var rt={},at=function(e,n,o,s,i,r,a,l,c){if(e===o&&n===s&&i===a&&r==l){var p=a-e,d=l-n,u=Math.sqrt(p*p+d*d);if(null==c)return u;var h=c/u;return{start:{x:e,y:n},m:{x:e,y:n},n:{x:a,y:l},end:{x:a,y:l},x:e+h*p,y:n+h*d,alpha:90-180*w.atan(p/d)/_}}var f,m,g=0,v=100,y=[e,n,o,s,i,r,a,l].join(),b=rt[y];(!b&&(rt[y]=b={data:[]}),b.timer&&clearTimeout(b.timer),b.timer=setTimeout((function(){delete rt[y]}),2e3),null!=c)&&(v=10*~~at(e,n,o,s,i,r,a,l));for(var x=0;x<v+1;x++){if(b.data[c]>x?m=b.data[x*v]:(m=t.findDotsAtSegment(e,n,o,s,i,r,a,l,x/v),b.data[x]=m),x&&(g+=E(E(f.x-m.x,2)+E(f.y-m.y,2),.5)),null!=c&&g>=c)return m;f=m}if(null==c)return g},lt=function(e,n){return function(o,s,i){for(var r,a,l,c,p,d="",u={},h=0,f=0,m=(o=ge(o)).length;f<m;f++){if("M"==(l=o[f])[0])r=+l[1],a=+l[2];else{if(h+(c=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6]))>s){if(n&&!u.start){if(d+=["C",(p=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6],s-h)).start.x,p.start.y,p.m.x,p.m.y,p.x,p.y],i)return d;u.start=d,d=["M",p.x,p.y+"C",p.n.x,p.n.y,p.end.x,p.end.y,l[5],l[6]].join(),h+=c,r=+l[5],a=+l[6];continue}if(!e&&!n)return{x:(p=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6],s-h)).x,y:p.y,alpha:p.alpha}}h+=c,r=+l[5],a=+l[6]}d+=l}return u.end=d,(p=e?h:n?u:t.findDotsAtSegment(r,a,l[1],l[2],l[3],l[4],l[5],l[6],1)).alpha&&(p={x:p.x,y:p.y,alpha:p.alpha}),p}},ct=lt(1),pt=lt(),dt=lt(0,1);Re.getTotalLength=function(){if("path"==this.type)return this.node.getTotalLength?this.node.getTotalLength():ct(this.attrs.path)},Re.getPointAtLength=function(e){if("path"==this.type)return pt(this.attrs.path,e)},Re.getSubpath=function(e,t){if("path"==this.type){if(S(this.getTotalLength()-t)<"1e-6")return dt(this.attrs.path,e).end;var n=dt(this.attrs.path,t,1);return e?dt(n,e).end:n}},t.easing_formulas={linear:function(e){return e},"<":function(e){return E(e,3)},">":function(e){return E(e-1,3)+1},"<>":function(e){return(e*=2)<1?E(e,3)/2:(E(e-=2,3)+2)/2},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return(e-=1)*e*((t+1)*e+t)+1},elastic:function(e){if(0==e||1==e)return e;return E(2,-10*e)*w.sin(2*_*(e-.075)/.3)+1},bounce:function(e){var t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375}};var ut=[],ht=function(){for(var e=+new Date,n=0;n<ut[b];n++){var o=ut[n];if(!o.stop&&!o.el.removed){var s,i=e-o.start,r=o.ms,l=o.easing,c=o.from,p=o.diff,d=o.to,u=o.t,h=o.el,g={};if(i<r){var v=l(i/r);for(var y in c)if(c[a](y)){switch(U[y]){case"along":s=v*r*p[y],d.back&&(s=d.len-s);var x=pt(d[y],s);h.translate(p.sx-p.x||0,p.sy-p.y||0),p.x=x.x,p.y=x.y,h.translate(x.x-p.sx,x.y-p.sy),d.rot&&h.rotate(p.r+x.alpha,x.x,x.y);break;case T:s=+c[y]+v*r*p[y];break;case"colour":s="rgb("+[mt(L(c[y].r+v*r*p[y].r)),mt(L(c[y].g+v*r*p[y].g)),mt(L(c[y].b+v*r*p[y].b))].join(",")+")";break;case"path":s=[];for(var w=0,C=c[y][b];w<C;w++){s[w]=[c[y][w][0]];for(var k=1,S=c[y][w][b];k<S;k++)s[w][k]=+c[y][w][k]+v*r*p[y][w][k];s[w]=s[w].join(m)}s=s.join(m);break;case"csv":switch(y){case"translation":var E=v*r*p[y][0]-u.x,_=v*r*p[y][1]-u.y;u.x+=E,u.y+=_,s=E+m+_;break;case"rotation":s=+c[y][0]+v*r*p[y][0],c[y][1]&&(s+=","+c[y][1]+","+c[y][2]);break;case"scale":s=[+c[y][0]+v*r*p[y][0],+c[y][1]+v*r*p[y][1],2 in d[y]?d[y][2]:f,3 in d[y]?d[y][3]:f].join(m);break;case"clip-rect":for(s=[],w=4;w--;)s[w]=+c[y][w]+v*r*p[y][w]}break;default:var M=[].concat(c[y]);for(s=[],w=h.paper.customAttributes[y].length;w--;)s[w]=+M[w]+v*r*p[y][w]}g[y]=s}h.attr(g),h._run&&h._run.call(h)}else d.along&&(x=pt(d.along,d.len*!d.back),h.translate(p.sx-(p.x||0)+x.x-p.sx,p.sy-(p.y||0)+x.y-p.sy),d.rot&&h.rotate(p.r+x.alpha,x.x,x.y)),(u.x||u.y)&&h.translate(-u.x,-u.y),d.scale&&(d.scale+=f),h.attr(d),ut.splice(n--,1)}}t.svg&&h&&h.paper&&h.paper.safari(),ut[b]&&setTimeout(ht)},ft=function(e,n,o,s,i){var r=o-s;n.timeouts.push(setTimeout((function(){t.is(i,"function")&&i.call(n),n.animate(e,r,e.easing)}),s))},mt=function(e){return C(k(e,255),0)},gt=function(e,t){if(null==e)return{x:this._.tx,y:this._.ty,toString:it};switch(this._.tx+=+e,this._.ty+=+t,this.type){case"circle":case"ellipse":this.attr({cx:+e+this.attrs.cx,cy:+t+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+e+this.attrs.x,y:+t+this.attrs.y});break;case"path":var n=ce(this.attrs.path);n[0][1]+=+e,n[0][2]+=+t,this.attr({path:n})}return this};function vt(e){return function(n,o,s,i){var r={back:e};return t.is(s,"function")?i=s:r.rot=s,n&&n.constructor==Ae&&(n=n.attrs.path),n&&(r.along=n),this.animate(r,o,i)}}function yt(e,t,n,o,s,i){var r=3*t,a=3*(o-t)-r,l=1-r-a,c=3*n,p=3*(s-n)-c,d=1-c-p;function u(e){return((l*e+a)*e+r)*e}return function(e,t){var n=function(e,t){var n,o,s,i,c,p;for(s=e,p=0;p<8;p++){if(i=u(s)-e,S(i)<t)return s;if(S(c=(3*l*s+2*a)*s+r)<1e-6)break;s-=i/c}if(o=1,(s=e)<(n=0))return n;if(s>o)return o;for(;n<o;){if(i=u(s),S(i-e)<t)return s;e>i?n=s:o=s,s=(o-n)/2+n}return s}(e,t);return((d*n+p)*n+c)*n}(e,1/(200*i))}Re.animateWith=function(e,t,n,o,s){for(var i=0,r=ut.length;i<r;i++)ut[i].el.id==e.id&&(t.start=ut[i].start);return this.animate(t,n,o,s)},Re.animateAlong=vt(),Re.animateAlongBack=vt(1),Re.onAnimation=function(e){return this._run=e||0,this},Re.animate=function(e,n,s,i){var r=this;if(r.timeouts=r.timeouts||[],!t.is(s,"function")&&s||(i=s||null),r.removed)return i&&i.call(r),r;var l={},c={},p=!1,d={};for(var u in e)if(e[a](u)&&(U[a](u)||r.paper.customAttributes[a](u)))switch(p=!0,l[u]=r.attr(u),null==l[u]&&(l[u]=W[u]),c[u]=e[u],U[u]){case"along":var h=ct(e[u]),f=pt(e[u],h*!!e.back),m=r.getBBox();d[u]=h/n,d.tx=m.x,d.ty=m.y,d.sx=f.x,d.sy=f.y,c.rot=e.rot,c.back=e.back,c.len=h,e.rot&&(d.r=B(r.rotate())||0);break;case T:d[u]=(c[u]-l[u])/n;break;case"colour":l[u]=t.getRGB(l[u]);var v=t.getRGB(c[u]);d[u]={r:(v.r-l[u].r)/n,g:(v.g-l[u].g)/n,b:(v.b-l[u].b)/n};break;case"path":var y=ge(l[u],c[u]);l[u]=y[0];var x=y[1];d[u]=[];for(var w=0,C=l[u][b];w<C;w++){d[u][w]=[0];for(var k=1,S=l[u][w][b];k<S;k++)d[u][w][k]=(x[w][k]-l[u][w][k])/n}break;case"csv":var E=g(e[u]).split(o),_=g(l[u]).split(o);switch(u){case"translation":l[u]=[0,0],d[u]=[E[0]/n,E[1]/n];break;case"rotation":l[u]=_[1]==E[1]&&_[2]==E[2]?_:[0,E[1],E[2]],d[u]=[(E[0]-l[u][0])/n,0,0];break;case"scale":e[u]=E,l[u]=g(l[u]).split(o),d[u]=[(E[0]-l[u][0])/n,(E[1]-l[u][1])/n,0,0];break;case"clip-rect":for(l[u]=g(l[u]).split(o),d[u]=[],w=4;w--;)d[u][w]=(E[w]-l[u][w])/n}c[u]=E;break;default:for(E=[].concat(e[u]),_=[].concat(l[u]),d[u]=[],w=r.paper.customAttributes[u][b];w--;)d[u][w]=((E[w]||0)-(_[w]||0))/n}if(p){var M=t.easing_formulas[s];if(!M)if((M=g(s).match(D))&&5==M[b]){var I=M;M=function(e){return yt(e,+I[1],+I[2],+I[3],+I[4],n)}}else M=function(e){return e};ut.push({start:e.start||+new Date,ms:n,easing:M,from:l,diff:d,to:c,el:r,t:{x:0,y:0}}),t.is(i,"function")&&(r._ac=setTimeout((function(){i.call(r)}),n)),1==ut[b]&&setTimeout(ht)}else{var P,N=[];for(var A in e)e[a](A)&&V.test(A)&&(u={value:e[A]},"from"==A&&(A=0),"to"==A&&(A=100),u.key=z(A,10),N.push(u));for(N.sort(J),N[0].key&&N.unshift({key:0,value:r.attrs}),w=0,C=N[b];w<C;w++)ft(N[w].value,r,n/100*N[w].key,n/100*(N[w-1]&&N[w-1].key||0),N[w-1]&&N[w-1].value.callback);(P=N[N[b]-1].value.callback)&&r.timeouts.push(setTimeout((function(){P.call(r)}),n))}return this},Re.stop=function(){for(var e=0;e<ut.length;e++)ut[e].el.id==this.id&&ut.splice(e--,1);for(e=0,ii=this.timeouts&&this.timeouts.length;e<ii;e++)clearTimeout(this.timeouts[e]);return this.timeouts=[],clearTimeout(this._ac),delete this._ac,this},Re.translate=function(e,t){return this.attr({translation:e+" "+t})},Re.toString=function(){return"Raphaël’s object"},t.ae=ut;var bt=function(e){if(this.items=[],this[b]=0,this.type="set",e)for(var t=0,n=e[b];t<n;t++)!e[t]||e[t].constructor!=Ae&&e[t].constructor!=bt||(this[this.items[b]]=this.items[this.items[b]]=e[t],this[b]++)};for(var xt in bt[r][A]=function(){for(var e,t,n=0,o=arguments[b];n<o;n++)!(e=arguments[n])||e.constructor!=Ae&&e.constructor!=bt||(this[t=this.items[b]]=this.items[t]=e,this[b]++);return this},bt[r].pop=function(){return delete this[this[b]--],this.items.pop()},Re)Re[a](xt)&&(bt[r][xt]=function(e){return function(){for(var t=0,n=this.items[b];t<n;t++)this.items[t][e][u](this.items[t],arguments);return this}}(xt));bt[r].attr=function(e,n){if(e&&t.is(e,I)&&t.is(e[0],"object"))for(var o=0,s=e[b];o<s;o++)this.items[o].attr(e[o]);else for(var i=0,r=this.items[b];i<r;i++)this.items[i].attr(e,n);return this},bt[r].animate=function(e,n,o,s){(t.is(o,"function")||!o)&&(s=o||null);var i,r,a=this.items[b],l=a,c=this;for(s&&(r=function(){!--a&&s.call(c)}),o=t.is(o,M)?o:r,i=this.items[--l].animate(e,n,o,r);l--;)this.items[l]&&!this.items[l].removed&&this.items[l].animateWith(i,e,n,o,r);return this},bt[r].insertAfter=function(e){for(var t=this.items[b];t--;)this.items[t].insertAfter(e);return this},bt[r].getBBox=function(){for(var e=[],t=[],n=[],o=[],s=this.items[b];s--;){var i=this.items[s].getBBox();e[A](i.x),t[A](i.y),n[A](i.x+i.width),o[A](i.y+i.height)}return{x:e=k[u](0,e),y:t=k[u](0,t),width:C[u](0,n)-e,height:C[u](0,o)-t}},bt[r].clone=function(e){e=new bt;for(var t=0,n=this.items[b];t<n;t++)e[A](this.items[t].clone());return e},t.registerFont=function(e){if(!e.face)return e;this.fonts=this.fonts||{};var t={w:e.w,face:{},glyphs:{}},n=e.face["font-family"];for(var o in e.face)e.face[a](o)&&(t.face[o]=e.face[o]);if(this.fonts[n]?this.fonts[n][A](t):this.fonts[n]=[t],!e.svg)for(var s in t.face["units-per-em"]=z(e.face["units-per-em"],10),e.glyphs)if(e.glyphs[a](s)){var i=e.glyphs[s];if(t.glyphs[s]={w:i.w,k:{},d:i.d&&"M"+i.d[G](/[mlcxtrv]/g,(function(e){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[e]||"M"}))+"z"},i.k)for(var r in i.k)i[a](r)&&(t.glyphs[s].k[r]=i.k[r])}return e},n.getFont=function(e,n,o,s){if(s=s||"normal",o=o||"normal",n=+n||{normal:400,bold:700,lighter:300,bolder:800}[n]||400,t.fonts){var i,r=t.fonts[e];if(!r){var l=new RegExp("(^|\\s)"+e[G](/[^\w\d\s+!~.:_-]/g,f)+"(\\s|$)","i");for(var c in t.fonts)if(t.fonts[a](c)&&l.test(c)){r=t.fonts[c];break}}if(r)for(var p=0,d=r[b];p<d&&((i=r[p]).face["font-weight"]!=n||i.face["font-style"]!=o&&i.face["font-style"]||i.face["font-stretch"]!=s);p++);return i}},n.print=function(e,n,s,i,r,a,l){a=a||"middle",l=C(k(l||0,1),-1);var c,p=this.set(),d=g(s).split(f),u=0;if(t.is(i,s)&&(i=this.getFont(i)),i){c=(r||16)/i.face["units-per-em"];for(var h=i.face.bbox.split(o),m=+h[0],v=+h[1]+("baseline"==a?h[3]-h[1]+ +i.face.descent:(h[3]-h[1])/2),y=0,x=d[b];y<x;y++){var w=y&&i.glyphs[d[y-1]]||{},S=i.glyphs[d[y]];u+=y?(w.w||i.w)+(w.k&&w.k[d[y]]||0)+i.w*l:0,S&&S.d&&p[A](this.path(S.d).attr({fill:"#000",stroke:"none",translation:[u,0]}))}p.scale(c,c,m,v).translate(e-m,n-v)}return p},t.format=function(e,n){var o=t.is(n,I)?[0].concat(n):arguments;return e&&t.is(e,M)&&o[b]-1&&(e=e[G](i,(function(e,t){return null==o[++t]?f:o[t]}))),e||f},t.ninja=function(){return p.was?c.Raphael=p.is:Raphael=void 0,t},t.el=Re,t.st=bt[r],pn.exports=t}();const dn={BLUE:"#6495ED",ORANGE:"#FFA500",PINK:"#FF00AF",GREEN:"#28AE7B",PURPLE:"#9D38BD",RED:"#DF0030",GRAY:"gray",BLACK:"black",LIGHT_BLUE:"#9AB8ED",LIGHT_ORANGE:"#EDD19B",LIGHT_PINK:"#ED9BD3",LIGHT_GREEN:"#9BEDCE",LIGHT_PURPLE:"#DA9BED",LIGHT_RED:"#ED9AAC",LIGHT_GRAY:"#ED9B9B",LIGHT_BLACK:"#ED9B9B",GRAY10:"#D6D6D6",GRAY20:"#CDCDCD",GRAY30:"#B3B3B3",GRAY40:"#9A9A9A",GRAY50:"#808080",GRAY60:"#666666",GRAY70:"#4D4D4D",GRAY80:"#333333",GRAY90:"#1A1A1A",BLUE_A:"#CCFAFF",BLUE_B:"#80F6FF",BLUE_C:"#63D9EA",BLUE_D:"#11ACCD",BLUE_E:"#0C7F99",TEAL_A:"#94FFF5",TEAL_B:"#26EDD5",TEAL_C:"#01D1C1",TEAL_D:"#01A995",TEAL_E:"#208170",GREEN_A:"#B6FFB0",GREEN_B:"#8AF281",GREEN_C:"#74CF70",GREEN_D:"#1FAB54",GREEN_E:"#0D923F",GOLD_A:"#FFD0A9",GOLD_B:"#FFBB71",GOLD_C:"#FF9C39",GOLD_D:"#E07D10",GOLD_E:"#A75A05",RED_A:"#FCA9A9",RED_B:"#FF8482",RED_C:"#F9685D",RED_D:"#E84D39",RED_E:"#BC2612",MAROON_A:"#FFBDE0",MAROON_B:"#FF92C6",MAROON_C:"#ED5FA6",MAROON_D:"#CA337C",MAROON_E:"#9E034E",PURPLE_A:"#DDD7FF",PURPLE_B:"#C6B9FC",PURPLE_C:"#AA87FF",PURPLE_D:"#7854AB",PURPLE_E:"#543B78",MINT_A:"#F5F9E8",MINT_B:"#EDF2DF",MINT_C:"#E0E5CC",GRAY_A:"#F6F7F7",GRAY_B:"#F0F1F2",GRAY_C:"#E3E5E6",GRAY_D:"#D6D8DA",GRAY_E:"#BABEC2",GRAY_F:"#888D93",GRAY_G:"#626569",GRAY_H:"#3B3E40",GRAY_I:"#21242C",KA_BLUE:"#314453",KA_GREEN:"#71B307",_BACKGROUND:"#FDFDFD",INTERACTING:"#71B307",INTERACTIVE:"#71B307",DYNAMIC:"#6495ED"};function un(e,t){const n=R.default(e).find("."+t);return 0===n.length?R.default("<span>").addClass(t).appendTo(R.default(e)):n}function hn(e,t){let n=0;!function o(){e.scrollHeight>18||n>=10?t():(n++,setTimeout(o,100))}()}var fn={processMath:async function(e,t,n,o){const s=R.default(e);if(null==s.attr("data-math-formula")||n){const n=un(s,"katex-holder"),i=un(s,"mathjax-holder"),r=i.find("script[type='math/tex']")[0];null==t&&(s.attr("data-math-formula")?t=s.attr("data-math-formula"):r&&(t=r.text||r.textContent)),t=null!=t?t+"":"",t=ae.cleanMath(t),s.attr("data-math-formula",t);const a=await ne().getKaTeX();try{if(a.render(t,n[0],{colorIsTextColor:!0}),"mathjax"===s.attr("data-math-type")&&"undefined"!=typeof MathJax){const e=MathJax.Hub.getJaxFor(r);if(e){const t=e.SourceElement();t.previousSibling&&t.previousSibling.className&&e.Remove()}}return s.attr("data-math-type","katex"),void(o&&hn(e,o))}catch(e){if(ne().logKaTeXError(t,e),e instanceof a.ParseError)throw e}s.attr("data-math-type","mathjax"),r?"text"in r?r.text=t:r.textContent=t:i.append("<script type='math/tex'>"+t.replace(/<\//g,"< /")+"<\/script>"),"undefined"!=typeof MathJax&&(MathJax.Hub.Queue(["Reprocess",MathJax.Hub,i[0]]),o&&MathJax.Hub.Queue((function(){const t=MathJax.Callback((function(){}));return hn(e,(function(){o(),t()})),t})))}},cleanupMath:function(e){const t=R.default(e);if(t.attr("data-math-formula")){if("undefined"!=typeof MathJax){const e=MathJax.Hub.getJaxFor(t.find("script")[0]);if(e){const t=e.SourceElement();t.previousSibling&&t.previousSibling.className&&e.Remove()}}t.text(t.attr("data-math-formula")),t.attr("data-math-formula",null),t.attr("data-math-type",null)}return e},retrieveMathFormula:function(e){return R.default(e).attr("data-math-formula")}};const{processMath:mn}=fn;function gn(e,t){return"number"==typeof e&&(e=[e,e]),t=t*Math.PI/180,[e[0]*Math.cos(t),e[1]*Math.sin(t)]}const vn={unscaledSvgPath:function(e){return!0===e[0]?"":R.default.map(e,(function(e,t){return!0===e?"z":(0===t?"M":"L")+e[0]+" "+e[1]})).join("")},getDistance:function(e,t){return d.point.distanceToPoint(e,t)},coordDiff:function(e,t){return M.default.map(t,(function(n,o){return t[o]-e[o]}))},snapCoord:function(e,t){return M.default.map(e,(function(e,n){return ae.roundToNearest(t[n],e)}))},findAngle:function(e,t,n){if(void 0===n){const n=e[0]-t[0],o=e[1]-t[1];return n||o?(180+180*Math.atan2(-o,-n)/Math.PI+360)%360:0}return vn.findAngle(e,n)-vn.findAngle(t,n)},graphs:{}},yn=vn.Graphie=function(){};M.default.extend(yn.prototype,{cartToPolar:function(e,t){const n=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2));let o=Math.atan2(e[1],e[0]);return o<0&&(o+=2*Math.PI),t||(o=180*o/Math.PI),[n,o]},polar:gn});const bn={center:[-.5,-.5],above:[-.5,-1],"above right":[0,-1],right:[0,-.5],"below right":[0,0],below:[-.5,0],"below left":[-1,0],left:[-1,-.5],"above left":[-1,-1]},xn={"stroke-width":null};vn.createGraphie=function(e){let t,n,o=40,s=40;R.default(e).css("position","relative");const i=pn.exports(e);R.default(e).children("div").css("position","absolute");let r={"stroke-width":2,fill:"none"};const a=function(e){if("number"==typeof e)return a([e,e]);const t=e[0],n=e[1];return[t*o,n*s]},l=function e(i){if("number"==typeof i)return e([i,i]);const r=i[0],a=i[1];return[(r-t[0])*o,(n[1]-a)*s]},c=function(e){if("number"==typeof e)return c([e,e]);const i=e[0],r=e[1];return[i/o+t[0],n[1]-r/s]},p=function(e){return"number"==typeof e?p([e,e]):[e[0]/o,e[1]/s]},u=function(e,t){const n=R.default(e),o=n.data("labelDirection");let[s,i]=t;if(0===s&&0===i&&([s,i]=[1,1],ie.log("Label size was 0x0 in graphie.js; using 1x1 instead")),n.css("visibility",""),"number"==typeof o){const e=Math.cos(o),t=Math.sin(o),r=Math.min(s/2/Math.abs(e),i/2/Math.abs(t));n.css({marginLeft:-s/2+e*r,marginTop:-i/2-t*r})}else{const e=bn[o||"center"];n.css({marginLeft:Math.round(s*e[0]),marginTop:Math.round(i*e[1])})}},h=function(e,t){return R.default.map(e,(function(e,n){if(!0===e)return"z";const o=t?e:l(e);return(0===n?"M":"L")+ae.bound(o[0])+" "+ae.bound(o[1])})).join("")},f=function(e,n,o){const s=function(t){return(e*t+n)*t+o};if(0===e){const e=M.default.map(t,(function(e){return[e,s(e)]}));return h(e)}const i=-n/(2*e),r=i+Math.max(Math.abs(i-t[0]),Math.abs(i-t[1])),a=[i,s(i)],c=[r,s(r)],p=[a[0],a[1]-(c[1]-a[1])],d=Math.abs(a[0]-c[0]),u=[a[0]-d,c[1]],f=[a[0]+d,c[1]],m=M.default.map([u,p,f],l),g=M.default.map(M.default.flatten(m),ae.bound);return"M"+g[0]+","+g[1]+" Q"+g[2]+","+g[3]+" "+g[4]+","+g[5]},m=function(e,n,o,s){const i=Math.abs(Math.PI/(2*n)),r=function(t){return e*Math.sin(n*t-o)+s},a=function(t){return e*n*Math.cos(o-n*t)},c=function(e,t){const n=e+i*t,o=n+i,s=[n,2*n/3+1*o/3,1*n/3+2*o/3,o],c=[r(n),r(n)+a(n)*(o-n)/3,r(o)-a(o)*(o-n)/3,r(o)];return M.default.map(M.default.zip(s,c),l)},p=t[1]-t[0],d=Math.ceil(p/i)+1;let u=o/n;const h=u-t[0];u-=i*Math.ceil(h/i);let f=c(u,0),m="M"+f[0][0]+","+f[0][1]+" C"+f[1][0]+","+f[1][1]+" "+f[2][0]+","+f[2][1]+" "+f[3][0]+","+f[3][1];for(let e=1;e<d;e++)f=c(u,e),m+=" C"+f[1][0]+","+f[1][1]+" "+f[2][0]+","+f[2][1]+" "+f[3][0]+","+f[3][1];return m};vn.svgPath=h;const g=function(e){const r={scale:function(e){"number"==typeof e&&(e=[e,e]),o=e[0],s=e[1],i.setSize((t[1]-t[0])*o,(n[1]-n[0])*s)},clipRect:function(e){const t=e[0],n=e[1];return t[1]+=n[1],{"clip-rect":l(t).concat(a(n)).join(" ")}},strokeWidth:function(e){return{"stroke-width":parseFloat(e)}},rx:function(e){return{rx:a([e,0])[0]}},ry:function(e){return{ry:a([0,e])[1]}},r:function(e){const t=a([e,e]);return{rx:t[0],ry:t[1]}}},c={};return R.default.each(e||{},(function(e,t){const n=r[e];if("function"==typeof n)R.default.extend(c,n(t));else{const n=e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase();c[n]=t}})),c},v=function e(t){const n=t.constructor.prototype;if(n===pn.exports.el){if("path"===t.type&&void 0===t.arrowheadsDrawn){const e=.6+.4*t.attr("stroke-width"),n=t.getTotalLength(),o=i.set(),s=i.path(b.isMobile?"M-4,4 C-4,4 -0.25,0 -0.25,0 C-0.25,0 -4,-4 -4,-4":"M-3 4 C-2.75 2.5 0 0.25 0.75 0C0 -0.25 -2.75 -2.5 -3 -4"),r=t.getPointAtLength(n-.4),a=t.getPointAtLength(n-.75*e),l=180*Math.atan2(r.y-a.y,r.x-a.x)/Math.PI,c=t.attr();delete c.path;let p=t.getSubpath(0,n-.75*e);return p=i.path(p).attr(c),p.arrowheadsDrawn=!0,t.remove(),s.rotate(l,b.isMobile?1e-5:.75,0).scale(e,e,.75,0).translate(a.x,a.y).attr(c).attr({"stroke-linejoin":"round","stroke-linecap":"round"}),s.arrowheadsDrawn=!0,o.push(p),o.push(s),o}}else if(n===pn.exports.st)for(let n=0,o=t.items.length;n<o;n++)e(t.items[n]);return t},y={circle:function(e,t){return i.ellipse(...l(e).concat(a([t,t])))},rect:function(e,t,n,o){const s=l([e,t+o]),r=a([n,o]),c=i.rect(...s.concat(r));return b.isMobile&&(c.node.style.shapeRendering="crispEdges"),c},ellipse:function(e,t){return i.ellipse(...l(e).concat(a(t)))},fixedEllipse:function(e,t,n,o){const s=l(e),i=a(t),r=2*i[0]*n+o,c=2*i[1]*n+o,p=s[0]-r/2,d=s[1]-c/2,u=document.createElement("div");R.default(u).css({position:"absolute",width:r+"px",height:c+"px",left:p+"px",top:d+"px"});return{wrapper:u,visibleShape:pn.exports(u,r,c).ellipse(r/2,c/2,i[0],i[1])}},arc:function(e,t,n,o,s){n=(n%360+360)%360,o=(o%360+360)%360;const r=l(e),c=a(t),p=gn(t,n),d=gn(t,o),u=l([e[0]+p[0],e[1]+p[1]]),h=l([e[0]+d[0],e[1]+d[1]]),f=((o-n)%360+360)%360>180;return i.path("M"+u.join(" ")+"A"+c.join(" ")+" 0 "+(f?1:0)+" 0 "+h.join(" ")+(s?"L"+r.join(" ")+"z":""))},path:function(e){const t=i.path(h(e));return t.graphiePath=e,t},fixedPath:function(e,t,n){e=M.default.map(e,l),t=t?l(t):null,n=n||h;const o=M.default.min(M.default.pluck(e,0)),s=M.default.max(M.default.pluck(e,0)),i=M.default.min(M.default.pluck(e,1)),r=M.default.max(M.default.pluck(e,1)),a=[4,4],c=[o,i];e=M.default.map(e,(function(e){return d.vector.add(d.vector.subtract(e,c),d.vector.scale(a,.5))}));const p=s-o+a[0],u=r-i+a[1],f=c[0]-a[0]/2,m=c[1]-a[1]/2,g=document.createElement("div");R.default(g).css({position:"absolute",width:p+"px",height:u+"px",left:f+"px",top:m+"px",transformOrigin:t?p/2+t[0]+"px "+(u/2+t[1])+"px":null});return{wrapper:g,visibleShape:pn.exports(g,p,u).path(n(e))}},scaledPath:function(e){const t=i.path(h(e,!0));return t.graphiePath=e,t},line:function(e,t){const n=this.path([e,t]);return b.isMobile&&(n.node.style.shapeRendering="crispEdges"),n},parabola:function(e,t,n){return i.path(f(e,t,n))},fixedLine:function(e,t,n){const o=[n,n];e=l(e),t=l(t);const s=[Math.min(e[0],t[0]),Math.min(e[1],t[1])];e=d.vector.add(d.vector.subtract(e,s),d.vector.scale(o,.5)),t=d.vector.add(d.vector.subtract(t,s),d.vector.scale(o,.5));const i=s[0]-o[0]/2,r=s[1]-o[1]/2,a=Math.abs(e[0]-t[0])+o[0],c=Math.abs(e[1]-t[1])+o[1],p=document.createElement("div");R.default(p).css({position:"absolute",width:a+"px",height:c+"px",left:i+"px",top:r+"px",transformOrigin:e[0]+"px "+e[1]+"px"});const u=pn.exports(p,a,c),h="M"+e[0]+" "+e[1]+" L"+t[0]+" "+t[1],f=u.path(h);return f.graphiePath=[e,t],{wrapper:p,visibleShape:f}},sinusoid:function(e,t,n,o){return i.path(m(e,t,n,o))},grid:function(e,t){const n=r.step||[1,1],o=i.set();let s=n[0]*Math.ceil(e[0]/n[0]);for(;s<=e[1];s+=n[0])o.push(this.line([s,t[0]],[s,t[1]]));let a=n[1]*Math.ceil(t[0]/n[1]);for(;a<=t[1];a+=n[1])o.push(this.line([e[0],a],[e[1],a]));return o},label:function(t,n,o,s){s=void 0===s||s;const i=R.default("<span>").addClass("graphie-label"),a=r["label-distance"];i.css(R.default.extend({},{position:"absolute",padding:(null!=a?a:7)+"px",color:"black"})).data("labelDirection",o).appendTo(e),i.setPosition=function(e){const t=l(e);i.css({left:t[0],top:t[1]})},i.setPosition(t);const c=i[0];return i.processMath=function(e,t){mn(c,e,t,(function(){const e=c.scrollWidth,t=c.scrollHeight;u(c,[e,t])}))},i.processText=function(e){i.html(e);const t=c.scrollWidth,n=c.scrollHeight;u(c,[t,n])},s?i.processMath(n,!1):i.processText(n),i},plotParametric:function(e,t,n,o){o=o||function(e){return[e,0]};const a=e=>Math.abs(e[1])>5e5?[e[0],Math.min(Math.max(e[1],-5e5),5e5)]:e,l=t=>a(e(t)),c=e=>a(o(e));r.strokeLinejoin||(r.strokeLinejoin="round"),r.strokeLinecap||(r.strokeLinecap="round");const p=t[0],d=t[1];let u=(d-p)/(r["plot-points"]||800);0===u&&(u=1);const h=i.set();let f=[],m=vn.coordDiff(l(p),c(p)),g=p;for(let e=p;e<=d;e+=u){const t=l(e),o=c(e),i=vn.coordDiff(t,o);if(i[1]<0!=m[1]<0&&Math.abs(i[1]-m[1])>2*s||isNaN(i[1])){if(n){f.push(t);for(let t=e-u;t>=g;t-=u)f.push(c(t));g=e}h.push(this.path(f)),f=[],n&&f.push(t)}else f.push(t);m=i}if(n)for(let e=d-u;e>=g;e-=u)f.push(c(e));return h.push(this.path(f)),h},plotPolar:function(e,t){const n=t[0],s=t[1];return r["plot-points"]||(r["plot-points"]=2*(s-n)*o),this.plotParametric((function(t){return gn(e(t),180*t/Math.PI)}),t)},plot:function(e,t,n,s,i){const a=t[0],l=t[1];if(r["plot-points"]||(r["plot-points"]=2*(l-a)*o),n){if(i)throw new re("Can't shade area between functions with swapped axes.",se.Internal);return this.plotParametric((function(t){return[e(t),t]}),t,s)}if(i){if(s)return this.plotParametric((function(t){return[t,e(t)]}),t,s,(function(e){return[e,i(e)]}));throw new re("fn2 should only be set when 'shade' is True.",se.Internal)}return this.plotParametric((function(t){return[t,e(t)]}),t,s)},plotPiecewise:function(e,t){const n=i.set(),o=this;return M.default.times(e.length,(function(s){const i=e[s],r=t[s],a=o.plotParametric((function(e){return[e,i(e)]}),r);M.default.each(a,(function(e){n.push(e)}))})),n},plotEndpointCircles:function(e){const t=i.set(),n=this;return M.default.each(e,(function(e,o){t.push(n.circle(e,.15))})),t},plotAsymptotes:function(e,t){const n=t[0],o=t[1],a=(o-n)/(r["plot-points"]||800),l=i.set();let c=e(n);for(let t=n;t<=o;t+=a){const n=e(t);n<0!=c<0&&Math.abs(n-c)>2*s&&l.push(this.line([t,s],[t,-s])),c=n}return l}},b=new yn;return M.default.extend(b,{raphael:i,init:function(r){let a=r.scale||[40,40];if(a="number"==typeof a?[a,a]:a,o=a[0],s=a[1],null==r.range)throw new re("range should be specified in graph init",se.Internal);t=r.range[0],n=r.range[1];const l=(t[1]-t[0])*o,c=(n[1]-n[0])*s;return i.setSize(l,c),R.default(e).css({width:l,height:c}),this.range=r.range,this.scale=a,this.dimensions=[l,c],this.xpixels=l,this.ypixels=c,this.isMobile=r.isMobile,this},style:function(e,t){const n=g(e);if("function"==typeof t){const e=r;r=R.default.extend({},r,n);const o=t.call(b);return r=e,o}R.default.extend(r,n)},scalePoint:l,scaleVector:a,unscalePoint:c,unscaleVector:p,svgPath:h,svgParabolaPath:f,svgSinusoidPath:m}),R.default.each(y,(function(e){b[e]=function(){const t=arguments[arguments.length-1],n=r;let o;if("object"!=typeof t||M.default.isArray(t))r=R.default.extend({},r),o=y[e](...arguments);else{r={...r,...g(t)};const n=[].slice.call(arguments,0,arguments.length-1);o=y[e](...n)}const s=o.constructor.prototype;return s===pn.exports.el||s===pn.exports.st?(o.attr(r),r.arrows&&(o=v(o))):o instanceof R.default&&o.css({...r,...xn}),r=n,o}})),b.graphInit=function(e){e=e||{},R.default.each(e,(function(t,n){t.match(/.*Opacity$/)||"range"===t||"number"!=typeof n||(e[t]=[n,n]),"range"!==t&&"gridRange"!==t||(n.constructor===Array?n[0].constructor!==Array&&(e[t]=[[-n[0],n[0]],[-n[1],n[1]]]):"number"==typeof n&&(e[t]=[[-n,n],[-n,n]]))}));const t=e.range||[[-10,10],[-10,10]],n=e.gridRange||e.range,o=e.scale||[20,20],s=null==e.grid||e.grid,i=e.gridOpacity||.1,r=e.gridStep||[1,1],a=null==e.axes||e.axes,l=e.axisArrows||"",c=e.axisOpacity||1,p=e.axisCenter||[Math.min(Math.max(t[0][0],0),t[0][1]),Math.min(Math.max(t[1][0],0),t[1][1])],d=null!=e.axisLabels&&e.axisLabels,u=null==e.ticks||e.ticks,h=e.tickStep||[2,2],f=e.tickLen||[5,5],m=e.tickOpacity||1,g=e.labels||e.labelStep||!1,v=e.labelStep||[1,1],y=e.labelOpacity||1;let b=e.unityLabels||!1;const x=e.labelFormat||function(e){return e};let w=e.xLabelFormat||x,C=e.yLabelFormat||x;const k=null==e.smartLabelPositioning||e.smartLabelPositioning,S=[[t[0][0]-(t[0][0]>0?1:0),t[0][1]+(t[0][1]<0?1:0)],[t[1][0]-(t[1][0]>0?1:0),t[1][1]+(t[1][1]<0?1:0)]];if(M.default.isArray(b)||(b=[b,b]),k){const e=function(e){return function(t){return(e(t)+"").replace(/-(\d)/g,"\\llap{-}$1")}};w=e(w),C=e(C)}if(this.init({range:S,scale:o,isMobile:e.isMobile}),s&&this.grid(n[0],n[1],{stroke:e.isMobile?dn.GRAY_C:"#000000",opacity:e.isMobile?1:i,step:r,strokeWidth:e.isMobile?1:2}),a&&("<->"===l||!0===l?this.style({stroke:e.isMobile?dn.GRAY_G:"#000000",opacity:e.isMobile?1:c,strokeWidth:e.isMobile?1:2,arrows:"->"},(function(){t[1][0]<0&&t[1][1]>0&&(this.path([p,[n[0][0],p[1]]]),this.path([p,[n[0][1],p[1]]])),t[0][0]<0&&t[0][1]>0&&(this.path([p,[p[0],n[1][0]]]),this.path([p,[p[0],n[1][1]]]))})):"->"!==l&&""!==l||this.style({stroke:"#000000",opacity:c,strokeWidth:2,arrows:l},(function(){this.path([[n[0][0],p[1]],[n[0][1],p[1]]]),this.path([[p[0],n[1][0]],[p[0],n[1][1]]])})),d&&2===d.length&&(this.label([n[0][1],p[1]],d[0],"right"),this.label([p[0],n[1][1]],d[1],"above"))),u){const s=e.isMobile;this.style({stroke:e.isMobile?dn.GRAY_G:"#000000",opacity:e.isMobile?1:m,strokeWidth:1},(function(){let e=r[0]*h[0],i=f[0]/o[1],a=n[0][0],c=n[0][1];if(t[1][0]<0&&t[1][1]>0){for(let t=e+p[0];t<=c;t+=e)(t<c||!l)&&this.line([t,-i+p[1]],[t,s?0:i+p[1]]);for(let t=-e+p[0];t>=a;t-=e)(t>a||!l)&&this.line([t,-i+p[1]],[t,s?0:i+p[1]])}if(e=r[1]*h[1],i=f[1]/o[0],a=n[1][0],c=n[1][1],t[0][0]<0&&t[0][1]>0){for(let t=e+p[1];t<=c;t+=e)(t<c||!l)&&this.line([-i+p[0],t],[s?0:i+p[0],t]);for(let t=-e+p[1];t>=a;t-=e)(t>a||!l)&&this.line([-i+p[0],t],[s?0:i+p[0],t])}}))}g&&this.style({stroke:e.isMobile?dn.GRAY_G:"#000000",opacity:e.isMobile?1:y},(function(){let e=r[0]*h[0]*v[0],t=n[0][0],o=n[0][1];const s=p[0]<0?"above":"below",i=p[0]<0?"right":"left",a=0===p[0]&&0!==p[1],c=0!==p[0]&&0===p[1],d=0!==p[0]||0!==p[1],u=b[0]||d,f=b[1]||d;for(let t=(a?0:e)+p[0];t<=o;t+=e)(t<o||!l)&&this.label([t,p[1]],w(t),s);for(let n=-e*(u?1:2)+p[0];n>=t;n-=e)(n>t||!l)&&this.label([n,p[1]],w(n),s);e=r[1]*h[1]*v[1],t=n[1][0],o=n[1][1];for(let t=(c?0:e)+p[1];t<=o;t+=e)(t<o||!l)&&this.label([p[0],t],C(t),i);for(let n=-e*(f?1:2)+p[1];n>=t;n-=e)(n>t||!l)&&this.label([p[0],n],C(n),i)}))},b},function(e,t,n,o){if(void 0!==e){var s="virtualMouseBindings",i="virtualTouchID",r="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),a="clientX clientY pageX pageY screenX screenY".split(" "),l=e.event.mouseHooks?e.event.mouseHooks.props:[],c=e.event.props.concat(l),p={},d=0,u=0,h=0,f=!1,m=[],g=!1,v=!1,y="addEventListener"in n,b=e(n),x=1,w=0;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var C=0;C<r.length;C++)e.event.special[r[C]]=L(r[C]);y&&n.addEventListener("click",(function(t){var n,o,s,r,a,l=m.length,c=t.target;if(l)for(n=t.clientX,o=t.clientY,threshold=e.vmouse.clickDistanceThreshold,s=c;s;){for(r=0;r<l;r++)if(a=m[r],s===c&&Math.abs(a.x-n)<threshold&&Math.abs(a.y-o)<threshold||e.data(s,i)===a.touchID)return t.preventDefault(),void t.stopPropagation();s=s.parentNode}}),!0)}function k(e){for(;e&&void 0!==e.originalEvent;)e=e.originalEvent;return e}function S(t){for(var n,o,i={};t;){for(o in n=e.data(t,s))n[o]&&(i[o]=i.hasVirtualBinding=!0);t=t.parentNode}return i}function E(){v=!0}function _(){v=!1}function T(){M(),d=setTimeout((function(){d=0,w=0,m.length=0,g=!1,E()}),e.vmouse.resetTimerDuration)}function M(){d&&(clearTimeout(d),d=0)}function I(t,n,o){var i;return(o&&o[t]||!o&&function(t,n){for(var o;t;){if((o=e.data(t,s))&&(!n||o[n]))return t;t=t.parentNode}return null}(n.target,t))&&(i=function(t,n){var o,s,i,r,l,p,d,u,h,f=t.type;if((t=e.Event(t)).type=n,o=t.originalEvent,s=e.event.props,f.search(/mouse/)>-1&&(s=c),o)for(d=s.length;d;)t[r=s[--d]]=o[r];if(f.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1),-1!==f.search(/^touch/)&&(f=(i=k(o)).touches,l=i.changedTouches,p=f&&f.length?f[0]:l&&l.length?l[0]:void 0))for(u=0,h=a.length;u<h;u++)t[r=a[u]]=p[r];return t}(n,t),e(n.target).trigger(i)),i}function P(t){var n=e.data(t.target,i);if(!(g||w&&w===n)){var o=I("v"+t.type,t);o&&(o.isDefaultPrevented()&&t.preventDefault(),o.isPropagationStopped()&&t.stopPropagation(),o.isImmediatePropagationStopped()&&t.stopImmediatePropagation())}}function N(t){var n,o,s=k(t).touches;if(s&&1===s.length&&(o=S(n=t.target)).hasVirtualBinding){w=x++,e.data(n,i,w),M(),_(),f=!1;var r=k(t).touches[0];u=r.pageX,h=r.pageY,I("vmouseover",t,o),I("vmousedown",t,o)}}function A(e){v||(f||I("vmousecancel",e,S(e.target)),f=!0,T())}function R(t){if(!v){var n=k(t).touches[0],o=i,s=e.vmouse.moveDistanceThreshold,i=i||Math.abs(n.pageX-u)>s||Math.abs(n.pageY-h)>s,r=S(t.target);i&&!o&&I("vmousecancel",t,r),I("vmousemove",t,r),T()}}function F(e){if(!v){E();var t,n=S(e.target);if(I("vmouseup",e,n),!f){var o=I("vclick",e,n);o&&o.isDefaultPrevented()&&(t=k(e).changedTouches[0],m.push({touchID:w,x:t.clientX,y:t.clientY}),g=!0)}I("vmouseout",e,n),f=!1,T()}}function O(t){var n,o=e.data(t,s);if(o)for(n in o)if(o[n])return!0;return!1}function D(){}function L(t){var n=t.substr(1);return{setup:function(o,i){O(this)||e.data(this,s,{}),e.data(this,s)[t]=!0,p[t]=(p[t]||0)+1,1===p[t]&&b.bind(n,P),e(this).bind(n,D),y&&(p.touchstart=(p.touchstart||0)+1,1===p.touchstart&&b.bind("touchstart",N).bind("touchend",F).bind("touchmove",R).bind("scroll",A))},teardown:function(o,i){--p[t],p[t]||b.unbind(n,P),y&&(--p.touchstart,p.touchstart||b.unbind("touchstart",N).unbind("touchmove",R).unbind("touchend",F).unbind("scroll",A));var r=e(this),a=e.data(this,s);a&&(a[t]=!1),r.unbind(n,D),O(this)||r.removeData(s)}}}}(window.jQuery,window,document);var wn={pluck:function(e,t){return M.default.object(M.default.map(e,(function(e,n){return[n,e[t]]})))},mapObject:function(e,t){const n={};return M.default.each(M.default.keys(e),(function(o){n[o]=t(e[o],o)})),n},mapObjectFromArray:function(e,t){const n={};return M.default.each(e,(function(e){n[e]=t(e)})),n}};const Cn=M.default.extend({transform:function(e){const t=an.getPrefixedTransform();this.wrapper.style[t]=e},toFront:function(){const e=this.wrapper.parentNode;e&&e.appendChild(this.wrapper)},toBack:function(){const e=this.wrapper.parentNode;e.firstChild!==this.wrapper&&e.insertBefore(this.wrapper,e.firstChild)},remove:function(){this.visibleShape.remove(),R.default(this.wrapper).remove()},getMouseTarget:function(){return this.visibleShape[0]},moveTo:function(e){const t=d.vector.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),n=an.getCanUse3dTransform(),o="translateX("+t[0]+"px) translateY("+t[1]+"px)"+(n?" translateZ(0)":"");this.transform(o)},hide:function(){this.visibleShape.hide()},show:function(){this.visibleShape.show()}},wn.mapObjectFromArray(["attr","animate"],(function(e){return function(){this.visibleShape[e](...arguments)}}))),kn={maxScale:1,mouselayer:!1,shadow:!1,disableMouseEventsOnWrapper:!1},Sn=function(e,t,n,o){o=M.default.extend({},kn,o);const s=e.fixedEllipse(t,n,o.maxScale,o.padding);if(M.default.extend(this,s,{graphie:e,initialPoint:t}),o.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",o.interactiveKindForTesting),o.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),o.shadow){const e="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))",t=this.wrapper;t.style.webkitFilter=e,t.style.filter=e,this.moveTo=function(e){const t=d.vector.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),n=an.getCanUse3dTransform(),o="translateX("+Math.round(t[0])+"px) translateY("+Math.round(t[1])+"px)"+(n?" translateZ(0)":"");this.transform(o)}}o.disableMouseEventsOnWrapper&&(this.wrapper.style.pointerEvents="none",this.visibleShape.node.style.pointerEvents="auto")};M.default.extend(Sn.prototype,Cn);const En={thickness:2,mouselayer:!1},_n=function(e,t,n,o){o=M.default.extend({},En,o);const s=[e.range[0][0],0],i=[e.range[0][1],0];M.default.extend(this,e.fixedLine(s,i,o.thickness)),o.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",o.interactiveKindForTesting),this.visibleShape.attr(o.normalStyle),M.default.extend(this,{graphie:e,initialPoint:e.scalePoint(s),initialLength:d.point.distanceToPoint(e.scalePoint(s),e.scalePoint(i))}),o.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),this.moveTo(t,n)};M.default.extend(_n.prototype,Cn,{getMouseTarget:function(){return this.wrapper},moveTo:function(e,t){const n=this.graphie.scalePoint(e),o=this.graphie.scalePoint(t),s=d.vector.polarDegFromCart(d.vector.subtract(o,n)),i=s[0],r=ae.bound(s[1]),a=d.vector.subtract(n,this.initialPoint),l=ae.bound(i/this.initialLength),c=an.getCanUse3dTransform(),p="translateX("+a[0]+"px) translateY("+a[1]+"px) "+(c?" translateZ(0)":"")+"rotate("+r+"deg) scaleX("+l+") scaleY(1)";this.transform(p)}});const Tn={center:null,createPath:null,mouselayer:!1},Mn=function(e,t,n){n=M.default.extend({},Tn,n),M.default.extend(this,e.fixedPath(t,n.center,n.createPath)),M.default.extend(this,{graphie:e,initialPoint:e.scalePoint(M.default.head(t))}),n.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper)};M.default.extend(Mn.prototype,Cn);const{getCanUse3dTransform:In}=an;function Pn(e){return M.default.reduce(e,(function(e,t){return e+t}),0)}function Nn(){const e=M.default.zip(...arguments);return M.default.map(e,Pn)}function An(e){return M.default.map(e,(function(e){return-1*e}))}function Rn(e){const t=11.374597405497571;return 58.919514629750836*Math.exp(-.037587715462826674*e)+t}function Fn(e,t){return[e*Math.cos(t),e*Math.sin(t)*-1]}function On(e,t){return Fn(e,t*Math.PI/180)}let Dn=!1;const Ln={animate:function(){},attr:function(){},remove:function(){}};function Bn(e,t){this.set=e.raphael.set(),this.cx=t[0],this.cy=t[1];const n=this,o=e.unscaleVector(180.5)[0],s=e.scalePoint([this.cx-o,this.cy+o-e.unscaleVector(10.5)[1]]),i=e.mouselayer.image("https://ka-perseus-graphie.s3.amazonaws.com/e9d032f2ab8b95979f674fbfa67056442ba1ff6a.png",s[0],s[1],360,180);this.set.push(i),i.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});const r=function(n,s){const i=e.scaleVector(o);i[0]-=16,i[1]-=16;const r=e.scalePoint(t);return Math.sin((n+90)*Math.PI/180)*(i[0]+s)+r[0]+","+(Math.cos((n+90)*Math.PI/180)*(i[1]+s)+r[1])},a=e.raphael.path(" M"+r(180,6)+" L"+r(180,2)+" L"+r(183,10)+" L"+r(180,18)+" L"+r(180,14)+" A"+(e.scaleVector(o)[0]+10)+","+(e.scaleVector(o)[1]+10)+",0,0,1,"+r(170,14)+" L"+r(170,18)+" L"+r(167,10)+" L"+r(170,2)+" L"+r(170,6)+" A"+(e.scaleVector(o)[0]+10)+","+(e.scaleVector(o)[1]+10)+",0,0,0,"+r(180,6)+" Z").attr({stroke:null,fill:dn.INTERACTIVE});this.set.push(a),this.centerPoint=e.addMovablePoint({coord:t,visible:!1}),this.rotateHandle=e.addMovablePoint({bounded:!1,coord:[Math.sin(275*Math.PI/180)*o+this.cx,Math.cos(275*Math.PI/180)*o+this.cy],onMove:function(e,t){const o=180*Math.atan2(n.centerPoint.coord[1]-t,n.centerPoint.coord[0]-e)/Math.PI;n.rotate(-o-5,!0)}}),this.rotateHandle.constraints.fixedDistance.dist=o,this.rotateHandle.constraints.fixedDistance.point=this.centerPoint,this.rotateHandle.visibleShape.remove(),this.rotateHandle.mouseTarget.attr({scale:2});let l=!1,c=!1;const p=function(){return c||l},d=R.default(this.rotateHandle.mouseTarget.getMouseTarget());d.bind("vmousedown",(function(e){l=!0,d.css("cursor","-webkit-grabbing"),d.css("cursor","grabbing"),a.animate({scale:1.5,fill:dn.INTERACTING},50),R.default(document).bind("vmouseup.rotateHandle",(function(e){l=!1,d.css("cursor","-webkit-grab"),d.css("cursor","grab"),p()||a.animate({scale:1,fill:dn.INTERACTIVE},50),R.default(document).unbind("vmouseup.rotateHandle")}))})),d.bind("vmouseover",(function(e){c=!0,a.animate({scale:1.5,fill:dn.INTERACTING},50)})),d.bind("vmouseout",(function(e){c=!1,p()||a.animate({scale:1,fill:dn.INTERACTIVE},50)}));const u=R.default.map(this.set,(function(e){return e.node}));return this.makeTranslatable=function(){R.default(u).css("cursor","move"),d.css("cursor","-webkit-grab"),d.css("cursor","grab"),R.default(u).bind("vmousedown",(function(t){t.preventDefault();let o=t.pageX-R.default(e.raphael.canvas.parentNode).offset().left,s=t.pageY-R.default(e.raphael.canvas.parentNode).offset().top;R.default(document).bind("vmousemove.protractor",(function(t){let i=t.pageX-R.default(e.raphael.canvas.parentNode).offset().left,r=t.pageY-R.default(e.raphael.canvas.parentNode).offset().top;i=Math.max(10,Math.min(e.xpixels-10,i)),r=Math.max(10,Math.min(e.ypixels-10,r));const a=i-o,l=r-s;R.default.each(n.set.items,(function(){this.translate(a,l)})),n.centerPoint.setCoord([n.centerPoint.coord[0]+a/e.scale[0],n.centerPoint.coord[1]-l/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+a/e.scale[0],n.rotateHandle.coord[1]-l/e.scale[1]]),o=i,s=r})),R.default(document).one("vmouseup",(function(e){R.default(document).unbind("vmousemove.protractor")}))}))},this.rotation=0,this.rotate=function(t,n){const o=e.scalePoint(this.centerPoint.coord);return n&&(this.rotation=0),this.set.rotate(this.rotation+t,o[0],o[1]),this.rotation=this.rotation+t,this},this.moveTo=function(t,o){const s=e.scalePoint(n.centerPoint.coord),i=e.scalePoint([t,o]),r=2*vn.getDistance(s,i);R.default({x:s[0],y:s[1]}).animate({x:i[0],y:i[1]},{duration:r,step:function(t,o){let s=0,i=0;"x"===o.prop?s=t-e.scalePoint(n.centerPoint.coord)[0]:"y"===o.prop&&(i=t-e.scalePoint(n.centerPoint.coord)[1]),R.default.each(n.set.items,(function(){this.translate(s,i)})),n.centerPoint.setCoord([n.centerPoint.coord[0]+s/e.scale[0],n.centerPoint.coord[1]-i/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+s/e.scale[0],n.rotateHandle.coord[1]-i/e.scale[1]])}})},this.rotateTo=function(e){Math.abs(this.rotation-e)>180&&(this.rotation+=360);const t=5*Math.abs(this.rotation-e);R.default({0:this.rotation}).animate({0:e},{duration:t,step:function(e,t){n.rotate(e,!0),n.rotateHandle.setCoord([Math.sin((e+275)*Math.PI/180)*o+n.centerPoint.coord[0],Math.cos((e+275)*Math.PI/180)*o+n.centerPoint.coord[1]])}})},this.remove=function(){this.set.remove()},this.makeTranslatable(),this}function zn(e,t){M.default.defaults(t,{center:[0,0],pixelsPerUnit:40,ticksPerUnit:10,units:10,label:"",style:{fill:null,stroke:dn.GRAY}});const n=M.default.extend({},t.style,{strokeWidth:1}),o=M.default.extend({},t.style,{strokeWidth:2}),s=t.units*t.pixelsPerUnit,i=e.unscalePoint(d.vector.subtract(e.scalePoint(t.center),d.vector.scale([s,-50],.5))),r=t.pixelsPerUnit/e.scale[0],a=50/e.scale[0],l=d.vector.add(i,[t.units*r,a]);let c;if(10===t.ticksPerUnit)c={10:1,5:.55,1:.35};else{const e=[1,.6,.45,.3];c={};for(let n=t.ticksPerUnit;n>=1;n/=2)c[n]=1*(e.shift()||.2)}const p=M.default.keys(c).sort((function(e,t){return t-e}));const u=i[0],h=i[1],f=l[0],m=l[1],g=t.units*t.ticksPerUnit+1,v=e.raphael.set(),y=1/e.scale[0];v.push(e.line([u-y,h],[f+y,h],o)),v.push(e.line([u-y,m],[f+y,m],o)),M.default.times(g,(function(s){const i=s/t.ticksPerUnit,l=u+i*r,d=function(e){for(let t=0;t<p.length;t++){const n=p[t];if(e%n==0)return c[n]}return 0}(s)*a,f=0===s||s===g-1?o:n;if(v.push(e.line([l,h],[l,h+d],f)),i%1==0){const n=e.scalePoint([l,m]);let o,s;0===i?(o=t.label,s={mm:13,cm:11,m:8,km:11,in:8,ft:8,yd:10,mi:10}[o]||3*o.toString().length):(o=i,s=-3*(i.toString().length+1));const r=e.raphael.text(n[0]+s,n[1]+10,o);r.attr({"font-family":"KaTeX_Main","font-size":"12px",color:"#444"}),v.push(r)}}));const b=e.mouselayer.path(vn.svgPath([i,[u,m],l,[f,h],!0]));b.attr({fill:"#000",opacity:0,stroke:"#000","stroke-width":2}),v.push(b),b.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});const x=R.default.map(v,(function(e){return e.node}));R.default(x).css("cursor","move"),R.default(x).bind("vmousedown",(function(t){t.preventDefault();let n=t.pageX-R.default(e.raphael.canvas.parentNode).offset().left,o=t.pageY-R.default(e.raphael.canvas.parentNode).offset().top;R.default(document).bind("vmousemove.ruler",(function(t){let s=t.pageX-R.default(e.raphael.canvas.parentNode).offset().left,i=t.pageY-R.default(e.raphael.canvas.parentNode).offset().top;s=Math.max(10,Math.min(e.xpixels-10,s)),i=Math.max(10,Math.min(e.ypixels-10,i));const r=s-n,a=i-o;v.translate(r,a),w.setCoord([w.coord[0]+r/e.scale[0],w.coord[1]-a/e.scale[1]]),C.setCoord([C.coord[0]+r/e.scale[0],C.coord[1]-a/e.scale[1]]),n=s,o=i})),R.default(document).one("vmouseup",(function(e){R.default(document).unbind("vmousemove.ruler")}))}));const w=e.addMovablePoint({coord:i,normalStyle:{fill:dn.INTERACTIVE,"fill-opacity":0,stroke:dn.INTERACTIVE},highlightStyle:{fill:dn.INTERACTING,"fill-opacity":.1,stroke:dn.INTERACTING},pointSize:6,onMove:function(t,n){const o=C.coord[1]-n,s=C.coord[0]-t,i=180*Math.atan2(o,s)/Math.PI,r=d.vector.scale(d.vector.add([t,n],C.coord),.5),a=e.scalePoint(r),l=d.vector.scale(d.vector.add(w.coord,C.coord),.5),c=e.scalePoint(l),p=d.vector.subtract(a,c);v.rotate(-i,c[0],c[1]),v.translate(p[0],p[1])}}),C=e.addMovablePoint({coord:[f,h],normalStyle:{fill:dn.INTERACTIVE,"fill-opacity":0,stroke:dn.INTERACTIVE},highlightStyle:{fill:dn.INTERACTING,"fill-opacity":.1,stroke:dn.INTERACTING},pointSize:6,onMove:function(t,n){const o=n-w.coord[1],s=t-w.coord[0],i=180*Math.atan2(o,s)/Math.PI,r=d.vector.scale(d.vector.add([t,n],w.coord),.5),a=e.scalePoint(r),l=d.vector.scale(d.vector.add(w.coord,C.coord),.5),c=e.scalePoint(l),p=d.vector.subtract(a,c);v.rotate(-i,c[0],c[1]),v.translate(p[0],p[1])}});return w.constraints.fixedDistance.dist=s/e.scale[0],w.constraints.fixedDistance.point=C,C.constraints.fixedDistance.dist=s/e.scale[0],C.constraints.fixedDistance.point=w,this.remove=function(){v.remove(),w.remove(),C.remove()},this}function qn(e,t){if(this.graphie=e,M.default.extend(this,t),M.default.defaults(this,{normalStyle:{stroke:dn.INTERACTIVE,"stroke-width":2,fill:dn.INTERACTIVE},highlightStyle:{stroke:dn.INTERACTING,"stroke-width":2,fill:dn.INTERACTING},labelStyle:{stroke:dn.DYNAMIC,"stroke-width":1,color:dn.DYNAMIC},angleStyle:{stroke:dn.DYNAMIC,"stroke-width":1,color:dn.DYNAMIC},allowReflex:!0}),!this.points||3!==this.points.length)throw new re("MovableAngle requires 3 points",se.InvalidInput);this.points=M.default.map(t.points,(function(t){return M.default.isArray(t)?e.addMovablePoint({coord:t,visible:!1,constraints:{fixed:!0},normalStyle:this.normalStyle}):t}),this),this.coords=M.default.pluck(this.points,"coord"),null==this.reflex&&(this.allowReflex?this.reflex=this._getClockwiseAngle(this.coords)>180:this.reflex=!1),this.rays=M.default.map([0,2],(function(t){return e.addMovableLineSegment({pointA:this.points[1],pointZ:this.points[t],fixed:!0,extendRay:!0})}),this),this.temp=[],this.labeledAngle=e.label([0,0],"","center",this.labelStyle),this.fixed||(this.addMoveHandlers(),this.addHighlightHandlers()),this.update()}M.default.extend(vn.Graphie.prototype,{addMouseLayer:function(e){const t=this;e=M.default.extend({allowScratchpad:!1,setDrawingAreaAvailable:function(){}},e);if(t.mouselayer=pn.exports(t.raphael.canvas.parentNode,t.xpixels,t.ypixels),R.default(t.mouselayer.canvas).css("z-index",2),e.onClick||e.onMouseDown||e.onMouseMove||e.onMouseOver||e.onMouseOut){const n=t.mouselayer.rect(0,0,t.xpixels,t.ypixels).attr({fill:"#000",opacity:0});let o=!1;R.default(t.mouselayer.canvas).on("vmousedown",(function(s){s.target===n[0]&&(e.onMouseDown&&e.onMouseDown(t.getMouseCoord(s)),o=!0,e.onMouseMove&&R.default(document).bind("vmousemove.mouseLayer",(function(n){o&&(n.preventDefault(),e.onMouseMove(t.getMouseCoord(n)))})),R.default(document).bind("vmouseup.mouseLayer",(function(n){R.default(document).unbind(".mouseLayer"),o&&e.onClick&&e.onClick(t.getMouseCoord(n)),o=!1})))})),e.onMouseOver&&R.default(t.mouselayer.canvas).on("vmouseover",(function(n){e.onMouseOver(t.getMouseCoord(n))})),e.onMouseOut&&R.default(t.mouselayer.canvas).on("vmouseout",(function(n){e.onMouseOut(t.getMouseCoord(n))}))}e.allowScratchpad||e.setDrawingAreaAvailable(!1),t._mouselayerWrapper=document.createElement("div"),R.default(t._mouselayerWrapper).css({position:"absolute",left:0,top:0,zIndex:2}),t._visiblelayerWrapper=document.createElement("div"),R.default(t._visiblelayerWrapper).css({position:"absolute",left:0,top:0});const n=t.raphael.canvas.parentNode;n.appendChild(t._visiblelayerWrapper),n.appendChild(t._mouselayerWrapper),t.addToMouseLayerWrapper=function(e){this._mouselayerWrapper.appendChild(e)},t.addToVisibleLayerWrapper=function(e){this._visiblelayerWrapper.appendChild(e)}},getMousePx:function(e){return[e.pageX-R.default(this.raphael.canvas.parentNode).offset().left,e.pageY-R.default(this.raphael.canvas.parentNode).offset().top]},getMouseCoord:function(e){return this.unscalePoint(this.getMousePx(e))},labelAngle:function(e){const t=this;M.default.defaults(e,{point1:[0,0],vertex:[0,0],point3:[0,0],label:null,numArcs:1,showRightAngleMarker:!0,pushOut:0,clockwise:!1,style:{}});let n=void 0===e.text?"":e.text;const o=e.vertex,s=t.scalePoint(o);let i,r;e.clockwise?(i=e.point1,r=e.point3):(i=e.point3,r=e.point1);const a=vn.findAngle(i,o),l=vn.findAngle(r,o),c=(l+360-a)%360,p=(a+c/2)%360;let d=5*e.pushOut+Rn(c);const u=[];if(Math.abs(c-90)<1e-9&&e.showRightAngleMarker){const n=Nn(s,On(d,a)),o=Nn(s,On(d,l));d*=Math.SQRT2;const i=Nn(s,On(d,p));M.default.each([n,o],(function(n){u.push(t.scaledPath([n,i],e.style))}))}else M.default.times(e.numArcs,(function(n){u.push(t.arc(o,t.unscaleVector(d),a,l,e.style)),d+=3}));if(n){const o=n.match(/\$deg(\d)?/);if(o){const e=o[1]||1;n=n.replace(o[0],ae.toFixedApprox(c,e)+"^{\\circ}")}const i=Nn(s,On(d+15,p)),r=t.unscalePoint(i);e.label?(e.label.setPosition(r),e.label.processMath(n,!0)):t.label(r,n,"center",e.style)}return u},labelSide:function(e){const t=this;let n,o;M.default.defaults(e,{point1:[0,0],point2:[0,0],label:null,text:"",numTicks:0,numArrows:0,clockwise:!1,style:{}}),e.clockwise?(n=e.point1,o=e.point2):(n=e.point2,o=e.point1);const s=[(n[0]+o[0])/2,(n[1]+o[1])/2],i=t.scalePoint(s),r=Math.atan2(o[1]-n[1],o[0]-n[0]),a=r+Math.PI/2,l=[];let c=0;if(e.numTicks){const n=e.numTicks,o=5,s=5,p=M.default.extend({},e.style,{strokeWidth:2});M.default.times(n,(function(e){const c=Fn(o*(e-(n-1)/2),r),d=Fn(s,a),u=[Nn(i,c,d),Nn(i,c,An(d))];l.push(t.scaledPath(u,p))})),c+=o*(n-1)+15}if(e.numArrows){const s=e.numArrows,a=[n,o].sort((function(e,t){return e[1]===t[1]?e[0]-t[0]:e[1]-t[1]}))[0],p=t.scalePoint(a),d=M.default.extend({},e.style,{arrows:"->",strokeWidth:2}),u=5;M.default.times(s,(function(e){let o=Fn(c+u*e,r);a!==n&&(o=An(o));const s=Nn(i,o);l.push(t.scaledPath([p,s],d))}))}let p=e.text;if(p){const s=p.match(/\$len(\d)?/);if(s){const e=vn.getDistance(n,o),t=s[1]||1;p=p.replace(s[0],ae.toFixedApprox(e,t))}const r=Fn(20,a),l=Nn(i,r),c=t.unscalePoint(l);e.label?(e.label.setPosition(c),e.label.processMath(p,!0)):t.label(c,p,"center",e.style)}return l},labelVertex:function(e){const t=this;if(M.default.defaults(e,{point1:null,vertex:[0,0],point3:null,label:null,text:"",clockwise:!1,style:{}}),!e.text)return;const n=e.vertex,o=t.scalePoint(n);let s,i;e.clockwise?(s=e.point1,i=e.point3):(s=e.point3,i=e.point1);let r,a=135;if(s&&i){const e=vn.findAngle(s,n);a=(vn.findAngle(i,n)+360-e)%360,r=(e+a/2+180)%360}else if(s){r=vn.findAngle(n,s)+90}else if(i){r=vn.findAngle(i,n)+90}else r=135;const l=Nn(o,On(10+Rn(360-a),r)),c=t.unscalePoint(l);e.label?(e.label.setPosition(c),e.label.processMath(e.text,!0)):t.label(c,e.text,"center",e.style)},addMovablePoint:function(e){const t=R.default.extend(!0,{graph:this,coord:[0,0],snapX:0,snapY:0,pointSize:4,highlight:!1,dragging:!1,visible:!0,bounded:!0,constraints:{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},lineStarts:[],lineEnds:[],polygonVertices:[],normalStyle:{},highlightStyle:{fill:dn.INTERACTING,stroke:dn.INTERACTING},labelStyle:{color:dn.INTERACTIVE},vertexLabel:"",mouseTarget:null},e),n=t.constraints.fixed?dn.DYNAMIC:dn.INTERACTIVE;t.normalStyle=M.default.extend({},{fill:n,stroke:n},e.normalStyle),void 0!==e.coordX&&(t.coord[0]=e.coordX),void 0!==e.coordY&&(t.coord[1]=e.coordY);const o=t.graph,s=function(e){t.visible&&t.bounded&&!t.constraints.fixed&&(e=o.constrainToBounds(e,10));let n=e[0],s=e[1];if(0!==t.snapX&&(n=Math.round(n/t.snapX)*t.snapX),0!==t.snapY&&(s=Math.round(s/t.snapY)*t.snapY),t.constraints.fixedDistance.snapPoints){const i=o.scalePoint(e);let r=i[0],a=i[1];const l=2*Math.PI/t.constraints.fixedDistance.snapPoints,c=t.constraints.fixedDistance.dist,p=t.constraints.fixedDistance.point,d=(p[0]-o.range[0][0])*o.scale[0],u=(-p[1]+o.range[1][1])*o.scale[1];let h=r-d,f=-a+u,m=Math.atan(f/h);h<0&&(m+=Math.PI),m=Math.round(m/l)*l,h=c*Math.cos(m),f=c*Math.sin(m),r=h+d,a=-f+u,n=ae.roundTo(5,r/o.scale[0]+o.range[0][0]),s=ae.roundTo(5,o.range[1][1]-a/o.scale[1])}return t.applyConstraint([n,s])};t.applyConstraint=function(e,n,o){let s=e.slice();const i={};if(o?R.default.extend(i,{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},n):R.default.extend(i,this.constraints,n),i.constrainX)s=[this.coord[0],e[1]];else if(i.constrainY)s=[e[0],this.coord[1]];else if("number"==typeof i.fixedAngle.angle&&"number"==typeof i.fixedDistance.dist){const e=i.fixedAngle.vertex.coord||i.fixedAngle.vertex,t=i.fixedAngle.ref.coord||i.fixedAngle.ref,n=i.fixedDistance.point.coord||i.fixedDistance.point,o=(i.fixedAngle.angle+vn.findAngle(t,e))*Math.PI/180,r=i.fixedDistance.dist;s[0]=r*Math.cos(o)+n[0],s[1]=r*Math.sin(o)+n[1]}else if("number"==typeof i.fixedAngle.angle){const t=i.fixedAngle.vertex.coord||i.fixedAngle.vertex,n=i.fixedAngle.ref.coord||i.fixedAngle.ref,o=(i.fixedAngle.angle+vn.findAngle(n,t))*Math.PI/180,r=vn.findAngle(e,t)*Math.PI/180;let a=vn.getDistance(e,t)*Math.cos(o-r);a=a<1?1:a,s[0]=a*Math.cos(o)+t[0],s[1]=a*Math.sin(o)+t[1]}else if("number"==typeof i.fixedDistance.dist){const t=i.fixedDistance.point.coord||i.fixedDistance.point;let n=vn.findAngle(e,t);const o=i.fixedDistance.dist;n=n*Math.PI/180,s[0]=o*Math.cos(n)+t[0],s[1]=o*Math.sin(n)+t[1]}else i.fixed&&(s=t.coord);return s},t.coord=s(t.coord);if(t.visible&&o.style(t.normalStyle,(function(){const e=[t.pointSize/o.scale[0],t.pointSize/o.scale[1]],n={maxScale:2,padding:2};t.visibleShape=new Sn(o,t.coord,e,n),t.visibleShape.attr(M.default.omit(t.normalStyle,"scale")),t.visibleShape.toFront()})),t.normalStyle.scale=1,t.highlightStyle.scale=2,t.vertexLabel&&(t.labeledVertex=this.label([0,0],"","center",t.labelStyle)),t.drawLabel=function(){t.vertexLabel&&t.graph.labelVertex({vertex:t.coord,label:t.labeledVertex,text:t.vertexLabel,style:t.labelStyle})},t.drawLabel(),t.grab=function(e){e=e||[0,0],R.default(document).bind("vmousemove.point vmouseup.point",(function(n){n.preventDefault(),t.dragging=!0,Dn=!0;let i=d.vector.add(o.getMouseCoord(n),e);i=s(i);let r,a,l=i[0],c=i[1];if("vmousemove"===n.type){let e=!0;if(M.default.isFunction(t.onMove)){const n=t.onMove(l,c);!1===n&&(e=!1),M.default.isArray(n)&&(l=n[0],c=n[1])}if(r=(l-o.range[0][0])*o.scale[0],a=(-c+o.range[1][1])*o.scale[1],e){const e=o.unscalePoint([r,a]);t.visibleShape.moveTo(e),t.mouseTarget.moveTo(e),t.coord=[l,c],t.updateLineEnds(),R.default(t).trigger("move")}t.drawLabel()}else if("vmouseup"===n.type){if(R.default(document).unbind(".point"),t.dragging=!1,Dn=!1,M.default.isFunction(t.onMoveEnd)){const e=t.onMoveEnd(l,c);if(M.default.isArray(e)){l=e[0],c=e[1],r=(l-o.range[0][0])*o.scale[0],a=(-c+o.range[1][1])*o.scale[1];const n=o.unscalePoint([r,a]);t.visibleShape.moveTo(n),t.mouseTarget.moveTo(n),t.coord=[l,c]}}t.highlight||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight())}}))},t.visible&&!t.constraints.fixed){if(!t.mouseTarget){const e=o.unscaleVector(16),n={mouselayer:!0,padding:0,disableMouseEventsOnWrapper:!0,interactiveKindForTesting:"movable-point"};t.mouseTarget=new Sn(o,t.coord,e,n),t.mouseTarget.attr({fill:"#000",opacity:0})}const e=R.default(t.mouseTarget.getMouseTarget());e.css("cursor","move"),e.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)t.highlight=!0,Dn||(t.visibleShape.animate(t.highlightStyle,50),t.onHighlight&&t.onHighlight());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||Dn||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();const n=t.coord,s=o.getMouseCoord(e),i=!("ontouchstart"in window)?[0,0]:d.vector.subtract(n,s);t.grab(i)}}))}return t.moveTo=function(e,n,o){const s=5*vn.getDistance(this.graph.scalePoint([e,n]),this.graph.scalePoint(this.coord)),i=o&&function(e){t.coord=e,t.updateLineEnds()};this.visibleShape.animateTo([e,n],s,i),this.mouseTarget.animateTo([e,n],s,i),this.coord=[e,n],M.default.isFunction(this.onMove)&&this.onMove(e,n)},t.updateLineEnds=function(){R.default(this.lineStarts).each((function(){this.coordA=t.coord,this.transform()})),R.default(this.lineEnds).each((function(){this.coordZ=t.coord,this.transform()})),R.default(this.polygonVertices).each((function(){this.transform()}))},t.setCoord=function(e){this.visible&&(this.visibleShape.moveTo(e),null!=this.mouseTarget&&this.mouseTarget.moveTo(e)),this.coord=e.slice()},t.setCoordConstrained=function(e){this.setCoord(s(e))},t.toBack=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toBack(),this.visibleShape.toBack())},t.toFront=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toFront(),this.visibleShape.toFront())},t.remove=function(){this.visibleShape&&this.visibleShape.remove(),this.mouseTarget&&this.mouseTarget.remove(),this.labeledVertex&&this.labeledVertex.remove()},t},addMovableLineSegment:function(e){const t=R.default.extend({graph:this,coordA:[0,0],coordZ:[1,1],snapX:0,snapY:0,fixed:!1,ticks:0,normalStyle:{},highlightStyle:{stroke:dn.INTERACTING,"stroke-width":6},labelStyle:{stroke:dn.INTERACTIVE,color:dn.INTERACTIVE},highlight:!1,dragging:!1,tick:[],extendLine:!1,extendRay:!1,constraints:{fixed:!1,constrainX:!1,constrainY:!1},sideLabel:"",vertexLabels:[],numArrows:0,numTicks:0,movePointsWithLine:!1},e),n=t.fixed?dn.DYNAMIC:dn.INTERACTIVE;t.normalStyle=M.default.extend({},{"stroke-width":2,stroke:n},e.normalStyle),t.arrowStyle=M.default.extend({},t.normalStyle,{color:t.normalStyle.stroke}),void 0!==e.pointA?(t.coordA=e.pointA.coord,t.pointA.lineStarts.push(t)):void 0!==e.coordA&&(t.coordA=e.coordA.slice()),void 0!==e.pointZ?(t.coordZ=e.pointZ.coord,t.pointZ.lineEnds.push(t)):void 0!==e.coordA&&(t.coordA=t.coordA.slice());const o=t.graph;o.style(t.normalStyle);for(let e=0;e<t.ticks;++e)t.tick[e]=Ln;let s=vn.unscaledSvgPath([[0,0],[1,0]]);for(let e=0;e<t.ticks;++e){const n=.5-(t.ticks-1+2*e)/o.scale[0];s+=vn.unscaledSvgPath([[n,-7],[n,7]])}if(e={thickness:Math.max(t.normalStyle["stroke-width"],t.highlightStyle["stroke-width"])},t.visibleLine=new _n(o,[0,0],[1,0],e),t.visibleLine.attr(t.normalStyle),!t.fixed){const e={thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"};t.mouseTarget=new _n(o,[0,0],[1,0],e),t.mouseTarget.attr({fill:"#000",opacity:0})}if(t.transform=function(e){e&&("object"==typeof this.pointA&&(this.coordA=this.pointA.coord),"object"==typeof this.pointZ&&(this.coordZ=this.pointZ.coord));const n=function(e,n,o){const s=(e=t.graph).range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),i=e.unscaleVector(d.vector.cartFromPolarDeg(1,o)),r=d.vector.scale(d.vector.normalize(i),s),a=d.vector.add(n,r),l=d.vector.polarDegFromCart(i)[1];return e.constrainToBoundsOnAngle(a,4,l*Math.PI/180)},s=function(e){const t=e.graph.scalePoint(e.coordA),n=e.graph.scalePoint(e.coordZ);return d.vector.polarDegFromCart(d.vector.subtract(n,t))[1]}(this);let i=this.coordA,r=this.coordZ;this.extendLine?(i=n(o,i,360-s),r=n(o,r,(540-s)%360)):this.extendRay&&(r=n(o,i,360-s));const a=[this.visibleLine];this.fixed||a.push(this.mouseTarget),M.default.each(a,(function(e){e.moveTo(i,r)}));const l=function(e,t){const o=[.75,0];let s=[[-3,4],[-2.75,2.5],[0,.25],o,[0,-.25],[-2.75,-2.5],[-3,-4]];s=M.default.map(s,(function(e){const t=d.vector.subtract(e,o),n=d.vector.scale(t,1.4);return d.vector.add(o,n)}));const i=M.default.map(s,e.unscalePoint),r={center:e.unscalePoint(o),createPath:function(e){let t="M"+e[0][0]+" "+e[0][1];for(let n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t}},a=new Mn(e,i,r);return a.attr(M.default.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),a.toCoordAtAngle=function(t,s){const i=e.scalePoint(n(e,t,s)),r=In();a.transform("translateX("+(i[0]+1.4*o[0])+"px) translateY("+(i[1]+1.4*o[1])+"px) "+(r?"translateZ(0) ":"")+"rotate("+(360-ae.bound(s))+"deg)")},a};null==this._arrows&&(this._arrows=[],this.extendLine?(this._arrows.push(l(o,this.normalStyle)),this._arrows.push(l(o,this.normalStyle))):this.extendRay&&this._arrows.push(l(o,this.normalStyle)));const c=[this.coordA,this.coordZ],p=[360-s,(540-s)%360];M.default.each(this._arrows,(function(e,t){e.toCoordAtAngle(c[t],p[t])})),M.default.invoke(this.temp,"remove"),this.temp=[];const u=this.coordA[0]<this.coordZ[0]||this.coordA[0]===this.coordZ[0]&&this.coordA[1]>this.coordZ[1];this.sideLabel&&this.temp.push(this.graph.labelSide({point1:this.coordA,point2:this.coordZ,label:this.labeledSide,text:this.sideLabel,numArrows:this.numArrows,numTicks:this.numTicks,clockwise:u,style:this.labelStyle})),this.vertexLabels.length&&(this.graph.labelVertex({vertex:this.coordA,point3:this.coordZ,label:this.labeledVertices[0],text:this.vertexLabels[0],clockwise:u,style:this.labelStyle}),this.graph.labelVertex({point1:this.coordA,vertex:this.coordZ,label:this.labeledVertices[1],text:this.vertexLabels[1],clockwise:u,style:this.labelStyle})),this.temp=M.default.flatten(this.temp)},t.toBack=function(){t.fixed||t.mouseTarget.toBack(),t.visibleLine.toBack()},t.toFront=function(){t.fixed||t.mouseTarget.toFront(),t.visibleLine.toFront()},t.remove=function(){t.fixed||t.mouseTarget.remove(),t.visibleLine.remove(),t.labeledSide&&t.labeledSide.remove(),t.labeledVertices&&M.default.invoke(t.labeledVertices,"remove"),t._arrows&&M.default.invoke(t._arrows,"remove"),t.temp.length&&M.default.invoke(t.temp,"remove")},t.hide=function(){t.visibleLine.hide(),t.temp.length&&M.default.invoke(t.temp,"hide"),t._arrows&&M.default.invoke(t._arrows,"hide")},t.show=function(){t.visibleLine.show(),t.temp.length&&M.default.invoke(t.temp,"show"),t._arrows&&M.default.invoke(t._arrows,"show")},t.sideLabel&&(t.labeledSide=this.label([0,0],"","center",t.labelStyle)),t.vertexLabels.length&&(t.labeledVertices=M.default.map(t.vertexLabels,(function(e){return this.label([0,0],"","center",t.labelStyle)}),this)),!t.fixed&&!t.constraints.fixed){const e=R.default(t.mouseTarget.getMouseTarget());e.css("cursor","move"),e.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Dn||(t.highlight=!0,t.visibleLine.animate(t.highlightStyle,50),t.arrowStyle=M.default.extend({},t.arrowStyle,{color:t.highlightStyle.stroke,stroke:t.highlightStyle.stroke}),t.transform());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=M.default.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();let n=(e.pageX-R.default(o.raphael.canvas.parentNode).offset().left)/o.scale[0]+o.range[0][0],s=o.range[1][1]-(e.pageY-R.default(o.raphael.canvas.parentNode).offset().top)/o.scale[1];t.snapX>0&&(n=Math.round(n/t.snapX)*t.snapX),t.snapY>0&&(s=Math.round(s/t.snapY)*t.snapY);const i=[t.coordA[0]-n,t.coordA[1]-s],r=[t.coordZ[0]-n,t.coordZ[1]-s],a=-Math.min(o.scaleVector(i)[0],o.scaleVector(r)[0]),l=Math.max(o.scaleVector(i)[0],o.scaleVector(r)[0]),c=Math.max(o.scaleVector(i)[1],o.scaleVector(r)[1]),p=-Math.min(o.scaleVector(i)[1],o.scaleVector(r)[1]);R.default(document).bind("vmousemove.lineSegment vmouseup.lineSegment",(function(e){e.preventDefault(),t.dragging=!0,Dn=!0;let n=e.pageX-R.default(o.raphael.canvas.parentNode).offset().left,s=e.pageY-R.default(o.raphael.canvas.parentNode).offset().top;n=Math.max(a+10,Math.min(o.xpixels-10-l,n)),s=Math.max(c+10,Math.min(o.ypixels-10-p,s));let d=n/o.scale[0]+o.range[0][0],u=o.range[1][1]-s/o.scale[1];if(t.snapX>0&&(d=Math.round(d/t.snapX)*t.snapX),t.snapY>0&&(u=Math.round(u/t.snapY)*t.snapY),"vmousemove"===e.type){t.constraints.constrainX&&(d=t.coordA[0]-i[0]),t.constraints.constrainY&&(u=t.coordA[1]-i[1]);const e=d+i[0]-t.coordA[0],n=u+i[1]-t.coordA[1];t.coordA=[d+i[0],u+i[1]],t.coordZ=[d+r[0],u+r[1]],t.transform(),t.movePointsWithLine&&("object"==typeof t.pointA&&t.pointA.setCoord([t.pointA.coord[0]+e,t.pointA.coord[1]+n]),"object"==typeof t.pointZ&&t.pointZ.setCoord([t.pointZ.coord[0]+e,t.pointZ.coord[1]+n])),M.default.isFunction(t.onMove)&&t.onMove(e,n)}else"vmouseup"===e.type&&(R.default(document).unbind(".lineSegment"),t.dragging=!1,Dn=!1,t.highlight||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=M.default.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform()),M.default.isFunction(t.onMoveEnd)&&t.onMoveEnd());R.default(t).trigger("move")}))}}))}return void 0!==t.pointA&&t.pointA.toFront(),void 0!==t.pointZ&&t.pointZ.toFront(),t.transform(),t},addMovablePolygon:function(e){const t=this,n=R.default.extend({snapX:0,snapY:0,fixed:!1,constrainToGraph:!0,normalStyle:{},highlightStyle:{stroke:dn.INTERACTING,"stroke-width":2,fill:dn.INTERACTING,"fill-opacity":.05},pointHighlightStyle:{fill:dn.INTERACTING,stroke:dn.INTERACTING},labelStyle:{stroke:dn.DYNAMIC,"stroke-width":1,color:dn.DYNAMIC},angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],updateOnPointMove:!0,closed:!0},M.default.omit(e,"points")),o=n.fixed?dn.DYNAMIC:dn.INTERACTIVE;n.normalStyle=M.default.extend({"stroke-width":2,"fill-opacity":0,fill:o,stroke:o},e.normalStyle),n.points=e.points;const s=function(e){return!M.default.isArray(e)};if(n.update=function(){const e=n.points.length;n.coords=M.default.map(n.points,(function(e,t){return s(e)?e.coord:e})),n.left=M.default.min(M.default.pluck(n.coords,0)),n.right=M.default.max(M.default.pluck(n.coords,0)),n.top=M.default.max(M.default.pluck(n.coords,1)),n.bottom=M.default.min(M.default.pluck(n.coords,1));let o=M.default.map(n.coords,(function(e){return t.scalePoint(e)}));n.closed?o.push(!0):o=o.concat(M.default.clone(o).reverse()),n.path=vn.unscaledSvgPath(o),M.default.invoke(n.temp,"remove"),n.temp=[];const i=function(e){const t=M.default.zip(e,e.slice(1).concat(e.slice(0,1)));return Pn(M.default.map(t,(function(e){const t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])})))>0}(n.coords);(n.angleLabels.length||n.showRightAngleMarkers.length)&&M.default.each(n.labeledAngles,(function(o,s){n.temp.push(t.labelAngle({point1:n.coords[(s-1+e)%e],vertex:n.coords[s],point3:n.coords[(s+1)%e],label:o,text:n.angleLabels[s],showRightAngleMarker:n.showRightAngleMarkers[s],numArcs:n.numArcs[s],clockwise:i,style:n.labelStyle}))})),n.sideLabels.length&&M.default.each(n.labeledSides,(function(o,s){n.temp.push(t.labelSide({point1:n.coords[s],point2:n.coords[(s+1)%e],label:o,text:n.sideLabels[s],numArrows:n.numArrows[s],numTicks:n.numTicks[s],clockwise:i,style:n.labelStyle}))})),n.vertexLabels.length&&M.default.each(n.labeledVertices,(function(o,s){t.labelVertex({point1:n.coords[(s-1+e)%e],vertex:n.coords[s],point3:n.coords[(s+1)%e],label:o,text:n.vertexLabels[s],clockwise:i,style:n.labelStyle})})),n.temp=M.default.flatten(n.temp)},n.transform=function(){n.update(),n.visibleShape.attr({path:n.path}),n.fixed||n.mouseTarget.attr({path:n.path})},n.remove=function(){n.visibleShape.remove(),n.fixed||n.mouseTarget.remove(),n.labeledAngles&&M.default.invoke(n.labeledAngles,"remove"),n.labeledSides&&M.default.invoke(n.labeledSides,"remove"),n.labeledVertices&&M.default.invoke(n.labeledVertices,"remove"),n.temp.length&&M.default.invoke(n.temp,"remove")},n.toBack=function(){n.fixed||n.mouseTarget.toBack(),n.visibleShape.toBack()},n.toFront=function(){n.fixed||n.mouseTarget.toFront(),n.visibleShape.toFront()},n.updateOnPointMove&&M.default.each(M.default.filter(n.points,s),(function(e){e.polygonVertices.push(n)})),n.coords=new Array(n.points.length),n.angleLabels.length){const e=Math.max(n.angleLabels.length,n.showRightAngleMarkers.length);n.labeledAngles=M.default.times(e,(function(){return this.label([0,0],"","center",n.labelStyle)}),this)}return n.sideLabels.length&&(n.labeledSides=M.default.map(n.sideLabels,(function(e){return this.label([0,0],"","center",n.labelStyle)}),this)),n.vertexLabels.length&&(n.labeledVertices=M.default.map(n.vertexLabels,(function(e){return this.label([0,0],"","center",n.labelStyle)}),this)),n.update(),n.visibleShape=t.raphael.path(n.path),n.visibleShape.attr(n.normalStyle),n.fixed||(n.mouseTarget=t.mouselayer.path(n.path),n.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"}),R.default(n.mouseTarget[0]).bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Dn&&!n.dragging||(n.highlight=!0,n.visibleShape.animate(n.highlightStyle,50),M.default.each(M.default.filter(n.points,s),(function(e){e.visibleShape.animate(n.pointHighlightStyle,50)})));else if("vmouseout"===e.type){if(n.highlight=!1,!n.dragging){n.visibleShape.animate(n.normalStyle,50);const e=M.default.filter(n.points,s);M.default.any(M.default.pluck(e,"dragging"))||M.default.each(e,(function(e){e.visibleShape.animate(e.normalStyle,50)}))}}else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),M.default.each(M.default.filter(n.points,s),(function(e){e.dragging=!0}));let o=(e.pageX-R.default(t.raphael.canvas.parentNode).offset().left)/t.scale[0]+t.range[0][0],i=t.range[1][1]-(e.pageY-R.default(t.raphael.canvas.parentNode).offset().top)/t.scale[1];n.snapX>0&&(o=Math.round(o/n.snapX)*n.snapX),n.snapY>0&&(i=Math.round(i/n.snapY)*n.snapY);let r=o,a=i;const l=n.coords.slice(),c=(o-n.left)*t.scale[0],p=(n.right-o)*t.scale[0],d=(n.top-i)*t.scale[1],u=(i-n.bottom)*t.scale[1];R.default(document).bind("vmousemove.polygon vmouseup.polygon",(function(e){e.preventDefault(),n.dragging=!0,Dn=!0;let h=e.pageX-R.default(t.raphael.canvas.parentNode).offset().left,f=e.pageY-R.default(t.raphael.canvas.parentNode).offset().top;n.constrainToGraph&&(h=Math.max(c+10,Math.min(t.xpixels-10-p,h)),f=Math.max(d+10,Math.min(t.ypixels-10-u,f)));let m=h/t.scale[0]+t.range[0][0],g=t.range[1][1]-f/t.scale[1];if(n.snapX>0&&(m=Math.round(m/n.snapX)*n.snapX),n.snapY>0&&(g=Math.round(g/n.snapY)*n.snapY),"vmousemove"===e.type){let e=m-o,t=g-i,c=!0;if(M.default.isFunction(n.onMove)){const s=n.onMove(e,t);!1===s?c=!1:M.default.isArray(s)&&(e=s[0],t=s[1],m=o+e,g=i+t)}const p=function(n){return[l[n][0]+e,l[n][1]+t]};c&&(M.default.each(n.points,(function(e,t){s(e)?e.setCoord(p(t)):n.points[t]=p(t)})),n.transform(),R.default(n).trigger("move"),r=m,a=g)}else if("vmouseup"===e.type){R.default(document).unbind(".polygon");const e=M.default.filter(n.points,s);M.default.each(e,(function(e){e.dragging=!1})),n.dragging=!1,Dn=!1,n.highlight||(n.visibleShape.animate(n.normalStyle,50),M.default.each(e,(function(e){e.visibleShape.animate(e.normalStyle,50)}))),M.default.isFunction(n.onMoveEnd)&&n.onMoveEnd(r-o,a-i)}}))}}))),M.default.invoke(M.default.filter(n.points,s),"toFront"),n},constrainToBounds:function(e,t){const n=this.unscalePoint([t,this.ypixels-t]),o=this.unscalePoint([this.xpixels-t,t]);return[Math.max(n[0],Math.min(o[0],e[0])),Math.max(n[1],Math.min(o[1],e[1]))]},constrainToBoundsOnAngle:function(e,t,n){const o=this.unscalePoint([t,this.ypixels-t]),s=this.unscalePoint([this.xpixels-t,t]);let i=e.slice();return i[0]<o[0]?i=[o[0],i[1]+(o[0]-i[0])*Math.tan(n)]:i[0]>s[0]&&(i=[s[0],i[1]-(i[0]-s[0])*Math.tan(n)]),i[1]<o[1]?i=[i[0]+(o[1]-i[1])/Math.tan(n),o[1]]:i[1]>s[1]&&(i=[i[0]-(i[1]-s[1])/Math.tan(n),s[1]]),i},addMovableAngle:function(e){return new qn(this,e)},addCircleGraph:function(e){const t=this,n=R.default.extend({center:[0,0],radius:2,snapX:.5,snapY:.5,snapRadius:.5,minRadius:1,centerConstraints:{},centerNormalStyle:{},centerHighlightStyle:{stroke:dn.INTERACTING,fill:dn.INTERACTING},circleNormalStyle:{stroke:dn.INTERACTIVE,"fill-opacity":0},circleHighlightStyle:{stroke:dn.INTERACTING,fill:dn.INTERACTING,"fill-opacity":.05}},e),o=n.centerConstraints.fixed?dn.DYNAMIC:dn.INTERACTIVE,s=e?e.centerNormalStyle:null;n.centerNormalStyle=M.default.extend({},{fill:o,stroke:o},s),n.centerPoint=t.addMovablePoint({graph:t,coord:n.center,normalStyle:n.centerNormalStyle,snapX:n.snapX,snapY:n.snapY,constraints:n.centerConstraints}),n.circ=t.circle(n.center,n.radius,n.circleNormalStyle),n.perim=t.mouselayer.circle(t.scalePoint(n.center)[0],t.scalePoint(n.center)[1],t.scaleVector(n.radius)[0]).attr({"stroke-width":20,opacity:.002}),n.centerConstraints.fixed||R.default(n.centerPoint.mouseTarget.getMouseTarget()).on("vmouseover vmouseout",(function(e){n.centerPoint.highlight||n.centerPoint.dragging?n.circ.animate(n.circleHighlightStyle,50):n.circ.animate(n.circleNormalStyle,50)})),n.toFront=function(){n.circ.toFront(),n.perim.toFront(),n.centerPoint.visibleShape.toFront(),n.centerConstraints.fixed||n.centerPoint.mouseTarget.toFront()},n.centerPoint.onMove=function(e,o){n.toFront(),n.circ.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(o)[1]}),n.perim.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(o)[1]}),n.onMove&&n.onMove(e,o)},R.default(n.centerPoint).on("move",(function(){n.center=this.coord,R.default(n).trigger("move")})),n.setCenter=function(e,t){n.centerPoint.setCoord([e,t]),n.centerPoint.onMove(e,t),n.center=[e,t]},n.setRadius=function(e){n.radius=e,n.perim.attr({r:t.scaleVector(e)[0]}),n.circ.attr({rx:t.scaleVector(e)[0],ry:t.scaleVector(e)[1]})},n.remove=function(){n.centerPoint.remove(),n.circ.remove(),n.perim.remove()};const i=[[-1*Math.PI,-.875*Math.PI,"ew-resize"],[-.875*Math.PI,-.625*Math.PI,"nesw-resize"],[-.625*Math.PI,-.375*Math.PI,"ns-resize"],[-.375*Math.PI,-.125*Math.PI,"nwse-resize"],[-.125*Math.PI,.125*Math.PI,"ew-resize"],[.125*Math.PI,.375*Math.PI,"nesw-resize"],[.375*Math.PI,.625*Math.PI,"ns-resize"],[.625*Math.PI,.875*Math.PI,"nwse-resize"],[.875*Math.PI,1*Math.PI,"ew-resize"]];return R.default(n.perim.node).on("vmousemove",(e=>{let[t,o]=this.getMouseCoord(e);t-=n.center[0],o-=n.center[1];const s=Math.atan2(o,t);i.forEach((function(e){const[t,o,i]=e;s>=t&&s<o&&R.default(n.perim.node).css("cursor",i)}))})),R.default(n.perim.node).css("cursor","nesw-resize"),n.perim.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),R.default(n.perim.node).on("vmouseover vmouseout vmousedown",(function(e){if("vmouseover"===e.type)n.highlight=!0,Dn||(n.circ.animate(n.circleHighlightStyle,50),n.centerPoint.visibleShape.animate(n.centerHighlightStyle,50));else if("vmouseout"===e.type)n.highlight=!1,n.dragging||n.centerPoint.dragging||(n.circ.animate(n.circleNormalStyle,50),n.centerPoint.visibleShape.animate(n.centerNormalStyle,50));else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),n.toFront();const o=n.radius;R.default(document).on("vmousemove vmouseup",(function(e){if(e.preventDefault(),n.dragging=!0,Dn=!0,"vmousemove"===e.type){const o=t.constrainToBounds(t.getMouseCoord(e),10);let s=vn.getDistance(n.centerPoint.coord,o);s=Math.max(n.minRadius,Math.round(s/n.snapRadius)*n.snapRadius);const i=n.radius;let r=!0;if(n.onResize){const e=n.onResize(s,i);M.default.isNumber(e)?s=e:!1===e&&(r=!1)}r&&(n.setRadius(s),R.default(n).trigger("move"))}else"vmouseup"===e.type&&(R.default(document).off("vmousemove vmouseup"),n.dragging=!1,Dn=!1,n.onResizeEnd&&n.onResizeEnd(n.radius,o))}))}})),n},addRotateHandle:function(e){const t=this;let n=e.center;const o=e.radius,s=e.lengthAngle||30,i=e.hideArrow||!1,r=e.mouseTarget,a=M.default.uniqueId("rotateHandle");M.default.isArray(n)&&(n={coord:n});const l=t.addMovablePoint({coord:d.point.addVector(n.coord,d.vector.cartFromPolarDeg(o,e.angleDeg||0)),constraints:{fixedDistance:{dist:o,point:n}},mouseTarget:r});n.toFront();let c,p=n.coord,u=l.coord,h=u,f=!1,m=!1;const g=function(o){if(i)return;const r=d.vector.subtract(o,n.coord),a=d.vector.polarDegFromCart(r)[1];c&&c.remove(),c=function(e,t,n,o,s,i,r){const a=function(o,s){const r=n+s,a=d.vector.cartFromPolarDeg(r,i+o),l=d.vector.add(t,a),c=e.scalePoint(l);return c[0]+","+c[1]},l=e.scaleVector(n-o),c=e.scaleVector(n+o);return e.raphael.path(" M"+a(s,-o)+" L"+a(s,-3*o)+" L"+a(2*s,0)+" L"+a(s,3*o)+" L"+a(s,o)+" A"+c[0]+","+c[1]+",0,0,1,"+a(-s,o)+" L"+a(-s,3*o)+" L"+a(-2*s,0)+" L"+a(-s,-3*o)+" L"+a(-s,-o)+" A"+l[0]+","+l[1]+",0,0,0,"+a(s,-o)+" Z").attr({stroke:null,fill:r?dn.INTERACTING:dn.INTERACTIVE})}(t,n.coord,e.radius,f||m?e.hoverWidth/2:e.width/2,s,a,f||m)};R.default(n).on("move."+a,(function(){const e=d.vector.subtract(n.coord,p);l.setCoord(d.vector.add(l.coord,e)),g(l.coord),p=n.coord,l.constraints.fixedDistance.point=n,u=l.coord})),l.onMove=function(t,o){f||(h=u,f=!0);let s=[t,o];if(e.onMove){const t=d.vector.polarDegFromCart(d.vector.subtract(u,n.coord)),o=d.vector.polarDegFromCart(d.vector.subtract(s,n.coord)),i=t[1],r=o[1];let a=e.onMove(r,i);null!=a&&!0!==a&&(!1===a&&(a=i),s=d.vector.add(n.coord,d.vector.cartFromPolarDeg(t[0],a)))}return g(s),u=s,s},l.onMoveEnd=function(){if(f=!1,g(l.coord),e.onMoveEnd){const t=d.vector.polarDegFromCart(d.vector.subtract(h,n.coord)),o=d.vector.polarDegFromCart(d.vector.subtract(l.coord,n.coord));e.onMoveEnd(o[1],t[1])}},l.visibleShape.remove(),r||l.mouseTarget.attr({scale:2});const v=R.default(l.mouseTarget.getMouseTarget());v.bind("vmouseover",(function(e){m=!0,g(l.coord)})),v.bind("vmouseout",(function(e){m=!1,g(l.coord)})),g(l.coord);const y=l.remove;return l.remove=function(){y.call(l),c&&c.remove(),R.default(n).off("move."+a)},l.update=function(){g(l.coord)},l},addReflectButton:function(e){const t=this,n=e.line,o=t.addMovablePoint({constraints:e.constraints,coord:d.line.midpoint([n.pointA.coord,n.pointZ.coord]),snapX:t.snap[0],snapY:t.snap[1],onMove:function(e,t){return!1},onMoveEnd:function(t,n){e.onMoveEnd&&e.onMoveEnd.call(this,t,n)}});let s,i=!1,r=!1;const a=function(){return i},l=M.default.map([0,1],(function(t){const n=t?e.highlightStyle:e.normalStyle;return M.default.map([0,1],(function(e){return M.default.defaults({"fill-opacity":e},n)}))})),c=function(e){return r&&(e=!e),l[+a()][+e]},p=function(n,o){s&&s.remove(),s=function(e,t,n,o,s,i,r){d.point.equal(n[0],n[1])&&(n=[n[0],d.point.addVector(n[0],[1,1])]);const a=d.vector.normalize(d.vector.subtract(n[1],n[0])),l=d.vector.scale(a,o/2),c=d.vector.scale(a,s),p=d.vector.rotateDeg(c,90),u=d.vector.rotateDeg(c,-90),h=d.vector.negate(l),f=d.vector.rotateDeg(l,90),m=d.vector.rotateDeg(l,-90),g=d.point.addVectors(t,p),v=d.point.addVectors(t,u),y=d.point.addVectors(t,p,l,f),b=d.point.addVectors(t,p,h,f),x=d.point.addVectors(t,u,l,m),w=d.point.addVectors(t,u,h,m),C=e.path([g,y,b,!0],i),k=e.path([v,x,w,!0],r);return{remove:function(){C.remove(),k.remove()}}}(t,n,o,a()?1.5*e.size:e.size,a()?.125*e.size:.25,c(0),c(1))},u=function(e,t){e=e||n.pointA.coord,t=t||n.pointZ.coord;const s=d.line.midpoint([e,t]);o.setCoord(s),p(s,[e,t])};R.default(n).on("move",M.default.bind(u,o,null,null));const h=R.default(o.mouseTarget.getMouseTarget());h.on("vclick",(function(){!1!==e.onClick()&&(r=!r,p(o.coord,[n.pointA.coord,n.pointZ.coord]))})),n.pointA.toFront(),n.pointZ.toFront(),o.visibleShape.remove();const f=t.scaleVector(e.size)[0]/20;o.mouseTarget.attr({scale:1.5*f}),h.css("cursor","pointer"),h.bind("vmouseover",(function(e){i=!0,p(o.coord,[n.pointA.coord,n.pointZ.coord])})),h.bind("vmouseout",(function(e){i=!1,p(o.coord,[n.pointA.coord,n.pointZ.coord])}));const m=o.remove;return o.remove=function(){s.remove(),m.call(o)},o.update=u,o.isFlipped=function(){return r},u(),o},protractor:function(e){return new Bn(this,e)},ruler:function(e){return new zn(this,e||{})},addPoints:Nn}),M.default.extend(qn.prototype,{points:[],snapDegrees:0,snapOffsetDeg:0,angleLabel:"",numArcs:1,pushOut:0,fixed:!1,addMoveHandlers:function(){const e=this.graphie;function t(t,n){return vn.getDistance(e.scalePoint(t),e.scalePoint(n))<30}const n=this.points;n[1].onMove=function(o,s){const i=n[1].coord,r=[o,s],a=Nn(r,An(i));let l=!0;const c={};return M.default.each([0,2],(function(o){let s=Nn(n[o].coord,a),i=vn.findAngle(r,s);i*=Math.PI/180,s=e.constrainToBoundsOnAngle(s,10,i),c[o]=s,t(r,s)&&(l=!1)})),l&&M.default.each(c,(function(e,t){n[t].setCoord(e)})),l};const o=this.snapDegrees,s=this.snapOffsetDeg;M.default.each([0,2],(function(i){n[i].onMove=function(i,r){const a=[i,r],l=n[1].coord;if(t(l,a))return!1;if(o){let t=vn.findAngle(a,l);t=Math.round((t-s)/o)*o+s;const n=vn.getDistance(a,l);return Nn(l,e.polar(n,t))}return!0}})),R.default(n).on("move",function(){this.update(),R.default(this).trigger("move")}.bind(this))},addHighlightHandlers:function(){const e=this.points[1];e.onHighlight=function(){M.default.each(this.points,(function(e){e.visibleShape.animate(this.highlightStyle,50)}),this),M.default.each(this.rays,(function(e){e.visibleLine.animate(this.highlightStyle,50),e.arrowStyle=M.default.extend({},e.arrowStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke})}),this),this.angleStyle=M.default.extend({},this.angleStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke}),this.update()}.bind(this),e.onUnhighlight=function(){M.default.each(this.points,(function(e){e.visibleShape.animate(this.normalStyle,50)}),this),M.default.each(this.rays,(function(e){e.visibleLine.animate(e.normalStyle,50),e.arrowStyle=M.default.extend({},e.arrowStyle,{color:e.normalStyle.stroke,stroke:e.normalStyle.stroke})}),this),this.angleStyle=M.default.extend({},this.angleStyle,{color:dn.DYNAMIC,stroke:dn.DYNAMIC}),this.update()}.bind(this)},_getClockwiseAngle:function(e){return vn.findAngle(e[2],e[0],e[1])+0},isReflex:function(){return this.reflex},isClockwise:function(){return this._getClockwiseAngle(this.coords)>180===this.reflex},getClockwiseCoords:function(){return this.isClockwise()?M.default.clone(this.coords):M.default.clone(this.coords).reverse()},update:function(e){const t=this.coords;this.coords=M.default.pluck(this.points,"coord"),M.default.invoke(this.points,"updateLineEnds");const n=this._getClockwiseAngle(t),o=this._getClockwiseAngle(this.coords),s=n>180,i=o>180;this.allowReflex&&(null==e&&(e=s!==i&&Math.abs(o-n)<180),e&&(this.reflex=!this.reflex)),M.default.invoke(this.temp,"remove"),this.temp=this.graphie.labelAngle({point1:this.coords[0],vertex:this.coords[1],point3:this.coords[2],label:this.labeledAngle,text:this.angleLabel,numArcs:this.numArcs,pushOut:this.pushOut,clockwise:this.reflex===i,style:this.angleStyle})},remove:function(){M.default.invoke(this.rays,"remove"),M.default.invoke(this.temp,"remove"),this.labeledAngle.remove()}});const Hn=Ae.nestedMap,Wn=Ae.deepEq;function Un(e){M.default.extend(this,e)}const Gn=function(){throw new re("Abstract method! Must be implemented by Graphie Movable"+this.constructor.displayName,se.NotAllowed)};M.default.extend(Un.prototype,{movableProps:[],add:Gn,modify:Gn,remove:Gn,toFront:function(){},componentDidMount:function(){}});const Vn=function(e){const t=function(e){if(!(this instanceof t))throw new re("Use createElement or JSX with graphie movables",se.NotAllowed);return this.props=function(e,t){return M.default.extend({},e,{children:M.default.filter(M.default.flatten(t),M.default.identity)})}(e,e.children||[]),this};return e.displayName=e.displayName||M.default.uniqueId("GraphieClass"),t.displayName=e.displayName,t.prototype=new Un(e),t.prototype.constructor=t,t};var jn={GraphieMovable:Un,createClass:Vn,createSimpleClass:function(e){return Vn({displayName:e.name||M.default.uniqueId("GraphieSimpleClass"),movableProps:["children"],add:function(t){this._elements=e(t,this.props),this._prevProps=this.props},modify:function(e){if(!Wn(this.props,this._prevProps))return this.remove(),this.add(e),this._prevProps=this.props,"reordered"},remove:function(){Hn(this._elements,(e=>{e&&e.remove()})),this._elements=null,this._prevProps=null},toFront:function(){Hn(this._elements,(e=>{M.default.isFunction(e.toFront)&&e.toFront()}))}})}};const Yn=function(e){const t=e.graphie.scalePoint(e.coord(0)),n=e.graphie.scalePoint(e.coord(1));return d.vector.polarDegFromCart(d.vector.subtract(n,t))[1]},$n=function(e,t,n){const o=e.range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),s=e.unscaleVector(d.vector.cartFromPolarDeg(1,n)),i=d.vector.scale(d.vector.normalize(s),o),r=d.vector.add(t,i),a=d.vector.polarDegFromCart(s)[1];return e.constrainToBoundsOnAngle(r,4,a*Math.PI/180)},Xn=function(e,t){const n=[.75,0];let o=[[-3,4],[-2.75,2.5],[0,.25],n,[0,-.25],[-2.75,-2.5],[-3,-4]];o=M.default.map(o,(function(e){const t=d.vector.subtract(e,n),o=d.vector.scale(t,1.4);return d.vector.add(n,o)}));const s=M.default.map(o,e.unscalePoint),i={center:e.unscalePoint(n),createPath:function(e){let t="M"+e[0][0]+" "+e[0][1];for(let n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t}},r=new Mn(e,s,i);return r.attr(M.default.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),r.toCoordAtAngle=function(t,o){const s=e.scalePoint($n(e,t,o));r.transform("translateX("+(s[0]+1.4*n[0])+"px) translateY("+(s[1]+1.4*n[1])+"px) translateZ(0) rotate("+(360-ae.bound(o))+"deg)")},r},Kn={draw:function(){this.draw()},pointsToFront:function(e){M.default.invoke(e.points,"toFront")}};Kn.standard=[Kn.draw,Kn.pointsToFront];const Zn={draw:function(){this.draw()}};Zn.standard=[Zn.draw];const Jn={basic:function(e){const t=this.graphie;let n=this.coord(0),o=this.coord(1);if(!this.state.visibleShape){const e={thickness:10};this.state.visibleShape=new _n(t,n,o,e),this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}const s=Yn(this);e.extendLine?(n=$n(t,n,360-s),o=$n(t,o,(540-s)%360)):e.extendRay&&(o=$n(t,o,360-s));const i=[this.state.visibleShape];this.mouseTarget()&&i.push(this.mouseTarget()),M.default.each(i,(function(e){e.moveTo(n,o)}))},arrows:function(e){null==this._arrows&&(this._arrows=[],e.extendLine?(this._arrows.push(Xn(this.graphie,this.normalStyle())),this._arrows.push(Xn(this.graphie,this.normalStyle()))):e.extendRay&&this._arrows.push(Xn(this.graphie,this.normalStyle())));const t=Yn(this),n=[360-t,(540-t)%360];M.default.each(this._arrows,(function(e,t){e.toCoordAtAngle(this.coord(t),n[t])}),this)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(e.highlightStyle,50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(e.normalStyle,50)}};Jn.standard=[Jn.basic,Jn.arrows,Jn.highlight];const Qn={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},arrows:function(){null!=this._arrows&&M.default.invoke(this._arrows,"remove"),this._arrows=null}};Qn.standard=[Qn.basic,Qn.arrows];const eo={fixed:function(){return function(){return!1}},snap:function(e){return function(t,n){if(null===e)return!0;let o=d.vector.subtract(t,n);return e=e||this.graphie.snap,o=d.point.roundTo(o,e),d.vector.add(n,o)}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(o,s){const i=this.graphie,r=d.vector.subtract(o,s);e=e||i.range,void 0===t&&(t=i.snap);let a=i.unscalePoint([n,i.ypixels-n]),l=i.unscalePoint([i.xpixels-n,n]);t&&(a=d.point.ceilTo(a,t),l=d.point.floorTo(l,t));const c=M.default.map(this.coords(),(function(e,t){const n=d.vector.subtract(l,e);return[d.vector.subtract(a,e),n]})),p=M.default.reduce(c,(function(e,t){const n=t[0],o=t[1];return[Math.max(n[0],Math.min(o[0],e[0])),Math.max(n[1],Math.min(o[1],e[1]))]}),r);return d.vector.add(s,p)}},standard:null},to={updatePoints:function(e,t){const n=d.vector.subtract(e,t);M.default.each(this.state.points,(function(e){e.setCoord(d.vector.add(e.coord(),n))}))},standard:null};var no={add:Kn,modify:Zn,draw:Jn,remove:Qn,onMoveStart:{standard:null},constraints:eo,onMove:to,onMoveEnd:{standard:null}};const oo=an.assert,so=an.normalizeOptions,io=["add","draw","remove","onMoveStart","constraints","onMove","onMoveEnd"],ro={points:null,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,extendLine:!1,extendRay:!1},ao={visibleShape:null,mouseTarget:null},lo=function(e,t,n){oo(null!=e),oo(null!=n),M.default.extend(this,{graphie:e,movable:t,state:{id:M.default.uniqueId("movableLine")}}),this.modify(M.default.extend({},ao,n))};M.default.extend(lo,no),an.createGettersFor(lo,M.default.extend({},ro,ao)),an.addMovableHelperMethodsTo(lo),M.default.extend(lo.prototype,{cloneState:function(){return M.default.extend(this.movable.cloneState(),{coords:this.coords()},this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id},so(io,wn.pluck(no,"standard")),ro)},modify:function(e){this.update(M.default.extend(this._createDefaultState(),e))},update:function(e){const t=this,n=this.graphie,o=t.state=M.default.extend(t.state,so(io,e)),s=o.static?dn.DYNAMIC:dn.INTERACTIVE;if(o.normalStyle=M.default.extend({stroke:s,"stroke-width":2},o.normalStyle),o.highlightStyle=M.default.extend({stroke:dn.INTERACTING,"stroke-width":3},o.highlightStyle),!o.static&&!o.mouseTarget){const e={thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"};o.mouseTarget=new _n(n,this.coord(0),this.coord(1),e),o.mouseTarget.attr({fill:"#000",opacity:0})}o.static&&o.mouseTarget&&(o.mouseTarget.remove(),o.mouseTarget=null),t.movable.modify(M.default.extend({},o,{mouseTarget:o.mouseTarget,add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){const o=d.vector.subtract(e,n);t._totalDelta=d.vector.add(t._totalDelta,o);let s=d.vector.add(t._initialRefCoord,t._totalDelta);s=t._applyConstraints(s,t._prevRefCoord),!1!==s&&(t._fireEvent(t.state.onMove,s,t._prevRefCoord),t._prevRefCoord=s)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),o.added||(t.prevState={},t._fireEvent(o.add,t.cloneState(),t.prevState),o.added=!0,M.default.invoke(o.points,"listen","onMove",o.id,t.draw.bind(t)),t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},coords:function(){return M.default.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.points&&M.default.invoke(this.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove()},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}});const co={path:"M8.70710678,12.2928932 C8.31658249,11.9023689 7.68341751,11.9023689 7.29289322,12.2928932 C6.90236893,12.6834175 6.90236893,13.3165825 7.29289322,13.7071068 L9.82842712,16.2426407 C10.2207367,16.6349502 10.8574274,16.6328935 11.2471942,16.2380576 L16.7116603,10.7025237 C17.0996535,10.3094846 17.0955629,9.67633279 16.7025237,9.28833966 C16.3094846,8.90034653 15.6763328,8.90443714 15.2883397,9.29747629 L10.5309507,14.1167372 L8.70710678,12.2928932 Z",width:24,height:24},po={path:"M6.072 10.4l6.175-7.058a1 1 0 1 1 1.506 1.317L6.769 12.64a1 1 0 0 1-1.55-.054L2.203 8.604a1 1 0 1 1 1.594-1.208L6.072 10.4z",width:16,height:16},uo={path:"M99.669 13.048q0 3.36-2.352 5.712l-41.664 41.664q-2.408 2.408-5.88 2.408t-5.712-2.408l-41.664-41.664q-2.408-2.24-2.408-5.712t2.408-5.88l4.76-4.816q2.52-2.352 5.88-2.352t5.656 2.352l31.136 31.136 31.08-31.136q2.352-2.352 5.712-2.352t5.88 2.352l4.816 4.816q2.352 2.52 2.352 5.88z",width:100,height:63.034},ho={path:"M62.808 49.728q0 3.36-2.352 5.88l-41.72 41.664q-2.352 2.408-5.768 2.408t-5.768-2.408l-4.872-4.76q-2.352-2.52-2.352-5.88t2.352-5.712l31.08-31.136-31.08-31.024q-2.352-2.52-2.352-5.88t2.352-5.712l4.872-4.76q2.296-2.408 5.768-2.408t5.768 2.408l41.72 41.664q2.352 2.296 2.352 5.656z",width:63.034,height:100},fo={path:"M100.035 50.046q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},mo={path:"M50.046 83.676q1.767 0 2.907-1.14l29.526-29.526q1.197-1.197 1.197-2.907t-1.197-2.964l-5.928-5.928q-1.197-1.14-2.964-1.14t-2.907 1.14l-12.312 12.312l0-32.661q0-1.71-1.254-2.964t-2.907-1.254l-8.322 0q-1.71 0-2.964 1.254t-1.254 2.964l0 32.661l-12.312-12.312q-1.197-1.254-2.907-1.254t-2.907 1.254l-5.928 5.928q-1.197 1.197-1.197 2.964t1.197 2.907l29.469 29.526q1.197 1.14 2.964 1.14zm49.989-33.63q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},go={path:"M54.207 83.391q1.653 0 2.907-1.254t1.254-2.907l0-32.718l12.312 12.312q1.254 1.254 2.964 1.254t2.907-1.254l5.928-5.928q1.197-1.197 1.14-2.964 0-1.767-1.14-2.907l-29.526-29.526q-1.197-1.14-2.907-1.14t-2.964 1.14l-29.469 29.526q-1.197 1.254-1.197 2.964t1.197 2.907l5.928 5.928q1.197 1.197 2.907 1.197t2.907-1.197l12.312-12.312l0 32.718q0 1.653 1.254 2.907t2.964 1.254l8.322 0zm45.828-33.345q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},vo={path:"M50.046 8.322q-8.493 0-16.188 3.306-15.561 6.669-22.173 22.23-3.363 7.695-3.363 16.188t3.306 16.188 8.949 13.281q5.586 5.586 13.281 8.892t16.188 3.306 16.188-3.306 13.281-8.892 8.892-13.281 3.306-16.188-3.306-16.188-8.892-13.281-13.281-8.949q-7.695-3.306-16.188-3.306zm0 91.713q-13.623 0-25.137-6.726t-18.183-18.183q-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.126q-11.514 6.726-25.08 6.726z",width:100,height:99.944},yo={path:"M58.368 81.225l0-12.369q0-.912-.57-1.539t-1.425-.627l-12.54 0q-.855-.057-1.482.627t-.684 1.539l0 12.369q-.057.855.627 1.482t1.539.684l12.54 0q.855 0 1.425-.627t.57-1.539zm1.026-62.871q0-1.596-2.223-1.71l-14.307 0q-2.109 0-2.223 1.71l1.14 40.47q0 .627.627 1.14t1.539.456l12.084 0q.912-.057 1.539-.513t.684-1.083zm-9.348-18.354q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669z",width:100,height:99.944},bo={path:"M37.964 76.048q-2.576 0-4.368-1.792l-31.864-31.864q-1.792-1.792-1.792-4.368t1.792-4.368l8.736-8.68q1.792-1.792 4.368-1.792t4.312 1.792l18.816 18.872 42-42.056q1.792-1.792 4.368-1.792t4.312 1.792l8.736 8.736q1.792 1.792 1.792 4.368t-1.792 4.312l-55.048 55.048q-1.792 1.792-4.368 1.792z",width:100,height:76.637},xo={path:"M99.758 43.09l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-29.45 0l0 29.45q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-29.45l-29.45 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l29.45 0l0-29.45q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836l0 29.45l29.45 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:100},wo={path:"M100.464 80.808q0 3.404-2.368 5.772l-11.47 11.544q-2.368 2.368-5.772 2.368t-5.698-2.368l-24.864-24.864-24.864 24.864q-2.368 2.368-5.772 2.368t-5.772-2.368l-11.47-11.544q-2.368-2.368-2.368-5.772t2.368-5.698l24.864-24.864-24.864-24.864q-2.368-2.368-2.368-5.772t2.368-5.772l11.47-11.47q2.368-2.368 5.772-2.368t5.772 2.368l24.864 24.864 24.864-24.864q2.294-2.368 5.698-2.368t5.772 2.368l11.47 11.47q2.368 2.368 2.368 5.772t-2.368 5.772l-24.864 24.864 24.864 24.864q2.368 2.294 2.368 5.698z",width:100,height:100},Co={path:"M15.1052249,9.55978547 L22.0028147,9.55978545 C23.6568673,9.55978545 23.9349557,10.3753626 22.6181351,11.3858845 L16.9943688,15.7015366 L19.2518801,22.8294455 C19.7526645,24.4106317 19.0984455,24.8825885 17.769353,23.8673293 L12.0490577,19.4977438 L6.5116497,23.8422153 C5.20921411,24.8640642 4.53299569,24.4067544 5.00266927,22.8160582 L7.10332364,15.7015366 L1.42794544,11.3634306 C0.110226041,10.3562014 0.383967283,9.54239221 2.0409646,9.54574013 L8.9924676,9.55978547 L11.1485117,2.72669438 C11.6458693,1.15043244 12.4548928,1.15900049 12.9494787,2.72669438 L15.1052249,9.55978547 Z",width:24,height:24},ko={path:"M3.74890556,17.9799506 C2.19251241,16.1970909 1.10103636,13.4971457 1.13090903,11.1491783 C1.17160478,7.95052637 4.01704076,0.865059407 11.7028044,0.865059407 C19.388568,0.865059407 22.3026521,7.35203035 22.3026521,11.5879453 C22.3026521,15.8238603 19.386629,20.5574509 13.6832464,21.7131548 L13.6757539,17.3722171 C17.0812986,16.2190517 18.331158,14.1944123 18.3311578,11.5879451 C18.3311574,8.16554692 15.6664205,5.03476549 11.7028048,5.20494205 C7.73918903,5.37511861 5.59244567,8.66930079 5.59244567,11.1491783 C5.59244567,12.9090077 6.11128139,14.1753512 6.93640437,15.3053215 L8.14052356,14.2949456 C8.98559348,13.5858477 9.6994861,13.9070448 9.73489556,15.0076413 L9.91284941,20.5388014 C9.94832683,21.6415103 9.09967118,22.3514475 8.02194403,22.1254594 L2.60571602,20.9897332 C1.5259204,20.7633114 1.34338662,19.9984207 2.18070755,19.295825 L3.74890556,17.9799506 Z",width:23,height:23},So={path:"M31.293 37.506q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.218 0q-.912-.057-1.482-.627t-.57-1.482l0-37.506q0-2.109 2.052-2.109l4.218 0zm18.753 2.109l0 37.506q0 .912-.57 1.482t-1.539.627l-4.161 0q-1.995 0-2.109-2.109l0-37.506q.057-.912.627-1.482t1.482-.627l4.161 0q.969.057 1.539.627t.57 1.482zm14.592-2.109q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.161 0q-.969-.057-1.539-.627t-.57-1.482l0-37.506q0-2.109 2.109-2.109l4.161 0zm10.431 49.248l0-61.731l-58.368 0l0 61.731q.057 2.679.969 3.819t1.083 1.14l54.207 0q.171 0 1.14-1.083t.969-3.876zm-43.776-70.11l29.184 0l-3.135-7.581q-.456-.57-1.14-.741l-20.634 0q-.627.114-1.083.741zm-31.293 2.109q0-1.995 2.109-2.109l20.121 0l4.56-10.83q.969-2.394 3.477-4.104 2.565-1.71 5.187-1.71l20.805 0q2.622 0 5.187 1.71t3.477 4.104l4.56 10.83l20.178 0q.912.057 1.482.627t.57 1.482l0 4.161q0 1.995-2.052 2.109l-6.27 0l0 61.731q0 5.415-3.078 9.348t-7.353 3.933l-54.207 0q-4.275 0-7.353-3.819t-3.078-9.177l0-62.016l-6.213 0q-.969 0-1.539-.57t-.57-1.539l0-4.161z",width:91.681,height:100},Eo={path:"M10,6.6C10,7.2,9.8,8,9.3,9.1c0,0,0,0.1-0.1,0.1S9.2,9.3,9.2,9.4c0,0,0,0.1-0.1,0.1C9,9.6,9,9.6,8.9,9.6 c-0.1,0-0.1,0-0.1-0.1c0,0,0-0.1,0-0.1c0,0,0-0.1,0-0.1s0-0.1,0-0.1c0-0.3,0-0.5,0-0.7c0-0.4,0-0.7-0.1-1C8.6,7.1,8.5,6.9,8.4,6.7S8.2,6.3,8,6.1C7.8,5.9,7.6,5.8,7.4,5.7S6.9,5.5,6.7,5.5S6.1,5.4,5.8,5.4c-0.3,0-0.6,0-1,0H3.6v1.4c0,0.1,0,0.2-0.1,0.3C3.4,7.1,3.3,7.1,3.2,7.1C3.1,7.1,3,7.1,3,7L0.1,4.1C0,4.1,0,4,0,3.9s0-0.2,0.1-0.3L3,0.8C3,0.7,3.1,0.7,3.2,0.7c0.1,0,0.2,0,0.3,0.1C3.5,0.9,3.6,0.9,3.6,1v1.4h1.2c2.6,0,4.3,0.7,4.9,2.2C9.9,5.2,10,5.8,10,6.6z",width:10,height:10},_o={path:"M8,13 L16,13 C16.5522847,13 17,12.5522847 17,12 C17,11.4477153 16.5522847,11 16,11 L8,11 C7.44771525,11 7,11.4477153 7,12 C7,12.5522847 7.44771525,13 8,13 Z",width:24,height:24};var To=Object.freeze({__proto__:null,iconCheck:co,iconCheckMedium:po,iconChevronDown:uo,iconChevronRight:ho,iconCircle:fo,iconCircleArrowDown:mo,iconCircleArrowUp:go,iconCircleThin:vo,iconDesktop:{path:"M94.208 52.119l0-43.746q0-.69-.506-1.15t-1.196-.506l-84.088 0q-.69 0-1.196.506t-.506 1.15l0 43.746q0 .69.506 1.196t1.196.506l84.088 0q.69 0 1.196-.506t.506-1.196zm6.716-43.746l0 57.224q0 3.45-2.484 5.934t-5.934 2.484l-28.566 0q0 3.128 2.53 7.774.828 1.61.828 2.622t-1.012 2.07q-1.012 1.012-2.346.966l-26.91 0q-1.38 0-2.392-1.012t-1.012-2.024q0-1.058 1.656-4.14t1.748-6.256l-28.612 0q-3.45 0-5.934-2.484t-2.484-5.934l0-57.224q0-3.45 2.484-5.934t5.934-2.438l84.088 0q3.45 0 5.98 2.438 2.438 2.484 2.438 5.934z",width:100,height:86.648},iconDropdownArrow:{path:"M9 9.8c0 .5.7 1.7 1.5 2.8 1.5 1.9 1.5 1.9 3 0C15.7 9.7 15.4 9 12 9c-1.6 0-3 .4-3 .8z",width:24,height:24},iconExclamationSign:yo,iconGear:{path:"M1152 896q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm512-109v222q0 12-8 23t-20 13l-185 28q-19 54-39 91 35 50 107 138 10 12 10 25t-9 23q-27 37-99 108t-94 71q-12 0-26-9l-138-108q-44 23-91 38-16 136-29 186-7 28-36 28h-222q-14 0-24.5-8.5t-11.5-21.5l-28-184q-49-16-90-37l-141 107q-10 9-25 9-14 0-25-11-126-114-165-168-7-10-7-23 0-12 8-23 15-21 51-66.5t54-70.5q-27-50-41-99l-183-27q-13-2-21-12.5t-8-23.5v-222q0-12 8-23t19-13l186-28q14-46 39-92-40-57-107-138-10-12-10-24 0-10 9-23 26-36 98.5-107.5t94.5-71.5q13 0 26 10l138 107q44-23 91-38 16-136 29-186 7-28 36-28h222q14 0 24.5 8.5t11.5 21.5l28 184q49 16 90 37l142-107q9-9 24-9 13 0 25 10 129 119 165 170 7 8 7 22 0 12-8 23-15 21-51 66.5t-54 70.5q26 50 41 98l183 28q13 2 21 12.5t8 23.5z",width:1792,height:1792},iconMobilePhone:{path:"M36.04 89.557q0-2.584-1.836-4.42t-4.42-1.836-4.352 1.836q-1.836 1.836-1.836 4.42t1.836 4.352 4.42 1.836q2.652-.068 4.42-1.836t1.768-4.352zm16.184-12.444l0-54.74q0-1.088-.748-1.768t-1.768-.68l-39.78 0q-1.088 0-1.768.748t-.68 1.7l0 54.74q0 1.02.748 1.768t1.7.68l39.78 0q1.02-.068 1.768-.748t.748-1.7zm-14.892-65.892q0-1.224-1.292-1.292l-12.444 0q-1.224.068-1.224 1.292t1.224 1.224l12.444 0q1.292 0 1.292-1.224zm22.372-1.292l0 79.628q0 3.944-2.992 6.936t-7.004 2.992l-39.78 0q-4.012 0-7.004-2.924-2.924-2.924-2.924-7.004l0-79.628q0-4.012 2.924-6.936t7.004-2.992l39.78 0q4.012-.068 7.004 2.924t2.992 7.004z",width:60.013,height:100},iconOk:bo,iconPlus:xo,iconRemove:wo,iconStar:Co,iconTryAgain:ko,iconTablet:{path:"M45.322 90.706q0-1.86-1.302-3.224-1.364-1.364-3.224-1.364t-3.224 1.364-1.302 3.224q0 1.86 1.364 3.224 1.302 1.364 3.162 1.302 1.86.062 3.224-1.302t1.302-3.224zm27.218-11.346l0-68.014q0-.93-.682-1.612t-1.55-.682l-58.962 0q-.93 0-1.612.682t-.682 1.612l0 68.014q0 .93.682 1.612t1.612.62l58.962 0q.992-.062 1.612-.682t.62-1.55zm9.114-68.014l0 77.066q0 4.65-3.348 7.998t-7.998 3.348l-58.962 0q-4.65 0-7.998-3.348t-3.348-7.998l0-77.066q0-4.65 3.348-7.998t7.998-3.348l58.962 0q4.65 0 7.998 3.348t3.348 7.998z",width:81.852,height:100},iconTrash:So,iconUndo:Eo,iconMinus:_o});const Mo={constrain:function(){this.constrain()}};Mo.standard=[Mo.constrain];const Io={draw:function(){this.draw()}};Io.standard=[Io.draw];const Po={basic:function(e,t){const n=this.graphie;if(!this.state.visibleShape){const t=[this.pointSize()/n.scale[0],this.pointSize()/n.scale[1]],o={maxScale:Math.max(this.highlightStyle().scale,this.normalStyle().scale),padding:10,shadow:e.shadow};this.state.visibleShape=new Sn(n,this.coord(),t,o),this.state.visibleShape.attr(M.default.omit(this.normalStyle(),"scale")),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}e.normalStyle===t.normalStyle||M.default.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.moveTo(this.coord()),this.mouseTarget()&&this.mouseTarget().moveTo(this.coord())},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};Po.standard=[Po.basic,Po.highlight];const No={basic:function(){this.state.visibleShape&&(this.state.visibleShape.remove(),this.state.visibleShape=null)}};No.standard=No.basic;const Ao={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,d.point.roundTo(t,e))}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(o,s,i){const r=this.graphie;e=e||r.range,void 0===t&&(t=r.snap);let a=r.unscalePoint([n,r.ypixels-n]),l=r.unscalePoint([r.xpixels-n,n]);if(t&&(a=d.point.ceilTo(a,t),l=d.point.floorTo(l,t)),i&&i.onOutOfBounds)return(o[0]>l[0]||o[0]<a[0]||o[1]>l[1]||o[1]<a[1])&&(i.onSkipRemaining(),i.onOutOfBounds()),o;return[Math.max(a[0],Math.min(l[0],o[0])),Math.max(a[1],Math.min(l[1],o[1]))]}},standard:null};var Ro={add:Mo,modify:Io,draw:Po,remove:No,onMoveStart:{standard:null},constraints:Ao,onMove:{standard:null},onMoveEnd:{standard:null},onClick:{standard:null}};const Fo=an.assert,Oo=an.normalizeOptions,{processMath:Do}=fn,Lo=M.default.keys(Ro),Bo={coord:[0,0],pointSize:4,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,shadow:!1,tooltip:!1},zo={added:!1,hasMoved:!1,visibleShape:null,outOfBounds:!1,mouseTarget:null,touchOffset:null},qo=[],Ho=function(e,t,n){M.default.extend(this,{graphie:e,movable:t,state:{id:M.default.uniqueId("movablePoint")}}),this.modify(M.default.extend({},zo,n))};function Wo(e){const t=M.default.zip(e,e.slice(1).concat(e.slice(0,1))),n=M.default.map(t,(function(e){const t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])}));return o=n,M.default.reduce(o,(function(e,t){return e+t}),0)>0;var o}M.default.extend(Ho,Ro),an.createGettersFor(Ho,M.default.extend({},Bo,zo)),an.addMovableHelperMethodsTo(Ho),M.default.extend(Ho.prototype,{cloneState:function(){return M.default.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id},Oo(Lo,wn.pluck(Ro,"standard")),Bo)},modify:function(e){this.update(M.default.extend(this._createDefaultState(),e))},_showTooltip:function(e){this._tooltip||(this._tooltip=document.createElement("div"),this._tooltip.className="tooltip-content",this.state.visibleShape.wrapper.className="tooltip",this.state.visibleShape.wrapper.appendChild(this._tooltip),qo.push((()=>{this.state.added&&this._hideTooltip()}))),this._tooltip.firstChild&&this._tooltip.removeChild(this._tooltip.firstChild),this.state.visibleShape.wrapper.className="tooltip visible",this._tooltip.appendChild(document.createElement("span")),"string"==typeof e?Do(this._tooltip.firstChild,e,!1):"function"==typeof e?e(this._tooltip.firstChild):this._tooltip.firstChild.appendChild(e)},_hideTooltip:function(){this._tooltip&&(this.state.visibleShape.wrapper.className="tooltip")},update:function(e){const t=this,n=t.graphie,o=M.default.extend(t.state,Oo(Lo,e));Fo(d.point.is(o.coord));const s=o.static?dn.DYNAMIC:dn.INTERACTIVE;if(o.normalStyle=M.default.extend({fill:s,stroke:s,scale:1},o.normalStyle),o.highlightStyle=M.default.extend({fill:dn.INTERACTING,stroke:dn.INTERACTING,scale:2},o.highlightStyle),!o.static&&!o.mouseTarget){const e=t.state.coord,s=n.unscaleVector(24),i={mouselayer:!0,padding:0,interactiveKindForTesting:"movable-point"};o.mouseTarget=new Sn(n,e,s,i),o.mouseTarget.attr({fill:"#000",opacity:0})}const i=()=>{this._showTooltip((e=>{A.render(_.createElement("span",{style:{fontSize:"2em"}},_.createElement(G,U({},So,{style:{position:"static",color:dn.INTERACTIVE,marginLeft:9,marginRight:9}}))),e)}))};let r=o.coord;t.movable.modify(M.default.extend({},o,{add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:e=>{if(o.hasMoved=!1,r=o.coord,null==o.touchOffset){const t=!("ontouchstart"in window);o.touchOffset=t?[0,0]:d.vector.subtract(r,e)}const n=o.visibleShape.wrapper;if(o.shadow){const e="none";n.style.webkitFilter=e,n.style.filter=e}if(o.showHairlines&&o.showHairlines(o.coord),qo.forEach((e=>e())),o.tooltip&&(o.xOnlyTooltip?this._showTooltip("".concat(o.coord[0])):this._showTooltip("(".concat(o.coord[0],", ").concat(o.coord[1],")")),o.shadow)){const e=n.getElementsByClassName("tooltip-content")[0],t="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=t,e.style.filter=t}t._fireEvent(o.onMoveStart,r,r),t.draw()},onMove:(e,n)=>{const s=d.vector.add(e,o.touchOffset);t.moveTo(s),o.showHairlines&&(this.state.outOfBounds?o.hideHairlines():o.showHairlines(o.coord)),o.tooltip&&(this.state.outOfBounds||(o.xOnlyTooltip?this._showTooltip("".concat(o.coord[0])):this._showTooltip("(".concat(o.coord[0],", ").concat(o.coord[1],")")))),o.onRemove&&this.state.outOfBounds&&i()},onMoveEnd:()=>{t.isHovering()&&!o.hasMoved&&t._fireEvent(o.onClick,o.coord,r);const e=o.visibleShape.wrapper;if(o.shadow){const t="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=t,e.style.filter=t}if(o.hideHairlines&&o.hideHairlines(),o.hasMoved)this._hideTooltip();else if(o.onRemove){i();const t=e.getElementsByClassName("tooltip-content")[0];t.style.webkitFilter="none",t.style.filter="none",this._tooltip.firstChild.addEventListener("touchstart",(e=>{e.stopPropagation()}),!0),this._tooltip.firstChild.addEventListener("touchend",(e=>{o.onRemove(),e.stopPropagation()}),!0)}else o.tooltip&&this._hideTooltip();o.outOfBounds&&o.onRemove(),t._fireEvent(o.onMoveEnd,o.coord,r),o.hasMoved=!1,o.touchOffset=null,t.draw()}})),o.added||(t.prevState={},t._fireEvent(o.add,t.cloneState(),t.prevState),o.added=!0,t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){const e=this._applyConstraints(this.coord(),this.coord());return d.point.is(e)&&this.setCoord(e),!1!==e},setCoord:function(e){Fo(d.point.is(e,2)),this.state.coord=M.default.clone(e),this.draw()},setCoordConstrained:function(e){Fo(d.point.is(e,2));const t=this._applyConstraints(e,this.coord());!1!==t&&(this.state.coord=M.default.clone(t),this.draw())},moveTo:function(e){const t=this.state;this.state.outOfBounds=!1;const n=this._applyConstraints(e,t.coord,t.onRemove?{onOutOfBounds:()=>{this.state.outOfBounds=!0}}:{});if(!1!==n&&(d.point.is(n)&&(e=n),!d.point.equal(e,t.coord))){const n=t.coord;t.coord=e,t.hasMoved=!0,this._fireEvent(t.onMove,t.coord,n),this.draw()}},normalStyle:function(){return M.default.clone(this.state.normalStyle)},highlightStyle:function(){return M.default.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()},grab:function(e){this.state.touchOffset=[0,0],this.movable.grab(e),this.moveTo(e)}});const Uo={constrain:function(){this.constrain()},pointsToFront:function(e){M.default.invoke(e.points,"toFront")}};Uo.standard=[Uo.constrain,Uo.pointsToFront];const Go={draw:function(){this.draw()}};Go.standard=[Go.draw];const Vo={basic:function(e,t){const n=this.graphie,o=this.path(e);this.state.visibleShape||(this.state.visibleShape=n.raphael.path(o),this.state.visibleShape.attr(this.normalStyle())),e.normalStyle===t.normalStyle||M.default.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.attr({path:o}),this.mouseTarget()&&this.mouseTarget().attr({path:o})},labels:function(e,t){const n=this.graphie,o=this,s=M.default.invoke(e.points,"coord"),i=Wo(s),r=s.length;null!=o.state._labelCache&&M.default.invoke(o.state._labelCache,"remove"),o.state._labelCache=[],(e.angleLabels.length||e.showRightAngleMarkers.length)&&(null==o.state._labeledAngles&&(o.state._labeledAngles=M.default.times(Math.max(e.angleLabels.length,e.showRightAngleMarkers.length),(function(){return n.label([0,0],"","center",e.labelStyle)}))),M.default.each(o.state._labeledAngles,(function(t,a){o.state._labelCache.push(n.labelAngle({point1:s[(a-1+r)%r],vertex:s[a],point3:s[(a+1)%r],label:t,text:e.angleLabels[a],showRightAngleMarker:e.showRightAngleMarkers[a],numArcs:e.numArcs[a],clockwise:i,style:e.labelStyle}))}))),e.sideLabels.length&&(null==o.state._labeledSides&&(o.state._labeledSides=M.default.map(e.sideLabels,(function(t){return n.label([0,0],"","center",e.labelStyle)}))),M.default.each(o.state._labeledSides,(function(t,a){o.state._labelCache.push(n.labelSide({point1:s[a],point2:s[(a+1)%r],label:t,text:e.sideLabels[a],numArrows:e.numArrows[a],numTicks:e.numTicks[a],clockwise:i,style:e.labelStyle}))}))),e.vertexLabels.length&&(null==o.state._labeledVertices&&(o.state._labeledVertices=M.default.map(e.vertexLabels,(function(t){return n.label([0,0],"","center",e.labelStyle)}))),M.default.each(o.state._labeledVertices,(function(t,a){o.state._labelCache.push(n.labelVertex({point1:s[(a-1+r)%r],vertex:s[a],point3:s[(a+1)%r],label:t,text:e.vertexLabels[a],clockwise:i,style:e.labelStyle}))}))),o.state._labelCache=M.default.flatten(o.state._labelCache)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};Vo.standard=[Vo.basic,Vo.labels,Vo.highlight];const jo={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},labels:function(){const e=[this.state._labeledSides,this.state._labeledVertices,this.state._labeledAngles,this.state._labelCache];M.default.each(e,(function(e){null!=e&&e.length&&M.default.invoke(e,"remove")}))}};jo.standard=[jo.basic,jo.labels];const Yo={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,d.point.roundTo(t,e))}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(o,s){const i=this.graphie,r=d.vector.subtract(o,s);e=e||i.range,void 0===t&&(t=i.snap);let a=i.unscalePoint([n,i.ypixels-n]),l=i.unscalePoint([i.xpixels-n,n]);t&&(a=d.point.ceilTo(a,t),l=d.point.floorTo(l,t));const c=M.default.map(this.coords(),(function(e,t){const n=d.vector.subtract(l,e);return[d.vector.subtract(a,e),n]})),p=M.default.reduce(c,(function(e,t){const n=t[0],o=t[1];return[Math.max(n[0],Math.min(o[0],e[0])),Math.max(n[1],Math.min(o[1],e[1]))]}),r);return d.vector.add(s,p)}},standard:null},$o={updatePoints:function(e,t){const n=d.vector.subtract(e,t);M.default.each(this.state.points,(function(e){e.setCoord(d.vector.add(e.coord(),n))}))},standard:null};var Xo={add:Uo,modify:Go,draw:Vo,remove:jo,onMoveStart:{standard:null},constraints:Yo,onMove:$o,onMoveEnd:{standard:null},onClick:{standard:null}};const Ko=an.assert,Zo=an.normalizeOptions,Jo=M.default.keys(Xo),Qo={points:null,angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],closed:!0,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,labelStyle:null},es={added:!1,hasMoved:!1,visibleShape:null,mouseTarget:null},ts=function(e,t,n){Ko(null!=e),Ko(null!=n),M.default.extend(this,{graphie:e,movable:t,state:{id:M.default.uniqueId("movablePolygon")}}),this.modify(M.default.extend({},es,n))};M.default.extend(ts,Xo),an.createGettersFor(ts,M.default.extend({},Qo,es)),an.addMovableHelperMethodsTo(ts),M.default.extend(ts.prototype,{cloneState:function(){return M.default.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id},Zo(Jo,wn.pluck(Xo,"standard")),Qo)},modify:function(e){this.update(M.default.extend(this._createDefaultState(),e))},update:function(e){const t=this,n=t.graphie,o=M.default.extend(t.state,Zo(Jo,e)),s=o.static?dn.DYNAMIC:dn.INTERACTIVE;o.normalStyle=M.default.extend({},o.normalStyle,{"stroke-width":2,"fill-opacity":0,fill:s,stroke:s},e.normalStyle),o.highlightStyle=M.default.extend({},{stroke:dn.INTERACTING,"stroke-width":2,fill:dn.INTERACTING,"fill-opacity":.05},o.highlightStyle),o.labelStyle=M.default.extend({},{stroke:dn.DYNAMIC,"stroke-width":1,color:dn.DYNAMIC},o.labelStyle),o.static||o.mouseTarget||(o.mouseTarget=n.mouselayer.path(this.path()),o.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"})),t.movable.modify(M.default.extend({},o,{modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){const o=d.vector.subtract(e,n);t._totalDelta=d.vector.add(t._totalDelta,o);let s=d.vector.add(t._initialRefCoord,t._totalDelta);s=t._applyConstraints(s,t._prevRefCoord),!1!==s&&(t._fireEvent(t.state.onMove,s,t._prevRefCoord),t._prevRefCoord=s)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),M.default.invoke(o.points,"listen","onMove",o.id,t.draw.bind(t)),o.added||(t.prevState={},t._fireEvent(o.add,t.cloneState(),t.prevState),o.added=!0,t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},path:function(e){const t=this.graphie;e=e||this.state;let n=M.default.map(e.points,(function(e){return t.scalePoint(e.coord())}));return e.closed?n.push(!0):n=n.concat(M.default.clone(n).reverse()),vn.unscaledSvgPath(n)},coords:function(){return M.default.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.points&&M.default.invoke(this.state.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){if(null==this.points||0===this.points.length)return;const e=this.coord(0),t=this._applyConstraints(e,e);!1!==t&&this._fireEvent(this.state.onMove,t,e)},normalStyle:function(){return M.default.clone(this.state.normalStyle)},highlightStyle:function(){return M.default.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}});const ns=an.normalizeOptions,os=an.assert,ss=["add","modify","draw","remove","onMoveStart","onMove","onMoveEnd","onClick"],is={cursor:null},rs={added:!1,isHovering:!1,isMouseOver:!1,isDragging:!1,mouseTarget:null},as=function(e,t){M.default.extend(this,{graphie:e,state:{id:M.default.uniqueId("movable")}}),this.modify(M.default.extend({},rs,t))};an.createGettersFor(as,M.default.extend({},is,rs)),an.addMovableHelperMethodsTo(as),M.default.extend(as.prototype,{cloneState:function(){return M.default.clone(this.state)},_createDefaultState:function(){return M.default.extend({id:this.state.id,add:[],modify:[],draw:[],remove:[],onMoveStart:[],onMove:[],onMoveEnd:[],onClick:[]},is)},modify:function(e){this.update(M.default.extend({},this._createDefaultState(),e))},grab:function(e){os(d.point.is(e));const t=this,n=t.graphie,o=t.state;o.isHovering=!0,o.isDragging=!0,n.isDragging=!0;const s=e;let i=s;t._fireEvent(o.onMoveStart,s,s);const r=function(e){e.preventDefault();const s=n.getMouseCoord(e);t._fireEvent(o.onMove,s,i),t.draw(),i=s},a=function(e){R.default(document).unbind("vmousemove",r),R.default(document).unbind("vmouseup",a),o.isHovering&&t._fireEvent(o.onClick,i,s),o.isHovering=t.state.isMouseOver,o.isDragging=!1,n.isDragging=!1,t._fireEvent(o.onMoveEnd,i,s),t.draw()};R.default(document).bind("vmousemove",r),R.default(document).bind("vmouseup",a)},update:function(e){const t=this,n=t.graphie,o=t.cloneState(),s=M.default.extend(t.state,ns(ss,e));if(s.mouseTarget&&!o.mouseTarget){let e;e=s.mouseTarget.getMouseTarget?R.default(s.mouseTarget.getMouseTarget()):R.default(s.mouseTarget[0]);!("ontouchstart"in window)&&(e.on("vmouseover",(function(){s.isMouseOver=!0,n.isDragging||(s.isHovering=!0),t.state.added&&t.draw()})),e.on("vmouseout",(function(){s.isMouseOver=!1,s.isDragging||(s.isHovering=!1),t.state.added&&t.draw()}))),e[0].addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),e.on("vmousedown",(function(e){if(0!==e.which&&1!==e.which)return;e.preventDefault();const o=n.getMouseCoord(e);t.grab(o)}))}if(s.mouseTarget&&void 0!==s.cursor){let e;e=s.mouseTarget.getMouseTarget?R.default(s.mouseTarget.getMouseTarget()):R.default(s.mouseTarget[0]),e.css("cursor",s.cursor||"")}s.added||(t._fireEvent(s.modify,t.cloneState(),{}),s.added=!0,t.prevState=t.cloneState()),t._fireEvent(s.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.mouseTarget&&(R.default(this.state.mouseTarget).off(),this.state.mouseTarget.remove(),this.state.mouseTarget=null)},toBack:function(){this.state.mouseTarget&&this.state.mouseTarget.toBack()},toFront:function(){this.state.mouseTarget&&this.state.mouseTarget.toFront()}});const ls={MovablePoint:Ho,addMovablePoint:function(e,t){const n=new as(e,{});return new Ho(e,n,t)},MovableLine:lo,addMovableLine:function(e,t){const n=new as(e,{});return new lo(e,n,t)},MovablePolygon:ts,addMovablePolygon:function(e,t){const n=new as(e,{});return new ts(e,n,t)},addMaybeMobileMovablePoint:function(e,t){const n=e.props.apiOptions.isMobile,o=n?{stroke:"#ffffff","stroke-width":3,fill:dn.INTERACTIVE}:{stroke:dn.INTERACTIVE,fill:dn.INTERACTIVE},s=Object.assign(o,t.normalStyle),i=Object.assign(n?{...o,"stroke-width":0,scale:.75}:{},t.highlightStyle),r=Object.assign({normalStyle:s,highlightStyle:i,shadow:n,tooltip:n&&e.props.showTooltips,showHairlines:e.showHairlines,hideHairlines:e.hideHairlines},n?{pointSize:7}:{});return ls.addMovablePoint(e.graphie,Object.assign(t,r))}},cs=jn.createClass({displayName:"MovablePoint",movableProps:["children"],_getProps:function(){if(this.props.isMobile){const e=this.props.isMobile,t=e?{stroke:"#ffffff","stroke-width":3,fill:dn.INTERACTIVE}:{stroke:dn.INTERACTIVE,fill:dn.INTERACTIVE},n=e?Object.assign(t,this.props.mobileStyleOverride||{}):Object.assign(t,this.props.normalStyle),o=e?{...t,"stroke-width":0,scale:.75}:this.props.highlightStyle,s=Object.assign({normalStyle:n,highlightStyle:o,shadow:e,tooltip:e&&this.props.showTooltips},e?{pointSize:7}:{});return Object.assign(this.props,s)}return this.props},add:function(e){this.point=ls.addMovablePoint(e,this._getProps())},modify:function(){this.point.modify(this._getProps())},remove:function(){this.point.remove()},toFront:function(){this.point.toFront()},grab:function(e){this.point.grab(e)}});M.default.extend(cs,ls.MovablePoint);const ps=jn.createClass({displayName:"MovableLine",movableProps:["children"],add:function(e){const t=M.default.pluck(this.props.children,"point"),n=M.default.extend({},this.props,{points:t});this.line=ls.addMovableLine(e,n)},modify:function(){const e=M.default.pluck(this.props.children,"point"),t=M.default.extend({},this.props,{points:e});this.line.modify(t)},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}});M.default.extend(ps,ls.MovableLine);const ds=jn.createSimpleClass(((e,t)=>{let n=t.coord;t.unscaled&&(n=e.unscalePoint(n));let o=null;return ne().JIPT.useJIPT?(o=e.label(n,t.text,t.direction,!1,t.style),ne().graphieMovablesJiptLabels.addLabel(o,t.tex)):o=e.label(n,t.text,t.direction,t.tex,t.style),o})),us=jn.createClass({displayName:"Line",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.line=this.graphie.line(t.start,t.end,t.style)},modify:function(){const e=this.props,t=this.graphie.svgPath([e.start,e.end]);this.line.attr(M.default.extend({},e.style,{path:t}))},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}}),hs=jn.createClass({displayName:"Parabola",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.parabola=this.graphie.parabola(t.a,t.b,t.c,t.style)},modify:function(){const e=this.props,t=this.graphie.svgParabolaPath(e.a,e.b,e.c);this.parabola.attr(M.default.extend({},e.style,{path:t}))},remove:function(){this.parabola.remove()},toFront:function(){this.parabola.toFront()}}),fs=jn.createClass({displayName:"Sinusoid",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.sinusoid=this.graphie.sinusoid(t.a,t.b,t.c,t.d,t.style)},modify:function(){const e=this.props,t=this.graphie.svgSinusoidPath(e.a,e.b,e.c,e.d);this.sinusoid.attr(M.default.extend({},e.style,{path:t}))},remove:function(){this.sinusoid.remove()},toFront:function(){this.sinusoid.toFront()}}),ms=jn.createSimpleClass(((e,t)=>e.plot(t.fn,t.range,t.style))),gs=jn.createSimpleClass(((e,t)=>e.plotParametric(t.fn,t.range,t.style))),vs=jn.createSimpleClass(((e,t)=>e.ellipse(t.coord,e.unscaleVector([4,4]),{fill:t.color||dn.BLACK,stroke:t.color||dn.BLACK}))),ys=jn.createClass({displayName:"Path",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.path=this.graphie.path(t.coords,t.style)},modify:function(){const e=this.props,t=this.graphie.svgPath(e.coords);this.path.attr({path:t})},remove:function(){this.path.remove()},toFront:function(){this.path.toFront()}});var bs={Arc:jn.createSimpleClass(((e,t)=>{let n=t.center,o=t.radius;return t.unscaled&&(n=e.unscalePoint(n),o=e.unscaleVector(o)),e.arc(n,o,t.startAngle,t.endAngle,t.sector,t.style)})),Circle:jn.createSimpleClass(((e,t)=>e.circle(t.center,t.radius,t.style))),Label:ds,Line:us,MovableLine:ps,MovablePoint:cs,Parabola:hs,Path:ys,Plot:ms,PlotParametric:gs,Point:vs,Sinusoid:fs,Rect:jn.createSimpleClass(((e,t)=>e.rect(t.x,t.y,t.width,t.height,t.style)))};const xs=jn.GraphieMovable,ws=vn.createGraphie,{deepEq:Cs,nestedMap:ks}=Ae,{assert:Ss}=an;class Es extends _.Component{constructor(){super(...arguments),W(this,"getGraphie",(()=>this._graphie)),W(this,"_range",(()=>M.default.map(this.props.range,(e=>e[0]>=e[1]?[-10,10]:e)))),W(this,"_box",(()=>M.default.map(this.props.box,(e=>e>0?e:340)))),W(this,"_scale",(()=>{const e=this._box(),t=this._range();return M.default.map(e,((e,n)=>e/(t[n][1]-t[n][0])))})),W(this,"_setupGraphie",(()=>{this._removeMovables();const e=N.default.findDOMNode(this.refs.graphieDiv);R.default(e).empty();const t=this._graphie=ws(e);t.init({range:this._range(),scale:this._scale(),isMobile:this.props.isMobile}),this.props.addMouseLayer&&t.addMouseLayer({onClick:this.props.onClick,onMouseDown:this.props.onMouseDown,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),t.snap=this.props.options.snapStep||[1,1],this.props.responsive&&(R.default(e).css({width:"100%",height:"100%"}),t.raphael.setSize("100%","100%")),this.props.setup(t,M.default.extend({range:this._range(),scale:this._scale()},this.props.options))})),W(this,"_removeMovables",(()=>{M.default.invoke(this._movables,"remove"),this._movables={}})),W(this,"_renderMovables",((e,t)=>{const n=t.graphie,o=t.oldMovables,s=t.newMovables,i=e=>{M.default.each(e.movableProps,(n=>{e.props[n]=this._renderMovables(e.props[n],t)}))};let r=!1;return ks(e,(e=>{if(!e)return t.nextKey++,e;const a=new e.type(e.props);Ss(a instanceof xs,"All children of a Graphie component must be Graphie movables");const l=e.key,c=null==l?"_no_id_"+t.nextKey:l;t.nextKey++;const p=e.ref;i(a);const d=o[c];if(d)if(a.constructor===d.constructor){d.props=a.props;"reordered"===d.modify(n)&&(r=!0),s[c]=d}else null==l&&ie.error("Replacing a <Graphie> child with a child of a different type. Please add keys to your <Graphie> children",se.Internal),d.remove(),a.add(n),r=!0,s[c]=a;else a.add(n),r=!0,s[c]=a;return r&&s[c].toFront(),p&&(this.movables[p]=s[c]),s[c]}))})),W(this,"_updateMovables",(()=>{const e=this._graphie,t=this._movables,n={};this._movables=n,this.movables={},this._renderMovables(this.props.children,{nextKey:1,graphie:e,oldMovables:t,newMovables:n}),M.default.each(t,((e,t)=>{n[t]||e.remove()}))}))}componentDidMount(){this._setupGraphie(),this._updateMovables()}shouldComponentUpdate(e){return!M.default.isEqual(this.props,e)}componentDidUpdate(e){this.props.setup!==e.setup&&ie.error("<Graphie> was given a new setup function. This is a bad idea; please refactor your code to give the same setup function reference to <Graphie> on every render.",se.Internal),Cs(this.props.options,e.options)&&Cs(this.props.box,e.box)&&Cs(this.props.range,e.range)||this._setupGraphie(),this._updateMovables()}render(){return _.createElement("div",{className:"graphie-container"},_.createElement("div",{className:"graphie",ref:"graphieDiv"}))}}W(Es,"propTypes",{addMouseLayer:I.default.bool,box:I.default.arrayOf(I.default.number).isRequired,children:I.default.node,isMobile:I.default.bool,onClick:I.default.func,onMouseDown:I.default.func,onMouseMove:I.default.func,onMouseUp:I.default.func,options:I.default.shape({snapStep:I.default.arrayOf(I.default.number)}),range:I.default.arrayOf(I.default.arrayOf(I.default.number)),responsive:I.default.bool,setDrawingAreaAvailable:I.default.func,setup:I.default.func.isRequired}),W(Es,"defaultProps",{range:[[-10,10],[-10,10]],options:{},responsive:!1,addMouseLayer:!0}),M.default.extend(Es,jn),M.default.extend(Es,bs);const _s="pending",Ts="loading",Ms="loaded",Is="failed";class Ps extends _.Component{constructor(e){super(e),W(this,"img",void 0),W(this,"createLoader",(()=>{this.destroyLoader(),this.img=new Image,this.img.onload=this.handleLoad,this.img.onerror=this.handleError,this.img.src=this.props.src})),W(this,"destroyLoader",(()=>{this.img&&(this.img.onload=null,this.img.onerror=null,this.img=null)})),W(this,"handleLoad",(e=>{this.destroyLoader(),this.setState({status:Ms}),this.props.onLoad&&this.props.onLoad(e)})),W(this,"handleError",(e=>{this.destroyLoader(),this.setState({status:Is}),this.props.onError&&this.props.onError(e)})),W(this,"renderImg",(()=>{const{src:e,imgProps:t}=this.props;let n=null,o=null;null!=t.onClick&&(n=e=>{13!==e.keyCode&&32!==e.keyCode||t.onClick&&t.onClick(e)},o=e=>{32===e.keyCode&&e.preventDefault()});const s=ne().staticUrl;return _.createElement("img",U({src:s(e),onKeyUp:n,onKeyDown:o},t))})),this.state={status:e.src?Ts:_s}}componentDidMount(){this.state.status===Ts&&this.createLoader()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({status:e.src?Ts:_s})}componentDidUpdate(e,t){this.state.status!==Ts||this.img||this.createLoader(),t.status!==this.state.status&&this.props.onUpdate(this.state.status)}componentWillUnmount(){this.destroyLoader()}render(){switch(this.state.status){case Ms:return this.renderImg();case Is:if(this.props.children)return this.props.children;break;default:if(this.props.preloader)return this.props.preloader()}return null}}const Ns={},As=/^file\+graphie\:/,Rs=/\/([^/]+)$/;function Fs(e){return/\.(jpg|jpeg)$/i.test(e)}function Os(){const{JIPT:e,kaLocale:t}=ne();return e.useJIPT?"en-pt":t}function Ds(){return"en"!==Os()}const Ls=/\/(?=[^/]+$)/;function Bs(e){return _.createElement("span",{style:{background:"url(/images/spinner.gif) no-repeat",backgroundPosition:"center",width:"100%",height:"100%",position:"absolute",minWidth:"20px"}})}class zs extends _.Component{constructor(e){super(e),W(this,"_isMounted",void 0),W(this,"onDataLoaded",((e,t)=>{if(this._isMounted&&e.labels&&e.range){const n=e.labels.reduce(((e,t)=>({...e,[t.content]:!1})),{});this.setState({dataLoaded:!0,labelDataIsLocalized:t,labelsRendered:n,labels:e.labels,range:e.range})}})),W(this,"onImageLoad",(()=>{this.sizeProvided()?this.setState({imageLoaded:!0}):Ae.getImageSize(this.props.src,((e,t)=>{this._isMounted&&this.setState({imageLoaded:!0,imageDimensions:[e,t]})}))})),W(this,"setupGraphie",((e,t)=>{M.default.map(t.labels,(t=>{const{JIPT:n}=ne();if(n.useJIPT&&this.state.labelDataIsLocalized){const n=e.label(t.coordinates,t.content,t.alignment,!1);ne().svgImageJiptLabels.addLabel(n,t.typesetAsMath)}else if(t.coordinates){const n=e.label(t.coordinates,t.content,t.alignment,t.typesetAsMath,{"font-size":100*this.props.scale+"%"}),o=n[0].style;let s=this._tryGetPixels(o.top),i=this._tryGetPixels(o.left);if(null===s||null===i){const e=n.position();s=e.top,i=e.left}const r=(this.props.height||0)*this.props.scale,a=(this.props.width||0)*this.props.scale;n.css({top:s/r*100+"%",left:i/a*100+"%"}),M.default.each(t.style,((e,t)=>{n.css(t,e)}))}this.setState({labelsRendered:{...this.state.labelsRendered,[t.content]:!0}})}))})),W(this,"_handleZoomClick",(e=>{(R.default(e.target).width()<this.props.width||this.props.zoomToFullSizeOnMobile)&&en.handleZoomClick(e,this.props.zoomToFullSizeOnMobile),this.props.trackInteraction&&this.props.trackInteraction()})),W(this,"handleUpdate",(e=>{this.props.onUpdate(),Ae.isLabeledSVG(this.props.src)||"loaded"!==e||this.setState({imageLoaded:!0})})),e.setAssetStatus(e.src,!1),this._isMounted=!1,this.state={imageLoaded:!1,imageDimensions:null,dataLoaded:!1,labelDataIsLocalized:!1,labels:[],labelsRendered:{},range:[[0,0],[0,0]]}}componentDidMount(){this._isMounted=!0,Ae.isLabeledSVG(this.props.src)&&this.loadResources()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({imageLoaded:!1,dataLoaded:!1})}shouldComponentUpdate(e,t){if(!M.default.isEqual(this.props,e))return!0;return this.isLoadedInState(this.state)!==this.isLoadedInState(t)}componentDidUpdate(e,t){const n=this.isLoadedInState(t),o=this.isLoadedInState(this.state);Ae.isLabeledSVG(this.props.src)&&!o&&this.loadResources(),!n&&o&&this.props.setAssetStatus(this.props.src,!0)}componentWillUnmount(){this._isMounted=!1}isLoadedInState(e){return Ae.isLabeledSVG(this.props.src)?e.imageLoaded&&e.dataLoaded:e.imageLoaded}loadResources(){const e=function(e){const t=e.match(Rs);if(null==t)throw new re("not a valid URL",se.InvalidInput);return t&&t[1]}(this.props.src);if(Ns[e])if(Ns[e].loaded){const{data:t,localized:n}=Ns[e];this.onDataLoaded(t,n)}else Ns[e].dataCallbacks.push(this.onDataLoaded);else{const t={loaded:!1,dataCallbacks:[this.onDataLoaded],data:null,localized:Ds()};Ns[e]=t;const n=(n,o)=>{!function(e,t){t={callbackName:"callback",success:R.default.noop,error:R.default.noop,...t};const n=document.createElement("script");function o(){document.head&&document.head.removeChild(n),delete window[t.callbackName]}n.setAttribute("async",""),n.setAttribute("src",e),window[t.callbackName]=function(){o(),t.success.apply(null,arguments)},n.addEventListener("error",(function(){o(),t.error.apply(null,arguments)})),document.head&&document.head.appendChild(n)}(n,{callbackName:"svgData"+e,success:e=>{t.data=e,t.loaded=!0,M.default.each(t.dataCallbacks,(e=>{e(t.data,t.localized)}))},error:o})};Ds()?n(function(e){if(As.test(e))return Ae.getDataUrl(e);const[t,n]=Ae.getBaseUrl(e).split(Ls);return"".concat(t,"/").concat(Os(),"/").concat(n,"-data.json")}(this.props.src),((e,o,s)=>{t.localized=!1,n(Ae.getDataUrl(this.props.src),((e,t,n)=>{ie.error("Data load failed for svg-image",se.Service,{cause:n,loggedMetadata:{dataUrl:Ae.getDataUrl(this.props.src),status:t}})}))})):n(Ae.getDataUrl(this.props.src),((e,t,n)=>{ie.error("Data load failed for svg-image",se.Service,{cause:n,loggedMetadata:{dataUrl:Ae.getDataUrl(this.props.src),status:t}})}))}}sizeProvided(){return null!=this.props.width&&null!=this.props.height}_tryGetPixels(e){return(e=e||"").endsWith("px")&&parseFloat(e)||null}render(){const e=this.props.src,t={alt:this.props.alt,title:this.props.title,tabIndex:"0"};this.props.alt&&this.props.overrideAriaHidden&&(t["aria-hidden"]=!0);const n=this.props.width&&this.props.width*this.props.scale,o=this.props.height&&this.props.height*this.props.scale,s={width:n,height:o},i=this.props.responsive&&!(!n||!o);let r;this.props.extraGraphie&&this.props.extraGraphie.labels.length&&(r=_.createElement(Es,{box:this.props.extraGraphie.box,range:this.props.extraGraphie.range,options:{labels:this.props.extraGraphie.labels},responsive:!0,addMouseLayer:!1,setup:this.setupGraphie}));const a=void 0===this.props.preloader?Bs:this.props.preloader,l=a?()=>a(s):null;if(!Ae.isLabeledSVG(e)){if(i){const s=E.default({zoomable:(n||0)>700,"svg-image":!0});return t.onClick=this._handleZoomClick,_.createElement(tn,{className:s,width:n,height:o,constrainHeight:this.props.constrainHeight,allowFullBleed:this.props.allowFullBleed&&Fs(e)},_.createElement(Ps,{src:e,imgProps:t,preloader:l,onUpdate:this.handleUpdate}),r)}return t.style=s,_.createElement(Ps,{src:e,preloader:l,imgProps:t,onUpdate:this.handleUpdate})}const c=Ae.getSvgUrl(e);let p;if(this.isLoadedInState(this.state)){let e;if(this.sizeProvided())e=[n,o];else{if(!this.state.imageDimensions)throw new re("svg-image has no dimensions",se.InvalidInput,{metadata:{src:this.props.src}});e=[this.state.imageDimensions[0]*this.props.scale,this.state.imageDimensions[1]*this.props.scale]}const t=[40*this.props.scale,40*this.props.scale];p=_.createElement(Es,{ref:"graphie",box:e,scale:t,range:this.state.range,options:M.default.pick(this.state,"labels"),responsive:i,addMouseLayer:!1,setup:this.setupGraphie})}return i?_.createElement(tn,{className:"svg-image",width:n,height:o,constrainHeight:this.props.constrainHeight},_.createElement(Ps,{src:c,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:l,imgProps:t}),p,r):(t.style=s,_.createElement("div",{className:"unresponsive-svg-image",style:s},_.createElement(Ps,{src:c,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:l,imgProps:t}),p))}}W(zs,"defaultProps",{constrainHeight:!1,onUpdate:()=>{},responsive:!0,src:"",scale:1,zoomToFullSizeOnMobile:!1,setAssetStatus:(e,t)=>{}});class qs extends _.Component{constructor(e){super(e),W(this,"_hasRendered",void 0),W(this,"handleRender",(()=>{this.props.onRender(),this.setState({rendered:!0}),this.props.onRender(),this._hasRendered||(this._hasRendered=!0,this.props.setAssetStatus(this.props.children,!0))})),this.props.setAssetStatus(this.props.children,!1),this.state={rendered:!1},this._hasRendered=!1}render(){const{TeX:e}=ne();return _.createElement(e,{onRender:this.handleRender},this.props.children)}}W(qs,"defaultProps",{onRender:()=>{},setAssetStatus:(e,t)=>{}});class Hs extends _.Component{constructor(){super(...arguments),W(this,"_isMounted",void 0),W(this,"_observer",void 0),W(this,"_measuringInitialized",void 0),W(this,"_originalWidth",void 0),W(this,"_node",void 0),W(this,"state",{visible:!1,marginBottomPx:0,zoomed:!0}),W(this,"reset",(()=>{this._isMounted&&this.state.visible&&(this._originalWidth=null,this.setState({visible:!1,compactHeight:null,expandedHeight:null,zoomed:!0},(()=>{this.measureAndScaleChildToFit(!1)})))})),W(this,"stopPropagationIfZoomed",(e=>{this.state.zoomed||e.stopPropagation()})),W(this,"handleClickIfZoomed",(e=>{this.state.zoomed||(e.stopPropagation(),this.handleClick())})),W(this,"handleClick",(()=>{this.setState({zoomed:!this.state.zoomed})}))}componentDidMount(){this._isMounted=!0,this.maybeInitializeMeasuring()}componentDidUpdate(){this.maybeInitializeMeasuring()}componentWillUnmount(){window.removeEventListener("resize",this.reset),this._observer&&this._observer.disconnect(),this._isMounted=!1}maybeInitializeMeasuring(){const e=this.props.readyToMeasure&&!this._measuringInitialized;this._isMounted&&e&&(this._measuringInitialized=!0,this._node=N.default.findDOMNode(this),setTimeout((()=>this.measureAndScaleChildToFit(!1)),0),window.MutationObserver&&(this._observer=new MutationObserver((e=>{if(this._isMounted)for(const t of e)if(t.target!==this._node){this.measureAndScaleChildToFit(this.state.zoomed);break}})),this._observer.observe(this._node,{childList:!0,subtree:!0,attributes:!0})),window.addEventListener("resize",this.reset))}measureAndScaleChildToFit(e){if(!this._isMounted)return;const t={width:this._node.offsetWidth,height:this._node.offsetHeight},n=this.props.computeChildBounds(this._node,t),o=n.width+1,s=n.height+1;if(o>t.width){const n=t.width/o;this.setState({scale:n,zoomed:e,compactHeight:Math.ceil(n*s),expandedHeight:s}),setTimeout((()=>{this._isMounted&&this.setState({visible:!0})}))}else this.setState({visible:!0})}render(){const{visible:e,scale:t,compactHeight:n,expandedHeight:o,zoomed:s}=this.state,{animateHeight:i}=this.props,r=i?"opacity transform height":"opacity transform",a=e?{transitionProperty:r,WebkitTransitionProperty:r,msTransitionProperty:r,transitionDuration:"0.3s",WebkitTransitionDuration:"0.3s",msTransitionDuration:"0.3s",transitionTimingFunction:"ease-out",WebkitTransitionTimingfunction:"ease-out",msTransitionTmingFunction:"ease-out"}:{},l=e?"":" translate(0, 8px)",c=(null!=t?t:1).toString(),p=s?"scale(1, 1) ".concat(l):"scale(".concat(c,", ").concat(c,") ").concat(l),d={display:"block",width:"100%",height:s?o:n,transform:p,WebkitTransform:p,msTransform:p,transformOrigin:"0 0",WebkitTransformOrigin:"0 0",msTransformOrigin:"0 0",opacity:e?1:0,WebkitTapHighlightColor:"transparent",...a};return _.createElement("span",{onClick:this.handleClick,onClickCapture:this.handleClickIfZoomed,onTouchCancelCapture:this.stopPropagationIfZoomed,onTouchEndCapture:this.stopPropagationIfZoomed,onTouchStartCapture:this.stopPropagationIfZoomed,style:d},this.props.children)}}W(Hs,"defaultProps",{animateHeight:!1,readyToMeasure:!0,computeChildBounds:e=>{const t=e.firstElementChild;return{width:t.offsetWidth,height:t.offsetHeight}}});const Ws=(e,t)=>{const n=e.querySelector(".katex-html")||e.querySelector(".MathJax"),o={width:n.offsetWidth,height:n.offsetHeight};return{width:Math.max(t.width,o.width),height:Math.max(t.height,o.height)}};class Us extends _.Component{constructor(){super(),W(this,"handleRender",(()=>{this.setState({isRendered:!0})})),this.state={isRendered:!1}}render(){return _.createElement(Hs,{readyToMeasure:this.state.isRendered,computeChildBounds:Ws},_.createElement(Kt.Consumer,null,(e=>{let{setAssetStatus:t}=e;return _.createElement(qs,{onRender:this.handleRender,setAssetStatus:t},this.props.children)})))}}class Gs extends _.Component{constructor(e){super(e),this.state={error:""}}componentDidCatch(e,t){this.setState({error:e.toString()}),ie.error("Perseus error boundary caught error",se.Internal,{cause:e,loggedMetadata:{info:t.toString()}})}render(){return this.state.error?_.createElement("svg",{height:"16",width:"16",viewBox:"0 0 16 16"},_.createElement("path",{d:"m8 16c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-3c0.55 0 1-0.45 1-1s-0.45-1-1-1-1 0.45-1 1 0.45 1 1 1zm0-9c-0.55 0-1 0.45-1 1v4c0 0.55.45 1 1 1s1-0.45 1-1v-4c0-0.55-0.45-1-1-1z",fill:"#d92916",fillRule:"evenodd"})):this.props.children}}function Vs(){}class js{constructor(e,t,n,o){W(this,"_tracked",void 0),W(this,"setting",void 0),W(this,"track",void 0),W(this,"trackApi",void 0),W(this,"widgetID",void 0),W(this,"widgetType",void 0),W(this,"_track",(e=>{this._tracked&&!this.setting||(this._tracked=!0,this.trackApi({type:this.widgetType,id:this.widgetID,...e}))})),e?(this._tracked=!1,this.trackApi=e,this.widgetType=t,this.widgetID=n,this.setting=o,this.track=this._track):this.track=Vs}}const Ys={fence:{match:P.default.defaultRules.fence.match,order:1,parse:(e,t,n)=>e[3]},paragraph:{match:P.default.defaultRules.paragraph.match,order:2,parse:(e,t,n)=>e[1]}},$s=P.default.parserFor(Ys);var Xs={parseToArray:e=>{const t=e.replace(/^\n\s*\n/,"")+"\n\n";return $s(t,{inline:!1})},joinFromArray:e=>e.join("\n\n")};class Ks{constructor(){W(this,"previousContent",null),W(this,"runLinter",i.debounce(((e,t)=>{"undefined"!=typeof KA&&e!==this.previousContent&&(this.previousContent=e,""!==e?fetch("/api/internal/translations/lint_poentry?preview=1&lang=en",{headers:{"Content-Type":"application/json"},body:JSON.stringify({msgid:e,msgstr:e,format:"perseus_text",filename:""}),method:"POST"}).then((e=>e.status>=400?{status:"error",message:"Could not run i18n linter."}:e.json()),(e=>({status:"error",message:"Could not run i18n linter."}))).then((e=>{"error"===e.status?t(["Some part of this text makes it untranslatable. The specific message from the i18n linter was: "+e.message.replace(/\n/g," ")]):t([])})):t([]))}),1e3))}applyLintErrors(e,t){if(t.length){const n=t.join("\n\n");e.unshift({content:{type:"text",content:""},insideTable:!1,message:n,ruleName:"legacy-error",severity:nt.Severity.ERROR,type:"lint"})}}}class Zs extends _.Component{render(){const e=this.props.className?"paragraph "+this.props.className:"paragraph";return _.createElement("div",{className:e,"data-perseus-component-index":this.props.translationIndex,"data-perseus-paragraph-index":this.props.paragraphIndex},this.props.children)}}var Js=e=>e.replace(/\{align[*]?\}/g,"{aligned}").replace(/[\u00a0]/g," ");const{interactiveSizes:Qs}=Z,ei={SMALL:"small",MEDIUM:"medium",LARGE:"large",XLARGE:"xlarge"},ti=e=>e?e<=512?ei.SMALL:e<=688?ei.MEDIUM:ei.LARGE:ei.MEDIUM,ni=e=>e===ei.SMALL?[Qs.defaultBoxSizeSmall,Qs.defaultBoxSizeSmall]:[Qs.defaultBoxSize,Qs.defaultBoxSize];var oi=Object.freeze({__proto__:null,containerSizeClass:ei,getClassFromWidth:ti,getInteractiveBoxFromSizeClass:ni});const si=["default"],ri={},ai={},li=(e,t)=>{ri[e]=t},ci=e=>{e.forEach((e=>{li(e.name,e)})),xi()},pi=e=>M.default.has(ri,e)?ri[e].getWidget?ri[e].getWidget():ri[e].widget:null,di=e=>ri[e]?ri[e].version||{major:0,minor:0}:null,ui=()=>{const e={};return M.default.each(M.default.keys(ri),(function(t){e[t]=di(t)})),e},hi=e=>{const t=ri[e.type].accessible;return"function"==typeof t?t(e.options):!!t},fi=e=>{const t=e.type;if(!M.default.isString(t))throw new re("widget type must be a string, but was: "+t,se.Internal);const n=ri[t];if(null==n)return e;const o=e.version||{major:0,minor:0},s=n.version||{major:0,minor:0};if(o.major>s.major||o.major===s.major&&o.minor>s.minor)return e;let i=M.default.clone(e.options)||{};const r=n.propUpgrades||{};if(0!==M.default.keys(i).length)for(let e=o.major+1;e<=s.major;e++)r[String(e)]?i=r[String(e)](i):ie.error("No upgrade found for widget. Cannot render.",se.Internal,{loggedMetadata:{type:t,fromMajorVersion:e-1,toMajorVersion:e}});i={...t in ai?ai[t].defaultProps:{},...i};let a=e.alignment;null!=a&&"default"!==a||(a=vi(t)[0]);let l=e.static;return null==l&&(l=false),M.default.extend({},e,{version:s,graded:null==e.graded||e.graded,alignment:a,static:l,options:i})},mi=(e,t)=>{const n=e.type,o=ri[n];if(null==o)return e.options;let s;return s=e.static?wi(n)||M.default.identity:o.transform||M.default.identity,s(e.options,t)},gi=(e,t)=>{if(!t)throw new re("traverseRenderer must be provided, but was not",se.Internal);if(!e||!e.type||!ri[e.type])return e;const n=ri[e.type],o=e.options;if(n.traverseChildWidgets&&o){const s=n.traverseChildWidgets(o,t);return M.default.extend({},e,{options:s})}return e},vi=e=>{const t=ri[e];return t&&t.supportedAlignments||si},yi=e=>{const t=ri[e];let n;return t?(n=t.getDefaultAlignment?t.getDefaultAlignment():t.defaultAlignment,n||"block"):"block"},bi=["block","inline-block","inline","float-left","float-right","full-width"],xi=()=>{M.default.each(ri,(function(e){if(e.defaultAlignment&&!M.default.contains(bi,e.defaultAlignment))throw new re("Widget '"+e.displayName+"' has an invalid defaultAlignment value: "+e.defaultAlignment,se.InvalidInput);if(e.supportedAlignments){const t=M.default.difference(e.supportedAlignments,bi);if(t.length)throw new re("Widget '"+e.displayName+"' has an invalid value for supportedAlignments: "+t.join(" "),se.InvalidInput)}}))},wi=e=>{const t=ri[e];return t&&t.staticTransform},Ci=e=>{const t=ri[e];return t&&t.tracking||""},ki=e=>{const t=ri[e];return t&&t.isLintable||false};var Si=Object.freeze({__proto__:null,registerWidget:li,registerWidgets:ci,registerEditors:e=>{e.forEach((e=>{if(!e.widgetName)throw new re("Editor ".concat(e.displayName," doesn't have a widgetName property"),se.Internal);ai[e.widgetName]=e}))},getWidget:pi,getEditor:e=>M.default.has(ai,e)?ai[e]:null,getTransform:e=>M.default.has(ri,e)?ri[e].transform||M.default.identity:null,getVersion:di,getVersionVector:ui,getPublicWidgets:()=>M.default.pick(ri,M.default.reject(M.default.keys(ri),(function(e){return ri[e].hidden}))),isAccessible:hi,getAllWidgetTypes:()=>M.default.keys(ri),upgradeWidgetInfoToLatestVersion:fi,getRendererPropsForWidgetInfo:mi,traverseChildWidgets:gi,getSupportedAlignments:vi,getDefaultAlignment:yi,validateAlignments:xi,supportsStaticMode:e=>{const t=ri[e];return t&&null!=t.staticTransform},getStaticTransform:wi,getTracking:Ci,isLintable:ki});class Ei extends _.Component{constructor(){super(...arguments),W(this,"state",{sizeClass:ei.MEDIUM,widgetProps:this.props.initialProps}),W(this,"getWidget",(()=>this.refs.widget)),W(this,"replaceWidgetProps",(e=>{this.setState({widgetProps:e})}))}componentDidMount(){if(this.state.widgetProps.apiOptions.isMobile){const e=N.default.findDOMNode(this).offsetWidth;this.setState({sizeClass:ti(e)})}}render(){let e=E.default({"perseus-widget-container":!0,"widget-highlight":this.props.shouldHighlight,"widget-nohighlight":!this.props.shouldHighlight});const t=this.props.type,n=pi(t);if(null==n)return console.warn("Widget type '".concat(t,"' not found!")),_.createElement("div",{className:e});let o=this.state.widgetProps.alignment;"default"===o&&(o=yi(t)),e+=" widget-"+o;const s=this.state.widgetProps.apiOptions,i=this.state.widgetProps.static||s.readOnly,r={width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:3},a=ki(t)?this.props.linterContext:{...this.props.linterContext,highlightLint:!1};return _.createElement("div",{className:e,style:i?{position:"relative",overflow:"visible"}:{}},_.createElement(n,U({},this.state.widgetProps,{linterContext:a,containerSizeClass:this.state.sizeClass,ref:"widget"})),i&&_.createElement("div",{style:r}))}UNSAFE_componentWillReceiveProps(e){if(this.props.type!==e.type)throw new Error("WidgetContainer can't change widget type; set a different key instead to recreate the container.")}shouldComponentUpdate(e,t){return this.props.shouldHighlight!==e.shouldHighlight||this.props.type!==e.type||this.state.widgetProps!==t.widgetProps||this.state.sizeClass!==t.sizeClass}}W(Ei,"defaultProps",{linterContext:Ht});const{mapObject:_i,mapObjectFromArray:Ti}=wn,Mi=/\S/,Ii=/(web\+graphie|https):\/\/[^\s]*/,Pi=()=>{},Ni=["content","problemNum","widgets"];class Ai extends _.Component{constructor(e,t){var n;super(e,t),n=this,W(this,"_currentFocus",void 0),W(this,"_foundTextNodes",void 0),W(this,"_interactionTrackers",void 0),W(this,"_isMounted",void 0),W(this,"_isTwoColumn",void 0),W(this,"_notGorgon",void 0),W(this,"lastRenderedMarkdown",void 0),W(this,"reuseMarkdown",void 0),W(this,"translationIndex",void 0),W(this,"widgetIds",void 0),W(this,"getApiOptions",(()=>({...Yt.defaults,...this.props.apiOptions}))),W(this,"_getInitialWidgetState",(e=>{const t=this._getAllWidgetsInfo(e);return{widgetInfo:t,widgetProps:this._getAllWidgetsStartProps(t,e)}})),W(this,"_getAllWidgetsInfo",(e=>_i(e.widgets,((e,t)=>{if(!e.type||!e.alignment){const n={};e.type||(n.type=t.split(" ")[0]),e.alignment||(n.alignment="default"),e=M.default.extend({},e,n)}return fi(e)})))),W(this,"_getAllWidgetsStartProps",((e,t)=>_i(e,(e=>mi(e,t.problemNum))))),W(this,"_getDefaultWidgetInfo",(e=>{const t=Ae.rTypeFromWidgetId.exec(e);return null==t?{}:{type:t[1],graded:!0,options:{}}})),W(this,"_getWidgetInfo",(e=>this.state.widgetInfo[e]||this._getDefaultWidgetInfo(e))),W(this,"renderWidget",((e,t,n)=>{const o=this.state.widgetInfo[t];if(o&&"full-width"===o.alignment&&(n.foundFullWidth=!0),o){const n=o&&o.type||e,s=M.default.contains(this.props.highlightedWidgets,t);return _.createElement(Gs,{key:"container:"+t},_.createElement(Ei,{ref:"container:"+t,type:n,initialProps:this.getWidgetProps(t),shouldHighlight:s,linterContext:zt.pushContextStack(this.props.linterContext,"widget")}))}return null})),W(this,"getWidgetProps",(e=>{const t=this.getApiOptions(),o=this.state.widgetProps[e]||{};let s=null;const i=this.state.widgetInfo[e];this.props.reviewMode&&i&&(s=i.options),this._interactionTrackers||(this._interactionTrackers={});let r=this._interactionTrackers[e];return r||(r=this._interactionTrackers[e]=new js(t.trackInteraction,i&&i.type,e,Ci(i&&i.type))),{...o,ref:e,widgetId:e,alignment:i&&i.alignment,static:i&&i.static&&!this.props.problemNum,problemNum:this.props.problemNum,apiOptions:this.getApiOptions(),keypadElement:this.props.keypadElement,questionCompleted:this.props.questionCompleted,onFocus:M.default.partial(this._onWidgetFocus,e),onBlur:M.default.partial(this._onWidgetBlur,e),findWidgets:this.findWidgets,reviewModeRubric:s,onChange:function(t,o){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];n._setWidgetProps(e,t,o,s)},trackInteraction:r.track,isLastUsedWidget:e===this.state.lastUsedWidgetId}})),W(this,"getSerializedState",(e=>_i(e||this.state.widgetProps,((e,t)=>{const n=this.getWidgetInstance(t);return n&&n.getSerializedState?n.getSerializedState():e})))),W(this,"restoreSerializedState",((e,t)=>{const n=M.default.keys(e),o=M.default.keys(this.state.widgetProps);if(n.length!==o.length||M.default.intersection(n,o).length!==n.length)return void ie.error("Refusing to restore bad serialized state:",se.Internal,{loggedMetadata:{serializedState:JSON.stringify(e),currentProps:JSON.stringify(this.state.widgetProps)}});let s=1;const i=()=>{--s,t&&0===s&&t()};this.setState({widgetProps:_i(e,((e,t)=>{const n=this.getWidgetInstance(t);if(n&&n.restoreSerializedState){++s;const o=n.restoreSerializedState(e,i);return M.default.extend({},this.state.widgetProps[t],o)}return e}))},(()=>{setTimeout(i,0)}))})),W(this,"showRationalesForCurrentlySelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{const t=this.getWidgetInstance(e);t&&t.showRationalesForCurrentlySelectedChoices&&t.showRationalesForCurrentlySelectedChoices(this._getWidgetInfo(e).options)}))})),W(this,"deselectIncorrectSelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{const t=this.getWidgetInstance(e);t&&t.deselectIncorrectSelectedChoices&&t.deselectIncorrectSelectedChoices()}))})),W(this,"findInternalWidgets",(e=>{let t;if("string"==typeof e)if(-1!==e.indexOf(" ")){const n=e;t=(e,t,o)=>e===n}else{const n=e;t=(e,t,o)=>t.type===n}else t=e;return this.widgetIds.filter((e=>{const n=this._getWidgetInfo(e),o=this.getWidgetInstance(e);return t(e,n,o)})).map(this.getWidgetInstance)})),W(this,"findWidgets",(e=>[...this.findInternalWidgets(e),...this.props.findExternalWidgets(e)])),W(this,"getWidgetInstance",(e=>{const t=this.refs["container:"+e];return t?t.getWidget():null})),W(this,"_onWidgetFocus",(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!M.default.isArray(t))throw new re("widget props.onFocus focusPath must be an Array, but was"+JSON.stringify(t),se.Internal);n._setCurrentFocus([e].concat(t))})),W(this,"_onWidgetBlur",((e,t)=>{const n=this._currentFocus,o=[e].concat(t);M.default.isEqual(o,n)&&M.default.defer((()=>{M.default.isEqual(this._currentFocus,n)&&this._setCurrentFocus(null)}))})),W(this,"getContent",((e,t)=>t.jiptContent||e.content)),W(this,"shouldRenderJiptPlaceholder",((e,t)=>ne().JIPT.useJIPT&&null==t.jiptContent&&-1!==e.content.indexOf("crwdns"))),W(this,"replaceJiptContent",((e,t)=>{if(null==t)this.setState({jiptContent:e});else{/^\s*(`{3,}|~{3,})\s*(\S+)?\s*\n([\s\S]+?)\s*\1\s*$/.test(e)||(/\S\n\s*\n\S/.test(e)?e="$\\large{\\red{\\text{Please translate each paragraph to a single paragraph.}}}$":/^\s*$/.test(e)&&(e="$\\large{\\red{\\text{Translated paragraph is currently empty}}}$"));const n=this.getContent(this.props,this.state),o=Xs.parseToArray(n);o[t]=e,this.setState({jiptContent:Xs.joinFromArray(o)})}})),W(this,"outputMarkdown",((e,t)=>{if(M.default.isArray(e)){const n=t.key,o=[];let s=!1;for(let n=0;n<e.length;n++){t.key=n,t.paragraphIndex=n;const i=this.outputMarkdown(e[n],t),r="string"==typeof i;"string"==typeof i&&s?o[o.length-1]+=i:o.push(i),s=r}return t.key=n,o}this._foundTextNodes=!1,t.foundFullWidth=!1;const n=this.outputNested(e,t);let o;return o=null!=this.translationIndex?null:E.default({"perseus-paragraph-centered":!this._foundTextNodes,"perseus-paragraph-full-width":t.foundFullWidth&&1===e.content.length}),_.createElement(Zs,{key:t.key,className:o,translationIndex:this.translationIndex,paragraphIndex:t.paragraphIndex},_.createElement(Gs,null,n))})),W(this,"outputNested",((e,t)=>{if(M.default.isArray(e)){const n=t.key,o=[];let s=!1;for(let n=0;n<e.length;n++){t.key=n;const i=this.outputNested(e[n],t),r="string"==typeof i;"string"==typeof i&&s?o[o.length-1]+=i:o.push(i),s=r}return t.key=n,o}return this.outputNode(e,this.outputNested,t)})),W(this,"outputNode",((e,t,n)=>{const o=this.getApiOptions(),s=o.imagePlaceholder;if("widget"===e.type){const t=o.widgetPlaceholder;return t||(this._foundTextNodes=!0,M.default.contains(this.widgetIds,e.id)?_.createElement("span",{key:n.key,className:"renderer-widget-error"},["Widget [[","☃"," ",e.id,"]] already exists."].join("")):(this.widgetIds.push(e.id),this.renderWidget(e.widgetType,e.id,n)))}if("blockMath"===e.type){const t=Js(e.content),s={overflowX:"auto",overflowY:"hidden",paddingTop:10,paddingBottom:10,marginTop:-10,marginBottom:-10};if(o.isMobile){const e=16,o={marginLeft:-e,marginRight:-e},i={paddingLeft:e,paddingRight:e},r={...s,...Ri.mobileZoomableParentFix};return _.createElement("div",{key:n.key,className:"perseus-block-math",style:o},_.createElement(Gs,null,_.createElement("div",{className:"perseus-block-math-inner",style:{...r,...i}},_.createElement(Us,null,t))))}return _.createElement("div",{key:n.key,className:"perseus-block-math"},_.createElement(Gs,null,_.createElement("div",{className:"perseus-block-math-inner",style:s},_.createElement(Kt.Consumer,null,(e=>{let{setAssetStatus:n}=e;return _.createElement(qs,{setAssetStatus:n},t)})))))}if("math"===e.type){const t=e.content.replace(/\{align[*]?\}/g,"{aligned}");return _.createElement("span",{key:n.key,style:{whiteSpace:"nowrap"}},_.createElement(Gs,null,_.createElement("span",null),_.createElement(Kt.Consumer,null,(e=>{let{setAssetStatus:n}=e;return _.createElement(qs,{onRender:this.props.onRender,setAssetStatus:n},t)})),_.createElement("span",null)))}if("image"===e.type){if(s)return s;const t=M.default.has(this.props.images,e.target)?this.props.images[e.target]:null,i=!n.inTable;return _.createElement(Gs,{key:n.key},_.createElement(Kt.Consumer,null,(n=>{let{setAssetStatus:s}=n;return _.createElement(zs,U({setAssetStatus:s,src:Ge.sanitizeUrl(e.target),alt:e.alt,title:e.title,responsive:i,onUpdate:this.props.onRender,zoomToFullSizeOnMobile:o.isMobile&&o.isArticle},t))})))}if("columns"===e.type)return this._isTwoColumn=!0,_.createElement(Gs,{key:n.key},Ge.ruleOutput(e,t,n));if("text"===e.type)return Mi.test(e.content)&&(this._foundTextNodes=!0),s&&Ii.test(e.content)?s:e.content;if("table"===e.type||"titledTable"===e.type){const s=Ge.ruleOutput(e,t,{...n,isMobile:o.isMobile,inTable:!0});if(!o.isMobile)return s;const i=16,r={marginLeft:-i,marginRight:-i},a={...{paddingLeft:0,paddingRight:0},...Ri.mobileZoomableParentFix},l=_.createElement("div",{style:{...a,overflowX:"auto"}},_.createElement(Gs,null,_.createElement(Hs,{animateHeight:!0},s)));return _.createElement("div",{style:r},l)}return _.createElement(Gs,{key:n.key},Ge.ruleOutput(e,t,n))})),W(this,"handleRender",(e=>{const t=this.props.onRender,n=e.onRender;if(t!==Pi||n!==Pi){const e=R.default(N.default.findDOMNode(this)).find("img");n!==Pi&&e.off("load",n),t!==Pi&&e.on("load",t)}t()})),W(this,"_setCurrentFocus",(e=>{const t=this.getApiOptions();if(n=e,o=this._currentFocus,!(null===n||null===o?n===o:M.default.every(n,((e,t)=>{if(null!=o)return M.default.isEqual(e,o[t])})))){const n=this._currentFocus;n&&this.blurPath(n),this._currentFocus=e,t.onFocusChange(this._currentFocus,n)}var n,o})),W(this,"focus",(()=>{let e,t;for(let n=0;n<this.widgetIds.length;n++){const o=this.widgetIds[n],s=this.getWidgetInstance(o),i=s&&s.focus&&s.focus();if(i){e=o,t=i;break}}if(e){let n;return"object"==typeof t?(n=[e].concat(t.path||[]),ie.error("Renderer received a focus result of type 'object' instead of the expected type 'boolean'",se.Internal,{loggedMetadata:{focusResult:JSON.stringify(t),currentProps:JSON.stringify(this.state.widgetProps)}})):n=[e],this._setCurrentFocus(n),!0}})),W(this,"getDOMNodeForPath",(e=>{const t=M.default.first(e),n=M.default.rest(e),o=this.getWidgetInstance(t),s=o&&o.getDOMNodeForPath;return s?s(n):0===n.length?N.default.findDOMNode(o):void 0})),W(this,"getGrammarTypeForPath",(e=>{const t=M.default.first(e),n=M.default.rest(e),o=this.getWidgetInstance(t);if(o&&o.getGrammarTypeForPath)return o.getGrammarTypeForPath(n)})),W(this,"getInputPaths",(()=>{const e=[];return M.default.each(this.widgetIds,(t=>{const n=this.getWidgetInstance(t);if(n&&n.getInputPaths){const o=n.getInputPaths();M.default.each(o,(n=>{const o=[t].concat(n);e.push(o)}))}})),e})),W(this,"focusPath",(e=>{if(M.default.isEqual(this._currentFocus,e))return;this._currentFocus&&this.blurPath(this._currentFocus);const t=M.default.first(e),n=M.default.rest(e),o=this.getWidgetInstance(t);o&&o.focusInputPath&&o.focusInputPath(n)})),W(this,"blurPath",(e=>{if(!M.default.isEqual(this._currentFocus,e))return;const t=M.default.first(e),n=M.default.rest(e);if(this.getWidgetInstance(t)){const e=this.getWidgetInstance(t);e&&e.blurInputPath&&e.blurInputPath(n)}})),W(this,"blur",(()=>{this._currentFocus&&this.blurPath(this._currentFocus)})),W(this,"serialize",(()=>{const e={};return M.default.each(this.state.widgetInfo,(function(t,n){const o=this.getWidgetInstance(n).serialize();M.default.isEmpty(o)||(e[n]=o)}),this),e})),W(this,"emptyWidgets",(()=>M.default.filter(this.widgetIds,(e=>{const t=this._getWidgetInfo(e);if(t.static)return!1;const n=this.getWidgetInstance(e);if(n&&n.simpleValidate){const e=n.simpleValidate(t.options,null);return Ae.scoreIsEmpty(e)}})))),W(this,"_setWidgetProps",((e,t,n,o)=>{this.setState((n=>{const s={...n.widgetProps,[e]:{...n.widgetProps[e],...t}},i=o?n.lastUsedWidgetId:e;return o||this.props.onSerializedStateUpdated(this.getSerializedState(s)),{lastUsedWidgetId:i,widgetProps:s}}),(()=>{setTimeout((()=>{const t=n&&n();o||this.props.onInteractWithWidget(e),!1!==t&&this._setCurrentFocus([e])}),0)}))})),W(this,"setInputValue",((e,t,n)=>{var o;const s=M.default.first(e),i=M.default.rest(e),r=this.getWidgetInstance(s);null==r||null===(o=r.setInputValue)||void 0===o||o.call(r,i,t,n)})),W(this,"getUserInput",(()=>this.widgetIds.map((e=>{const t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),W(this,"getWidgetIds",(()=>this.widgetIds)),W(this,"getUserInputForWidgets",(()=>Ti(this.widgetIds,(e=>{const t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),W(this,"scoreWidgets",(()=>{const e=this.state.widgetInfo,t=this.getApiOptions().onInputError,n=M.default.filter(this.widgetIds,(t=>{const n=e[t],o=null==(null==n?void 0:n.graded)||n.graded,s=!(null==n||!n.static);return o&&!s})),o={};return M.default.each(n,(n=>{const s=e[n],i=this.getWidgetInstance(n);i&&i.simpleValidate&&(o[n]=i.simpleValidate(null==s?void 0:s.options,t))})),o})),W(this,"score",(()=>M.default.reduce(this.scoreWidgets(),Ae.combineScores,Ae.noScore))),W(this,"guessAndScore",(()=>[this.getUserInput(),this.score()])),W(this,"examples",(()=>{const e=this.widgetIds,t=M.default.compact(M.default.map(e,(e=>{const t=this.getWidgetInstance(e);return null!=t&&t.examples?t.examples():null})));if(!t.length)return null;return M.default.all(t,(function(e){return M.default.isEqual(t[0],e)}))?t[0]:null})),W(this,"handleNotGorgonLintErrors",(e=>{this._isMounted&&this.setState({notGorgonLintErrors:e})})),this._notGorgon=new Ks,this.state={jiptContent:null,notGorgonLintErrors:[],lastUsedWidgetId:null,...this._getInitialWidgetState(e)}}componentDidMount(){this._isMounted=!0,this.handleRender({}),this._currentFocus=null,this.props.serializedState&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}UNSAFE_componentWillReceiveProps(e){M.default.isEqual(M.default.pick(this.props,Ni),M.default.pick(e,Ni))||this.setState(this._getInitialWidgetState(e))}shouldComponentUpdate(e,t){if(this.props.alwaysUpdate)return!0;const n=!M.default.isEqual(this.state,t);return!M.default.isEqual(this.props,e)||n}UNSAFE_componentWillUpdate(e,t){const n=this.shouldRenderJiptPlaceholder(this.props,this.state),o=this.shouldRenderJiptPlaceholder(e,t),s=this.getContent(this.props,this.state),i=this.getContent(e,t),r=this.props.highlightedWidgets,a=e.highlightedWidgets;this.reuseMarkdown=!n&&!o&&s===i&&M.default.isEqual(this.state.notGorgonLintErrors,t.notGorgonLintErrors)&&(!this.props.linterContext.highlightLint||M.default.isEqual(this.props.widgets,e.widgets))&&this.props.linterContext.highlightLint===e.linterContext.highlightLint&&r===a}componentDidUpdate(e,t){this.handleRender(e),M.default.each(this.widgetIds,(e=>{const t=this.refs["container:"+e];t&&t.replaceWidgetProps(this.getWidgetProps(e))})),this.props.serializedState&&!M.default.isEqual(this.props.serializedState,this.getSerializedState())&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}componentWillUnmount(){this.widgetIds=[],null!=this.translationIndex&&ne().rendererTranslationComponents.removeComponentAtIndex(this.translationIndex),this._isMounted=!1}render(){const e=this.getApiOptions(),{KatexProvider:t}=ne();if(this.reuseMarkdown)return this.lastRenderedMarkdown;const n=this.getContent(this.props,this.state);if(this.widgetIds=[],this.shouldRenderJiptPlaceholder(this.props,this.state)&&(this.translationIndex||(this.translationIndex=ne().rendererTranslationComponents.addComponent(this)),!e.isArticle))return _.createElement(t,null,_.createElement("div",{"data-perseus-component-index":this.translationIndex},n));this._isTwoColumn=!1;const o=Ge.parse(n,{isJipt:null!=this.translationIndex});if(this.props.linterContext.highlightLint){const e={content:this.props.content,widgets:this.props.widgets,...this.props.linterContext};zt.runLinter(o,e,!0),this._notGorgon.applyLintErrors(o,[...this.state.notGorgonLintErrors,...this.props.legacyPerseusLint||[]])}const s=this.outputMarkdown(o,{baseElements:e.baseElements}),i=E.default({[$t.RENDERER]:!0,[$t.RESPONSIVE_RENDERER]:!0,[$t.TWO_COLUMN_RENDERER]:this._isTwoColumn});return this.lastRenderedMarkdown=_.createElement(t,null,_.createElement("div",{className:i},s)),this.lastRenderedMarkdown}}W(Ai,"defaultProps",{content:"",widgets:{},images:{},highlightedWidgets:[],questionCompleted:!1,onRender:Pi,onInteractWithWidget:function(){},findExternalWidgets:()=>[],alwaysUpdate:!1,reviewMode:!1,serializedState:null,onSerializedStateUpdated:()=>{},linterContext:Ht});const Ri={mobileZoomableParentFix:{transform:"translate3d(0,0,0)"}},Fi={fontSize:"150%"},Oi={fontSize:"120%"},Di={fontSize:"130%"},Li=[()=>[_.createElement("span",{key:"plus",style:Oi},"+"),"+"],()=>[_.createElement("span",{key:"minus",style:Fi},"-"),"-"],e=>{const{TeX:t}=ne();return e.convertDotToTimes?[_.createElement(t,{key:"times",style:Fi},S.doNotTranslate("\\times")),"\\times"]:[_.createElement(t,{key:"times",style:Fi},S.doNotTranslate("\\cdot")),"\\cdot"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"frac",style:Fi},S.doNotTranslate("\\frac{x}{y}")),e=>{const t=e.latex();e.typedText("/"),e.latex()===t&&e.cmd("\\frac")}]}],Bi={basic:Li,"basic+div":Li.concat([()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"div"},S.doNotTranslate("\\div")),"\\div"]}]),trig:[()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"sin"},S.doNotTranslate("\\sin")),"\\sin"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"cos"},S.doNotTranslate("\\cos")),"\\cos"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"tan"},S.doNotTranslate("\\tan")),"\\tan"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"theta",style:Di},S.doNotTranslate("\\theta")),"\\theta"]},()=>{const{TeX:e}=ne();return[_.createElement("span",{key:"phi"},_.createElement("span",{className:"perseus-sr-only"},S.doNotTranslate("phi")),_.createElement(e,{key:"pi",style:Di},S.doNotTranslate("\\phi"))),"\\phi"]}],prealgebra:[()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"sqrt"},S.doNotTranslate("\\sqrt{x}")),"\\sqrt"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"nthroot"},S.doNotTranslate("\\sqrt[3]{x}")),e=>{e.typedText("nthroot3"),e.keystroke("Right")}]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"pow",style:Oi},S.doNotTranslate("a^b")),e=>{const t=e.latex();e.typedText("^"),e.latex()===t&&e.typedText("a^b")}]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"pi",style:Oi},S.doNotTranslate("\\pi")),"\\pi"]}],logarithms:[()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"log"},S.doNotTranslate("\\log")),"\\log"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"ln"},S.doNotTranslate("\\ln")),"\\ln"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"log_b"},S.doNotTranslate("\\log_b")),e=>{e.typedText("log_"),e.keystroke("Right"),e.typedText("("),e.keystroke("Left"),e.keystroke("Left")}]}],"basic relations":[()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"eq"},"="),"="]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"lt"},S.doNotTranslate("\\lt")),"\\lt"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"gt"},S.doNotTranslate("\\gt")),"\\gt"]}],"advanced relations":[()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"neq"},S.doNotTranslate("\\neq")),"\\neq"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"leq"},S.doNotTranslate("\\leq")),"\\leq"]},()=>{const{TeX:e}=ne();return[_.createElement(e,{key:"geq"},S.doNotTranslate("\\geq")),"\\geq"]}]},zi=I.default.arrayOf(I.default.oneOf(M.default(Bi).keys()));class qi extends _.Component{render(){const e=M.default.sortBy(this.props.sets,(e=>M.default.keys(Bi).indexOf(e))),t=M.default(e).map((e=>Bi[e])),n=M.default(t).map((e=>e.map((e=>{const t=e(this.props);return _.createElement("button",{onClick:()=>this.props.onInsert(t[1]),className:"tex-button",key:t[0].key,type:"button"},t[0])})))),o=M.default(n).map(((e,t)=>_.createElement("div",{className:"clearfix tex-button-row",key:this.props.sets[t]},e)));return _.createElement("div",{className:"".concat(this.props.className||""," preview-measure")},o)}}W(qi,"propTypes",{sets:zi.isRequired,onInsert:I.default.func.isRequired,className:I.default.string}),W(qi,"buttonSets",Bi),W(qi,"buttonSetsType",zi);const Hi=I.default;class Wi extends _.Component{constructor(){super(...arguments),W(this,"mouseDown",void 0),W(this,"state",{focused:!1}),W(this,"handleFocus",(()=>{this.setState({focused:!0})})),W(this,"handleMouseDown",(e=>{const t=N.default.findDOMNode(this).contains(e.target);this.mouseDown=t,t||this.setState({focused:!1})})),W(this,"handleMouseUp",(()=>{this.mouseDown&&this.focus(),this.mouseDown=!1})),W(this,"handleBlur",(e=>{this.mouseDown||N.default.findDOMNode(this).contains(e.relatedTarget)||this.setState({focused:!1})})),W(this,"_shouldShowButtons",(()=>"always"===this.props.buttonsVisible||"never"!==this.props.buttonsVisible&&this.state.focused)),W(this,"insert",(e=>{const t=this.mathField();M.default(e).isFunction()?e(t):"\\"===e[0]?t.cmd(e).focus():t.write(e).focus(),t.focus()})),W(this,"mathField",(e=>O.default.getInterface(2).MathField(N.default.findDOMNode(this.refs.mathinput),e))),W(this,"focus",(()=>{this.mathField().focus(),this.setState({focused:!0})})),W(this,"blur",(()=>{this.mathField().blur(),this.setState({focused:!1})}))}render(){let e=E.default({"perseus-math-input":!0,"mq-editable-field":!0,"mq-math-mode":!0});this.props.className&&(e=e+" "+this.props.className);let t=null;return this._shouldShowButtons()&&(t=_.createElement(qi,{sets:this.props.buttonSets,className:"math-input-buttons absolute",convertDotToTimes:this.props.convertDotToTimes,onInsert:this.insert})),_.createElement("div",{style:{display:"inline-block"}},_.createElement("div",{style:{display:"inline-block"}},_.createElement("span",{className:e,ref:"mathinput","aria-label":this.props.labelText,onFocus:this.handleFocus,onBlur:this.handleBlur})),_.createElement("div",{style:{position:"relative"},onBlur:this.handleBlur},t))}componentWillUnmount(){window.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}componentDidMount(){window.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp);let e=!1;this.mathField({autoCommands:"pi theta phi sqrt nthroot",charsThatBreakOutOfSupSub:"+-*/=<>≠≤≥",supSubsRequireOperand:!0,spaceBehavesLikeTab:!0,handlers:{edited:t=>{let n=t.latex();if(n=n.replace(/<>/g,"\\ne"),this.props.convertDotToTimes){n=n.replace(/\\cdot/g,"\\times");const e=t.__controller.cursor[O.default.L];e&&"\\cdot "===e.ctrlSeq&&(t.__controller.backspace(),t.cmd("\\times"))}else n=n.replace(/\\times/g,"\\cdot");e&&this.props.value!==n&&this.props.onChange(n)},enter:()=>{R.default(N.default.findDOMNode(this.refs.mathinput)).submit()},upOutOf:e=>{e.typedText("^")}}}),this.mathField().latex(this.props.value),e=!0}}function Ui(e,t,n){const o=e.indexOf("{",t)+1,s=function(e,t){let n=0;for(let o=t,s=e.length;o<s;o++){const t=e[o];if("{"===t?n++:"}"===t&&n--,n<0)return o}return e.length}(e,o);return{endpoint:s,expression:Vi(e.substring(o,s),n)}}function Gi(e,t){const n=e.indexOf("\\frac",t),o=e.indexOf("\\dfrac",t);return n>-1&&o>-1?Math.min(n,o):n>-1?n:o>-1?o:-1}function Vi(e,t){if(!e)return"";let n="",o=0,s=Gi(e,o);for(;s>-1;){n+=e.substring(o,s),o=s;const i=Ui(e,o,t);o=i.endpoint+1;const r=Ui(e,o,t);o=r.endpoint+1,n.length&&(n+=" "),n+=t(i.expression,r.expression),s=Gi(e,o)}return n+=e.slice(o),n}W(Wi,"propTypes",{value:Hi.string,onChange:Hi.func.isRequired,convertDotToTimes:Hi.bool,buttonsVisible:Hi.oneOf(["always","never","focused"]),buttonSets:qi.buttonSetsType.isRequired,labelText:I.default.string,onFocus:Hi.func,onBlur:Hi.func}),W(Wi,"defaultProps",{value:"",convertDotToTimes:!1,buttonsVisible:"focused"});var ji=function(e){return Vi(e,(function(e,t){return e+"/"+t})).replace("\\%","%")},Yi=function(e){function t(e){return e.indexOf("\\frac")>-1||e.indexOf("\\dfrac")>-1}return Vi(e,(function(e,n){let o;return o=t(e)||t(n)?"\\dfrac":"\\frac",o+" {"+e+"}{"+n+"}"}))};const $i=Yi;class Xi extends _.Component{constructor(){super(...arguments),W(this,"state",{focused:!1,selectorNamespace:M.default.uniqueId("math-output")}),W(this,"_getInputClassName",(()=>{let e="math-output "+$t.INPUT+" "+$t.INTERACTIVE;return this.state.focused&&(e+=" "+$t.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),W(this,"_getDisplayValue",(e=>{let t;return t=null!=e?""+e:"",$i(t)})),W(this,"getValue",(()=>this.props.value)),W(this,"focus",(()=>{this.state.focused||(this.props.onFocus(),this._bindBlurHandler(),this.setState({focused:!0}))})),W(this,"blur",(()=>{this.state.focused&&(this.props.onBlur(),this._unbindBlurHandler(),this.setState({focused:!1}))})),W(this,"_bindBlurHandler",(()=>{R.default(document).bind("vclick."+this.state.selectorNamespace,(e=>{R.default(e.target).closest(N.default.findDOMNode(this)).length||this.blur()}))})),W(this,"_unbindBlurHandler",(()=>{R.default(document).unbind("."+this.state.selectorNamespace)}))}render(){const{TeX:e}=ne();return _.createElement("span",{ref:"input",className:this._getInputClassName(),"aria-label":this.props.labelText,onMouseDown:this.focus,onTouchStart:this.focus},_.createElement("div",{style:{textAlign:"center"}},_.createElement(e,null,this._getDisplayValue(this.props.value))))}componentWillUnmount(){this._unbindBlurHandler()}}W(Xi,"propTypes",{value:I.default.oneOfType([I.default.string,I.default.number]),className:I.default.string,labelText:I.default.string,onFocus:I.default.func,onBlur:I.default.func}),W(Xi,"defaultProps",{value:"",onFocus:function(){},onBlur:function(){}});class Ki extends _.Component{constructor(){super(...arguments),W(this,"focus",(()=>{N.default.findDOMNode(this).focus()})),W(this,"blur",(()=>{N.default.findDOMNode(this).blur()})),W(this,"getValue",(()=>{var e;return null===(e=N.default.findDOMNode(this))||void 0===e?void 0:e.value})),W(this,"getStringValue",(()=>{var e;return null===(e=N.default.findDOMNode(this))||void 0===e?void 0:e.value.toString()})),W(this,"setSelectionRange",((e,t)=>{N.default.findDOMNode(this).setSelectionRange(e,t)})),W(this,"getSelectionStart",(()=>N.default.findDOMNode(this).selectionStart)),W(this,"getSelectionEnd",(()=>N.default.findDOMNode(this).selectionEnd))}render(){const{labelText:e,...t}=this.props;return _.createElement("input",U({},t,{type:"text","aria-label":e,onChange:e=>this.props.onChange(e.target.value)}))}}W(Ki,"propTypes",{value:I.default.string,onChange:I.default.func.isRequired,className:I.default.string,labelText:I.default.string,onFocus:I.default.func,onBlur:I.default.func,disabled:I.default.bool}),W(Ki,"defaultProps",{value:"",disabled:!1});const Zi=F.default({displayName:"Triangle",propTypes:{color:I.default.string.isRequired,left:I.default.number.isRequired,top:I.default.number.isRequired,width:I.default.number.isRequired,height:I.default.number.isRequired,horizontalDirection:I.default.oneOf(["left","right"]).isRequired,verticalDirection:I.default.oneOf(["top","bottom"]).isRequired},render:function(){let e,t,n,o;const s="".concat(this.props.width,"px solid transparent");"right"===this.props.horizontalDirection?e=s:t=s;const i="".concat(this.props.height,"px solid ").concat(this.props.color);return"top"===this.props.verticalDirection?n=i:o=i,_.createElement("div",{style:{display:"block",height:0,width:0,position:"absolute",left:this.props.left,top:this.props.top,borderLeft:e,borderRight:t,borderTop:n,borderBottom:o}})}}),Ji=F.default({displayName:"TooltipArrow",propTypes:{position:I.default.string,visibility:I.default.string,left:I.default.number,top:I.default.number,color:I.default.string.isRequired,border:I.default.string.isRequired,width:I.default.number.isRequired,height:I.default.number.isRequired,horizontalDirection:I.default.oneOf(["left","right"]).isRequired,verticalDirection:I.default.oneOf(["top","bottom"]).isRequired},getDefaultProps:function(){return{position:"relative",visibility:"visible",left:0,top:0}},render:function(){const e="top"===this.props.verticalDirection,t=e?0:1,n=e?0:-1;return _.createElement("div",{style:{display:"block",position:this.props.position,visibility:this.props.visibility,left:this.props.left,top:this.props.top,width:this.props.width+2,height:this.props.height+1,marginTop:-1,marginBottom:-2,zIndex:10}},_.createElement(Zi,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.border,left:0,top:n,width:this.props.width+2,height:this.props.height+2}),_.createElement(Zi,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.color,left:1,top:t,width:this.props.width,height:this.props.height}))}}),Qi={top:{top:"-100%"},bottom:{top:0}},er={left:{targetLeft:0},right:{targetLeft:"100%"}},tr={left:{tooltipLeft:0,arrowLeft:e=>0},right:{tooltipLeft:"-100%",arrowLeft:e=>-e-2}},nr=F.default({displayName:"Tooltip",propTypes:{show:I.default.bool.isRequired,className:I.default.string,arrowSize:I.default.number,borderColor:I.default.string,verticalPosition:I.default.oneOf(Object.keys(Qi)),horizontalPosition:I.default.oneOf(Object.keys(er)),horizontalAlign:I.default.oneOf(Object.keys(tr)),children:I.default.arrayOf(I.default.element).isRequired,targetContainerStyle:I.default.any},getDefaultProps:function(){return{className:"",arrowSize:10,borderColor:"#ccc",verticalPosition:"bottom",horizontalPosition:"left",horizontalAlign:"left",targetContainerStyle:{}}},getInitialState:function(){return{height:null}},componentDidMount:function(){this._updateHeight()},UNSAFE_componentWillReceiveProps:function(){this.setState({height:null})},componentDidUpdate:function(){this._updateHeight()},_renderToolTipDiv:function(e){const t=Object.assign({},er[this.props.horizontalPosition],tr[this.props.horizontalAlign],Qi[this.props.verticalPosition]);let n,o;return e?(n=_.createElement(Ji,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,position:"absolute",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:2-this.props.arrowSize,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),o=_.createElement(Ji,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,visibility:"hidden",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10})):(n=_.createElement(Ji,{verticalDirection:"bottom",horizontalDirection:this.props.horizontalAlign,color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),o=null),_.createElement("div",{style:{position:"relative",height:0,display:this.props.show?"block":"none"}},_.createElement("div",{ref:"tooltipContainer",className:"tooltipContainer",style:{position:"absolute",height:this.state.height||void 0,left:t.targetLeft}},n,_.createElement("div",{className:this.props.className,ref:"tooltipContent",style:{position:"relative",top:t.top,left:t.tooltipLeft,border:"1px solid "+this.props.borderColor,WebkitBoxShadow:"0 1px 3px "+this.props.borderColor,MozBoxShadow:"0 1px 3px "+this.props.borderColor,boxShadow:"0 1px 3px "+this.props.borderColor,zIndex:9}},this.props.children.slice(1)),o))},_updateHeight:function(){const e=N.default.findDOMNode(this.refs.tooltipContainer).offsetHeight;e!==this.state.height&&this.setState({height:e})},render:function(){const e="top"===this.props.verticalPosition;return _.createElement("span",null,e&&this._renderToolTipDiv(e),_.createElement("div",{style:this.props.targetContainerStyle},this.props.children[0]),!e&&this._renderToolTipDiv())}}),{captureScratchpadTouchStart:or}=Ae;class sr extends _.Component{constructor(){super(...arguments),W(this,"state",{focused:!1,showExamples:!1}),W(this,"_getUniqueId",(()=>"input-with-examples-".concat(btoa(this.props.id).replace(/=/g,"")))),W(this,"_getInputClassName",(()=>{if("tex"===this.props.type)return this.props.className;let e=$t.INPUT+" "+$t.INTERACTIVE;return this.state.focused&&(e+=" "+$t.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),W(this,"_getPropsForInputType",(()=>{const e={"aria-describedby":this._getUniqueId(),ref:"input",className:this._getInputClassName(),labelText:this.props.labelText,value:this.props.value,onFocus:this._handleFocus,onBlur:this._handleBlur,disabled:this.props.disabled};return"tex"===this.props.type?e:(M.default.extend(e,{onChange:this.props.onChange,onTouchStart:or}),"math"===this.props.type?M.default.extend({buttonSet:this.props.buttonSet,buttonsVisible:this.props.buttonsVisible,convertDotToTimes:this.props.convertDotToTimes},e):"text"===this.props.type?M.default.extend({autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:"false"},e):void 0)})),W(this,"_getComponentForInputType",(()=>{switch(this.props.type){case"tex":return Xi;case"math":return Wi;case"text":return Ki;default:return null}})),W(this,"_renderInput",(()=>{const e=this._getPropsForInputType(),t=this._getComponentForInputType();return _.createElement(t,e)})),W(this,"_handleFocus",(()=>{this.props.onFocus(),this.setState({focused:!0,showExamples:!0})})),W(this,"show",(()=>{this.setState({showExamples:!0})})),W(this,"hide",(()=>{this.setState({showExamples:!1})})),W(this,"_handleBlur",(()=>{this.props.onBlur(),this.setState({focused:!1,showExamples:!1})})),W(this,"focus",(()=>{this.refs.input.focus()})),W(this,"blur",(()=>{this.refs.input.blur()})),W(this,"handleChange",(e=>{this.props.onChange(e.target.value)}))}render(){const e=this._renderInput();if("tex"===this.props.type)return e;const t=M.default.map(this.props.examples,(e=>"- "+e)).join("\n"),n=this.props.shouldShowExamples&&this.state.showExamples;return _.createElement(nr,{ref:"tooltip",className:"perseus-formats-tooltip preview-measure",horizontalPosition:"left",horizontalAlign:"left",verticalPosition:"bottom",arrowSize:10,borderColor:"#ccc",show:n},e,_.createElement("div",{id:this._getUniqueId()},_.createElement(Ai,{content:t,linterContext:zt.pushContextStack(this.props.linterContext,"input-with-examples")})))}}W(sr,"propTypes",{type:I.default.oneOf(["math","text","tex"]),value:I.default.string,onChange:I.default.func.isRequired,className:I.default.string,examples:I.default.arrayOf(I.default.string).isRequired,shouldShowExamples:I.default.bool,convertDotToTimes:I.default.bool,buttonSet:I.default.string,buttonsVisible:I.default.oneOf(["always","never","focused"]),labelText:I.default.string,onFocus:I.default.func,onBlur:I.default.func,disabled:I.default.bool,id:I.default.string.isRequired,linterContext:qt}),W(sr,"defaultProps",{type:"text",shouldShowExamples:!0,onFocus:function(){},onBlur:function(){},disabled:!1,linterContext:Ht});var ir=["key","ref","containerSizeClass","widgetId","onChange","problemNum","apiOptions","questionCompleted","findWidgets","onRemove","id","onBlur","onFocus","trackInteraction","keypadElement"];const rr='Usage:\n this.change({propName: 5}, callback);\n this.change("propName", 5, callback);\n this.change("propName")',ar=function(e,t,n){const o=M.default.omit(e.props,ir),s=M.default.extend(o,t);e.props.onChange(s,n)},lr=function(e,t,n,o){if(void 0===n)return M.default.partial(lr,e,t);const s={};s[t]=n,ar(e,s,o)},cr=function(e,t,n){if(M.default.isObject(e)&&void 0===n)return ar(this,e,n=t);if("string"==typeof e)return lr(this,e,t,n);throw new re("Invalid types sent to this.change(): "+M.default.toArray(arguments).join()+"\n"+rr,se.Internal)},pr={onChange:I.default.func.isRequired};var dr=Object.freeze({__proto__:null,change:cr,propTypes:pr});const ur=S._("Sorry, I don't understand that!"),hr=e=>e.replace(/([_^])([^{])/g,"$1{$2}");class fr extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"displayName","Expression"),W(this,"state",{showErrorTooltip:!1,showErrorText:!1}),W(this,"componentDidMount",(()=>{this._isMounted=!0})),W(this,"componentDidUpdate",(e=>{M.default.isEqual(this.props.value,e.value)&&M.default.isEqual(this.props.functions,e.functions)||(clearTimeout(this.errorTimeout),this.parse(this.props.value,this.props).parsed?this.setState({showErrorTooltip:!1}):this.errorTimeout=setTimeout((()=>{!1!==this.props.apiOptions.onInputError(null,this.props.value,ur)&&this.setState({showErrorTooltip:!0})}),2e3))})),W(this,"componentWillUnmount",(()=>{clearTimeout(this.errorTimeout),this._isMounted=!1})),W(this,"_isMounted",!1),W(this,"errorTimeout",null),W(this,"simpleValidate",((e,t)=>(t=t||function(){},fr.validate(this.getUserInput(),e,t)))),W(this,"getUserInput",(()=>fr.getUserInputFromProps(this.props))),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"parse",((e,t)=>{const n=M.default.pick(t||this.props,"functions");return M.default.extend(n,{decimal_separator:S.getDecimalSeparator()}),k.parse(hr(e),n)})),W(this,"changeAndTrack",((e,t)=>{this.change("value",e,t),this.props.trackInteraction()})),W(this,"_handleFocus",(()=>{this.props.onFocus([])})),W(this,"_handleBlur",(()=>{this.props.onBlur([])})),W(this,"focus",(()=>(this.props.apiOptions.customKeypad&&this.refs.input.focus(),!0))),W(this,"focusInputPath",(e=>{this.refs.input.focus()})),W(this,"blurInputPath",(e=>{this.refs.input.blur()})),W(this,"insert",(e=>{this.props.apiOptions.staticRender||this.refs.input.insert(e)})),W(this,"getInputPaths",(()=>[[]])),W(this,"getGrammarTypeForPath",(e=>"expression")),W(this,"setInputValue",((e,t,n)=>{this.props.onChange({value:t},n)}))}static validate(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};const o=M.default.clone(t);M.default.extend(o,{decimal_separator:S.getDecimalSeparator()});const s=e=>{const n=k.parse(e.value,t);return n.parsed?pe.expression.createValidatorFunctional(n.expr,M.default({}).extend(o,{simplify:e.simplify,form:e.form})):(ie.error("Unable to parse solution answer for expression",se.InvalidInput,{loggedMetadata:{rubric:JSON.stringify(t)}}),null)};let i,r,a,l=!0;for(const n of t.answerForms||[]){const t=s(n);if(!t)continue;const o=t(e);if(o.correct){i=n,r=o.message||"";break}l=l&&o.empty,"correct"===n.considered&&o.ungraded&&!a&&(a=o)}if(!i)return a?{type:"invalid",message:a.message,suppressAlmostThere:a.suppressAlmostThere}:l?{type:"invalid",message:null}:{type:"points",earned:0,total:1};if("ungraded"===i.considered){return{type:"invalid",message:!1===n(null,e,r)?null:r}}return{type:"points",earned:"correct"===i.considered?1:0,total:1,message:r}}static getUserInputFromProps(e){return hr(e.value)}static getOneCorrectAnswerFromRubric(e){const t=(e.answerForms||[]).filter((e=>"correct"===e.considered));if(0!==t.length)return t[0].value}render(){if(this.props.apiOptions.customKeypad)return _.createElement(t.KeypadInput,{ref:"input",value:this.props.value,keypadElement:this.props.keypadElement,onChange:this.changeAndTrack,onFocus:()=>{var e;null===(e=this.props.keypadElement)||void 0===e||e.configure(this.props.keypadConfiguration,(()=>{this._isMounted&&this._handleFocus()}))},onBlur:this._handleBlur});if(this.props.apiOptions.staticRender)return _.createElement(sr,{ref:"input",value:this.props.value,type:"tex",examples:[],shouldShowExamples:!1,onChange:this.changeAndTrack,onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,linterContext:this.props.linterContext});const e=_.createElement("span",{className:"error-tooltip",role:"tooltip"},_.createElement(nr,{className:"error-text-container",horizontalPosition:"right",horizontalAlign:"left",verticalPosition:"top",arrowSize:10,borderColor:"#fcc335",show:this.state.showErrorText},_.createElement("span",{className:"error-icon","data-test-id":"test-error-icon",onMouseEnter:()=>{this.setState({showErrorText:!0})},onMouseLeave:()=>{this.setState({showErrorText:!1})},onClick:()=>{this.setState({showErrorText:!this.state.showErrorText})}},_.createElement(G,yo)),_.createElement("div",{className:"error-text"},ur))),n=E.default({"perseus-widget-expression":!0,"show-error-tooltip":this.state.showErrorTooltip});return _.createElement("div",{className:n},_.createElement(Wi,{ref:"input",className:$t.INTERACTIVE,value:this.props.value,onChange:this.changeAndTrack,convertDotToTimes:this.props.times,buttonsVisible:this.props.buttonsVisible||"focused",buttonSets:this.props.buttonSets,onFocus:this._handleFocus,onBlur:this._handleBlur}),this.state.showErrorTooltip&&e)}}W(fr,"defaultProps",{value:"",times:!1,functions:[],buttonSets:["basic","trig","prealgebra","logarithms"],onFocus:()=>{},onBlur:()=>{},apiOptions:Yt.defaults,linterContext:Ht});const mr=e=>{const n=t.KeypadTypes.EXPRESSION,o={},s={};for(const t of e.answerForms){const n=k.parse(t.value,e);if(n.parsed){const e=n.expr,t=e=>"pi"===e||"theta"===e,i=e=>t(e)?e.toUpperCase():e;for(const t of e.getVars())o[i(t)]=!0;for(const t of e.getConsts())s[i(t)]=!0}}const i=Object.keys(o);i.sort();const r=Object.keys(s);r.sort();const a=[...i,...r];return a.length||a.push("PI"),{keypadType:n,extraKeys:a}};var gr={name:"expression",displayName:"Expression / Equation",defaultAlignment:"inline-block",widget:fr,transform:e=>{const{times:t,functions:n,buttonSets:o,buttonsVisible:s}=e;return{keypadConfiguration:mr(e),times:t,functions:n,buttonSets:o,buttonsVisible:s}},version:{major:1,minor:0},propUpgrades:{1:e=>({times:e.times,buttonSets:e.buttonSets,functions:e.functions,buttonsVisible:e.buttonsVisible,answerForms:[{considered:"correct",form:e.form,simplify:e.simplify,value:e.value}]})},isLintable:!0};class vr extends _.Component{render(){const e=M.default.uniq(this.props.answers),t=M.default.map(e,(e=>_.createElement("dd",{key:e},e)));return _.createElement("dl",{className:"perseus-possible-answers"},_.createElement("dt",null,S.doNotTranslate("Correct Answer")),t)}}W(vr,"propTypes",{answers:I.default.arrayOf(I.default.string)});const yr=F.default({displayName:"SimpleKeypadInput",propTypes:{keypadElement:t.keypadElementPropType,onFocus:I.default.func,value:I.default.oneOfType([I.default.string,I.default.number])},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},focus(){this.refs.input.focus()},blur(){this.refs.input.blur()},getValue:function(){return this.props.value},render(){const e=this,{keypadElement:n,onFocus:o,value:s,...i}=e.props;return _.createElement(t.KeypadInput,U({ref:"input",keypadElement:n,onFocus:()=>{n?n.configure({keypadType:t.KeypadTypes.FRACTION},(()=>{e._isMounted&&o&&o()})):o&&o()},value:null==s?"":""+s},i))}}),br=ji,xr={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"}},wr={integer:function(e){return S._("an integer, like $6$")},proper:function(e){return"optional"===e.simplify?S._("a *proper* fraction, like $1/2$ or $6/10$"):S._("a *simplified proper* fraction, like $3/5$")},improper:function(e){return"optional"===e.simplify?S._("an *improper* fraction, like $10/7$ or $14/8$"):S._("a *simplified improper* fraction, like $7/4$")},mixed:function(e){return S._("a mixed number, like $1\\ 3/4$")},decimal:function(e){return S._("an *exact* decimal, like $0.75$")},percent:function(e){return S._("a percent, like $12.34\\%$")},pi:function(e){return S._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")}};class Cr extends _.Component{constructor(){super(...arguments),W(this,"shouldShowExamples",(()=>"number"!==this.props.answerType&&!this.props.apiOptions.staticRender)),W(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t)})),W(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),W(this,"_handleFocus",(()=>{this.props.onFocus([]);const{interactionCallback:e}=this.props.apiOptions;e&&e()})),W(this,"_handleBlur",(()=>{this.props.onBlur([])})),W(this,"focus",(()=>(this.refs.input.focus(),!0))),W(this,"focusInputPath",(e=>{this.refs.input.focus()})),W(this,"blurInputPath",(e=>{this.refs.input.blur()})),W(this,"getInputPaths",(()=>[[]])),W(this,"getGrammarTypeForPath",(e=>"number")),W(this,"setInputValue",((e,t,n)=>{this.props.onChange({currentValue:t},n)})),W(this,"getUserInput",(()=>Cr.getUserInputFromProps(this.props))),W(this,"simpleValidate",((e,t)=>(t=t||function(){},Cr.validate(this.getUserInput(),e,t)))),W(this,"examples",(()=>{const e=this.props.answerType,t=xr[e].forms.split(/\s*,\s*/),n=M.default.map(t,(function(e){return wr[e](this.props)}),this);return[S._("**Your answer should be** ")].concat(n)}))}render(){if(this.props.apiOptions.customKeypad){const e=_.createElement(yr,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur});return this.props.rightAlign?_.createElement("div",{className:"perseus-input-right-align"},e):e}const e=this.props.reviewModeRubric;let t=null,n=null;if(this.props.apiOptions.satStyling&&e){const o=this.simpleValidate(e);if(t="points"===o.type&&o.earned===o.total,!t){let t=String(e.value);e.inexact&&e.maxError&&(t+=" ± "+e.maxError);const o=[t];n=_.createElement(vr,{answers:o})}}const o={};o["perseus-input-size-"+this.props.size]=!0,o["perseus-input-right-align"]=this.props.rightAlign,o[$t.CORRECT]=e&&t&&this.props.currentValue,o[$t.INCORRECT]=e&&!t&&this.props.currentValue,o[$t.UNANSWERED]=e&&!this.props.currentValue;const s=_.createElement(sr,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:E.default(o),type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,linterContext:this.props.linterContext});return n?_.createElement("span",{className:"perseus-input-with-answer-blurb"},s,n):s}static validate(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>{};null==t.answerType&&(t.answerType="number");const o=pe.number.createValidatorFunctional(t.value,{simplify:t.simplify,inexact:t.inexact||void 0,maxError:t.maxError,forms:xr[t.answerType].forms})(br(e.currentValue));if(o.empty){return{type:"invalid",message:!1===(null==n?void 0:n(null,e.currentValue,o.message))?null:o.message}}return{type:"points",earned:o.correct?1:0,total:1,message:o.message}}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){if(null==e.value)return;let t=String(e.value);return e.inexact&&e.maxError&&(t+=" ± "+e.maxError),t}}W(Cr,"defaultProps",{currentValue:"",size:"normal",answerType:"number",rightAlign:!1,apiOptions:Yt.defaults,linterContext:Ht});var kr={name:"input-number",displayName:"Number text box (old)",defaultAlignment:"inline-block",hidden:!0,widget:Cr,transform:e=>{const{simplify:t,size:n,answerType:o,rightAlign:s}=e;return{simplify:t,size:n,answerType:o,rightAlign:s}},isLintable:!0};const Sr=ji,Er=[{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:"π"}],_r={integer:()=>S._("an integer, like $6$"),proper:e=>"optional"===e.simplify?S._("a *proper* fraction, like $1/2$ or $6/10$"):S._("a *simplified proper* fraction, like $3/5$"),improper:e=>"optional"===e.simplify?S._("an *improper* fraction, like $10/7$ or $14/8$"):S._("a *simplified improper* fraction, like $7/4$"),mixed:()=>S._("a mixed number, like $1\\ 3/4$"),decimal:()=>S._("an *exact* decimal, like $0.75$"),pi:()=>S._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")};class Tr extends _.Component{constructor(){super(...arguments),W(this,"state",{previousValues:[""]}),W(this,"getAnswerBlurb",(e=>{let t,n;if(this.props.apiOptions.satStyling&&e){const o=this.simpleValidate(e);if(t="points"===o.type&&o.earned===o.total,!t){const t=M.default.filter(e.answers,(e=>"correct"===e.status)),o=M.default.map(t,(e=>{let t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);let n=ae.toNumericString(e.value,t);return e.maxError&&(n+=" ± "+ae.toNumericString(e.maxError,t)),n}));n=_.createElement(vr,{answers:o})}}return[n,!!t]})),W(this,"getClasses",((e,t)=>{const n={};return n["perseus-input-size-"+this.props.size]=!0,n["perseus-input-right-align"]=this.props.rightAlign,n[$t.CORRECT]=t&&e&&this.props.currentValue,n[$t.INCORRECT]=t&&!e&&this.props.currentValue,n[$t.UNANSWERED]=t&&!this.props.currentValue,n})),W(this,"examples",(()=>{var e;const t=0!==(null===(e=this.props.answerForms)||void 0===e?void 0:e.length)?this.props.answerForms:M.default.map(M.default.keys(_r),(e=>({name:e,simplify:"required"})));let n=M.default.map(t,(e=>_r[e.name](e)));return n=M.default.uniq(n),[S._("**Your answer should be** ")].concat(n)})),W(this,"shouldShowExamples",(()=>{var e,t;const n=0===(null===(e=this.props.answerForms)||void 0===e?void 0:e.length),o=M.default.uniq(null===(t=this.props.answerForms)||void 0===t?void 0:t.map((e=>e.name))).length>=M.default.size(_r);return!n&&!o})),W(this,"simpleValidate",(e=>Tr.validate(this.getUserInput(),e))),W(this,"focus",(()=>(this.refs.input.focus(),!0))),W(this,"focusInputPath",(e=>{this.refs.input.focus()})),W(this,"blurInputPath",(e=>{this.refs.input.blur()})),W(this,"getInputPaths",(()=>[[]])),W(this,"getGrammarTypeForPath",(e=>"number")),W(this,"setInputValue",((e,t,n)=>{this.props.onChange({currentValue:t},n)})),W(this,"getUserInput",(()=>Tr.getUserInputFromProps(this.props))),W(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t),this.props.trackInteraction()})),W(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),W(this,"_handleFocus",(()=>{this.props.onFocus([]);const{interactionCallback:e}=this.props.apiOptions;e&&e()})),W(this,"_handleBlur",(()=>{this.props.onBlur([])}))}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){const t=M.default.filter(e.answers,(e=>"correct"===e.status)),n=M.default.map(t,(e=>{let t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);let n=ae.toNumericString(e.value,t);return e.maxError&&(n+=" ± "+ae.toNumericString(e.maxError,t)),n}));if(0!==n.length)return n[0]}static validate(e,t){const n=M.default.pluck(Er,"value"),o=e=>pe.number.createValidatorFunctional(e.value,{message:e.message,simplify:"correct"===e.status?e.simplify:"optional",inexact:!0,maxError:e.maxError,forms:e.strict&&e.answerForms&&0!==e.answerForms.length?e.answerForms:n}),s=Sr(e.currentValue),i=M.default.where(t.answers,{status:"correct"}),r=i.every((e=>Math.abs(e.value)<=1));let a=M.default.find(M.default.map(i,(e=>{let n=s;t.coefficient&&(n?"-"===n&&(n=-1):n=1);return o(e)(Ir(n,r))})),(e=>e.correct||e.empty));if(!a){const e=[].concat(M.default.where(t.answers,{status:"ungraded"}),M.default.where(t.answers,{status:"wrong"})),n=M.default.find(e,(e=>o(e)(Ir(s,r)).correct));a={empty:!!n&&"ungraded"===n.status,correct:!!n&&"correct"===n.status,message:n?n.message:null,guess:s}}return a.empty?{type:"invalid",message:a.message}:{type:"points",earned:a.correct?1:0,total:1,message:a.message}}render(){const e=this.props.reviewModeRubric,t=this.getAnswerBlurb(e),n=t[0],o=t[1],s=this.getClasses(o,e);let i=this.props.labelText;null!=i&&""!==i||(i=S._("Your answer:"));const r=e=>this.props.rightAlign?_.createElement("div",{className:"perseus-input-right-align"},e):e;if(this.props.apiOptions.customKeypad)return r(_.createElement(yr,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur}));const a=_.createElement(sr,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:E.default(s),labelText:i,type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,highlightLint:this.props.highlightLint});return n?_.createElement("span",{className:"perseus-input-with-answer-blurb"},a,n):this.props.apiOptions.satStyling?_.createElement("label",{className:"perseus-input-with-label"},_.createElement("span",{className:"perseus-input-label","aria-hidden":"true"},S.doNotTranslate("Answer:")),a):_.createElement("div",null,a)}}W(Tr,"defaultProps",{currentValue:"",size:"normal",rightAlign:!1,apiOptions:Yt.defaults,coefficient:!1,answerForms:[],labelText:"",linterContext:Ht,multipleNumberInput:!1});const Mr=function(e){const t=M.default.flatten(e),n=(o=t,s=M.default.isEqual,M.default.reduce(o,((e,t)=>M.default.find(e,s.bind(null,t))?e:e.concat([t])),[]));var o,s;return M.default.sortBy(n,(e=>M.default.keys(_r).indexOf(e.name)))},Ir=(e,t)=>{if("string"!=typeof e||!e.endsWith("%"))return e;const n=parseFloat(e.slice(0,-1));return isNaN(n)?e:t?n/100:n};var Pr={name:"numeric-input",displayName:"Number text box",defaultAlignment:"inline-block",accessible:!0,widget:Tr,transform:function(e){return M.default.extend(M.default.omit(e,"answers"),{answerForms:Mr(M.default.map(e.answers,(e=>M.default.map(e.answerForms,(t=>({simplify:e.simplify,name:t}))))))})},isLintable:!0};const Nr={getUserInput:function(){return M.default.omit(this.props,ir)},getUserInputFromProps:function(e){return M.default.omit(e,ir)}};class Ar extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"displayName","PassageRef"),W(this,"_isMounted",void 0),W(this,"_throttledUpdateRange",void 0),W(this,"state",{lineRange:null,content:null}),W(this,"getUserInput",(()=>Nr.getUserInput.call(this))),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"_deferredUpdateRange",(()=>{M.default.defer(this._updateRange)})),W(this,"_updateRange",(()=>{const e=this.props.findWidgets("passage "+this.props.passageNumber)[0];let t=null;e&&(t=e.getReference(this.props.referenceNumber)),this._isMounted&&(t?this.setState({lineRange:[t.startLine,t.endLine],content:t.content}):this.setState({lineRange:null,content:null}))})),W(this,"simpleValidate",(e=>Ar.validate(this.getUserInput(),e)))}shouldComponentUpdate(e,t){return!M.default.isEqual(this.props,e)||!M.default.isEqual(this.state,t)}render(){const e=this.state.lineRange;let t,n;if(t=e?e[0]===e[1]?S.$_("line %(lineNumber)s",{lineNumber:e[0]}):S.$_("lines %(lineRange)s",{lineRange:e[0]+"–"+e[1]}):S.$_("lines %(lineRange)s",{lineRange:"?".concat("–","?")}),this.props.summaryText){const e=Ge.parseInline(this.props.summaryText);n=_.createElement("span",{"aria-hidden":!0}," ","(“",Ge.basicOutput(e),"”)")}else n=null;return _.createElement("span",null,t,n,e&&_.createElement("div",{className:"perseus-sr-only"},this.state.content))}componentDidMount(){this._isMounted=!0,this._deferredUpdateRange(),this._throttledUpdateRange=M.default.throttle(this._deferredUpdateRange,500),window.addEventListener("resize",this._throttledUpdateRange)}componentDidUpdate(){this._deferredUpdateRange()}componentWillUnmount(){window.removeEventListener("resize",this._throttledUpdateRange),this._isMounted=!1}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}W(Ar,"defaultProps",{passageNumber:1,referenceNumber:1,summaryText:""});var Rr={name:"passage-ref",displayName:"PassageRef (SAT only)",defaultAlignment:"inline",widget:Ar,transform:e=>({passageNumber:e.passageNumber,referenceNumber:e.referenceNumber,summaryText:e.summaryText}),version:{major:0,minor:1}};const{pureXsMax:Fr,pureSmMin:Or,pureSmMax:Dr,pureMdMin:Lr,pureMdMax:Br,pureLgMin:zr,pureLgMax:qr,pureXlMin:Hr}=Z;var Wr={xs:"@media screen and (max-width: ".concat(Fr,")"),sm:"@media screen and (min-width: ".concat(Or,") and ")+"(max-width: ".concat(Dr,")"),md:"@media screen and (min-width: ".concat(Lr,") and ")+"(max-width: ".concat(Br,")"),lg:"@media screen and (min-width: ".concat(zr,") and ")+"(max-width: ".concat(qr,")"),xl:"@media screen and (min-width: ".concat(Hr,")"),xsOrSmaller:"@media screen and (max-width: ".concat(Fr,")"),smOrSmaller:"@media screen and (max-width: ".concat(Dr,")"),mdOrSmaller:"@media screen and (max-width: ".concat(Br,")"),lgOrSmaller:"@media screen and (max-width: ".concat(qr,")"),smOrLarger:"@media screen and (min-width: ".concat(Or,")"),mdOrLarger:"@media screen and (min-width: ".concat(Lr,")"),lgOrLarger:"@media screen and (min-width: ".concat(zr,")"),xlOrLarger:"@media screen and (min-width: ".concat(Hr,")")};const{zIndexAboveScratchpad:Ur,zIndexInteractiveComponent:Gr,radioBorderColor:Vr,checkedColor:jr,circleSize:Yr,radioMarginWidth:$r}=Z;var Xr=l.StyleSheet.create({perseusInteractive:{zIndex:Gr,position:"relative"},aboveScratchpad:{position:"relative",zIndex:Ur},blankBackground:{backgroundColor:"#FDFDFD"},perseusSrOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1},responsiveLabel:{[Wr.smOrSmaller]:{fontSize:14,lineHeight:1.3},[Wr.md]:{fontSize:17,lineHeight:1.4},[Wr.lgOrLarger]:{fontSize:20,lineHeight:1.4}},responsiveInput:{display:"inline-block",WebkitAppearance:"none",appearance:"none","::-ms-check":{display:"none"},backgroundColor:"#fff",border:"2px solid #fff",boxShadow:"0 0px 0px 1px ".concat(Vr),outline:"none",boxSizing:"border-box",flexShrink:0,marginBottom:1,marginLeft:1,marginRight:1,marginTop:1,height:Yr-2,width:Yr-2},responsiveRadioInput:{borderRadius:"50%",":checked":{backgroundColor:jr,border:"none",borderRadius:"50%",boxShadow:"inset 0px 0px 0px 2px white, "+"0 0px 0px 2px ".concat(jr),marginTop:$r,marginBottom:$r,marginLeft:$r,marginRight:$r,height:Yr-2*$r,width:Yr-2*$r}},responsiveRadioInputActive:{backgroundColor:"#fff",border:"2px solid #fff",borderRadius:"50%",boxShadow:"0 0px 0px 2px ".concat(jr),marginTop:$r,marginBottom:$r,marginLeft:$r,marginRight:$r,height:Yr-2*$r,width:Yr-2*$r,":checked":{backgroundColor:"#fff"}},disableTextSelection:{userSelect:"none"}});"undefined"==typeof HTMLElement||HTMLElement.prototype.scrollTo||(HTMLElement.prototype.scrollTo=function(e,t){this.scrollLeft=e,this.scrollTop=t});const Kr=(e,t)=>{"function"==typeof e.scrollTo?e.scrollTo(0,t):"scrollTop"in e&&(e.scrollTop=t)},Zr=e=>e===document.body||null==e?window:e.scrollHeight>e.clientHeight?e:Zr(e.parentElement),Jr=(e,t)=>{setTimeout((()=>{const n=Zr(e),o=e.getBoundingClientRect(),s=n===window?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect();let i=0;const r=n===window?window.scrollY:n.scrollTop;if(o.bottom>s.bottom){let e=o.bottom-s.bottom;o.top+e<s.top&&(e=o.top-s.top),i=r+e}else if(o.top<s.top){i=r+(o.top-s.top)}!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;const s=e===window?window.pageYOffset:e.scrollTop,i=t,r=i-s,a=17,l=n/a;let c=0;const p=setInterval((function(){if(c<l){const t=c/l,n=(1-Math.cos(Math.PI*t))/2;Kr(e,s+r*n),c+=1}else Kr(e,i),clearInterval(p),o&&o()}),a)}(n,i,750,t)}),0)};class Qr extends _.Component{render(){const e={borderColor:this.props.visible?this.props.color:"transparent"};return _.createElement("span",{className:l.css(ea.ring),style:e},this.props.children)}}W(Qr,"defaultProps",{visible:!0,color:"#71B307"});const ea=l.StyleSheet.create({ring:{margin:"auto",display:"inline-block",borderRadius:"50%",borderWidth:2,padding:2,borderStyle:"solid"}});function ta(e){const t=S._("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z").split(" ");return e<t.length?t[e]:" "}class na extends _.Component{constructStyles(e,t,n){let o,s="#0084CE",i="#0084CE";return e?t?(s="#009900",i=n?j:"#009900",o=n?"#009900":j):n&&(s="#990000",i=j,o="#990000"):n&&(i=j,o="#0084CE"),{color:i,backgroundColor:o,borderColor:s}}render(){const{letter:e,a11yText:t,reviewMode:n,checked:o,correct:s,crossedOut:i}=this.props,{color:r,backgroundColor:a,borderColor:c}=this.constructStyles(n,s,o);return _.createElement("div",{className:l.css(ra.iconWrapper)},_.createElement("div",{className:l.css(ra.satCircle),style:{backgroundColor:a,borderColor:c}}),_.createElement("div",{style:{color:r},className:l.css(ra.letter)},_.createElement("span",{className:"perseus-sr-only"},t),_.createElement("span",{"aria-hidden":"true"},e)),i&&_.createElement(sa,{color:c,sat:!0}))}}class oa extends _.Component{getChoiceInner(){const{letter:e,showCorrectness:t,correct:n}=this.props;return t?n?_.createElement(G,U({},co,{style:{position:"relative",top:-1}})):_.createElement(G,_o):e}getDynamicStyles(){const{checked:e,showCorrectness:t,pressed:n,primaryProductColor:o,correct:s,transparentBackground:i}=this.props;if(!t&&n)return{borderColor:o,color:o,backgroundColor:i?"transparent":j};if(e){const e=t&&s?"#71B307":o;return{color:j,backgroundColor:e,borderColor:e}}return{borderColor:$,color:$}}render(){const{a11yText:e,checked:t,crossedOut:n,showCorrectness:o,correct:s,focused:i,primaryProductColor:r,previouslyAnswered:a}=this.props,c=this.getDynamicStyles();return _.createElement("div",{className:l.css(ra.iconWrapper)},_.createElement(Qr,{color:r,visible:i},_.createElement("div",{style:c,className:l.css(ra.libraryCircle,o&&s&&ra.libraryCircleCorrect,o&&!s&&ra.libraryCircleIncorrect,o&&!s&&(t||a)&&ra.libraryCircleIncorrectAnswered),"data-is-radio-icon":!0},_.createElement("div",{className:"perseus-sr-only"},e),_.createElement("div",{"aria-hidden":!0},this.getChoiceInner()))),n&&_.createElement(sa,{color:c.borderColor}))}}function sa(e){const t=e.sat?29:28;return _.createElement("svg",{width:t,height:t,viewBox:"0 0 ".concat(t," ").concat(t),className:l.css(ra.crossOutLine)},_.createElement("line",{x1:2,x2:t-2,y1:t-2,y2:2,stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}))}class ia extends _.Component{a11yText(e){const{checked:t,correct:n,crossedOut:o,showCorrectness:s}=this.props;return s&&n?t?S._("(Choice %(letter)s, Checked, Correct)",{letter:e}):o?S._("(Choice %(letter)s, Crossed out, Correct)",{letter:e}):S._("(Choice %(letter)s, Correct)",{letter:e}):s&&!n?t?S._("(Choice %(letter)s, Checked, Incorrect)",{letter:e}):o?S._("(Choice %(letter)s, Crossed out, Incorrect)",{letter:e}):S._("(Choice %(letter)s, Incorrect)",{letter:e}):t?S._("(Choice %(letter)s, Checked)",{letter:e}):o?S._("(Choice %(letter)s, Crossed out)",{letter:e}):S._("(Choice %(letter)s)",{letter:e})}render(){const{pos:e,reviewMode:t,checked:n,crossedOut:o,correct:s,product:i,showCorrectness:r,pressed:a,focused:l,primaryProductColor:c,previouslyAnswered:p,transparentBackground:d}=this.props,u=ta(e);return"sat"===i?_.createElement(na,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:n,correct:s,crossedOut:o}):_.createElement(oa,{letter:u,a11yText:this.a11yText(u),reviewMode:t,checked:n,crossedOut:o,pressed:a,focused:l,correct:s,showCorrectness:r,primaryProductColor:c,previouslyAnswered:p,transparentBackground:d})}}W(ia,"defaultProps",{primaryProductColor:"#71B307"});const ra=l.StyleSheet.create({satCircle:{display:"block",borderRadius:25,borderStyle:"solid",borderWidth:2,content:"''",height:25,width:25,top:1,left:1},iconWrapper:{display:"inline-block",position:"relative"},crossOutLine:{position:"absolute",top:"calc(50% - ".concat(14,"px)"),left:"calc(50% - ".concat(14,"px)")},libraryCircle:{width:24,height:24,boxSizing:"border-box",borderRadius:24,borderStyle:"solid",borderWidth:2,fontFamily:"'Proxima Nova',sans-serif",fontWeight:"bold",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1px"},libraryCircleCorrect:{fontSize:24},libraryCircleIncorrect:{fontSize:24,borderColor:$,color:$},libraryCircleIncorrectAnswered:{backgroundColor:"#F86700",borderColor:"#F86700",color:j},letter:{border:"2px solid transparent",width:25,height:25,position:"absolute",top:1,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:V,fontSize:13}});class aa extends _.Component{render(){const{color:e,pathClassName:t,className:n,title:o,style:s,alt:i}=this.props;let{icon:r,size:a}=this.props,l="";"string"==typeof r&&(r={path:r,width:10,height:10}),"number"!=typeof a&&(a=1,l="em");const c=a,p=c/r.height*r.width,d=!!this.props.focusable;return _.createElement("svg",{role:"img",alt:i,"aria-label":o,"aria-hidden":!o||null,className:n,style:s,focusable:d.toString(),width:p+l,height:c+l,viewBox:"".concat(0," ").concat(0," ").concat(r.width," ").concat(r.height)},!!o&&_.createElement("title",null,o),_.createElement("path",{className:t,fill:e,d:r.path}))}}function la(){return la=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},la.apply(this,arguments)}function ca(e,t){if(null==e)return{};var n,o,s={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(s[n]=e[n]);return s}W(aa,"defaultProps",{color:"currentColor"});const pa="@media (max-width: 1023px)",da="@media (min-width: 1024px)",ua={display:"block"},ha='Lato, "Noto Sans", sans-serif',fa=l.StyleSheet.create({Title:la({},ua,{fontFamily:ha,fontWeight:900,[da]:{fontSize:36,lineHeight:"40px"},[pa]:{fontSize:28,lineHeight:"32px"}}),Tagline:la({},ua,{fontFamily:ha,fontWeight:400,fontSize:20,lineHeight:"24px"}),HeadingLarge:la({},ua,{fontFamily:ha,fontWeight:700,[da]:{fontSize:28,lineHeight:"32px"},[pa]:{fontSize:24,lineHeight:"28px"}}),HeadingMedium:la({},ua,{fontFamily:ha,fontWeight:700,[da]:{fontSize:24,lineHeight:"28px"},[pa]:{fontSize:22,lineHeight:"26px"}}),HeadingSmall:la({},ua,{fontFamily:ha,fontWeight:700,fontSize:20,lineHeight:"24px"}),HeadingXSmall:la({},ua,{fontFamily:ha,fontWeight:700,fontSize:12,lineHeight:"16px",letterSpacing:.6,textTransform:"uppercase"}),BodySerifBlock:la({},ua,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:22,lineHeight:"28px"}),BodySerif:la({},ua,{fontFamily:'"Noto Serif", serif',fontWeight:400,fontSize:18,lineHeight:"22px"}),BodyMonospace:la({},ua,{fontFamily:"Inconsolata, monospace",fontWeight:400,fontSize:17,lineHeight:"22px"}),Body:la({},ua,{fontFamily:ha,fontWeight:400,fontSize:16,lineHeight:"22px"}),LabelLarge:la({},ua,{fontFamily:ha,fontWeight:700,fontSize:16,lineHeight:"20px"}),LabelMedium:la({},ua,{fontFamily:ha,fontWeight:400,fontSize:16,lineHeight:"20px"}),LabelSmall:la({},ua,{fontFamily:ha,fontWeight:400,fontSize:14,lineHeight:"18px"}),LabelXSmall:la({},ua,{fontFamily:ha,fontWeight:400,fontSize:12,lineHeight:"16px"}),Caption:la({},ua,{fontFamily:ha,fontWeight:400,fontSize:14,lineHeight:"20px"}),Footnote:la({},ua,{fontFamily:ha,fontWeight:400,fontSize:12,lineHeight:"18px"})}),ma=["style","children"];class ga extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,ma);return _.createElement(m.Text,la({},o,{style:[fa.Title,t]}),n)}}ga.defaultProps={tag:"h1"};const va=["style","children"];class ya extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,va);return _.createElement(m.Text,la({},o,{style:[fa.HeadingLarge,t]}),n)}}ya.defaultProps={tag:"h2"};const ba=["style","children"];class xa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,ba);return _.createElement(m.Text,la({},o,{style:[fa.HeadingMedium,t]}),n)}}xa.defaultProps={tag:"h3"};const wa=["style","children"];class Ca extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,wa);return _.createElement(m.Text,la({},o,{style:[fa.HeadingSmall,t]}),n)}}Ca.defaultProps={tag:"h4"};const ka=["style","children"];class Sa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,ka);return _.createElement(m.Text,la({},o,{style:[fa.HeadingXSmall,t]}),n)}}Sa.defaultProps={tag:"h4"};const Ea=["style","children"];class _a extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Ea);return _.createElement(m.Text,la({},o,{style:[fa.BodySerifBlock,t]}),n)}}_a.defaultProps={tag:"span"};const Ta=["style","children"];class Ma extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Ta);return _.createElement(m.Text,la({},o,{style:[fa.BodySerif,t]}),n)}}Ma.defaultProps={tag:"span"};const Ia=["style","children"];class Pa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Ia);return _.createElement(m.Text,la({},o,{style:[fa.BodyMonospace,t]}),n)}}Pa.defaultProps={tag:"span"};const Na=["style","children"];class Aa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Na);return _.createElement(m.Text,la({},o,{style:[fa.Body,t]}),n)}}Aa.defaultProps={tag:"span"};const Ra=["style","children"];class Fa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Ra);return _.createElement(m.Text,la({},o,{style:[fa.LabelLarge,t]}),n)}}Fa.defaultProps={tag:"span"};const Oa=["style","children"];class Da extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Oa);return _.createElement(m.Text,la({},o,{style:[fa.LabelMedium,t]}),n)}}Da.defaultProps={tag:"span"};const La=["style","children"];class Ba extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,La);return _.createElement(m.Text,la({},o,{style:[fa.LabelSmall,t]}),n)}}Ba.defaultProps={tag:"span"};const za=["style","children"];class qa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,za);return _.createElement(m.Text,la({},o,{style:[fa.LabelXSmall,t]}),n)}}qa.defaultProps={tag:"span"};const Ha=["style","children"];class Wa extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Ha);return _.createElement(m.Text,la({},o,{style:[fa.Tagline,t]}),n)}}Wa.defaultProps={tag:"span"};const Ua=["style","children"];class Ga extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Ua);return _.createElement(m.Text,la({},o,{style:[fa.Caption,t]}),n)}}Ga.defaultProps={tag:"span"};const Va=["style","children"];class ja extends _.Component{render(){const e=this.props,{style:t,children:n}=e,o=ca(e,Va);return _.createElement(m.Text,la({},o,{style:[fa.Footnote,t]}),n)}}ja.defaultProps={tag:"span"};var Ya=Object.freeze({__proto__:null,black:"#000000",grayDarker:"#333333",grayDark:"#555555",gray:"#999999",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",white:"#FFFFFF",blue:"#005A88",blueDark:"#2C3747",green:"#76A005",red:"#CF5044",yellow:"#FFC40D",orange:"#BF4F04",pink:"#C3325F",purple:"#7A43B6",bodyBackground:"#FFFFFF",textColor:"#444444",linkColor:"#005987",linkColorHover:"#678D00",sansFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",serifFontFamily:"Georgia,'Times New Roman',Times,serif",monoFontFamily:"Monaco,Menlo,Consolas,'Courier New',monospace",baseFontSize:"14px",baseFontFamily:"inherit",baseLineHeight:"20px",altFontFamily:"Georgia,'Times New Roman',Times,serif",headingsFontFamily:"inherit",headingsFontWeight:"bold",headingsColor:"inherit",fontSizeLarge:"18px",fontSizeSmall:"12px",fontSizeMini:"10.5px",paddingLarge:"11px 19px",paddingSmall:"2px 10px",paddingMini:"0 6px",baseBorderRadius:"4px",borderRadiusLarge:"6px",borderRadiusSmall:"3px",tableBackground:"#000000",tableBackgroundAccent:"#F9F9F9",tableBackgroundHover:"#F5F5F5",tableBorder:"#DDDDDD",btnBackground:"#FFFFFF",btnBackgroundHighlight:"rgb(230, 230, 230)",btnBorder:"#CCCCCC",btnPrimaryBackground:"#0088CC",btnPrimaryBackgroundHighlight:"rgb(0, 68, 204)",btnInfoBackground:"#5BC0DE",btnInfoBackgroundHighlight:"#2F96B4",btnSuccessBackground:"#62C462",btnSuccessBackgroundHighlight:"#51A351",btnWarningBackground:"rgb(251, 180, 81)",btnWarningBackgroundHighlight:"#F89406",btnDangerBackground:"#EE5F5B",btnDangerBackgroundHighlight:"#BD362F",btnInverseBackground:"#444444",btnInverseBackgroundHighlight:"#222222",inputBackground:"#FFFFFF",inputBorder:"#CCCCCC",inputBorderRadius:"4px",inputDisabledBackground:"#EEEEEE",formActionsBackground:"#F5F5F5",inputHeight:"30px",dropdownBackground:"#FFFFFF",dropdownBorder:"rgba(0, 0, 0, 0.2)",dropdownDividerTop:"#E5E5E5",dropdownDividerBottom:"#FFFFFF",dropdownLinkColor:"#333333",dropdownLinkColorHover:"#FFFFFF",dropdownLinkColorActive:"#FFFFFF",dropdownLinkBackgroundActive:"#0088CC",dropdownLinkBackgroundHover:"#0088CC",zindexDropdown:1e3,zindexPopover:1010,zindexTooltip:1030,zindexFixedNavbar:1030,zindexHeader:1060,zindexModalBackdrop:1070,zindexModal:1080,zindexAboveModal:1090,iconSpritePath:"../img/glyphicons-halflings.png",iconWhiteSpritePath:"../img/glyphicons-halflings-white.png",placeholderText:"#999999",hrBorder:"#EEEEEE",horizontalComponentOffset:"180px",wellBackground:"#F5F5F5",navbarCollapseWidth:"979px",navbarCollapseDesktopWidth:"980px",navbarHeight:"40px",navbarBackgroundHighlight:"#FFFFFF",navbarBackground:"rgb(242, 242, 242)",navbarBorder:"rgb(212, 212, 212)",navbarText:"#777777",navbarLinkColor:"#777777",navbarLinkColorHover:"#333333",navbarLinkColorActive:"#555555",navbarLinkBackgroundHover:"#000000",navbarLinkBackgroundActive:"rgb(230, 230, 230)",navbarBrandColor:"#777777",navbarInverseBackground:"#111111",navbarInverseBackgroundHighlight:"#222222",navbarInverseBorder:"#252525",navbarInverseText:"#999999",navbarInverseLinkColor:"#999999",navbarInverseLinkColorHover:"#FFFFFF",navbarInverseLinkColorActive:"#FFFFFF",navbarInverseLinkBackgroundHover:"#000000",navbarInverseLinkBackgroundActive:"#111111",navbarInverseSearchBackground:"rgb(82, 82, 82)",navbarInverseSearchBackgroundFocus:"#FFFFFF",navbarInverseSearchBorder:"#111111",navbarInverseSearchPlaceholderColor:"#CCCCCC",navbarInverseBrandColor:"#999999",paginationBackground:"#FFFFFF",paginationBorder:"#DDDDDD",paginationActiveBackground:"#F5F5F5",heroUnitBackground:"#EEEEEE",heroUnitHeadingColor:"inherit",heroUnitLeadColor:"inherit",warningText:"#C09853",warningBackground:"#FCF8E3",warningBorder:"rgb(251, 239, 213)",errorText:"#B94A48",errorBackground:"#F2DEDE",errorBorder:"rgb(238, 211, 215)",successText:"#468847",successBackground:"#DFF0D8",successBorder:"rgb(212, 232, 197)",infoText:"#4A7C17",infoBackground:"#EDF2DF",infoBorder:"rgb(228, 232, 197)",tooltipColor:"#FFFFFF",tooltipBackground:"#000000",tooltipArrowWidth:"5px",tooltipArrowColor:"#000000",popoverBackground:"#FFFFFF",popoverArrowWidth:"10px",popoverArrowColor:"#FFFFFF",popoverTitleBackground:"rgb(247, 247, 247)",popoverArrowOuterWidth:"11px",popoverArrowOuterColor:"rgba(0, 0, 0, 0.25)",gridColumns:"12",gridColumnWidth:"60px",gridGutterWidth:"20px",gridRowWidth:"940px",gridColumnWidth1200:"70px",gridGutterWidth1200:"30px",gridRowWidth1200:"1170px",gridColumnWidth768:"42px",gridGutterWidth768:"20px",gridRowWidth768:"724px",fluidGridColumnWidth:"6.382978723404255%",fluidGridGutterWidth:"2.127659574468085%",fluidGridColumnWidth1200:"5.982905982905983%",fluidGridGutterWidth1200:"2.564102564102564%",fluidGridColumnWidth768:"5.801104972375691%",fluidGridGutterWidth768:"2.7624309392265194%",kaGreen:"#71B307",kaGreenLight:"#BED47A",kaBlue:"#314453",kaBlueLight:"#4D6779",grayExtraDark:"#111111",grayExtraLight:"#EEEEEE",graySuperLight:"#F7F7F7",whiteDark:"#FDFDFD",dark:"#21242C",blueDarkUnsaturated:"#3B414E",blueDarkSaturated:"#1F3043",blueLight:"#A9C0D1",greenLight:"#C6D1AD",greenDark:"#356700",yellowGreen:"#9DB63B",okGreen:"#A7CF5B",alertRed:"#C42420",coral:"#EE6666",grayBlue:"#9AB3B9",lightPageBackground:"#FDFDFD",yclaBlue:"#49BAD5",yclaTeal:"#56D0B3",yclaTealDark:"#50C1A7",yclaGreenDark:"#3D9A82",yclaGreen:"#81C262",learnstormBlue:"#4898FC",homepageBlue:"#46A8BF",backgroundBlue:"#00294A",teacherSignupBlue:"#335d7d",homepageGreen:"#2B8E7B",streakColor:"#F79734",facebookColor:"#1A60A2",blueGoogleColor:"#2CAFE2",redGoogleColor:"#BF4434",homepageColor:"#2D585E",lightTextColor:"#898989",fontSizeTiny:"11px",fontSizeNormal:"14px",fontSizeMedium:"16px",fontSizeExtraLarge:"24px",fontSizeHuge:"36px",fontSizeBakana:"48px",fontSizeBananas:"60px",fixedWidthFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",contentPadding:"20px",primaryButtonBackground:"#89B908",primaryButtonBorder:"#76A005",buttonTextColor:"rgb(122, 122, 122)",buttonBorderRadius:"3px",basicBorderColor:"#CCCCCC",minContainerWidth:"1000px",maxContainerWidth:"1200px",formHintColor:"#999999",guidelineExampleText:"#606060",hoverCardWidth:"450px",menuHighlightColor:"#96AB4F",menuHighlightBorderColor:"#76A005",menuActiveTextColor:"#FFFFFF",menuInactiveTextColor:"#444444",menuSubheaderTextColor:"rgb(120, 120, 120)",menuBorderColor:"#94A170",unreadBackgroundColor:"#ECEEF4",menuLineHeight:"18px",menuSubheaderLineHeight:"17px",menuSubheaderFontSize:"9px",notificationBarColor:"#4858A4",modalBodyTopPadding:"20px",modalDialogPadding:"15px",modalSectionPadding:"9px",mathDomain1:"#11ACCD",mathDomain2:"#63D9EA",mathDomain3:"#027d97",mathDomain4:"#085566",partnerContentDomain1:"#01A995",partnerContentDomain2:"#01D1C1",partnerContentDomain3:"#208170",partnerContentDomain4:"#144F44",csDomain1:"#1FAB54",csDomain2:"#74CF70",csDomain3:"#0D923F",csDomain4:"#085E29",economicsDomain1:"#E07D10",economicsDomain2:"#FFBE26",economicsDomain3:"#A75A05",economicsDomain4:"#953C02",collegeCareersMoreDomain1:"#01A995",collegeCareersMoreDomain2:"#01D1C1",collegeCareersMoreDomain3:"#208170",collegeCareersMoreDomain4:"#144F44",humanitiesDomain1:"#E84D39",humanitiesDomain2:"#FF8482",humanitiesDomain3:"#BE2612",humanitiesDomain4:"#8C1C0D",gtpDomain1:"#1865F2",gtpDomain2:"#1865F2",gtpDomain3:"#1865F2",gtpDomain4:"#1865F2",scienceDomain1:"#CA337C",scienceDomain2:"#FF92C6",scienceDomain3:"#9E034E",scienceDomain4:"#6B0235",testPrepDomain1:"#1865F2",testPrepDomain2:"#1865F2",testPrepDomain3:"#1865F2",testPrepDomain4:"#1865F2",defaultDomain1:"#1865F2",defaultDomain2:"#66afe9",defaultDomain3:"#1152b0",defaultDomain4:"#0d3d82",defaultDomainColor:"#314453",defaultSubjectColor:"#4D6779",defaultTopicColor:"#6A8DA6",defaultHoverColor:"#314453",defaultLinkColor:"#314453",defaultLinkHoverColor:"#6A8DA6",scienceDomainColor:"#94424F",scienceSubjectColor:"#9D4A5A",scienceTopicColor:"#C55F73",scienceHoverColor:"#94424F",scienceLinkColor:"#94424F",scienceLinkHoverColor:"#C55F73",humanitiesDomainColor:"#AD3434",humanitiesSubjectColor:"#C13B31",humanitiesTopicColor:"#D24A45",humanitiesHoverColor:"#AD3434",humanitiesLinkColor:"#AD3434",humanitiesLinkHoverColor:"#D24A45",economicsDomainColor:"#B77033",economicsSubjectColor:"#BF7B34",economicsTopicColor:"#D1933B",economicsHoverColor:"#B77033",economicsLinkColor:"#B77033",economicsLinkHoverColor:"#D1933B",csDomainColor:"#437A39",csSubjectColor:"#53893E",csTopicColor:"#689B51",csHoverColor:"#437A39",csLinkColor:"#437A39",csLinkHoverColor:"#689B51",partnerContentDomainColor:"#218270",partnerContentSubjectColor:"#2C8D7B",partnerContentTopicColor:"#329A86",partnerContentHoverColor:"#218270",partnerContentLinkColor:"#218270",partnerContentLinkHoverColor:"#329A86",essayDomainColor:"#0071B3",mathDomainColor:"#1C758A",mathSubjectColor:"#46A8BF",mathTopicColor:"#4FBAD4",mathHoverColor:"#1C758A",mathLinkColor:"#1C758A",mathLinkHoverColor:"#4FBAD4",testPrepDomainColor:"#644172",testPrepSubjectColor:"#7E5F8E",testPrepTopicColor:"#9A72AC",testPrepHoverColor:"#644172",testPrepLinkColor:"#644172",testPrepLinkHoverColor:"#9A72AC",collegeCareersMoreDomainColor:"#218270",collegeCareersMoreSubjectColor:"#2C8D7B",collegeCareersMoreTopicColor:"#329A86",collegeCareersMoreHoverColor:"#218270",collegeCareersMoreLinkColor:"#218270",collegeCareersMoreLinkHoverColor:"#329A86",satDomainColor:"#0084CE",satSubjectColor:"#0084CE",satTopicColor:"#0084CE",satHoverColor:"#0084CE",satLinkColor:"#0084CE",satLinkHoverColor:"#0084CE",colorProficient:"#1C758A",colorPracticed:"rgb(158, 221, 235)",colorMastery1:"rgb(90, 197, 221)",colorMastery2:"rgb(42, 174, 203)",colorMastery3:"#1C758A",colorSuggested:"#73982C",colorReview:"#E35D04",colorNotStarted:"#CCCCCC",colorStarted:"#C7E5F7",colorStruggling:"#C30202",colorPersonal:"#00809C",colorPractice:"#96D9FF",colorEnergyPoints:"#005987",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1200px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1199px"});const $a={white:"#FFFFFF",gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:"#BABEC2",gray72:"#999A9D",gray68:"#888D93",gray55:"#707378",gray41:"#626569",gray25:"#3B3E40",gray17:"#21242C",gray10:"#1499af",black:"#000000",alertRed:"#C42420",homepageBlue:"#46A8BF",kaBlue:"#314453",kaBlueLight:"#4D6779",kaGreen:"#71B307",kaGreenLight:"#BED47A",learnstormBlue:"#4898FC",backgroundBlue:"#00294A",adminGreen:"#78C008",kaBlueExtraLight:"#39c2db",kaBlueHover:"#0c7f99",kaGreenHover:"#518005",skyDark:"#001f4d",recommendationGold:"#ffbe26",starAced:"#ff9c39",google:"#C1432f",modernGoogle:"#be2612",modernGoogleHover:"#8c1c0d",facebook:"#4267B2",modernFacebook:"#4267B2",modernFacebookHover:"#00294a",wonderBlocksGold:"#FFB100",wonderBlocksLightBlue:"#37C5FD",breadcrumbs:"rgba(255, 255, 255, 0.7)"},Xa={color:$a.breadcrumbs,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased"},Ka={regular:"inherit"},Za={subjectHeadingDesktop:{fontFamily:"inherit",fontSize:50,fontWeight:"bold",lineHeight:"61px"},subjectHeadingMobile:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingDesktop:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingMobile:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingDesktop:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingMobile:{fontFamily:"inherit",fontSize:20,fontWeight:"bold",lineHeight:"24px"},smallSubheadingDesktop:{fontFamily:"inherit",fontSize:20,lineHeight:1.25},smallSubheadingMobile:{fontFamily:"inherit",fontSize:15,lineHeight:1.25},smallHeading:{color:$a.gray25,fontFamily:"inherit",fontSize:17,fontWeight:"bold",lineHeight:"23px"},smallHeadingMobile:{color:$a.gray25,fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},accentHeading:{color:$a.gray68,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase"},bodyLarge:{fontFamily:Ka.regular,fontSize:20,lineHeight:"30px"},bodySmall:{fontFamily:Ka.regular,fontSize:17,fontWeight:"normal",lineHeight:"23px"},bodySmallBold:{fontFamily:Ka.regular,fontSize:17,fontWeight:"bold",lineHeight:"23px"},bodyXsmall:{fontFamily:Ka.regular,fontSize:15,lineHeight:"22px"},bodyXsmallBold:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"22px"},breadcrumb:Xa,breadcrumbSmall:{...Xa,fontSize:12,lineHeight:"13px"},labelLarge:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},labelMedium:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},labelSmall:{fontFamily:Ka.regular,fontSize:12,lineHeight:"14px"},caption:{fontFamily:Ka.regular,fontSize:14,fontStyle:"italic",lineHeight:"17px"},desktopScalingOnMobile:{MozTextSizeAdjust:"100%",MsTextSizeAdjust:"100%",WebkitTextSizeAdjust:"100%"},modalSubtitle:{fontSize:12,lineHeight:1.65,WebkitFontSmoothing:"antialiased",fontWeight:"bold"},wonderBlocksHeader:{paddingLeft:16,paddingRight:16,paddingBottom:24,paddingTop:34,[Wr.mdOrLarger]:{paddingBottom:32}},wonderBlocksTitle:{color:$a.white,fontWeight:900,fontSize:28,lineHeight:"32px",margin:0,[Wr.mdOrLarger]:{fontSize:36,lineHeight:"40px"}},wonderBlocksLabelLarge:{fontSize:16,lineHeight:"20px",fontWeight:700}};var Ja=Object.freeze({__proto__:null,colors:$a,borderRadius:4,fonts:Ka,typography:Za});class Qa extends _.PureComponent{constructor(){super(...arguments),W(this,"_handleTooltipButtonRef",(e=>{e&&this.props.usingKeyboardFocus&&e.focus()}))}_getAriaLabel(){const{crossedOut:e,pos:t}=this.props,n=ta(t);return e?S._("Bring back Choice %(letter)s",{letter:n}):S._("Cross out Choice %(letter)s",{letter:n})}render(){const{crossedOut:e,pos:t,primaryProductColor:n,theme:o}=this.props,s="day"===o?n:D.default.white;return _.createElement("button",{type:"button","aria-label":this._getAriaLabel(),className:l.css([el.tooltipButton]),onClick:()=>this.props.onClick(),onMouseDown:e=>e.preventDefault(),onFocus:()=>this.props.onFocus(),onBlur:()=>this.props.onBlur(),disabled:this.props.disabled,tabIndex:this.props.tabFocusable?0:-1,ref:this._handleTooltipButtonRef},_.createElement(ia,{pos:t,product:"library",crossedOut:!this.props.crossedOut,primaryProductColor:s,pressed:!0,checked:!1,focused:!1,correct:!1,showCorrectness:!1,reviewMode:!1,previouslyAnswered:!1,transparentBackground:!0}),_.createElement(Fa,{style:{color:s}},e?S._("Bring back"):S._("Cross out")))}}W(Qa,"defaultProps",{primaryProductColor:$a.kaGreen});const el=l.StyleSheet.create({tooltipButton:{background:"none",border:"none",font:"inherit",padding:0,cursor:"pointer",textDecoration:"none",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"}});class tl{constructor(e,t,n){W(this,"_intersectionObserver",void 0),W(this,"_onVisibilityChange",void 0),W(this,"_handleIntersection",(e=>{for(const t of e)this._onVisibilityChange(t.isIntersecting,t.rootBounds)})),this._intersectionObserver=new IntersectionObserver(this._handleIntersection,{root:e,threshold:Number.EPSILON,rootMargin:n}),this._onVisibilityChange=t}setTargetElement(e){this._intersectionObserver.disconnect(),this._intersectionObserver.observe(e)}disconnect(){this._intersectionObserver.disconnect()}}class nl extends _.PureComponent{render(){const{direction:e,pxFromStart:t,pxFromEnd:n}=this.props,o=[ol.wrapper,"horizontal"===e&&ol.wrapperHorizontal,"vertical"===e&&ol.wrapperVertical],s=[ol.content,"horizontal"===e&&ol.contentHorizontal,"vertical"===e&&ol.contentVertical];return 0===t?_.createElement("div",{className:l.css(...o)},_.createElement("div",{className:l.css(...s)},this.props.children)):0===n?_.createElement("div",{className:l.css(...o,ol.wrapperAlignToEnd)},_.createElement("div",{className:l.css(...s)},this.props.children)):_.createElement("div",{className:l.css(...o)},_.createElement("div",{style:{flexShrink:n,flexBasis:t}}),_.createElement("div",{className:l.css(...s)},this.props.children),_.createElement("div",{style:{flexShrink:t,flexBasis:n}}))}}const ol=l.StyleSheet.create({wrapper:{display:"flex",overflow:"hidden"},wrapperHorizontal:{flexDirection:"row",width:"100%"},wrapperVertical:{flexDirection:"column",height:"100%"},wrapperAlignToEnd:{justifyContent:"flex-end"},content:{flex:"0 0 auto"},contentHorizontal:{maxWidth:"100%"},contentVertical:{maxHeight:"100%"}}),sl=parseInt("6px");function il(e){const{color:t,inverted:n}=e;return n?{backgroundColor:t,textColor:D.default.white}:{backgroundColor:D.default.white,textColor:t}}class rl extends _.PureComponent{render(){const{onClick:e,onMouseEnter:t,onMouseLeave:n,side:o}=this.props.tooltipProps,{backgroundColor:s}=il(this.props.tooltipProps);let i,r,a;if("top"===o)i=["0,0","".concat(9,",").concat(9),"".concat(18,",0")],r=18,a=9;else if("right"===o)i=["".concat(9,",0"),"0,".concat(9),"".concat(9,",").concat(18)],r=9,a=18;else if("bottom"===o)i=["0,".concat(9),"".concat(9,",0"),"".concat(18,",").concat(9)],r=18,a=9;else{if("left"!==o)throw new re("unexpected side ".concat(o),se.InvalidInput);i=["0,0","".concat(9,",").concat(9),"0,".concat(18)],r=9,a=18}return _.createElement("svg",{width:r,height:a,className:l.css(al.tooltipArrow)},_.createElement("filter",{id:"tooltip-dropshadow-".concat(o),height:"150%"},_.createElement("feOffset",{dx:0,dy:1,result:"offsetblur"}),_.createElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:2}),_.createElement("feComponentTransfer",null,_.createElement("feFuncA",{type:"linear",slope:.1})),_.createElement("feMerge",null,_.createElement("feMergeNode",null),_.createElement("feMergeNode",{in:"SourceGraphic"}))),_.createElement("polyline",{fill:s,stroke:s,points:i.join(" "),className:l.css(e&&al.tooltipArrowShapeWithOnClick),onClick:e,onMouseEnter:t,onMouseLeave:n}),_.createElement("polyline",{fill:s,points:i.join(" "),stroke:"rgba(0, 0, 0, 0.1)",filter:"url(#tooltip-dropshadow-".concat(o,")")}))}}const al=l.StyleSheet.create({tooltipArrow:{display:"block",userSelect:"none"},tooltipArrowShapeWithOnClick:{pointerEvents:"auto",cursor:"pointer"}});var ll=l.StyleSheet.create({srOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1}});class cl extends _.PureComponent{constructor(){super(...arguments),W(this,"_handleClickClose",(()=>this.props.dismiss()))}_renderCloseButton(e){const{inverted:t,dismissOnClickClose:n}=this.props.tooltipProps;if(!n)return null;const o=e.get("button-description"),s=this.getA11yHeaderId(e);return _.createElement("button",{className:l.css(pl.closeIcon),onClick:this._handleClickClose,"aria-describedby":"".concat(o," ").concat(s)},_.createElement(aa,{title:S._("Close"),icon:"M6.26353762,4.99851587 L9.73097464,1.53107884 C10.0836373,1.17841618 10.0842213,0.612127047 9.73530496,0.263210718 C9.38395604,-0.0881381913 8.81874474,-0.0837668714 8.46743686,0.267541014 L4.99999981,3.73497806 L1.5325628,0.267541051 C1.1812549,-0.0837668481 0.616043606, -0.0881381955 0.264694717,0.263210694 C-0.0842215912,0.612127004 -0.0836375768,1.17841613 0.269025093,1.5310788 L3.73646206,4.9985158 L0.269025109,8.46595276 C-0.083637537,8.81861541 -0.0842215923, 9.38490462 0.264694642,9.73382106 C0.616043456,10.0851701 1.18125469, 10.0807988 1.53256259,9.72949093 L4.99999988,6.26205363 L8.46743739, 9.72949117 C8.8187453,10.0807991 9.38395655,10.0851704 9.73530537, 9.73382138 C10.0842216,9.38490498 10.0836375,8.81861579 9.73097488, 8.46595313 L6.26353762,4.99851587 Z",size:10,color:t?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.15)"}),_.createElement("div",{id:o,className:l.css(ll.srOnly)},S._("Closes the tooltip: ")))}getA11yHeaderId(e){const{tooltipProps:{a11y:t}}=this.props;return t&&t.title?"string"==typeof t.title?e.get("header"):t.title.id:this.getA11yContentId(e)}getA11yContentId(e){return e.get("content")}renderTooltip(e){const{content:t,dismissOnClickClose:n,noPadding:o,onClick:s,onMouseEnter:i,onMouseLeave:r,a11y:a,testId:c}=this.props.tooltipProps,p=a&&a.title,d=a&&a.assertiveness,{backgroundColor:u,textColor:h}=il(this.props.tooltipProps),f=this.getA11yHeaderId(e),m=this.getA11yContentId(e);return _.createElement("div",{className:l.css(pl.tooltipBubble,!o&&pl.tooltipBubbleWithPadding,n&&pl.tooltipBubbleWithCloseIcon,s&&pl.tooltipBubbleWithOnClick),onClick:s,onMouseEnter:i,onMouseLeave:r,style:{backgroundColor:u,color:h},role:"region","aria-labelledby":f,"aria-describedby":m===f?null:m,"data-test-id":c},this._renderCloseButton(e),_.createElement("div",{"aria-live":d},"string"==typeof p?_.createElement("div",{className:l.css(ll.srOnly),id:f},p):null,_.createElement("div",{id:m,className:l.css(pl.tooltipContent)},t)))}render(){return _.createElement(m.UniqueIDProvider,{mockOnFirstRender:!1,scope:"tooltip-bubble"},(e=>this.renderTooltip(e)))}}const pl=l.StyleSheet.create({tooltipBubble:{boxSizing:"border-box",position:"relative",...Za.labelMedium,borderRadius:sl,border:"1px solid rgba(0, 0, 0, 0.1)",boxShadow:"".concat(0,"px ").concat(1,"px ")+"".concat(4,"px 0px ")+"rgba(0, 0, 0, ".concat(.1,")"),userSelect:"none"},tooltipBubbleWithPadding:{padding:"10px 23px"},tooltipBubbleWithCloseIcon:{paddingRight:34},tooltipBubbleWithOnClick:{cursor:"pointer"},tooltipContent:{userSelect:"auto"},closeIcon:{display:"block",position:"absolute",right:10,top:10,padding:0,background:"inherit",border:"none"}});class dl extends _.PureComponent{constructor(){super(...arguments),W(this,"_mountRemeasureTimeout",void 0),W(this,"state",{targetElementClientRect:null,rootElementClientRect:null}),W(this,"_handleScroll",(e=>{const{rootElement:t,targetElement:n}=this.props,o=e.target;t.contains(o)&&o.contains(n)&&this.remeasure()})),W(this,"remeasure",(()=>{const{targetElement:e,rootElement:t}=this.props;this.setState({targetElementClientRect:e.getBoundingClientRect(),rootElementClientRect:t.getBoundingClientRect()})}))}componentDidMount(){this._mountRemeasureTimeout=setTimeout(this.remeasure,0),window.addEventListener("resize",this.remeasure),window.addEventListener("scroll",this._handleScroll,!0)}componentWillUnmount(){this._mountRemeasureTimeout&&clearTimeout(this._mountRemeasureTimeout),window.removeEventListener("resize",this.remeasure),window.removeEventListener("scroll",this._handleScroll,!0)}_computeTargetPointOffsets(e,t){const{offset:n,offsetFrom:o,side:s}=this.props.tooltipProps,i=e,r=t;let a,l=n;if("arrow"===o&&(l+=9),"top"===s)a={left:i.left+i.width/2,top:i.top-l};else if("bottom"===s)a={left:i.left+i.width/2,top:i.bottom+l};else if("left"===s)a={left:i.left-l,top:i.top+i.height/2};else{if("right"!==s)throw new re("unexpected side ".concat(s),se.InvalidInput);a={left:i.right+l,top:i.top+i.height/2}}return{pxFromTop:a.top-r.top,pxFromBottom:r.bottom-a.top,pxFromLeft:a.left-r.left,pxFromRight:r.right-a.left}}_renderBubble(e){const{isAboveModal:t}=this.props,{side:n,tooltipMargin:o}=this.props.tooltipProps;let s;const i={},r={},a={};if("top"===n||"bottom"===n)s=ul.tooltipBubblePositionerTopBottom,r.direction="horizontal",r.pxFromStart=e.pxFromLeft,r.pxFromEnd=e.pxFromRight,a.marginLeft=o,a.marginRight=o;else{if("left"!==n&&"right"!==n)throw new re("unexpected side ".concat(n),se.InvalidInput);s=ul.tooltipBubblePositionerLeftRight,r.direction="vertical",r.pxFromStart=e.pxFromTop,r.pxFromEnd=e.pxFromBottom,a.marginTop=o,a.marginBottom=o}if("top"===n)i.bottom=e.pxFromBottom;else if("bottom"===n)i.top=e.pxFromTop;else if("left"===n)i.right=e.pxFromRight;else{if("right"!==n)throw new re("unexpected side ".concat(n),se.InvalidInput);i.left=e.pxFromLeft}return _.createElement("div",{className:l.css(ul.tooltipBubblePositioner,s,t&&ul.tooltipAboveModal),style:i},_.createElement(nl,r,_.createElement("div",{className:l.css(ul.tooltipBubbleWrapper),style:a},_.createElement(cl,{tooltipProps:this.props.tooltipProps,dismiss:this.props.dismiss}))))}_renderArrow(e,t){const{isAboveModal:n}=this.props,{side:o,tooltipMargin:s}=this.props.tooltipProps,i={};if("top"===o)i.bottom=e.pxFromBottom-9+1;else if("bottom"===o)i.top=e.pxFromTop-9+1;else if("left"===o)i.right=e.pxFromRight-9+1;else{if("right"!==o)throw new re("unexpected side ".concat(o),se.InvalidInput);i.left=e.pxFromLeft-9+1}const r=s+sl;if("top"===o||"bottom"===o){const n=r,o=t.width-18-r;i.left=e.pxFromLeft-9,i.left=Math.min(i.left,o),i.left=Math.max(i.left,n)}else{if("left"!==o&&"right"!==o)throw new re("unexpected side ".concat(o),se.InvalidInput);{const n=r,o=t.height-18-r;i.top=e.pxFromTop-9,i.top=Math.min(i.top,o),i.top=Math.max(i.top,n)}}return _.createElement("div",{className:l.css(ul.tooltipArrowPositioner,n&&ul.tooltipAboveModal),style:i},_.createElement(rl,{tooltipProps:this.props.tooltipProps}))}_buildMediaFilterStyle(){const{media:e}=this.props.tooltipProps;if(!e)return null;return l.StyleSheet.create({mediaFilter:{display:"none",[e]:{display:"block"}}}).mediaFilter}render(){const{targetElementClientRect:e,rootElementClientRect:t}=this.state;if(!e||!t)return null;const n=this._computeTargetPointOffsets(e,t);return _.createElement("div",{className:l.css(this._buildMediaFilterStyle())},this._renderBubble(n),this._renderArrow(n,t))}}const ul=l.StyleSheet.create({tooltipBubblePositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"},tooltipAboveModal:{zIndex:1090},tooltipBubblePositionerTopBottom:{left:0,width:"100%"},tooltipBubblePositionerLeftRight:{top:0,height:"100%"},tooltipBubbleWrapper:{pointerEvents:"auto"},tooltipArrowPositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"}});class hl extends _.Component{constructor(){super(...arguments),W(this,"_mountNode",void 0),W(this,"_tooltipPositioner",void 0)}componentDidMount(){const e=document.createElement("div");this._mountNode=e,this.props.rootElement.appendChild(e),this._renderInMountNode(e)}componentDidUpdate(){const e=this._mountNode;e&&this._renderInMountNode(e)}componentWillUnmount(){const e=this._mountNode;e&&(N.default.unmountComponentAtNode(e),this.props.rootElement.removeChild(e))}remeasure(){this._tooltipPositioner&&this._tooltipPositioner.remeasure()}_renderInMountNode(e){const{tooltipProps:t,dismiss:n,rootElement:o,targetElement:s,isAboveModal:i}=this.props;N.default.render(_.createElement(dl,{tooltipProps:t,dismiss:n,rootElement:o,targetElement:s,isAboveModal:i,ref:e=>this._tooltipPositioner=e}),e)}render(){return null}}const fl=Object.freeze({side:"top",offset:0,offsetFrom:"bubble",tooltipMargin:0,noPadding:!1,color:$a.gray17,inverted:!1,dismissOnClickClose:!1,toggleOnHover:!0,showOnMount:!1});class ml extends _.PureComponent{constructor(e){super(e),W(this,"_rootElement",void 0),W(this,"_wrapper",void 0),W(this,"_targetElement",void 0),W(this,"_tooltipPortal",void 0),W(this,"_visibilityObserver",void 0),W(this,"_isMounted",void 0),W(this,"_targetElementMountTimeout",void 0),W(this,"_handleVisibilityChange",(e=>{this.setState({targetElementIsVisible:e})})),W(this,"_handleMouseEnter",(()=>{this.setState({hovered:!0})})),W(this,"_handleMouseLeave",(()=>{this.setState({hovered:!1})})),W(this,"_handleDismiss",(()=>{null==this.props.dismissed&&this.setState({dismissed:!0}),this.props.onDismiss&&this.props.onDismiss()})),this._isMounted=!1,this.state={dismissed:null!=e.dismissed&&e.dismissed,hovered:!1,targetElementIsVisible:!1}}componentDidMount(){this._isMounted=!0,this._registerVisibilityObserver()}UNSAFE_componentWillReceiveProps(e){null!=e.dismissed&&this.setState({dismissed:e.dismissed})}UNSAFE_componentWillUpdate(){this._registerVisibilityObserver()}componentWillUnmount(){this._isMounted=!1,this._targetElementMountTimeout&&clearTimeout(this._targetElementMountTimeout),this._visibilityObserver.disconnect()}_findRootElement(){return this.context.modalContainerElement||document.getElementById("mission-task-container")||document.getElementById("outer-wrapper")||document.body}_registerVisibilityObserver(){const e=this._findRootElement();if(!e)throw new re("Failed to mount NewTooltip: we need a #outer-wrapper or document.body element.",se.Internal);if(e===this._rootElement)return;this._rootElement=e,this._visibilityObserver&&this._visibilityObserver.disconnect(),this._visibilityObserver=function(e,t,n){return new tl(e,t,n)}(e,this._handleVisibilityChange);const t=this._wrapper;if(!t)throw new re("NewTooltip expected a wrapper element after mount",se.Internal);let n=t;for(;n.hasAttribute("data-tooltip-wrapper");)if(n=n.childNodes[0],!n)throw new re("NewTooltip expected wrapper element to have a child",se.Internal);this._targetElement=n,this._targetElementMountTimeout=setTimeout((()=>{const e=this._targetElement;if(!e)throw new re("NewTooltip should have a target element after mounting.",se.Internal);ne().isDevServer&&"inline"===getComputedStyle(e).display&&(ie.error("Warning: The children of a NewTooltip element must be block-like, but this element seems to have `display: inline`. This could break position tracking.",se.Internal),ie.log("NewTooltip Target Element:",{targetElement:e.outerHTML})),this._visibilityObserver.setTargetElement(e),this.forceUpdate()}),0)}_shouldShowTooltip(){const{toggleOnHover:e,showOnMount:t}=this.props,{dismissed:n,targetElementIsVisible:o}=this.state;return!1!==o&&(!n&&(!!t||!(!e||!this.state.hovered)))}remeasure(){this._tooltipPortal&&this._tooltipPortal.remeasure()}render(){const{children:e,toggleOnHover:t}=this.props,{children:n,...o}=this.props;return _.createElement("div",{className:l.css(gl.targetElement),onMouseEnter:t?this._handleMouseEnter:void 0,onMouseLeave:t?this._handleMouseLeave:void 0,ref:e=>this._wrapper=e,"data-tooltip-wrapper":!0,"data-test-id":"question-id"},e,this._targetElement&&this._shouldShowTooltip()&&_.createElement(hl,{tooltipProps:o,dismiss:this._handleDismiss,rootElement:this._rootElement,targetElement:this._targetElement,isAboveModal:!!this.context.modalContainerElement,ref:e=>this._tooltipPortal=e}))}}W(ml,"defaultProps",fl),ml.contextTypes={modalContainerElement:I.default.instanceOf(HTMLElement)};const gl=l.StyleSheet.create({targetElement:{display:"inline"}});class vl extends _.PureComponent{constructor(){super(...arguments),W(this,"_handleKeyDown",(e=>{"Tab"===e.key&&(this.props.onDismiss(),e.preventDefault())}))}_renderTooltipContent(){return _.createElement("div",{onKeyDown:this._handleKeyDown},_.createElement(Qa,this.props.buttonProps))}render(){return _.createElement("div",null,_.createElement(ml,{content:this._renderTooltipContent(),offsetFrom:"arrow",offset:10,dismissed:this.props.dismissed,showOnMount:!0,toggleOnHover:!1,onClick:()=>this.props.buttonProps.onClick(),media:Wr.mdOrLarger},this.props.children),!this.props.dismissed&&_.createElement(yl,{onDismiss:this.props.onDismiss}))}}class yl extends _.PureComponent{constructor(){super(...arguments),W(this,"_handleGlobalClick",(()=>{this.props.onDismiss()})),W(this,"_handleGlobalKeyup",(e=>{"Escape"===e.key&&this.props.onDismiss()}))}componentDidMount(){setTimeout((()=>{window.addEventListener("click",this._handleGlobalClick),window.addEventListener("keyup",this._handleGlobalKeyup)}),0)}componentWillUnmount(){window.removeEventListener("click",this._handleGlobalClick),window.removeEventListener("keyup",this._handleGlobalKeyup)}render(){return null}}const bl={path:"M27.218 6.82l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:27.284};class xl extends _.PureComponent{constructor(){super(...arguments),W(this,"_menu",void 0),W(this,"_menuButton",void 0),W(this,"_crossOutButtonIsFocused",void 0),W(this,"state",{hovered:!1,opened:!1,slidePanelCovered:!0,usingKeyboardFocus:!1,wasCrossedOutOnLastOpen:!1}),W(this,"_openMenu",(()=>{const e=null!=this._menu&&this._menu.contains(document.activeElement);this.setState({opened:!0,usingKeyboardFocus:e,wasCrossedOutOnLastOpen:this.props.crossedOut})})),W(this,"_closeMenu",(()=>{this._crossOutButtonIsFocused&&this._menuButton&&this._menuButton.focus(),this.setState({opened:!1,slidePanelCovered:!0})})),W(this,"_handleMenuClick",((e,t)=>{t?this._openMenu():this._closeMenu(),e.preventDefault()})),W(this,"_handleCrossedOutButtonClick",(e=>{this.props.onCrossedOutChange(e),this._closeMenu()})),W(this,"_handleSlideTransitionEnd",(()=>{this.state.opened&&this.setState({slidePanelCovered:!1})}))}UNSAFE_componentWillReceiveProps(e){e.enabled||this._closeMenu()}_getButtonProps(e){const t=this.state.wasCrossedOutOnLastOpen;return{onClick:()=>{this._handleCrossedOutButtonClick(!t)},onFocus:()=>{this._crossOutButtonIsFocused=!0},onBlur:()=>{this._crossOutButtonIsFocused=!1},crossedOut:t,pos:this.props.pos,primaryProductColor:this.props.primaryProductColor,usingKeyboardFocus:this.state.usingKeyboardFocus,theme:e}}_getMenuIconColor(){return this.state.opened?this.props.primaryProductColor:this.state.hovered?D.default.offBlack:D.default.offBlack50}_renderMenu(){const{pos:e,isSatProduct:t}=this.props,{opened:n}=this.state,o=l.css(wl.menu,t&&wl.spacing);return _.createElement("div",{ref:e=>this._menu=e,className:o,onClick:e=>this._handleMenuClick(e,!n),onMouseEnter:()=>this.setState({hovered:!0}),onMouseLeave:()=>this.setState({hovered:!1})},_.createElement(vl,{dismissed:!this.state.opened,onDismiss:this._closeMenu,buttonProps:this._getButtonProps("day")},_.createElement("button",{type:"button","aria-label":S._("Open menu for Choice %(letter)s",{letter:ta(e)}),className:l.css([wl.menuButton]),onClick:e=>this._handleMenuClick(e,!n),onMouseDown:e=>e.preventDefault(),ref:e=>this._menuButton=e},_.createElement(aa,{className:l.css(wl.menuIcon),icon:bl,size:3,color:this._getMenuIconColor()}))))}_renderSlidePanel(){const e=this._getButtonProps("night"),{slidePanelCovered:t}=this.state;return _.createElement("div",{className:l.css(wl.slidePanel,t&&wl.slidePanelCovered),onClick:e.onClick,"aria-hidden":t},_.createElement(Qa,U({},e,{disabled:t,tabFocusable:!t})))}render(){const{enabled:e}=this.props,{opened:t}=this.state;return _.createElement("div",{className:l.css(wl.wrapper)},_.createElement("div",{className:l.css(wl.slidingContent,e&&wl.slidingContentEnabled,t&&wl.slidingContentOpen),onTransitionEnd:this._handleSlideTransitionEnd},_.createElement("div",{className:l.css(wl.content)},this.props.children),e&&this._renderMenu()),e&&this._renderSlidePanel())}}const wl=l.StyleSheet.create({wrapper:{display:"block",position:"relative"},slidingContent:{display:"flex",flexDirection:"row",alignItems:"stretch"},slidingContentEnabled:{[Wr.smOrSmaller]:{transition:"transform 0.2s ease-out",backgroundColor:D.default.white}},slidingContentOpen:{[Wr.smOrSmaller]:{transform:"translateX(-".concat(96,"px)")}},content:{display:"block",flex:"1 1 0"},menu:{cursor:"pointer",boxSizing:"border-box",width:32,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",[Wr.smOrSmaller]:{paddingRight:8}},menuButton:{background:"none",border:"none",font:"inherit",padding:0,textAlign:"inherit",cursor:"pointer",display:"flex",flexDirection:"column",justifyContent:"center",height:16},menuIcon:{display:"block"},slidePanel:{position:"absolute",top:0,right:0,boxSizing:"border-box",width:96,height:"100%",paddingLeft:8,paddingRight:8,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",background:D.default.offBlack50,cursor:"pointer",[Wr.mdOrLarger]:{display:"none"}},spacing:{paddingRight:12},slidePanelCovered:{zIndex:-1}});class Cl extends _.Component{_renderText(){const{checked:e,correct:t,crossedOut:n}=this.props;return t?e?S._("Correct (selected)"):n?S._("Correct (but you crossed it out)"):S._("Correct"):e?S._("Incorrect (selected)"):S._("Incorrect")}render(){const{checked:e,correct:t,previouslyAnswered:n}=this.props;let o;return o=t?kl.correct:e||n?kl.incorrectAnswered:kl.incorrect,_.createElement("div",{className:l.css(kl.text,o)},this._renderText())}}const kl=l.StyleSheet.create({text:{alignItems:"center",display:"flex",fontSize:12,height:32,textTransform:"uppercase"},correct:{color:"#71B307"},incorrectAnswered:{color:"#F86700"},incorrect:{color:$}});class Sl extends _.Component{constructor(){super(...arguments),W(this,"_inputElement",void 0),W(this,"handleClick",(e=>{this.props.onChecked(!this.props.checked)})),W(this,"handleKeyUp",(e=>{" "===e.key&&(this.props.onChecked(!this.props.checked),e.preventDefault())})),W(this,"handleChange",(e=>{!this.props.checked&&e.target.checked&&this.props.onChecked(!0)})),W(this,"handleKeyDown",(e=>{" "===e.key?e.preventDefault():"ArrowUp"===e.key||"ArrowLeft"===e.key?(this.props.goToPrevChoice(),e.preventDefault()):"ArrowDown"!==e.key&&"ArrowRight"!==e.key||(this.props.goToNextChoice(),e.preventDefault())})),W(this,"handleRef",(e=>{this._inputElement=e,this.props.inputRef&&this.props.inputRef(e)}))}render(){const{inputRef:e,onChecked:t,goToPrevChoice:n,goToNextChoice:o,...s}=this.props;return _.createElement("input",U({},s,{type:"radio",onChange:this.handleChange,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,ref:this.handleRef}))}}W(Sl,"propTypes",{checked:I.default.bool.isRequired,inputRef:I.default.func,onChecked:I.default.func.isRequired,goToPrevChoice:I.default.func.isRequired,goToNextChoice:I.default.func.isRequired});const El={backgroundColor:"#E4F3F9",outline:"2px solid ".concat("#0084CE"),zIndex:1};class _l extends _.Component{constructor(){super(...arguments),W(this,"justFinishedTouch",void 0),W(this,"justFinishedTimeoutID",void 0),W(this,"_input",void 0),W(this,"state",{isInputFocused:!1,isInputActive:!1}),W(this,"onInputFocus",(()=>{this.setState({isInputFocused:!0})})),W(this,"onInputBlur",(()=>{this.setState({isInputFocused:!1})})),W(this,"onInputMouseDown",(e=>{"mousedown"===e.type&&this.justFinishedTouch||(this.setState({isInputActive:!0}),this.props.apiOptions.satStyling&&this._input&&this._input.focus())})),W(this,"onInputMouseUp",(e=>{if("mouseup"!==e.type||!this.justFinishedTouch){if("touchend"===e.type)return this.justFinishedTouch=!0,null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID),void(this.justFinishedTimeoutID=setTimeout((()=>{this.setState({isInputActive:!1}),this.justFinishedTouch=!1}),10));this.setState({isInputActive:!1}),this.props.apiOptions.satStyling&&this._input&&this._input.focus()}})),W(this,"onInputMouseOut",(()=>{this.setState({isInputActive:!1})})),W(this,"inputRef",(e=>{this._input=e})),W(this,"renderOptionStatus",(()=>{const{correct:e,checked:t,crossedOut:n,reviewMode:o,previouslyAnswered:s}=this.props;return this.props.apiOptions.satStyling?null:o||s?_.createElement(Cl,{checked:t,correct:e,crossedOut:n,previouslyAnswered:s}):null})),W(this,"renderChoiceIcon",(()=>{const{radioStyleVersion:e,primaryProductColor:t}=this.props.apiOptions.styling;return void 0!==e&&"final"===e||this.props.apiOptions.satStyling?_.createElement(ia,{pos:this.props.pos,correct:this.props.correct,crossedOut:this.props.crossedOut,pressed:this.state.isInputActive,focused:this.state.isInputFocused,checked:this.props.checked,showCorrectness:this.props.showCorrectness,reviewMode:this.props.reviewMode,product:this.props.apiOptions.satStyling?"sat":"library",primaryProductColor:t,previouslyAnswered:this.props.previouslyAnswered}):null})),W(this,"_setChecked",(e=>{e?this._sendChange({checked:!0,crossedOut:!1}):this._sendChange({checked:!1})})),W(this,"_setCrossedOut",(e=>{e?this._sendChange({checked:!1,crossedOut:!0}):this._sendChange({crossedOut:!1})})),W(this,"_sendChange",(e=>{const t=null!=e.checked?e.checked:this.props.checked,n=null!=e.crossedOut?e.crossedOut:this.props.crossedOut;this.props.onChange({checked:t,crossedOut:n})})),W(this,"focusInput",(()=>{var e;null===(e=this._input)||void 0===e||e.focus()}))}UNSAFE_componentWillUpdate(e){this.state.isInputFocused&&e.disabled&&this.setState({isInputFocused:!1})}componentWillUnmount(){null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID)}render(){const e=this.props.apiOptions.satStyling,t=this.props.apiOptions.isMobile,{radioStyleVersion:n}=this.props.apiOptions.styling,o=void 0!==n&&"final"===n,s=E.default(this.props.className,"checkbox-label",l.css(Tl.label,t&&Xr.disableTextSelection,!e&&Tl.responsiveLabel,e&&Tl.satLabel)),i=E.default(l.css(this.state.isInputFocused&&Tl.satDescriptionInputFocused,this.state.isInputActive&&Tl.satDescriptionInputActive)),r=this.props.showCorrectness&&!this.props.correct,a=this.props.checked&&!r,c={type:this.props.type,name:this.props.groupName,id:"".concat(this.props.groupName,"-choice-").concat(this.props.pos),checked:a,disabled:this.props.disabled,onFocus:this.onInputFocus,onBlur:this.onInputBlur,className:l.css(!o&&Xr.perseusInteractive,!o&&Tl.input,!o&&Xr.responsiveInput,!o&&!e&&Xr.responsiveRadioInput,!o&&!e&&this.state.isInputActive&&Xr.responsiveRadioInputActive,o&&Xr.perseusSrOnly,e&&Xr.perseusSrOnly,e&&this.props.reviewMode&&Tl.satReviewInput)};let p=null;p="radio"===this.props.type?_.createElement(Sl,U({onChecked:e=>this._setChecked(e),goToPrevChoice:this.props.goToPrevChoice,goToNextChoice:this.props.goToNextChoice,inputRef:this.inputRef},c)):_.createElement("input",U({onChange:e=>this._setChecked(e.target.checked),ref:this.inputRef},c));const{reviewMode:d,correct:u,checked:h}=this.props,f=e&&d&&u,m=e&&d&&!u&&h,g=E.default("description",f&&"sat-correct",m&&"sat-incorrect",l.css(!e&&Tl.description,e&&Tl.satDescription,f&&Tl.satDescriptionCorrect,f&&h&&Tl.satDescriptionCorrectChecked,m&&Tl.satDescriptionIncorrectChecked)),v=E.default("checkbox",l.css(Xr.perseusInteractive,!e&&Tl.choiceIconWrapper,e&&Tl.satCheckboxOptionContent)),y=E.default("checkbox-and-option",l.css(!e&&Tl.intermediateResponsiveCheckbox,!e&&d&&Tl.intermediateResponsiveCheckboxReview)),b=E.default("perseus-radio-rationale-content",l.css(Tl.rationale,!e&&Tl.nonSatRationale,e&&Tl.satReviewRationale)),x=this.props.editMode?"div":"label",w=this.props.apiOptions.crossOutEnabled&&!this.props.showCorrectness,C=!e&&!d&&this.props.apiOptions.readOnly||w&&this.props.crossedOut;return _.createElement("div",{className:e?i:void 0},_.createElement(xl,{enabled:w,pos:this.props.pos,primaryProductColor:this.props.apiOptions.styling.primaryProductColor,crossedOut:this.props.crossedOut,onCrossedOutChange:this._setCrossedOut,isSatProduct:e},_.createElement(x,{htmlFor:this.props.editMode?void 0:c.id,className:s,style:{opacity:C?.5:1}},_.createElement("div",{className:g,onMouseDown:this.onInputMouseDown,onMouseUp:this.onInputMouseUp,onMouseOut:this.onInputMouseOut,onTouchStart:this.onInputMouseDown,onTouchEnd:this.onInputMouseUp},_.createElement("div",{className:y},_.createElement("span",{className:v},p,this.renderChoiceIcon()),_.createElement("span",{className:E.default($t.RADIO.OPTION_CONTENT,$t.INTERACTIVE,l.css(e&&Tl.satRadioOptionContent,e&&d&&Tl.satReviewRadioOptionContent)),style:{cursor:"default"}},_.createElement("div",{className:l.css(Tl.optionStatusContainer)},this.renderOptionStatus()),_.createElement("div",null,this.props.content))),this.props.showRationale&&_.createElement("div",{className:b,"data-test-id":"perseus-radio-rationale-content-".concat(this.props.pos)},this.props.rationale)))))}}W(_l,"propTypes",{apiOptions:I.default.shape({satStyling:I.default.bool,isMobile:I.default.bool,styling:I.default.shape({radioStyleVersion:I.default.oneOf(["intermediate","final"]),primaryProductColor:I.default.string}),readOnly:I.default.bool}),checked:I.default.bool,className:I.default.string,rationale:I.default.node,content:I.default.node,correct:I.default.bool,deselectEnabled:I.default.bool,disabled:I.default.bool,editMode:I.default.bool,groupName:I.default.string,isLastChoice:I.default.bool,pos:I.default.number,reviewMode:I.default.bool,showRationale:I.default.bool,showCorrectness:I.default.bool,type:I.default.string,crossedOut:I.default.bool,previouslyAnswered:I.default.bool,onChange:I.default.func,goToPrevChoice:I.default.func.isRequired,goToNextChoice:I.default.func.isRequired}),W(_l,"defaultProps",{apiOptions:{styling:{}},checked:!1,classSet:{},correct:!1,disabled:!1,editMode:!1,onChange:function(){},showRationale:!1,type:"radio",pos:0,previouslyAnswered:!1});const Tl=l.StyleSheet.create({description:{display:"inline-block",width:"100%"},satDescription:{display:"block",position:"relative",boxSizing:"border-box",cursor:"pointer",marginLeft:0,padding:"17px 14px"},satDescriptionInputFocused:{...El,display:"block"},satDescriptionInputActive:{...El,backgroundColor:"#D0EDF4"},satDescriptionCorrect:{color:"#009900"},satDescriptionCorrectChecked:{backgroundColor:"#E4F7E4"},satDescriptionIncorrectChecked:{color:"#990000",backgroundColor:"#F2EBEB"},input:{display:"inline-block",width:20,margin:3,marginLeft:-20,marginRight:0,float:"none"},satReviewInput:{pointerEvents:"none"},satRadioOptionContent:{userSelect:"text",display:"block",marginLeft:45,cursor:"inherit"},satReviewRadioOptionContent:{fontWeight:"bold"},satCheckboxOptionContent:{position:"absolute",display:"block",top:"50%",margin:"-16px 0 0 0",width:"auto"},choiceIconWrapper:{display:"flex",marginRight:12,flexShrink:0},optionStatusContainer:{display:"block"},rationale:{display:"block"},nonSatRationale:{padding:"16px 16px",paddingTop:0,marginLeft:44,[Wr.smOrSmaller]:{padding:"12px 16px",paddingTop:0}},satReviewRationale:{marginTop:13,marginLeft:45},label:{display:"block",transition:"opacity 0.2s ease-out"},responsiveLabel:{WebkitTapHighlightColor:"transparent",display:"flex",alignItems:"stretch"},satLabel:{cursor:"pointer"},intermediateResponsiveCheckbox:{display:"flex",alignItems:"center",padding:"16px 16px",[Wr.smOrSmaller]:{padding:"12px 16px"}},intermediateResponsiveCheckboxReview:{alignItems:"flex-start"}});class Ml extends _.Component{constructor(){super(...arguments),W(this,"_choice",void 0),W(this,"focusInput",(()=>{this._choice.focusInput()}))}render(){const e={...this.props,className:E.default(this.props.className,"none-of-above"),content:this.props.showContent?this.props.content:_.createElement(Ai,{key:"noneOfTheAboveRenderer",content:S._("None of the above")}),ref:e=>this._choice=e};return _.createElement(_l,e)}}W(Ml,"propTypes",{className:I.default.string,content:I.default.node,showContent:I.default.bool}),W(Ml,"defaultProps",{showContent:!0});const{captureScratchpadTouchStart:Il}=Ae,Pl=I.default.arrayOf(I.default.shape({checked:I.default.bool,crossedOut:I.default.bool,content:I.default.node,rationale:I.default.node,hasRationale:I.default.bool,showRationale:I.default.bool,showCorrectness:I.default.bool,correct:I.default.bool,originalIndex:I.default.number,isNoneOfTheAbove:I.default.bool}));class Nl extends _.Component{constructor(){super(...arguments),W(this,"state",{radioGroupName:M.default.uniqueId("perseus_radio_")}),W(this,"updateChoice",((e,t)=>{let n;n=t.checked&&!this.props.multipleSelect?this.props.choices.map((e=>!1)):this.props.choices.map((e=>e.checked));const o=this.props.choices.map((e=>e.crossedOut));n[e]=t.checked,o[e]=t.crossedOut,this.props.onChange({checked:n,crossedOut:o})})),W(this,"focus",(e=>(N.default.findDOMNode(this.refs["radio"+(e||0)]).focus(),!0))),W(this,"getInstructionsText",(()=>this.props.multipleSelect?this.props.countChoices?S._("Choose %(numCorrect)s answers:",{numCorrect:this.props.numCorrect}):S._("Choose all answers that apply:"):S._("Choose 1 answer:"))),W(this,"deselectEnabled",(()=>this.props.apiOptions.isMobile||this.props.deselectEnabled)),W(this,"goToChoice",(e=>{const t=this.props.choices.length;e<0&&(e+=t),e>=t&&(e-=t);const n=this.refs["radio".concat(e)];if(!n)return void ie.error("found no choice at index ".concat(e,", even after ")+"wrapping it to be within bounds",se.Internal,{loggedMetadata:{choices:JSON.stringify(this.props.choices)}});n.focusInput();const o=this.props.choices.map((e=>e.crossedOut)),s=this.props.choices.map((e=>!1));this.props.choices[e].crossedOut||(s[e]=!0),this.props.onChange({checked:s,crossedOut:o})}))}componentDidUpdate(e){const{apiOptions:t,choices:n,isLastUsedWidget:o,reviewModeRubric:s}=this.props;if(t.canScrollPage&&o&&s&&!e.reviewModeRubric){const e=n.findIndex((e=>e.checked));if(e>=0){const t=N.default.findDOMNode(this.refs["radio"+e]);Jr(t)}}}render(){const e=this.props.multipleSelect?"checkbox":"radio",t=this.props.reviewModeRubric,n=!!t,o=Nl.styles,s=this.props.apiOptions.satStyling,i=this.props.apiOptions.isMobile,r=this.props.choices,a=r[0].highlighted,c=r[r.length-1].highlighted,p=E.default("perseus-widget-radio",!this.props.editMode&&"perseus-rendered-radio",l.css(o.radio,!s&&o.responsiveRadioContainer,!s&&a&&i&&o.radioContainerFirstHighlighted,!s&&c&&i&&o.radioContainerLastHighlighted,s&&o.satRadio)),d=E.default("instructions",l.css(o.instructions,i&&o.instructionsMobile)),u=this.getInstructionsText(),h=!s,f=l.css(o.responsiveFieldset),m=_.createElement("fieldset",{className:"perseus-widget-radio-fieldset ".concat(f)},_.createElement("legend",{className:"perseus-sr-only"},u),h&&_.createElement("div",{className:d},u),_.createElement("ul",{className:p},this.props.choices.map((function(i,r){let a=_l;const c={ref:"radio".concat(r),apiOptions:this.props.apiOptions,checked:i.checked,crossedOut:i.crossedOut,previouslyAnswered:i.previouslyAnswered,reviewMode:n,correct:i.correct,rationale:i.rationale,content:i.content,disabled:this.props.apiOptions.readOnly||i.disabled,editMode:this.props.editMode,groupName:this.state.radioGroupName,isLastChoice:r===this.props.choices.length-1,showCorrectness:n||!!i.showCorrectness,showRationale:i.hasRationale&&(n||i.showRationale),type:e,pos:r,deselectEnabled:this.deselectEnabled(),onChange:e=>{this.updateChoice(r,e)},goToPrevChoice:()=>this.goToChoice(r-1),goToNextChoice:()=>this.goToChoice(r+1)};i.isNoneOfTheAbove&&(a=Ml,M.default.extend(c,{showContent:i.revealNoneOfTheAbove}));const p=this.props.choices[r+1],d=!!p&&p.highlighted,u=e=>{const r=s&&n&&e,a=s&&n&&p&&p.checked;return l.css(Xr.aboveScratchpad,o.item,!s&&o.responsiveItem,!s&&e&&o.selectedItem,!s&&e&&i.highlighted&&o.aboveBackdrop,!s&&e&&i.highlighted&&this.props.apiOptions.isMobile&&o.aboveBackdropMobile,!s&&d&&this.props.apiOptions.isMobile&&o.nextHighlighted,s&&o.satRadioOption,r&&!i.correct&&o.satRadioOptionIncorrect,r&&i.correct&&o.satRadioOptionCorrect,a&&!p.correct&&o.satRadioOptionNextIncorrect,a&&p.correct&&o.satRadioOptionNextCorrect,s&&t&&o.satReviewRadioOption)};u(!0);const h=E.default(u(i.checked),$t.RADIO.OPTION,i.checked&&$t.RADIO.SELECTED,n&&t.choices[r].correct&&$t.CORRECT,n&&!t.choices[r].correct&&$t.INCORRECT);let f=null,m=null;return this.props.editMode&&(m=e=>{let t=e.target;for(;t&&t!==f;){if(t.getAttribute("data-is-radio-icon"))return void this.updateChoice(r,{checked:!i.checked});t=t.parentNode}}),_.createElement("li",{key:r,ref:e=>f=e,className:h,onClick:m,onTouchStart:this.props.labelWrap?Il:null},_.createElement(a,c))}),this)));return _.createElement("div",{className:l.css(!s&&o.responsiveContainer)},m)}}W(Nl,"propTypes",{apiOptions:I.default.shape({readOnly:I.default.bool,satStyling:I.default.bool,isMobile:I.default.bool,styling:I.default.shape({radioStyleVersion:I.default.oneOf(["intermediate","final"])}),canScrollPage:I.default.bool}),choices:Pl,deselectEnabled:I.default.bool,editMode:I.default.bool,labelWrap:I.default.bool,countChoices:I.default.bool,numCorrect:I.default.number,multipleSelect:I.default.bool,reviewModeRubric:I.default.shape({choices:Pl}),onChange:I.default.func,isLastUsedWidget:I.default.bool}),W(Nl,"styles",l.StyleSheet.create({instructions:{display:"block",color:X,fontSize:14,lineHeight:1.25,fontStyle:"normal",fontWeight:"bold",marginBottom:16},instructionsMobile:{fontSize:18,[Wr.smOrSmaller]:{fontSize:16},[Wr.xl]:{fontSize:20}},radio:{width:"100%"},responsiveRadioContainer:{borderBottom:"1px solid ".concat("#BABEC2"),borderTop:"1px solid ".concat("#BABEC2"),width:"auto",[Wr.smOrSmaller]:{marginLeft:-16,marginRight:-16}},radioContainerFirstHighlighted:{borderTop:"1px solid rgba(0, 0, 0, 0)"},radioContainerLastHighlighted:{borderBottom:"1px solid rgba(0, 0, 0, 0)"},satRadio:{background:"none",marginLeft:0,userSelect:"none"},satRadioOption:{margin:0,padding:0,borderBottom:"1px solid #ccc",":first-child":{borderTop:"1px solid #ccc"}},satRadioOptionCorrect:{borderBottomColor:"#00CC00",":first-child":{borderTopColor:"#00CC00"}},satRadioOptionIncorrect:{borderBottomColor:"#CC5252",":first-child":{borderTopColor:"#CC5252"}},satRadioOptionNextCorrect:{borderBottomColor:"#00CC00"},satRadioOptionNextIncorrect:{borderBottomColor:"#CC5252"},satReviewRadioOption:{pointerEvents:"none"},item:{marginLeft:20},inlineItem:{display:"inline-block",paddingLeft:20,verticalAlign:"middle"},responsiveItem:{marginLeft:0,padding:0,":not(:last-child)":{borderBottom:"1px solid ".concat("#BABEC2")}},selectedItem:{background:"white"},aboveBackdrop:{position:"relative",zIndex:1062},aboveBackdropMobile:{boxShadow:"0 0 4px 0 rgba(0, 0, 0, 0.2),0 0 2px 0 rgba(0, 0, 0, 0.1)",":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},nextHighlighted:{":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},responsiveContainer:{overflow:"auto",marginLeft:-16,marginRight:-16,paddingLeft:16},responsiveFieldset:{paddingRight:16}})),W(Nl,"defaultProps",{editMode:!1});class Al extends _.Component{constructor(){super(...arguments),W(this,"_renderRenderer",(e=>{let t=1;const n={},o=(e=e||"").replace(/\{\{passage-ref (\d+) (\d+)(?: "([^"]*)")?\}\}/g,((e,o,s,i)=>{const r="passage-ref "+t;return t++,n[r]={type:"passage-ref",graded:!1,options:{passageNumber:parseInt(o),referenceNumber:parseInt(s),summaryText:i},version:Rr.version},"[["+Ae.snowman+" "+r+"]]"}));return _.createElement(Ai,{key:"choiceContentRenderer",content:o,widgets:n,findExternalWidgets:this.props.findWidgets,alwaysUpdate:!0,linterContext:{...this.props.linterContext,blockHighlight:!0}})})),W(this,"focus",(e=>this.refs.baseRadio.focus(e))),W(this,"updateChoices",(e=>{const{choiceStates:t,choices:n}=this.props;let o;o=t?t.map((e=>({...e}))):n.map((()=>({selected:!1,crossedOut:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1,readOnly:!1}))),o.forEach(((t,n)=>{t.selected=e.checked[n],t.crossedOut=e.crossedOut[n]})),this.props.onChange({choiceStates:o}),this.props.trackInteraction()})),W(this,"getUserInput",(()=>Al.getUserInputFromProps(this.props))),W(this,"simpleValidate",(e=>Al.validate(this.getUserInput(),e))),W(this,"showRationalesForCurrentlySelectedChoices",(e=>{const{choiceStates:t}=this.props;if(t){const n=this.simpleValidate(e),o="points"===n.type&&n.total===n.earned,s=t.map((e=>({...e,highlighted:e.selected,rationaleShown:e.selected||e.rationaleShown||o,readOnly:e.selected||e.readOnly||o,correctnessShown:e.selected||e.correctnessShown,previouslyAnswered:e.previouslyAnswered||e.selected})));this.props.onChange({choiceStates:s},null,!0)}})),W(this,"deselectIncorrectSelectedChoices",(()=>{if(this.props.choiceStates){const e=this.props.choiceStates.map(((e,t)=>({...e,selected:e.selected&&!!this.props.choices[t].correct,highlighted:!1})));this.props.onChange({choiceStates:e},null,!1)}}))}render(){let e,t=this.props.choices;return e=this.props.static?M.default.map(t,(e=>({selected:e.correct,crossedOut:e.crossedOut,readOnly:!0,highlighted:!1,rationaleShown:!0,correctnessShown:!0,previouslyAnswered:!1}))):this.props.choiceStates?this.props.choiceStates:this.props.values?M.default.map(this.props.values,(e=>({selected:e,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))):M.default.map(t,(()=>({selected:!1,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))),t=M.default.map(t,((t,n)=>{const o=t.isNoneOfTheAbove&&!t.content?S._("None of the above"):t.content,{selected:s,crossedOut:i,rationaleShown:r,correctnessShown:a,readOnly:l,highlighted:c,previouslyAnswered:p}=e[n],d=this.props.reviewModeRubric&&this.props.reviewModeRubric.choices[n];return{content:this._renderRenderer(o),checked:s,correct:void 0===t.correct?!!d&&d.correct:t.correct,disabled:l,hasRationale:!!t.clue,rationale:this._renderRenderer(t.clue),showRationale:r,showCorrectness:a,isNoneOfTheAbove:t.isNoneOfTheAbove,revealNoneOfTheAbove:this.props.questionCompleted&&s,crossedOut:i,highlighted:c,previouslyAnswered:p}})),_.createElement(Nl,{ref:"baseRadio",labelWrap:!0,multipleSelect:this.props.multipleSelect,countChoices:this.props.countChoices,numCorrect:this.props.numCorrect,choices:t,onChange:this.updateChoices,reviewModeRubric:this.props.reviewModeRubric,deselectEnabled:this.props.deselectEnabled,apiOptions:this.props.apiOptions,isLastUsedWidget:this.props.isLastUsedWidget})}static validate(e,t){const n=M.default.reduce(e.choicesSelected,((e,t)=>e+(t?1:0)),0);if(0===n)return{type:"invalid",message:null};if(e.numCorrect>1&&n!==e.numCorrect)return{type:"invalid",message:S._("Please choose the correct number of answers.")};if(e.noneOfTheAboveSelected&&n>1)return{type:"invalid",message:S._("'None of the above' may not be selected when other answers are selected.")};return{type:"points",earned:M.default.all(e.choicesSelected,((n,o)=>{let s;return s=e.noneOfTheAboveIndex===o?M.default.all(t.choices,((e,t)=>o===t||!e.correct)):!!t.choices[o].correct,s===n}))?1:0,total:1,message:null}}static getUserInputFromProps(e){if(e.choiceStates){let t=null,n=!1;const o=e.choiceStates,s=o.map((()=>!1)),i=e.countChoices,r=e.numCorrect;for(let i=0;i<s.length;i++){const r=e.choices[i].originalIndex;s[r]=o[i].selected,e.choices[i].isNoneOfTheAbove&&(t=r,s[i]&&(n=!0))}return{countChoices:i,choicesSelected:s,numCorrect:r,noneOfTheAboveIndex:t,noneOfTheAboveSelected:n}}if(e.values){let t=null,n=!1;const o=e.values.slice(),s=e.countChoices,i=e.numCorrect;for(let s=0;s<e.values.length;s++){const i=e.choices[s].originalIndex;o[i]=e.values[s],e.choices[s].isNoneOfTheAbove&&(t=i,o[s]&&(n=!0))}return{choicesSelected:o,noneOfTheAboveIndex:t,noneOfTheAboveSelected:n,countChoices:s,numCorrect:i}}return{choicesSelected:M.default.map(e.choices,(()=>!1))}}}W(Al,"defaultProps",{choices:[{}],displayCount:null,multipleSelect:!1,countChoices:!1,deselectEnabled:!1,linterContext:Ht});const{shuffle:Rl,random:Fl}=Ae,Ol=[[S._("False"),S._("True")],[S._("No"),S._("Yes")]],Dl=(e,t)=>{const n=((e,t)=>{let n=e.choices.slice();return n=M.default.map(n,((e,t)=>M.default.extend({},e,{originalIndex:t,correct:Boolean(e.correct)}))),function(e){let t=null;const n=M.default.reject(e,(function(e,n){if(e.isNoneOfTheAbove)return t=e,!0}));return t&&n.push(t),n}((e=>{const t=e.map((e=>e.content));return Ol.some((e=>M.default.isEqual(t,e)))?[e[1],e[0]]:e})(function(n){const o=void 0===t?Fl:t;return e.randomize?Rl(n,null!=o?o:0):n}(n)))})(e,t),o=M.default.reduce(e.choices,(function(e,t){return t.correct?e+1:e}),0),{hasNoneOfTheAbove:s,multipleSelect:i,countChoices:r,deselectEnabled:a}=e;return{numCorrect:o,hasNoneOfTheAbove:s,multipleSelect:i,countChoices:r,deselectEnabled:a,choices:n,selectedChoices:M.default.pluck(n,"correct")}};var Ll={name:"radio",displayName:"Multiple choice",accessible:!0,widget:Al,transform:Dl,staticTransform:Dl,version:{major:1,minor:0},propUpgrades:{1:e=>{let t,n;if(e.noneOfTheAbove)throw new Error("radio widget v0 no longer supports auto noneOfTheAbove");return t=e.choices,n=!1,M.default.extend(M.default.omit(e,"noneOfTheAbove"),{choices:t,hasNoneOfTheAbove:n})}},isLintable:!0},Bl=[Ll,kr,Pr,gr];class zl extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"state",{uniqueId:M.default.uniqueId("perseus_radio_")}),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"getUserInput",(()=>zl.getUserInputFromProps(this.props))),W(this,"onChange",((e,t)=>{const n=[...this.props.values];n[e]=t,this.change("values",n),this.props.trackInteraction()})),W(this,"simpleValidate",(e=>zl.validate(this.getUserInput(),e)))}render(){const e=this,t=this.props.apiOptions.isMobile;let n=this.props.items.map(((e,t)=>[e,t]));this.props.randomizeItems&&(n=Ae.shuffle(n,this.props.problemNum));const o=_.createElement("table",{className:"categorizer-table "+l.css(ql.mobileTable)},_.createElement("thead",null,_.createElement("tr",null,_.createElement("th",null," "),this.props.categories.map(((e,t)=>_.createElement("th",{className:l.css(ql.header),key:t},_.createElement(Ai,{content:e,linterContext:this.props.linterContext})))))),_.createElement("tbody",null,n.map((n=>{const o=n[0],s=n[1],i=e.state.uniqueId+"_"+s;return _.createElement("tr",{key:s},_.createElement("td",null,_.createElement(Ai,{content:o,linterContext:this.props.linterContext})),e.props.categories.map(((n,o)=>{const r=e.props.values[s]===o;return _.createElement("td",{className:"category "+l.css(ql.cell),key:o},_.createElement("div",{className:$t.INTERACTIVE,role:"button","aria-label":n,onClick:this.onChange.bind(this,s,o)},t&&_.createElement("input",{type:"radio",name:i,className:l.css(Xr.responsiveInput,Xr.responsiveRadioInput),checked:r,onChange:this.onChange.bind(this,s,o),onClick:e=>e.stopPropagation()}),!t&&_.createElement("span",{className:l.css(ql.radioSpan,r&&ql.checkedRadioSpan,this.props.static&&r&&ql.staticCheckedRadioSpan)},r?_.createElement(G,fo):_.createElement(G,vo))))})))})))),s=E.default({"categorizer-container":!0,"static-mode":this.props.static}),i=this.props.apiOptions.isMobile?[ql.fullBleedContainer]:[];return _.createElement("div",{className:s+" "+l.css(...i)},o)}static validate(e,t){let n=!0,o=!0;return M.default.each(t.values,(function(t,s){null==e.values[s]&&(n=!1),e.values[s]!==t&&(o=!1)})),n?{type:"points",earned:o?1:0,total:1,message:null}:{type:"invalid",message:S._("Make sure you select something for every row.")}}static getUserInputFromProps(e){return Nr.getUserInputFromProps(e)}}W(zl,"defaultProps",{items:[],categories:[],values:[],linterContext:Ht});const ql=l.StyleSheet.create({mobileTable:{[Wr.smOrSmaller]:{minWidth:"auto"}},fullBleedContainer:{[Wr.mdOrSmaller]:{marginLeft:-16,marginRight:-16,overflowX:"auto"}},header:{textAlign:"center",verticalAlign:"bottom"},cell:{textAlign:"center",padding:0,color:"#ccc",verticalAlign:"middle"},radioSpan:{fontSize:30,paddingRight:3,":hover":{color:"#999"}},checkedRadioSpan:{color:"#333"},staticCheckedRadioSpan:{color:"#888"}});var Hl={name:"categorizer",displayName:"Categorizer",widget:zl,transform:e=>M.default.pick(e,"items","categories","randomizeItems"),staticTransform:e=>M.default.pick(e,"items","categories","values","randomizeItems"),isLintable:!0};let Wl;const Ul=e=>new URL(e,(Wl||(Wl=window.location),Wl).origin),{updateQueryString:Gl}=Ae;function Vl(e){const{InitialRequestUrl:t}=ne(),n="/computer-programming/program/"+"".concat(e,"/embedded?embed=yes&author=no");return(o=t.protocol)&&"file:"===o.toLowerCase()?"https://khanacademy.org".concat(n):Ul(n).href;var o}class jl extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"handleMessageEvent",(e=>{let t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(M.default.isUndefined(t.testsPassed))return;const n=t.testsPassed?"correct":"incorrect";this.change({status:n,message:t.message})})),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"simpleValidate",(e=>jl.validate({status:this.props.status,message:this.props.message},e)))}static validate(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}componentDidMount(){R.default(window).on("message",this.handleMessageEvent)}componentWillUnmount(){R.default(window).off("message",this.handleMessageEvent)}render(){if(!this.props.programID)return _.createElement("div",null);let e,t=!1,n=Vl(this.props.programID);const o={height:this.props.height,width:"100%"};if(this.props.showEditor?(n+="&editor=yes",e="perseus-scratchpad-editor"):(n+="&editor=no&width=".concat(688),e="perseus-scratchpad","webpage"!==this.props.programType&&(t=!0)),this.props.showButtons?(n+="&buttons=yes",o.height+=67):n+="&buttons=no",this.props.settings){const e={};M.default.each(this.props.settings,(function(t){t.name&&t.value&&(e[t.name]=t.value)})),n=Gl(n,"settings",JSON.stringify(e))}const s=["allow-popups","allow-same-origin","allow-scripts","allow-top-navigation"].join(" ");return _.createElement("div",{className:l.css(Yl.widthOverride,t&&Yl.container)},_.createElement("iframe",{sandbox:s,src:n,style:o,className:e,allowFullScreen:!0}))}}W(jl,"propTypes",{...pr,programID:I.default.string,programType:I.default.oneOf(["pjs","sql","webpage"]),width:I.default.number,height:I.default.number,settings:I.default.array,showEditor:I.default.bool,showButtons:I.default.bool,status:I.default.oneOf(["incomplete","incorrect","correct"]),message:I.default.string}),W(jl,"defaultProps",{showEditor:!1,showButtons:!1,status:"incomplete",message:null});const Yl=l.StyleSheet.create({widthOverride:{width:820},container:{margin:"auto"}});var $l={name:"cs-program",displayName:"CS Program",supportedAlignments:["block","full-width"],widget:jl,hidden:!0};class Xl extends _.Component{componentDidMount(){this.props.trackInteraction()}render(){return _.createElement(m.View,{style:Zl.tooltipBody},_.createElement(Ai,{apiOptions:this.props.apiOptions,content:this.props.content,widgets:this.props.widgets}))}}W(Xl,"propTypes",{apiOptions:Yt.propTypes,content:I.default.string,trackInteraction:I.default.func.isRequired,widgets:I.default.objectOf(I.default.any)});class Kl extends _.Component{constructor(){super(...arguments),W(this,"getUserInput",(()=>({}))),W(this,"simpleValidate",(e=>Kl.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const e=_.createElement(Xl,{apiOptions:this.props.apiOptions,content:this.props.definition,key:this.props.definition,trackInteraction:this.props.trackInteraction,widgets:this.props.widgets});return _.createElement(B.default,{content:e,placement:"top"},_.createElement("span",{className:"perseus-widget-definition"},_.createElement(m.View,{style:Zl.definitionLink},this.props.togglePrompt)))}}W(Kl,"defaultProps",{togglePrompt:"define me",definition:"definition goes here"});const Zl={tooltipBody:{color:D.default.offBlack,display:"block",fontSize:20,fontWeight:500,lineHeight:"30px",margin:L.default.xSmall_8},definitionLink:{borderBottom:"dashed 1px ".concat(D.default.blue),color:D.default.blue,cursor:"pointer",display:"inline-block",textDecoration:"none"}};var Jl={name:"definition",displayName:"Definition",accessible:!0,defaultAlignment:"inline",widget:Kl,transform:M.default.identity};class Ql extends _.Component{constructor(){super(...arguments),W(this,"focus",(()=>(N.default.findDOMNode(this).focus(),!0))),W(this,"_handleChangeEvent",(e=>{this._handleChange(parseInt(e.target.value))})),W(this,"_handleChange",(e=>{this.props.trackInteraction(),this.props.onChange({selected:e})})),W(this,"getUserInput",(()=>({value:this.props.selected}))),W(this,"simpleValidate",(e=>Ql.validate(this.getUserInput(),e)))}static validate(e,t){const n=e.value;if(0===n)return{type:"invalid",message:null};return{type:"points",earned:t.choices[n-1].correct?1:0,total:1,message:null}}render(){const e=[_.createElement(y.OptionItem,{key:"placeholder",value:"0",disabled:!0,label:this.props.placeholder}),...this.props.choices.map(((e,t)=>_.createElement(y.OptionItem,{key:String(t+1),value:String(t+1),label:e})))];return _.createElement("div",{onClick:e=>{e.stopPropagation()},onTouchStart:e=>{e.stopPropagation()}},_.createElement(y.SingleSelect,{onChange:e=>this._handleChange(parseInt(e)),selectedValue:String(this.props.selected),disabled:this.props.apiOptions.readOnly},e))}}W(Ql,"defaultProps",{choices:[],selected:0,placeholder:"",apiOptions:Yt.defaults});var ec={name:"dropdown",displayName:"Drop down",defaultAlignment:"inline-block",accessible:!0,widget:Ql,transform:e=>({placeholder:e.placeholder,choices:M.default.map(e.choices,(e=>e.content))})};class tc extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"state",{expanded:!1}),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"_onClick",(()=>{this.setState({expanded:!this.state.expanded}),this.props.trackInteraction()})),W(this,"getUserInput",(()=>({}))),W(this,"simpleValidate",(e=>tc.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const{Link:e}=this.props.apiOptions.baseElements,{isArticle:t,isMobile:n}=this.props.apiOptions,o=this.state.expanded?this.props.hidePrompt:this.props.showPrompt;let s;const i="javascript:void(0)",r=this._onClick;s=n?_.createElement("div",{className:l.css(ic.linkContainer)},_.createElement("a",{className:l.css(ic.mobileExplanationLink),href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},o),this.state.expanded&&_.createElement("svg",{className:l.css(ic.disclosureArrow)},_.createElement("polygon",{style:{fill:sc},points:"0,".concat(oc," ")+"".concat(nc,",").concat(oc," ")+"".concat(nc/2,",0")}))):t?_.createElement("div",{className:l.css(ic.linkContainer,ic.articleLink)},_.createElement(e,{className:l.css(ic.explanationLink),style:ic.explanationLink,href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},"[".concat(o,"]"))):_.createElement("div",{className:l.css(ic.linkContainer,ic.exerciseLink)},_.createElement(e,{className:l.css(ic.explanationLink),href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},"[".concat(o,"]")));const a=n?ic.contentExpandedMobile:ic.contentExpanded;return _.createElement("div",{className:l.css(ic.container)},s,this.state.expanded&&_.createElement("div",{className:l.css(ic.content,n&&ic.contentMobile,this.state.expanded&&a),ref:"content"},_.createElement(Ai,{apiOptions:this.props.apiOptions,content:this.props.explanation,widgets:this.props.widgets,linterContext:this.props.linterContext})))}}W(tc,"defaultProps",{showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{},linterContext:Ht});const nc=30,oc=14,sc="#F0F1F2",ic=l.StyleSheet.create({container:{display:"inline",position:"relative"},linkContainer:{display:"inline-block"},explanationLink:{fontStyle:"italic",color:"#007d96"},articleLink:{fontSize:20,lineHeight:"30px"},exerciseLink:{fontSize:14,lineHeight:"19.6px"},mobileExplanationLink:{color:"#71B307",borderBottom:"dashed 1px ".concat("#71B307"),textDecoration:"none",[Wr.xl]:{fontSize:22,lineHeight:1.4},[Wr.lgOrSmaller]:{fontSize:20,lineHeight:1.5},[Wr.smOrSmaller]:{fontSize:18,lineHeight:1.2}},content:{position:"relative",transition:"margin-top 0.1s"},contentExpanded:{borderLeft:"5px solid #ccc",marginLeft:-23,paddingLeft:23,paddingBottom:10,marginBottom:oc,marginTop:oc},contentExpandedMobile:{boxSizing:"content-box",paddingTop:32,paddingBottom:32,marginTop:oc},contentMobile:{background:sc,marginLeft:-16,marginRight:-16,paddingLeft:16,paddingRight:16},disclosureArrow:{bottom:-(oc+5),height:oc,left:"50%",marginLeft:-nc/2,position:"absolute",width:nc}});var rc={name:"explanation",displayName:"Explanation",accessible:!0,defaultAlignment:"inline",widget:tc,transform:M.default.identity,isLintable:!0};function ac(e,t){return ac=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ac(e,t)}function lc(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ac(e,t)}function cc(e){return"/"===e.charAt(0)}function pc(e,t){for(var n=t,o=n+1,s=e.length;o<s;n+=1,o+=1)e[n]=e[o];e.pop()}var dc="production"===process.env.NODE_ENV;function uc(e,t){if(!dc){if(e)return;var n="Warning: "+t;"undefined"!=typeof console&&console.warn(n);try{throw Error(n)}catch(e){}}}var hc="production"===process.env.NODE_ENV,fc="Invariant failed";function mc(e,t){if(!e){if(hc)throw new Error(fc);var n="function"==typeof t?t():t;throw new Error(n?fc+": "+n:fc)}}function gc(e){return"/"===e.charAt(0)?e:"/"+e}function vc(e){return"/"===e.charAt(0)?e.substr(1):e}function yc(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}function bc(e,t){return yc(e,t)?e.substr(t.length):e}function xc(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function wc(e){var t=e.pathname,n=e.search,o=e.hash,s=t||"/";return n&&"?"!==n&&(s+="?"===n.charAt(0)?n:"?"+n),o&&"#"!==o&&(s+="#"===o.charAt(0)?o:"#"+o),s}function Cc(e,t,n,o){var s;"string"==typeof e?(s=function(e){var t=e||"/",n="",o="",s=t.indexOf("#");-1!==s&&(o=t.substr(s),t=t.substr(0,s));var i=t.indexOf("?");return-1!==i&&(n=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===n?"":n,hash:"#"===o?"":o}}(e),s.state=t):(void 0===(s=la({},e)).pathname&&(s.pathname=""),s.search?"?"!==s.search.charAt(0)&&(s.search="?"+s.search):s.search="",s.hash?"#"!==s.hash.charAt(0)&&(s.hash="#"+s.hash):s.hash="",void 0!==t&&void 0===s.state&&(s.state=t));try{s.pathname=decodeURI(s.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+s.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return n&&(s.key=n),o?s.pathname?"/"!==s.pathname.charAt(0)&&(s.pathname=function(e,t){void 0===t&&(t="");var n,o=e&&e.split("/")||[],s=t&&t.split("/")||[],i=e&&cc(e),r=t&&cc(t),a=i||r;if(e&&cc(e)?s=o:o.length&&(s.pop(),s=s.concat(o)),!s.length)return"/";if(s.length){var l=s[s.length-1];n="."===l||".."===l||""===l}else n=!1;for(var c=0,p=s.length;p>=0;p--){var d=s[p];"."===d?pc(s,p):".."===d?(pc(s,p),c++):c&&(pc(s,p),c--)}if(!a)for(;c--;c)s.unshift("..");!a||""===s[0]||s[0]&&cc(s[0])||s.unshift("");var u=s.join("/");return n&&"/"!==u.substr(-1)&&(u+="/"),u}(s.pathname,o.pathname)):s.pathname=o.pathname:s.pathname||(s.pathname="/"),s}function kc(){var e=null;var t=[];return{setPrompt:function(t){return"production"!==process.env.NODE_ENV&&uc(null==e,"A history supports only one prompt at a time"),e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,o,s){if(null!=e){var i="function"==typeof e?e(t,n):e;"string"==typeof i?"function"==typeof o?o(i,s):("production"!==process.env.NODE_ENV&&uc(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),s(!0)):s(!1!==i)}else s(!0)},appendListener:function(e){var n=!0;function o(){n&&e.apply(void 0,arguments)}return t.push(o),function(){n=!1,t=t.filter((function(e){return e!==o}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];t.forEach((function(e){return e.apply(void 0,n)}))}}}var Sc=!("undefined"==typeof window||!window.document||!window.document.createElement);function Ec(e,t){t(window.confirm(e))}function _c(){try{return window.history.state||{}}catch(e){return{}}}function Tc(e){void 0===e&&(e={}),Sc||("production"!==process.env.NODE_ENV?mc(!1,"Browser history needs a DOM"):mc(!1));var t,n=window.history,o=(-1===(t=window.navigator.userAgent).indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&window.history&&"pushState"in window.history,s=!(-1===window.navigator.userAgent.indexOf("Trident")),i=e,r=i.forceRefresh,a=void 0!==r&&r,l=i.getUserConfirmation,c=void 0===l?Ec:l,p=i.keyLength,d=void 0===p?6:p,u=e.basename?xc(gc(e.basename)):"";function h(e){var t=e||{},n=t.key,o=t.state,s=window.location,i=s.pathname+s.search+s.hash;return"production"!==process.env.NODE_ENV&&uc(!u||yc(i,u),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+i+'" to begin with "'+u+'".'),u&&(i=bc(i,u)),Cc(i,o,n)}function f(){return Math.random().toString(36).substr(2,d)}var m=kc();function g(e){la(M,e),M.length=n.length,m.notifyListeners(M.location,M.action)}function v(e){(function(e){return void 0===e.state&&-1===navigator.userAgent.indexOf("CriOS")})(e)||x(h(e.state))}function y(){x(h(_c()))}var b=!1;function x(e){if(b)b=!1,g();else{m.confirmTransitionTo(e,"POP",c,(function(t){t?g({action:"POP",location:e}):function(e){var t=M.location,n=C.indexOf(t.key);-1===n&&(n=0);var o=C.indexOf(e.key);-1===o&&(o=0);var s=n-o;s&&(b=!0,S(s))}(e)}))}}var w=h(_c()),C=[w.key];function k(e){return u+wc(e)}function S(e){n.go(e)}var E=0;function _(e){1===(E+=e)&&1===e?(window.addEventListener("popstate",v),s&&window.addEventListener("hashchange",y)):0===E&&(window.removeEventListener("popstate",v),s&&window.removeEventListener("hashchange",y))}var T=!1;var M={length:n.length,action:"POP",location:w,createHref:k,push:function(e,t){"production"!==process.env.NODE_ENV&&uc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var s="PUSH",i=Cc(e,t,f(),M.location);m.confirmTransitionTo(i,s,c,(function(e){if(e){var t=k(i),r=i.key,l=i.state;if(o)if(n.pushState({key:r,state:l},null,t),a)window.location.href=t;else{var c=C.indexOf(M.location.key),p=C.slice(0,c+1);p.push(i.key),C=p,g({action:s,location:i})}else"production"!==process.env.NODE_ENV&&uc(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&&uc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var s="REPLACE",i=Cc(e,t,f(),M.location);m.confirmTransitionTo(i,s,c,(function(e){if(e){var t=k(i),r=i.key,l=i.state;if(o)if(n.replaceState({key:r,state:l},null,t),a)window.location.replace(t);else{var c=C.indexOf(M.location.key);-1!==c&&(C[c]=i.key),g({action:s,location:i})}else"production"!==process.env.NODE_ENV&&uc(void 0===l,"Browser history cannot replace state in browsers that do not support HTML5 history"),window.location.replace(t)}}))},go:S,goBack:function(){S(-1)},goForward:function(){S(1)},block:function(e){void 0===e&&(e=!1);var t=m.setPrompt(e);return T||(_(1),T=!0),function(){return T&&(T=!1,_(-1)),t()}},listen:function(e){var t=m.appendListener(e);return _(1),function(){_(-1),t()}}};return M}var Mc={hashbang:{encodePath:function(e){return"!"===e.charAt(0)?e:"!/"+vc(e)},decodePath:function(e){return"!"===e.charAt(0)?e.substr(1):e}},noslash:{encodePath:vc,decodePath:gc},slash:{encodePath:gc,decodePath:gc}};function Ic(e){var t=e.indexOf("#");return-1===t?e:e.slice(0,t)}function Pc(){var e=window.location.href,t=e.indexOf("#");return-1===t?"":e.substring(t+1)}function Nc(e){window.location.replace(Ic(window.location.href)+"#"+e)}function Ac(e){void 0===e&&(e={}),Sc||("production"!==process.env.NODE_ENV?mc(!1,"Hash history needs a DOM"):mc(!1));var t=window.history,n=-1===window.navigator.userAgent.indexOf("Firefox"),o=e,s=o.getUserConfirmation,i=void 0===s?Ec:s,r=o.hashType,a=void 0===r?"slash":r,l=e.basename?xc(gc(e.basename)):"",c=Mc[a],p=c.encodePath,d=c.decodePath;function u(){var e=d(Pc());return"production"!==process.env.NODE_ENV&&uc(!l||yc(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=bc(e,l)),Cc(e)}var h=kc();function f(e){la(_,e),_.length=t.length,h.notifyListeners(_.location,_.action)}var m=!1,g=null;function v(){var e,t,n=Pc(),o=p(n);if(n!==o)Nc(o);else{var s=u(),r=_.location;if(!m&&(t=s,(e=r).pathname===t.pathname&&e.search===t.search&&e.hash===t.hash))return;if(g===wc(s))return;g=null,function(e){if(m)m=!1,f();else{var t="POP";h.confirmTransitionTo(e,t,i,(function(n){n?f({action:t,location:e}):function(e){var t=_.location,n=w.lastIndexOf(wc(t));-1===n&&(n=0);var o=w.lastIndexOf(wc(e));-1===o&&(o=0);var s=n-o;s&&(m=!0,C(s))}(e)}))}}(s)}}var y=Pc(),b=p(y);y!==b&&Nc(b);var x=u(),w=[wc(x)];function C(e){"production"!==process.env.NODE_ENV&&uc(n,"Hash history go(n) causes a full page reload in this browser"),t.go(e)}var k=0;function S(e){1===(k+=e)&&1===e?window.addEventListener("hashchange",v):0===k&&window.removeEventListener("hashchange",v)}var E=!1;var _={length:t.length,action:"POP",location:x,createHref:function(e){var t=document.querySelector("base"),n="";return t&&t.getAttribute("href")&&(n=Ic(window.location.href)),n+"#"+p(l+wc(e))},push:function(e,t){"production"!==process.env.NODE_ENV&&uc(void 0===t,"Hash history cannot push state; it is ignored");var n="PUSH",o=Cc(e,void 0,void 0,_.location);h.confirmTransitionTo(o,n,i,(function(e){if(e){var t=wc(o),s=p(l+t);if(Pc()!==s){g=t,function(e){window.location.hash=e}(s);var i=w.lastIndexOf(wc(_.location)),r=w.slice(0,i+1);r.push(t),w=r,f({action:n,location:o})}else"production"!==process.env.NODE_ENV&&uc(!1,"Hash history cannot PUSH the same path; a new entry will not be added to the history stack"),f()}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&uc(void 0===t,"Hash history cannot replace state; it is ignored");var n="REPLACE",o=Cc(e,void 0,void 0,_.location);h.confirmTransitionTo(o,n,i,(function(e){if(e){var t=wc(o),s=p(l+t);Pc()!==s&&(g=t,Nc(s));var i=w.indexOf(wc(_.location));-1!==i&&(w[i]=t),f({action:n,location:o})}}))},go:C,goBack:function(){C(-1)},goForward:function(){C(1)},block:function(e){void 0===e&&(e=!1);var t=h.setPrompt(e);return E||(S(1),E=!0),function(){return E&&(E=!1,S(-1)),t()}},listen:function(e){var t=h.appendListener(e);return S(1),function(){S(-1),t()}}};return _}function Rc(e,t,n){return Math.min(Math.max(e,t),n)}function Fc(e){void 0===e&&(e={});var t=e,n=t.getUserConfirmation,o=t.initialEntries,s=void 0===o?["/"]:o,i=t.initialIndex,r=void 0===i?0:i,a=t.keyLength,l=void 0===a?6:a,c=kc();function p(e){la(g,e),g.length=g.entries.length,c.notifyListeners(g.location,g.action)}function d(){return Math.random().toString(36).substr(2,l)}var u=Rc(r,0,s.length-1),h=s.map((function(e){return Cc(e,void 0,"string"==typeof e?d():e.key||d())})),f=wc;function m(e){var t=Rc(g.index+e,0,g.entries.length-1),o=g.entries[t];c.confirmTransitionTo(o,"POP",n,(function(e){e?p({action:"POP",location:o,index:t}):p()}))}var g={length:h.length,action:"POP",location:h[u],index:u,entries:h,createHref:f,push:function(e,t){"production"!==process.env.NODE_ENV&&uc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to push when the 1st argument is a location-like object that already has state; it is ignored");var o="PUSH",s=Cc(e,t,d(),g.location);c.confirmTransitionTo(s,o,n,(function(e){if(e){var t=g.index+1,n=g.entries.slice(0);n.length>t?n.splice(t,n.length-t,s):n.push(s),p({action:o,location:s,index:t,entries:n})}}))},replace:function(e,t){"production"!==process.env.NODE_ENV&&uc(!("object"==typeof e&&void 0!==e.state&&void 0!==t),"You should avoid providing a 2nd state argument to replace when the 1st argument is a location-like object that already has state; it is ignored");var o="REPLACE",s=Cc(e,t,d(),g.location);c.confirmTransitionTo(s,o,n,(function(e){e&&(g.entries[g.index]=s,p({action:o,location:s}))}))},go:m,goBack:function(){m(-1)},goForward:function(){m(1)},canGo:function(e){var t=g.index+e;return t>=0&&t<g.entries.length},block:function(e){return void 0===e&&(e=!1),c.setPrompt(e)},listen:function(e){return c.appendListener(e)}};return g}var Oc="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function Dc(e){var t=[];return{on:function(e){t.push(e)},off:function(e){t=t.filter((function(t){return t!==e}))},get:function(){return e},set:function(n,o){e=n,t.forEach((function(t){return t(e,o)}))}}}var Lc=T.default.createContext||function(e,t){var n,o,i="__create-react-context-"+function(){var e="__global_unique_id__";return Oc[e]=(Oc[e]||0)+1}()+"__",r=function(e){function n(){var t;return(t=e.apply(this,arguments)||this).emitter=Dc(t.props.value),t}lc(n,e);var o=n.prototype;return o.getChildContext=function(){var e;return(e={})[i]=this.emitter,e},o.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var n,o=this.props.value,s=e.value;((i=o)===(r=s)?0!==i||1/i==1/r:i!=i&&r!=r)?n=0:(n="function"==typeof t?t(o,s):1073741823,"production"!==process.env.NODE_ENV&&uc((1073741823&n)===n,"calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: "+n),0!==(n|=0)&&this.emitter.set(e.value,n))}var i,r},o.render=function(){return this.props.children},n}(s.Component);r.childContextTypes=((n={})[i]=I.default.object.isRequired,n);var a=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).state={value:e.getValue()},e.onUpdate=function(t,n){0!=((0|e.observedBits)&n)&&e.setState({value:e.getValue()})},e}lc(n,t);var o=n.prototype;return o.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?1073741823:t},o.componentDidMount=function(){this.context[i]&&this.context[i].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?1073741823:e},o.componentWillUnmount=function(){this.context[i]&&this.context[i].off(this.onUpdate)},o.getValue=function(){return this.context[i]?this.context[i].get():e},o.render=function(){return(e=this.props.children,Array.isArray(e)?e[0]:e)(this.state.value);var e},n}(s.Component);return a.contextTypes=((o={})[i]=I.default.object,o),{Provider:r,Consumer:a}},Bc={exports:{}},zc=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)};Bc.exports=Xc,Bc.exports.parse=Hc,Bc.exports.compile=function(e,t){return Uc(Hc(e,t),t)},Bc.exports.tokensToFunction=Uc,Bc.exports.tokensToRegExp=$c;var qc=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function Hc(e,t){for(var n,o=[],s=0,i=0,r="",a=t&&t.delimiter||"/";null!=(n=qc.exec(e));){var l=n[0],c=n[1],p=n.index;if(r+=e.slice(i,p),i=p+l.length,c)r+=c[1];else{var d=e[i],u=n[2],h=n[3],f=n[4],m=n[5],g=n[6],v=n[7];r&&(o.push(r),r="");var y=null!=u&&null!=d&&d!==u,b="+"===g||"*"===g,x="?"===g||"*"===g,w=n[2]||a,C=f||m;o.push({name:h||s++,prefix:u||"",delimiter:w,optional:x,repeat:b,partial:y,asterisk:!!v,pattern:C?Vc(C):v?".*":"[^"+Gc(w)+"]+?"})}}return i<e.length&&(r+=e.substr(i)),r&&o.push(r),o}function Wc(e){return encodeURI(e).replace(/[\/?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()}))}function Uc(e,t){for(var n=new Array(e.length),o=0;o<e.length;o++)"object"==typeof e[o]&&(n[o]=new RegExp("^(?:"+e[o].pattern+")$",Yc(t)));return function(t,o){for(var s="",i=t||{},r=(o||{}).pretty?Wc:encodeURIComponent,a=0;a<e.length;a++){var l=e[a];if("string"!=typeof l){var c,p=i[l.name];if(null==p){if(l.optional){l.partial&&(s+=l.prefix);continue}throw new TypeError('Expected "'+l.name+'" to be defined')}if(zc(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 d=0;d<p.length;d++){if(c=r(p[d]),!n[a].test(c))throw new TypeError('Expected all "'+l.name+'" to match "'+l.pattern+'", but received `'+JSON.stringify(c)+"`");s+=(0===d?l.prefix:l.delimiter)+c}}else{if(c=l.asterisk?encodeURI(p).replace(/[?#]/g,(function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})):r(p),!n[a].test(c))throw new TypeError('Expected "'+l.name+'" to match "'+l.pattern+'", but received "'+c+'"');s+=l.prefix+c}}else s+=l}return s}}function Gc(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function Vc(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function jc(e,t){return e.keys=t,e}function Yc(e){return e&&e.sensitive?"":"i"}function $c(e,t,n){zc(t)||(n=t||n,t=[]);for(var o=(n=n||{}).strict,s=!1!==n.end,i="",r=0;r<e.length;r++){var a=e[r];if("string"==typeof a)i+=Gc(a);else{var l=Gc(a.prefix),c="(?:"+a.pattern+")";t.push(a),a.repeat&&(c+="(?:"+l+c+")*"),i+=c=a.optional?a.partial?l+"("+c+")?":"(?:"+l+"("+c+"))?":l+"("+c+")"}}var p=Gc(n.delimiter||"/"),d=i.slice(-p.length)===p;return o||(i=(d?i.slice(0,-p.length):i)+"(?:"+p+"(?=$))?"),i+=s?"$":o&&d?"":"(?="+p+"|$)",jc(new RegExp("^"+i,Yc(n)),t)}function Xc(e,t,n){return zc(t)||(n=t||n,t=[]),n=n||{},e instanceof RegExp?function(e,t){var n=e.source.match(/\((?!\?)/g);if(n)for(var o=0;o<n.length;o++)t.push({name:o,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return jc(e,t)}(e,t):zc(e)?function(e,t,n){for(var o=[],s=0;s<e.length;s++)o.push(Xc(e[s],t,n).source);return jc(new RegExp("(?:"+o.join("|")+")",Yc(n)),t)}(e,t,n):function(e,t,n){return $c(Hc(e,n),t,n)}(e,t,n)}var Kc,Zc={exports:{}},Jc={};var Qc,ep,tp={};
|
|
8
|
-
/** @license React v16.13.1
|
|
9
|
-
* react-is.development.js
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the MIT license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/ep=Zc,"production"===process.env.NODE_ENV?ep.exports=function(){if(Kc)return Jc;Kc=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,r=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,h=e?Symbol.for("react.memo"):60115,f=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var u=e.$$typeof;switch(u){case t:switch(e=e.type){case l:case c:case o:case i:case s:case d:return e;default:switch(e=e&&e.$$typeof){case a:case p:case f:case h:case r:return e;default:return u}}case n:return u}}}function x(e){return b(e)===c}return Jc.AsyncMode=l,Jc.ConcurrentMode=c,Jc.ContextConsumer=a,Jc.ContextProvider=r,Jc.Element=t,Jc.ForwardRef=p,Jc.Fragment=o,Jc.Lazy=f,Jc.Memo=h,Jc.Portal=n,Jc.Profiler=i,Jc.StrictMode=s,Jc.Suspense=d,Jc.isAsyncMode=function(e){return x(e)||b(e)===l},Jc.isConcurrentMode=x,Jc.isContextConsumer=function(e){return b(e)===a},Jc.isContextProvider=function(e){return b(e)===r},Jc.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},Jc.isForwardRef=function(e){return b(e)===p},Jc.isFragment=function(e){return b(e)===o},Jc.isLazy=function(e){return b(e)===f},Jc.isMemo=function(e){return b(e)===h},Jc.isPortal=function(e){return b(e)===n},Jc.isProfiler=function(e){return b(e)===i},Jc.isStrictMode=function(e){return b(e)===s},Jc.isSuspense=function(e){return b(e)===d},Jc.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===c||e===i||e===s||e===d||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===h||e.$$typeof===r||e.$$typeof===a||e.$$typeof===p||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y||e.$$typeof===m)},Jc.typeOf=b,Jc}():ep.exports=(Qc||(Qc=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,r=e?Symbol.for("react.provider"):60109,a=e?Symbol.for("react.context"):60110,l=e?Symbol.for("react.async_mode"):60111,c=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,u=e?Symbol.for("react.suspense_list"):60120,h=e?Symbol.for("react.memo"):60115,f=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var u=e.$$typeof;switch(u){case t:var m=e.type;switch(m){case l:case c:case o:case i:case s:case d:return m;default:var g=m&&m.$$typeof;switch(g){case a:case p:case f:case h:case r:return g;default:return u}}case n:return u}}}var x=l,w=c,C=a,k=r,S=t,E=p,_=o,T=f,M=h,I=n,P=i,N=s,A=d,R=!1;function F(e){return b(e)===c}tp.AsyncMode=x,tp.ConcurrentMode=w,tp.ContextConsumer=C,tp.ContextProvider=k,tp.Element=S,tp.ForwardRef=E,tp.Fragment=_,tp.Lazy=T,tp.Memo=M,tp.Portal=I,tp.Profiler=P,tp.StrictMode=N,tp.Suspense=A,tp.isAsyncMode=function(e){return R||(R=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),F(e)||b(e)===l},tp.isConcurrentMode=F,tp.isContextConsumer=function(e){return b(e)===a},tp.isContextProvider=function(e){return b(e)===r},tp.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},tp.isForwardRef=function(e){return b(e)===p},tp.isFragment=function(e){return b(e)===o},tp.isLazy=function(e){return b(e)===f},tp.isMemo=function(e){return b(e)===h},tp.isPortal=function(e){return b(e)===n},tp.isProfiler=function(e){return b(e)===i},tp.isStrictMode=function(e){return b(e)===s},tp.isSuspense=function(e){return b(e)===d},tp.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===c||e===i||e===s||e===d||e===u||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===h||e.$$typeof===r||e.$$typeof===a||e.$$typeof===p||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y||e.$$typeof===m)},tp.typeOf=b}()),tp);var np=Zc.exports,op={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},sp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},ip={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},rp={};function ap(e){return np.isMemo(e)?ip:rp[e.$$typeof]||op}rp[np.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},rp[np.Memo]=ip;var lp=Object.defineProperty,cp=Object.getOwnPropertyNames,pp=Object.getOwnPropertySymbols,dp=Object.getOwnPropertyDescriptor,up=Object.getPrototypeOf,hp=Object.prototype;var fp=function e(t,n,o){if("string"!=typeof n){if(hp){var s=up(n);s&&s!==hp&&e(t,s,o)}var i=cp(n);pp&&(i=i.concat(pp(n)));for(var r=ap(t),a=ap(n),l=0;l<i.length;++l){var c=i[l];if(!(sp[c]||o&&o[c]||a&&a[c]||r&&r[c])){var p=dp(n,c);try{lp(t,c,p)}catch(e){}}}}return t},mp=function(e){var t=Lc();return t.displayName=e,t},gp=mp("Router-History"),vp=mp("Router"),yp=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}lc(t,e),t.computeRootMatch=function(e){return{path:"/",url:"/",params:{},isExact:"/"===e}};var n=t.prototype;return n.componentDidMount=function(){this._isMounted=!0,this._pendingLocation&&this.setState({location:this._pendingLocation})},n.componentWillUnmount=function(){this.unlisten&&(this.unlisten(),this._isMounted=!1,this._pendingLocation=null)},n.render=function(){return T.default.createElement(vp.Provider,{value:{history:this.props.history,location:this.state.location,match:t.computeRootMatch(this.state.location.pathname),staticContext:this.props.staticContext}},T.default.createElement(gp.Provider,{children:this.props.children||null,value:this.props.history}))},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(yp.propTypes={children:I.default.node,history:I.default.object.isRequired,staticContext:I.default.object},yp.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&uc(e.history===this.props.history,"You cannot change <Router history>")});var bp=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).history=Fc(t.props),t}return lc(t,e),t.prototype.render=function(){return T.default.createElement(yp,{history:this.history,children:this.props.children})},t}(T.default.Component);if("production"!==process.env.NODE_ENV&&(bp.propTypes={initialEntries:I.default.array,initialIndex:I.default.number,getUserConfirmation:I.default.func,keyLength:I.default.number,children:I.default.node},bp.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&uc(!this.props.history,"<MemoryRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { MemoryRouter as Router }`.")}),T.default.Component,"production"!==process.env.NODE_ENV){var xp=I.default.oneOfType([I.default.func,I.default.string]);I.default.bool,xp.isRequired}"production"!==process.env.NODE_ENV&&(I.default.bool,I.default.string,I.default.oneOfType([I.default.string,I.default.object]).isRequired);var wp={},Cp=0;function kp(e,t){void 0===t&&(t={}),("string"==typeof t||Array.isArray(t))&&(t={path:t});var n=t,o=n.path,s=n.exact,i=void 0!==s&&s,r=n.strict,a=void 0!==r&&r,l=n.sensitive,c=void 0!==l&&l;return[].concat(o).reduce((function(t,n){if(!n&&""!==n)return null;if(t)return t;var o=function(e,t){var n=""+t.end+t.strict+t.sensitive,o=wp[n]||(wp[n]={});if(o[e])return o[e];var s=[],i={regexp:Bc.exports(e,s,t),keys:s};return Cp<1e4&&(o[e]=i,Cp++),i}(n,{end:i,strict:a,sensitive:c}),s=o.regexp,r=o.keys,l=s.exec(e);if(!l)return null;var p=l[0],d=l.slice(1),u=e===p;return i&&!u?null:{path:n,url:"/"===n&&""===p?"/":p,isExact:u,params:r.reduce((function(e,t,n){return e[t.name]=d[n],e}),{})}}),null)}function Sp(e){return 0===T.default.Children.count(e)}function Ep(e,t,n){var o=e(t);return"production"!==process.env.NODE_ENV&&uc(void 0!==o,"You returned `undefined` from the `children` function of <Route"+(n?' path="'+n+'"':"")+">, but you should have returned a React element or `null`"),o||null}var _p=function(e){function t(){return e.apply(this,arguments)||this}return lc(t,e),t.prototype.render=function(){var e=this;return T.default.createElement(vp.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?mc(!1,"You should not use <Route> outside a <Router>"):mc(!1));var n=e.props.location||t.location,o=la({},t,{location:n,match:e.props.computedMatch?e.props.computedMatch:e.props.path?kp(n.pathname,e.props):t.match}),s=e.props,i=s.children,r=s.component,a=s.render;return Array.isArray(i)&&Sp(i)&&(i=null),T.default.createElement(vp.Provider,{value:o},o.match?i?"function"==typeof i?"production"!==process.env.NODE_ENV?Ep(i,o,e.props.path):i(o):i:r?T.default.createElement(r,o):a?a(o):null:"function"==typeof i?"production"!==process.env.NODE_ENV?Ep(i,o,e.props.path):i(o):null)}))},t}(T.default.Component);function Tp(e){return"/"===e.charAt(0)?e:"/"+e}function Mp(e,t){if(!e)return t;var n=Tp(e);return 0!==t.pathname.indexOf(n)?t:la({},t,{pathname:t.pathname.substr(n.length)})}function Ip(e){return"string"==typeof e?e:wc(e)}function Pp(e){return function(){"production"!==process.env.NODE_ENV?mc(!1,"You cannot %s with <StaticRouter>"):mc(!1)}}function Np(){}"production"!==process.env.NODE_ENV&&(_p.propTypes={children:I.default.oneOfType([I.default.func,I.default.node]),component:function(e,t){if(e[t]&&!Zc.exports.isValidElementType(e[t]))return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component")},exact:I.default.bool,location:I.default.object,path:I.default.oneOfType([I.default.string,I.default.arrayOf(I.default.string)]),render:I.default.func,sensitive:I.default.bool,strict:I.default.bool},_p.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&uc(!(this.props.children&&!Sp(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&&uc(!(this.props.children&&!Sp(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&&uc(!(this.props.component&&this.props.render),"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored")},_p.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&uc(!(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&&uc(!(!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 Ap=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).handlePush=function(e){return t.navigateTo(e,"PUSH")},t.handleReplace=function(e){return t.navigateTo(e,"REPLACE")},t.handleListen=function(){return Np},t.handleBlock=function(){return Np},t}lc(t,e);var n=t.prototype;return n.navigateTo=function(e,t){var n=this.props,o=n.basename,s=void 0===o?"":o,i=n.context,r=void 0===i?{}:i;r.action=t,r.location=function(e,t){return e?la({},t,{pathname:Tp(e)+t.pathname}):t}(s,Cc(e)),r.url=Ip(r.location)},n.render=function(){var e=this.props,t=e.basename,n=void 0===t?"":t,o=e.context,s=void 0===o?{}:o,i=e.location,r=void 0===i?"/":i,a=ca(e,["basename","context","location"]),l={createHref:function(e){return Tp(n+Ip(e))},action:"POP",location:Mp(n,Cc(r)),push:this.handlePush,replace:this.handleReplace,go:Pp(),goBack:Pp(),goForward:Pp(),listen:this.handleListen,block:this.handleBlock};return T.default.createElement(yp,la({},a,{history:l,staticContext:s}))},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(Ap.propTypes={basename:I.default.string,context:I.default.object,location:I.default.oneOfType([I.default.string,I.default.object])},Ap.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&uc(!this.props.history,"<StaticRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { StaticRouter as Router }`.")});var Rp=function(e){function t(){return e.apply(this,arguments)||this}return lc(t,e),t.prototype.render=function(){var e=this;return T.default.createElement(vp.Consumer,null,(function(t){t||("production"!==process.env.NODE_ENV?mc(!1,"You should not use <Switch> outside a <Router>"):mc(!1));var n,o,s=e.props.location||t.location;return T.default.Children.forEach(e.props.children,(function(e){if(null==o&&T.default.isValidElement(e)){n=e;var i=e.props.path||e.props.from;o=i?kp(s.pathname,la({},e.props,{path:i})):t.match}})),o?T.default.cloneElement(n,{location:s,computedMatch:o}):null}))},t}(T.default.Component);if("production"!==process.env.NODE_ENV&&(Rp.propTypes={children:I.default.node,location:I.default.object},Rp.prototype.componentDidUpdate=function(e){"production"!==process.env.NODE_ENV&&uc(!(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&&uc(!(!this.props.location&&e.location),'<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.')}),T.default.useContext,"production"!==process.env.NODE_ENV&&"undefined"!=typeof window){var Fp=window,Op="__react_router_build__",Dp={cjs:"CommonJS",esm:"ES modules",umd:"UMD"};if(Fp[Op]&&"esm"!==Fp[Op]){var Lp=Dp[Fp[Op]];throw new Error("You are loading the "+Dp.esm+" build of React Router on a page that is already running the "+Lp+" build, so things won't work right.")}Fp[Op]="esm"}var Bp=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).history=Tc(t.props),t}return lc(t,e),t.prototype.render=function(){return T.default.createElement(yp,{history:this.history,children:this.props.children})},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(Bp.propTypes={basename:I.default.string,children:I.default.node,forceRefresh:I.default.bool,getUserConfirmation:I.default.func,keyLength:I.default.number},Bp.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&uc(!this.props.history,"<BrowserRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { BrowserRouter as Router }`.")});var zp=function(e){function t(){for(var t,n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return(t=e.call.apply(e,[this].concat(o))||this).history=Ac(t.props),t}return lc(t,e),t.prototype.render=function(){return T.default.createElement(yp,{history:this.history,children:this.props.children})},t}(T.default.Component);"production"!==process.env.NODE_ENV&&(zp.propTypes={basename:I.default.string,children:I.default.node,getUserConfirmation:I.default.func,hashType:I.default.oneOf(["hashbang","noslash","slash"])},zp.prototype.componentDidMount=function(){"production"!==process.env.NODE_ENV&&uc(!this.props.history,"<HashRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { HashRouter as Router }`.")});var qp=function(e,t){return"function"==typeof e?e(t):e},Hp=function(e,t){return"string"==typeof e?Cc(e,null,null,t):e},Wp=function(e){return e},Up=T.default.forwardRef;void 0===Up&&(Up=Wp);var Gp=Up((function(e,t){var n=e.innerRef,o=e.navigate,s=e.onClick,i=ca(e,["innerRef","navigate","onClick"]),r=i.target,a=la({},i,{onClick:function(e){try{s&&s(e)}catch(t){throw e.preventDefault(),t}e.defaultPrevented||0!==e.button||r&&"_self"!==r||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||(e.preventDefault(),o())}});return a.ref=Wp!==Up&&t||n,T.default.createElement("a",a)}));"production"!==process.env.NODE_ENV&&(Gp.displayName="LinkAnchor");var Vp=Up((function(e,t){var n=e.component,o=void 0===n?Gp:n,s=e.replace,i=e.to,r=e.innerRef,a=ca(e,["component","replace","to","innerRef"]);return T.default.createElement(vp.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?mc(!1,"You should not use <Link> outside a <Router>"):mc(!1));var n=e.history,l=Hp(qp(i,e.location),e.location),c=l?n.createHref(l):"",p=la({},a,{href:c,navigate:function(){var t=qp(i,e.location),o=wc(e.location)===wc(Hp(t));(s||o?n.replace:n.push)(t)}});return Wp!==Up?p.ref=t||r:p.innerRef=r,T.default.createElement(o,p)}))}));if("production"!==process.env.NODE_ENV){var jp=I.default.oneOfType([I.default.string,I.default.object,I.default.func]),Yp=I.default.oneOfType([I.default.string,I.default.func,I.default.shape({current:I.default.any})]);Vp.displayName="Link",Vp.propTypes={innerRef:Yp,onClick:I.default.func,replace:I.default.bool,target:I.default.string,to:jp.isRequired}}var $p=function(e){return e},Xp=T.default.forwardRef;void 0===Xp&&(Xp=$p);var Kp=Xp((function(e,t){var n=e["aria-current"],o=void 0===n?"page":n,s=e.activeClassName,i=void 0===s?"active":s,r=e.activeStyle,a=e.className,l=e.exact,c=e.isActive,p=e.location,d=e.sensitive,u=e.strict,h=e.style,f=e.to,m=e.innerRef,g=ca(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return T.default.createElement(vp.Consumer,null,(function(e){e||("production"!==process.env.NODE_ENV?mc(!1,"You should not use <NavLink> outside a <Router>"):mc(!1));var n=p||e.location,s=Hp(qp(f,n),n),v=s.pathname,y=v&&v.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),b=y?kp(n.pathname,{path:y,exact:l,sensitive:d,strict:u}):null,x=!!(c?c(b,n):b),w="function"==typeof a?a(x):a,C="function"==typeof h?h(x):h;x&&(w=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((function(e){return e})).join(" ")}(w,i),C=la({},C,r));var k=la({"aria-current":x&&o||null,className:w,style:C,to:s},g);return $p!==Xp?k.ref=t||m:k.innerRef=m,T.default.createElement(Vp,k)}))}));if("production"!==process.env.NODE_ENV){Kp.displayName="NavLink";var Zp=I.default.oneOf(["page","step","location","date","time","true","false"]);Kp.propTypes=la({},Vp.propTypes,{"aria-current":Zp,activeClassName:I.default.string,activeStyle:I.default.object,className:I.default.oneOfType([I.default.string,I.default.func]),exact:I.default.bool,isActive:I.default.func,location:I.default.object,sensitive:I.default.bool,strict:I.default.bool,style:I.default.oneOfType([I.default.object,I.default.func])})}const Jp=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}}},Qp={onClick:()=>{},onMouseEnter:()=>{},onMouseLeave:()=>{},onMouseDown:()=>{},onMouseUp:()=>{},onDragStart:()=>{},onTouchStart:()=>{},onTouchEnd:()=>{},onTouchCancel:()=>{},onKeyDown:()=>{},onKeyUp:()=>{},tabIndex:0},ed=13,td=32,nd={hovered:!1,focused:!1,pressed:!1,waiting:!1};class od extends _.Component{static getDerivedStateFromProps(e,t){return e.disabled?la({},nd,{focused:t.focused}):null}constructor(e){super(e),this.handleClick=e=>{const{onClick:t,beforeNav:n,safeWithNav:o}=this.props;this.enterClick||((t||n||o)&&(this.waitingForClick=!1),this.runCallbackAndMaybeNavigate(e))},this.handleMouseEnter=e=>{1===e.buttons?(this.dragging=!0,this.setState({pressed:!0})):this.waitingForClick||this.setState({hovered:!0})},this.handleMouseLeave=()=>{this.waitingForClick||(this.dragging=!1,this.setState({hovered:!1,pressed:!1,focused:!1}))},this.handleMouseDown=()=>{this.setState({pressed:!0})},this.handleMouseUp=e=>{this.dragging&&(this.dragging=!1,this.handleClick(e)),this.setState({pressed:!1,focused:!1})},this.handleDragStart=e=>{this.dragging=!0,e.preventDefault()},this.handleTouchStart=()=>{this.setState({pressed:!0})},this.handleTouchEnd=()=>{this.setState({pressed:!1}),this.waitingForClick=!0},this.handleTouchCancel=()=>{this.setState({pressed:!1}),this.waitingForClick=!0},this.handleKeyDown=e=>{const{onKeyDown:t,role:n}=this.props;t&&t(e);const o=e.which||e.keyCode,{triggerOnEnter:s,triggerOnSpace:i}=Jp(n);s&&o===ed||i&&o===td?(e.preventDefault(),this.setState({pressed:!0})):s||o!==ed||(this.enterClick=!0)},this.handleKeyUp=e=>{const{onKeyUp:t,role:n}=this.props;t&&t(e);const o=e.which||e.keyCode,{triggerOnEnter:s,triggerOnSpace:i}=Jp(n);s&&o===ed||i&&o===td?(this.setState({pressed:!1,focused:!0}),this.runCallbackAndMaybeNavigate(e)):s||o!==ed||(this.enterClick=!1)},this.handleFocus=e=>{this.setState({focused:!0})},this.handleBlur=e=>{this.setState({focused:!1,pressed:!1})},this.state=nd,this.waitingForClick=!1,this.enterClick=!1,this.dragging=!1}navigateOrReset(e){if(e){const{history:e,href:t,skipClientNav:n,target:o}=this.props;t&&("_blank"===o?(window.open(t,"_blank"),this.setState({waiting:!1})):e&&!n?(e.push(t),this.setState({waiting:!1})):window.location.assign(t))}else this.setState({waiting:!1})}handleSafeWithNav(e,t){const{skipClientNav:n,history:o}=this.props;return o&&!n||"_blank"===this.props.target?(e(),this.navigateOrReset(t),Promise.resolve()):(this.state.waiting||this.setState({waiting:!0}),e().then((()=>{this.state.waiting||this.setState({waiting:!0})})).catch((e=>{})).finally((()=>{this.navigateOrReset(t)})))}runCallbackAndMaybeNavigate(e){const{onClick:t,beforeNav:n,safeWithNav:o,href:s,type:i}=this.props;let r=!0,a=!0;if(t&&t(e),e.defaultPrevented&&(r=!1,a=!1),e.preventDefault(),!s&&"submit"===i&&a){let t=e.currentTarget;for(;t;){if(t instanceof window.HTMLFormElement){const e=new window.Event("submit",{cancelable:!0});t.dispatchEvent(e);break}t=t.parentElement}}if(n)this.setState({waiting:!0}),n().then((()=>o?this.handleSafeWithNav(o,r):this.navigateOrReset(r))).catch((()=>{}));else{if(o)return this.handleSafeWithNav(o,r);this.navigateOrReset(r)}}render(){const e=this.props.disabled?la({},Qp,{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)}}od.defaultProps={disabled:!1};const sd=e=>"string"==typeof e&&(!/^(https?:)?\/\//i.test(e)&&!/^([^#]*#[\w-]*|[\w\-.]+:)/.test(e)),id=(ad="withRouter("+((rd=od).displayName||rd.name)+")",ld=function(e){var t=e.wrappedComponentRef,n=ca(e,["wrappedComponentRef"]);return T.default.createElement(vp.Consumer,null,(function(e){return e||("production"!==process.env.NODE_ENV?mc(!1,"You should not use <"+ad+" /> outside a <Router>"):mc(!1)),T.default.createElement(rd,la({},n,e,{ref:t}))}))},ld.displayName=ad,ld.WrappedComponent=rd,"production"!==process.env.NODE_ENV&&(ld.propTypes={wrappedComponentRef:I.default.oneOfType([I.default.string,I.default.func,I.default.object])}),fp(ld,rd));var rd,ad,ld;function cd(e,t,n){return n&&!0!==t&&e&&sd(e)?id:od}const pd=["href","onClick","skipClientNav","beforeNav","safeWithNav","style","target","testId","onKeyDown","onKeyUp","hideDefaultFocusRing","light","disabled"],dd=m.addStyle("a"),ud=m.addStyle("button"),hd=m.addStyle(Vp);class fd extends _.Component{constructor(...e){super(...e),this.getCorrectTag=(e,t,n)=>{const o=this.props.href&&!this.props.disabled,s=t&&!this.props.skipClientNav&&sd(this.props.href||"");return o&&s&&this.props.href?_.createElement(hd,la({},n,{to:this.props.href,role:this.props.role,target:this.props.target||void 0,"aria-disabled":this.props.disabled?"true":void 0}),this.props.children(e)):o&&!s?_.createElement(dd,la({},n,{href:this.props.href,role:this.props.role,target:this.props.target||void 0,"aria-disabled":this.props.disabled?"true":void 0}),this.props.children(e)):_.createElement(ud,la({},n,{type:"button","aria-disabled":this.props.disabled}),this.props.children(e))}}renderClickableBehavior(e){const t=this.props,{href:n,onClick:o,skipClientNav:s,beforeNav:i,safeWithNav:r,style:a,target:l,testId:c,onKeyDown:p,onKeyUp:d,hideDefaultFocusRing:u,light:h,disabled:f}=t,m=ca(t,pd),g=cd(n,s,e),v=e=>[md.reset,md.link,!u&&e.focused&&(h?md.focusedLight:md.focused),a];return i?_.createElement(g,{href:n,onClick:o,beforeNav:i,safeWithNav:r,onKeyDown:p,onKeyUp:d,disabled:f},((t,n)=>this.getCorrectTag(t,e,la({},m,{"data-test-id":c,style:v(t)},n)))):_.createElement(g,{href:n,onClick:o,safeWithNav:r,onKeyDown:p,onKeyUp:d,target:l,disabled:f},((t,n)=>this.getCorrectTag(t,e,la({},m,{"data-test-id":c,style:v(t)},n))))}render(){return _.createElement(vp.Consumer,null,(e=>this.renderClickableBehavior(e)))}}fd.defaultProps={light:!1,disabled:!1,"aria-label":""};const md=l.StyleSheet.create({reset:{border:"none",margin:0,padding:0,width:"auto",overflow:"visible",background:"transparent",textDecoration:"none",color:"inherit",font:"inherit",boxSizing:"border-box",touchAction:"manipulation",userSelect:"none",outline:"none",lineHeight:"normal",WebkitFontSmoothing:"inherit",MozOsxFontSmoothing:"inherit"},link:{cursor:"pointer"},focused:{outline:`solid 2px ${D.default.blue}`},focusedLight:{outline:`solid 2px ${D.default.white}`}}),gd={xsmall:16,small:24,medium:48,large:96},vd={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"},yd={light:D.default.white,dark:D.default.offBlack16},bd=m.addStyle("path");class xd extends _.Component{render(){const{size:e,light:t,style:n}=this.props,o=gd[e],s=vd[e],i=t?yd.light:yd.dark,r=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:`0 0 ${o} ${o}`},_.createElement(bd,{style:[wd.loadingSpinner,{fill:i}],fillRule:"nonzero",d:s}));return _.createElement(m.View,{style:[wd.spinnerContainer,n]},r)}}xd.defaultProps={size:"large",light:!1};const wd=l.StyleSheet.create({spinnerContainer:{justifyContent:"center"},loadingSpinner:{transformOrigin:"50% 50%",animationName:{"0%":{transform:"rotate(0deg)"},"50%":{transform:"rotate(180deg)"},"100%":{transform:"rotate(360deg)"}},animationDuration:"1.1s",animationIterationCount:"infinite",animationTimingFunction:"linear"}}),Cd=e=>({small:16,medium:24,large:48,xlarge:96}[e]),kd=["color","icon","size","style"],Sd=m.addStyle("svg");class Ed extends _.PureComponent{render(){const e=this.props,{color:t,icon:n,size:o,style:s}=e,i=ca(e,kd),{assetSize:r,path:a}=((e,t)=>{if(e[t])return{assetSize:t,path:e[t]};{const n=Cd(t),o=Object.keys(e),s=e=>{const t=Cd(e)-n;return t>0?Number.POSITIVE_INFINITY:Math.abs(t)},i=o.sort(((e,t)=>s(e)-s(t)))[0];if(i&&e[i])return{assetSize:i,path:e[i]};throw new Error("Icon does not contain any valid asset sizes!")}})(n,o),l=Cd(o),c=Cd(r);return _.createElement(Sd,la({},i,{style:[_d.svg,s],width:l,height:l,viewBox:`0 0 ${c} ${c}`}),_.createElement("path",{fill:t,d:a}))}}Ed.defaultProps={color:"currentColor",size:"small"};const _d=l.StyleSheet.create({svg:{display:"inline-block",verticalAlign:"text-bottom",flexShrink:0,flexGrow:0}}),Td=["children","skipClientNav","color","disabled","focused","hovered","href","kind","light","pressed","size","style","testId","type","spinner","icon","id","waiting"],Md=m.addStyle("a"),Id=m.addStyle("button"),Pd=m.addStyle(Vp);class Nd extends _.Component{renderInner(e){const t=this.props,{children:n,skipClientNav:o,color:s,disabled:i,focused:r,hovered:a,href:l,kind:c,light:p,pressed:d,size:u,style:h,testId:m,type:g,spinner:v,icon:y,id:b}=t,x=ca(t,Td),w="destructive"===s?f.SemanticColor.controlDestructive:f.SemanticColor.controlDefault,C=Fd(w,c,p,y?8+("small"===u?16:24):0,u),k=v||i,S=la({"data-test-id":m,id:b,role:"button",style:[[Ad.shared,k&&Ad.disabled,y&&Ad.withIcon,C.default,k&&C.disabled,"tertiary"!==c&&!k&&(d?C.active:(a||r)&&C.focus),"small"===u&&Ad.small,"xlarge"===u&&Ad.xlarge],h]},x),E="small"===u?Ba:Fa,T=_.createElement(E,{style:[Ad.text,"xlarge"===u&&Ad.xlargeText,y&&Ad.textWithIcon,v&&Ad.hiddenText,"tertiary"===c&&Ad.textWithFocus,"tertiary"===c&&!k&&(d?C.active:(a||r)&&C.focus)]},y&&_.createElement(Ed,{size:u,color:"currentColor",icon:y,style:Ad.icon}),n),M=_.createElement(_.Fragment,null,T,v&&_.createElement(xd,{style:Ad.spinner,size:{medium:"small",small:"xsmall",xlarge:"medium"}[u],light:"primary"===c}));return l&&!k?e&&!o&&sd(l)?_.createElement(Pd,la({},S,{to:l}),M):_.createElement(Md,la({},S,{href:l}),M):_.createElement(Id,la({type:g||"button"},S,{"aria-disabled":k}),M)}render(){return _.createElement(vp.Consumer,null,(e=>this.renderInner(e)))}}const Ad=l.StyleSheet.create({shared:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:40,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16,border:"none",borderRadius:4,cursor:"pointer",outline:"none",textDecoration:"none",boxSizing:"border-box",touchAction:"manipulation",userSelect:"none",":focus":{WebkitTapHighlightColor:"rgba(0,0,0,0)"}},withIcon:{paddingLeft:12},disabled:{cursor:"auto"},small:{height:32},xlarge:{height:60},text:{alignItems:"center",fontWeight:"bold",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",pointerEvents:"none"},xlargeText:{fontSize:18,lineHeight:"20px"},textWithIcon:{display:"flex"},textWithFocus:{position:"relative"},hiddenText:{visibility:"hidden"},spinner:{position:"absolute"},icon:{paddingRight:L.default.xSmall_8}}),Rd={},Fd=(e,t,n,o,s)=>{const i=e+t+n.toString()+o.toString()+s;if(Rd[i])return Rd[i];const{white:r,white50:a,white64:c,offBlack32:p,offBlack50:d,darkBlue:u}=D.default,h=f.mix(f.fade(e,.32),r),m=f.mix(p,e),g="xlarge"===s?L.default.xLarge_32:L.default.medium_16;let v={};if("primary"===t)v={default:{background:n?r:e,color:n?e:r,paddingLeft:g,paddingRight:g},focus:{boxShadow:`0 0 0 1px ${n?u:r}, 0 0 0 3px ${n?r:e}`},active:{boxShadow:`0 0 0 1px ${n?u:r}, 0 0 0 3px ${n?h:m}`,background:n?h:m,color:n?m:h},disabled:{background:n?h:p,color:n?e:c,cursor:"default",":focus":{boxShadow:`0 0 0 1px ${n?p:r}, 0 0 0 3px ${n?h:p}`}}};else if("secondary"===t)v={default:{background:"none",color:n?r:e,borderColor:n?a:d,borderStyle:"solid",borderWidth:1,paddingLeft:o?g-4:g,paddingRight:g},focus:{background:n?"transparent":r,borderColor:n?r:e,borderWidth:2,paddingLeft:o?g-5:g-1,paddingRight:g-1},active:{background:n?m:h,color:n?h:m,borderColor:n?h:m,borderWidth:2,paddingLeft:o?g-5:g-1,paddingRight:g-1},disabled:{color:n?a:p,borderColor:n?h:p,cursor:"default",":focus":{borderColor:n?a:p,borderWidth:2,paddingLeft:o?g-5:g-1,paddingRight:g-1}}};else{if("tertiary"!==t)throw new Error("Button kind not recognized");v={default:{background:"none",color:n?r:e,paddingLeft:0,paddingRight:0},focus:{":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${o}px)`,right:0,bottom:0,background:n?r:e,borderRadius:2}},active:{color:n?h:m,":after":{content:"''",position:"absolute",height:2,width:`calc(100% - ${o}px)`,right:0,bottom:"calc(50% - 11px)",background:n?h:m,borderRadius:2}},disabled:{color:n?h:p,cursor:"default"}}}return Rd[i]=l.StyleSheet.create(v),Rd[i]},Od=["href","type","children","skipClientNav","spinner","disabled","onClick","beforeNav","safeWithNav","tabIndex","target","rel"],Dd=["tabIndex"];class Ld extends _.Component{renderClickableBehavior(e){const t=this.props,{href:n,type:o,children:s,skipClientNav:i,spinner:r,disabled:a,onClick:l,beforeNav:c,safeWithNav:p,tabIndex:d,target:u,rel:h}=t,f=ca(t,Od),m=cd(n,i,e),g=(e,t)=>{let{tabIndex:l}=t,c=ca(t,Dd);return _.createElement(Nd,la({},f,e,c,{disabled:a,spinner:r||e.waiting,skipClientNav:i,href:n,target:u,type:o,tabIndex:d||l}),s)};return c?_.createElement(m,{disabled:r||a,href:n,role:"button",type:o,onClick:l,beforeNav:c,safeWithNav:p,rel:h},g):_.createElement(m,{disabled:r||a,href:n,role:"button",type:o,onClick:l,safeWithNav:p,target:u,rel:h},g)}render(){return _.createElement(vp.Consumer,null,(e=>this.renderClickableBehavior(e)))}}Ld.defaultProps={color:"default",kind:"primary",light:!1,size:"medium",disabled:!1,spinner:!1};class Bd extends _.Component{render(){const{apiOptions:e,answerBarState:t,onCheckAnswer:n,onNextQuestion:o}=this.props,s={...zd.answerBar,backgroundColor:"CORRECT"===t?D.default.offWhite:"white",justifyContent:"CORRECT"!==t||o?"space-between":"center"},i="INCORRECT"===t?_.createElement("span",{style:zd.text},_.createElement("span",{style:zd.tryAgainIcon},_.createElement(G,ko)),_.createElement("span",{style:{marginLeft:8}},S._("Keep trying"))):_.createElement("span",null);if("CORRECT"!==t){const o="INCORRECT"===t?S._("Try again"):S._("Check");return _.createElement("div",{style:s},i,_.createElement(Ld,{disabled:e.readOnly||"ACTIVE"!==t,onClick:n},o))}return _.createElement("div",{style:s},_.createElement("span",{style:zd.text},_.createElement("span",{style:{fontSize:28,color:D.default.green}},_.createElement(G,U({},Co,{style:{marginBottom:5}}))),_.createElement("span",{role:"alert","aria-label":S._("Correct!"),style:{marginLeft:8}},S._("Correct!"))),o&&_.createElement(Ld,{onClick:o},S._("Next question")))}}const zd={answerBar:{display:"flex",alignItems:"center",height:68,marginLeft:-16,marginRight:-16,marginBottom:-16,marginTop:16,paddingLeft:16,paddingRight:10,borderTop:"1px solid ".concat(D.default.offBlack50)},tryAgainIcon:{fontSize:28,color:"#63D9EA",transform:"scale(-1,1) rotate(-268deg)"},text:{display:"flex",flexDirection:"row",alignItems:"center",fontWeight:"bold",fontSize:17}},qd="ungraded",Hd="correct",Wd="incorrect",Ud="invalid",Gd=(e,t)=>{switch(e){case"HIDDEN":case"INACTIVE":return t?"ACTIVE":e;case"ACTIVE":return t?e:"INACTIVE";case"INCORRECT":return t?"ACTIVE":"INACTIVE";default:return e}},Vd=S._("We couldn't grade your answer."),jd=S._("It looks like you left something blank or ")+S._("entered in an invalid answer.");class Yd extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"state",{status:qd,showHint:!1,message:"",answerBarState:"HIDDEN"}),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"_onInteractWithWidget",(e=>{if(this.setState({status:qd,message:""}),this.refs.renderer){this.change("widgets",this.props.widgets);const e=0===this.refs.renderer.emptyWidgets().length,t=this.state.answerBarState;this.setState({answerBarState:Gd(t,e)})}})),W(this,"_checkAnswer",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices();const e=this.refs.renderer.score(),t="points"===e.type?e.total===e.earned?Hd:Wd:Ud,n="points"===e.type?e.message||"":e.message?"".concat(Vd," ").concat(e.message):"".concat(Vd," ").concat(jd);this.setState({status:t,message:n,answerBarState:"correct"===t?"CORRECT":"INCORRECT"}),this.props.trackInteraction({status:t})})),W(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),W(this,"setInputValue",((e,t,n)=>this.refs.renderer.setInputValue(e,t,n))),W(this,"focus",(()=>this.refs.renderer.focus())),W(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),W(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){const e=M.default.extend({},Yt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}});let t=null,n=null;this.state.status===Hd?(n=_.createElement(G,U({},bo,{style:{color:"#526f03"}})),t=S._("Correct")):this.state.status===Wd&&(n=_.createElement(G,U({},wo,{style:{color:"#ff5454"}})),t=S._("Incorrect"));const o=this.props.inGradedGroupSet?l.css($d.gradedGroupInSet):l.css($d.gradedGroup),s=E.default({[o]:e.isMobile,"perseus-graded-group":!0,"answer-correct":!e.isMobile&&this.state.status===Hd,"answer-incorrect":!e.isMobile&&this.state.status===Wd}),{answerBarState:i}=this.state,r="CORRECT"===i,a=e.readOnly||e.isMobile&&r;return _.createElement("div",{className:s},!!this.props.title&&_.createElement("div",{className:l.css($d.title)},this.props.title),_.createElement(Ai,U({},this.props,{ref:"renderer",apiOptions:{...e,readOnly:a},onInteractWithWidget:this._onInteractWithWidget,linterContext:this.props.linterContext})),!e.isMobile&&n&&_.createElement("div",{className:"group-icon"},n),!e.isMobile&&t&&_.createElement("div",{className:l.css(ll.srOnly),role:"alert","aria-label":t},t),!e.isMobile&&_.createElement("p",null,this.state.message),!e.isMobile&&_.createElement(Ld,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this._checkAnswer},S._("Check")),!e.isMobile&&r&&this.props.onNextQuestion&&_.createElement(Ld,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this.props.onNextQuestion,style:{marginLeft:5}},S._("Next question")),this.props.hint&&this.props.hint.content&&(this.state.showHint?_.createElement("div",null,_.createElement("button",{tabIndex:"0",className:l.css($d.explanationTitle),onClick:()=>this.setState({showHint:!1}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!1})}},S._("Hide explanation")),_.createElement(Ai,U({},this.props.hint,{ref:"hints-renderer",apiOptions:e,linterContext:this.props.linterContext}))):_.createElement("button",{tabIndex:"0",onClick:()=>this.setState({showHint:!0}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!0})},className:l.css($d.showHintLink)},S._("Explain"))),e.isMobile&&"HIDDEN"!==i&&_.createElement(Bd,{apiOptions:e,answerBarState:i,onCheckAnswer:this._checkAnswer,onNextQuestion:this.props.onNextQuestion}))}}W(Yd,"defaultProps",{title:"",content:"",widgets:{},images:{},hint:null,hasHint:!1,linterContext:Ht});const $d=l.StyleSheet.create({gradedGroupInSet:{marginLeft:0,paddingLeft:0},gradedGroup:{borderTop:"1px solid ".concat(Y),borderBottom:"1px solid ".concat(Y),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"},showHintLink:{backgroundColor:"unset",fontSize:14,padding:0,border:"none",marginTop:20,color:"#71B307",cursor:"pointer",display:"block",clear:"both"},explanationTitle:{backgroundColor:"unset",marginTop:20,color:"#71B307",marginBottom:10,cursor:"pointer",fontSize:14,padding:0,border:"none",display:"block",clear:"both"},title:{fontSize:12,color:Y,textTransform:"uppercase",marginBottom:11,letterSpacing:.8}});var Xd={name:"graded-group",displayName:"Graded group (articles only)",widget:Yd,traverseChildWidgets:function(e,t){return M.default.extend({},e,t(e))},hidden:!1,tracking:"all",isLintable:!0};const Kd=Xd.widget;class Zd extends _.Component{render(){const e=[];for(let t=0;t<this.props.numGroups;t++)e.push(_.createElement("div",{role:"button","aria-label":S._("Skip to %(title)s",{title:this.props.groupTitles[t]}),key:t,className:l.css(eu.indicator,t===this.props.currentGroup&&eu.selectedIndicator),onClick:()=>this.props.onChangeCurrentGroup(t)}));return _.createElement("div",{className:l.css(eu.indicatorContainer)},e)}}class Jd extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"_childGroup",void 0),W(this,"state",{currentGroup:0}),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"getInputPaths",(()=>this._childGroup.getInputPaths())),W(this,"setInputValue",((e,t,n)=>this._childGroup.setInputValue(e,t,n))),W(this,"focus",(()=>this._childGroup.focus())),W(this,"focusInputPath",(e=>{this._childGroup.focusInputPath(e)})),W(this,"blurInputPath",(e=>{this._childGroup.blurInputPath(e)})),W(this,"handleNextQuestion",(()=>{const{currentGroup:e}=this.state;e<this.props.gradedGroups.length-1&&this.setState({currentGroup:e+1})}))}shouldComponentUpdate(e,t){return e.gradedGroups,e!==this.props||t!==this.state}render(){const{JIPT:e}=ne();if(e.useJIPT&&this.props.gradedGroups.length>1)return _.createElement("div",{className:l.css(eu.container)},this.props.gradedGroups.map(((e,t)=>_.createElement(Kd,U({key:t},this.props,e,{inGradedGroupSet:!1,linterContext:this.props.linterContext})))));const t=this.props.gradedGroups[this.state.currentGroup];if(!t)return _.createElement("span",null,S.doNotTranslate("No current group..."));const n=this.props.gradedGroups.length,o=this.state.currentGroup<n-1?this.handleNextQuestion:null;return _.createElement("div",{className:l.css(eu.container)},_.createElement("div",{className:l.css(eu.top)},_.createElement("div",{className:l.css(eu.title)},t.title),_.createElement("div",{className:l.css(eu.spacer)}),_.createElement(Zd,{numGroups:n,currentGroup:this.state.currentGroup,groupTitles:this.props.gradedGroups.map((e=>e.title)),onChangeCurrentGroup:e=>this.setState({currentGroup:e})})),_.createElement(Kd,U({key:this.state.currentGroup,ref:e=>this._childGroup=e},this.props,t,{inGradedGroupSet:!0,title:null,onNextQuestion:o,linterContext:this.props.linterContext})))}}W(Jd,"defaultProps",{gradedGroups:[],linterContext:Ht});var Qd={name:"graded-group-set",displayName:"Graded group set (articles only)",widget:Jd,traverseChildWidgets:function(e,t){return{groups:e.gradedGroups.map(t)}},hidden:!1,tracking:"all",isLintable:!0};const eu=l.StyleSheet.create({top:{display:"flex",flexDirection:"row"},spacer:{flex:1},title:{fontSize:12,color:Y,textTransform:"uppercase",marginBottom:11,letterSpacing:.8},indicatorContainer:{display:"flex",flexDirection:"row"},indicator:{width:10,height:10,borderRadius:5,backgroundColor:"#AAAAAA",marginLeft:5,cursor:"pointer"},selectedIndicator:{backgroundColor:"#71B307"},container:{borderTop:"1px solid ".concat(Y),borderBottom:"1px solid ".concat(Y),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"}});class tu extends _.Component{constructor(){super(...arguments),W(this,"container",void 0)}componentWillUnmount(){this.container=null}focus(){if(this.container)return this.container.focus(),!0}toggleSelect(e){const t=this.props.value;this.props.allowEmpty?this.props.onChange(t!==e?e:null):this.props.onChange(e)}render(){const e=this.props.value,t=this.props.buttons.map(((t,n)=>_.createElement("button",{title:t.title,type:"button",id:""+n,ref:"button"+n,key:""+n,className:l.css(nu.buttonStyle,t.value===e&&nu.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)));return _.createElement("div",{style:{display:"inline-block"},ref:e=>this.container=e},t)}}W(tu,"defaultProps",{value:null,allowEmpty:!0});const nu=l.StyleSheet.create({buttonStyle:{backgroundColor:"white",border:"1px solid #ccc",borderLeft:"0",cursor:"pointer",margin:"0",padding:"5px 10px",position:"relative",":first-child":{borderLeft:"1px solid #ccc",borderTopLeftRadius:"3px",borderBottomLeftRadius:"3px"},":last-child":{borderRight:"1px solid #ccc",borderTopRightRadius:"3px",borderBottomRightRadius:"3px"},":hover":{backgroundColor:"#ccc"},":focus":{zIndex:2}},selectedStyle:{backgroundColor:"#ddd"}}),ou={url:null};function su(e){let t=e[0],n=e[1],o=e[2];const s=e[3];t<0&&(t*=-1,n*=-1,o*=-1);const i=2*Math.PI;for(n<0&&(n*=-1,o*=-1,o+=i/2);o>0;)o-=i;for(;o<0;)o+=i;return[t,n,o,s]}function iu(e){let t=e[0],n=e[1],o=e[2];const s=e[3];t<0&&(t*=-1,n*=-1,o*=-1);const i=Math.PI;for(n<0&&(n*=-1,o*=-1,o+=i/2);o>0;)o-=i;for(;o<0;)o+=i;return[t,n,o,s]}const ru={areEqual:function(e,t){return Ae.deepEq(e,t)},Movable:Es.Plot,getPropsForCoeffs:function(e){return{fn:M.default.partial(this.getFunctionForCoeffs,e)}}},au=M.default.extend({},ru,{url:"https://ka-perseus-graphie.s3.amazonaws.com/67aaf581e6d9ef9038c10558a1f70ac21c11c9f8.png",defaultCoords:[[.25,.75],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],o=n[0]-t[0],s=n[1]-t[1];if(0===o)return;const i=s/o;return[i,n[1]-i*n[0]]},getFunctionForCoeffs:function(e,t){return e[0]*t+e[1]},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1];return"y = "+n.toFixed(3)+"x + "+o.toFixed(3)}}),lu=M.default.extend({},ru,{url:"https://ka-perseus-graphie.s3.amazonaws.com/e23d36e6fc29ee37174e92c9daba2a66677128ab.png",defaultCoords:[[.5,.5],[.75,.75]],Movable:Es.Parabola,getCoefficients:function(e){const t=e[0],n=e[1],o=t[0],s=t[1],i=(n[1]-s)/((n[0]-o)*(n[0]-o));return[i,-2*o*i,i*o*o+s]},getFunctionForCoeffs:function(e,t){return(e[0]*t+e[1])*t+e[2]},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2]}},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2];return"y = "+n.toFixed(3)+"x^2 + "+o.toFixed(3)+"x + "+s.toFixed(3)}}),cu=M.default.extend({},ru,{url:"https://ka-perseus-graphie.s3.amazonaws.com/3d68e7718498475f53b206c2ab285626baf8857e.png",defaultCoords:[[.5,.5],[.6,.6]],Movable:Es.Sinusoid,getCoefficients:function(e){const t=e[0],n=e[1],o=n[1]-t[1],s=Math.PI/(2*(n[0]-t[0]));return[o,s,t[0]*s,t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2],i=e[3];return n*Math.sin(o*t-s)+i},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2],d:e[3]}},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2],i=t[3];return"y = "+n.toFixed(3)+" sin("+o.toFixed(3)+"x - "+s.toFixed(3)+") + "+i.toFixed(3)},areEqual:function(e,t){return Ae.deepEq(su(e),su(t))}}),pu=M.default.extend({},ru,{url:"https://ka-perseus-graphie.s3.amazonaws.com/7db80d23c35214f98659fe1cf0765811c1bbfbba.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],o=n[1]-t[1],s=Math.PI/(4*(n[0]-t[0]));return[o,s,t[0]*s,t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2],i=e[3];return n*Math.tan(o*t-s)+i},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2],i=t[3];return"y = "+n.toFixed(3)+" sin("+o.toFixed(3)+"x - "+s.toFixed(3)+") + "+i.toFixed(3)},areEqual:function(e,t){return Ae.deepEq(iu(e),iu(t))}}),du=M.default.extend({},ru,{url:"https://ka-perseus-graphie.s3.amazonaws.com/9cbfad55525e3ce755a31a631b074670a5dad611.png",defaultCoords:[[.5,.55],[.75,.75]],defaultAsymptote:[[0,.5],[1,.5]],extraCoordConstraint:function(e,t,n,o,s){const i=M.default.head(o)[1];return M.default.all(n,(e=>e[1]!==i))},extraAsymptoteConstraint:function(e,t,n,o,s){const i=e[1];if(M.default.all(n,(e=>e[1]>i))||M.default.all(n,(e=>e[1]<i)))return[t[0],i];const r=t[1];if(M.default.all(n,(e=>e[1]>r))){const e=M.default.min(M.default.map(n,(e=>e[1])));return[t[0],e-s.snapStep[1]]}const a=M.default.max(M.default.map(n,(e=>e[1])));return[t[0],a+s.snapStep[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){const n=e[0],o=e[1],s=M.default.head(t)[1],i=Math.log((n[1]-s)/(o[1]-s))/(n[0]-o[0]);return[(n[1]-s)/Math.exp(i*n[0]),i,s]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2];return n*Math.exp(o*t)+s},getEquationString:function(e,t){if(!t)return null;const n=this.getCoefficients(e,t),o=n[0],s=n[1],i=n[2];return"y = "+o.toFixed(3)+"e^("+s.toFixed(3)+"x) + "+i.toFixed(3)}}),uu=M.default.extend({},ru,{url:"https://ka-perseus-graphie.s3.amazonaws.com/f6491e99d34af34d924bfe0231728ad912068dc3.png",defaultCoords:[[.55,.5],[.75,.75]],defaultAsymptote:[[.5,0],[.5,1]],extraCoordConstraint:function(e,t,n,o,s){const i=M.default.head(o)[0];return M.default.all(n,(e=>e[0]!==i))&&n[0][1]!==n[1][1]},extraAsymptoteConstraint:function(e,t,n,o,s){const i=e[0];if(M.default.all(n,(e=>e[0]>i))||M.default.all(n,(e=>e[0]<i)))return[i,t[1]];const r=t[0];if(M.default.all(n,(e=>e[0]>r))){return[M.default.min(M.default.map(n,(e=>e[0])))-s.snapStep[0],t[1]]}return[M.default.max(M.default.map(n,(e=>e[0])))+s.snapStep[0],t[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){const n=e=>[e[1],e[0]],o=du.getCoefficients(M.default.map(e,n),M.default.map(t,n)),s=-o[2]/o[0],i=1/o[0];return[1/o[1],i,s]},getFunctionForCoeffs:function(e,t,n){const o=e[0],s=e[1],i=e[2];return o*Math.log(s*t+i)},getEquationString:function(e,t){if(!t)return null;const n=this.getCoefficients(e,t),o=n[0],s=n[1],i=n[2];return"y = ln("+o.toFixed(3)+"x + "+s.toFixed(3)+") + "+i.toFixed(3)}}),hu=M.default.extend({},ru,{url:"https://ka-perseus-graphie.s3.amazonaws.com/8256a630175a0cb1d11de223d6de0266daf98721.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],o=n[0]-t[0],s=n[1]-t[1];if(0===o)return;let i=Math.abs(s/o);n[1]<t[1]&&(i*=-1);return[i,t[0],t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],o=e[1],s=e[2];return n*Math.abs(t-o)+s},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],o=t[1],s=t[2];return"y = "+n.toFixed(3)+"| x - "+o.toFixed(3)+"| + "+s.toFixed(3)}}),fu={linear:au,quadratic:lu,sinusoid:cu,tangent:pu,exponential:du,logarithm:uu,absolute_value:hu},mu=M.default.keys(fu);function gu(e){return fu[e]}const vu=(e,t)=>{if(e.type!==t.correct.type)return{type:"points",earned:0,total:1,message:null};if(null==e.coords)return{type:"invalid",message:null};const n=gu(e.type),o=n.getCoefficients(e.coords,e.asymptote),s=n.getCoefficients(t.correct.coords,t.correct.asymptote);return null==o||null==s?{type:"invalid",message:null}:n.areEqual(o,s)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}},yu=(e,t,n,o)=>e.map((e=>{const s=e.map(((e,o)=>{const s=t[o],i=n[o],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(s,i),a=Math.round(e*r);return s[0]+i*a}));return d.point.roundTo(s,o)})),bu=(e,t,n,o)=>e?yu(e,t,n,o):e,xu=(e,t)=>{const n=gu(e),o=Ae.snapStepFromGridStep([1,1]);return{type:e,asymptote:bu(n.defaultAsymptote,t.range,t.step,o),coords:null}},wu=M.default.first,Cu=(e,t)=>{const n=e.gridStep||Ae.getGridStep(e.range,e.step,t);return{gridStep:n,snapStep:e.snapStep||Ae.snapStepFromGridStep(n)}},ku={labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:ou,markings:"graph",rulerLabel:"",rulerTicks:10,valid:!0,showTooltips:!1},Su=xu("linear",ku),Eu={graph:ku,plot:Su,availableTypes:[Su.type]},_u=e=>{const t=e.charAt(0).toUpperCase()+e.substring(1),n=ne().staticUrl;return{value:e,title:t,content:_.createElement("img",{src:n(gu(e).url),alt:t})}};var Tu=Object.freeze({__proto__:null,DEFAULT_BACKGROUND_IMAGE:ou,allTypes:mu,functionForType:gu,validate:vu,getEquationString:e=>{const t=e.plot;if(t.type&&t.coords){return gu(t.type).getEquationString(t.coords,t.asymptote)||""}return""},pointsFromNormalized:yu,maybePointsFromNormalized:bu,defaultPlotProps:xu,chooseType:wu,getGridAndSnapSteps:Cu,DEFAULT_GRAPHER_PROPS:Eu,typeToButton:_u});const Mu=Es.MovablePoint,Iu=Es.MovableLine;const Pu={padding:"5px 5px"};class Nu extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"_coords",(()=>{const e=this.props,t=e.graph,n=e.model&&bu(e.model.defaultCoords,t.range,t.step,t.snapStep);return e.coords||n||null})),W(this,"_asymptote",(()=>this.props.asymptote)),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"renderPlot",(()=>{const e=this.props.model,t=this.props.graph.range[0],n={stroke:this.props.isMobile?dn.BLUE_C:dn.DYNAMIC,...this.props.isMobile?{"stroke-width":3}:{}},o=e.getCoefficients(this._coords(),this._asymptote());if(!o)return;const s=e.getPropsForCoeffs(o,t);return _.createElement(e.Movable,U({},s,{key:this.props.model.url,range:t,style:n}))})),W(this,"renderAsymptote",(()=>{const e=this.props.model,t=this.props.graph,n=this._asymptote(),o={strokeDasharray:"- "};return n&&_.createElement(Iu,{onMove:(e,t)=>{const n=d.vector.subtract(e,t),o=M.default.map(this._asymptote(),(e=>d.vector.add(e,n)));this.props.onChange({asymptote:o})},constraints:[ls.MovableLine.constraints.bound(),ls.MovableLine.constraints.snap(),(n,o)=>{const s=d.vector.subtract(n,o),i=M.default.map(this._asymptote(),(e=>d.vector.add(e,s)));return!e.extraAsymptoteConstraint||e.extraAsymptoteConstraint(n,o,this._coords(),i,t)}],normalStyle:o,highlightStyle:o},M.default.map(n,((e,t)=>_.createElement(Mu,{key:"asymptoteCoord-".concat(t),coord:e,static:!0,draw:null,extendLine:!0,showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))))}))}render(){const e=M.default.map(this._coords(),((e,t)=>_.createElement(Mu,{key:t,coord:e,static:this.props.static,constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),e=>{const n=M.default.all(this._coords(),((n,o)=>t===o||!n||!d.number.equal(e[0],n[0])));if(!n)return!1;if(this.props.model&&this.props.model.extraCoordConstraint){const n=this.props.model.extraCoordConstraint,o=M.default.clone(this._coords()),s=M.default.clone(o[t]);return o[t]=e,n(e,s,o,this._asymptote(),this.props.graph)}return n}],onMove:(e,n)=>{let o;const s=this._asymptote();o=s&&this.props.model.allowReflectOverAsymptote&&function(e,t,n){const o=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1]);return o(n[0],n[1],t)>0!=o(n[0],n[1],e)>0}(e,n,s)?M.default.map(this._coords(),(e=>d.point.reflectOverLine(e,s))):M.default.clone(this._coords()),o[t]=e,this.props.onChange({coords:o})},showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))),t=this.props.graph.box,n=this.props.graph.backgroundImage;let o=null;if(n.url){const e=t[0]/K.defaultBoxSize;o=_.createElement(zs,{src:n.url,width:n.width,height:n.height,scale:e})}return _.createElement("div",{className:"perseus-widget perseus-widget-grapher",style:{width:t[0],height:t[1],boxSizing:"initial"}},_.createElement("div",{className:"graphie-container above-scratchpad",style:{width:t[0],height:t[1]}},o,_.createElement(Es,U({},this.props.graph,{setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this.props.model&&this.renderPlot(),this.props.model&&this.renderAsymptote(),this.props.model&&e)))}}W(Nu,"defaultProps",{graph:{range:[[-10,10],[-10,10]],step:[1,1]},coords:null,asymptote:null,isMobile:!1});class Au extends _.Component{constructor(){super(...arguments),W(this,"horizHairline",void 0),W(this,"vertHairline",void 0),W(this,"handlePlotChanges",(e=>{const t=M.default.extend({},this.props.plot,e);this.props.onChange({plot:t}),this.props.trackInteraction()})),W(this,"handleActiveTypeChange",(e=>{const t=this.props.graph,n=M.default.extend({},this.props.plot,xu(e,t));this.props.onChange({plot:n})})),W(this,"_setupGraphie",((e,t)=>{const n=this.props.apiOptions.isMobile;if("graph"===t.markings?(e.graphInit({range:t.range,scale:M.default.pluck(t.gridConfig,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,snapStep:t.snapStep,tickStep:n?this._calculateMobileTickStep(t.gridStep,t.step,t.range):M.default.pluck(t.gridConfig,"tickStep"),labelStep:1,unityLabels:M.default.pluck(t.gridConfig,"unityLabel"),isMobile:n}),e.label([0,t.range[1][1]],t.labels[1],n?"below right":"above"),e.label([t.range[0][1],0],t.labels[0],n?"above left":"right")):"grid"===t.markings?e.graphInit({range:t.range,scale:M.default.pluck(t.gridConfig,"scale"),gridStep:t.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:n}):"none"===t.markings&&e.init({range:t.range,scale:M.default.pluck(t.gridConfig,"scale")}),this.props.apiOptions.isMobile){const t={normalStyle:{strokeWidth:1}};this.horizHairline=new _n(e,[0,0],[0,0],t),this.horizHairline.attr({stroke:dn.INTERACTIVE}),this.horizHairline.hide(),this.vertHairline=new _n(e,[0,0],[0,0],t),this.vertHairline.attr({stroke:dn.INTERACTIVE}),this.vertHairline.hide()}})),W(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.props.graph.range[0][0],e[1]],[this.props.graph.range[0][1],e[1]]),this.horizHairline.show(),this.vertHairline.moveTo([e[0],this.props.graph.range[1][0]],[e[0],this.props.graph.range[1][1]]),this.vertHairline.show())})),W(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&(this.horizHairline.hide(),this.vertHairline.hide())}))}render(){const e=this.props.plot.type,t=this.props.plot.coords,n=this.props.plot.asymptote,o=_.createElement("div",{style:Pu,className:"above-scratchpad"},_.createElement(tu,{value:e,allowEmpty:!0,buttons:M.default.map(this.props.availableTypes,_u),onChange:this.handleActiveTypeChange})),s=ni(this.props.containerSizeClass),i={...this.props.graph,...Cu(this.props.graph,s[0]),gridConfig:this._getGridConfig({...this.props.graph,box:s,...Cu(this.props.graph,s[0])})},r={graph:{box:s,range:i.range,step:i.step,snapStep:i.snapStep,backgroundImage:i.backgroundImage,options:i,setup:this._setupGraphie},onChange:this.handlePlotChanges,model:e&&gu(e),coords:t,asymptote:n,static:this.props.static,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile,showTooltips:this.props.graph.showTooltips,showHairlines:this.showHairlines,hideHairlines:this.hideHairlines};return _.createElement("div",null,_.createElement(Nu,r),this.props.availableTypes.length>1&&o)}_getGridConfig(e){return e.step.map(((t,n)=>Ae.gridDimensionConfig(t,e.range[n],e.box[n],e.gridStep[n])))}_calculateMobileTickStep(e,t,n){const o=Ae.constrainedTickStepsFromTickSteps(t,n);return o[0]=o[0]/e[0],o[1]=o[1]/e[1],o}simpleValidate(e){return vu(this.getUserInput(),e)}getUserInput(){return Au.getUserInputFromProps(this.props)}focus(){}static validate(e,t){return vu(e,t)}static getUserInputFromProps(e){return e.plot}}W(Au,"defaultProps",Eu);const Ru=e=>{const t={availableTypes:e.availableTypes,graph:e.graph};if(1===t.availableTypes.length){const e=t.graph,n=wu(t.availableTypes);t.plot=xu(n,e)}return t};var Fu={name:"grapher",displayName:"Grapher",widget:Au,transform:Ru,staticTransform:e=>({...Ru(e),availableTypes:[e.correct.type],plot:e.correct})};class Ou extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"getUserInput",(()=>this.refs.renderer.getUserInput())),W(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),W(this,"restoreSerializedState",((e,t)=>(this.refs.renderer.restoreSerializedState(e,t),null))),W(this,"simpleValidate",(e=>this.refs.renderer.score())),W(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),W(this,"setInputValue",((e,t,n)=>this.refs.renderer.setInputValue(e,t,n))),W(this,"focus",(()=>this.refs.renderer.focus())),W(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),W(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)})),W(this,"showRationalesForCurrentlySelectedChoices",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices()}))}componentDidMount(){this.forceUpdate()}render(){const e=M.default.extend({},Yt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}}),t=M.default.indexOf(this.props.findWidgets("group"),this),n=this.props.apiOptions.groupAnnotator(t,this.props.widgetId),o=this.refs.renderer&&this.refs.renderer.score(),s=o&&"invalid"!==o.type,i=o&&"invalid"===o.type;return _.createElement("div",{className:E.default({"perseus-group":!0,"perseus-group-valid-answer":s,"perseus-group-invalid-answer":i})},n,_.createElement(Ai,U({},this.props,{ref:"renderer",apiOptions:e,findExternalWidgets:this.props.findWidgets,reviewMode:!!this.props.reviewModeRubric,onInteractWithWidget:e=>{this.refs.renderer&&this.change("widgets",this.refs.renderer.props.widgets)},linterContext:this.props.linterContext})),this.props.icon&&_.createElement("div",{className:"group-icon"},this.props.icon))}}W(Ou,"defaultProps",{content:"",widgets:{},images:{},linterContext:Ht});var Du={name:"group",displayName:"Group (SAT only)",widget:Ou,traverseChildWidgets:function(e,t){return M.default.extend({},e,t(e))},hidden:!1,isLintable:!0};const{updateQueryString:Lu}=Ae;class Bu extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"getUserInput",(()=>Nr.getUserInput.call(this))),W(this,"handleMessageEvent",(e=>{let t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(M.default.isUndefined(t.testsPassed))return;const n=t.testsPassed?"correct":"incorrect";this.change({status:n,message:t.message})})),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"simpleValidate",(e=>Bu.validate(this.getUserInput(),e)))}componentDidMount(){R.default(window).on("message",this.handleMessageEvent)}componentWillUnmount(){R.default(window).off("message",this.handleMessageEvent)}render(){const e={width:String(this.props.width),height:String(this.props.height)},{InitialRequestUrl:t}=ne();Object.entries(e).forEach((t=>{let[n,o]=t;o.endsWith("%")||o.endsWith("px")||(e[n]=o+"px")}));let n=this.props.url;if(n&&n.length&&0!==n.indexOf("http")&&(n="https://www.khanacademy.org/computer-programming/program/"+n+"/embedded?buttons=no&embed=yes&editor=no&author=no",n=Lu(n,"width",this.props.width),n=Lu(n,"height",this.props.height),n=Lu(n,"origin",t.origin)),this.props.settings){const e={};M.default.each(this.props.settings,(function(t){t.name&&t.value&&(e[t.name]=t.value)})),n=Lu(n,"settings",JSON.stringify(e))}let o="allow-same-origin allow-scripts";return o+=" allow-top-navigation",_.createElement("iframe",{sandbox:"allow-same-origin allow-scripts allow-top-navigation",style:e,src:n,allowFullScreen:this.props.allowFullScreen})}}W(Bu,"propTypes",{...pr,width:I.default.oneOfType([I.default.string,I.default.number]),height:I.default.oneOfType([I.default.string,I.default.number]),url:I.default.string,settings:I.default.array,status:I.default.oneOf(["incomplete","incorrect","correct"]),message:I.default.string,allowFullScreen:I.default.bool,allowTopNavigation:I.default.bool}),W(Bu,"defaultProps",{status:"incomplete",message:null,allowFullScreen:!1,allowTopNavigation:!1}),M.default.extend(Bu,{validate:function(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}});var zu={name:"iframe",displayName:"Iframe",widget:Bu,hidden:!0};const qu=[0,10];class Hu extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"getUserInput",(()=>null)),W(this,"simpleValidate",(e=>Hu.validate(this.getUserInput(),e))),W(this,"focus",(()=>{}))}render(){let e,t;const{apiOptions:n}=this.props,o=this.props.backgroundImage;if(o.url&&(e=_.createElement(zs,{src:o.url,alt:this.props.alt,overrideAriaHidden:!0,width:o.width,height:o.height,preloader:n.imagePreloader,extraGraphie:{box:this.props.box,range:this.props.range,labels:this.props.labels},trackInteraction:this.props.trackInteraction,zoomToFullSizeOnMobile:n.isMobile,constrainHeight:n.isMobile,allowFullBleed:n.isMobile})),this.props.alt&&(t=_.createElement("span",{className:"perseus-sr-only"},_.createElement(Ai,{content:this.props.alt,apiOptions:n,linterContext:this.props.linterContext}))),n.isMobile){let o;if(this.props.title||this.props.caption){let e=this.props.title;e&&(this.props.caption&&!/[.?!"']\s*$/.test(e)&&(e+="."),e="**".concat(e,"** "));const t=E.default({"perseus-image-caption":!0,"has-title":!!e}),s=this.props.alignment,i="block"===s||"full-width"===s?null:"0 !important";o=_.createElement("div",{className:t},_.createElement("div",{className:l.css(Wu.caption),style:{minWidth:i}},_.createElement(Ai,{content:e+this.props.caption,apiOptions:n,linterContext:this.props.linterContext})))}return _.createElement("div",{className:"perseus-image-widget"},e,t,o)}let s,i;return this.props.title&&(s=_.createElement("div",{className:"perseus-image-title"},_.createElement(Ai,{content:this.props.title,apiOptions:n,linterContext:this.props.linterContext}))),this.props.caption&&(i=_.createElement("div",{className:"perseus-image-caption"},_.createElement(Ai,{content:this.props.caption,apiOptions:n,linterContext:this.props.linterContext}))),_.createElement("div",{className:"perseus-image-widget"},s,e,t,i)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}W(Hu,"defaultProps",{alignment:"block",title:"",range:[qu,qu],box:[400,400],backgroundImage:{url:null,width:0,height:0},labels:[],alt:"",caption:"",linterContext:Ht});const Wu=l.StyleSheet.create({caption:{display:"inline-block",marginTop:16,maxWidth:640,[Wr.lgOrSmaller]:{maxWidth:540},[Wr.smOrSmaller]:{maxWidth:450}}});var Uu={name:"image",accessible:e=>{const t=e.backgroundImage;return!(t&&t.url&&!e.alt)},defaultAlignment:"block",supportedAlignments:["block","full-width"],displayName:"Image",widget:Hu,isLintable:!0};const Gu=Es.Label,Vu=Es.Line,ju=Es.MovablePoint,Yu=Es.MovableLine,$u=Es.Plot,Xu=Es.PlotParametric,Ku=Es.Point,Zu=Es.Rect,{unescapeMathMode:Ju}=Ae,Qu=(e,t)=>{let n=e+"||"+(t=t||{}).decimal_separator+"||";const o=t.functions,s=o?o.length:0;for(let e=0;e<s;e++)n+=o[e]+"|";return n},eh=Object.create(null),th=(e,t)=>{const n=Qu(e,t);let o=eh[n];return o||(o=k.parse(e,t),eh[n]=o,o)},nh=Object.create(null),oh=(e,t)=>{const n=Qu(e,t);let o=nh[n];if(o)return o;const s=k.parse(e,t).expr;return o=s?s.compile():function(){return 0},nh[n]=o,o};class sh extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"state",{variables:ih(this.props.elements),functions:rh(this.props.elements)}),W(this,"_setupGraphie",((e,t)=>{e.graphInit(M.default.extend({},t,{grid:M.default.contains(["graph","grid"],this.props.graph.markings),axes:M.default.contains(["graph"],this.props.graph.markings),ticks:M.default.contains(["graph"],this.props.graph.markings),labels:M.default.contains(["graph"],this.props.graph.markings),labelFormat:function(e){return"\\small{"+e+"}"},axisArrows:"<->",unityLabels:!1}))})),W(this,"_updatePointLocation",((e,t)=>{const n=M.default.clone(this.state.variables);n["x_"+e]=t[0],n["y_"+e]=t[1],this.setState({variables:n}),this.props.trackInteraction()})),W(this,"_updateLineLocation",((e,t)=>{const n=this._eval("("+e.endX+")-("+e.startX+")"),o=this._eval("("+e.endY+")-("+e.startY+")"),s=d.vector.add(t,[n,o]),i=M.default.clone(this.state.variables);i["x_"+e.startSubscript]=t[0],i["y_"+e.startSubscript]=t[1],i["x_"+e.endSubscript]=s[0],i["y_"+e.endSubscript]=s[1],this.setState({variables:i}),this.props.trackInteraction()})),W(this,"_eval",((e,t)=>{const n=oh(e,{functions:this.state.functions}),o=M.default.extend({},this.state.variables,t);return M.default.each(M.default.keys(o),(e=>{if(M.default.isString(o[e])){const t=oh(o[e],{functions:this.state.functions});o[e]=function(e){return t(M.default.extend({},o,{x:e}))}}})),n(o)||0})),W(this,"_extractVars",(e=>{if(null==e)return[];let t=[];return M.default.each(e.args(),(function(e){e&&"Expr"===e.constructor.name&&(t=t.concat(this._extractVars(e)))}),this),"Var"===e.name()&&t.push(e.prettyPrint()),t})),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"getUserInput",(()=>({}))),W(this,"simpleValidate",(e=>sh.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){M.default.isEqual(this.props.elements,e.elements)||this.setState({variables:ih(e.elements),functions:rh(e.elements)})}render(){const e=this.props.graph.range;let t=this.props.graph.labels;return"graph"===this.props.graph.markings&&(t=this.props.graph.labels.map((e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e))),_.createElement(Es,{box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable},"graph"===this.props.graph.markings&&_.createElement(Gu,{coord:[0,e[1][1]],text:t[1],direction:"above"}),"graph"===this.props.graph.markings&&_.createElement(Gu,{coord:[e[0][1],0],text:t[0],direction:"right"}),M.default.map(this.props.elements,(function(e,t){if("point"===e.type)return _.createElement(Ku,{key:e.key,coord:[this._eval(e.options.coordX),this._eval(e.options.coordY)],color:e.options.color});if("line"===e.type){const t=[this._eval(e.options.startX),this._eval(e.options.startY)],n=[this._eval(e.options.endX),this._eval(e.options.endY)];return _.createElement(Vu,{key:e.key,start:t,end:n,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,arrows:e.options.arrows}})}if("movable-point"===e.type){const t=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];return"snap"===e.options.constraint?t.push(ju.constraints.snap(e.options.snap)):"x"===e.options.constraint?t.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&t.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})])),_.createElement(ju,{key:e.key,coord:[this.state.variables["x_"+e.options.varSubscript],this.state.variables["y_"+e.options.varSubscript]],constraints:t,foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap,onMove:M.default.partial(this._updatePointLocation,e.options.varSubscript)})}if("movable-line"===e.type){const t=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];"snap"===e.options.constraint?t.push(ju.constraints.snap(e.options.snap)):"x"===e.options.constraint?t.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&t.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})]));const n=[this.state.variables["x_"+e.options.startSubscript],this.state.variables["y_"+e.options.startSubscript]],o=[this.state.variables["x_"+e.options.endSubscript],this.state.variables["y_"+e.options.endSubscript]];return _.createElement(Yu,{key:e.key,constraints:t,onMove:M.default.bind(this._updateLineLocation,this,e.options),foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap},_.createElement(ju,{coord:n,static:!0,normalStyle:{stroke:"none",fill:"none"}}),_.createElement(ju,{coord:o,static:!0,normalStyle:{stroke:"none",fill:"none"}}))}if("function"===e.type){const t=t=>this._eval(e.options.value,{x:t}),n=M.default.without(this._extractVars(th(e.options.value).expr),"x"),o=M.default.object(n,M.default.map(n,(e=>this.state.variables[e]))),s=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return _.createElement($u,{key:e.key,fn:t,foo_fn:e.options.value,foo_varvalues:o,range:s,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("parametric"===e.type){const t=t=>[this._eval(e.options.x,{t:t}),this._eval(e.options.y,{t:t})],n=M.default.without(this._extractVars(th(e.options.x).expr).concat(this._extractVars(th(e.options.y).expr)),"t"),o=M.default.object(n,M.default.map(n,(e=>this.state.variables[e]))),s=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return _.createElement(Xu,{key:e.key,fn:t,foo_fnx:e.options.x,foo_fny:e.options.y,foo_varvalues:o,range:s,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("label"===e.type){const n=[this._eval(e.options.coordX),this._eval(e.options.coordY)];return _.createElement(Gu,{key:t+1,coord:n,text:Ju(e.options.label),style:{color:e.options.color}})}return"rectangle"===e.type?_.createElement(Zu,{key:t+1,x:this._eval(e.options.coordX),y:this._eval(e.options.coordY),width:M.default.max([this._eval(e.options.width),0]),height:M.default.max([this._eval(e.options.height),0]),style:{stroke:"none",fill:e.options.color}}):void 0}),this))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}W(sh,"defaultProps",{graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]});const ih=e=>{const t={};return M.default.each(M.default.where(e,{type:"movable-point"}),(e=>{const n=e.options.varSubscript,o=th(e.options.startX||"0").expr,s=th(e.options.startY||"0").expr;let i=0,r=0;o&&(i=o.eval({})||0),s&&(r=s.eval({})||0),t["x_"+n]=i,t["y_"+n]=r})),M.default.each(M.default.where(e,{type:"movable-line"}),(e=>{const n=e.options.startSubscript,o=e.options.endSubscript,s=th(e.options.startX||"0").expr,i=th(e.options.startY||"0").expr,r=th(e.options.endX||"0").expr,a=th(e.options.endY||"0").expr;let l=0,c=0,p=0,d=0;s&&(l=s.eval({})||0),i&&(c=i.eval({})||0),r&&(p=r.eval({})||0),a&&(d=a.eval({})||0),t["x_"+n]=l,t["y_"+n]=c,t["x_"+o]=p,t["y_"+o]=d})),M.default.each(M.default.where(e,{type:"function"}),(e=>{t[e.options.funcName]=e.options.value})),t},rh=e=>M.default.map(M.default.where(e,{type:"function"}),(e=>e.options.funcName));var ah={name:"interaction",displayName:"Interaction",widget:sh,transform:M.default.identity,hidden:!0},lh=/^\s+|\s+$/g,ch=/^[-+]0x[0-9a-f]+$/i,ph=/^0b[01]+$/i,dh=/^0o[0-7]+$/i,uh=parseInt,hh="object"==typeof ln&&ln&&ln.Object===Object&&ln,fh="object"==typeof self&&self&&self.Object===Object&&self,mh=hh||fh||Function("return this")(),gh=Object.prototype.toString,vh=Math.max,yh=Math.min,bh=function(){return mh.Date.now()};function xh(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function wh(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==gh.call(e)}(e))return NaN;if(xh(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=xh(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(lh,"");var n=ph.test(e);return n||dh.test(e)?uh(e.slice(2),n?2:8):ch.test(e)?NaN:+e}var Ch=function(e,t,n){var o,s,i,r,a,l,c=0,p=!1,d=!1,u=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var n=o,i=s;return o=s=void 0,c=t,r=e.apply(i,n)}function f(e){return c=e,a=setTimeout(g,t),p?h(e):r}function m(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=i}function g(){var e=bh();if(m(e))return v(e);a=setTimeout(g,function(e){var n=t-(e-l);return d?yh(n,i-(e-c)):n}(e))}function v(e){return a=void 0,u&&o?h(e):(o=s=void 0,r)}function y(){var e=bh(),n=m(e);if(o=arguments,s=this,l=e,n){if(void 0===a)return f(l);if(d)return a=setTimeout(g,t),h(l)}return void 0===a&&(a=setTimeout(g,t)),r}return t=wh(t)||0,xh(n)&&(p=!!n.leading,i=(d="maxWait"in n)?vh(wh(n.maxWait)||0,t):i,u="trailing"in n?!!n.trailing:u),y.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=s=a=void 0},y.flush=function(){return void 0===a?r:v(bh())},y};const kh={fontStyle:"italic",fontWeight:"bold",fontSize:"32px",width:"100%",height:"100%",textAlign:"center",backgroundColor:"white",position:"absolute",zIndex:1,transition:"opacity .25s ease-in-out","-moz-transition":"opacity .25s ease-in-out","-webkit-transition":"opacity .25s ease-in-out"},Sh={position:"relative",top:"25%"};class Eh extends _.Component{constructor(){super(...arguments),W(this,"protractor",void 0),W(this,"ruler",void 0),W(this,"_graphie",void 0),W(this,"_hasSetupGraphieThisUpdate",void 0),W(this,"_shouldSetupGraphie",void 0),W(this,"reset",(()=>{this._setupGraphie(!1)})),W(this,"graphie",(()=>this._graphie)),W(this,"pointsFromNormalized",((e,t)=>{const n=this;return M.default.map(e,(function(e){return M.default.map(e,(function(e,o){const s=n.props.range[o];if(t)return s[0]+(s[1]-s[0])*e;const i=n.props.step[o],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(s,i),a=Math.round(e*r);return s[0]+i*a}))}))})),W(this,"_setupGraphie",(e=>{if(this._hasSetupGraphieThisUpdate)return;const t=N.default.findDOMNode(this.refs.graphieDiv);R.default(t).empty();const n=this.props.labels.map((e=>Ae.unescapeMathMode(e))),o=this.props.range,s=this._graphie=vn.createGraphie(t),i=this._getGridConfig();s.snap=this.props.snapStep,"graph"===this.props.markings?(s.graphInit({range:o,scale:M.default.pluck(i,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:this.props.gridStep,tickStep:M.default.pluck(i,"tickStep"),labelStep:1,unityLabels:M.default.pluck(i,"unityLabel"),isMobile:this.props.isMobile}),s.label([0,o[1][1]],n[1],this.props.isMobile?"below right":"above"),s.label([o[0][1],0],n[0],this.props.isMobile?"above left":"right")):"grid"===this.props.markings?s.graphInit({range:o,scale:M.default.pluck(i,"scale"),gridStep:this.props.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:this.props.isMobile}):"none"===this.props.markings&&s.init({range:o,scale:M.default.pluck(i,"scale"),isMobile:this.props.isMobile});let r;if(this.props.instructions){r=R.default("<div/>"),M.default.each(kh,(function(e,t){r.css(t,e)})),r.css("opacity",.5);const e=R.default("<span/>",{text:this.props.instructions});M.default.each(Sh,(function(t,n){e.css(n,t)})),r.append(e),R.default(t).append(r)}else r=void 0;const a=r||this.props.onMouseDown?M.default.bind((function(e){r&&(r.remove(),r=null),this.props.onMouseDown(e)}),this):null,l=r?function(){r&&r.css("opacity",0)}:null,c=r?function(){r&&r.css("opacity",.5)}:null;s.addMouseLayer({onClick:this.props.onClick,onMouseDown:a,onMouseOver:l,onMouseOut:c,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,allowScratchpad:!0,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this._updateProtractor(),this._updateRuler(),this._hasSetupGraphieThisUpdate=!0,!e&&this.props.onGraphieUpdated&&this.props.onGraphieUpdated(s)})),W(this,"_getGridConfig",(()=>{const e=this;return M.default.map(e.props.step,(function(t,n){return Ae.gridDimensionConfig(t,e.props.range[n],e.props.box[n],e.props.gridStep[n])}))})),W(this,"_updateProtractor",(()=>{if(this.protractor&&this.protractor.remove(),this.props.showProtractor){const e=this.pointsFromNormalized([[.5,.05]])[0];this.protractor=this._graphie.protractor(e)}})),W(this,"_updateRuler",(()=>{if(this.ruler&&this.ruler.remove(),this.props.showRuler){const e=this.pointsFromNormalized([[.5,.25]])[0],t=this._graphie.range[0][1]-this._graphie.range[0][0];this.ruler=this._graphie.ruler({center:e,label:this.props.rulerLabel,pixelsPerUnit:this._graphie.scale[0],ticksPerUnit:this.props.rulerTicks,units:Math.round(.8*t)})}})),W(this,"toJSON",(()=>M.default.pick(this.props,"range","step","markings","labels","backgroundImage","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep")))}render(){let e;const t=this.props.backgroundImage;if(t.url){const n=this.props.box[0]/K.defaultBoxSize;e=_.createElement(zs,{src:t.url,width:t.width,height:t.height,scale:n,responsive:!1})}else e=null;return _.createElement("div",{className:"graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]},onMouseOut:this.onMouseOut,onMouseOver:this.onMouseOver,onClick:this.onClick},e,_.createElement("div",{className:"graphie",ref:"graphieDiv"}))}componentDidMount(){this._setupGraphie(!0)}componentDidUpdate(){this._hasSetupGraphieThisUpdate=!1,this._shouldSetupGraphie&&(this._setupGraphie(!1),this._shouldSetupGraphie=!1)}UNSAFE_componentWillReceiveProps(e){const t=this;M.default.each(["labels","range","step","markings","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep"],(function(n){M.default.isEqual(t.props[n],e[n])||(t._shouldSetupGraphie=!0)}))}}W(Eh,"propTypes",{box:I.default.array.isRequired,labels:I.default.arrayOf(I.default.string),range:I.default.arrayOf(I.default.arrayOf(I.default.number)),step:I.default.arrayOf(I.default.number),gridStep:I.default.arrayOf(I.default.number),snapStep:I.default.arrayOf(I.default.number),markings:I.default.string,backgroundImage:I.default.shape({url:I.default.string}),showProtractor:I.default.bool,showRuler:I.default.bool,rulerLabel:I.default.string,rulerTicks:I.default.number,onGraphieUpdated:I.default.func,instructions:I.default.string,onClick:I.default.func,setDrawingAreaAvailable:I.default.func,isMobile:I.default.bool}),W(Eh,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[.5,.5],markings:"graph",backgroundImage:{url:null},showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,instructions:null,onGraphieUpdated:null,onClick:null,onMouseDown:null,isMobile:!1});const{DeprecationMixin:_h}=Ae,Th=Ae.eq,Mh=Ae.deepEq;function Ih(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])}function Ph(e,t,n){return Th(Ih(e,t,n),0)}function Nh(e){return Th(e,0)?0:e>0?1:-1}function Ah(e,t,n){return n[0]<=Math.max(e[0],t[0])&&n[0]>=Math.min(e[0],t[0])&&n[1]<=Math.max(e[1],t[1])&&n[1]>=Math.min(e[1],t[1])}function Rh(e,t){const n=[[e[0],e[1],t[0]],[e[0],e[1],t[1]],[t[0],t[1],e[0]],[t[0],t[1],e[1]]],o=M.default.map(n,(function(e){return Nh(Ih(...e))}));if(o[0]!==o[1]&&o[2]!==o[3])return!0;for(let e=0;e<4;e++)if(0===o[e]&&Ah(...n[e]))return!0;return!1}function Fh(e,t){return M.default.map(M.default.zip(e,t),(function(e){return e[0]-e[1]}))}function Oh(e){return Math.sqrt(M.default.reduce(e,(function(e,t){return e+Math.pow(t,2)}),0))}function Dh(e){return M.default.zip(e,Hh(e)).map((function(e){return Oh(Fh(...e))}))}function Lh(e){const t=M.default.zip(Hh(e,-1),e,Hh(e,1)),n=M.default.map(t,(function(e){const t=Fh(e[1],e[0]),n=Fh(e[2],e[1]),o=Math.acos((s=t,i=n,M.default.reduce(M.default.zip(s,i),(function(e,t){return e+t[0]*t[1]}),0)/(Oh(t)*Oh(n))));var s,i;return Nh(Ih(...e))>0?o:-o})),o=M.default.reduce(n,(function(e,t){return e+t}),0);return M.default.map(n,(function(e){return o>0?Math.PI-e:Math.PI+e}))}function Bh(e,t,n){if(e.length!==t.length)return!1;const o=e.length,s=Lh(e),i=Lh(t),r=Dh(e),a=Dh(t);for(let e=0;e<2*o;e++){let t=i.slice(),l=a.slice();if(e>=o&&(t.reverse(),l.reverse(),l=Hh(l,1)),t=Hh(t,e),l=Hh(l,e),Mh(s,t)){const e=M.default.zip(r,l),t=M.default.map(e,(function(e){return e[0]/e[1]})),o=M.default.all(t,(function(e){return Th(t[0],e)})),s=M.default.all(e,(function(e){return d.number.equal(e[0],e[1],n)}));if(o&&s)return!0}}return!1}function zh(e,t){return e<t||Th(e,t)}function qh(e){let[t,n,o,s]=e;t<0&&(t*=-1,n*=-1,o*=-1);const i=2*Math.PI;for(n<0&&(n*=-1,o*=-1,o+=i/2);o>0;)o-=i;for(;o<0;)o+=i;return[t,n,o,s]}function Hh(e,t){return t=void 0===t?1:t%e.length,e.slice(t).concat(e.slice(0,t))}function Wh(e){return e.replace(/(?:^|-)(.)/g,(function(e,t){return t.toUpperCase()}))}function Uh(e,t){if(Th(e[0],t[0]))return"x = "+e[0].toFixed(3);const n=(t[1]-e[1])/(t[0]-e[0]),o=e[1]-n*e[0];return"y = "+n.toFixed(3)+"x + "+o.toFixed(3)}const Gh={showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},Vh=e=>jh(e)&&(null==e.graph.coords||0===e.graph.coords.length),jh=e=>"point"===e.graph.type&&"unlimited"===e.graph.numPoints||"polygon"===e.graph.type&&"unlimited"===e.graph.numSides,Yh=(e,t)=>new re("".concat(e," called but current graph type is not a '").concat(t,"'"),se.NotAllowed,{metadata:{graphType:t}});class $h extends _.Component{constructor(){super(...arguments),W(this,"angle",void 0),W(this,"circle",void 0),W(this,"graphie",void 0),W(this,"horizHairline",void 0),W(this,"line",void 0),W(this,"lines",void 0),W(this,"parabola",void 0),W(this,"pointA",void 0),W(this,"pointB",void 0),W(this,"pointC",void 0),W(this,"points",void 0),W(this,"polygon",void 0),W(this,"shouldResetGraphie",void 0),W(this,"sinusoid",void 0),W(this,"trashCan",void 0),W(this,"vertHairline",void 0),W(this,"state",{shouldShowInstructions:Vh(this.props)}),W(this,"_getShouldShowInstructions",(e=>(e=e||this.props,this.isClickToAddPoints(e)&&(null==e.graph.coords||0===e.graph.coords.length)))),W(this,"deprecatedProps",Gh),W(this,"setGraphie",(e=>{this.graphie=e,this.setupGraphie()})),W(this,"handleAddPointsMouseDown",(e=>{if(!this.isClickToAddPoints())throw new re("handleAddPointsClick should not be registeredwhen isClickToAddPoints() is false",se.NotAllowed);if(!this.isCoordInTrash(e)){let n;if("point"===this.props.graph.type){if(n=this.createPointForPointsType(e,this.points.length),!n.constrain())return void n.remove();this.points.push(n);const t=this.points.length-1;this.points[t].grab(e),this.updateCoordsFromPoints()}else if("polygon"===this.props.graph.type){var t;if(null!==(t=this.polygon)&&void 0!==t&&t.closed())return;n=this.createPointForPolygonType(e,this.points.length),this.points.push(n);const o=this.points.length-1;this.points[o].grab(e),this.updatePolygon()}this.setState({shouldShowInstructions:!1})}})),W(this,"resetGraphie",(()=>{this.shouldResetGraphie=!1,this.parabola=null,this.sinusoid=null,this.refs.graph.reset()})),W(this,"setupGraphie",(()=>{var e,t;(this.setTrashCanVisibility(0),this.isClickToAddPoints()&&this.setTrashCanVisibility(.5),this.props.apiOptions.isMobile)&&(this.horizHairline=new _n(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:dn.INTERACTIVE}),null===(e=this.horizHairline)||void 0===e||e.hide(),this.vertHairline=new _n(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.vertHairline.attr({stroke:dn.INTERACTIVE}),null===(t=this.vertHairline)||void 0===t||t.hide());this["add"+Wh(this.props.graph.type)+"Controls"]()})),W(this,"showHairlines",(e=>{var t,n,o,s;this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(null===(t=this.horizHairline)||void 0===t||t.moveTo([this.props.range[0][0],e[1]],[this.props.range[0][1],e[1]]),null===(n=this.horizHairline)||void 0===n||n.show(),null===(o=this.vertHairline)||void 0===o||o.moveTo([e[0],this.props.range[1][0]],[e[0],this.props.range[1][1]]),null===(s=this.vertHairline)||void 0===s||s.show())})),W(this,"hideHairlines",(()=>{var e,t;this.props.apiOptions.isMobile&&(null===(e=this.horizHairline)||void 0===e||e.hide(),null===(t=this.vertHairline)||void 0===t||t.hide())})),W(this,"setTrashCanVisibility",(e=>{const t=this.graphie;if(d.number.equal(e,0))this.trashCan&&(this.trashCan.remove(),this.trashCan=null);else if(!this.props.apiOptions.isMobile){var n,o;if(!this.trashCan)this.trashCan=null==t||null===(o=t.raphael)||void 0===o?void 0:o.image("https://ka-perseus-graphie.s3.amazonaws.com/b1452c0d79fd0f7ff4c3af9488474a0a0decb361.png",t.xpixels-40,t.ypixels-40,40,40);null===(n=this.trashCan)||void 0===n||n.attr({opacity:e})}})),W(this,"isClickToAddPoints",(e=>(e=e||this.props,jh(e)))),W(this,"_lineStroke",(()=>this.props.isMobile?{"stroke-width":3}:{})),W(this,"addLine",(e=>{const t=this,n=t.graphie,o=$h.getLineCoords(t.props.graph,t.props),s=t.points=M.default.map(o,(e=>ls.addMaybeMobileMovablePoint(this,{coord:e,constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap()],onMove:()=>{const e=M.default.extend({},t.props.graph,{coords:M.default.invoke(s,"coord")});t.onChange({graph:e})}}))),i={points:s,static:!0,normalStyle:{stroke:this.props.apiOptions.isMobile?dn.BLUE_C:dn.INTERACTIVE,...this._lineStroke()}};"line"===e?i.extendLine=!0:"ray"===e&&(i.extendRay=!0),t.line=ls.addMovableLine(n,i),s[0].listen("constraints","isLine",(e=>!d.point.equal(e,s[1].coord()))),s[1].listen("constraints","isLine",(e=>!d.point.equal(e,s[0].coord())))})),W(this,"removeLine",(()=>{var e;M.default.invoke(this.points,"remove"),null===(e=this.line)||void 0===e||e.remove()})),W(this,"addLinearControls",(()=>{this.addLine("line")})),W(this,"removeLinearControls",(()=>{this.removeLine()})),W(this,"addQuadraticControls",(()=>{if("quadratic"!==this.props.graph.type)throw Yh("addQuadraticControls","quadratic");let e=this.props.graph.coords;e||(e=$h.defaultQuadraticCoords(this.props));const t=()=>{const e=M.default.extend({},this.props.graph,{coords:[n.coord(),o.coord(),s.coord()]});this.onChange({graph:e}),this.updateQuadratic()};let n=null;n=this.pointA=ls.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),e=>!n||e[0]!==o.coord()[0]&&e[0]!==s.coord()[0]],onMove:t});let o=null;o=this.pointB=ls.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),e=>!o||e[0]!==n.coord()[0]&&e[0]!==s.coord()[0]],onMove:t});let s=null;s=this.pointC=ls.addMaybeMobileMovablePoint(this,{coord:e[2],constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),e=>!s||e[0]!==n.coord()[0]&&e[0]!==o.coord()[0]],onMove:t}),this.updateQuadratic()})),W(this,"updateQuadratic",(()=>{const e=$h.getCurrentQuadraticCoefficients(this.props);if(!e)return;const t=e[0],n=e[1],o=e[2];if(this.parabola){var s,i;const e=null===(s=this.graphie)||void 0===s?void 0:s.svgParabolaPath(t,n,o);null===(i=this.parabola)||void 0===i||i.attr({path:e})}else{var r,a,l;this.parabola=null===(r=this.graphie)||void 0===r?void 0:r.parabola(t,n,o),null===(a=this.parabola)||void 0===a||a.attr({stroke:this.props.apiOptions.isMobile?dn.BLUE_C:dn.DYNAMIC,...this._lineStroke()}),null===(l=this.parabola)||void 0===l||l.toBack()}})),W(this,"removeQuadraticControls",(()=>{var e,t,n;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),null===(n=this.pointC)||void 0===n||n.remove(),this.parabola&&(this.parabola.remove(),this.parabola=null)})),W(this,"addSinusoidControls",(()=>{if("sinusoid"!==this.props.graph.type)throw Yh("addSinusoidControls","sinusoid");let e=this.props.graph.coords;e||(e=$h.defaultSinusoidCoords(this.props));const t=()=>{const e=M.default.extend({},this.props.graph,{coords:[n.coord(),o.coord()]});this.onChange({graph:e}),this.updateSinusoid()};let n=null;n=this.pointA=ls.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),e=>!n||e[0]!==o.coord()[0]],onMove:t});const o=this.pointB=ls.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),e=>!n||e[0]!==n.coord()[0]],onMove:t});this.updateSinusoid()})),W(this,"updateSinusoid",(()=>{const e=$h.getCurrentSinusoidCoefficients(this.props);if(!e)return;const t=e[0],n=e[1],o=e[2],s=e[3];if(this.sinusoid){var i,r;const e=null===(i=this.graphie)||void 0===i?void 0:i.svgSinusoidPath(t,n,o,s);null===(r=this.sinusoid)||void 0===r||r.attr({path:e})}else{var a,l,c;this.sinusoid=null===(a=this.graphie)||void 0===a?void 0:a.sinusoid(t,n,o,s),null===(l=this.sinusoid)||void 0===l||l.attr({stroke:this.props.apiOptions.isMobile?dn.BLUE_C:dn.DYNAMIC,...this._lineStroke()}),null===(c=this.sinusoid)||void 0===c||c.toBack()}})),W(this,"removeSinusoidControls",(()=>{var e,t;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),this.sinusoid&&(this.sinusoid.remove(),this.sinusoid=null)})),W(this,"addCircleControls",(()=>{const e=this.graphie,t=M.default.min(e.snap),n=this.circle=null==e?void 0:e.addCircleGraph({center:this.props.graph.center||[0,0],radius:this.props.graph.radius||M.default.min(this.props.step),snapX:e.snap[0],snapY:e.snap[1],minRadius:t,snapRadius:t});R.default(n).on("move",(()=>{const e=M.default.extend({},this.props.graph,{center:n.center,radius:n.radius});this.onChange({graph:e})}))})),W(this,"removeCircleControls",(()=>{var e;null===(e=this.circle)||void 0===e||e.remove()})),W(this,"addLinearSystemControls",(()=>{const e=this.graphie,t=$h.getLinearSystemCoords(this.props.graph,this.props),n=[dn.INTERACTIVE,dn.GREEN],o=this.points=M.default.map(t,((e,t)=>{const o=[];for(let s=0;s<e.length;s+=1){const i=e[s];o.push(ls.addMaybeMobileMovablePoint(this,{coord:i,constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),e=>{const t=o[1-s];if(t)return!d.point.equal(e,t.coord())}],onMove:()=>{const e=M.default.extend({},this.props.graph,{coords:M.default.map(this.points,(e=>M.default.invoke(e,"coord")))});this.onChange({graph:e})},normalStyle:{fill:n[t]},highlightStyle:{fill:n[t]}}))}return o}));this.lines=M.default.map(o,((t,o)=>ls.addMovableLine(e,{points:t,static:!0,extendLine:!0,normalStyle:{stroke:n[o]}})))})),W(this,"removeLinearSystemControls",(()=>{M.default.invoke(this.lines,"remove"),M.default.map(this.points,(e=>M.default.invoke(e,"remove")))})),W(this,"isCoordInTrash",(e=>{if(this.props.apiOptions.isMobile)return!1;const t=this.graphie,n=null==t?void 0:t.scalePoint(e);return n[0]>=t.xpixels-40&&n[1]>=t.ypixels-40})),W(this,"createPointForPointsType",((e,t)=>{const n=this,o=()=>{n.points=M.default.filter(n.points,(function(e){return e!==s})),n.updateCoordsFromPoints(),setTimeout(s.remove.bind(s),0)};let s=null;return s=ls.addMaybeMobileMovablePoint(this,{coord:e,constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),function(e){return M.default.all(n.points,(function(t){return s===t||!d.point.equal(e,t.coord())}))}],onMoveStart:function(){n.isClickToAddPoints()&&n.setTrashCanVisibility(1)},onMove:n.updateCoordsFromPoints,onMoveEnd:function(e){n.isClickToAddPoints()&&(n.isCoordInTrash(e)&&o(),n.setTrashCanVisibility(.5))},...this.props.apiOptions.isMobile&&n.isClickToAddPoints()?{onRemove:o}:{}}),s})),W(this,"removePoint",(e=>{let t=null;return this.points=M.default.filter(this.points,(function(n,o){return n!==e||(t=o,!1)})),t})),W(this,"createPointForPolygonType",((e,t)=>{if("polygon"!==this.props.graph.type)throw Yh("createPointForPolygonType","polygon");const n=!M.default.contains(["angles","sides"],this.props.graph.snapTo),o=e=>(t+e+this.points.length)%this.points.length,s=()=>{var e;const t=this.removePoint(r);var n;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&(this.points=Hh(this.points,t),null===(n=this.polygon)||void 0===n||n.update({closed:!1}));this.updatePolygon(),this.clearCoords(),setTimeout(r.remove.bind(r),0)},i=Ch(((e,t)=>{e.state.isInitialMove=t}),1e3),r=ls.addMaybeMobileMovablePoint(this,{coord:e,constraints:[ls.MovablePoint.constraints.bound(),n?ls.MovablePoint.constraints.snap():null,e=>{if(null==this.points||0===this.points.length)return!0;const n=M.default.invoke(this.points,"coord");if(n[t]=e,!this.isClickToAddPoints()){if(Ph(n[o(-2)],n[o(-1)],n[t])||Ph(n[o(-1)],n[t],n[o(1)])||Ph(n[t],n[o(1)],n[o(2)]))return!1;const e=M.default.zip(n,Hh(n));if(this.points.length>3)for(let t=-1;t<=0;t++){const n=e[o(t)],s=M.default.without(e,n,e[o(t-1)],e[o(t+1)]);for(let e=0;e<s.length;e++){if(Rh(n,s[e]))return!1}}}if("angles"===this.props.graph.snapTo&&this.points.length>2){var s,i;const e=M.default.map(Lh(n),(function(e){return 180*e/Math.PI}));M.default.each([-1,1],(function(t){e[o(t)]=Math.round(e[o(t)])}));const r=function(e,t,s){return(vn.findAngle(n[o(e)],n[o(s)],n[o(t)])+360)%360},a=[e[o(-1)]-r(-2,-1,1),e[o(1)]-r(-1,1,2)];if(a[2]=180-(a[0]+a[1]),M.default.any(a,(function(e){return zh(e,1)})))return!1;const l=Oh(Fh(n[o(-1)],n[o(1)])),c=1===Nh(Ih(n[o(-1)],n[o(1)],n[t])),p=Math.sin(a[1]*Math.PI/180)/Math.sin(a[2]*Math.PI/180)*l,d=vn.findAngle(n[o(1)],n[o(-1)]),u=null===(s=this.graphie)||void 0===s?void 0:s.polar(p,d+(c?1:-1)*a[0]);return null===(i=this.graphie)||void 0===i?void 0:i.addPoints(n[o(-1)],u)}if("sides"===this.props.graph.snapTo&&this.points.length>1){var r,a;const e=M.default.map([[n[o(-1)],n[t]],[n[t],n[o(1)]],[n[o(-1)],n[o(1)]]],(function(e){return Oh(Fh(...e))}));if(M.default.each([0,1],(function(t){e[t]=Math.round(e[t])})),zh(e[1]+e[2],e[0])||zh(e[0]+e[2],e[1])||zh(e[0]+e[1],e[2]))return!1;const s=(l=e[0],c=e[2],p=e[1],180*Math.acos((l*l+c*c-p*p)/(2*l*c))/Math.PI),i=vn.findAngle(n[o(1)],n[o(-1)]),d=1===Nh(Ih(n[o(-1)],n[o(1)],n[t])),u=null===(r=this.graphie)||void 0===r?void 0:r.polar(e[0],i+(d?1:-1)*s);return null===(a=this.graphie)||void 0===a?void 0:a.addPoints(n[o(-1)],u)}var l,c,p;return!0}],onMoveStart:()=>{this.isClickToAddPoints()&&this.setTrashCanVisibility(1)},onMove:()=>{var e;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&this.updateCoordsFromPoints()},onMoveEnd:e=>{const t=this.points.length>1&&(r===this.points[0]&&d.point.equal(e,M.default.last(this.points).coord())||r===M.default.last(this.points)&&d.point.equal(e,this.points[0].coord()));if(this.isClickToAddPoints()){if(this.isCoordInTrash(e))s();else if(t){const e=this.points.pop();var n,o;if(this.points.length>2)null===(n=this.polygon)||void 0===n||n.update({closed:!0}),this.updateCoordsFromPoints();else null===(o=this.polygon)||void 0===o||o.update({closed:!1}),this.clearCoords();this.updatePolygon(),setTimeout(e.remove.bind(e),0)}else{if(M.default.any(this.points,(function(t){return t!==r&&d.point.equal(t.coord(),e)}))){var a,l;if(this.removePoint(r),this.points.length<3)null===(l=this.polygon)||void 0===l||l.update({closed:!1}),this.clearCoords();else null!==(a=this.polygon)&&void 0!==a&&a.closed()&&this.updateCoordsFromPoints();this.updatePolygon(),setTimeout(r.remove.bind(r),0)}else{var c;const e=r===M.default.head(this.points)||r===M.default.last(this.points),t=!r.hasMoved(),n=!r.state.isInitialMove,o=!(null!==(c=this.polygon)&&void 0!==c&&c.closed()),s=this.points.length>2;var p;if(e&&t&&n&&o&&s)null===(p=this.polygon)||void 0===p||p.update({closed:!0}),this.updatePolygon(),this.updateCoordsFromPoints()}}this.setTrashCanVisibility(.5)}i(r,!1)},...this.props.apiOptions.isMobile&&this.isClickToAddPoints()?{onRemove:s}:{}});return r.state.isInitialMove=!0,r})),W(this,"updateCoordsFromPoints",(()=>{const e=M.default.extend({},this.props.graph,{coords:M.default.map(this.points,(function(e){return M.default.result(e,"coord")}))});this.onChange({graph:e})})),W(this,"clearCoords",(()=>{const e=M.default.extend({},this.props.graph,{coords:null});this.onChange({graph:e})})),W(this,"onChange",(e=>{this.props.onChange(e),this.props.trackInteraction()})),W(this,"addPointControls",(()=>{if("point"!==this.props.graph.type)throw Yh("addPointControls","point");const e=$h.getPointCoords(this.props.graph,this.props);this.points=[],this.points=M.default.map(e,this.createPointForPointsType,this)})),W(this,"removePointControls",(()=>{M.default.invoke(this.points,"remove")})),W(this,"addSegmentControls",(()=>{if("segment"!==this.props.graph.type)throw Yh("addSegmentControls","segment");const e=this,t=this.graphie,n=$h.getSegmentCoords(this.props.graph,this.props),o=e=>ls.addMaybeMobileMovablePoint(this,e);this.points=[],this.lines=M.default.map(n,(function(n,s){const i=function(){const t=M.default.extend({},e.props.graph,{coords:M.default.invoke(e.lines,"coords")});e.onChange({graph:t})},r=[];for(let e=0;e<n.length;e+=1){const t=n[e];r.push(o({coord:t,constraints:[ls.MovablePoint.constraints.bound(),ls.MovablePoint.constraints.snap(),t=>{const n=r[1-e];return!!n&&!d.point.equal(t,n.coord())}],onMove:i}))}e.points=e.points.concat(r);const a=ls.addMovableLine(t,{points:r,static:!1,constraints:[ls.MovableLine.constraints.bound(),ls.MovableLine.constraints.snap()],onMove:[ls.MovableLine.onMove.updatePoints,i],normalStyle:{stroke:this.props.apiOptions.isMobile?dn.BLUE_C:dn.INTERACTIVE,...this._lineStroke()},highlightStyle:{stroke:this.props.apiOptions.isMobile?dn.BLUE_C:dn.INTERACTING,...this._lineStroke()}});return M.default.invoke(r,"toFront"),a}),this)})),W(this,"removeSegmentControls",(()=>{M.default.invoke(this.points,"remove"),M.default.invoke(this.lines,"remove")})),W(this,"addRayControls",(()=>{this.addLine("ray")})),W(this,"removeRayControls",(()=>{this.removeLine()})),W(this,"addPolygonControls",(()=>{this.polygon=null;const e=$h.getPolygonCoords(this.props.graph,this.props);this.points=[],this.points=M.default.map(e,this.createPointForPolygonType,this),this.updatePolygon()})),W(this,"updatePolygon",(()=>{if("polygon"!==this.props.graph.type)throw Yh("updatePolygon","polygon");let e;e=this.polygon?this.polygon.closed():this.points.length>=3;const t=this.graphie,n=this.points.length,o=!M.default.contains(["angles","sides"],this.props.graph.snapTo),s=M.default.times(n,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==n-1)?"angles"===this.props.graph.snapTo?"$deg0":"$deg1":""}),this),i=M.default.times(n,(function(t){return e||0!==t&&t!==n-1}),this),r=M.default.times(n,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==n-1)?1:0}),this),a=M.default.times(n,(function(t){return!this.props.graph.showSides||!e&&t===n-1?"":"sides"===this.props.graph.snapTo?"$len0":"$len1"}),this);if(null==this.polygon){const n=this;n.polygon=ls.addMovablePolygon(t,{constraints:[ls.MovablePolygon.constraints.bound(),o?ls.MovablePolygon.constraints.snap():null],closed:e,points:n.points,angleLabels:s,showRightAngleMarkers:i,numArcs:r,sideLabels:a,onMove:[ls.MovablePolygon.onMove.updatePoints,function(){this.closed()&&n.updateCoordsFromPoints()}],normalStyle:{stroke:this.props.apiOptions.isMobile?dn.BLUE_C:dn.INTERACTIVE,...this._lineStroke()}})}else this.polygon.update({closed:e,points:this.points,angleLabels:s,showRightAngleMarkers:i,numArcs:r,sideLabels:a})})),W(this,"removePolygonControls",(()=>{var e;M.default.invoke(this.points,"remove"),null===(e=this.polygon)||void 0===e||e.remove()})),W(this,"addAngleControls",(()=>{if("angle"!==this.props.graph.type)throw Yh("addAngleControls","angle");const e=this.props.graph,t=this.graphie,n=$h.getAngleCoords(this.props.graph,this.props);var o,s;this.points=n.map((function(e,n){return null==t?void 0:t.addMovablePoint(M.default.extend({coord:e,normalStyle:{stroke:dn.INTERACTIVE,fill:dn.INTERACTIVE}},1===n?{snapX:t.snap[0],snapY:t.snap[1]}:{}))})),this.angle=null==t?void 0:t.addMovableAngle({points:this.points,snapDegrees:e.snapDegrees||1,snapOffsetDeg:e.angleOffsetDeg||0,angleLabel:e.showAngles?"$deg0":"",pushOut:2,allowReflex:(o=e.allowReflexAngles,s=!0,null==o?s:o)}),R.default(this.angle).on("move",(()=>{var t;this.onChange({graph:{...e,coords:null===(t=this.angle)||void 0===t?void 0:t.getClockwiseCoords()}})}))})),W(this,"removeAngleControls",(()=>{var e;M.default.invoke(this.points,"remove"),null===(e=this.angle)||void 0===e||e.remove()})),W(this,"toggleShowAngles",(()=>{if("polygon"!==this.props.graph.type)throw Yh("toggleShowAngles","polygon");const e=M.default.extend({},this.props.graph,{showAngles:!this.props.graph.showAngles});this.onChange({graph:e})})),W(this,"toggleShowSides",(()=>{if("polygon"!==this.props.graph.type)throw Yh("toggleShowSides","polygon");const e=M.default.extend({},this.props.graph,{showSides:!this.props.graph.showSides});this.onChange({graph:e})})),W(this,"getUserInput",(()=>$h.getUserInputFromProps(this.props))),W(this,"simpleValidate",(e=>$h.validate(this.getUserInput(),e,this))),W(this,"focus",R.default.noop)}UNSAFE_componentWillMount(){_h.UNSAFE_componentWillMount.call(this)}componentDidMount(){this.setGraphie(this.refs.graph.graphie())}UNSAFE_componentWillReceiveProps(e){var t,n;this.isClickToAddPoints()!==this.isClickToAddPoints(e)&&(this.shouldResetGraphie=!0,this.setState({shouldShowInstructions:Vh(e)})),(null===(t=this.props.backgroundImage)||void 0===t?void 0:t.url)===(null===(n=e.backgroundImage)||void 0===n?void 0:n.url)&&this.props.backgroundImage===e.backgroundImage&&this.props.containerSizeClass===e.containerSizeClass||(this.shouldResetGraphie=!0)}componentDidUpdate(e,t){const n=e.graph.type,o=this.props.graph.type;(n!==o||"angle"===e.graph.type&&"angle"===this.props.graph.type&&this.areAngleGraphsEqual(e.graph,this.props.graph)||"point"===e.graph.type&&"point"===this.props.graph.type&&this.arePointGraphsEqual(e.graph,this.props.graph)||"polygon"===e.graph.type&&"polygon"===this.props.graph.type&&this.arePolygonGraphsEqual(e.graph,this.props.graph)||"segment"===e.graph.type&&"segment"===this.props.graph.type&&this.areSegmentGraphsEqual(e.graph,this.props.graph))&&(this["remove"+Wh(n)+"Controls"](),this["add"+Wh(o)+"Controls"]()),this.shouldResetGraphie&&this.resetGraphie()}areAngleGraphsEqual(e,t){return e.allowReflexAngles!==t.allowReflexAngles||e.angleOffsetDeg!==t.angleOffsetDeg||e.snapDegrees!==t.snapDegrees}arePointGraphsEqual(e,t){return e.numPoints!==t.numPoints}arePolygonGraphsEqual(e,t){return e.numSides!==t.numSides||e.showAngles!==t.showAngles||e.showSides!==t.showSides||e.snapTo!==t.snapTo}areSegmentGraphsEqual(e,t){return e.numSegments!==t.numSegments}render(){const e=ni(this.props.containerSizeClass);let t;this.isClickToAddPoints()&&this.state.shouldShowInstructions?"point"===this.props.graph.type?t=S._("Click to add points"):"polygon"===this.props.graph.type&&(t=S._("Click to add vertices")):t=void 0;const n=this.isClickToAddPoints()?this.handleAddPointsMouseDown:null,o=this.props.gridStep||Ae.getGridStep(this.props.range,this.props.step,e[0]),s=this.props.snapStep||Ae.snapStepFromGridStep(o),i=this.props.apiOptions.isMobile;return _.createElement("div",{className:"perseus-widget perseus-widget-interactive-graph",style:{width:e[0],height:e[1]}},_.createElement(Eh,{instructions:t,ref:"graph",box:e,labels:this.props.labels,range:this.props.range,step:i?Ae.constrainedTickStepsFromTickSteps(this.props.step,this.props.range):this.props.step,gridStep:o,snapStep:s,markings:this.props.markings,backgroundImage:this.props.backgroundImage,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,onMouseDown:n,onGraphieUpdated:this.setGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:i}))}static getQuadraticCoefficients(e){const t=e[0],n=e[1],o=e[2],s=(t[0]-n[0])*(t[0]-o[0])*(n[0]-o[0]);if(0===s)return;return[(o[0]*(n[1]-t[1])+n[0]*(t[1]-o[1])+t[0]*(o[1]-n[1]))/s,(o[0]*o[0]*(t[1]-n[1])+n[0]*n[0]*(o[1]-t[1])+t[0]*t[0]*(n[1]-o[1]))/s,(n[0]*o[0]*(n[0]-o[0])*t[1]+o[0]*t[0]*(o[0]-t[0])*n[1]+t[0]*n[0]*(t[0]-n[0])*o[1])/s]}static getSinusoidCoefficients(e){const t=e[0],n=e[1],o=n[1]-t[1],s=Math.PI/(2*(n[0]-t[0]));return[o,s,t[0]*s,t[1]]}static getLineCoords(e,t){return e.coords||$h.pointsFromNormalized(t,[[.25,.75],[.75,.75]])}static getPointCoords(e,t){const n=e.numPoints||1;let o=e.coords;if(o)return o;switch(n){case 1:o=[e.coord||[0,0]];break;case 2:o=[[-5,0],[5,0]];break;case 3:o=[[-5,0],[0,0],[5,0]];break;case 4:o=[[-6,0],[-2,0],[2,0],[6,0]];break;case 5:o=[[-6,0],[-3,0],[0,0],[3,0],[6,0]];break;case 6:o=[[-5,0],[-3,0],[-1,0],[1,0],[3,0],[5,0]];break;case"unlimited":o=[]}const s=$h.normalizeCoords(o,[[-10,10],[-10,10]]);return $h.pointsFromNormalized(t,s)}static getLinearSystemCoords(e,t){return e.coords||M.default.map([[[.25,.75],[.75,.75]],[[.25,.25],[.75,.25]]],(e=>$h.pointsFromNormalized(t,e)))}static getPolygonCoords(e,t){if("polygon"!==e.type)throw Yh("toggleShowSides","polygon");let n=e.coords;if(n)return n;const o=e.numSides||3;if("unlimited"===o)n=[];else{const t=2*Math.PI/o,s=(1/o-.5)*Math.PI,i="sides"===e.snapTo?Math.sqrt(3)/3*7:4;n=M.default.times(o,(function(e){return[i*Math.cos(e*t+s),i*Math.sin(e*t+s)]}))}n=$h.normalizeCoords(n,[[-10,10],[-10,10]]);const s=!M.default.contains(["angles","sides"],e.snapTo);return n=$h.pointsFromNormalized(t,n,!s),n}static getSegmentCoords(e,t){const n=e.coords;if(n)return n;const o=e.numSegments||1,s=[[-10,10],[-10,10]];return{1:[5],2:[5,-5],3:[5,0,-5],4:[6,2,-2,-6],5:[6,3,0,-3,-6],6:[5,3,1,-1,-3,-5]}[o].map((function(e){let n=[[-5,e],[5,e]];return n=$h.normalizeCoords(n,s),n=$h.pointsFromNormalized(t,n),n}))}static getAngleCoords(e,t){let n=e.coords;if(n)return n;const o=e.snapDegrees||1;let s=o;for(;s<20;)s+=o;s=s*Math.PI/180;const i=(e.angleOffsetDeg||0)*Math.PI/180;n=$h.pointsFromNormalized(t,[[.85,.5],[.5,.5]]);const r=Oh(Fh(...n));return n[0]=[n[1][0]+r*Math.cos(i),n[1][1]+r*Math.sin(i)],n[2]=[n[1][0]+r*Math.cos(s+i),n[1][1]+r*Math.sin(s+i)],n}static normalizeCoords(e,t){return M.default.map(e,(function(e){return M.default.map(e,(function(e,n){const o=t[n][1]-t[n][0];return(e+t[n][1])/o}))}))}static getEquationString(e){const t="get"+Wh(e.graph.type)+"EquationString";return $h[t](e)}static pointsFromNormalized(e,t,n){return M.default.map(t,(function(t){return M.default.map(t,(function(t,o){const s=e.range[o];if(n)return s[0]+(s[1]-s[0])*t;const i=e.step[o],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(s,i),a=Math.round(t*r);return s[0]+i*a}))}))}static getLinearEquationString(e){const t=$h.getLineCoords(e.graph,e);if(Th(t[0][0],t[1][0]))return"x = "+t[0][0].toFixed(3);const n=(t[1][1]-t[0][1])/(t[1][0]-t[0][0]),o=t[0][1]-n*t[0][0];return Th(n,0)?"y = "+o.toFixed(3):"y = "+n.toFixed(3)+"x + "+o.toFixed(3)}static getCurrentQuadraticCoefficients(e){const t=e.graph.coords||$h.defaultQuadraticCoords(e);return $h.getQuadraticCoefficients(t)}static defaultQuadraticCoords(e){return $h.pointsFromNormalized(e,[[.25,.75],[.5,.25],[.75,.75]])}static getQuadraticEquationString(e){const t=$h.getCurrentQuadraticCoefficients(e);return"y = "+t[0].toFixed(3)+"x^2 + "+t[1].toFixed(3)+"x + "+t[2].toFixed(3)}static getCurrentSinusoidCoefficients(e){const t=e.graph.coords||$h.defaultSinusoidCoords(e);return $h.getSinusoidCoefficients(t)}static defaultSinusoidCoords(e){return $h.pointsFromNormalized(e,[[.5,.5],[.65,.6]])}static getSinusoidEquationString(e){const t=$h.getCurrentSinusoidCoefficients(e);return"y = "+t[0].toFixed(3)+"sin("+t[1].toFixed(3)+"x - "+t[2].toFixed(3)+") + "+t[3].toFixed(3)}static getCircleEquationString(e){const t=e.graph,n=t.center||[0,0],o=t.radius||2;return"center ("+n[0]+", "+n[1]+"), radius "+o}static getLinearSystemEquationString(e){const t=$h.getLinearSystemCoords(e.graph,e);return"\n"+Uh(t[0][0],t[0][1])+"\n"+Uh(t[1][0],t[1][1])+"\n"+function(e,t){const n=e[0][0],o=e[0][1],s=e[1][0],i=e[1][1],r=t[0][0],a=t[0][1],l=t[1][0],c=t[1][1],p=(n-s)*(a-c)-(o-i)*(r-l);if(Math.abs(p)<1e-9)return"Lines are parallel";const d=((n*i-o*s)*(a-c)-(o-i)*(r*c-a*l))/p;return"Intersection: ("+(((n*i-o*s)*(r-l)-(n-s)*(r*c-a*l))/p).toFixed(3)+", "+d.toFixed(3)+")"}(t[0],t[1])}static getPointEquationString(e){if("point"!==e.graph.type)throw Yh("getPointEquationString","point");return $h.getPointCoords(e.graph,e).map((function(e){return"("+e[0]+", "+e[1]+")"})).join(", ")}static getSegmentEquationString(e){if("segment"!==e.graph.type)throw Yh("getSegmentEquationString","segment");const t=$h.getSegmentCoords(e.graph,e);return M.default.map(t,(function(e){return"["+M.default.map(e,(function(e){return"("+e.join(", ")+")"})).join(" ")+"]"})).join(" ")}static getRayEquationString(e){if("ray"!==e.graph.type)throw Yh("createPointForPolygonType","ray");const t=$h.getLineCoords(e.graph,e),n=t[0],o=t[1];let s=$h.getLinearEquationString(e);return n[0]>o[0]?s+=" (for x <= "+n[0].toFixed(3)+")":n[0]<o[0]?s+=" (for x >= "+n[0].toFixed(3)+")":n[1]>o[1]?s+=" (for y <= "+n[1].toFixed(3)+")":s+=" (for y >= "+n[1].toFixed(3)+")",s}static getPolygonEquationString(e){if("polygon"!==e.graph.type)throw Yh("getPolygonEquationString","polygon");const t=$h.getPolygonCoords(e.graph,e);return M.default.map(t,(function(e){return"("+e.join(", ")+")"})).join(" ")}static getAngleEquationString(e){if("angle"!==e.graph.type)throw Yh("getAngleEquationString","angle");const t=$h.getAngleCoords(e.graph,e);return vn.findAngle(t[2],t[0],t[1]).toFixed(0)+"° angle at ("+t[1].join(", ")+")"}static validate(e,t,n){const o=!!(e.coords||e.center&&e.radius);if(e.type===t.correct.type&&o)if("linear"===e.type&&"linear"===t.correct.type&&null!=e.coords){const n=e.coords,o=t.correct.coords;if(Ph(o[0],o[1],n[0])&&Ph(o[0],o[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("linear-system"===e.type&&"linear-system"===t.correct.type&&null!=e.coords){const n=e.coords,o=t.correct.coords;if(Ph(o[0][0],o[0][1],n[0][0])&&Ph(o[0][0],o[0][1],n[0][1])&&Ph(o[1][0],o[1][1],n[1][0])&&Ph(o[1][0],o[1][1],n[1][1])||Ph(o[0][0],o[0][1],n[1][0])&&Ph(o[0][0],o[0][1],n[1][1])&&Ph(o[1][0],o[1][1],n[0][0])&&Ph(o[1][0],o[1][1],n[0][1]))return{type:"points",earned:1,total:1,message:null}}else if("quadratic"===e.type&&"quadratic"===t.correct.type&&null!=e.coords){const n=this.getQuadraticCoefficients(e.coords),o=this.getQuadraticCoefficients(t.correct.coords);if(Mh(n,o))return{type:"points",earned:1,total:1,message:null}}else if("sinusoid"===e.type&&"sinusoid"===t.correct.type&&null!=e.coords){const n=this.getSinusoidCoefficients(e.coords),o=this.getSinusoidCoefficients(t.correct.coords),s=qh(n),i=qh(o);if(Mh(s,i))return{type:"points",earned:1,total:1,message:null}}else if("circle"===e.type&&"circle"===t.correct.type){if(Mh(e.center,t.correct.center)&&Th(e.radius,t.correct.radius))return{type:"points",earned:1,total:1,message:null}}else if("point"===e.type&&"point"===t.correct.type&&null!=e.coords){var s;let o=$h.getPointCoords(t.correct,n);const i=null===(s=e.coords)||void 0===s?void 0:s.slice();if(o=o.slice(),null==i||i.sort(),o.sort(),Mh(i,o))return{type:"points",earned:1,total:1,message:null}}else if("polygon"===e.type&&"polygon"===t.correct.type&&null!=e.coords){var i,r;const n=null===(i=e.coords)||void 0===i?void 0:i.slice(),o=null===(r=t.correct.coords)||void 0===r?void 0:r.slice();let s;if("similar"===t.correct.match?s=Bh(n,o,Number.POSITIVE_INFINITY):"congruent"===t.correct.match?s=Bh(n,o,d.number.DEFAULT_TOLERANCE):"approx"===t.correct.match?s=Bh(n,o,.1):(n.sort(),o.sort(),s=Mh(n,o)),s)return{type:"points",earned:1,total:1,message:null}}else if("segment"===e.type&&"segment"===t.correct.type&&null!=e.coords){var a;let n=e.coords.slice(),o=null===(a=t.correct.coords)||void 0===a?void 0:a.slice();if(n=M.default.invoke(n,"sort").sort(),o=M.default.invoke(o,"sort").sort(),Mh(n,o))return{type:"points",earned:1,total:1,message:null}}else if("ray"===e.type&&"ray"===t.correct.type&&null!=e.coords){const n=e.coords,o=t.correct.coords;if(Mh(n[0],o[0])&&Ph(o[0],o[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("angle"===e.type&&"angle"===t.correct.type){const n=e.coords,o=t.correct.coords;let s;if("congruent"===t.correct.match){const e=M.default.map([n,o],(function(e){return(vn.findAngle(e[2],e[0],e[1])+360)%360}));s=Th(...e)}else s=Mh(n[1],o[1])&&Ph(o[1],o[0],n[0])&&Ph(o[1],o[2],n[2]);if(s)return{type:"points",earned:1,total:1,message:null}}return!o||M.default.isEqual(e,t.graph)?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}static getUserInputFromProps(e){return e.graph}}W($h,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showTooltips:!1,showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,graph:{type:"linear"}});var Xh={name:"interactive-graph",displayName:"Interactive graph",widget:$h};class Kh extends _.Component{constructor(){super(...arguments),W(this,"_input",void 0),W(this,"state",{isInputFocused:!1})}focusInput(){this._input&&this._input.focus()}handleClick(e){const{checked:t,onChange:n}=this.props;e.preventDefault(),this.focusInput(),n(!t)}handleKeyDown(e){const{onFocusPrevAnswer:t,onFocusNextAnswer:n}=this.props;switch(e.key){case"ArrowUp":e.preventDefault(),t();break;case"ArrowDown":e.preventDefault(),n()}}handleInputChange(e){e.preventDefault()}handleInputFocus(){this.setState({isInputFocused:!0})}handleInputBlur(){this.setState({isInputFocused:!1})}renderCheckmark(){const{checked:e}=this.props;return _.createElement("span",{className:l.css(Jh.checkmarkContainer)},e&&_.createElement(aa,{icon:po,size:16,color:D.default.offBlack}))}render(){const{content:e,checked:t,groupName:n,index:o,inputType:s}=this.props,{isInputFocused:i}=this.state,r="".concat(n,"-").concat(o);return _.createElement("div",{className:l.css(Jh.answerChoice,i&&Jh.answerFocused),onClick:e=>this.handleClick(e),onKeyDown:e=>this.handleKeyDown(e)},_.createElement("span",{className:l.css(Jh.answerInputWrapper)},_.createElement("input",{className:l.css(Xr.perseusSrOnly),checked:t,name:n,id:r,type:s,onChange:e=>this.handleInputChange(e),onFocus:()=>this.handleInputFocus(),onBlur:()=>this.handleInputBlur(),ref:e=>this._input=e}),this.renderCheckmark()),_.createElement("label",{htmlFor:r},_.createElement(Ai,{content:e})))}}class Zh extends _.Component{constructor(e){super(e),W(this,"_choices",void 0),this._choices=[],this.state={groupName:M.default.uniqueId("answer_choices_")}}focusAnswer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=this.props.choices.length;e<0?e+=t:e>=t&&(e-=t);const n=this._choices[e];n&&n.focusInput()}onAnswerChange(e,t){const{choices:n,multipleSelect:o,onChange:s}=this.props,i=[];for(let s=0;s<n.length;s++)i.push(o?s===e?t:n[s].checked:s===e&&t);s(i)}onFocusAnswer(e){this.focusAnswer(e)}render(){const{choices:e,multipleSelect:t}=this.props,{groupName:n}=this.state;return _.createElement("fieldset",null,e.map(((e,o)=>_.createElement(Kh,U({},e,{key:e.content,groupName:n,index:o,inputType:t?"checkbox":"radio",onChange:e=>this.onAnswerChange(o,e),onFocusPrevAnswer:()=>this.onFocusAnswer(o-1),onFocusNextAnswer:()=>this.onFocusAnswer(o+1),ref:e=>this._choices[o]=e})))))}}const Jh=l.StyleSheet.create({answerChoice:{display:"flex",alignItems:"center",userSelect:"none",padding:"10px 16px 10px 0px",fontWeight:"bold",border:"solid 2px transparent",borderRadius:2,":active":{backgroundColor:"rgba(33, 36, 44, 0.08)"}},answerFocused:{borderColor:"#1865f2",":active":{borderColor:"transparent"}},answerInputWrapper:{marginRight:8},checkmarkContainer:{display:"flex",position:"relative",width:16,height:16,marginLeft:8}});class Qh extends _.Component{constructor(){super(...arguments),W(this,"_icon",void 0),W(this,"state",{isFocused:!1})}handleFocus(){this.setState({isFocused:!0})}handleBlur(){this.setState({isFocused:!1})}renderIcon(){const{selected:e,showCorrectness:t,showSelected:n,showPulsate:o}=this.props,{isFocused:s}=this.state,i=n||s;let r,a;return t?(r=_.createElement(aa,{icon:"correct"===t?co:_o,size:24,color:D.default.white}),a="correct"===t?[ef.markerCorrect,i&&ef.markerCorrectSelected]:[ef.markerIncorrect,i&&ef.markerIncorrectSelected]):a=e&&e.length>0?[ef.markerFilled,i&&ef.markerFilledSelected]:[i?ef.markerUnfilledSelected:o&&ef.markerUnfilledPulsate],_.createElement("div",{className:l.css(ef.markerIcon,...a),ref:e=>this._icon=e},r)}render(){const{label:e,x:t,y:n,showCorrectness:o}=this.props,s="correct"===o;return _.createElement("button",{"aria-label":e,className:l.css(ef.unstyledButton,ef.marker,s&&ef.disabled),style:{left:"".concat(t,"%"),top:"".concat(n,"%")},tabIndex:s?-1:0,onFocus:()=>this.handleFocus(),onBlur:()=>this.handleBlur(),onClick:e=>this.props.onClick(e),onKeyDown:e=>this.props.onKeyDown(e)},this.renderIcon())}}W(Qh,"defaultProps",{selected:[]});const ef=l.StyleSheet.create({unstyledButton:{padding:0,overflow:"visible",color:"inherit",font:"inherit",lineHeight:"normal",background:"none",border:"none"},marker:{position:"absolute",width:30,height:30,marginLeft:-15,marginTop:-15},disabled:{pointerEvents:"none"},markerIcon:{display:"flex",position:"relative",boxSizing:"content-box",width:16,height:16,marginLeft:5,cursor:"pointer",backgroundColor:"#1865f2",border:"solid 2px #ffffff",borderRadius:16,boxShadow:"0 2px 6px 0 ".concat("rgba(33, 36, 44, 0.32)")},markerUnfilledPulsate:{animationName:{"0%":{transform:"scale(1)"},"100%":{transform:"scale(1.5)"}},animationDirection:"alternate",animationDuration:"0.8s",animationIterationCount:"infinite",animationTimingFunction:"ease-in",transformOrigin:"50% 50%"},markerUnfilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:20,height:20,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:20},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerFilled:{width:8,height:8,marginLeft:9,borderRadius:8,boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerFilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:12,height:12,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:12},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerCorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#00a60e",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerCorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#167b1f",boxShadow:"none","::before":{display:"none"}}},markerIncorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#909195",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerIncorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#6c6e73",boxShadow:"none","::before":{display:"none"}}}});class tf extends _.Component{static gradeMarker(e){const t={hasAnswers:!1,isCorrect:!1};return e.selected&&e.selected.length>0&&(t.hasAnswers=!0),e.answers.length>0?e.selected&&e.selected.length===e.answers.length&&(t.isCorrect=e.selected.every((t=>e.answers.includes(t)))):e.selected&&0!==e.selected.length||(t.isCorrect=!0),t}static validate(e,t){let n=0,o=0;for(const t of e.markers){const e=tf.gradeMarker(t);e.hasAnswers&&n++,e.isCorrect&&o++}return n!==e.markers.length?{type:"invalid",message:null}:{type:"points",earned:o===e.markers.length?1:0,total:1,message:null}}static pointInTriangle(e,t,n,o){const s=(e,t,n)=>(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y),i=s(e,t,n)<0,r=s(e,n,o)<0,a=s(e,o,t)<0;return i===r&&r===a}static imageSideForMarkerPosition(e,t){if(e<20)return"left";if(e>80)return"right";const n={x:20,y:0},o={x:80,y:0},s={x:80,y:100},i={x:20,y:100},r={x:50,y:50},a={top:[n,o,r],right:[r,o,s],bottom:[i,r,s],left:[n,r,i]},l={x:e,y:t};for(const e of Object.keys(a)){const t=a[e];if(tf.pointInTriangle(l,...t))return e}return"center"}static navigateToMarkerIndex(e,t,n){const o=t[n],s=t.map(((e,t)=>{const n=e.x-o.x,s=e.y-o.y,i=Math.sqrt(n**2+s**2);return{index:t,dist:i,dir:{x:0!==i?n/i:0,y:0!==i?s/i:0}}})).filter((e=>e.index!==n&&"correct"!==t[e.index].showCorrectness)).sort(((t,n)=>{const o=Math.round(t.dist*(e.x*t.dir.x+e.y*t.dir.y)),s=Math.round(n.dist*(e.x*n.dir.x+e.y*n.dir.y));let i,r;return e.x>0?(i=t.dir.x>0&&0!==o,r=n.dir.x>0&&0!==s):e.x<0?(i=t.dir.x<0&&0!==o,r=n.dir.x<0&&0!==s):e.y>0?(i=t.dir.y>0&&0!==o,r=n.dir.y>0&&0!==s):e.y<0&&(i=t.dir.y<0&&0!==o,r=n.dir.y<0&&0!==s),i!==r?i?-1:1:o-s}));return s.length>0?s[0].index:n}constructor(e){super(e),W(this,"_markers",void 0),W(this,"_selectedMarkerPopup",void 0),W(this,"_answerChoices",void 0),W(this,"handleDocumentClick",(e=>{if(this._selectedMarkerPopup&&this._answerChoices){const t=N.default.findDOMNode(this._answerChoices),n=e.target,o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return e&&(e.contains(n)||t>0&&o(e.parentElement,t-1))};o(t)||this.dismissMarkerPopup()}})),W(this,"handleDocumentKeyDown",(e=>{this._selectedMarkerPopup&&27===e.keyCode&&(e.stopPropagation(),this.dismissMarkerPopup())})),this._markers=[],this.state={selectedMarkerIndex:-1,markersInteracted:!1}}componentDidMount(){document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeyDown,!0)}componentWillUnmount(){document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeyDown,!0)}simpleValidate(e){return tf.validate(this.getUserInput(),e)}getUserInput(){const{markers:e}=this.props;return{markers:e}}showRationalesForCurrentlySelectedChoices(e){const{markers:t}=this.props,{onChange:n}=this.props;n({markers:t.map((e=>{const t=tf.gradeMarker(e);return{...e,showCorrectness:t.hasAnswers?t.isCorrect?"correct":"incorrect":void 0}}))},null,!0)}dismissMarkerPopup(){const{selectedMarkerIndex:e}=this.state;-1!==e&&this.setState({selectedMarkerIndex:-1},(()=>{const t=this._markers[e];t&&N.default.findDOMNode(t).focus()}))}handleMarkerChange(e,t){const{markers:n,onChange:o}=this.props;o({markers:[...n.slice(0,e),{...t,showCorrectness:void 0},...n.slice(e+1)]})}handleMarkerClick(e,t){const{selectedMarkerIndex:n}=this.state;t.preventDefault(),n!==e?this.setState({selectedMarkerIndex:e,markersInteracted:!0},(()=>{setTimeout((()=>{this._answerChoices&&this._answerChoices.focusAnswer()}),100)})):this.dismissMarkerPopup()}handleMarkerKeyDown(e,t){const{markers:n}=this.props;if(n.length<2)return;const o={ArrowUp:{x:0,y:-1},ArrowRight:{x:1,y:0},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0}}[t.key];if(!o)return;t.preventDefault();const s=this._markers[tf.navigateToMarkerIndex(o,n,e)];s&&N.default.findDOMNode(s).focus()}handleAnswerChoicesChangeForMarker(e,t){const{choices:n,markers:o,multipleAnswers:s}=this.props,i=n.filter(((e,n)=>t[n]));this.handleMarkerChange(e,{...o[e],selected:i}),s||this.dismissMarkerPopup()}renderAnswerChoicesForMarker(e,t){const{choices:n,multipleAnswers:o}=this.props,s=t.selected;return _.createElement("div",{className:E.default("perseus-label-image-widget-answer-choices",l.css(nf.scrollableChoices))},_.createElement(Zh,{choices:n.map((e=>({content:e,checked:!!s&&s.includes(e)}))),multipleSelect:o,onChange:t=>this.handleAnswerChoicesChangeForMarker(e,t),ref:e=>this._answerChoices=e}))}renderMarkers(){const{markers:e,questionCompleted:t}=this.props,{selectedMarkerIndex:n,markersInteracted:o}=this.state;return e.map(((e,s)=>{const i=tf.gradeMarker(e),r=_.createElement(Qh,U({},e,{showCorrectness:t&&i.hasAnswers&&i.isCorrect?"correct":e.showCorrectness,showSelected:s===n,showPulsate:!o,key:"".concat(e.x,".").concat(e.y),onClick:e=>this.handleMarkerClick(s,e),onKeyDown:e=>this.handleMarkerKeyDown(s,e),ref:e=>this._markers[s]=e}));if(s!==n)return r;let a;return a=window.matchMedia(Wr.xsOrSmaller.replace("@media ","")).matches?e.y>50?"top":"bottom":{left:"right",top:"bottom",right:"left",bottom:"top",center:"top"}[tf.imageSideForMarkerPosition(e.x,e.y)],_.createElement(b.Popover,{content:()=>_.createElement(b.PopoverContentCore,{style:nf.choicesPopover},this.renderAnswerChoicesForMarker(s,e)),placement:a,opened:!0,key:"".concat(e.x,".").concat(e.y),ref:e=>this._selectedMarkerPopup=e},r)}))}renderInstructions(){const{apiOptions:{isMobile:e},choices:t,multipleAnswers:n,hideChoicesFromInstructions:o}=this.props,s=e?n?S._("Tap each dot on the image to select all answers that apply."):S._("Tap each dot on the image to select an answer."):n?S._("Click each dot on the image to select all answers that apply."):S._("Click each dot on the image to select an answer."),i=S._("Choices:");return _.createElement("div",{className:E.default("perseus-label-image-widget-instructions",l.css(nf.instructions))},_.createElement("div",{className:l.css(nf.instructionsCaption)},s," ",!o&&i),!o&&_.createElement("div",{className:l.css(nf.instructionsChoices)},t.map(((e,t)=>_.createElement("div",{className:l.css(nf.instructionsChoice),key:t},_.createElement(Ai,{content:e}))))))}render(){const{imageAlt:e,imageUrl:t,imageWidth:n,imageHeight:o}=this.props,{selectedMarkerIndex:s}=this.state;return _.createElement("div",null,this.renderInstructions(),_.createElement("div",{className:l.css(nf.markersCanvas),style:{maxWidth:n,maxHeight:o}},_.createElement("div",{className:l.css(nf.imageContainer,-1!==s&&nf.imageInteractionDisabled)},_.createElement(Kt.Consumer,null,(s=>{let{setAssetStatus:i}=s;return _.createElement(zs,{alt:e,src:t,width:n,height:o,setAssetStatus:i})}))),this.renderMarkers()))}}const nf=l.StyleSheet.create({instructions:{paddingBottom:16},instructionsCaption:{...Za.bodyXsmallBold,paddingBottom:16},instructionsChoices:{display:"flex",flexWrap:"wrap",margin:"-8px 0"},instructionsChoice:{display:"flex",alignItems:"center",margin:"8px 0",":not(:last-child)":{"::after":{content:"''",display:"inline-block",position:"relative",width:2,height:2,marginLeft:5,marginRight:5,background:"rgba(33, 36, 44, 0.32)",borderRadius:2}}},markersCanvas:{position:"relative"},imageContainer:{display:"flex"},imageInteractionDisabled:{pointerEvents:"none"},scrollableChoices:{paddingTop:8,paddingBottom:8,[Wr.xsOrSmaller]:{maxHeight:250,overflowY:"auto"}},choicesPopover:{padding:0}});var of={name:"label-image",displayName:"Label Image",widget:tf,accessible:!0,isLintable:!0};const sf={display:"table",tableLayout:"fixed"},rf={display:"table-row"},af={display:"table-cell",padding:5},lf={borderRadius:10,cursor:"pointer"},cf={padding:5,display:"inline-block"},pf={float:"right",paddingRight:5},df={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?df.x():df.plus()};class uf extends _.Component{constructor(){super(...arguments),W(this,"_flip",(()=>{this.props.onChange(!this.props.value)}))}render(){const e=this.props.value?"#55dd55":"#115511",t=M.default.extend({},lf,{width:this.props.size,height:this.props.size,backgroundColor:e});return _.createElement("div",{style:t,onClick:this._flip})}}W(uf,"propTypes",{value:I.default.bool.isRequired,size:I.default.number.isRequired});class hf extends _.Component{render(){return _.createElement("div",{style:sf,className:"no-select"},M.default.map(this.props.cells,((e,t)=>_.createElement("div",{key:t,style:rf},M.default.map(e,((e,n)=>_.createElement("div",{key:n,style:af},_.createElement(uf,{value:e,size:this.props.size,onChange:M.default.partial(this.props.onChange,t,n)}))))))))}}W(hf,"propTypes",{cells:I.default.arrayOf(I.default.arrayOf(I.default.bool)).isRequired,size:I.default.number.isRequired});const ff=(e,t,n,o)=>((e,t)=>M.default.map(e,((e,n)=>M.default.map(e,((e,o)=>t(n,o)?!e:e)))))(e,((e,s)=>{const i=e-t,r=s-n;return Math.abs(i)<=1&&Math.abs(r)<=1&&o[i+1][r+1]}));class mf extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"_currPattern",void 0),W(this,"_nextPattern",void 0),W(this,"_patternIndex",void 0),W(this,"getUserInput",(()=>Nr.getUserInput.call(this))),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"_width",(()=>0!==this.props.cells.length?this.props.cells[0].length:0)),W(this,"_initNextPatterns",(()=>{this._currPattern=df[this.props.flipPattern](0),this._nextPattern=df[this.props.flipPattern](1),this._patternIndex=2})),W(this,"_shiftPatterns",(()=>{this._currPattern=this._nextPattern,this._nextPattern=df[this.props.flipPattern](this._patternIndex),this._patternIndex++})),W(this,"_flipTile",((e,t)=>{const n=ff(this.props.cells,e,t,this._currPattern);this._shiftPatterns(),this.change({cells:n,moveCount:this.props.moveCount+1})})),W(this,"_reset",(()=>{this.change({cells:this.props.startCells,moveCount:0})})),W(this,"simpleValidate",(e=>gf(e,this.getUserInput())))}render(){const e=60*this._width();return _.createElement("div",null,_.createElement(hf,{cells:this.props.cells,size:50,onChange:this._flipTile}),_.createElement("div",{style:{width:e}},_.createElement("div",{style:cf},S.ngettext("Moves: %(num)s","Moves: %(num)s",this.props.moveCount)),_.createElement("div",{style:pf},_.createElement("input",{type:"button",value:"Reset",onClick:this._reset,className:"simple-button"}))),_.createElement("div",{className:"clearfix"}))}componentDidMount(){this._initNextPatterns()}componentDidUpdate(e){e.flipPattern!==this.props.flipPattern&&this._initNextPatterns()}}W(mf,"propTypes",{...pr,cells:I.default.arrayOf(I.default.arrayOf(I.default.bool)),startCells:I.default.arrayOf(I.default.arrayOf(I.default.bool)),flipPattern:I.default.string.isRequired,moveCount:I.default.number.isRequired}),W(mf,"defaultProps",{cells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",moveCount:0});const gf=function(e,t){if(M.default.all(t.cells,((t,n)=>M.default.all(t,((t,o)=>t===e.startCells[n][o])))))return{type:"invalid",message:S._("Click on the tiles to change the lights.")};return M.default.all(t.cells,(e=>M.default.all(e,(e=>e))))?{type:"points",earned:1,total:1,message:null}:e.gradeIncompleteAsWrong?{type:"points",earned:0,total:1,message:null}:{type:"invalid",message:S._("You must turn on all of the lights to continue.")}};var vf={name:"lights-puzzle",displayName:"Lights Puzzle",hidden:!0,widget:mf,transform:function(e){return{cells:e.startCells,startCells:e.startCells,flipPattern:e.flipPattern}}};const yf=(e,t)=>{const n=e.offsetParent();return{top:t.top+n.scrollTop(),left:t.left+n.scrollLeft()}};class bf extends _.Component{render(){const{layout:e}=this.props,t=l.css(Cf.card,Cf.placeholder,"horizontal"===e&&Cf.horizontalCard),n={width:this.props.width,height:this.props.height};return null!=this.props.margin&&(n.margin=this.props.margin),_.createElement("li",{className:t,style:n})}}W(bf,"propTypes",{layout:I.default.oneOf(["horizontal","vertical"]),width:I.default.number.isRequired,height:I.default.number.isRequired});class xf extends _.Component{constructor(){super(...arguments),W(this,"animationFrameRequest",null),W(this,"isMouseMoveUpBound",void 0),W(this,"_mounted",void 0),W(this,"state",{startPosition:{left:0,top:0},startMouse:{left:0,top:0},mouse:{left:0,top:0}}),W(this,"getCurrentPosition",(()=>({left:this.state.startPosition.left+this.state.mouse.left-this.state.startMouse.left,top:this.state.startPosition.top+this.state.mouse.top-this.state.startMouse.top}))),W(this,"bindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!0,R.default(document).on("mousemove",this.onMouseMove),R.default(document).on("mouseup",this.onMouseUp)})),W(this,"unbindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!1,R.default(document).off("mousemove",this.onMouseMove),R.default(document).off("mouseup",this.onMouseUp)})),W(this,"onMouseDown",(e=>{if("static"!==this.props.type)return;if(0!==e.button&&(null==e.touches||1!==e.touches.length))return;e.preventDefault();const t=Ae.extractPointerLocation(e);this.animationFrameRequest=requestAnimationFrame((()=>{const e=R.default(N.default.findDOMNode(this)),n=e.position(),o=yf(e,n);t&&this._mounted&&this.setState({startPosition:o,startMouse:t,mouse:t,dragging:!0},(function(){this.bindMouseMoveUp(),this.props.onMouseDown()}))}))})),W(this,"onMouseMove",(e=>{if("dragging"!==this.props.type||!this.state.dragging)return;e.preventDefault();const t=Ae.extractPointerLocation(e);t&&(this.animationFrameRequest=requestAnimationFrame((()=>{this.setState({mouse:t},this.props.onMouseMove)})))})),W(this,"onMouseUp",(e=>{if("dragging"!==this.props.type||!this.state.dragging)return;e.preventDefault();Ae.extractPointerLocation(e)&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp())}))}componentDidMount(){this._mounted=!0,this.isMouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!Ae.supportsPassiveEvents()&&{passive:!1})}componentWillUnmount(){this._mounted=!1,this.isMouseMoveUpBound&&this.unbindMouseMoveUp(),this.animationFrameRequest&&cancelAnimationFrame(this.animationFrameRequest),document.removeEventListener("touchmove",this.onMouseMove)}render(){const{includePadding:e,layout:t,type:n}=this.props;let o=l.css(Cf.card,Cf.draggable,"horizontal"===t&&Cf.horizontalCard,"vertical"===t&&Cf.verticalCard,"dragging"===n&&Cf.dragging,"disabled"===n&&Cf.disabled,!e&&Cf.unpaddedCard)+" "+$t.INTERACTIVE+" perseus-sortable-draggable";e||(o+=" perseus-sortable-draggable-unpadded");const s={position:"static"};return"dragging"!==this.props.type&&"animating"!==this.props.type||M.default.extend(s,{position:"absolute"},this.getCurrentPosition()),this.props.width&&(s.width=this.props.width+1),this.props.height&&(s.height=this.props.height),null!=this.props.margin&&(s.margin=this.props.margin),_.createElement("li",{className:o,style:s,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,onTouchMove:this.onMouseMove,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},_.createElement(Ai,{content:this.props.content,linterContext:zt.pushContextStack(this.props.linterContext,"draggable"),onRender:this.props.onRender}))}componentDidUpdate(e){if(this.props.type!==e.type)if("animating"===this.props.type){const e=this.getCurrentPosition(),t=15*Math.sqrt(Math.sqrt(Math.pow(this.props.endPosition.left-e.left,2)+Math.pow(this.props.endPosition.top-e.top,2)));R.default(N.default.findDOMNode(this)).animate(this.props.endPosition,{duration:Math.max(t,1),complete:this.props.onAnimationEnd})}else"static"===this.props.type&&R.default(N.default.findDOMNode(this)).finish()}}W(xf,"propTypes",{content:I.default.string.isRequired,endPosition:I.default.object.isRequired,includePadding:I.default.bool,layout:I.default.oneOf(["horizontal","vertical"]),onAnimationEnd:I.default.func.isRequired,onMouseDown:I.default.func.isRequired,onMouseMove:I.default.func.isRequired,onMouseUp:I.default.func.isRequired,onRender:I.default.func.isRequired,type:I.default.oneOf(["static","dragging","animating","disabled"]),linterContext:qt}),W(xf,"defaultProps",{includePadding:!0,type:"static",linterContext:Ht});class wf extends _.Component{constructor(e){super(e),W(this,"remeasureItems",M.default.debounce((()=>{this.setState({items:wf.clearItemMeasurements(this.state.items)})}),20)),this.state={items:wf.itemsFromProps(this.props),katex:null}}UNSAFE_componentWillReceiveProps(e){const t=this.props;M.default.isEqual(e.options,t.options)?e.layout===t.layout&&e.padding===t.padding&&e.disabled===t.disabled&&M.default.isEqual(e.constraints,t.constraints)||this.setState({items:wf.clearItemMeasurements(this.state.items)}):this.setState({items:wf.itemsFromProps(e)})}componentDidUpdate(){!this.state.items.length||this.state.items[0].width||this.state.items[0].height||setTimeout((()=>{this.measureItems()}),0)}componentDidMount(){ne().getKaTeX().then((e=>{this.setState({katex:e})}))}static itemsFromProps(e){const t=e.disabled?"disabled":"static";return e.options.map(((e,n)=>({option:e,key:n,type:t,endPosition:{},width:0,height:0})))}static clearItemMeasurements(e){return e.map((e=>({...e,width:0,height:0})))}measureItems(){let e=M.default.clone(this.state.items);const t=M.default.map(e,(function(e){return R.default(N.default.findDOMNode(this.refs[e.key]))}),this),n=M.default.invoke(t,"outerWidth"),o=M.default.invoke(t,"outerHeight"),{constraints:s,layout:i}=this.props;let r=null;null!=s&&s.width?r=M.default.max(n.concat(s.width)):"vertical"===i&&(r=M.default.max(n));let a=null;null!=s&&s.height?a=M.default.max(o.concat(s.height)):"horizontal"===i&&(a=M.default.max(o)),e=M.default.map(e,(function(e,t){return e.width=r||n[t],e.height=a||o[t],e})),this.setState({items:e},(()=>{this.props.onMeasure&&this.props.onMeasure({widths:n,heights:o})}))}render(){var e,t;if(this.props.waitForKatexLoad&&!this.state.katex)return _.createElement(xd,null);const n=[],{layout:o}=this.props,s=l.css(Cf.sortable)+" perseus-sortable",i=(null===(e=this.props.constraints)||void 0===e?void 0:e.width)||"vertical"===o,r=(null===(t=this.props.constraints)||void 0===t?void 0:t.height)||"horizontal"===o;return M.default.each(this.state.items,(function(e,t,s){const a=t===s.length-1,l="static"===e.type||"disabled"===e.type;let c;"horizontal"===this.props.layout?c="0 "+this.props.margin+"px 0 0":"vertical"===this.props.layout&&(c="0 0 "+this.props.margin+"px 0"),n.push(_.createElement(xf,{content:e.option,key:e.key,type:e.type,ref:e.key,width:i?e.width:void 0,height:r?e.height:void 0,layout:o,includePadding:this.props.padding,margin:a&&l?0:c,endPosition:e.endPosition,linterContext:zt.pushContextStack(this.props.linterContext,"sortable"),onRender:this.remeasureItems,onMouseDown:this.onMouseDown.bind(this,e.key),onMouseMove:this.onMouseMove.bind(this,e.key),onMouseUp:this.onMouseUp.bind(this,e.key),onTouchMove:this.onMouseMove.bind(this,e.key),onTouchEnd:this.onMouseUp.bind(this,e.key),onTouchCancel:this.onMouseUp.bind(this,e.key),onAnimationEnd:this.onAnimationEnd.bind(this,e.key)})),"dragging"!==e.type&&"animating"!==e.type||n.push(_.createElement(bf,{key:"placeholder_"+e.key,ref:"placeholder_"+e.key,width:e.width,height:e.height,layout:o,margin:a?0:c}))}),this),_.createElement("ul",{className:s},n)}onMouseDown(e){const t=M.default.map(this.state.items,(function(t){return t.key===e&&(t.type="dragging"),t}));this.setState({items:t})}moveOptionToIndex(e,t){const{items:n}=this.state;if(t<0||t>n.length)throw new Error("index ".concat(t," out of bounds"));const o=M.default.clone(n),s=n.filter((t=>t.option===e))[0];if(null==s)throw new Error("option ".concat(e," not found"));const i=n.findIndex((e=>e.key===s.key));o.splice(i,1),o.splice(t,0,s),this.setState({items:o}),this.props.onChange&&this.props.onChange({})}onMouseMove(e){const t=R.default(N.default.findDOMNode(this.refs[e])),n=R.default(N.default.findDOMNode(this)),o=M.default.clone(this.state.items),s=M.default.findWhere(this.state.items,{key:e}),i=this.props.margin||0,r=M.default.indexOf(o,s);let a=0;if(o.splice(r,1),"horizontal"===this.props.layout){const e=t.offset().left-n.offset().left;let s,r=0;M.default.each(o,(function(t){s=t.width,e>r+s/2&&(a+=1),r+=s+i}))}else{const e=t.offset().top-n.offset().top;let s,r=0;M.default.each(o,(function(t){s=t.height,e>r+s/2&&(a+=1),r+=s+i}))}a!==r&&(o.splice(a,0,s),this.setState({items:o}))}onMouseUp(e){const t=requestAnimationFrame((()=>{const t=M.default.map(this.state.items,(function(t){if(t.key===e){t.type="animating";const n=R.default(N.default.findDOMNode(this.refs["placeholder_"+e])),o=n.position(),s=yf(n,o);t.endPosition=s}return t}),this);this.setState({items:t}),this.props.onChange&&this.props.onChange({})}));this.animationFrameRequest=t}onAnimationEnd(e){const t=M.default.map(this.state.items,(function(t){return t.key===e&&(t.type="static"),t}));this.setState({items:t})}getOptions(){return M.default.pluck(this.state.items,"option")}}W(wf,"defaultProps",{layout:"horizontal",padding:!0,disabled:!1,constraints:{},onMeasure:function(){},margin:5,onChange:function(){},linterContext:Ht,waitForKatexLoad:!0});const Cf=l.StyleSheet.create({sortable:{boxSizing:"border-box",float:"left",padding:0,margin:0},card:{boxSizing:"border-box",background:"#fff",border:"1px solid #ddd",borderRadius:4,cursor:"pointer",minWidth:25,minHeight:44,padding:10,listStyleType:"none",userSelect:"none",touchAction:"none"},placeholder:{background:"#ddd",border:"1px solid #ccc"},draggable:{textAlign:"center"},horizontalCard:{float:"left",cursor:"ew-resize"},verticalCard:{maxWidth:"100%",cursor:"ns-resize"},unpaddedCard:{padding:0},dragging:{background:"#ffedcd",opacity:.8},disabled:{backgroundColor:"inherit",border:"1px solid transparent",cursor:"default"}}),{shuffle:kf,seededRNG:Sf}=Ae;class Ef extends _.Component{constructor(){super(...arguments),W(this,"state",{leftHeight:0,rightHeight:0,katex:null}),W(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),W(this,"onMeasureLeft",(e=>{const t=M.default.max(e.heights);this.setState({leftHeight:t})})),W(this,"onMeasureRight",(e=>{const t=M.default.max(e.heights);this.setState({rightHeight:t})})),W(this,"getUserInput",(()=>this.state.katex?{left:this.refs.left.getOptions(),right:this.refs.right.getOptions()}:{left:[],right:[]})),W(this,"moveLeftOptionToIndex",((e,t)=>{this.refs.left.moveOptionToIndex(e,t)})),W(this,"moveRightOptionToIndex",((e,t)=>{this.refs.right.moveOptionToIndex(e,t)})),W(this,"simpleValidate",(e=>Ef.validate(this.getUserInput(),e)))}componentDidMount(){ne().getKaTeX().then((e=>this.setState({katex:e})))}render(){if(!this.state.katex)return _.createElement(xd,null);const e=Sf(this.props.problemNum);let t;t=this.props.orderMatters?kf(this.props.left,e,!0):this.props.left;const n=kf(this.props.right,e,!0),o=M.default.any(this.props.labels),s={height:M.default.max([this.state.leftHeight,this.state.rightHeight])},i=this.props.apiOptions.isMobile?8:5;return _.createElement("table",{className:l.css(_f.widget)+" perseus-widget-matcher"},_.createElement("tbody",null,o&&_.createElement("tr",{className:l.css(_f.row)},_.createElement("th",{className:l.css(_f.column,_f.columnLabel)},_.createElement(Ai,{content:this.props.labels[0]||"...",linterContext:this.props.linterContext})),_.createElement("th",{className:l.css(_f.column,_f.columnRight,_f.columnLabel)},_.createElement(Ai,{content:this.props.labels[1]||"...",linterContext:this.props.linterContext}))),_.createElement("tr",{className:l.css(_f.row)},_.createElement("td",{className:l.css(_f.column)},_.createElement(wf,{options:t,layout:"vertical",padding:this.props.padding,disabled:!this.props.orderMatters,constraints:s,onMeasure:this.onMeasureLeft,onChange:this.changeAndTrack,margin:i,linterContext:this.props.linterContext,ref:"left"})),_.createElement("td",{className:l.css(_f.column,_f.columnRight)},_.createElement(wf,{options:n,layout:"vertical",padding:this.props.padding,constraints:s,onMeasure:this.onMeasureRight,onChange:this.changeAndTrack,margin:i,linterContext:this.props.linterContext,ref:"right"})))))}}W(Ef,"propTypes",{apiOptions:Yt.propTypes,labels:I.default.array,left:I.default.array,onChange:I.default.func,orderMatters:I.default.bool,padding:I.default.bool,problemNum:I.default.number,right:I.default.array,trackInteraction:I.default.func.isRequired,linterContext:qt}),W(Ef,"defaultProps",{left:[],right:[],labels:["",""],orderMatters:!1,padding:!0,problemNum:0,onChange:function(){},linterContext:Ht}),M.default.extend(Ef,{validate:function(e,t){return{type:"points",earned:M.default.isEqual(e.left,t.left)&&M.default.isEqual(e.right,t.right)?1:0,total:1,message:null}}});const _f=l.StyleSheet.create({widget:{paddingTop:5,maxWidth:"100%",minWidth:"auto"},row:{border:0},column:{padding:0,border:0},columnRight:{borderLeft:"1px solid #444"},columnLabel:{fontWeight:"inherit",borderBottom:"1px solid #444",padding:"0 ".concat(5,"px ").concat(5,"px ").concat(5,"px"),textAlign:"center"}});var Tf={name:"matcher",displayName:"Two column matcher",widget:Ef,isLintable:!0};const{firstNumericalParse:Mf,captureScratchpadTouchStart:If}=Ae,Pf=ae.toNumericString,Nf=ae.getNumericFormat;class Af extends _.Component{constructor(){super(...arguments),W(this,"state",{format:this.props.format}),W(this,"getValue",(()=>this.parseInputValue(N.default.findDOMNode(this.refs.input).value))),W(this,"getStringValue",(()=>N.default.findDOMNode(this.refs.input).value.toString())),W(this,"parseInputValue",(e=>{if(""===e){const e=this.props.placeholder;return M.default.isFinite(e)?+e:null}const t=Mf(e);return M.default.isFinite(t)?t:this.props.value})),W(this,"focus",(()=>{N.default.findDOMNode(this.refs.input).focus(),this._handleFocus()})),W(this,"blur",(()=>{N.default.findDOMNode(this.refs.input).blur(),this._handleBlur()})),W(this,"setSelectionRange",((e,t)=>{N.default.findDOMNode(this).setSelectionRange(e,t)})),W(this,"getSelectionStart",(()=>N.default.findDOMNode(this).selectionStart)),W(this,"getSelectionEnd",(()=>N.default.findDOMNode(this).selectionEnd)),W(this,"_checkValidity",(e=>{if(null==e)return!0;const t=Mf(e),n=this.props.checkValidity;return M.default.isFinite(t)&&n(t)})),W(this,"_handleChange",(e=>{const t=e.target.value,n=this.parseInputValue(t),o=Nf(t);this.props.onChange(n),o&&(this.props.onFormatChange(n,o),this.setState({format:o}))})),W(this,"_handleFocus",(()=>{this.props.onFocus&&this.props.onFocus()})),W(this,"_handleBlur",(e=>{e&&"keypress"===e.type&&13!==e.keyCode||(this._setValue(this.props.value,this.state.format),this.props.onBlur&&this.props.onBlur())})),W(this,"_onKeyDown",(e=>{if(this.props.onKeyDown&&this.props.onKeyDown(e),!this.props.useArrowKeys||!M.default.contains(["ArrowUp","ArrowDown"],e.key))return;let t=this.getValue();t===Math.floor(t)&&("ArrowUp"===e.key?t+=1:"ArrowDown"===e.key&&(t-=1),this._checkValidity(t)&&this.props.onChange(t))})),W(this,"_setValue",((e,t)=>{R.default(N.default.findDOMNode(this.refs.input)).val(Pf(e,t))}))}render(){let e=E.default({"number-input":!0,"invalid-input":!this._checkValidity(this.props.value),mini:"mini"===this.props.size,small:"small"===this.props.size,normal:"normal"===this.props.size});null!=this.props.className&&(e=e+" "+this.props.className);const{onFormatChange:t,checkValidity:n,useArrowKeys:o,...s}=this.props;return _.createElement("input",U({},s,{className:e,type:"text",ref:"input",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,onKeyPress:this._handleBlur,onKeyDown:this._onKeyDown,onTouchStart:If,defaultValue:Pf(this.props.value,this.state.format),value:void 0}))}componentDidUpdate(e){d.number.equal(this.getValue(),this.props.value)||this._setValue(this.props.value,this.state.format)}}W(Af,"propTypes",{value:I.default.number,format:I.default.string,placeholder:I.default.oneOfType([I.default.string,I.default.number]),onChange:I.default.func.isRequired,onFormatChange:I.default.func,checkValidity:I.default.func,size:I.default.string,label:I.default.oneOf(["put your labels outside your inputs!"])}),W(Af,"defaultProps",{value:null,placeholder:null,format:null,onFormatChange:()=>null,checkValidity:()=>!0,useArrowKeys:!1});const{assert:Rf}=an,{stringArrayOfSize:Ff}=Ae,Of={INPUT_MARGIN:4,INPUT_HEIGHT:38,INPUT_WIDTH:82},Df={INPUT_MARGIN:3,INPUT_HEIGHT:30,INPUT_WIDTH:40},Lf={INPUT_MARGIN:4,INPUT_HEIGHT:36,INPUT_WIDTH:64};function Bf(e,t){return[""+e,""+t]}const zf=function(){return Bf(0,0)},qf=function(e){return Rf(M.default.isArray(e)&&2===e.length),+e[0]},Hf=function(e){return Rf(M.default.isArray(e)&&2===e.length),+e[1]},Wf=function(e){return"answer"+qf(e)+","+Hf(e)},Uf=function(e){const t=[1,1];return M.default(e).each(((e,n)=>{let o=0;M.default(e).each(((e,t)=>{null!=e&&e.toString().length&&(o=t+1)})),t[1]=Math.max(t[1],o),o>0&&(t[0]=Math.max(t[0],n+1))})),t};class Gf extends _.Component{constructor(){super(...arguments),W(this,"cursorPosition",void 0),W(this,"state",{enterTheMatrix:0}),W(this,"getInputPaths",(()=>{const e=[],t=this.props.matrixBoardSize[0],n=this.props.matrixBoardSize[1];return M.default(t).times((t=>{M.default(n).times((n=>{const o=Bf(t,n);e.push(o)}))})),e})),W(this,"getGrammarTypeForPath",(e=>"number")),W(this,"_handleFocus",((e,t)=>{this.props.onFocus(Bf(e,t))})),W(this,"_handleBlur",((e,t)=>{this.props.onBlur(Bf(e,t))})),W(this,"focus",(()=>(this.focusInputPath(zf()),!0))),W(this,"focusInputPath",(e=>{const t=Wf(e);this.refs[t].focus()})),W(this,"blurInputPath",(e=>{0===e.length&&(e=zf());const t=Wf(e);this.refs[t].blur()})),W(this,"getDOMNodeForPath",(e=>{const t=Wf(e);return N.default.findDOMNode(this.refs[t])})),W(this,"setInputValue",((e,t,n)=>{const o=qf(e),s=Hf(e);this.onValueChange(o,s,t,n)})),W(this,"handleKeyDown",((e,t,n)=>{const o=this.props.matrixBoardSize[0],s=this.props.matrixBoardSize[1];let i=null;const r=this.refs[Wf(Bf(e,t))],a=r.getStringValue(),l=r.getSelectionStart(),c=r.getSelectionEnd();let p=null;if("ArrowUp"===n.key&&e>0?p=Bf(e-1,t):"ArrowDown"===n.key&&e+1<o?p=Bf(e+1,t):"ArrowLeft"===n.key&&t>0?0===l&&0===c&&(p=Bf(e,t-1)):"ArrowRight"===n.key&&t+1<s?l===a.length&&(p=Bf(e,t+1)):"Enter"===n.key?i=this.state.enterTheMatrix+1:"Escape"===n.key&&(i=0),p){n.preventDefault();const e=this.refs[Wf(p)],t=2*e.getStringValue().length;e.focus(),"ArrowRight"===n.key?e.setSelectionRange(0,0):e.setSelectionRange(t,t)}null!=i&&this.setState({enterTheMatrix:i})})),W(this,"onValueChange",((e,t,n,o)=>{const s=M.default.map(this.props.answers,M.default.clone);s[e]||(s[e]=[]),s[e][t]=n,this.props.onChange({answers:s},o),this.props.trackInteraction()})),W(this,"getUserInput",(()=>({answers:this.props.answers}))),W(this,"simpleValidate",(e=>Gf.validate(this.getUserInput(),e)))}componentDidMount(){this.cursorPosition=[0,0]}render(){let e;e=this.props.apiOptions.customKeypad?Lf:this.props.apiOptions.staticRender?Of:Df;const{INPUT_MARGIN:t,INPUT_HEIGHT:n,INPUT_WIDTH:o}=e,s=Uf(this.props.answers),i=this.props.matrixBoardSize[0],r=this.props.matrixBoardSize[1],a=this.props.cursorPosition[0],l=this.props.cursorPosition[1],c=Math.max(a,s[0]-1),p=Math.max(l,s[1]-1),d=(c+1)*(n+2*t),u=(p+1)*(o+2*t),h=E.default({"perseus-matrix":!0,"static-mode":this.props.static,"the-matrix":this.state.enterTheMatrix>=5});return _.createElement("div",{className:h},this.props.prefix&&_.createElement("div",{className:"matrix-prefix"},_.createElement(Ai,{content:this.props.prefix,linterContext:this.props.linterContext})),_.createElement("div",{className:"matrix-input"},_.createElement("div",{className:"matrix-bracket bracket-left",style:{height:d}}),_.createElement("div",{className:"matrix-bracket bracket-right",style:{height:d,left:u}}),M.default(i).times((e=>{const s=this.props.answers[e];return _.createElement("div",{className:"matrix-row",key:e},M.default(r).times((i=>{const r=e>c||i>p,a={className:r?"outside":"inside",ref:Wf(Bf(e,i)),value:s?s[i]:null,style:{height:n,width:o,margin:t},disabled:this.props.apiOptions.readOnly,onFocus:()=>{this.cursorPosition=[e,i],this.props.onChange({cursorPosition:[e,i]},(()=>!1)),this._handleFocus(e,i)},onBlur:()=>{e===this.cursorPosition[0]&&i===this.cursorPosition[1]&&this.props.onChange({cursorPosition:[0,0]},(()=>!1)),this._handleBlur(e,i)},onKeyDown:t=>{this.handleKeyDown(e,i,t)},onChange:(t,n)=>{this.onValueChange(e,i,t,n)}};let l;if(this.props.apiOptions.customKeypad){const e={margin:t,minWidth:o,minHeight:n,boxSizing:"border-box",backgroundColor:r?"#f3f3f3":"#fff"};l=_.createElement(yr,U({},a,{style:e,scrollable:!0,keypadElement:this.props.keypadElement}))}else l=this.props.apiOptions.staticRender?_.createElement(Xi,a):this.props.numericInput?_.createElement(Af,a):_.createElement(Ki,a);return _.createElement("span",{key:i,className:"matrix-input-field"},l)})))}))),this.props.suffix&&_.createElement("div",{className:"matrix-suffix"},_.createElement(Ai,{content:this.props.suffix,linterContext:this.props.linterContext})))}}W(Gf,"defaultProps",{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0],apiOptions:Yt.defaults,linterContext:Ht}),M.default.extend(Gf,{validate:function(e,t){const n=t.answers,o=e.answers,s=Uf(n),i=Uf(o),r=s[0]!==i[0]||s[1]!==i[1],a=pe.number.createValidatorFunctional;let l=null,c=!1,p=!1;return M.default(i[0]).times((e=>{M.default(i[1]).times((t=>{if(null!=o[e][t]&&0!==o[e][t].toString().length||(c=!0),!r){const s=a(n[e][t],{simplify:!0})(o[e][t]);s.message&&(l=s.message),s.correct||(p=!0)}}))})),c?{type:"invalid",message:S._("Make sure you fill in all cells in the matrix.")}:r?{type:"points",earned:0,total:1,message:null}:{type:"points",earned:p?0:1,total:1,message:l}}});var Vf={name:"matrix",displayName:"Matrix",widget:Gf,transform:e=>{const t=M.default(e.matrixBoardSize[0]).times((function(){return Ff(e.matrixBoardSize[1])}));return e=M.default.pick(e,"matrixBoardSize","prefix","suffix"),M.default.extend(e,{answers:t})},staticTransform:e=>{const t=M.default.pick(e,"matrixBoardSize","prefix","suffix");return t.answers=M.default.map(e.answers,(e=>M.default.map(e,(e=>null!=e?String(e):"")))),t},isLintable:!0};const jf={url:null,top:0,left:0},Yf=F.default({displayName:"Measurer",propTypes:{apiOptions:Yt.propTypes,box:I.default.arrayOf(I.default.number),image:I.default.shape({url:I.default.string,top:I.default.number,left:I.default.number}),showProtractor:I.default.bool,protractorX:I.default.number,protractorY:I.default.number,showRuler:I.default.bool,rulerLabel:I.default.string,rulerTicks:I.default.number,rulerPixels:I.default.number,rulerLength:I.default.number},getDefaultProps:function(){return{box:[480,480],image:{},showProtractor:!0,protractorX:7.5,protractorY:.5,showRuler:!1,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10}},getInitialState:function(){return{}},render:function(){const e=M.default.extend({},jf,this.props.image);return _.createElement("div",{className:"perseus-widget perseus-widget-measurer graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]}},e.url&&_.createElement("div",{style:{position:"relative",top:e.top,left:e.left}},_.createElement(zs,{src:e.url})),_.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this.setupGraphie()},componentDidUpdate:function(e){M.default.any(["box","showProtractor","showRuler","rulerLabel","rulerTicks","rulerPixels","rulerLength"],(function(t){return e[t]!==this.props[t]}),this)&&this.setupGraphie()},setupGraphie:function(){const e=N.default.findDOMNode(this.refs.graphieDiv);R.default(e).empty();const t=this.graphie=vn.createGraphie(e),n=[40,40],o=[[0,this.props.box[0]/n[0]],[0,this.props.box[1]/n[1]]];t.init({range:o,scale:n}),t.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),this.protractor&&this.protractor.remove(),this.props.showProtractor&&(this.protractor=t.protractor([this.props.protractorX,this.props.protractorY])),this.ruler&&this.ruler.remove(),this.props.showRuler&&(this.ruler=t.ruler({center:[(o[0][0]+o[0][1])/2,(o[1][0]+o[1][1])/2],label:this.props.rulerLabel,pixelsPerUnit:this.props.rulerPixels,ticksPerUnit:this.props.rulerTicks,units:this.props.rulerLength}))},getUserInput:function(){return{}},simpleValidate:function(e){return Yf.validate(this.getUserInput(),e)},focus:R.default.noop});M.default.extend(Yf,{validate:function(e,t){return{type:"points",earned:1,total:1,message:null}}});var $f={name:"measurer",displayName:"Measurer",widget:Yf,version:{major:1,minor:0},propUpgrades:{1:e=>M.default(e).chain().omit("imageUrl","imageTop","imageLeft").extend({image:{url:e.imageUrl,top:e.imageTop,left:e.imageLeft}}).value()}};function Xf(e,t){const n=new Path2D;e.lineWidth=em.lineWidth,e.strokeStyle=em.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n)}const Kf={text:function(e,t){null!==t.value&&(e.fillStyle=em.fgColor,e.font=em.font,e.fillText(t.value,t.pos[0]-em.fontSizePx/2+1,t.pos[1]+em.fontSizePx/2))},"line:single":Xf,"line:double":function(e,t){let n=new Path2D;e.lineWidth=5*em.lineWidth,e.strokeStyle=em.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),n=new Path2D,e.lineWidth=3*em.lineWidth,e.strokeStyle=em.bgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n)},"line:triple":function(e,t){let n=new Path2D;e.lineWidth=7*em.lineWidth,e.strokeStyle=em.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),n=new Path2D,e.lineWidth=5*em.lineWidth,e.strokeStyle=em.bgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),Xf(e,t)}};const Zf={"line:single":0,"line:double":0,"line:triple":0,text:1};function Jf(e,t){return Zf[e.type]-Zf[t.type]}function Qf(e,t){t.sort(Jf).forEach(function(e){return function(t){Kf[t.type](e,t)}}(e))}const em={bgColor:"rgb(255, 255, 255)",fgColor:"rgb(0, 0, 0)",fontSizePx:12,lineWidth:1,font:"12px sans"};function tm(e,t,n,o){let s=e.symbol;if("C"===s&&1!==Object.keys(t).length&&(s=null),"1,0"===e.idx){const t=[0,0];return e.pos=t,e.baseAngle=-30+o,{type:"text",value:s,pos:t,idx:e.idx}}const i=t[e.connections.find((function(e){return t[e].pos}))],r=i.connections.indexOf(e.idx);let a=60,l=120;4===i.connections.length?(l=90,a=90):(n.find((t=>"triple"===t.bondType&&t.to===e.idx))||n.find((e=>"triple"===e.bondType&&e.to===i.idx)))&&(l=0,a=0);let c=0;const p=i.idx.split(":"),d=p[p.length-1].split(",")[0];c=parseInt(d)%2!=0?i.baseAngle-(a-l*r):i.baseAngle+(a-l*r);const u=function(e,t,n){const o=e[0],s=e[1];return[o+Math.cos(2*t*Math.PI/360)*n,s+-1*Math.sin(2*t*Math.PI/360)*n]}(i.pos,c,30);return e.pos=u,e.baseAngle=c,{type:"text",value:s,pos:u,idx:e.idx}}function nm(e,t){const n=function(e,t){let n=[e.pos[0],e.pos[1]],o=[t.pos[0],t.pos[1]];return"C"!==e.symbol&&(n=[t.pos[0]-.75*(t.pos[0]-e.pos[0]),t.pos[1]-.75*(t.pos[1]-e.pos[1])]),"C"!==t.symbol&&(o=[e.pos[0]-.75*(e.pos[0]-t.pos[0]),e.pos[1]-.75*(e.pos[1]-t.pos[1])]),[n,o]}(t[e.from],t[e.to]);return{type:"line:"+e.bondType,startPos:n[0],endPos:n[1]}}function om(e){return e.join(":")}function sm(e,t,n){if(null===n)return[e,t];if("atom"===n.type){const o=om(n.idx);e[o]={idx:o,symbol:n.symbol,connections:[]},n.bonds&&n.bonds.forEach((function(n){const s=om(n.to.idx);e[o].connections.push(s),t.push({from:o,to:s,bondType:n.bondType}),sm(e,t,n.to),e[s].connections.push(o)}))}return[e,t]}function im(e,t,n,o,s){if(0===t.length)return e;const i=t.shift(),r=n[i];return r.connections.forEach((function(e){n[e].pos||t.push(e)})),im(e.concat(tm(r,n,o,s)),t,n,o,s)}function rm(e,t,n){return 0===n.length?e:rm(e.concat(nm(n[0],t)),t,n.slice(1))}var am={layout:function(e,t){const n=sm({},[],e),o=n[0],s=n[1];return rm(im([],["1,0"],o,s,t),o,s)},_atomLayout:tm,_bondLayout:nm,_bondLength:30,_convertTree:sm};const lm=new RegExp("^[A-Za-z\\[\\]()=#+-]*$"),cm=new RegExp("^(Cl|Br|[CONPSFBI]|\\[)");function pm(e){this.message=e}function dm(e,t,n){const o=t[0],s=t.slice(1);let i;i=Array.isArray(e)?[...e]:{...e||{}};let r=n;return s.length>0&&(r=dm(i[o],s,n)),i[o]=r,i}function um(e,t){if(0===t.length)return e;if(""===e)throw new pm("Mismatched parentheses");const n=e[0],o=e.slice(1);return um(o,"("===n?t.concat(n):")"===n?t.slice(1):t)}function hm(e,t){const n=e[0],o=e.slice(1);if("("===n){let e={...t,parens:t.parens+"("};e=function(e,t){const n=t.reduce((function(e,t){return e[t]}),e);return dm(e,t,n+1)}(t,["idx",t.idx.length-1,1]);let n=-1;t.idx[t.idx.length-1][0]%2==0&&(n=0);const s=mm(o,{...e,idx:e.idx.concat([[n,0]]),parens:e.parens.concat("(")}),i=mm(um(o,["("]),e);return[s].concat(i)}if(")"===n){if("("!==t.parens[t.parens.length-1])throw new pm("Mismatched parentheses");return null}throw new pm("Invalid bare character: "+n)}function fm(e,t){const n=function(e,t){let n=null,o=null;if("["===e[0]){const t=e.indexOf("]");if(-1===t)return["",e];n=e.slice(1,t),o=e.slice(t+1)}else n=cm.exec(e)[1],o=e.slice(n.length);return[n,o]}(e),o=n[0];if(""===o)return["error","Unable to parse bracketed atom."];const s=n[1],i=dm(t,["idx",t.idx.length-1],[1+t.idx[t.idx.length-1][0],0]);let r=mm(s,dm(i,["bond","bondType"],"single"));!Array.isArray(r)&&r&&(r=[r]);const a={type:"atom",symbol:o,bonds:r,idx:i.idx};return t.bond?{type:"bond",bondType:t.bond.bondType,to:a}:a}function mm(e,t){if(!function(e){return lm.test(e)}(e))throw new pm("Invalid input.");return e&&0!==e.length?(n=e,cm.test(n)?fm(e,t||{idx:[[0,0]],parens:[],stack:[],bondModifiers:[]}):function(e){return"="===e||"#"===e}(e[0])?function(e,t){const n=e[0],o=e.slice(1);if("="===n)return mm(o,dm(t,["bond","bondType"],"double"));if("#"===n)return mm(o,dm(t,["bond","bondType"],"triple"));throw new pm("Invalid character: "+n)}(e,t):hm(e,t)):null;var n}var gm=mm,vm=pm;const{layout:ym}=am,bm=gm,xm=vm;class wm extends _.Component{constructor(){super(...arguments),W(this,"state",{parsedSmiles:null,error:null}),W(this,"stateFromSmiles",(e=>{try{this.setState({parsedSmiles:bm(e),error:null})}catch(e){if(!(e instanceof xm))throw e;this.setState({error:e.message})}})),W(this,"setCanvasBounds",((e,t)=>{const n=Math.max(...t.map((e=>e.pos?e.pos[0]:-1/0))),o=Math.max(...t.map((e=>e.pos?e.pos[1]:-1/0))),s=Math.min(...t.map((e=>e.pos?e.pos[0]:1/0))),i=Math.min(...t.map((e=>e.pos?e.pos[1]:1/0))),r=n-s+60,a=o-i+60;return e.width=r,e.height=a,[30-s,30-i]})),W(this,"canvasRender",(()=>{if(this.state.error||!this.state.parsedSmiles)return;const e=ym(this.state.parsedSmiles,this.props.rotationAngle),t=this.refs.canvas,n=this.setCanvasBounds(t,e),o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),o.save(),o.translate(n[0],n[1]),Qf(o,e),o.restore()}))}UNSAFE_componentWillMount(){this.stateFromSmiles(this.props.smiles)}componentDidMount(){this.canvasRender()}UNSAFE_componentWillReceiveProps(e){this.stateFromSmiles(e.smiles)}componentDidUpdate(){this.canvasRender()}render(){let e=_.createElement("canvas",{className:"molecule-canvas",id:this.props.id+"-molecule",ref:"canvas"},S.$_("A molecular structure drawing. SMILES notation: %(content)s",{content:this.props.smiles}));return this.state.error&&(e=_.createElement("div",{className:"error"},this.state.error)),_.createElement("div",{className:"molecule-canvas"},e)}}W(wm,"propTypes",{id:I.default.string.isRequired,rotationAngle:I.default.number,smiles:I.default.string});class Cm extends _.Component{constructor(){super(...arguments),W(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),W(this,"getUserInput",(()=>[])),W(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null})))}render(){return _.createElement(wm,{id:this.props.widgetId,smiles:this.props.smiles,rotationAngle:this.props.rotationAngle})}}W(Cm,"propTypes",{rotationAngle:I.default.number,smiles:I.default.string,widgetId:I.default.string}),W(Cm,"defaultProps",{rotationAngle:0});var km={name:"molecule-renderer",displayName:"Molecule renderer",hidden:!0,widget:Cm};const Sm=Es.MovablePoint,Em=Es.Line,{assert:_m}=an,Tm={ge:"le",gt:"lt",le:"ge",lt:"gt"},Mm={ge:"gt",gt:"ge",le:"lt",lt:"le"};function Im(e,t){return 1===t?""+e:"\\dfrac{".concat(e,"}{").concat(t,"}")}function Pm(e,t){if(e<0)return"-"+Pm(-e,t);const n=Math.floor(e/t);return 0===n?Im(e,t):e-n*t==0?""+n:n+Im(e-n*t,t)}const Nm=(e,t,n,o,s)=>{if(o=o||n,"decimal"===t||"decimal ticks"===t)return e.label([n,-.53],Math.round(100*o)/100,"center");if("improper"===t){const t=ae.toFraction(o);return e.label([n,-.17],Im(t[0],t[1]),"below")}if("mixed"===t){const t=ae.toFraction(o);return e.label([n,-.17],Pm(t[0],t[1]),"below")}if("non-reduced"===t){const t=ae.toFraction(o);return e.label([n,-.17],function(e,t,n){return Im(e*Math.floor(n/t),n)}(t[0],t[1],s),"below")}},Am=Es.createSimpleClass(((e,t)=>{if(!M.default.isFinite(t.tickStep)||t.tickStep<=0)return[];const n=[],o=t.range,s=t.labelRange,i=null==s[0]?o[0]:s[0],r=null==s[1]?o[1]:s[1];let a;if("non-reduced"===t.labelStyle){const e=[i,r];for(let n=0;n<=t.numDivisions;n++){const s=o[0]+n*t.tickStep;e.push(s)}const n=e=>d.number.toFraction(e)[1],s=M.default.map(e,n);a=M.default.reduce(s,((e,t)=>ae.getLCM(e,t)))}else a=void 0;for(let s=0;s<=t.numDivisions;s++){const i=o[0]+s*t.tickStep;n.push(e.line([i,-.2],[i,.2]));(t.labelTicks||"decimal ticks"===t.labelStyle)&&n.push(Nm(e,t.labelStyle,i,i,a))}return n.push(e.style(t.isMobile?{color:dn.BLUE_D}:{},(()=>Nm(e,t.labelStyle,i,i,a)))),n.push(e.style(t.isMobile?{color:dn.BLUE_D}:{},(()=>Nm(e,t.labelStyle,r,r,a)))),e.style({stroke:t.isMobile?dn.BLUE_D:dn.DYNAMIC,strokeWidth:3.5},(()=>{n.push(e.line([i,-.2],[i,.2])),n.push(e.line([r,-.2],[r,.2]))})),n}));class Rm extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"state",{numDivisionsEmpty:!1}),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"isValid",(()=>{const e=this.props.range;let t=this.props.numLinePosition;const n=this.props.divisionRange;return t=null==t?e[0]:t,e[0]<e[1]&&d.number.sign(t-e[0])>=0&&d.number.sign(t-e[1])<=0&&n[0]<n[1]&&0<this.props.numDivisions&&0<this.props.snapDivisions})),W(this,"onNumDivisionsChange",((e,t)=>{const n=this.props.divisionRange.slice(),o=this.props.range[1]-this.props.range[0];if(e=(e=Math.round(e))<0?-1*e:e){const s=M.default.extend({},this.props,{tickStep:o/e}),i=this.snapNumLinePosition(s,this.props.numLinePosition);this.setState({numDivisionsEmpty:!1},(()=>{this.props.onChange({divisionRange:n,numDivisions:e,numLinePosition:i},t)}))}else this.setState({numDivisionsEmpty:!0},t)})),W(this,"_handleTickCtrlFocus",(()=>{this.props.onFocus(["tick-ctrl"])})),W(this,"_handleTickCtrlBlur",(()=>{this.props.onBlur(["tick-ctrl"])})),W(this,"focus",(()=>{if(this.props.isTickCtrl)return this.refs["tick-ctrl"].focus(),!0})),W(this,"focusInputPath",(e=>{1===e.length&&this.refs[e[0]].focus()})),W(this,"blurInputPath",(e=>{1===e.length&&this.refs[e[0]].blur()})),W(this,"getInputPaths",(()=>this.props.isTickCtrl?[["tick-ctrl"]]:[])),W(this,"getDOMNodeForPath",(e=>{if(1===e.length)return N.default.findDOMNode(this.refs[e[0]])})),W(this,"getGrammarTypeForPath",(e=>{if(1===e.length&&"tick-ctrl"===e[0])return"number"})),W(this,"setInputValue",((e,t,n)=>{1===e.length&&"tick-ctrl"===e[0]&&this.onNumDivisionsChange(t,n)})),W(this,"_renderGraphie",(()=>{const e=this.props.range,t=e[1]-e[0],n=M.default.pick(this.props,["range","isTickCtrl"]),o=M.default.extend({},this.props,{tickStep:t/this.props.numDivisions});return _.createElement(Es,{ref:"graphie",key:this.props.labelStyle,box:[this.props.apiOptions.isMobile?288:460,80],options:n,onMouseDown:e=>{this.refs.graphie.movables.numberLinePoint.grab(e)},setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile},_.createElement(Am,U({},M.default.pick(o,["range","numDivisions","labelTicks","labelStyle","labelRange","tickStep"]),{isMobile:this.props.apiOptions.isMobile})),this._renderInequality(o),this._renderNumberLinePoint(o))})),W(this,"snapNumLinePosition",((e,t)=>{const n=e.range[0],o=e.range[1],s=e.tickStep/e.snapDivisions;let i=((e,t,n)=>Math.min(Math.max(e,t),n))(t,n,o);return i=n+d.number.roundTo(i-n,s),_m(M.default.isFinite(i)),i})),W(this,"movePosition",(e=>{this.change({numLinePosition:e}),this.props.trackInteraction()})),W(this,"_renderNumberLinePoint",(e=>{const t=M.default(["lt","gt"]).contains(e.rel);let n;n=t?dn._BACKGROUND:e.static?dn.DYNAMIC:dn.INTERACTIVE;const o={fill:n,stroke:e.static?dn.DYNAMIC:dn.INTERACTIVE,"stroke-width":t?3:1},s={fill:t?dn._BACKGROUND:dn.INTERACTING,"stroke-width":t?3:1},i=e.isInequality?{stroke:dn.INTERACTIVE,"fill-opacity":t?0:1}:{};return _.createElement(Sm,{ref:"numberLinePoint",pointSize:6,coord:[e.numLinePosition,0],constraints:[(e,t)=>[e[0],t[1]],(t,n)=>[this.snapNumLinePosition(e,t[0]),t[1]]],normalStyle:o,highlightStyle:s,onMove:e=>{this.movePosition(e[0])},isMobile:this.props.apiOptions.isMobile,mobileStyleOverride:i,showTooltips:this.props.showTooltips,xOnlyTooltip:!0})})),W(this,"handleReverse",(()=>{const e=Tm[this.props.rel];this.props.onChange({rel:e})})),W(this,"handleToggleStrict",(()=>{const e=Mm[this.props.rel];this.props.onChange({rel:e})})),W(this,"_getInequalityEndpoint",(e=>{const t=M.default(["ge","gt"]).contains(e.rel),n=e.range,o=30*((n[1]-n[0])/400),s=n[0]-o,i=n[1]+o;return t?[i,0]:[s,0]})),W(this,"_renderInequality",(e=>{if(e.isInequality){const t=this._getInequalityEndpoint(e),n={arrows:"->",stroke:this.props.apiOptions.isMobile?dn.INTERACTIVE:dn.DYNAMIC,strokeWidth:3.5},o=["ge","gt"].includes(e.rel);return _.createElement(Em,{start:[(o?.4:-.4)+e.numLinePosition,0],end:t,style:n})}return null})),W(this,"_setupGraphie",((e,t)=>{if(!this.isValid())return;const n=this.props.apiOptions.isMobile?228:400,o=t.range,s=(o[1]-o[0])/n,i=30*s,r=o[0]-i,a=o[1]+i,l="improper"===this.props.labelStyle||"mixed"===this.props.labelStyle||"non-reduced"===this.props.labelStyle?-1.5:-1;e.init({range:[[r,a],[l,1]],scale:[1/s,40],isMobile:this.props.apiOptions.isMobile});const c=(o[0]+o[1])/2;e.line([c,0],[a,0],{arrows:"->"}),e.line([c,0],[r,0],{arrows:"->"})})),W(this,"getUserInput",(()=>({numLinePosition:this.props.numLinePosition,rel:this.props.isInequality?this.props.rel:"eq",numDivisions:this.props.numDivisions,divisionRange:this.props.divisionRange}))),W(this,"simpleValidate",(e=>Rm.validate(this.getUserInput(),e)))}render(){const e=this.props.divisionRange,t=e[0]+"–"+e[1],n=this.props.numDivisions<e[0]||this.props.numDivisions>e[1],o=_.createElement("div",null,_.createElement("input",{type:"button",className:"simple-button",value:S._("Switch direction"),onClick:this.handleReverse}),_.createElement("input",{type:"button",className:"simple-button",value:M.default(["le","ge"]).contains(this.props.rel)?S._("Make circle open"):S._("Make circle filled"),onClick:this.handleToggleStrict}));let s;if(this.props.isTickCtrl){let t;t=this.props.apiOptions.customKeypad?yr:this.props.apiOptions.staticRender?Xi:Af,s=_.createElement("label",null,S._("Number of divisions:")," ",_.createElement(t,{ref:"tick-ctrl",value:this.state.numDivisionsEmpty?null:this.props.numDivisions||e[0],checkValidity:t=>t>=e[0]&&t<=e[1],onChange:this.onNumDivisionsChange,onFocus:this._handleTickCtrlFocus,onBlur:this._handleTickCtrlBlur,useArrowKeys:!0,keypadElement:this.props.keypadElement}))}return _.createElement("div",{className:"perseus-widget perseus-widget-interactive-number-line"},s,this.isValid()?this.props.isTickCtrl&&n?_.createElement("div",{className:"perseus-error"},S.$_("Please make sure the number of divisions is in the range %(divRangeString)s.",{divRangeString:t})):this._renderGraphie():_.createElement("div",{className:"perseus-error"},S.doNotTranslate("Invalid number line configuration.")),!this.props.static&&this.props.isInequality&&o)}}W(Rm,"defaultProps",{range:[0,10],labelStyle:"decimal",labelRange:[null,null],divisionRange:[1,12],labelTicks:!0,isTickCtrl:!1,isInequality:!1,numLinePosition:0,snapDivisions:2,showTooltips:!1,rel:"ge",apiOptions:Yt.defaults}),M.default.extend(Rm,{validate:function(e,t){const n=t.range,o=e.divisionRange,s=null!=t.initialX?t.initialX:n[0],i=t.isInequality?"ge":"eq",r=t.correctRel||"eq",a=d.number.equal(e.numLinePosition,t.correctX||0),l=e.numDivisions>o[1]||e.numDivisions<o[0];return e.isTickCrtl&&l?{type:"invalid",message:"Number of divisions is outside the allowed range."}:a&&r===e.rel?{type:"points",earned:1,total:1,message:null}:e.numLinePosition===s&&e.rel===i?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}});var Fm={name:"number-line",displayName:"Number line",widget:Rm,transform:e=>{const t=M.default.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isTickCtrl","isInequality","showTooltips"]),n=null!=e.initialX?e.initialX:e.range[0],o=e.range[1]-e.range[0];let s;return s=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?o/e.tickStep:void 0,M.default.extend(t,{numLinePosition:n,numDivisions:s,snapDivisions:t.snapDivisions||void 0}),t},staticTransform:e=>{const t=M.default.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isInequality"]),n=null!=e.correctX?e.correctX:e.range[0],o=e.range[1]-e.range[0];let s;return s=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?o/e.tickStep:void 0,M.default.extend(t,{numLinePosition:n,numDivisions:s,rel:e.isInequality?e.correctRel:null,snapDivisions:t.snapDivisions||void 0}),t}};class Om extends _.Component{render(){return _.createElement("div",{className:"card-wrap "+$t.INTERACTIVE,style:{width:this.props.width}},_.createElement("div",{className:"card placeholder",style:{height:this.props.height}}))}}W(Om,"propTypes",{width:I.default.number.isRequired,height:I.default.number.isRequired});class Dm extends _.Component{render(){return _.createElement("div",{className:"card-wrap "+$t.INTERACTIVE},_.createElement("div",{className:"card drag-hint"}))}}const Lm=I.default.shape({left:I.default.number,top:I.default.number});class Bm extends _.Component{constructor(){super(...arguments),W(this,"mouseMoveUpBound",void 0),W(this,"state",{dragging:!1}),W(this,"bindMouseMoveUp",(()=>{this.mouseMoveUpBound=!0,R.default(document).on("mousemove",this.onMouseMove),R.default(document).on("mouseup",this.onMouseUp)})),W(this,"unbindMouseMoveUp",(()=>{this.mouseMoveUpBound=!1,R.default(document).off("mousemove",this.onMouseMove),R.default(document).off("mouseup",this.onMouseUp)})),W(this,"onMouseDown",(e=>{e.preventDefault();const t=Ae.extractPointerLocation(e);t&&(this.setState({dragging:!0}),this.bindMouseMoveUp(),this.props.onMouseDown&&this.props.onMouseDown(t,this))})),W(this,"onMouseMove",(e=>{if(!this.state.dragging)return;e.preventDefault();const t=Ae.extractPointerLocation(e);t&&this.props.onMouseMove&&this.props.onMouseMove(t)})),W(this,"onMouseUp",(e=>{e.preventDefault();const t=Ae.extractPointerLocation(e);t&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp&&this.props.onMouseUp(t))}))}render(){let e={};this.props.floating&&(e={position:"absolute",left:this.props.startOffset.left,top:this.props.startOffset.top}),this.props.width&&(e.width=this.props.width);const t=["card"];this.props.stack&&t.push("stack"),this.props.floating&&!this.props.animating&&(t.push("dragging"),e.left+=this.props.mouse.left-this.props.startMouse.left,e.top+=this.props.mouse.top-this.props.startMouse.top);const n=M.default.pick(this.props,"content"),o=this.props.animating?R.default.noop:this.onMouseDown;return _.createElement("div",{className:"card-wrap "+$t.INTERACTIVE,style:e,onMouseDown:o,onTouchStart:o,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},_.createElement("div",{className:t.join(" ")},_.createElement(Ai,U({},n,{linterContext:this.props.linterContext}))))}shouldComponentUpdate(e,t){return this.props.floating||e.floating||this.props.content!==e.content||this.props.fakeRef!==e.fakeRef}componentDidMount(){this.mouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!Ae.supportsPassiveEvents()&&{passive:!1})}componentDidUpdate(e,t){if(this.props.animating&&!e.animating){const e=15*Math.sqrt(Math.sqrt(Math.pow(this.props.animateTo.left-this.props.startOffset.left,2)+Math.pow(this.props.animateTo.top-this.props.startOffset.top,2)));R.default(N.default.findDOMNode(this)).animate(this.props.animateTo,Math.max(e,1),this.props.onAnimationEnd)}}componentWillUnmount(){this.mouseMoveUpBound&&(ie.error("Removing an element with bound event handlers.",se.Internal),this.unbindMouseMoveUp(),Ae.resetTouchHandlers()),document.removeEventListener("touchmove",this.onMouseMove)}}W(Bm,"propTypes",{floating:I.default.bool.isRequired,animating:I.default.bool,width:I.default.number,stack:I.default.bool,onMouseDown:I.default.func,onMouseMove:I.default.func,onMouseUp:I.default.func,startMouse:Lm,startOffset:Lm,animateTo:Lm,onAnimationEnd:I.default.func,linterContext:qt}),W(Bm,"defaultProps",{stack:!1,animating:!1,linterContext:Ht});class zm extends _.Component{constructor(){super(...arguments),W(this,"state",{current:[],dragging:!1,placeholderIndex:null,dragKey:null,animating:!1,dragContent:null,dragWidth:null,dragHeight:null,offsetPos:null,animateTo:null,grabPos:null}),W(this,"onClick",((e,t,n,o)=>{const s=R.default(N.default.findDOMNode(o)),i=this.state.current.slice();let r,a=null;"current"===e?(i.splice(t,1),r=this.state.current[t],a=t):"bank"===e&&(r=this.props.options[t]),this.setState({current:i,dragging:!0,placeholderIndex:a,dragKey:r.key,dragContent:r.content,dragWidth:s.width(),dragHeight:s.height(),grabPos:n,mousePos:n,offsetPos:s.position()})})),W(this,"onRelease",(e=>{const t=this.refs.dragging;if(null==t)return;const n=this.isCardInBank(t),o=this.state.placeholderIndex||0,s=()=>{const e=this.state.current.slice();if(!n){const t={content:this.state.dragContent,key:M.default.uniqueId("perseus_draggable_card_"),width:this.state.dragWidth};e.splice(o,0,t)}this.props.onChange({current:e}),this.setState({current:e,dragging:!1,placeholderIndex:null,animating:!1}),this.props.trackInteraction()},i=R.default(N.default.findDOMNode(t)).position();let r=null;n?M.default.each(this.props.options,(function(e,t){if(e.content===this.state.dragContent){const e=N.default.findDOMNode(this.refs["bank"+t]);r=R.default(e).position()}}),this):null!=this.refs.placeholder&&(r=R.default(N.default.findDOMNode(this.refs.placeholder)).position()),null==r?s():this.setState({offsetPos:i,animateTo:r,onAnimationEnd:s,animating:!0,dragging:!1})})),W(this,"onMouseMove",(e=>{const t=this.refs.dragging;if(null==t)return;let n;n=this.isCardInBank(t)?null:this.findCorrectIndex(t,this.state.current),this.setState({mousePos:e,placeholderIndex:n})})),W(this,"findCorrectIndex",((e,t)=>{const n="horizontal"===this.props.layout,o=R.default(N.default.findDOMNode(this.refs.dragList)),s=o.offset().left,i=o.offset().top,r=R.default(N.default.findDOMNode(e)).offset().left-s,a=R.default(N.default.findDOMNode(e)).offset().top-i;let l=0,c=0,p=0;return n?M.default.each(t,(function(e,t){const n=N.default.findDOMNode(this.refs["sortable"+t]),o=R.default(n).outerWidth(!0);r>c+o/2&&(l+=1),c+=o}),this):M.default.each(t,(function(e,t){const n=N.default.findDOMNode(this.refs["sortable"+t]),o=R.default(n).outerHeight(!0);a>p+o/2&&(l+=1),p+=o}),this),l})),W(this,"isCardInBank",(e=>{if(null==e)return!1;const t="horizontal"===this.props.layout,n=R.default(N.default.findDOMNode(e)),o=R.default(N.default.findDOMNode(this.refs.bank)),s=n.offset(),i=o.offset(),r=n.outerHeight(!0),a=o.outerHeight(!0),l=o.outerWidth(!0),c=N.default.findDOMNode(this.refs.dragList);R.default(c).width();const p=n.outerWidth(!0);return t?s.top+r/2<i.top+a:s.left+p/2<i.left+l})),W(this,"setListValues",(e=>{const t=e.map((e=>({content:e})));this.props.onChange({current:t}),this.setState({current:t})})),W(this,"getUserInput",(()=>({current:M.default.map(this.props.current,(function(e){return e.content}))}))),W(this,"simpleValidate",(e=>zm.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){M.default.isEqual(this.props.current,e.current)||this.setState({current:e.current})}render(){const e=this.state.dragging&&_.createElement(Bm,{ref:"dragging",floating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,startMouse:this.state.grabPos,mouse:this.state.mousePos,width:this.state.dragWidth,onMouseUp:this.onRelease,onMouseMove:this.onMouseMove,key:this.state.dragKey||"draggingCard",linterContext:this.props.linterContext}),t=this.state.animating&&_.createElement(Bm,{floating:!0,animating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,width:this.state.dragWidth,animateTo:this.state.animateTo,onAnimationEnd:this.state.onAnimationEnd,key:this.state.dragKey||"draggingCard",linterContext:this.props.linterContext}),n=M.default.map(this.state.current,(function(e,t){return _.createElement(Bm,{key:"sortableCard".concat(t),ref:"sortable"+t,fakeRef:"sortable"+t,floating:!1,content:e.content,width:e.width,linterContext:this.props.linterContext,onMouseDown:this.state.animating?R.default.noop:this.onClick.bind(null,"current",t)})}),this);if(null!=this.state.placeholderIndex){const e=_.createElement(Om,{ref:"placeholder",width:this.state.dragWidth,height:this.state.dragHeight,key:"placeholder"});n.splice(this.state.placeholderIndex,0,e)}const o=n.length>0;n.push(e,t);const s=_.createElement("div",{className:"perseus-clearfix draggable-box"},!o&&_.createElement(Dm,null),_.createElement("div",{ref:"dragList"},n)),i=_.createElement("div",{ref:"bank",className:"bank perseus-clearfix"},M.default.map(this.props.options,((e,t)=>_.createElement(Bm,{ref:"bank"+t,floating:!1,content:e.content,stack:!0,key:t,linterContext:this.props.linterContext,onMouseDown:this.state.animating?R.default.noop:this.onClick.bind(null,"bank",t),onMouseMove:this.onMouseMove,onMouseUp:this.onRelease})),this));return _.createElement("div",{className:"draggy-boxy-thing orderer height-"+this.props.height+" layout-"+this.props.layout+" above-scratchpad blank-background perseus-clearfix "+$t.INTERACTIVE,ref:"orderer"},i,s)}}W(zm,"defaultProps",{current:[],options:[],correctOptions:[],height:"normal",layout:"horizontal",linterContext:Ht}),M.default.extend(zm,{validate:function(e,t){if(0===e.current.length)return{type:"invalid",message:null};return{type:"points",earned:M.default.isEqual(e.current,M.default.pluck(t.correctOptions,"content"))?1:0,total:1,message:null}}});var qm={name:"orderer",displayName:"Orderer",widget:zm,isLintable:!0};class Hm extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"getUserInput",(()=>Nr.getUserInput.call(this))),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"simpleValidate",(e=>Hm.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){return _.createElement(Ai,{content:this.props.content,inline:!0,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext})}}W(Hm,"propTypes",{...pr,content:I.default.string,linterContext:qt}),W(Hm,"defaultProps",{content:"",linterContext:Ht});var Wm={name:"passage-ref-target",displayName:"PassageRefTarget",defaultAlignment:"inline",widget:Hm,hidden:!0,transform:e=>M.default.pick(e,"content"),version:{major:0,minor:0},isLintable:!0};function Um(e,t,n,o){let s;return s="start"===t&&"start"===o?Range.START_TO_START:"start"===t&&"end"===o?Range.END_TO_START:"end"===t&&"start"===o?Range.START_TO_END:Range.END_TO_END,e.compareBoundaryPoints(s,n)}function Gm(e,t){const n=e.cloneRange();return n.setEnd(t.endContainer,t.endOffset),n}function Vm(e,t){return!(Um(e,"end",t,"start")<0||Um(t,"end",e,"start")<0)}function jm(e,t){if(!Vm(e,t))return null;return Gm(Um(e,"start",t,"start")<0?e:t,Um(e,"end",t,"end")>0?e:t)}function Ym(e,t,n,o,s){let i=-1,r=o,a=s,l=0;for(;r<=a;){if(l++,l>2*t.length)throw new Error("Assertion error: Binary search isn't terminating? "+"lower=".concat(r,", upper=").concat(a));const o=Math.floor((r+a)/2);if("first"===n){Um(t[o],"end",e,"start")<=0?r=o+1:(i=o,a=o-1)}else{Um(t[o],"start",e,"end")>=0?a=o-1:(i=o,r=o+1)}}return i}function $m(e,t){const n={};let o=t.domRange,s=t.firstWordIndex,i=t.lastWordIndex;for(const t of Object.keys(e)){const r=e[t],a=jm(r.domRange,o);a?(o=a,s=Math.min(r.firstWordIndex,s),i=Math.max(r.lastWordIndex,i)):n[t]=r}const r={firstWordIndex:s,lastWordIndex:i,domRange:o},a=function(e){const t="".concat((new Date).getTime());if(!e.includes(t))return t;let n,o=0;do{n="".concat(t,"-").concat(o),o++}while(e.includes(n));return n}(Object.keys(n));return n[a]=r,n}function Xm(e,t,n){for(const t of Object.keys(e)){const i=e[t].domRange;if(Um(o=i,"start",s=n,"start")<=0&&Um(o,"end",s,"end")>=0)return null}var o,s;const i=function(e,t){const n=Ym(e,t,"first",0,t.length-1);if(n<0)return null;const o=Ym(e,t,"last",n,t.length-1);return o<0?null:[n,o]}(n,t);if(!i)return null;const[r,a]=i;return{firstWordIndex:r,lastWordIndex:a,domRange:Gm(t[r],t[a])}}function Km(e,t){const{firstWordIndex:n,lastWordIndex:o}=e.range,s=t[n];if(!s)throw new re("first word index ".concat(s," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),se.InvalidInput,{metadata:{firstWord:s,wordRanges:JSON.stringify(t)}});const i=t[o];if(!i)throw new re("last word index ".concat(i," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),se.InvalidInput,{metadata:{lastWord:i,wordRanges:JSON.stringify(t)}});return{firstWordIndex:n,lastWordIndex:o,domRange:Gm(s,i)}}function Zm(e){const{firstWordIndex:t,lastWordIndex:n}=e;return{range:{type:"word-indexes",firstWordIndex:t,lastWordIndex:n}}}function Jm(e,t){return{left:e.left-t.left,top:e.top-t.top}}function Qm(e,t){let{left:n,top:o,width:s,height:i}=e;return{...Jm({left:n,top:o},t),width:s,height:i}}function eg(e){const t=[];return tg(e.commonAncestorContainer,e,t),t}function tg(e,t,n){const o=new Range;if(o.selectNodeContents(e),e.nodeType===Node.TEXT_NODE){const r=Vm(s=t,i=o)?Gm(Um(s,"start",i,"start")>0?s:i,Um(s,"end",i,"end")<0?s:i):null;r&&function(e,t,n){const o=e.parentElement,s=window.getComputedStyle(o);let i=null;if("string"==typeof s.lineHeight&&s.lineHeight.endsWith("px")){const e=parseFloat(s.lineHeight);isNaN(e)||(i=e)}const r=Array.from(t.getClientRects());for(const e of r){const t={left:e.left,top:e.top,height:e.height,width:e.width};if(null!==i){const e=i-t.height;t.top-=e,t.height=i}n.push(t)}}(e,r,n)}else if(e.nodeType===Node.ELEMENT_NODE){if(!Vm(t,o))return;for(const o of Array.from(e.childNodes))tg(o,t,n)}var s,i}class ng extends _.PureComponent{constructor(){super(...arguments),W(this,"state",{cachedHighlightRects:this._computeRects(this.props),tooltipIsHovered:!1})}UNSAFE_componentWillReceiveProps(e){this.props.highlight===e.highlight&&this.props.offsetParent===e.offsetParent||this.setState({cachedHighlightRects:this._computeRects(e)})}_computeRects(e){const{highlight:t,offsetParent:n}=e,o=eg(t.domRange),{left:s,top:i}=n.getBoundingClientRect();return o.map((e=>Qm(e,{left:s,top:i})))}_rectIsHovered(e,t){const n=Jm(t,{left:e.left,top:e.top});return 0<=n.left&&n.left<e.width&&0<=n.top&&n.top<e.height}isHovered(e){if(!e)return!1;const{offsetParent:t}=this.props,{cachedHighlightRects:n}=this.state,{left:o,top:s}=t.getBoundingClientRect(),i=Jm(e,{left:o,top:s});return n.some((e=>this._rectIsHovered(e,i)))}render(){const e=this.state.cachedHighlightRects;return _.createElement("div",null,e.map(((e,t)=>_.createElement("div",{key:t,className:l.css(og.highlightRect),style:{position:"absolute",width:e.width,height:e.height,top:e.top,left:e.left,zIndex:this.props.zIndexes.belowContent}}))))}}const og=l.StyleSheet.create({highlightRect:{background:"#fffabe"}});class sg extends _.PureComponent{constructor(){super(...arguments),W(this,"_tooltip",void 0)}componentDidUpdate(e){var t;this.props.focusNode===e.focusNode&&this.props.focusOffset===e.focusOffset&&this.props.offsetParent===e.offsetParent||(null===(t=this._tooltip)||void 0===t||t.remeasure())}_getFocusRect(){const{focusNode:e,focusOffset:t,offsetParent:n}=this.props,o=document.createRange();o.setStart(e,t),o.setEnd(e,t);const s=o.getClientRects()[0];if(!s)return ie.log('[Highlighting] Known bug: Could not determine the focus position, so did not show an "Add Highlight" tooltip. https://app.asana.com/0/329800276300868/413878480039713 (see also /r/asana-links)'),null;const{left:i,top:r}=n.getBoundingClientRect();return Qm({left:s.left,top:s.top,width:s.width,height:s.height},{left:i,top:r})}render(){const e=this._getFocusRect();if(!e)return null;const t=_.createElement("div",{className:l.css(ig.tooltipLabel)},this.props.label);return _.createElement(ml,{content:t,color:$a.kaBlue,inverted:!0,onClick:this.props.onClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,toggleOnHover:!1,showOnMount:!0,ref:e=>this._tooltip=e},_.createElement("div",{style:{position:"absolute",left:e.left,top:e.top,height:e.height}}))}}const ig=l.StyleSheet.create({tooltipLabel:{userSelect:"none"}});class rg extends _.PureComponent{constructor(){super(...arguments),W(this,"state",{hoveredHighlightKey:null,hoveringTooltipFor:null}),W(this,"_highlightRenderers",{}),W(this,"_handleMouseMove",(e=>{const t={left:e.clientX,top:e.clientY},n=this._getHoveredHighlightKey(t);this.setState({hoveredHighlightKey:n})}))}componentDidMount(){this._updateEditListeners(!1,this.props.editable)}UNSAFE_componentWillReceiveProps(e){this._updateEditListeners(this.props.editable,e.editable),null==this.state.hoveredHighlightKey||this.state.hoveredHighlightKey in e.highlights||this.setState({hoveredHighlightKey:null}),null==this.state.hoveringTooltipFor||this.state.hoveringTooltipFor in e.highlights||this.setState({hoveringTooltipFor:null})}componentWillUnmount(){this._updateEditListeners(this.props.editable,!1)}_updateEditListeners(e,t){!e&&t?window.addEventListener("mousemove",this._handleMouseMove):e&&!t&&(window.removeEventListener("mousemove",this._handleMouseMove),this.setState({hoveredHighlightKey:null,hoveringTooltipFor:null}))}_getHoveredHighlightKey(e){const{hoveringTooltipFor:t}=this.state;if("string"==typeof t)return t;return Object.keys(this.props.highlights).find((t=>{const n=this._highlightRenderers[t];return n&&n.isHovered(e)}))}_renderTooltip(){const{hoveredHighlightKey:e}=this.state;if(null==e)return null;const t=this.props.highlights[e];return _.createElement(sg,{label:S._("Remove highlight"),focusNode:t.domRange.endContainer,focusOffset:t.domRange.endOffset,offsetParent:this.props.offsetParent,onClick:()=>this.props.onRemoveHighlight(e),onMouseEnter:()=>this.setState({hoveringTooltipFor:e}),onMouseLeave:()=>this.setState({hoveringTooltipFor:null})})}render(){return _.createElement("div",null,Object.keys(this.props.highlights).map((e=>_.createElement(ng,{ref:t=>{t?this._highlightRenderers[e]=t:delete this._highlightRenderers[e]},key:e,highlight:this.props.highlights[e],highlightKey:e,offsetParent:this.props.offsetParent,zIndexes:this.props.zIndexes}))),this.props.editable&&this._renderTooltip())}}class ag extends _.PureComponent{constructor(){super(...arguments),W(this,"state",{mouseState:"up",trackedSelection:null}),W(this,"_handleSelectionChange",(()=>{this._updateTrackedSelection(this.props.buildHighlight),"down"===this.state.mouseState&&this.setState({mouseState:"down-and-selecting"})})),W(this,"_handleMouseDown",(()=>{this.setState({mouseState:"down"})})),W(this,"_handleMouseUp",(()=>{this.setState({mouseState:"up"})}))}componentDidMount(){this._updateListeners(!1,this.props.enabled)}UNSAFE_componentWillReceiveProps(e){this.props.buildHighlight!==e.buildHighlight&&this._updateTrackedSelection(e.buildHighlight),this._updateListeners(this.props.enabled,e.enabled)}componentWillUnmount(){this._updateListeners(this.props.enabled,!1)}_updateListeners(e,t){!e&&t?(window.addEventListener("mousedown",this._handleMouseDown),window.addEventListener("mouseup",this._handleMouseUp),document.addEventListener("selectionchange",this._handleSelectionChange)):e&&!t&&(window.removeEventListener("mousedown",this._handleMouseDown),window.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("selectionchange",this._handleSelectionChange),this.setState({mouseState:"up",trackedSelection:null}))}_computeFocusAndRange(){const e=document.getSelection();if(!e||0===e.rangeCount)return null;const t=e.getRangeAt(0);if(t.collapsed)return null;return{focusNode:e.focusNode,focusOffset:e.focusOffset,range:t}}_computeTrackedSelection(e){const t=this._computeFocusAndRange();if(!t)return null;const{focusNode:n,focusOffset:o,range:s}=t,i=e(s);return i?{focusNode:n,focusOffset:o,proposedHighlight:i}:null}_updateTrackedSelection(e){const t=this._computeTrackedSelection(e);this.setState({trackedSelection:t})}render(){const{mouseState:e,trackedSelection:t}=this.state,n="down-and-selecting"===e;return this.props.children?_.createElement("div",null,this.props.children(t,n)):null}}class lg extends _.PureComponent{_handleAddHighlight(e){this.props.onAddHighlight(e);const t=document.getSelection();t&&t.collapseToEnd()}_selectionIsValid(e){if(!e)return!1;const{contentNode:t}=this.props,n=new Range;n.selectNodeContents(t);const o=new Range;o.setStart(e.focusNode,e.focusOffset),o.collapse(!0);return Vm(n,o)}render(){return _.createElement(ag,{buildHighlight:this.props.buildHighlight,enabled:this.props.editable},((e,t)=>_.createElement("div",null,_.createElement(rg,{editable:this.props.editable&&!this._selectionIsValid(e),highlights:this.props.highlights,offsetParent:this.props.offsetParent,onRemoveHighlight:this.props.onRemoveHighlight,zIndexes:this.props.zIndexes}),this._selectionIsValid(e)&&!t&&_.createElement(sg,{label:S._("Add highlight"),onClick:()=>this._handleAddHighlight(e.proposedHighlight),focusNode:e.focusNode,focusOffset:e.focusOffset,offsetParent:this.props.offsetParent}))))}}class cg extends _.PureComponent{constructor(){super(...arguments),W(this,"_container",void 0)}componentDidMount(){this._sendWordsUpdate()}componentDidUpdate(){this._sendWordsUpdate()}_sendWordsUpdate(){this.props.onWordsUpdate(this._getWordRanges())}_getWordRanges(){const e=this._container;if(!e)throw new re("invariant violation: `this._container` is not defined, but this method is only called after mount/update",se.NotAllowed);const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,(()=>NodeFilter.FILTER_ACCEPT),!1),n=[];let o=null;for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){"inline"!==getComputedStyle(e).display&&(o=null)}else if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue,s=/\S+/g;let i,r=null;for(;null!==(i=s.exec(t));){const s=i.index,a=i.index+i[0].length;let l;0===s&&o?(l=o,l.setEnd(e,a)):(l=e.ownerDocument.createRange(),l.setStart(e,s),l.setEnd(e,a),n.push(l)),a===t.length&&(r=l)}o=r}}return n}render(){return _.createElement("div",{ref:e=>this._container=e},this.props.children)}}class pg extends _.PureComponent{constructor(){super(...arguments),W(this,"_container",void 0),W(this,"_content",void 0),W(this,"state",{wordRanges:[]}),W(this,"_handleAddHighlight",(e=>{const t=$m(this._getDOMHighlights(),e),n={};for(const e of Object.keys(t))n[e]=Zm(t[e]);this.props.onSerializedHighlightsUpdate(n)})),W(this,"_handleRemoveHighlight",(e=>{const{serializedHighlights:t}=this.props,n={...t};delete n[e],this.props.onSerializedHighlightsUpdate(n)})),W(this,"_handleWordsUpdate",(e=>{this.setState({wordRanges:e})}))}_buildHighlight(e){return Xm(this._getDOMHighlights(),this.state.wordRanges,e)}_getDOMHighlights(){const{serializedHighlights:e}=this.props,{wordRanges:t}=this.state,n={};for(const o of Object.keys(e))n[o]=Km(e[o],t);return n}render(){const e=this._getDOMHighlights();return _.createElement("div",{className:l.css(dg.container),ref:e=>this._container=e},_.createElement("div",null,this.props.enabled&&this._container&&this._content&&_.createElement(lg,{buildHighlight:e=>this._buildHighlight(e),contentNode:this._content,editable:this.props.editable,highlights:e,offsetParent:this._container,zIndexes:{belowContent:0},onAddHighlight:this._handleAddHighlight,onRemoveHighlight:this._handleRemoveHighlight})),_.createElement("div",{className:l.css(dg.content),ref:e=>this._content=e},_.createElement(cg,{onWordsUpdate:this._handleWordsUpdate},this.props.children)))}}const dg=l.StyleSheet.create({container:{position:"relative",zIndex:0},content:{position:"relative",zIndex:1}}),ug={display:"inline-block",width:0,visibility:"hidden"},hg={display:"inline",whiteSpace:"nowrap"},fg={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",paddingLeft:10,paddingRight:10,userSelect:"none",WebkitUserSelect:"none"},mg={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",userSelect:"none",WebkitUserSelect:"none",width:22,height:22,borderRadius:"50%",textAlign:"center"};class gg extends _.Component{constructor(){super(...arguments),W(this,"getRefContent",(()=>this.props.refContent))}render(){return _.createElement("span",{style:ug},S.doNotTranslate("_"))}}W(gg,"propTypes",{refContent:I.default.node.isRequired});class vg extends _.Component{render(){return _.createElement("span",{style:ug},S.doNotTranslate("_"))}}const yg={newline:P.default.defaultRules.newline,paragraph:P.default.defaultRules.paragraph,escape:P.default.defaultRules.escape,passageFootnote:{order:P.default.defaultRules.escape.order+.1,match:P.default.inlineRegex(/^\^/),parse:(e,t,n)=>{const o=n.lastFootnote.id+1,s={id:o,text:1===o?"*":""+o};return"*"===n.lastFootnote.text&&(n.lastFootnote.text=""+n.lastFootnote.id),n.lastFootnote=s,s},react:(e,t,n)=>_.createElement("sup",{key:n.key},e.text)},refStart:{order:P.default.defaultRules.escape.order+.2,match:function(e,t){const n=/^\{\{/.exec(e);if(n){let t=2,o=0;for(;t<e.length;){const n=e.slice(t,t+2);if("{{"===n)o++,t++;else if("}}"===n){if(!(o>0))break;o--,t++}t++}const s=e.slice(2,t);return[n[0],s]}return null},parse:(e,t,n)=>{if(!n.useRefs)return{ref:null,refContent:null};const o=n.lastRef+1;n.lastRef=o,n.currentRef.push(o);return{ref:o,refContent:t("(“"+e[1]+"”)\n\n",M.default.defaults({useRefs:!1},bg))}},react:(e,t,n)=>{if(null==e.ref)return null;const o=t(e.refContent,{});return _.createElement(gg,{ref:"start-ref-"+e.ref,key:"start-ref-"+e.ref,refContent:o})}},refEnd:{order:P.default.defaultRules.escape.order+.3,match:P.default.inlineRegex(/^\}\}/),parse:(e,t,n)=>{if(!n.useRefs)return{ref:null};return{ref:n.currentRef.pop()||null}},react:(e,t,n)=>null!=e.ref?_.createElement(vg,{ref:"end-ref-"+e.ref,key:"end-ref-"+e.ref}):null},squareLabel:{order:P.default.defaultRules.escape.order+.4,match:P.default.inlineRegex(/^\[\[(\w+)\]\]( *)/),parse:(e,t,n)=>(n.firstQuestionRef||(n.firstQuestionRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,n)=>[_.createElement("span",{key:"visual-square",className:"perseus-passage-square-label",style:hg,"aria-hidden":"true"},_.createElement("span",{style:fg},e.content)),_.createElement("span",{key:"alt-text",className:"perseus-sr-only"},S.$_("[Marker for question %(number)s]",{number:e.content})),e.space?" ":null]},circleLabel:{order:P.default.defaultRules.escape.order+.5,match:P.default.inlineRegex(/^\(\((\w+)\)\)( *)/),parse:(e,t,n)=>({content:e[1],space:e[2].length>0}),react:(e,t,n)=>[_.createElement("span",{key:"visual-circle",className:"perseus-passage-circle-label",style:hg,"aria-hidden":!0},_.createElement("span",{style:mg},e.content)),_.createElement("span",{key:"alt-text",className:"perseus-sr-only"},S.$_("[Circle marker %(number)s]",{number:e.content})),e.space?" ":null]},squareBracketRef:{order:P.default.defaultRules.escape.order+.6,match:P.default.inlineRegex(/^\[(\d+)\]( *)/),parse:(e,t,n)=>(n.firstSentenceRef||(n.firstSentenceRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,n)=>[_.createElement("span",{key:"visual-brackets",className:"perseus-passage-bracket-label","aria-hidden":"true"},"[",e.content,"]"),_.createElement("span",{key:"alt-text",className:"perseus-sr-only"},S.$_("[Sentence %(number)s]",{number:e.content})),e.space?" ":null]},highlight:{order:P.default.defaultRules.escape.order+.7,match:P.default.inlineRegex(/^{highlighting.start}(.+?){highlighting.end}/),parse:(e,t,n)=>({content:e[1]}),react:(e,t,n)=>[_.createElement("span",{key:0,className:"perseus-highlight"},e.content)]},reviewHighlight:{order:P.default.defaultRules.escape.order+.7,match:P.default.inlineRegex(/^{review-highlighting.start}(.+?){review-highlighting.end}/),parse:(e,t,n)=>({content:e[1]}),react:(e,t,n)=>[_.createElement("span",{key:0,className:"perseus-review-highlight"},e.content)]},strong:P.default.defaultRules.strong,u:P.default.defaultRules.u,em:P.default.defaultRules.em,del:P.default.defaultRules.del,text:{...P.default.defaultRules.text,react:(e,t,n)=>_.createElement("span",{key:n.key},e.content)}},bg={currentRef:[],useRefs:!0,lastRef:0,lastFootnote:{id:0,text:""}},xg=P.default.parserFor(yg);var wg={parse:(e,t)=>{t=t||{};return xg(e+"\n\n",M.default.extend(t,bg))},output:P.default.reactFor(P.default.ruleOutput(yg,"react")),START_REF_PREFIX:"start-ref-",END_REF_PREFIX:"end-ref-",_rulesForTesting:yg};class Cg extends _.Component{constructor(){super(...arguments),W(this,"_cachedLineHeight",void 0),W(this,"$body",void 0),W(this,"$end",void 0)}measureLineHeight(){return"number"!=typeof this._cachedLineHeight&&this.forceMeasureLineHeight(),this._cachedLineHeight}forceMeasureLineHeight(){var e;this.$body.text(" "),this._cachedLineHeight=(e=this.$body,this.$end.offset().top-e.offset().top),this.$body.text("")}render(){return _.createElement("div",{className:l.css(kg.measurer)},_.createElement("div",null,_.createElement("div",{ref:e=>this.$body=R.default(e),className:"paragraph"}),_.createElement("div",{ref:e=>this.$end=R.default(e)})))}}const kg=l.StyleSheet.create({measurer:{position:"absolute",width:"100%",top:0,left:0}});class Sg extends _.Component{constructor(){super(...arguments),W(this,"_onResize",void 0),W(this,"_lineHeightMeasurer",void 0),W(this,"_stylesAppiedTimer",void 0),W(this,"state",{nLines:null,startLineNumbersAfter:0,stylesAreApplied:!1}),W(this,"_handleSerializedHighlightsUpdate",(e=>{this.props.onChange({highlights:e})}))}componentDidMount(){this._updateState(),this._onResize=M.default.throttle((()=>{this.shouldRenderJipt()||(this._lineHeightMeasurer.forceMeasureLineHeight(),this._updateState())}),500),window.addEventListener("resize",this._onResize),this._stylesAppiedTimer=window.setTimeout((()=>{this.setState({stylesAreApplied:!0})}),0)}shouldComponentUpdate(e,t){return!M.default.isEqual(this.props,e)||!M.default.isEqual(this.state,t)}componentDidUpdate(){this._updateState()}componentWillUnmount(){window.removeEventListener("resize",this._onResize),clearTimeout(this._stylesAppiedTimer)}_updateState(){this.shouldRenderJipt()||this.setState({nLines:this._measureLines(),startLineNumbersAfter:this._getInitialLineNumber()})}_measureLines(){const e=R.default(N.default.findDOMNode(this.refs.content)).height(),t=this._getLineHeight();return Math.round(e/t)}_getInitialLineNumber(){let e=!0;return this.props.findWidgets(((t,n)=>"passage"===n.type&&(t===this.props.widgetId&&(e=!1),e))).map((e=>e.getLineCount())).reduce(((e,t)=>e+t),0)}_getLineHeight(){return this._lineHeightMeasurer.measureLineHeight()}getLineCount(){return null!=this.state.nLines?this.state.nLines:this._measureLines()}_getStartRefLineNumber(e){const t=wg.START_REF_PREFIX+e,n=this.refs[t];if(!n)return null;const o=R.default(N.default.findDOMNode(n));let s=o.next();0===s.length&&(s=o);const i=s.offset().top;return this.state.startLineNumbersAfter+1+this._convertPosToLineNumber(i)}_getEndRefLineNumber(e){const t=wg.END_REF_PREFIX+e,n=this.refs[t];if(!n)return null;const o=R.default(N.default.findDOMNode(n));let s=o.prev();0===s.length&&(s=o);const i=s.height(),r=s.offset().top;let a=this._convertPosToLineNumber(r+i);return 0===i&&(a+=1),this.state.startLineNumbersAfter+a}_convertPosToLineNumber(e){const t=e-R.default(N.default.findDOMNode(this.refs.content)).offset().top,n=this._getLineHeight();return Math.round(t/n)}_getRefContent(e){const t=wg.START_REF_PREFIX+e,n=this.refs[t];return n?n.getRefContent():null}getReference(e){const t=this._getStartRefLineNumber(e),n=this._getEndRefLineNumber(e);if(null==t||null==n)return null;return{startLine:t,endLine:n,content:this._getRefContent(e)}}getUserInput(){return null}simpleValidate(e){return Sg.validate(this.getUserInput(),e)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}_renderInstructions(e){const t=e.firstQuestionRef,n=e.firstSentenceRef;let o="";t&&(o+=S._("The symbol %(questionSymbol)s indicates that question %(questionNumber)s references this portion of the passage.",{questionSymbol:"[["+t+"]]",questionNumber:t})),n&&(o+=S._(" The symbol %(sentenceSymbol)s indicates that the following sentence is referenced in a question.",{sentenceSymbol:"["+n+"]"}));const s=wg.parse(o);return _.createElement("div",{className:"perseus-widget-passage-instructions"},wg.output(s))}shouldRenderJipt(){const{JIPT:e}=ne();return e.useJIPT&&-1!==this.props.passageText.indexOf("crwdns")}_renderContent(e){const t=this.state.stylesAreApplied,n=!this.props.reviewModeRubric;return _.createElement(pg,{editable:n,enabled:t,onSerializedHighlightsUpdate:this._handleSerializedHighlightsUpdate,serializedHighlights:this.props.highlights},_.createElement("div",{ref:"content"},_.createElement(Cg,{ref:e=>this._lineHeightMeasurer=e}),wg.output(e)))}_hasFootnotes(){const e=this.props.footnotes;return!/^\s*$/.test(e)}_renderFootnotes(){const e=this.props.footnotes,t=wg.parse(e);return wg.output(t)}render(){let e;const t=this.state.nLines;this.props.showLineNumbers&&t&&(e=M.default.range(1,t+1).map((e=>{const t=e+this.state.startLineNumbersAfter;if(4===t){const e=S._("Line ");return _.createElement("span",{key:"line-marker",className:"line-marker"},e)}return _.createElement("span",{key:e},t)})));const n={firstSentenceRef:null,firstQuestionRef:null},o=this.props.passageText.replace(/("{1})([^"]*)("{1})/g,"“$2”"),s=wg.parse(o,n),i=/\S/.test(this.props.passageTitle);return _.createElement("div",null,_.createElement("div",{className:"perseus-widget-passage-container"},this._renderInstructions(n),_.createElement("div",{className:"perseus-widget-passage"},i&&_.createElement("h3",{className:"passage-title"},_.createElement(Ai,{content:this.props.passageTitle,linterContext:this.props.linterContext})),e&&_.createElement("div",{className:"line-numbers","aria-hidden":!0},e),!i&&_.createElement("h3",{className:"perseus-sr-only"},S._("Beginning of reading passage.")),_.createElement("div",{className:"passage-text"},this.shouldRenderJipt()?_.createElement(Ai,{content:this.props.passageText}):this._renderContent(s)),this._hasFootnotes()&&[_.createElement("h4",{key:"footnote-start",className:"perseus-sr-only"},S._("Beginning of reading passage footnotes.")),_.createElement("div",{key:"footnotes",className:"footnotes"},this._renderFootnotes())],_.createElement("div",{className:"perseus-sr-only"},S._("End of reading passage.")))))}}W(Sg,"defaultProps",{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0,highlights:{},linterContext:Ht});var Eg={name:"passage",displayName:"Passage (SAT only)",widget:Sg,transform:e=>M.default.pick(e,"passageTitle","passageText","footnotes","showLineNumbers"),isLintable:!0};const{deepEq:_g}=Ae;I.default.oneOf(["bar","line","pic","histogram","dotplot"]),I.default.arrayOf(I.default.string),I.default.arrayOf(I.default.oneOfType([I.default.number,I.default.string])),I.default.number,I.default.number,I.default.number,I.default.number,I.default.number,I.default.string,I.default.arrayOf(I.default.number),I.default.number,I.default.arrayOf(I.default.number),I.default.bool;class Tg extends _.Component{constructor(){super(...arguments),W(this,"shouldSetupGraphie",void 0),W(this,"_isMounted",!1),W(this,"horizHairline",void 0),W(this,"hairlineRange",void 0),W(this,"graphie",void 0),W(this,"state",{values:this.props.starting||[1],categoryHeights:{}}),W(this,"DOT_PLOT_POINT_SIZE",(()=>this.props.apiOptions.isMobile?6:4)),W(this,"DOT_PLOT_POINT_PADDING",(()=>8)),W(this,"DOT_TICK_POINT_SIZE",(()=>2)),W(this,"setupGraphie",(e=>{const t=this;t.shouldSetupGraphie=!1;const n=N.default.findDOMNode(t.refs.graphieDiv);R.default(n).empty();const o=vn.createGraphie(n);t.graphie=o,t.graphie.pics=[],t.graphie.dotTicks=[];const s="bar"===t.props.type,i="line"===t.props.type,r="pic"===t.props.type,a="histogram"===t.props.type,l="dotplot"===t.props.type,c=r||l,p={},d=p,u=this.props.apiOptions.isMobile;d.graph={lines:[],bars:[],points:[],dividers:[]},d.scaleY=t.props.scaleY,d.dimX=t.props.categories.length;const h=u?[288,336]:t.props.plotDimensions;if(i)d.dimX+=u?-.2:1;else if(a)d.barPad=0,d.barWidth=1;else if(s)d.barPad=u?.08:.15,d.barWidth=1-2*d.barPad,d.dimX+=(u?-2:2)*d.barPad;else if(c){d.picBoxHeight=t.props.picBoxHeight,d.picBoxWidthPx=h[0]/t.props.categories.length;const e=h[0]-d.dimX*d.picBoxWidthPx;d.picPad=e/(2*d.dimX+2);const n=d.picBoxWidthPx+2*d.picPad;d.picPad=d.picPad/n,d.picBoxWidth=d.picBoxWidthPx/n,d.dimX+=2*d.picPad}l&&(d.picBoxHeight=2*this.DOT_PLOT_POINT_SIZE()+this.DOT_PLOT_POINT_PADDING()),d.dimY=Math.ceil(t.props.maxY/d.scaleY)*d.scaleY;let f=25;(s||i)&&u&&(f=0!==t.props.labels[1].length?17:11),l&&(f/=2),u&&c&&0===t.props.labels[1].length&&(f=0);let m=25,g=75;if(u&&(s||c)){const e=Math.max(0,...Object.values(t.state.categoryHeights));if(e){let t=25;c&&(t+=10),g=t+e}}if(d.scale=u?[(h[0]-4*f)/d.dimX,(h[1]-(m+g))/d.dimY]:M.default.map([d.dimX,d.dimY],(function(e,t){return h[t]/e})),c&&(d.scale[1]=d.picBoxHeight/d.scaleY),f/=d.scale[0],m/=d.scale[1],g/=d.scale[1],o.init({range:[[-3*f,d.dimX+f],[-g,d.dimY+m]],scale:d.scale,isMobile:this.props.apiOptions.isMobile}),o.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!c){for(let e=u?d.scaleY:0;e<=d.dimY;e+=d.scaleY)o.label([0,e],ae.roundToApprox(e,2),"left",!0),o.style({stroke:u?"#e9ebec":"#000",strokeWidth:1,opacity:u?1:.3},(function(){o.line([0,e],[d.dimX,e])}))}(s||i)&&u&&(t.graphie.dragPrompt=o.label([d.dimX/2,d.dimY/2],S._("Drag handles to make graph"),"center",!1).css("font-weight","bold").css("color",dn.KA_GREEN).css("display","none")),t.setupCategories(p),c&&u&&(t.graphie.dotPrompt=o.label([d.dimX/2,d.dimY/2],S._("Tap to add points"),"center",!1).css("font-weight","bold").css("color",dn.KA_GREEN).css("display","none")),c&&t.drawPicHeights(t.state.values,e.values),o.style({stroke:"#000",strokeWidth:2,opacity:1},(function(){c?l?o.style({stroke:u?dn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([u?0:.5,0],[d.dimX-(u?0:.5),0]))):(o.line([0,0],[d.dimX,0]),0===t.props.labels[1].length&&u||o.style({stroke:u?dn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([0,0],[0,d.dimY])))):(o.style({stroke:u?dn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([u?3*-f:0,0],[d.dimX+(u?f:0),0]))),(s||i)&&u||o.style({stroke:u?dn.GRAY_G:"#000",strokeWidth:u?1:2},(()=>o.line([0,0],[0,d.dimY]))))})),o.label([d.dimX/2,u?-g:-35/d.scale[1]],t.props.labels[0],u?"above":"below",!1).css("font-weight","bold").css("color",u&&dn.GRAY_F),o.label([(u?-35:-60)/d.scale[0],d.dimY/2],t.props.labels[1],"center",!1).css("font-weight","bold").css("color",u&&dn.GRAY_F).addClass("rotate"),this.props.apiOptions.isMobile&&(this.horizHairline=new _n(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:dn.INTERACTIVE}),this.horizHairline.hide(),this.hairlineRange=[[0,d.dimX],[0,d.dimY]])})),W(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.hairlineRange[0][0],e[1]],[this.hairlineRange[0][1],e[1]]),this.horizHairline.show())})),W(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&this.horizHairline.hide()})),W(this,"labelCategory",((e,t)=>{const n=this.props.apiOptions.isMobile,o=this.graphie;let s=!1;const i=(t+="").match(/^\$(.*)\$$/);i&&(t=i[1],s=!0);const r=Math.PI/180*45,a="translateX(-50%) translateX(".concat(5,"px) ")+"translateY(-50%) rotate(-".concat(45,"deg)"),l=n&&!i;return new Promise((i=>{o.style({color:n?dn.GRAY_G:"inherit",transform:l?a:"none",transformOrigin:"100%"},(()=>{const a=o.label([e,n?-.5:0],t,"below",s),c=14+(l?Math.round(a.height()*Math.cos(r)+(a.width()+5)*Math.sin(r)):a.height());i({category:t,height:c})}))}))})),W(this,"setupCategories",(e=>{const t=this,n=e,o=t.graphie,s=this.props.apiOptions.isMobile,i=[];"histogram"===t.props.type?(M.default.times(t.props.categories.length-1,(function(n){t.setupBar({index:n,startHeight:t.state.values[n],config:e,isHistogram:!0})})),M.default.each(t.props.categories,(function(e,r){const a=.5+r*n.barWidth;i.push(t.labelCategory(a,e));const l=6/n.scale[1];o.style({stroke:"#000",strokeWidth:s?1:2,opacity:1},(function(){o.line([a,-l],[a,0])}))}))):M.default.each(t.props.categories,(function(r,a){const l=t.state.values[a];let c;"bar"===t.props.type?c=t.setupBar({index:a,startHeight:l,config:e,isHistogram:!1}):"line"===t.props.type?c=t.setupLine(a,l,e):"pic"===t.props.type?c=t.setupPic(a,e):"dotplot"===t.props.type&&(c=t.setupDotplot(a,e));let p=0,d=-6/n.scale[1];"dotplot"!==t.props.type||s||(p=-d),"dotplot"===t.props.type?a%t.props.labelInterval!=0&&a!==t.props.categories.length-1||(i.push(t.labelCategory(c,r)),p*=1.5,d*=1.5):i.push(t.labelCategory(c,r)),o.style({stroke:s?dn.GRAY_G:"#000",strokeWidth:s?1:2,opacity:1},(function(){o.line([c,p],[c,d])}))})),Promise.all(i).then((e=>{if(t._isMounted){const n={};e.forEach((e=>{let{category:t,height:o}=e;return n[t]=o})),t.setState({categoryHeights:n})}}))})),W(this,"_clampValue",((e,t,n)=>Math.max(Math.min(e,n),t))),W(this,"_maybeShowDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="inline")})),W(this,"_maybeHideDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="none")})),W(this,"setupBar",(e=>{const t=this.props.apiOptions.isMobile,n=e.index,o=e.startHeight,s=e.config,i=e.isHistogram,r=this,a=r.graphie,l=s.barWidth/2;let c;c=i?.5+n*s.barWidth+l:(t?l:.5+s.barPad)+n;const p=function(e,n){const o=a.scalePoint(0);if(s.graph.bars[e].scale(1,Math.max(t?.2:.01,n/s.scaleY),o[0],o[1]),i){const t=s.graph.dividers[e-1],i=s.graph.dividers[e];if(t){const i=Math.min(r.state.values[e-1],n);t.scale(1,Math.max(.01,i/s.scaleY),o[0],o[1])}if(i){const t=Math.min(r.state.values[e+1],n);i.scale(1,Math.max(.01,t/s.scaleY),o[0],o[1])}}};if(a.style({stroke:"none",fill:t?dn.BLUE_C:dn.LIGHT_BLUE,opacity:1},(function(){s.graph.bars[n]=a.path([[c-l,0],[c-l,s.scaleY],[c+l,s.scaleY],[c+l,0],[c-l,0]])})),i&&n>0&&a.style({stroke:"#000",strokeWidth:1,opacity:.3},(function(){s.graph.dividers.push(a.path([[c-l,0],[c-l,s.scaleY]]))})),t){const e=s.scaleY/r.props.snapsPerLine;s.graph.lines[n]=ls.addMaybeMobileMovablePoint(this,{coord:[c,o],constraints:[(t,n,o)=>[c,this._clampValue(Math.round(t[1]/e)*e,0,s.dimY)]],onMoveStart:function(){s.graph.bars[n].attr({fill:dn.INTERACTIVE})},onMove:function(){const e=s.graph.lines[n].coord()[1],t=M.default.clone(r.state.values);t[n]=e,r.setState({values:t}),r.changeAndTrack({values:t}),r._maybeHideDragPrompt(),p(n,e)},onMoveEnd:function(){s.graph.bars[n].attr({fill:dn.BLUE_C})}}),s.graph.lines[n].state.visibleShape.wrapper.style.zIndex="1",r._maybeShowDragPrompt()}else s.graph.lines[n]=a.addMovableLineSegment({coordA:[c-l,o],coordZ:[c+l,o],snapY:s.scaleY/r.props.snapsPerLine,constraints:{constrainX:!0},normalStyle:{stroke:dn.INTERACTIVE,"stroke-width":this.props.static?0:4}}),s.graph.lines[n].onMove=function(e,t){let o=this.coordA[1];(o<0||o>s.dimY)&&(o=Math.min(Math.max(o,0),s.dimY),this.coordA[1]=this.coordZ[1]=o,this.transform());const i=M.default.clone(r.state.values);i[n]=o,r.setState({values:i}),r.changeAndTrack({values:i}),p(n,o)};return p(n,o),c})),W(this,"setupLine",((e,t,n)=>{const o=this.props.apiOptions.isMobile,s=this,i=n,r=s.graphie,a=e+(o?.4:1);if(o){const o=n.scaleY/s.props.snapsPerLine;i.graph.points[e]=ls.addMaybeMobileMovablePoint(this,{coord:[a,t],constraints:[(e,t,s)=>[a,this._clampValue(Math.round(e[1]/o)*o,0,n.dimY)]],onMove:function(){const t=i.graph.points[e].coord()[1],n=M.default.clone(s.state.values);n[e]=t,s.setState({values:n}),s.changeAndTrack({values:n}),s._maybeHideDragPrompt()}}),s._maybeShowDragPrompt(),e>0&&(i.graph.lines[e]=ls.addMovableLine(r,{points:[i.graph.points[e-1],i.graph.points[e]],constraints:ls.MovablePoint.constraints.fixed(),normalStyle:{stroke:dn.BLUE_C,"stroke-width":2},highlightStyle:{stroke:dn.BLUE_C,"stroke-width":2}}))}else i.graph.points[e]=r.addMovablePoint({coord:[a,t],constraints:{constrainX:!0},normalStyle:{fill:dn.INTERACTIVE,stroke:dn.INTERACTIVE},snapY:i.scaleY/s.props.snapsPerLine}),i.graph.points[e].onMove=function(t,n){n=Math.min(Math.max(n,0),i.dimY);const o=M.default.clone(s.state.values);return o[e]=n,s.setState({values:o}),s.changeAndTrack({values:o}),[t,n]},e>0&&(i.graph.lines[e]=r.addMovableLineSegment({pointA:i.graph.points[e-1],pointZ:i.graph.points[e],constraints:{fixed:!0},normalStyle:{stroke:"#9ab8ed","stroke-width":2}}));return a})),W(this,"setupDotplot",((e,t)=>{const n=this.graphie,o=this.props.apiOptions.isMobile;return this.setupTiledPlot(e,o?.5:1,t,((e,t)=>n.ellipse([e,t],[this.DOT_PLOT_POINT_SIZE()/n.scale[0],this.DOT_PLOT_POINT_SIZE()/n.scale[1]],{fill:dn.INTERACTIVE,stroke:dn.INTERACTIVE})))})),W(this,"setupPic",((e,t)=>{const n=this.graphie;return this.setupTiledPlot(e,0,t,((e,t)=>{const o=n.scalePoint([e,t]),s=this.props.picSize;return n.raphael.image(this.props.picUrl,o[0]-s/2,o[1]-s/2,s,s)}))})),W(this,"setupTiledPlot",((e,t,n,o)=>{const s=this,i=n,r=s.graphie,a=r.pics,l=r.dotTicks,c=e+.5+i.picPad;r.mouselayer.canvas.style.touchAction="none",a[e]=[],l[e]=[];const p=Math.round(i.dimY/i.scaleY)+1;return M.default(p).times((function(n){const p=((n-=1)+.5)*i.scaleY,d=c-i.picBoxWidth/2,u=p+.5*i.scaleY,h=r.scalePoint([d,u+t]),f=r.mouselayer.rect(h[0],h[1],i.picBoxWidthPx,i.picBoxHeight);R.default(f[0]).css({fill:"#000",opacity:0,cursor:"pointer"}).on("vmousedown",(function(n){n.preventDefault(),s.whichPicClicked=e,s.setPicHeight(e,u),R.default(document).on("vmouseup.plotTile",(function(e){R.default(document).unbind(".plotTile")})),R.default(document).on("vmousemove.plotTile",(function(e){e.preventDefault();const n=r.getMouseCoord(e)[1],o=Math.floor(n-t),a=(Math.max(-1,Math.floor(o/i.scaleY))+.5)*i.scaleY,l=Math.min(a+.5*i.scaleY,i.dimY);s.setPicHeight(s.whichPicClicked,l)}))})),n<0||(a[e][n]=o(c,p+t),l[e][n]=r.ellipse([c,p+t],[s.DOT_TICK_POINT_SIZE()/r.scale[0],s.DOT_TICK_POINT_SIZE()/r.scale[1]],{fill:"#dee1e3",stroke:"#dee1e3"}))})),c})),W(this,"setPicHeight",((e,t)=>{const n=M.default.clone(this.state.values);n[e]=t,this.drawPicHeights(n,this.state.values),this.setState({values:n}),this.changeAndTrack({values:n})})),W(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),W(this,"drawPicHeights",((e,t)=>{const n=this,o=n.graphie,s=o.pics,i=this.props.apiOptions.isMobile;if(i){const t=e.every((e=>0===e));o.dotPrompt[0].style.display=t?"inline":"none"}M.default.each(s,(function(s,r){M.default.each(s,(function(s,a){const l=(a+1)*n.props.scaleY,c=l<=e[r];if("dotplot"===n.props.type){const e=l<=t[r];c&&!e&&s.animate({"stroke-width":8},75,(()=>s.animate({"stroke-width":2},75)))}R.default(s[0]).css({display:c?"inline":"none"}),o.dotTicks[r][a][0].style.display=c||!i?"none":"inline"}))}))})),W(this,"getUserInput",(()=>this.state.values)),W(this,"simpleValidate",(e=>Tg.validate(this.getUserInput(),e)))}render(){const e={marginBottom:this.props.labels[0]?75:0};return _.createElement("div",{className:"perseus-widget-plotter graphie "+$t.INTERACTIVE,ref:"graphieDiv",style:e})}componentDidUpdate(e,t){this.shouldSetupGraphie=this.shouldSetupGraphie||!M.default.isEqual(this.state.categoryHeights,t.categoryHeights),this.shouldSetupGraphie&&this.setupGraphie(t)}componentDidMount(){this._isMounted=!0,this.setupGraphie(this.state)}UNSAFE_componentWillReceiveProps(e){this.shouldSetupGraphie=M.default.any(["type","labels","categories","scaleY","maxY","snapsPerLine","picUrl","labelInterval","static"],(function(t){return!M.default.isEqual(this.props[t],e[t])}),this),M.default.isEqual(this.props.starting,e.starting)||M.default.isEqual(this.state.values,e.starting)||(this.shouldSetupGraphie=!0,this.setState({values:e.starting}))}componentWillUnmount(){this._isMounted=!1}}W(Tg,"propTypes",{onChange:I.default.func.isRequired,trackInteraction:I.default.func.isRequired}),W(Tg,"defaultProps",{type:"bar",labels:["",""],categories:[""],scaleY:1,maxY:10,snapsPerLine:2,picSize:40,picBoxHeight:48,picUrl:"",plotDimensions:[380,300],labelInterval:1}),M.default.extend(Tg,{validate:function(e,t){return _g(e,t.starting)?{type:"invalid",message:null}:{type:"points",earned:_g(e,t.correct)?1:0,total:1,message:null}}});const Mg=M.default.identity;var Ig={name:"plotter",displayName:"Plotter",widget:Tg,staticTransform:Mg};class Pg extends _.Component{constructor(){super(...arguments),W(this,"arrowLength",100),W(this,"drawArrow",(()=>{const e=this.refs["arrowCanvas"+this.props.index],t=e.getContext("2d");t.clearRect(0,0,e.width,e.height);const n=new Path2D;t.strokeStyle="rgb(0,0,0)",t.lineWidth=1.2,t.lineCap="round";n.moveTo(5,e.height/2),n.lineTo(e.width-5,e.height/2),n.moveTo(e.width-10,e.height/2-5),n.lineTo(e.width-5,e.height/2),n.moveTo(e.width-10,e.height/2+5),n.lineTo(e.width-5,e.height/2),t.stroke(n)}))}componentDidMount(){this.drawArrow()}componentDidUpdate(){this.drawArrow()}render(){return _.createElement("div",{className:"arrow-container"},_.createElement("div",{className:"above-text"},this.props.data.topText),_.createElement("canvas",{height:"30",id:"arrowCanvas"+this.props.index,ref:"arrowCanvas"+this.props.index,width:this.arrowLength},S._("Reaction arrow pointing to the right.")),_.createElement("div",{className:"below-text"},this.props.data.bottomText))}}W(Pg,"propTypes",{data:I.default.any,index:I.default.number});class Ng extends _.Component{constructor(){super(...arguments),W(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),W(this,"getUserInput",(()=>[])),W(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null}))),W(this,"focus",(()=>!0))}render(){return _.createElement("div",{className:"reaction",ref:"reaction"},this.props.smiles.map(((e,t)=>{const n=this.props.widgetId+"-"+t;return _.createElement("div",{key:n,className:"molecule-container"},_.createElement(wm,{id:n,rotationAngle:this.props.rotationAngle[t],smiles:e}),t===this.props.smiles.length-1?null:_.createElement(Pg,{data:this.props.separators[t],index:t}))})))}}W(Ng,"propTypes",{rotationAngle:I.default.arrayOf(I.default.number),separators:I.default.arrayOf(I.default.object),smiles:I.default.arrayOf(I.default.string),widgetId:I.default.string}),W(Ng,"defaultProps",{smiles:[],rotationAngle:[],separators:[]});var Ag={name:"reaction-diagram",displayName:"Chemical reaction",hidden:!0,widget:Ng};class Rg extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"state",{visible:1}),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"_handleInteraction",(e=>{const t=parseInt(e.split(" ")[1]);if(t===this.state.visible-1){const e=this.refs.renderer.getWidgetInstance("group "+t);e.showRationalesForCurrentlySelectedChoices();const n=e.simpleValidate();"points"===n.type&&n.total===n.earned&&(this.setState({visible:this.state.visible+1}),this.props.trackInteraction({visible:this.state.visible+1}))}}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){const e=_.createElement(G,U({},bo,{style:{color:"green"}})),t=M.default.chain(this.props.json).first(this.state.visible).map(((e,t)=>"[[".concat(Ae.snowman," group ").concat(t,"]]"))).join("\n\n").value(),n={};return M.default.each(this.props.json,((t,o)=>{const s="group ".concat(o);n[s]={type:"group",graded:!0,version:{major:0,minor:0},options:M.default.extend({},t,{icon:o<this.state.visible-1?e:null})}})),_.createElement("div",{className:"perseus-sequence"},_.createElement(Ai,{ref:"renderer",content:t,widgets:n,onInteractWithWidget:this._handleInteraction,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext}))}}W(Rg,"propTypes",{...pr,apiOptions:Yt.propTypes,json:I.default.arrayOf(I.default.shape({content:I.default.string,images:I.default.objectOf(I.default.any),widgets:I.default.objectOf(I.default.any)})),trackInteraction:I.default.func.isRequired,linterContext:qt}),W(Rg,"defaultProps",{json:[{content:"",widgets:{},images:{}}],linterContext:Ht});var Fg={name:"sequence",displayName:"Graded Sequence",widget:Rg,traverseChildWidgets:function(e,t){let n=e.json;M.default.isArray(n)||(n=[n]);const o=M.default.map(n,(e=>t(e)));return M.default.extend({},e,{json:o})},tracking:"all",hidden:!0,isLintable:!0};const Og="#aaa",Dg="#ccc",Lg="#fff",Bg={borderBottom:"9px solid transparent",borderTop:"9px solid transparent",content:'" "',height:"0",position:"absolute",top:"0",width:"0"},zg=l.StyleSheet.create({infoTip:{display:"inline-block",marginLeft:"5px",position:"relative"},infoTipContainer:{position:"absolute",top:"-12px",left:"22px",zIndex:1e3},infoTipTriangle:{height:"10px",left:"0",position:"absolute",top:"8px",width:"0",zIndex:1,":before":{...Bg,borderRight:"9px solid #bbb",right:"0"},":after":{...Bg,borderRight:"9px solid ".concat(Lg),right:"-1px"}},verticalShadow:{border:"1px solid ".concat(Dg),boxShadow:"0 1px 3px ".concat(Dg),borderBottom:"1px solid ".concat(Og)},infoTipContentContainer:{background:Lg,padding:"5px 10px",width:"240px"}});class qg extends _.Component{constructor(){super(...arguments),W(this,"state",{hover:!1}),W(this,"handleMouseEnter",(()=>{this.setState({hover:!0})})),W(this,"handleMouseLeave",(()=>{this.setState({hover:!1})}))}render(){return _.createElement("div",{className:l.css(zg.infoTip)},_.createElement("img",{alt:"",width:10,height:10,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo2N2M3NTAxYS04YmVlLTQ0M2MtYmRiNS04OGM2N2IxN2NhYzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUJCRTk4Qjc4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUJCRTk4QjY4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NGE5ZDI0OTMtODk1NC00OGFkLTlhMTgtZDAwM2MwYWNjNDJlIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjY3Yzc1MDFhLThiZWUtNDQzYy1iZGI1LTg4YzY3YjE3Y2FjMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pqm89uYAAADMSURBVHjaXJA9DoJAEIUH1M4TUHIFsCMGen9OwCGw1YRGW2ntKel0exsojHIBC0ouQAyUviFDstmXfNmZeS+zm7XSNCXRFiRgJf0bXIHixpbhGdxBBJYC1w/xaA424MhNEATkui71fU9KqfEU78UbD9PdbJRlOdae55GmhIP+1NV1TcMwkOM41DSNHvRtMhTHMRVFQW3b6mOLgx99kue5GRp/gIOZuZGvNpTNwjD8oliANU+qqqKu6/TQBdymN57AHjzBT+B6Jx79BRgAvc49kQA4yxgAAAAASUVORK5CYII=",onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave}),_.createElement("div",{className:l.css(zg.infoTipContainer),style:{display:this.state.hover?"block":"none"}},_.createElement("div",{className:l.css(zg.infoTipTriangle)}),_.createElement("div",{className:l.css(zg.verticalShadow,zg.infoTipContentContainer)},this.props.children)))}}class Hg extends _.Component{constructor(){super(...arguments),W(this,"state",{didMount:!1})}componentDidMount(){this.setState({didMount:!0})}render(){return this.state.didMount?_.createElement(qg,this.props):_.createElement("div",null)}}const{assert:Wg}=an,{Path:Ug,Arc:Gg,Circle:Vg,Label:jg,Line:Yg,MovablePoint:$g,MovableLine:Xg}=Es;class Kg extends _.Component{constructor(){super(...arguments),W(this,"_renderThresholdLine",(()=>{const e=[0,this._range()[1][1]],t=M.default.map(e,(e=>[this.state.threshold,e]));return _.createElement(Xg,{onMove:this.handleMouseInteraction},M.default.map(t,((e,t)=>_.createElement($g,{key:t,static:!0,coord:e,normalStyle:{stroke:"none",fill:"none"}}))))})),W(this,"_renderCircle",(()=>{const e=this.props.data,t=M.default.reduce(e,((e,t)=>e+t),0),n=M.default.reduce(e,((e,t,n)=>null!=this.state.threshold&&n<=this.state.threshold?e+t:e),0),o=n/t,s=1e-5,i=[this.props.box[0]-30,30],r=this._range()[0],a=Math.min(Math.max(this.state.threshold,r[0]),r[1]).toFixed(2);return[o>0&&(()=>{const e={key:"below",center:i,radius:20,startAngle:0,endAngle:o<1?360*o:359.99999,sector:1!==o,unscaled:!0,style:{fill:dn.LIGHT_RED,stroke:dn.RED}};return _.createElement(Gg,e)})(),o<1&&(()=>{const e={key:"above",center:i,radius:20,startAngle:o>0?360*o:s,endAngle:360,sector:0!==o,unscaled:!0,style:{fill:dn.LIGHT_BLUE,stroke:dn.BLUE}};return _.createElement(Gg,e)})(),(()=>{const e={key:"label",coord:[i[0],i[1]+30],text:n+" of "+t+" results below "+a+"%",direction:"center",tex:!1,unscaled:!0,style:{fontSize:"12px"}};return _.createElement(jg,e)})()]})),W(this,"_renderData",(()=>{const e=this.props.data;this._range();return M.default.map(e,((e,t)=>{if(!e)return;const n=null!=this.state.threshold&&t<=this.state.threshold,o={fill:n?dn.LIGHT_RED:dn.LIGHT_BLUE,stroke:n?dn.RED:dn.BLUE},s=[[t,0],[t,e],[t+1,e],[t+1,0]];return _.createElement(Ug,{key:t,coords:s,style:o})}))})),W(this,"_setupGraphie",((e,t)=>{const n=t.data,o=t.range,s=t.scale,i=o[0][1]-o[0][0],r=o[1][1]-0,a=Math.ceil(r/20);if(M.default.each(M.default.range(0,o[1][1],a),(t=>{n&&e.label([o[0][0],t],ae.roundToApprox(t,2),"left",!0),e.line([o[0][0],t],[o[0][1],t],{stroke:"#000",strokeWidth:1,opacity:.3})})),n){const t=15,n=Math.ceil(i/t);M.default.each(M.default.range(o[0][0],o[0][1],n),(t=>{e.label([t,0],d.number.round(t,2),"below",!0);e.line([t,0],[t,-8/s[1]],{stroke:"#000",strokeWidth:1})}))}const l=[o[0][0],0],c=[o[0][0],o[1][1]];e.line(l,c,{stroke:"#000",strokeWidth:2,opacity:1});const p=o[0][0]+i/2,u=n?25:0;e.label([p,-u/s[1]],t.xAxisLabel,"below",!1).css("font-weight","bold");const h=0+r/2,f=n?55:28;e.label([o[0][0]-f/s[0],h],t.yAxisLabel,"center",!1).css("font-weight","bold").css("-webkit-transform","rotate(-90deg)")})),W(this,"handleMouseInteraction",(e=>{this.setState({threshold:e[0]})})),W(this,"_range",(e=>(e=e||this.props).data?this._getRangeForData(e.data):[[0,100],[-1,10]])),W(this,"_getRangeForData",(e=>{const t=M.default.indexOf(e,M.default.find(e,(e=>e>0))),n=Math.max(0,t-10),o=M.default.lastIndexOf(e,M.default.last(M.default.filter(e,(e=>e>0))));return[[n,Math.min(101,o+1+10)],[-1,M.default.max(e)]]})),W(this,"_getInitialThreshold",(e=>{const t=e[0];return t[0]+(t[1]-t[0])/3})),W(this,"state",{threshold:this._getInitialThreshold(this._range())})}UNSAFE_componentWillReceiveProps(e){const t=this._range(),n=this._range(e);Ae.deepEq(t,n)||this.setState({threshold:this._getInitialThreshold(n)})}render(){const e=this.props.data,t=this._range(),n={xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,box:this.props.box,range:t,data:e,scale:[Ae.scaleFromExtent(t[0],this.props.box[0]),Ae.scaleFromExtent(t[1],this.props.box[1])]},o=[t[0][0],0],s=[t[0][1],0];return _.createElement(Es,{box:n.box,range:n.range,options:n,setup:this._setupGraphie,onMouseMove:this.handleMouseInteraction,onMouseDown:this.handleMouseInteraction,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable},_.createElement(Yg,{start:o,end:s,style:{stroke:"#000",strokeWidth:1,opacity:1}}),e&&this._renderData(),e&&this._renderCircle(),e&&this._renderThresholdLine())}}W(Kg,"propTypes",{data:I.default.arrayOf(I.default.number),xAxisLabel:I.default.string,yAxisLabel:I.default.string,box:I.default.arrayOf(I.default.number)}),W(Kg,"defaultProps",{data:null,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",box:[400,400]});class Zg extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"generateNumber",void 0),W(this,"state",{invalidInput:!1}),W(this,"calculateDisplayProportion",(()=>{const e=this.props.userProportion;return"percentage"===this.props.proportionOrPercentage?Math.round(100*e):e})),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"checkProportionValidity",(e=>e>=0&&"proportion"===this.props.proportionOrPercentage&&e<=1||"percentage"===this.props.proportionOrPercentage&&e<=100)),W(this,"handleUserProportionChange",((e,t)=>{let n;n="percentage"===this.props.proportionOrPercentage?e/100:e,null!=n&&(n=Math.min(1,Math.max(0,n))),this.props.onChange({userProportion:n},t)})),W(this,"handleSampleSizeChange",((e,t)=>{null!=e&&(e=Math.min(1e3,Math.max(0,Math.floor(e)))),this.props.onChange({sampleSize:e},t)})),W(this,"handleRunSimulation",(()=>{null!=this.props.numTrials&&null!=this.props.userProportion&&null!=this.props.sampleSize?(this.setState({invalidInput:!1}),this.props.onChange({data:this.generateData()}),this.props.trackInteraction()):this.setState({invalidInput:!0})})),W(this,"generateData",(e=>((e,t,n)=>{const o=()=>this.generateNumber()<n,s=M.default.times(101,(()=>0));return M.default.times(t,(()=>{const t=M.default.times(e,o),n=M.default.filter(t,M.default.identity).length,i=Math.floor(100*n/e);s[i]++})),s})((e=e||this.props).sampleSize,e.numTrials,e.userProportion))),W(this,"getInputPaths",(()=>[["userProportion"],["sampleSize"]])),W(this,"focus",(()=>{const e=M.default.head(this.getInputPaths());return this.focusInputPath(e),!0})),W(this,"focusInputPath",(e=>{Wg(e.length>0);const t=M.default.head(e);this.refs[t].focus()})),W(this,"blurInputPath",(e=>{Wg(e.length>0);const t=M.default.head(e);this.refs[t].blur()})),W(this,"getDOMNodeForPath",(e=>{Wg(e.length>0);const t=M.default.head(e);return N.default.findDOMNode(this.refs[t])})),W(this,"getGrammarTypeForPath",(e=>(Wg(e.length>0),"number"))),W(this,"setInputValue",((e,t,n)=>{Wg(e.length>0);const o=M.default.head(e);this["handle"+(o.charAt(0).toUpperCase()+o.slice(1))+"Change"](t,n)})),W(this,"getUserInput",(()=>null)),W(this,"simpleValidate",(e=>Zg.validate(this.getUserInput(),e)))}UNSAFE_componentWillMount(){null!=this.props.randomSeed&&(this.generateNumber=Ae.seededRNG(this.props.randomSeed))}UNSAFE_componentWillReceiveProps(e){e.randomSeed!==this.props.randomSeed&&(this.generateNumber=Ae.seededRNG(e.randomSeed))}render(){const e={marginLeft:"5px"},t="0px 0px 0px 2px rgba(255, 165, 0, 1)",n=M.default.extend({},e,{WebkitBoxShadow:t,MozBoxShadow:t,boxShadow:t,transition:"all 0.15s"}),o=M.default.extend({},e,{transition:"all 0.15s"}),s=this.state.invalidInput?n:o,i=this.props.apiOptions.staticRender?Xi:Af,r=_.createElement("div",null,_.createElement(i,{ref:"userProportion",style:s,value:this.calculateDisplayProportion(),checkValidity:this.checkProportionValidity,disabled:this.props.apiOptions.readOnly,onChange:this.handleUserProportionChange,onFocus:()=>this.props.onFocus(["userProportion"]),onBlur:()=>this.props.onBlur(["userProportion"])}),_.createElement(Hg,null,_.createElement("p",null,S._("This controls the proportion or percentage that will be used in your simulation.")))),a=_.createElement("div",null,_.createElement(i,{ref:"sampleSize",style:s,value:this.props.sampleSize,checkValidity:e=>e>=0,disabled:this.props.apiOptions.readOnly,onChange:this.handleSampleSizeChange,onFocus:()=>this.props.onFocus(["sampleSize"]),onBlur:()=>this.props.onBlur(["sampleSize"])}),_.createElement(Hg,null,_.createElement("p",null,S._("This controls the sample size that will be used in your simulation. For example, if you set this to 100, then for each trial, responses from 100 participants will be simulated.")))),l=_.createElement("div",{style:{textAlign:"right"}},_.createElement("b",null,this.props.numTrials),_.createElement(Hg,null,_.createElement("p",null,S._("This is the number of trials used in the simulation. For example, if set to 50, then the survey will be conducted 50 times.")))),c=[{title:this.props.proportionLabel+":",value:r},{title:S._("Sample size:"),value:a},{title:S._("Number of trials:"),value:l}],p=_.createElement("button",{className:"simple-button",style:{margin:"20px 0"},disabled:this.props.apiOptions.readOnly,onClick:this.handleRunSimulation},S._("Run simulation")),d={paddingBottom:this.props.data?40:0},u=_.createElement("div",{style:d},_.createElement(Kg,{data:this.props.data,xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}));return _.createElement("div",null,(e=>{const t=_.createElement("thead",null,_.createElement("tr",null,_.createElement("th",null,S._("Parameter")),_.createElement("th",null,S._("Value")))),n=_.createElement("tbody",null,M.default.map(e,((e,t)=>_.createElement("tr",{key:t},_.createElement("td",null,e.title),_.createElement("td",null,e.value)))));return _.createElement("table",null,t,n)})(c),p,u)}}W(Zg,"propTypes",{...pr,apiOptions:Yt.propTypes,data:I.default.arrayOf(I.default.number),numTrials:I.default.number,proportionLabel:I.default.string,proportionOrPercentage:I.default.string,randomSeed:I.default.number,sampleSize:I.default.number,trackInteraction:I.default.func.isRequired,userProportion:I.default.number,xAxisLabel:I.default.string,yAxisLabel:I.default.string}),W(Zg,"defaultProps",{data:null,userProportion:null,sampleSize:null,numTrials:null,randomSeed:0,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion",apiOptions:Yt.defaults}),M.default.extend(Zg,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var Jg={name:"simulator",displayName:"Simulator",widget:Zg,transform:e=>{const t=M.default.clone(e);return t.randomSeed=e.problemNum,t},hidden:!0};const{shuffle:Qg}=Ae;class ev extends _.Component{constructor(){super(...arguments),W(this,"_isMounted",void 0),W(this,"state",{changed:!1}),W(this,"handleChange",(e=>{this._isMounted&&this.setState({changed:!0},(()=>{setTimeout((()=>{this.props.onChange(e),this.props.trackInteraction()}),0)}))})),W(this,"getUserInput",(()=>({options:this.refs.sortable.getOptions()}))),W(this,"moveOptionToIndex",((e,t)=>{this.refs.sortable.moveOptionToIndex(e,t)})),W(this,"simpleValidate",(e=>this.state.changed?ev.validate(this.getUserInput(),e):{type:"invalid",message:null}))}static validate(e,t){return{type:"points",earned:M.default.isEqual(e.options,t.correct)?1:0,total:1,message:null}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1}render(){const e=Qg(this.props.correct,this.props.problemNum,!0),{apiOptions:t}=this.props,n=t.isMobile?8:5;return _.createElement("div",{className:"perseus-widget-sorter perseus-clearfix"},_.createElement(wf,{options:e,layout:this.props.layout,margin:n,padding:this.props.padding,onChange:this.handleChange,linterContext:this.props.linterContext,ref:"sortable"}))}}W(ev,"propTypes",{apiOptions:Yt.propTypes,correct:I.default.array,layout:I.default.oneOf(["horizontal","vertical"]),onChange:I.default.func,padding:I.default.bool,problemNum:I.default.number,trackInteraction:I.default.func.isRequired,linterContext:qt}),W(ev,"defaultProps",{correct:[],layout:"horizontal",padding:!0,problemNum:0,onChange:function(){},linterContext:Ht});var tv={name:"sorter",displayName:"Sorter",widget:ev,isLintable:!0};const{assert:nv}=an,ov=function(e,t){return[""+e,""+t]},sv=function(e){return nv(M.default.isArray(e)&&2===e.length),+e[0]},iv=function(e){return nv(M.default.isArray(e)&&2===e.length),+e[1]},rv=function(e){return"answer"+sv(e)+","+iv(e)};class av extends _.Component{constructor(){super(...arguments),W(this,"_getRows",(()=>this.props.answers.length)),W(this,"_getColumns",(()=>this.props.answers[0].length)),W(this,"getUserInput",(()=>M.default.map(this.props.answers,M.default.clone))),W(this,"onValueChange",((e,t,n)=>{const o=M.default.map(this.props.answers,M.default.clone);o[e][t]=n.target?n.target.value:n,this.props.onChange({answers:o}),this.props.trackInteraction()})),W(this,"onHeaderChange",((e,t)=>{const n=this.props.headers.slice();n[e]=t.content,this.props.onChange({headers:n})})),W(this,"simpleValidate",(e=>av.validate(this.getUserInput(),e))),W(this,"_handleFocus",(e=>{this.props.onFocus(e)})),W(this,"_handleBlur",(e=>{this.props.onBlur(e)})),W(this,"focus",(()=>(this.focusInputPath(ov(0,0)),!0))),W(this,"focusInputPath",(e=>{const t=rv(e),n=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?n.focus():N.default.findDOMNode(n).focus()})),W(this,"blurInputPath",(e=>{const t=rv(e),n=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?n.blur():N.default.findDOMNode(n).blur()})),W(this,"getDOMNodeForPath",(e=>{const t=rv(e);return N.default.findDOMNode(this.refs[t])})),W(this,"getInputPaths",(()=>{const e=this._getRows(),t=this._getColumns(),n=[];return M.default(e).times((e=>{M.default(t).times((t=>{const o=ov(e,t);n.push(o)}))})),n})),W(this,"getGrammarTypeForPath",(e=>"number")),W(this,"setInputValue",((e,t,n)=>{const o=sv(e),s=iv(e),i=M.default.map(this.props.answers,M.default.clone);i[o][s]=t,this.props.onChange({answers:i},n)}))}render(){const e=this._getRows(),t=this._getColumns(),n=this.props.headers;let o,s;const i={};return this.props.apiOptions.customKeypad?(o=yr,s={width:80},i.keypadElement=this.props.keypadElement):this.props.apiOptions.staticRender?(o=Xi,s={}):(o="input",s={}),_.createElement("table",{className:"perseus-widget-table-of-values non-markdown"},_.createElement("thead",null,_.createElement("tr",null,M.default.map(n,((e,t)=>this.props.editableHeaders?_.createElement("th",{key:t},_.createElement(this.props.Editor,{ref:"columnHeader"+t,apiOptions:this.props.apiOptions,content:e,widgetEnabled:!1,onChange:M.default.partial(this.onHeaderChange,t)})):_.createElement("th",{key:t},_.createElement(Ai,{content:e,linterContext:this.props.linterContext})))))),_.createElement("tbody",null,M.default(e).times((e=>_.createElement("tr",{key:e},M.default(t).times((t=>_.createElement("td",{key:t},_.createElement(o,U({ref:rv(ov(e,t)),type:"text",value:this.props.answers[e][t],disabled:this.props.apiOptions.readOnly,onFocus:M.default.partial(this._handleFocus,ov(e,t)),onBlur:M.default.partial(this._handleBlur,ov(e,t)),onChange:M.default.partial(this.onValueChange,e,t),style:s},i))))))))))}}W(av,"propTypes",{answers:I.default.arrayOf(I.default.arrayOf(I.default.string)),editableHeaders:I.default.bool,Editor:I.default.func,headers:I.default.arrayOf(I.default.string),keypadElement:t.keypadElementPropType,trackInteraction:I.default.func.isRequired,linterContext:qt}),W(av,"defaultProps",function(){const e=M.default(4).times((function(){return Ae.stringArrayOfSize(1)}));return{apiOptions:Yt.defaults,headers:[""],editableHeaders:!1,rows:4,columns:1,answers:e,linterContext:Ht}}()),M.default.extend(av,{validate:function(e,t){const n=function(e){return M.default.filter(e,(function(e){return M.default.some(e,M.default.identity)}))},o=n(t.answers),s=n(e);if(M.default.some(s,(function(e){return M.default.some(e,(function(e){return""===e}))}))||!s.length)return{type:"invalid",message:null};if(s.length!==o.length)return{type:"points",earned:0,total:1,message:null};const i=pe.number.createValidatorFunctional;let r=null;return{type:"points",earned:M.default.every(o,(function(e){let t;for(t=0;t<s.length;t++){const n=s[t],o=M.default.every(n,(function(t,n){const o=e[n],s=i(o,{simplify:!0})(t);return s.message&&(r=s.message),s.correct}));if(o)return s.splice(t,1),!0}return!1}))?1:0,total:1,message:r}}});var lv={name:"table",displayName:"Table of values",accessible:!0,widget:av,transform:e=>{const t=e.answers.length,n=e.answers[0].length,o=M.default(t).times((function(){return Ae.stringArrayOfSize(n)}));return M.default.extend({},e,{answers:o})},hidden:!0,isLintable:!0};const{deepEq:cv,getGridStep:pv,captureScratchpadTouchStart:dv}=Ae,{assert:uv}=an,hv={url:null};const fv={apiOptions:Yt.defaults,gradeEmpty:!1,graphMode:"interactive",listMode:"dynamic",graph:{},tools:{translation:{enabled:!0,required:!1,constraints:{}},rotation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[1,6]},reflection:{enabled:!0,required:!1,constraints:{fixed:!1},coords:[[2,-4],[2,2]]},dilation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[6,6]}},drawSolutionShape:!0,starting:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]},correct:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]}};function mv(e){return e.constraints.fixed?dn.DYNAMIC:dn.INTERACTIVE}function gv(e){return String(ae.roundTo(9,e))}function vv(e){const{TeX:t}=ne();return[_.createElement(t,{key:"("},"("),gv(e[0]),_.createElement(t,{key:","},", {}"),gv(e[1]),_.createElement(t,{key:")"},")")]}function yv(e){const{TeX:t}=ne();return[_.createElement(t,{key:"<"},S.doNotTranslate("\\langle")),gv(e[0]),_.createElement(t,{key:","},", {}"),gv(e[1]),_.createElement(t,{key:">"},S.doNotTranslate("\\rangle"))]}function bv(e,t){return e=M.default.clone(e).sort(d.point.compare),t=M.default.clone(t).sort(d.point.compare),M.default.all(M.default.map(e,(function(e,n){const o=t[n];return d.point.equal(e,o)})))}const xv=e=>e.customKeypad?yr:e.staticRender?Xi:Af,wv={apply:function(e){return Cv[e.type].isValid(e)?Cv[e.type].apply(e):M.default.identity},append:function(e,t){const n=wv._appendAndCollapseLastTwo(e,t);return wv._collapseFinalNoOps(n)},_collapseFinalNoOps:function(e){return e.length&&wv.isNoOp(M.default.last(e))?M.default.initial(e):e},_appendAndCollapseLastTwo:function(e,t){if(!e.length)return[t];const n=wv.collapse(M.default.last(e),t);return M.default.initial(e).concat(n)},isNoOp:function(e){return Cv[e.type].isNoOp(e)},collapse:function(e,t){return e.type!==t.type?[e,t]:wv.isEmpty(e)&&wv.isEmpty(t)?[]:wv.isValid(e)&&wv.isValid(t)?wv._collapseValidMonotypedTransforms(e,t):[e,t]},isValid:function(e){return Cv[e.type].isValid(e)},isEmpty:function(e){return Cv[e.type].isEmpty(e)},_collapseValidMonotypedTransforms:function(e,t){let n=Cv[e.type].collapse(e,t);return n?(M.default.isArray(n)||(n=[n]),M.default.each(n,(function(t){t.type=e.type})),n):[e,t]},toTeX:function(e){return Cv[e.type].toTeX(e)},ListItem:F.default({displayName:"ListItem",render:function(){if("dynamic"===this.props.mode)return _.createElement("div",null,wv.toTeX(this.props.transform));if("interactive"===this.props.mode){const e=Cv[this.props.transform.type].Input;return _.createElement(e,U({ref:"transform",onChange:this.handleChange,onFocus:this.props.onFocus,onBlur:this.props.onBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions},this.props.transform))}throw new re("Invalid mode: "+this.props.mode,se.InvalidInput)},value:function(){return"interactive"===this.props.mode?M.default.extend({type:this.props.transform.type},this.refs.transform.value()):this.props.transform},handleChange:M.default.debounce((function(e){this.props.onChange(this.value(),e)}),300),_getComponentAtPath:function(e){const t=this.refs.transform,n=M.default.head(e);return t.refs[n]},focus:function(){const e=this.refs.transform,t=M.default.head(e.getInputPaths());t&&this.focusInputPath(t)},focusInputPath:function(e){this._getComponentAtPath(e).focus()},blurInputPath:function(e){this._getComponentAtPath(e).blur()},getDOMNodeForPath:function(e){return N.default.findDOMNode(this._getComponentAtPath(e))},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,n){t.length&&(t=parseFloat(t),isNaN(t))||this.refs.transform.setInputValue(e,t,n)},getInputPaths:function(){return"dynamic"===this.props.mode?[]:this.refs.transform.getInputPaths()}})},Cv={translation:{verbName:S._("Translate"),nounName:S._("Translation"),lowerNounName:S._("translation"),apply:function(e){return function(t){return d.vector.add(t,e.vector)}},isValid:function(e){return M.default.isFinite(e.vector[0])&&M.default.isFinite(e.vector[1])},isEmpty:function(e){return null===e.vector[0]&&null===e.vector[1]},isNoOp:function(e){return d.vector.equal(e.vector,[0,0])},collapse:function(e,t){return{vector:d.vector.add(e.vector,t.vector)}},toTeX:function(e){return S.$_("Translation by %(vector)s",{vector:yv(e.vector)})},Input:class extends _.Component{constructor(){super(...arguments),W(this,"state",{vector:this.props.vector||[null,null]}),W(this,"value",(()=>({vector:[this.refs.x.getValue(),this.refs.y.getValue()]}))),W(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e),s=M.default.clone(this.state.vector);"x"===o?s[0]=t:"y"===o&&(s[1]=t),this.setState({vector:s},(()=>{this.props.onChange(n)}))})),W(this,"getInputPaths",(()=>[["x"],["y"]]))}componentDidUpdate(e){cv(this.props,e)||this.setState({vector:this.props.vector})}render(){const e=xv(this.props.apiOptions),{TeX:t}=ne(),n=[_.createElement(t,{key:"<"},S.doNotTranslate("\\langle")),_.createElement(e,{key:"vec_x",ref:"x",placeholder:0,value:this.state.vector[0],useArrowKeys:!0,onChange:e=>{const t=this.state.vector[1];this.setState({vector:[e,t]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"x"),onBlur:M.default.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"vec_y",ref:"y",placeholder:0,value:this.state.vector[1],useArrowKeys:!0,onChange:e=>{const t=this.state.vector[0];this.setState({vector:[t,e]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"y"),onBlur:M.default.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:">"},S.doNotTranslate("\\rangle"))];return _.createElement("div",null,S.$_("Translation by %(vector)s",{vector:n}))}}},rotation:{verbName:S._("Rotate"),nounName:S._("Rotation"),lowerNounName:S._("rotation"),apply:function(e){return function(t){return d.point.rotateDeg(t,e.angleDeg,e.center)}},isValid:function(e){return M.default.isFinite(e.angleDeg)&&M.default.isFinite(e.center[0])&&M.default.isFinite(e.center[1])},isEmpty:function(e){return null===e.angleDeg&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return d.number.equal(e.angleDeg,0)},collapse:function(e,t){return!!d.point.equal(e.center,t.center)&&{center:e.center,angleDeg:e.angleDeg+t.angleDeg}},toTeX:function(e){return S.$_("Rotation by %(degrees)s about %(point)s",{degrees:(t=e.angleDeg,gv(t)+"°"),point:vv(e.center)});var t},Input:class extends _.Component{constructor(){super(...arguments),W(this,"state",{center:this.props.center||[null,null],angleDeg:this.props.angleDeg||null}),W(this,"value",(()=>({angleDeg:this.refs.angleDeg.getValue(),center:[this.refs.centerX.getValue(),this.refs.centerY.getValue()]}))),W(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e);let s=M.default.clone(this.state.angleDeg);const i=M.default.clone(this.state.center);"angleDeg"===o?s=t:"centerX"===o?i[0]=t:"centerY"===o&&(i[1]=t),this.setState({angleDeg:s,center:i},(()=>{this.props.onChange(n)}))})),W(this,"getInputPaths",(()=>[["centerX"],["centerY"],["angleDeg"]]))}componentDidUpdate(e){cv(this.props,e)||this.setState({center:this.props.center,angleDeg:this.props.angleDeg})}render(){const e=xv(this.props.apiOptions),{TeX:t}=ne(),n=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"X",ref:"centerX",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{const t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"centerX"),onBlur:M.default.partial(this.props.onBlur,"centerX"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"Y",ref:"centerY",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{const t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"centerY"),onBlur:M.default.partial(this.props.onBlur,"centerY"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")],o=[_.createElement(e,{key:"deg",ref:"angleDeg",placeholder:0,value:this.state.angleDeg,useArrowKeys:!0,onChange:e=>{this.setState({angleDeg:e},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"angleDeg"),onBlur:M.default.partial(this.props.onBlur,"angleDeg"),keypadElement:this.props.keypadElement}),"°"],s=S.$_("Rotation about %(point)s by %(degrees)s",{point:n,degrees:o});return _.createElement("div",null,s)}}},reflection:{verbName:S._("Reflect"),nounName:S._("Reflection"),lowerNounName:S._("reflection"),apply:function(e){return function(t){return d.point.reflectOverLine(t,e.line)}},isValid:function(e){return M.default.all(M.default.flatten(e.line),M.default.isFinite)&&!d.point.equal(e.line[0],e.line[1])},isEmpty:function(e){return M.default.all(M.default.flatten(e.line),M.default.isNull)},isNoOp:function(e){return!1},collapse:function(e,t){return!!d.line.equal(e.line,t.line)&&[]},toTeX:function(e){const t=e.line[0],n=e.line[1];return S.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:vv(t),point2:vv(n)})},Input:class extends _.Component{constructor(){super(...arguments),W(this,"state",{line:this.props.line||[[null,null],[null,null]]}),W(this,"changePoint",((e,t,n,o)=>{const s=M.default.map(this.state.line,M.default.clone);s[e][t]=n,this.setState({line:s},(()=>{this.props.onChange(o)}))})),W(this,"value",(()=>({line:[[this.refs.x1.getValue(),this.refs.y1.getValue()],[this.refs.x2.getValue(),this.refs.y2.getValue()]]}))),W(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e);let s,i;"x"===o[0]?s=0:"y"===o[0]&&(s=1),"1"===o[1]?i=0:"2"===o[1]&&(i=1),this.changePoint(i,s,t,n)})),W(this,"getInputPaths",(()=>[["x1"],["y1"],["x2"],["y2"]]))}componentDidUpdate(e){cv(this.props,e)||this.setState({line:this.props.line})}render(){const e=xv(this.props.apiOptions),{TeX:t}=ne(),n=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"x1",ref:"x1",value:this.state.line[0][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,0),onFocus:M.default.partial(this.props.onFocus,"x1"),onBlur:M.default.partial(this.props.onBlur,"x1"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"y1",ref:"y1",value:this.state.line[0][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,1),onFocus:M.default.partial(this.props.onFocus,"y1"),onBlur:M.default.partial(this.props.onBlur,"y1"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")],o=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"x2",ref:"x2",value:this.state.line[1][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,0),onFocus:M.default.partial(this.props.onFocus,"x2"),onBlur:M.default.partial(this.props.onBlur,"x2"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"y2",ref:"y2",value:this.state.line[1][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,1),onFocus:M.default.partial(this.props.onFocus,"y2"),onBlur:M.default.partial(this.props.onBlur,"y2"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")];return _.createElement("div",null,S.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:n,point2:o}))}}},dilation:{verbName:S._("Dilate"),nounName:S._("Dilation"),lowerNounName:S._("dilation"),apply:function(e){return function(t){return function(e,t,n){const o=d.vector.subtract(e,t),s=d.vector.scale(o,n);return d.vector.add(t,s)}(t,e.center,e.scale)}},isValid:function(e){return M.default.isFinite(e.scale)&&M.default.isFinite(e.center[0])&&M.default.isFinite(e.center[1])},isEmpty:function(e){return null===e.scale&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return d.number.equal(e.scale,1)},collapse:function(e,t){return!!d.point.equal(e.center,t.center)&&{center:e.center,scale:e.scale*t.scale}},toTeX:function(e){const t=function(e){const t=ae.toFraction(e,d.number.DEFAULT_TOLERANCE);return 1===t[1]?gv(e):gv(t[0])+"/"+gv(t[1])}(e.scale);return S.$_("Dilation of scale %(scale)s about %(point)s",{scale:t,point:vv(e.center)})},Input:class extends _.Component{constructor(){super(...arguments),W(this,"state",{center:this.props.center||[null,null],scale:this.props.scale||null}),W(this,"value",(()=>({scale:this.refs.scale.getValue(),center:[this.refs.x.getValue(),this.refs.y.getValue()]}))),W(this,"setInputValue",((e,t,n)=>{const o=M.default.first(e);let s=this.state.scale;const i=M.default.clone(this.state.center);"x"===o?i[0]=t:"y"===o?i[1]=t:"scale"===o&&(s=t),this.setState({scale:s,center:i},(()=>{this.props.onChange(n)}))})),W(this,"getInputPaths",(()=>[["x"],["y"],["scale"]]))}componentDidUpdate(e){cv(this.props,e)||this.setState({center:this.props.center,scale:this.props.scale})}render(){const e=xv(this.props.apiOptions),{TeX:t}=ne(),n=[_.createElement(t,{key:"("},"("),_.createElement(e,{key:"point_x",ref:"x",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{const t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"x"),onBlur:M.default.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:","},", {}"),_.createElement(e,{key:"point_y",ref:"y",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{const t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"y"),onBlur:M.default.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),_.createElement(t,{key:")"},")")],o=_.createElement(e,{ref:"scale",placeholder:1,value:this.state.scale,useArrowKeys:!0,onChange:e=>{this.setState({scale:e},(()=>{this.props.onChange()}))},onFocus:M.default.partial(this.props.onFocus,"scale"),onBlur:M.default.partial(this.props.onBlur,"scale"),keypadElement:this.props.keypadElement});return _.createElement("div",null,S.$_("Dilation about %(point)s by %(scale)s",{point:n,scale:o}))}}}},kv={getPointCountForType:function(e){const t=e.split("-");return"polygon"===t[0]?t[1]||3:"line"===t[0]||"lineSegment"===t[0]?2:"angle"===t[0]?3:"circle"===t[0]?2:"point"===t[0]?1:void 0},addMovableShape:function(e,t){if(t.editable&&t.translatable)throw new re("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously. options: "+JSON.stringify(t),se.InvalidInput);const n=M.default.map(t.shape.coords,(function(s){let i=!1,r=s;const a=e.addMovablePoint({coord:s,normalStyle:t.normalPointStyle,highlightStyle:t.highlightPointStyle,constraints:{fixed:!t.translatable&&!t.editable},visible:t.showPoints,snapX:t.snap&&t.snap[0]||0,snapY:t.snap&&t.snap[1]||0,bounded:!1,onMove:function(e,s){i||(r=a.coord,i=!0);let l=d.vector.subtract([e,s],a.coord);t.onMove&&(l=t.onMove(l[0],l[1])),t.translatable&&M.default.each(n,(function(e){e!==a&&e.setCoord(d.vector.add(e.coord,l))}));const c=a.coord,p=d.vector.add(a.coord,l);return a.coord=p,o.update(),a.coord=c,p},onMoveEnd:function(){if(t.onMoveEnd&&i){i=!1;const e=d.vector.subtract(a.coord,r);t.onMoveEnd(e[0],e[1])}o.update()}});return a.bounded=!0,a})),o=kv.addShape(e,t,n),s=o.remove;return o.remove=function(){s.apply(o),M.default.invoke(n,"remove")},o},addShape:function(e,t,n){n=n||t.shape.coords;const o=kv._typesOf(t.shape),s=t.shape.options||kv.defaultOptions(o),i=kv._mapTypes(o,n,(function(n,o,i){const r=M.default.extend({},t,s[i]);return kv._addType(e,n,o,r)})),r=M.default.filter(M.default.pluck(i,"update"),M.default.identity),a=M.default.filter(M.default.pluck(i,"remove"),M.default.identity),l=function(){return M.default.map(i,(function(e){return e.getOptions?e.getOptions():{}}))};return{type:o,points:n,update:function(){M.default.invoke(r,"call")},remove:function(){M.default.invoke(a,"call")},toJSON:function(){const e=M.default.map(n,(function(e){return M.default.isArray(e)?e:e.coord}));return{type:o,coords:e,options:l()}},getOptions:l}},equal:function(e,t){const n=kv._typesOf(e),o=kv._typesOf(t);if(n.length!==o.length)return!1;const s=kv._mapTypes(n,e.coords,kv._combine),i=kv._mapTypes(o,t.coords,kv._combine);return M.default.all(M.default.map(s,(function(e,t){const n=i[t];return e.type===n.type&&kv._forType(e.type).equal(e.coords,n.coords)})))},_typesOf:function(e){let t=e.type;return M.default.isArray(t)||(t=[t]),M.default.map(t,(function(e){return"polygon"===e?"polygon-3":e}))},defaultOptions:function(e){return M.default.map(e,(function(e){const t=kv._forType(e).defaultOptions;return M.default.extend({},t)}))},_forType:function(e){const t=e.split("-")[0];return kv[t]},_mapTypes:function(e,t,n,o){return M.default.map(e,(function(e,s){const i=kv.getPointCountForType(e),r=M.default.first(t,i);return t=M.default.rest(t,i),n.call(o,e,r,s)}))},_addType:function(e,t,n,o){const s=M.default.isArray(n[0])?{coordA:n[0],coordZ:n[1]}:{pointA:n[0],pointZ:n[1]};if("polygon"===(t=t.split("-")[0])){const t=e.addMovablePolygon(M.default.extend({},o,{fixed:!o.editable,snapX:o.snap&&o.snap[0]||0,snapY:o.snap&&o.snap[1]||0,points:n,constrainToGraph:!1}));return{update:t.transform.bind(t),remove:t.remove.bind(t)}}if("line"===t||"lineSegment"===t){const n=e.addMovableLineSegment(M.default.extend({},o,s,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:"line"===t}));return{update:n.transform.bind(n,!0),remove:n.remove.bind(n)}}if("angle"===t){const t=!!o.editable&&null,s=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:n,normalStyle:o.normalStyle,reflex:o.reflex});return M.default.isArray(n[0])||o.editable||(n[0].remove(),n[2].remove()),{update:s.update.bind(s,t),remove:s.remove.bind(s),getOptions:function(){return{reflex:s.isReflex()}}}}if("circle"===t){let t={remove:M.default.identity};const s=function(){const s=n[0].coord||n[0],i=n[1].coord||n[1],r=d.point.distanceToPoint(s,i);t.remove(),t=e.circle(s,r,M.default.extend({stroke:dn.DYNAMIC,"stroke-width":2},o.normalStyle))};return s(),n[1].remove&&!o.editable&&n[1].remove(),{update:s,remove:function(){t.remove()}}}if("point"===t)return{update:null,remove:null};throw new re("Invalid shape type "+t,se.InvalidInput)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:bv},line:{equal:d.line.equal},lineSegment:{equal:bv},angle:{equal:function(e,t){if(!d.point.equal(e[1],t[1]))return!1;const n=[e[1],e[0]],o=[e[1],e[2]],s=[t[1],t[0]],i=[t[1],t[2]],r=d.ray.equal(n,s)&&d.ray.equal(o,i),a=d.ray.equal(n,i)&&d.ray.equal(o,s);return r||a},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){const n=d.point.distanceToPoint(e[0],e[1]),o=d.point.distanceToPoint(t[0],t[1]);return d.point.equal(e[0],t[0])&&d.number.equal(n,o)}},point:{equal:d.point.equal}},Sv=wv.ListItem;class Ev extends _.Component{constructor(){super(...arguments),W(this,"_transformationRefs",(()=>M.default.times(this.props.transformations.length,(e=>this.refs["transformation"+e])))),W(this,"value",(()=>M.default.invoke(this._transformationRefs(),"value"))),W(this,"handleChange",((e,t)=>{this.props.onChange(this.value(),t)})),W(this,"focusLast",(()=>{const e=this._transformationRefs();0!==e.length&&M.default.last(e).focus()}))}render(){if("static"===this.props.mode)return _.createElement("span",null);const e=M.default.map(this.props.transformations,(function(e,t){return _.createElement(Sv,{ref:"transformation"+t,key:"transformation"+t,transform:e,mode:this.props.mode,onChange:this.handleChange,onFocus:M.default.partial(this.props.onFocus,""+t),onBlur:M.default.partial(this.props.onBlur,""+t),keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions})}),this);return _.createElement("div",{className:"perseus-transformation-list"},e)}}class _v extends _.Component{render(){const e=this.props.toggled?"simple-button exercise-orange toggled highlighted-tool-button":"simple-button";return _.createElement("button",{type:"button",className:e,disabled:this.props.disabled,onClick:this.props.onClick,onTouchStart:dv},this.props.children)}}class Tv extends _.Component{constructor(){super(...arguments),W(this,"state",{selected:null}),W(this,"changeSelected",(e=>{this.props.removeTool(this.state.selected),e&&e!==this.state.selected?(this.props.addTool(e),this.setState({selected:e})):this.setState({selected:null})}))}render(){const e=M.default.map(Cv,(function(e,t){if(this.props.enabled[t])return _.createElement(_v,{key:t,disabled:this.props.apiOptions.readOnly,toggled:this.state.selected===t,onClick:this.changeSelected.bind(this,t)},e.verbName)}),this);return _.createElement("div",{className:"transformer-tools-bar"},_.createElement("span",{className:"simple-button-group"},e),_.createElement("button",{className:"transformer-undo-button simple-button",type:"button",disabled:this.props.apiOptions.readOnly,onClick:this.props.onUndoClick,onTouchStart:dv},_.createElement(G,Eo)," "+S._("Undo")),_.createElement("div",{className:"clear"}))}}class Mv extends _.Component{constructor(){super(...arguments),W(this,"changeSelected",(e=>{e&&this.props.addTool(e)}))}render(){const e=M.default.map(Cv,(function(e,t){if(this.props.enabled[t])return _.createElement(_v,{key:t,toggled:!1,disabled:this.props.apiOptions.readOnly,onClick:this.changeSelected.bind(this,t)},_.createElement(G,xo)," ",e.nounName)}),this);return _.createElement("div",{className:"transformer-tools-bar"},e,_.createElement("button",{className:"transformer-undo-button simple-button",type:"button",onClick:this.props.onUndoClick,disabled:this.props.apiOptions.readOnly,onTouchStart:dv},_.createElement(G,Eo)," "+S._("Undo")),_.createElement("div",{className:"clear"}))}}class Iv extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"tools",void 0),W(this,"currentTool",void 0),W(this,"transformations",void 0),W(this,"shape",void 0),W(this,"dilationCircle",void 0),W(this,"rotatePoint",void 0),W(this,"rotateHandle",void 0),W(this,"shouldSetupGraphie",((e,t)=>!cv(t.starting,e.starting)||(t.graphMode!==e.graphMode||(t.listMode!==e.listMode||(t.drawSolutionShape!==e.drawSolutionShape||(!(!e.drawSolutionShape||cv(t.correct.shape,e.correct.shape))||!cv(this.tools,e.tools))))))),W(this,"graphie",(()=>this.refs.graph.graphie())),W(this,"setupGraphie",(e=>{this.props.drawSolutionShape&&this.props.correct.shape&&this.props.correct.shape.coords&&kv.addShape(e,{fixed:!0,shape:this.props.correct.shape,normalStyle:{stroke:dn.GRAY,"stroke-dasharray":"","stroke-width":2}}),this.currentTool=null,this.refs.toolsBar.changeSelected(null),this.addTransformerShape(this.props.starting.shape,!1),this.setTransformations(this.props.transformations),this.tools={translation:M.default.clone(this.props.tools.translation),rotation:M.default.clone(this.props.tools.rotation),reflection:M.default.clone(this.props.tools.reflection),dilation:M.default.clone(this.props.tools.dilation)}})),W(this,"setTransformations",(e=>{this.resetCoords(),this.transformations=M.default.clone(e),M.default.each(this.transformations,this.applyTransform)})),W(this,"addTransformerShape",((e,t)=>{const n=this,o=this.graphie();this.shape=kv.addMovableShape(o,{shape:e,editable:!1,showPoints:"static"!==this.props.graphMode,translatable:t,onMove:function(e,t){return e=ae.roundToNearest(o.snap[0],e),t=ae.roundToNearest(o.snap[1],t),n.addTransform({type:"translation",vector:[e,t]}),[e,t]},normalPointStyle:{fill:t?dn.INTERACTIVE:dn.DYNAMIC,stroke:t?dn.INTERACTIVE:dn.DYNAMIC},highlightPointStyle:{fill:dn.INTERACTING,stroke:dn.INTERACTING}})})),W(this,"addTool",(e=>{const t=this;if("interactive"===this.props.graphMode)if("translation"===e)this.currentTool=this.addTranslationTool();else if("rotation"===e)this.currentTool=this.addRotationTool();else if("reflection"===e)this.currentTool=this.addReflectionTool();else{if("dilation"!==e)throw new re("Invalid tool id: "+e,se.InvalidInput);this.currentTool=this.addDilationTool()}else{let n;if("translation"===e)n={type:"translation",vector:[null,null]};else if("rotation"===e)n={type:"rotation",center:[null,null],angleDeg:null};else if("reflection"===e)n={type:"reflection",line:[[null,null],[null,null]]};else{if("dilation"!==e)throw new re("Invalid tool id: "+e,se.InvalidInput);n={type:"dilation",center:[null,null],scale:null}}this.doTransform(n,(function(){t.refs.transformationList.focusLast()}))}})),W(this,"removeTool",(e=>{this.currentTool&&this.currentTool.remove(),this.currentTool=null})),W(this,"addTranslationTool",(()=>{var e,t;const n=this;return null===(e=this.shape)||void 0===e||e.remove(),this.addTransformerShape(null===(t=this.shape)||void 0===t?void 0:t.toJSON(),!0),{remove:function(){var e,t;null===(e=n.shape)||void 0===e||e.remove(),n.addTransformerShape(null===(t=n.shape)||void 0===t?void 0:t.toJSON(),!1)}}})),W(this,"snapCoord",(e=>{const t=this.graphie();return M.default.map(e,(function(e,n){return ae.roundToNearest(t.snap[n],e)}))})),W(this,"normalizeReflectionCoords",(e=>{const t=this.snapCoord(d.line.midpoint(e)),n=d.vector.polarDegFromCart(d.vector.subtract(e[0],e[1])),o=d.vector.cartFromPolarDeg(1,ae.roundToNearest(45,n[1]));return M.default.map([-1,1],(function(e){const n=d.vector.add(t,d.vector.scale(o,e*this.scaleToCurrentRange(2)));return this.snapCoord(n)}),this)})),W(this,"addReflectionTool",(()=>{const e=this.props.tools.reflection;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),o=function(){t.changeTool("reflection",{coords:M.default.pluck(i,"coord")})},s=this.normalizeReflectionCoords(e.coords),i=M.default.map(s,(function(e){return n.addMovablePoint({coord:e,visible:!1})}),this);let r;const a=mv(e);n.style({},(function(){r=n.addMovableLineSegment({fixed:e.constraints.fixed,constraints:e.constraints,pointA:i[0],pointZ:i[1],snapX:n.snap[0],snapY:n.snap[1],extendLine:!0,normalStyle:{stroke:a,"stroke-width":2,"stroke-dasharray":"- "},highlightStyle:{stroke:dn.INTERACTING,"stroke-width":2,"stroke-dasharray":"- "},movePointsWithLine:!0,onMoveEnd:o})}));const l=n.addReflectButton({fixed:e.constraints.fixed,line:r,size:this.scaleToCurrentRange(1),onClick:function(){t.doTransform({type:"reflection",line:M.default.pluck(i,"coord")}),c&&(c.setCoord(d.vector.add(l.coord,d.vector.subtract(l.coord,c.coord))),c.update())},normalStyle:{stroke:a,"stroke-width":2,fill:a},highlightStyle:{stroke:dn.INTERACTING,"stroke-width":3,fill:dn.INTERACTING},onMoveEnd:o});let c=null;if(!e.constraints.fixed){const e=d.vector.polarDegFromCart(d.vector.subtract(i[1].coord,i[0].coord))[1]+90;c=n.addRotateHandle({center:l,radius:this.scaleToCurrentRange(2),angleDeg:e,width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),lengthAngle:17,onMove:function(e){return ae.roundToNearest(45,e)},onMoveEnd:o})}return R.default(r).on("move",(function(){l.update(),R.default(l).trigger("move")})),c&&R.default(c).on("move",(function(){const e=t.snapCoord(c.coord),n=d.vector.subtract(e,l.coord),o=l.isFlipped()?1:0;i[o].setCoord(d.vector.add(l.coord,d.vector.rotateDeg(n,90))),i[1-o].setCoord(d.vector.add(l.coord,d.vector.rotateDeg(n,-90))),r.transform(!0),l.update()})),{remove:function(){l.remove(),c&&c.remove(),r.remove(),i[0].remove(),i[1].remove()}}})),W(this,"scaleToCurrentRange",(e=>function(e,t){const n=t[0][1]-t[0][0],o=t[1][1]-t[1][0];return e*Math.max(n,o)/20}(e,this.refs.graph.props.range))),W(this,"addRotationTool",(()=>{const e=this.props.tools.rotation;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),o=mv(e);return this.rotatePoint=n.addMovablePoint({constraints:e.constraints,coord:e.coord,snapX:n.snap[0],snapY:n.snap[1],normalStyle:{"stroke-dasharray":"",stroke:o,fill:o},highlightStyle:{"stroke-dasharray":"",stroke:dn.INTERACTING,fill:dn.INTERACTING}}),this.rotateHandle=n.addRotateHandle({center:this.rotatePoint,radius:this.scaleToCurrentRange(1.5),width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),onMove:function(e,n){const o=t.getRotationTransformFromAngle(t.rotatePoint.coord,e-n);return t.doTransform(o),n+o.angleDeg}}),this.rotatePoint.onMoveEnd=(e,n)=>{t.changeTool("rotation",{coord:[e,n]})},{remove:function(){var e,n;null===(e=t.rotateHandle)||void 0===e||e.remove(),null===(n=t.rotatePoint)||void 0===n||n.remove()}}})),W(this,"addDilationTool",(()=>{const e=this.props.tools.dilation;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),o=mv(e);t.dilationCircle=n.addCircleGraph({centerConstraints:e.constraints,center:e.coord,radius:t.scaleToCurrentRange(2),snapX:n.snap[0],snapY:n.snap[1],minRadius:t.scaleToCurrentRange(1),snapRadius:t.scaleToCurrentRange(.5),onResize:function(e,n){t.doTransform({type:"dilation",center:t.dilationCircle.centerPoint.coord,scale:e/n})},circleNormalStyle:{stroke:o,"stroke-width":2,"stroke-dasharray":"- ","fill-opacity":0},circleHighlightStyle:{stroke:dn.INTERACTING,"stroke-width":2,"stroke-dasharray":"",fill:dn.INTERACTING,"fill-opacity":.05},centerNormalStyle:{stroke:o,fill:o,"stroke-width":2,"stroke-dasharray":""},centerHighlightStyle:{stroke:o,fill:o,"stroke-width":2,"stroke-dasharray":""}});const s=this.dilationCircle.centerPoint.onMoveEnd;return this.dilationCircle.centerPoint.onMoveEnd=function(){if(s){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];s(n)}t.changeTool("dilation",{coord:t.dilationCircle.centerPoint.coord})},{remove:function(){var e;null===(e=t.dilationCircle)||void 0===e||e.remove()}}})),W(this,"getRotationTransformFromAngle",((e,t)=>{(t=(t+360)%360)>180&&(t-=360);return{type:"rotation",center:e,angleDeg:15*Math.round(t/15)}})),W(this,"doTransform",((e,t)=>{this.applyTransform(e),this.addTransform(e,t)})),W(this,"applyTransform",(e=>{if("static"!==this.props.graphMode){const t=wv.apply(e);this.applyCoordTransformation(t)}})),W(this,"applyCoordTransformation",(e=>{var t;M.default.each(this.shape.points,(function(t){const n=e(t.coord);t.setCoord(n)})),null===(t=this.shape)||void 0===t||t.update()})),W(this,"resetCoords",(()=>{var e;const t=this.props.starting.shape.coords;M.default.each(this.shape.points,(function(e,n){e.setCoord(t[n])})),null===(e=this.shape)||void 0===e||e.update()})),W(this,"handleUndoClick",(()=>{this.refs.toolsBar.changeSelected(null),this.props.transformations.length&&this.props.onChange({transformations:M.default.initial(this.props.transformations)})})),W(this,"setTransformationProps",((e,t)=>{this.props.onChange({transformations:e},t)})),W(this,"addTransform",((e,t)=>{this.transformations=wv.append(this.transformations,e),this.props.onChange({transformations:M.default.clone(this.transformations)},t)})),W(this,"changeTool",((e,t)=>{const n=M.default.clone(this.props.tools);n[e]=M.default.extend({},this.props.tools[e],t),this.tools[e]=M.default.clone(n[e]),this.props.onChange({tools:n}),this.props.trackInteraction()})),W(this,"simpleValidate",(e=>Iv.validate(this.getUserInput(),e))),W(this,"getCoords",(()=>{const e=this.props.starting.shape.coords,t=this.props.transformations;return M.default.reduce(t,(function(e,t){return M.default.map(e,wv.apply(t))}),e)})),W(this,"getEditorJSON",(()=>{const e=M.default.pick(this.props,"grading","starting","graphMode","listMode","tools","drawSolutionShape","gradeEmpty");return e.graph=this.refs.graph.toJSON(),e.version=1.2,e.answer=this.getUserInput(),e})),W(this,"getUserInput",(()=>{var e;return{transformations:this.props.transformations,shape:{type:this.shape.type,coords:this.getCoords(),options:null===(e=this.shape)||void 0===e?void 0:e.getOptions()}}})),W(this,"_handleFocus",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];e.props.onFocus(n)})),W(this,"_handleBlur",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];e.props.onBlur(n)})),W(this,"_getTransformationForID",(e=>{const t=["transformationList","transformation"+e];let n=this;return M.default.each(t,(e=>{n=n.refs[e]})),n})),W(this,"getInputPaths",(()=>{if("static"===this.props.listMode)return[];let e=[];return M.default.each(this.props.transformations,((t,n)=>{const o=this._getTransformationForID(n).getInputPaths(),s=M.default.map(o,(e=>[""+n].concat(e)));e=e.concat(s)})),e})),W(this,"_passToInner",(function(e,t){if(!t||!t.length)return;const n=M.default.rest(t),o=M.default.head(t),s=this._getTransformationForID(o);for(var i=arguments.length,r=new Array(i>2?i-2:0),a=2;a<i;a++)r[a-2]=arguments[a];return s[e](n,...r)})),W(this,"focus",(()=>{const e=this.getInputPaths();return e.length>0&&(this.focusInputPath(e[0]),!0)})),W(this,"focusInputPath",(e=>0!==e.length&&(uv(e.length>=2),this._passToInner("focusInputPath",e)))),W(this,"blurInputPath",(e=>0!==e.length&&(uv(e.length>=2),this._passToInner("blurInputPath",e)))),W(this,"setInputValue",((e,t,n)=>(uv(e.length>=2),this._passToInner("setInputValue",e,t,n)))),W(this,"getDOMNodeForPath",(e=>(uv(e.length>=2),this._passToInner("getDOMNodeForPath",e)))),W(this,"getGrammarTypeForPath",(e=>(uv(e.length>=2),this._passToInner("getGrammarTypeForPath",e))))}render(){const e=M.default.extend(function(e,t){const n=(e=e||{}).labels||["x","y"],o=e.range||[[-10,10],[-10,10]],s=e.step||[1,1];return{box:[t,t],labels:n,range:o,step:s,gridStep:e.gridStep||pv(o,s,t),valid:!0,backgroundImage:hv,markings:"grid",showProtractor:!1}}(this.props.graph,400),this.props.graph),t="interactive"===this.props.graphMode,n=t?Tv:Mv,o=_.createElement("div",{style:{width:e.box[0]}},_.createElement(n,{ref:"toolsBar",enabled:(s=this.props.tools,i="enabled",M.default.object(M.default.map(s,(function(e,t){return[t,e[i]]})))),apiOptions:this.props.apiOptions,addTool:this.addTool,removeTool:this.removeTool,onUndoClick:this.handleUndoClick}));var s,i;return _.createElement("div",{className:"perseus-widget perseus-widget-transformer"},_.createElement(Eh,{ref:"graph",box:e.box,range:e.range,labels:e.labels,step:e.step,gridStep:e.gridStep,markings:e.markings,backgroundImage:e.backgroundImage,showProtractor:e.showProtractor,onGraphieUpdated:this.setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!t&&S._("Add transformations below:"),"static"===this.props.graphMode&&[_.createElement("br",{key:"static-br"}),_.createElement("em",{key:"static-nomove"}," ",S._("Note: For this question, the shape will not move.")," ")],t&&o,_.createElement(Ev,{ref:"transformationList",mode:this.props.listMode,transformations:this.props.transformations,onChange:this.setTransformationProps,onFocus:this._handleFocus,onBlur:this._handleBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions}),!t&&o)}componentDidMount(){this.setupGraphie(this.graphie())}componentDidUpdate(e){this.shouldSetupGraphie(this.props,e)?this.refs.graph.reset():cv(this.props.transformations,this.transformations)||this.setTransformations(this.props.transformations)}static validate(e,t){for(const n in Cv)if(t.tools[n].required){const t=M.default.any(M.default.map(e.transformations,(function(e){return e.type===n&&!wv.isEmpty(e)&&!wv.isNoOp(e)})));if(!t)return{type:"invalid",message:S._("Your transformation must use a %(type)s.",{type:Cv[n].lowerNounName})}}return kv.equal(e.shape,t.correct.shape)?{type:"points",earned:1,total:1,message:null}:!t.gradeEmpty&&cv(e.shape.coords,t.starting.shape.coords)?{type:"invalid",message:S._("Use the interactive graph to define a correct transformation.")}:{type:"points",earned:0,total:1,message:null}}}W(Iv,"defaultProps",M.default.defaults({transformations:[]},fv));var Pv,Nv={name:"transformer",displayName:"Transformer",widget:Iv},Av={exports:{}};Pv=function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var s=t[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){var n=function(e){return e===Object(e)},o=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var o in n)e[o]=n[o]}return e};e.exports={isObject:n,merge:o,clone:function(e){return n(e)?Array.isArray(e)?e.slice():o(e):e}}},function(e,t,n){var o=n(0),s=o.clone,i=o.isObject,r=o.merge,a=n(2),l=n(3),c=n(4),p=function(e){return Array.isArray(e)?a:i(e)?l:"string"==typeof e?c:void 0},d=function(e){if(e instanceof d)return e;if(!(this instanceof d))return new d(e);var t=p(e);this._wrapped=t.thaw?t.thaw(e):e};d.prototype.freeze=function(){var e=this._wrapped,t=p(e);return t.freeze?t.freeze(e):e},d.prototype.zoom=function(e){return void 0===this._zoomStack&&(this._zoomStack=[]),this._zoomStack.push({zoom:e,wrapped:this._wrapped}),this._wrapped=d(this._wrapped).get(e),this},d.prototype.deZoom=function(){var e=this._zoomStack.pop();return this._wrapped=d(e.wrapped).set(e.zoom,this._wrapped).freeze(),this},d.prototype.get=function(e){for(var t=this._wrapped,n=0;n<e.length;n++)t=p(t).get(t,e[n]);return t},d.prototype.mod=function(e,t){var n=this._wrapped,o=s(n),i=p(n);if(0===e.length)this._wrapped=t(this._wrapped);else if(1===e.length)this._wrapped=i.mod(o,e[0],t);else{var r=e[0],a=e.slice(1);o[r]=d(n[r]).mod(a,t).freeze(),this._wrapped=o}return this},d.prototype.merge=function(e,t){return this._wrapped=d(this._wrapped).mod(e,(function(e){return r(e,t)})).freeze(),this},d.prototype.del=function(e){var t=this._wrapped,n=p(t);if(1===e.length)this._wrapped=n.del(t,e[0]);else{var o=e[0],i=e.slice(1),r=s(t);r[o]=d(t[o]).del(i).freeze(),this._wrapped=r}return this},d.prototype.set=function(e,t){return this.mod(e,(function(){return t}))},e.exports=d},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var o=e.splice();return o[t]=n,o},mod:function(e,t,n){var o=e.slice();return o[t]=n(e[t]),o},del:function(e,t){var n=e.slice();return n.splice(t,1),n}}},function(e,t,n){var o=n(0).clone;e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var s=o(e);return s[t]=n,s},mod:function(e,t,n){var s=o(e);return s[t]=n(e[t]),s},del:function(e,t){var n=o(e);return delete n[t],n}}},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var o=e.splice();return o[t]=n,o},mod:function(e,t,n){var o=e.splice();return o[t]=n(e[t]),o},del:function(e,t){var n=e.slice();return n.splice(t),n}}}])};var Rv=cn(Av.exports=Pv());class Fv{constructor(e){W(this,"order",void 0),W(this,"mantissa",void 0),W(this,"positive",void 0),W(this,"sigFigs",void 0),W(this,"sigDecs",void 0),this.order=Bv(e),this.mantissa=Lv(e),this.positive=Dv(e),this.sigFigs=this.mantissa.length,this.sigDecs=this.order-this.mantissa.length}}function Ov(e){let t=0;for(let n=e.length-1;n>=0;n--){if("0"!=e.charAt(n))return t;t++}return t}function Dv(e){let t=!0,n=!1,o=!1,s="",i="",r=!0;for(let a=0;a<e.length;a++){const l=e.charAt(a);l>="1"&&l<="9"?(i+=s+l,s="",o=!0,t=!1):"0"==l?(n?o&&(i+=s+l,s=""):o&&(s+=l),t=!1):n||"."!=l?"e"==l||"E"==l&&a+1<e.length?(parseInt(e.substring(a+1,e.length)),a=e.length):!t||"+"!=l&&"-"!=l||"-"==l&&(r=!r):(i+=s,s="",n=!0,t=!1)}return""==i||r}function Lv(e){let t=!1,n=!1,o="",s="",i="";for(let r=0;r<e.length;r++){const a=e.charAt(r);a>="1"&&a<="9"?(i+=o+a,o="",n=!0):"0"==a?t?n?(i+=o+a,o=""):s+=a:n?(s+=a,o+=a):s+=a:t||"."!=a?("e"==a||"E"==a&&r+1<e.length)&&(parseInt(e.substring(r+1,e.length)),r=e.length):(i+=o,o="",t=!0)}return""==i?s:i}function Bv(e){let t=!1,n=!1,o="",s="",i=0,r=0;for(let a=0;a<e.length;a++){const l=e.charAt(a);if(l>="1"&&l<="9")s+=o+l,o="",n=!0,t||(r++,i++);else if("0"==l)t?n?(s+=o+l,o=""):i--:(r++,n&&(i++,o+=l));else if(t||"."!=l){if("e"==l||"E"==l&&a+1<e.length){const t=parseInt(e.substring(a+1,e.length));i+=t,r+=t,a=e.length}}else s+=o,o="",t=!0}return""==s?r:i}function zv(e,t){const n=e.length-t-1;if(n<0)return"";if(n>=e.length-1)return e;const o=e.charAt(n+1),s=e.charAt(n);let i=!1;if(o>"5")i=!0;else if("5"==o){for(let t=n+2;t<e.length;t++)"0"!=e.charAt(t)&&(i=!0);s%2==1&&(i=!0)}let r="";for(let t=n;t>=0;t--){const n=e.charAt(t);if(i){let e;if("9"==n)e="0";else{switch(n){case"0":e="1";break;case"1":e="2";break;case"2":e="3";break;case"3":e="4";break;case"4":e="5";break;case"5":e="6";break;case"6":e="7";break;case"7":e="8";break;case"8":e="9"}i=!1}r=e+r}else r=n+r}return i&&(r="1"+r),r}class qv extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"_errorTimeout",void 0),W(this,"_showError",(()=>{if(""===this.props.value)return;const e=R.default(N.default.findDOMNode(this.refs.error));e.is(":visible")||e.css({top:50,opacity:.1}).show().animate({top:0,opacity:1},300)})),W(this,"_hideError",(()=>{const e=R.default(N.default.findDOMNode(this.refs.error));e.is(":visible")&&e.animate({top:50,opacity:.1},300,(function(){R.default(this).hide()}))})),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)})),W(this,"handleBlur",(()=>{this.props.onBlur([]),clearTimeout(this._errorTimeout),k.unitParse(this.props.value).parsed||this._showError()})),W(this,"handleChange",(e=>{this._hideError(),this.props.onChange({value:e.target.value})})),W(this,"simpleValidate",((e,t)=>qv.validate(this.getUserInput(),e))),W(this,"getUserInput",(()=>this.props.value)),W(this,"getInputPaths",(()=>[[]])),W(this,"focusInputPath",(e=>{const t=N.default.findDOMNode(this.refs.input);t&&t.focus()})),W(this,"handleFocus",(()=>{this.props.onFocus([])})),W(this,"blurInputPath",(e=>{const t=N.default.findDOMNode(this.refs.input);t&&t.blur()})),W(this,"setInputValue",((e,t,n)=>{this.props.onChange({value:t},n)})),W(this,"getDOMNodeForPath",(()=>N.default.findDOMNode(this.refs.input))),W(this,"getGrammarTypeForPath",(e=>"unit"))}static validate(e,t){const n=k.unitParse(t.value).expr,o=k.unitParse(e);if(!o.parsed)return{type:"invalid",message:S._("I couldn't understand those units.")};let s=null;const i=t.sigfigs,r=(a=o.coefficient,new Fv(a).sigFigs===i);var a;let l,c;r||(s=S._("Check your significant figures."));try{const e=new k.Var("x"),t=new k.Eq(n.simplify(),"=",new k.Mul(e,o.expr.simplify())).solveLinearEquationForVariable(e);l=Number(t.eval()).toPrecision(i)===Number(1).toPrecision(i)}catch(e){l=!1}l||(s=S._("That answer is numerically incorrect."));const p=Hv(o.expr.simplify()),d=Hv(n.simplify());c="all"===t.accepting?k.compare(p,d).equal:M.default(t.acceptingUnits).any((e=>{const t=Hv(k.unitParse(e).unit.simplify());return k.compare(t,p).equal})),c||(s=S._("Check your units."));return{type:"points",earned:c&&l&&r?1:0,total:1,message:s}}render(){const e=this.props.apiOptions.staticRender?_.createElement(Xi,{onChange:this.handleChange,ref:"input",className:$t.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur}):_.createElement("input",{onChange:this.handleChange,ref:"input",className:$t.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur});return _.createElement("div",{className:"old-unit-input"},e,_.createElement("div",{ref:"error",className:"error",style:{display:"none"}},S._("I don't understand that")))}componentDidUpdate(){clearTimeout(this._errorTimeout),k.unitParse(this.props.value).parsed?this._hideError():this._errorTimeout=setTimeout(this._showError,2e3)}componentWillUnmount(){clearTimeout(this._errorTimeout)}}W(qv,"defaultProps",{apiOptions:Yt.defaults,value:""});const Hv=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()};var Wv={name:"unit-input",displayName:"Unit",defaultAlignment:"inline-block",widget:qv,transform:e=>Rv(e).del(["value"]).freeze(),version:{major:0,minor:1},hidden:!0};const Uv=L.default.large_24,Gv={small:{query:"(max-width: 767px)",totalColumns:4,gutterWidth:L.default.medium_16,marginWidth:L.default.medium_16},medium:{query:"(min-width: 768px) and (max-width: 1023px)",totalColumns:8,gutterWidth:L.default.xLarge_32,marginWidth:L.default.large_24},large:{query:"(min-width: 1024px)",totalColumns:12,gutterWidth:L.default.xLarge_32,marginWidth:Uv,maxWidth:1120+2*Uv}},Vv={large:{query:"(min-width: 1px)",totalColumns:12,gutterWidth:L.default.xLarge_32,marginWidth:L.default.medium_16}},jv={small:{query:"(max-width: 767px)",totalColumns:4,gutterWidth:L.default.medium_16,marginWidth:L.default.medium_16},large:{query:"(min-width: 768px)",totalColumns:12,gutterWidth:L.default.xLarge_32,marginWidth:L.default.xxLarge_48}},Yv={ssrSize:"large",mediaSpec:Gv};_.createContext(Yv),[].concat(Object.values(Gv).map((e=>e.query)),Object.values(Vv).map((e=>e.query)),Object.values(jv).map((e=>e.query))),l.StyleSheet.create({grow:{flexGrow:1}});class $v extends _.Component{render(){const{size:e,style:t}=this.props;return _.createElement(m.View,{"aria-hidden":"true",style:[Xv(e),t]})}}const Xv=e=>({width:e,MsFlexBasis:e,MsFlexPreferredSize:e,WebkitFlexBasis:e,flexBasis:e,flexShrink:0}),Kv=/^https?:\/\//,Zv=e=>{const t=e.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/);return t&&11===t[7].length?t[7]:"videoNotFound"},Jv=e=>{const{location:t}=e,{useVideo:n}=ne(),[o,s]=Kv.test(t)?[Zv(t),"YOUTUBE_ID"]:[t,"READABLE_ID"],i=n(o,s);switch(i.status){case"loading":return _.createElement(m.View,null,S._("Loading..."));case"success":{var r;const e=null===(r=i.data)||void 0===r?void 0:r.video;return _.createElement(m.View,{style:Qv.transcriptLink},_.createElement(m.Text,null,null==e?void 0:e.title),_.createElement($v,{size:10}),_.createElement(z.default,{href:"/transcript/"+((null==e?void 0:e.contentId)||"videoNotFound"),target:"_blank",className:"visited-no-recolor"},S._("See video transcript")))}default:return _.createElement(m.View,null,S._("Something went wrong."))}},Qv=l.StyleSheet.create({transcriptLink:{flexDirection:"row",width:"100%",justifyContent:"center"}}),ey="{host}/embed_video?slug={slug}&internal_video_only=1",ty=/^https?:\/\//,ny=/(khanacademy\.org|localhost)/;class oy extends _.Component{constructor(){var e;super(...arguments),e=this,W(this,"getUserInput",(()=>null)),W(this,"simpleValidate",(e=>oy.validate(null,e))),W(this,"change",(function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return cr.apply(e,n)}))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const{InitialRequestUrl:e}=ne(),t=this.props.location;if(!t)return _.createElement("div",null);let n;if(ty.test(t))n=t;else{n=ey.replace("{slug}",t);let o="https://www.khanacademy.org";ny.test(e.host)&&(o=e.origin),n=n.replace("{host}",o)}return _.createElement(m.View,null,_.createElement(tn,{width:1280,height:720,key:t+this.props.alignment},_.createElement(m.View,{style:ll.srOnly},S._("Khan Academy video wrapper")),_.createElement("iframe",{className:"perseus-video-widget",sandbox:"allow-same-origin allow-scripts",width:1280,height:720,src:n,allowFullScreen:!0})),_.createElement(Jv,{location:t}))}}var sy=[Hl,$l,ec,rc,Jl,Fu,Xd,Qd,Du,zu,Uu,ah,Xh,of,vf,Vf,Tf,$f,km,Fm,qm,Eg,Rr,Wm,Ig,Ag,Fg,Jg,tv,lv,Nv,Wv,{name:"video",displayName:"Video",defaultAlignment:"block",supportedAlignments:["block","float-left","float-right","full-width"],widget:oy}];var iy=[...Bl,...sy];ci(iy);const ry=ui();ry["::renderer::"]=H;const ay={propTypes:{apiOptions:I.default.shape({customKeypad:I.default.bool,nativeKeypadProxy:I.default.func}),keypadStyle:I.default.any},getInitialState(){const e=this;let t=null;return e.props.apiOptions&&e.props.apiOptions.customKeypad&&e.props.apiOptions.nativeKeypadProxy&&(t=e.props.apiOptions.nativeKeypadProxy((()=>e.blur&&e.blur()))),{keypadElement:t}},componentDidMount(){const e=this;var n;e.props.apiOptions&&e.props.apiOptions.customKeypad&&!e.props.apiOptions.nativeKeypadProxy&&(e._keypadContainer=document.createElement("div"),null===(n=document.body)||void 0===n||n.appendChild(e._keypadContainer),N.default.render(_.createElement(t.Keypad,{onElementMounted:t=>{e.setState({keypadElement:t})},onDismiss:()=>{e.blur&&e.blur()},style:e.props.keypadStyle}),e._keypadContainer))},componentWillUnmount(){const e=this;e._keypadContainer&&(N.default.unmountComponentAtNode(e._keypadContainer),e._keypadContainer.parentNode&&e._keypadContainer.parentNode.removeChild(e._keypadContainer),e._keypadContainer=null)},keypadElement(){return this.state.keypadElement}},ly=I.default.shape({content:I.default.string,widgets:I.default.objectOf(I.default.any),images:I.default.objectOf(I.default.any)});class cy extends _.Component{constructor(e){super(e),W(this,"_currentFocus",void 0),W(this,"keypadElement",(()=>ay.keypadElement.call(this))),W(this,"_handleFocusChange",((e,t)=>{e?this._setCurrentFocus(e):this._onRendererBlur(t)})),W(this,"_setCurrentFocus",(e=>{const t=this.keypadElement(),n=this._currentFocus;this._currentFocus=e;let o=!1;if(this._currentFocus){const[e,...t]=this._currentFocus;o=this.refs[e].getInputPaths().some((e=>Ae.inputPathsEqual(e,t)))}null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,n,o&&t&&t.getDOMNode()),t&&(o?t.activate():t.dismiss())})),W(this,"_onRendererBlur",(e=>{const t=this._currentFocus;Ae.inputPathsEqual(e,t)&&setTimeout((()=>{Ae.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))})),W(this,"blur",(()=>{if(this._currentFocus){const[e,...t]=this._currentFocus;this.refs[e].blurPath(t)}})),W(this,"_sections",(()=>Array.isArray(this.props.json)?this.props.json:[this.props.json])),this.state=ay.getInitialState.call(this)}componentDidMount(){ay.componentDidMount.call(this),this._currentFocus=null}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}componentWillUnmount(){ay.componentWillUnmount.call(this)}render(){const e={...Yt.defaults,...this.props.apiOptions,isArticle:!0},t=E.default({"framework-perseus":!0,"perseus-article":!0,"bibliotron-article":this.props.useNewStyles,[$t.MOBILE]:e.isMobile}),n=this._sections().map(((t,n)=>{const o="section-".concat(n);return _.createElement("div",{key:n,className:"clearfix"},_.createElement(Ai,U({},t,{ref:o,key:n,key_:n,keypadElement:this.keypadElement(),apiOptions:{...e,onFocusChange:(e,t)=>{this._handleFocusChange(e&&[o].concat(e),t&&[o].concat(t))}},linterContext:zt.pushContextStack(this.props.linterContext,"article"),legacyPerseusLint:this.props.legacyPerseusLint})))}));return _.createElement("div",{className:t},n)}}W(cy,"propTypes",{...ay.propTypes,apiOptions:I.default.shape({onFocusChange:I.default.func,isMobile:I.default.bool}),json:I.default.oneOfType([ly,I.default.arrayOf(ly)]).isRequired,useNewStyles:I.default.bool,linterContext:qt,legacyPerseusLint:I.default.arrayOf(I.default.string)}),W(cy,"defaultProps",{apiOptions:{},useNewStyles:!1,linterContext:Ht});class py extends _.Component{constructor(){super(...arguments),W(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),W(this,"restoreSerializedState",((e,t)=>{this.refs.renderer.restoreSerializedState(e,t)}))}render(){const{apiOptions:e,className:t,hint:n,lastHint:o,lastRendered:s,pos:i,totalHints:r}=this.props,{isMobile:a}=e,c=E.default(!a&&"perseus-hint-renderer",a&&l.css(dy.newHint),a&&s&&l.css(dy.lastRenderedNewHint),o&&"last-hint",s&&"last-rendered",t),p={...e,customKeypad:!1,staticRender:!1};return _.createElement("div",{className:c,tabIndex:"-1"},!e.isMobile&&_.createElement("span",{className:"perseus-sr-only"},S._("Hint #%(pos)s",{pos:i+1})),!e.isMobile&&!e.satStyling&&r&&null!=i&&_.createElement("span",{className:"perseus-hint-label",style:{display:"block",color:e.hintProgressColor}},"".concat(i+1," / ").concat(r)),_.createElement(Ai,{ref:"renderer",widgets:n.widgets,content:n.content||"",images:n.images,apiOptions:p,findExternalWidgets:this.props.findExternalWidgets,linterContext:zt.pushContextStack(this.props.linterContext,"hint")}))}}W(py,"defaultProps",{linterContext:Ht});const dy=l.StyleSheet.create({newHint:{marginBottom:24,borderLeftColor:"#F6F7F7",borderLeftStyle:"solid",borderLeftWidth:4,[Wr.lgOrSmaller]:{paddingLeft:16},[Wr.smOrSmaller]:{paddingLeft:0},":focus":{outline:"none"}},lastRenderedNewHint:{marginBottom:0,borderLeftColor:"#71B307"}});class uy extends _.Component{constructor(){super(...arguments),W(this,"state",{isFinalHelpPage:!1}),W(this,"_hintsVisible",(()=>null==this.props.hintsVisible||-1===this.props.hintsVisible?this.props.hints.length:this.props.hintsVisible)),W(this,"_cacheImagesInHint",(e=>{M.default.each(e.images,((e,t)=>{(new Image).src=Ae.getRealImageUrl(t)}))})),W(this,"_cacheHintImages",(()=>{this._hintsVisible()>0?M.default.each(this.props.hints,this._cacheImagesInHint):this.props.hints.length>0&&this._cacheImagesInHint(this.props.hints[0])})),W(this,"getApiOptions",(()=>({...Yt.defaults,...this.props.apiOptions,readOnly:!1}))),W(this,"getSerializedState",(()=>M.default.times(this._hintsVisible(),(e=>this.refs["hintRenderer"+e].getSerializedState())))),W(this,"restoreSerializedState",((e,t)=>{let n=1;const o=()=>{--n,t&&0===n&&t()};M.default.each(e,((e,t)=>{const s=this.refs["hintRenderer"+t];s&&(++n,s.restoreSerializedState(e,o))})),o()}))}componentDidMount(){this._cacheHintImages()}UNSAFE_componentWillReceiveProps(e){e.hintsVisible-this.props.hintsVisible>1&&this.setState({isFinalHelpPage:!0})}componentDidUpdate(e,t){if(M.default.isEqual(e.hints,this.props.hints)&&e.hintsVisible===this.props.hintsVisible||this._cacheHintImages(),e.hintsVisible<this.props.hintsVisible){const e=this.props.hintsVisible-1;N.default.findDOMNode(this.refs["hintRenderer"+e]).focus()}}render(){const e=this.getApiOptions(),t=this._hintsVisible(),n=[],o=this.state.isFinalHelpPage;this.props.hints.slice(0,t).forEach(((s,i)=>{const r=i===this.props.hints.length-1&&!/\*\*/.test(s.content),a=i===t-1,l=_.createElement(py,{lastHint:r,lastRendered:a,hint:s,pos:i,totalHints:this.props.hints.length,ref:"hintRenderer"+i,key:"hintRenderer"+i,apiOptions:e,findExternalWidgets:this.props.findExternalWidgets,linterContext:zt.pushContextStack(this.props.linterContext,"hints["+i+"]")});o?n.push(l):s.replace&&n.length>0?n[n.length-1]=l:n.push(l)}));const{getAnotherHint:s}=e,i=s&&t>0&&t<this.props.hints.length,r="(".concat(t,"/").concat(this.props.hints.length,")"),a=E.default(this.props.className,e.isMobile&&t>0&&l.css(hy.mobileHintStylesHintsRenderer));return _.createElement("div",{className:a},e.isMobile&&t>0&&_.createElement("div",{className:l.css(hy.mobileHintStylesHintTitle,Xr.responsiveLabel)},S._("Hints")),n,i&&_.createElement("button",{rel:"button",className:l.css(hy.linkButton,hy.getAnotherHintButton,e.isMobile&&hy.mobileHintStylesGetAnotherHintButton),onClick:e=>{e.preventDefault(),e.stopPropagation(),s&&s()}},_.createElement("span",{className:l.css(hy.plusText,e.isMobile&&hy.mobileHintStylesPlusText)},"+"),_.createElement("span",{className:l.css(hy.getAnotherHintText)},S._("Get another hint")," ",r)))}}W(uy,"defaultProps",{linterContext:Ht});const hy=l.StyleSheet.create({rendererMargins:{marginTop:16},linkButton:{cursor:"pointer",border:"none",backgroundColor:"transparent",fontSize:"100%",fontFamily:"inherit",fontWeight:"bold",color:"#71B307",padding:0,position:"relative"},plusText:{fontSize:20,position:"absolute",top:-3,left:0},getAnotherHintText:{marginLeft:16},mobileHintStylesHintsRenderer:{marginTop:64,border:"solid ".concat("#D6D8DA"),borderWidth:"1px 0 0 0",position:"relative",":before":{content:'""',display:"table",clear:"both"},":after":{content:'""',display:"table",clear:"both"}},mobileHintStylesHintTitle:{fontFamily:"inherit",fontStyle:"normal",fontWeight:"bold",color:X,paddingTop:16,paddingBottom:24,[Wr.lgOrSmaller]:{paddingLeft:0},[Wr.smOrSmaller]:{paddingLeft:20}},getAnotherHintButton:{marginTop:24},mobileHintStylesGetAnotherHintButton:{[Wr.lgOrSmaller]:{paddingLeft:0},[Wr.smOrSmaller]:{paddingLeft:20}},mobileHintStylesPlusText:{[Wr.lgOrSmaller]:{left:0},[Wr.smOrSmaller]:{left:20}}}),{mapObject:fy}=wn;class my extends _.Component{constructor(e){super(e),W(this,"questionRenderer",void 0),W(this,"hintsRenderer",void 0),W(this,"_currentFocus",void 0),W(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),W(this,"handleInteractWithWidget",(e=>{const t=M.default.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),this.state={...ay.getInitialState.call(this),hintsVisible:e.initialHintsVisible||0,questionCompleted:!1,questionHighlightedWidgets:[]}}componentDidMount(){ay.componentDidMount.call(this),this.props.controlPeripherals&&this.props.apiOptions.setDrawingAreaAvailable&&this.props.apiOptions.setDrawingAreaAvailable(!0),this._currentFocus=null,this.update()}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(){this.update()}componentWillUnmount(){ay.componentWillUnmount.call(this);const e=document.querySelector(this.props.workAreaSelector);null!=e&&A.unmountComponentAtNode(e);const t=document.querySelector(this.props.hintsAreaSelector);if(null!=t&&A.unmountComponentAtNode(t),this.props.controlPeripherals){const e=this.props.item.answerArea||{};e.calculator&&R.default("#calculator").hide(),e.periodicTable&&R.default(".periodic-table-info-box").hide(),e.zTable&&R.default(".z-table-info-box").hide(),e.tTable&&R.default(".t-table-info-box").hide(),e.chi2Table&&R.default(".chi2-table-info-box").hide()}}keypadElement(){return ay.keypadElement.call(this)}update(){const e={...Yt.defaults,...this.props.apiOptions,onFocusChange:this._handleFocusChange},t=document.querySelector(this.props.workAreaSelector),n=document.querySelector(this.props.hintsAreaSelector);if(!t||!n)return;A.render(_.createElement(Ai,U({ref:t=>{if(!t)return;this.questionRenderer=t;const{answerableCallback:n}=e;if(n){n(0===this.questionRenderer.emptyWidgets().length)}},keypadElement:this.keypadElement(),problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,savedState:this.props.savedState,linterContext:zt.pushContextStack(this.props.linterContext,"question")},this.props.item.question,{legacyPerseusLint:this.props.legacyPerseusLint})),t),A.render(_.createElement(uy,{ref:e=>this.hintsRenderer=e,hints:this.props.item.hints,hintsVisible:this.state.hintsVisible,apiOptions:e,linterContext:zt.pushContextStack(this.props.linterContext,"hints")}),n);const o=this.props.item.answerArea||{};this.props.controlPeripherals?(R.default("#calculator").toggle(o.calculator||!1),R.default(".periodic-table-info-box").toggle(o.periodicTable||!1),R.default(".z-table-info-box").toggle(o.zTable||!1),R.default(".t-table-info-box").toggle(o.tTable||!1),R.default(".chi2-table-info-box").toggle(o.chi2Table||!1)):(o.calculator&&this.props.onShowCalculator&&this.props.onShowCalculator(),o.periodicTable&&this.props.onShowPeriodicTable&&this.props.onShowPeriodicTable(),o.zTable&&this.props.onShowZTable&&this.props.onShowZTable(),o.tTable&&this.props.onShowTTable&&this.props.onShowTTable(),o.chi2Table&&this.props.onShowChi2Table&&this.props.onShowChi2Table())}_setCurrentFocus(e){const t=this.keypadElement(),n=this._currentFocus;this._currentFocus=e;const o=this.getInputPaths(),s=this._currentFocus&&o.some((e=>Ae.inputPathsEqual(e,this._currentFocus)));null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,n,s&&t&&t.getDOMNode()),t&&(s?t.activate():t.dismiss())}_onRendererBlur(e){const t=this._currentFocus;Ae.inputPathsEqual(e,t)&&setTimeout((()=>{Ae.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))}_setWidgetProps(e,t,n){this.questionRenderer._setWidgetProps(e,t,n)}setInputValue(e,t,n){return this.questionRenderer.setInputValue(e,t,n)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}showHint(){this.state.hintsVisible<this.getNumHints()&&this.setState({hintsVisible:this.state.hintsVisible+1})}getNumHints(){return this.props.item.hints.length}scoreInput(){const e=this.questionRenderer.guessAndScore(),t=e[0],n=e[1],o=[t,[]],s=Ae.keScoreFromPerseusScore(n,o,this.questionRenderer.getSerializedState()),i=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:s.correct,questionHighlightedWidgets:i}),s}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){const e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),n=this.questionRenderer.getSerializedState();return fy(e,((e,o)=>Ae.keScoreFromPerseusScore(e,t[o],n[o])))}getSerializedState(){var e;return{question:this.questionRenderer.getSerializedState(),hints:null===(e=this.hintsRenderer)||void 0===e?void 0:e.getSerializedState()}}restoreSerializedState(e,t){var n;let o=2;const s=()=>{--o,t&&0===o&&t()};this.questionRenderer.restoreSerializedState(e.question,s),null===(n=this.hintsRenderer)||void 0===n||n.restoreSerializedState(e.hints,s)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){return _.createElement("div",null)}}W(my,"defaultProps",{apiOptions:Yt.defaults,controlPeripherals:!0,hintsAreaSelector:"#hintsarea",initialHintsVisible:0,workAreaSelector:"#workarea",reviewMode:!1,linterContext:Ht});const gy={onRendered:e=>{}},vy=_.createContext(gy),{mapObject:yy}=wn;class by extends _.Component{constructor(e){super(e),W(this,"questionRenderer",void 0),W(this,"hintsRenderer",void 0),W(this,"_currentFocus",void 0),W(this,"_fullyRendered",void 0),W(this,"blurTimeoutID",void 0),W(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),W(this,"handleInteractWithWidget",(e=>{const t=M.default.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),W(this,"setAssetStatus",((e,t)=>{const n={...this.state.assetStatuses,[e]:t};this.setState({assetStatuses:n})})),this.state={questionCompleted:!1,questionHighlightedWidgets:[],assetStatuses:{}},this._fullyRendered=!1}componentDidMount(){this._currentFocus=null,this._fullyRendered=!1}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(e,t){if(this.props.apiOptions.answerableCallback){const e=0===this.questionRenderer.emptyWidgets().length,{answerableCallback:t}=this.props.apiOptions;t&&t(e)}if(!this._fullyRendered){Object.values(this.state.assetStatuses).every(Boolean)&&(this._fullyRendered=!0,this.props.onRendered(!0))}}componentWillUnmount(){null!=this.blurTimeoutID&&(clearTimeout(this.blurTimeoutID),this.blurTimeoutID=null)}_setCurrentFocus(e){const{apiOptions:{isMobile:t,onFocusChange:n},keypadElement:o}=this.props,s=this._currentFocus;this._currentFocus=e;const i=this.getInputPaths(),r=this._currentFocus&&i.some((e=>Ae.inputPathsEqual(e,this._currentFocus)));null!=n&&n(this._currentFocus,s,r&&o&&o.getDOMNode(),r&&this.questionRenderer.getDOMNodeForPath(e)),o&&t&&(r?o.activate():o.dismiss())}_onRendererBlur(e){const t=this._currentFocus;M.default.isEqual(e,t)&&(this.blurTimeoutID=setTimeout((()=>{M.default.isEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}),0))}_setWidgetProps(e,t,n){this.questionRenderer._setWidgetProps(e,t,n)}setInputValue(e,t,n){return this.questionRenderer.setInputValue(e,t,n)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}getNumHints(){return this.props.item.hints.length}scoreInput(){const e=this.questionRenderer.guessAndScore(),t=e[0],n=e[1],o=[t,[]],s=Ae.keScoreFromPerseusScore(n,o,this.questionRenderer.getSerializedState()),i=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:s.correct,questionHighlightedWidgets:i}),s}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){const e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),n=this.questionRenderer.getSerializedState();return yy(e,((e,o)=>Ae.keScoreFromPerseusScore(e,t[o],n)))}getSerializedState(){return{question:this.questionRenderer.getSerializedState(),hints:this.hintsRenderer.getSerializedState()}}restoreSerializedState(e,t){let n=2;const o=()=>{--n,t&&0===n&&t()};this.questionRenderer.restoreSerializedState(e.question,o),this.hintsRenderer.restoreSerializedState(e.hints,o)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){const e={...Yt.defaults,...this.props.apiOptions,onFocusChange:this._handleFocusChange},t={assetStatuses:this.state.assetStatuses,setAssetStatus:this.setAssetStatus},n=_.createElement(Kt.Provider,{value:t},_.createElement(Ai,{keypadElement:this.props.keypadElement,problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,ref:e=>{null!=e&&(this.questionRenderer=e)},content:this.props.item.question.content,widgets:this.props.item.question.widgets,images:this.props.item.question.images})),o=_.createElement(uy,{hints:this.props.item.hints,hintsVisible:this.props.hintsVisible,apiOptions:e,ref:e=>this.hintsRenderer=e});return _.createElement("div",null,_.createElement("div",null,n),_.createElement("div",{className:e.isMobile?void 0:l.css(xy.hintsContainer)},o))}}W(by,"defaultProps",{apiOptions:{},onRendered:e=>{}});const xy=l.StyleSheet.create({hintsContainer:{marginLeft:50}}),wy=_.forwardRef(((e,t)=>_.createElement(vy.Consumer,null,(n=>{let{onRendered:o}=n;return _.createElement(by,U({},e,{onRendered:o,ref:t}))}))));class Cy extends _.Component{render(){return _.createElement(tu,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:_.createElement("span",null,"—")},{value:"->",content:_.createElement("span",null,"→")}],onChange:this.props.onChange})}}W(Cy,"defaultProps",{value:""});const ky=[dn.BLACK,dn.BLUE,dn.GREEN,dn.PINK,dn.PURPLE,dn.RED,dn.GRAY],Sy=[dn.LIGHT_BLUE,dn.LIGHT_ORANGE,dn.LIGHT_PINK,dn.LIGHT_GREEN,dn.LIGHT_PURPLE,dn.LIGHT_RED,"#fff"];class Ey extends _.Component{render(){const e=this.props.lightColors?Sy:ky;return _.createElement(tu,{value:this.props.value,allowEmpty:!1,buttons:M.default.map(e,(e=>({value:e,content:_.createElement("span",null,_.createElement("span",{className:"colorpicker-circle",style:{background:e}})," ")}))),onChange:this.props.onChange})}}W(Ey,"defaultProps",{value:dn.BLACK,lightColors:!1});class _y extends _.Component{render(){return _.createElement(tu,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:_.createElement("span",null,"—")},{value:"-",content:_.createElement("span",null,"–––")},{value:"- ",content:_.createElement("span",null,"– –")},{value:".",content:_.createElement("span",null,"····")},{value:". ",content:_.createElement("span",null,"· · ·")}],onChange:this.props.onChange})}}W(_y,"defaultProps",{value:""});class Ty extends _.Component{constructor(e){super(e),W(this,"toggle",(e=>{e.preventDefault(),this.setState({show:!this.state.show})})),this.state={show:e.initiallyVisible}}render(){return _.createElement("div",{className:"perseus-interaction-element"},_.createElement("a",{href:"#",className:"perseus-interaction-element-title "+(this.state.show?"open":"closed"),onClick:this.toggle},this.state.show?_.createElement(G,uo):_.createElement(G,ho),this.props.title),_.createElement("div",{className:"perseus-interaction-element-content "+(this.state.show?"enter":"leave")},this.props.children,(null!=this.props.onUp||null!=this.props.onDown||null!=this.props.onDelete)&&_.createElement("div",{className:"edit-controls"},null!=this.props.onUp&&_.createElement("button",{onClick:this.props.onUp},_.createElement(G,go)),null!=this.props.onDown&&_.createElement("button",{onClick:this.props.onDown},_.createElement(G,mo)),null!=this.props.onDelete&&_.createElement("button",{onClick:this.props.onDelete},_.createElement(G,So)))))}}W(Ty,"defaultProps",{initiallyVisible:!1,title:"More"});class My extends _.Component{constructor(){super(...arguments),W(this,"renderVisibleIcon",(()=>_.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:l.css(Iy.icon)},_.createElement("defs",null,_.createElement("path",{id:"a",d:"M7.401 10.035c-1.424.748-2.599 1.905-3.544 3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"})),_.createElement("g",{fill:"none",fillRule:"evenodd"},_.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),_.createElement("mask",{id:"b",fill:"#fff"},_.createElement("use",{href:"#a"})),_.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),_.createElement("g",{fill:"#fff",mask:"url(#b)"},_.createElement("path",{d:"M0 0h24v24H0z"})))))),W(this,"renderHiddenIcon",(()=>_.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:l.css(Iy.icon)},_.createElement("defs",null,_.createElement("path",{id:"a",d:"M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48.258.604.401 1.268.401 1.966 0 1.02-.305 1.967-.828 2.757l2.535 2.536a1 1 0 0 1-1.414 1.414l-12-12a1 1 0 0 1 1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 0-4.001-4.001l4 4.001zM6.072 8.486l2.976 2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 2.363-3.085 3.929-4z"})),_.createElement("g",{fill:"none",fillRule:"evenodd"},_.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),_.createElement("mask",{id:"b",fill:"#fff"},_.createElement("use",{href:"#a"})),_.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),_.createElement("g",{fill:"#fff",mask:"url(#b)"},_.createElement("path",{d:"M0 0h24v24H0z"}))))))}render(){let e,t;return this.props.enabled?(e=Iy.enabled,t=this.renderVisibleIcon()):(e=Iy.disabled,t=this.renderHiddenIcon()),_.createElement("button",{className:l.css(Iy.hud,this.props.fixedPosition&&Iy.hudFixedPosition,e),onClick:e=>{this.props.onClick()}},t,this.props.message)}}W(My,"propTypes",{message:I.default.string.isRequired,enabled:I.default.bool.isRequired,onClick:I.default.func.isRequired,fixedPosition:I.default.bool}),W(My,"defaultProps",{fixedPosition:!0});const Iy=l.StyleSheet.create({hud:{boxSizing:"border-box",height:36,padding:"9px 16px",borderRadius:18,fontFamily:V,fontSize:"15px",lineHeight:"18px",color:j,userSelect:"none",borderWidth:0},hudFixedPosition:{bottom:20,position:"fixed",right:20,zIndex:1},icon:{width:24,height:24,marginRight:8,marginTop:-3,verticalAlign:"middle"},enabled:{backgroundColor:"#f86700",":hover":{backgroundColor:"#df5c00"},":active":{backgroundColor:"#c75300"}},disabled:{backgroundColor:Y,":hover":{backgroundColor:"#a1a5a9"},":active":{backgroundColor:$}}});class Py extends _.Component{constructor(){super(...arguments),W(this,"toggleSelect",(e=>{const t=(this.props.values||[]).slice(0),n=this.props.allowEmpty;t.indexOf(e)>=0&&(t.length>1||n)?t.splice(t.indexOf(e),1):t.indexOf(e)<0&&t.push(e),this.props.onChange(t)}))}focus(){var e;return null===(e=A.findDOMNode(this))||void 0===e||e.focus(),!0}render(){const e=this.props.values||[],t=this.props.buttons.map(((t,n)=>{const o=e.indexOf(t.value)>=0;return _.createElement("button",{title:t.title,type:"button",id:""+n,key:""+n,ref:"button"+n,className:l.css(Ny.buttonStyle,o&&Ny.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)}));return _.createElement("div",{style:{display:"inline-block"}},t)}}W(Py,"defaultProps",{values:[],allowEmpty:!0});const Ny=l.StyleSheet.create({buttonStyle:{backgroundColor:"white",border:"1px solid #ccc",borderLeft:"0",cursor:"pointer",margin:"0",padding:"5px 10px",position:"relative",":first-child":{borderLeft:"1px solid #ccc",borderTopLeftRadius:"3px",borderBottomLeftRadius:"3px"},":last-child":{borderRight:"1px solid #ccc",borderTopRightRadius:"3px",borderBottomRightRadius:"3px"},":hover":{backgroundColor:"#ccc"},":focus":{zIndex:2}},selectedStyle:{backgroundColor:"#ddd"}}),Ay=F.default({displayName:"PropCheckBox",propTypes:{labelAlignment:I.default.oneOf(["left","right"])},DEFAULT_PROPS:{label:null,onChange:null,labelAlignment:"left"},getDefaultProps:function(){return this.DEFAULT_PROPS},propName:function(){const e=M.default.find(M.default.keys(this.props),(function(e){return!M.default.has(this.DEFAULT_PROPS,e)}),this);if(!e)throw new re("Attempted to create a PropCheckBox with no prop!",se.InvalidInput);return e},_labelAlignLeft:function(){return"left"===this.props.labelAlignment},render:function(){const e=this.propName();return _.createElement("label",null,this._labelAlignLeft()&&this.props.label,_.createElement("input",{type:"checkbox",checked:this.props[e],onChange:this.toggle}),!this._labelAlignLeft()&&this.props.label)},toggle:function(){const e=this.propName(),t={};t[e]=!this.props[e],this.props.onChange(t)}}),Ry=()=>!0;class Fy extends _.Component{constructor(){super(...arguments),W(this,"onChange",((e,t)=>{const n=this.props.value;0===e?this.props.onChange([t,n[1]]):this.props.onChange([n[0],t])}))}render(){const e=this.props.value,t=this.props.checkValidity||Ry;return _.createElement("div",{className:"range-input"},_.createElement(Af,U({},this.props,{value:e[0],checkValidity:n=>t([n,e[1]]),onChange:this.onChange.bind(this,0),placeholder:this.props.placeholder[0]})),_.createElement(Af,U({},this.props,{value:e[1],checkValidity:n=>t([e[0],n]),onChange:this.onChange.bind(this,1),placeholder:this.props.placeholder[1]})))}}W(Fy,"propTypes",{value:I.default.array.isRequired,onChange:I.default.func.isRequired,placeholder:I.default.array,checkValidity:I.default.func}),W(Fy,"defaultProps",{placeholder:[null,null]});var Oy=Object.freeze({__proto__:null,ButtonGroup:tu,Graph:Eh,Graphie:Es,HUD:My,Icon:aa,InfoTip:Hg,InlineIcon:G,MathInput:Wi,MultiButtonGroup:Py,NumberInput:Af,PropCheckBox:Ay,RangeInput:Fy,SvgImage:zs,TextInput:Ki,TexButtons:qi,TextListEditor:Gt});var Dy=Object.freeze({__proto__:null,devices:{PHONE:"phone",TABLET:"tablet",DESKTOP:"desktop"},lintGutterWidth:36,perseusFrameBorderWidth:1});const Ly=_.createContext({setKeypadElement:e=>{},keypadElement:null,setRenderer:e=>{},renderer:null,setScrollableElement:e=>{},scrollableElement:null}),By=function(){},zy=function(e,t,n,o){let s=e.content;if(null!=e.content){const n=t(e.content);void 0!==n&&(s=n)}const i=wn.mapObject(e.widgets||{},(function(e,t){return null==e||null==e.type?e:n(e,t)})),r=M.default.extend({},e,{content:s,widgets:i}),a=o(r);return void 0!==a?a:r},qy=function(e,t,n,o){return zy(e,t=t||By,function(e,t,n){const o=function(s,i){var r;const a=fi(s),l=di(a.type);let c;c=l&&(null===(r=a.version)||void 0===r?void 0:r.major)===l.major?gi(a,(t=>zy(t,e,o,n))):a;const p=t(c,i);return void 0!==p?p:c};return o}(t,n=n||By,o=o||By),o)},Hy={type:"hint"},Wy=e=>({type:"array",elementShape:e});var Uy={content:{type:"content"},hint:Hy,hints:Wy(Hy),tags:{type:"tags"},arrayOf:Wy,shape:e=>({type:"object",shape:e})};class Gy{constructor(e,t,n){W(this,"content",void 0),W(this,"hint",void 0),W(this,"tags",void 0),W(this,"array",void 0),this.content=e,this.hint=t,this.tags=n,this.array=jy}setContentMapper(e){return new Gy(e,this.hint,this.tags)}setHintMapper(e){return new Gy(this.content,e,this.tags)}setTagsMapper(e){return new Gy(this.content,this.hint,e)}setArrayMapper(e){return new Vy(this.content,this.hint,this.tags,e)}mapTree(e,t){return $y(e,t,[],this)}}class Vy{constructor(e,t,n,o){W(this,"content",void 0),W(this,"hint",void 0),W(this,"tags",void 0),W(this,"array",void 0),this.content=e,this.hint=t,this.tags=n,this.array=o}setArrayMapper(e){return new Vy(this.content,this.hint,this.tags,e)}mapTree(e,t){return $y(e,t,[],this)}}function jy(e){return e}function Yy(){return new Gy(jy,jy,jy)}function $y(e,t,n,o){if("content"===t.type){const s=e;return o.content(s,t,n)}if("hint"===t.type){const s=e;return o.hint(s,t,n)}if("tags"===t.type){const s=e;return o.tags(s,t,n)}if("array"===t.type){const s=e;if(!Array.isArray(s))throw new re('Invalid object of type "'.concat(typeof s,'" found at path ')+"".concat(["<root>"].concat(n).join("."),". Expected array."),se.Internal);const i=t.elementShape,r=s.map(((e,t)=>$y(e,i,n.concat(t),o)));return o.array(r,s,t,n)}if("object"===t.type){const s=e;if(s&&"object"!=typeof s)throw new re('Invalid object of type "'.concat(typeof s,'" found at ')+"path ".concat(["<root>"].concat(n).join("."),". Expected ")+'"object" type.',se.InvalidInput);const i=t.shape;if(!i)throw new re("Unexpected shape ".concat(JSON.stringify(t)," at path ")+"".concat(["<root>"].concat(n).join("."),"."),se.InvalidInput);const r={};return Object.keys(i).forEach((e=>{if(!(e in s))throw new re('Key "'.concat(e,'" is missing from shape at path ')+"".concat(["<root>"].concat(n).join("."),"."),se.InvalidInput);r[e]=$y(s[e],i[e],n.concat(e),o)})),r}throw new re("unexpected shape type ".concat(t.type),se.InvalidInput)}function Xy(e){if("content"===e.type)return{__type:"content",content:"",images:{},widgets:{}};if("hint"===e.type)return{__type:"hint",replace:!1,content:"",images:{},widgets:{}};if("tags"===e.type)return[];if("array"===e.type)return[];if("object"===e.type){const t=e.shape,n={};return Object.keys(t).forEach((e=>{n[e]=Xy(t[e])})),n}throw new re("unexpected shape type ".concat(e.type),se.InvalidInput)}function Ky(e){if(Array.isArray(e))return e.length?"string"==typeof e[0]?Uy.tags:Uy.arrayOf(Ky(e[0])):Uy.arrayOf(Uy.content);if("object"==typeof e&&("content"===e.__type||"item"===e.__type))return Uy.content;if("object"==typeof e&&"hint"===e.__type)return Uy.hint;if("object"==typeof e){const t={};return Object.keys(e).forEach((n=>{t[n]=Ky(e[n])})),Uy.shape(t)}throw new re("unexpected multi-item node ".concat(JSON.stringify(e)),se.InvalidInput)}function Zy(e){return e._multi}class Jy extends _.Component{constructor(e){super(e),W(this,"rendererDataTreeMapper",void 0),W(this,"getRenderersMapper",void 0),W(this,"_handleSerializedStateUpdated",((e,t)=>{const{onSerializedStateUpdated:n}=this.props;if(n){const o=this._getSerializedState(this.props.serializedState);n(Rv(o).set(e,t).freeze())}})),this.rendererDataTreeMapper=Yy().setContentMapper(((e,t,n)=>this._makeContentRendererData(e,n))).setHintMapper((e=>this._makeHintRendererData(e))).setTagsMapper((e=>null)),this.getRenderersMapper=Yy().setContentMapper((e=>e.makeRenderer())).setHintMapper((e=>e.makeRenderer())).setArrayMapper(((e,t,n)=>this._annotateRendererArray(e,t,n))),this.state=this._tryMakeRendererState(this.props)}UNSAFE_componentWillReceiveProps(e){e.item!==this.props.item&&this.setState(this._tryMakeRendererState(e))}_tryMakeRendererState(e){try{return{rendererDataTree:this._makeRendererDataTree(e.item,e.shape),renderError:null}}catch(e){return ie.error("Error building tree state",se.Internal,{cause:e}),{rendererDataTree:null,renderError:e}}}_getRendererProps(){const{item:e,children:t,shape:n,serializedState:o,onSerializedStateUpdated:s,...i}=this.props;return i}_makeContentRendererData(e,t){const n={ref:null,makeRenderer:null},o=e=>n.ref=e,s=e=>this._findWidgets(n,e),i=e=>this._handleSerializedStateUpdated(t,e);return n.makeRenderer=()=>_.createElement(Ai,U({},this._getRendererProps(),e,{ref:o,findExternalWidgets:s,serializedState:this.props.serializedState?Rv(this.props.serializedState).get(t):null,onSerializedStateUpdated:i})),n}_makeHintRendererData(e){const t=e=>this._findWidgets({},e);return{hint:e,findExternalWidgets:t,ref:null,makeRenderer:()=>_.createElement(uy,U({},this._getRendererProps(),{findExternalWidgets:t,hints:[e]}))}}_makeRendererDataTree(e,t){const n=Zy(e);return this.rendererDataTreeMapper.mapTree(n,t)}_findWidgets(e,t){const n=[];return this._mapRenderers((o=>{e!==o&&o.ref&&n.push(...o.ref.findInternalWidgets(t))})),n}_mapRenderers(e){const{rendererDataTree:t}=this.state;if(!t)return null;return Yy().setContentMapper(e).setHintMapper(e).mapTree(t,this.props.shape)}_scoreFromRef(e){if(!e)return null;const[t,n]=e.guessAndScore();let o;return e.getSerializedState&&(o=e.getSerializedState()),Ae.keScoreFromPerseusScore(n,t,o)}getScores(){return this._mapRenderers((e=>this._scoreFromRef(e.ref)))}score(){const e=[],t=[],n=this._mapRenderers((n=>{var o;return n.ref?(n.ref.getSerializedState&&t.push(n.ref.getSerializedState()),e.push(n.ref.score()),null===(o=n.ref)||void 0===o?void 0:o.getUserInput()):null})),o=e.reduce(Ae.combineScores);return Ae.keScoreFromPerseusScore(o,n,t)}_getSerializedState(e){return this._mapRenderers(((t,n,o)=>t.ref?t.ref.getSerializedState():e?Rv(e).get(o):null))}restoreSerializedState(e,t){let n=0;const o=()=>{n--,t&&0===n&&t()};this._mapRenderers(((t,s,i)=>{var r;if(!t.ref)return;const a=Rv(e).get(i);a&&(n++,null===(r=t.ref)||void 0===r||r.restoreSerializedState(a,o))}))}_annotateRendererArray(e,t,n){if("hint"===n.elementShape.type){const n=t;(e=[...e]).firstN=e=>_.createElement(uy,U({},this._getRendererProps(),{findExternalWidgets:n[0]?n[0].findExternalWidgets:void 0,hints:n.map((e=>e.hint)),hintsVisible:e}))}return e}_getRenderers(){return this.getRenderersMapper.mapTree(this.state.rendererDataTree,this.props.shape)}render(){return this.state.renderError?_.createElement("div",{className:l.css(Qy.error)},S.$_("Error rendering: %(error)s",{error:String(this.state.renderError)})):this.props.children({renderers:this._getRenderers()})}}const Qy=l.StyleSheet.create({error:{color:"red"}});function eb(e){if("content"===e.type)return I.default.shape({__type:I.default.oneOf(["content","item"]).isRequired,content:I.default.string,images:I.default.objectOf(I.default.any),widgets:I.default.objectOf(I.default.any)});if("hint"===e.type)return I.default.shape({__type:I.default.oneOf(["hint"]).isRequired,content:I.default.string,images:I.default.objectOf(I.default.any),widgets:I.default.objectOf(I.default.any),replace:I.default.bool});if("tags"===e.type)return I.default.arrayOf(I.default.string.isRequired);if("array"===e.type){const t=eb(e.elementShape);return I.default.arrayOf(t.isRequired)}if("object"===e.type){const t=e.shape,n={};return Object.keys(t).forEach((e=>{n[e]=eb(t[e]).isRequired})),I.default.shape(n)}throw new re("unexpected shape type ".concat(e.type),se.InvalidInput)}var tb={MultiRenderer:Jy,shapes:Uy,buildPropTypeForShape:function(e){return I.default.oneOfType([I.default.shape({_multi:eb(e)}),I.default.oneOf([null,void 0])])},buildEmptyItemForShape:function(e){return{_multi:Xy(e)}},findContentNodesInItem:function(e,t,n){const o=Zy(e);Yy().setContentMapper(n).mapTree(o,t)},findHintNodesInItem:function(e,t,n){const o=Zy(e);Yy().setHintMapper(n).mapTree(o,t)},inferItemShape:function(e){return Ky(Zy(e))}};const{findContentNodesInItem:nb,inferItemShape:ob}=tb,sb=function(e,t){let n=!0;return qy(e,null,(function(e){n=n&&function(e,t){if(null==e||null==e.type)return!0;const n=fi(e);return function(e,t){if(null==t)return!1;const n=e.version||{major:0,minor:0};return t.major>n.major||!(t.major<n.major)&&t.minor>=n.minor}(n,t[n.type])}(e,t)})),n},{findContentNodesInItem:ib,inferItemShape:rb}=tb;function ab(e,t){qy(e,null,(function(e){e.type&&!hi(e)&&t.push(e.type)}))}const lb={serialize:function(){return M.default.omit(this.props,ir)}},cb=q,pb=H;exports.ApiOptions=Yt,exports.ArrowPicker=Cy,exports.ArticleRenderer=cy,exports.BaseRadio=Nl,exports.Categorizer=Hl,exports.Changeable=dr,exports.ClassNames=$t,exports.ColorPicker=Ey,exports.DashPicker=_y,exports.Dependencies=oe,exports.EditorJsonify=lb,exports.ElementContainer=Ty,exports.Errors=se,exports.Expression=fr,exports.GrapherUtil=Tu,exports.GrapherWidget=Fu,exports.HintRenderer=py,exports.HintsRenderer=uy,exports.InputNumber=kr,exports.InteractiveGraphWidget=Xh,exports.ItemRenderer=my,exports.JiptParagraphs=Xs,exports.KeypadContext=Ly,exports.KhanColors=dn,exports.KhanMath=ae,exports.LoadingContext=vy,exports.Log=ie,exports.MatrixWidget=Vf,exports.MultiItems=tb,exports.NumericInput=Pr,exports.PerseusError=re,exports.PerseusMarkdown=Ge,exports.PlotterWidget=Ig,exports.Radio=Ll,exports.Renderer=Ai,exports.ServerItemRenderer=wy,exports.SizingUtils=oi,exports.TableWidget=lv,exports.TransformerWidget=Nv,exports.Util=Ae,exports.WIDGET_PROP_BLACKLIST=ir,exports.WidgetJsonifyDeprecated=Nr,exports.Widgets=Si,exports.apiVersion=cb,exports.buildEmptyItemTreeForShape=Xy,exports.buildMapper=Yy,exports.components=Oy,exports.constants=Dy,exports.displaySigFigs=function(e,t,n,o){const s=""+e;let i,r,a,l=Bv(s),c=Lv(s),p=Dv(s),d=!1;if(0==e||""==c||"0"==c){c="";for(let e=0;e<t;e++)c+="0";l=t+n,n<0&&-n>=t&&(d=!0)}else{if(r=l-c.length-n,a=t-c.length,i=Math.min(a,r),i<0){let e=zv(c,-i);e.length>c.length+i&&(l++,r>a&&(e=zv(e,1))),c=e}else if(i>0)for(let e=0;e<i;e++)c+="0";""!=c&&"0"!=c||(c="0",p=!0,l=1+n,0!=l&&(d=!0))}let u="";if(p||(u+="-"),o||c.length>20||l>4||l<-2||l-c.length>0&&Ov(c)>0||d)u+=c.charAt(0),c.length>1&&(u+="."+c.substring(1,c.length)),l-1!=0&&(u+=" x 10^"+(l-1));else{let e="",t="",n=!0;if(l>0)if(c.length>l)e=c.substring(0,l),t=c.substring(l,c.length);else{e=c,n=0!=Ov(c);for(let t=0;t<l-c.length;t++)e+="0"}else{for(let e=0;e<-l;e++)t+="0";t+=c}u+=(""==e?"0":e)+(n?".":"")+t}return u},exports.globalConstants=Ya,exports.globalStyles=Ja,exports.icons=To,exports.init=function(e){ci(Bl),ci(sy);return e.skipMathJax?Promise.resolve():new Promise(((e,t)=>{MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:"none","HTML-CSS":{availableFonts:["TeX"],imageFont:null,scale:100,showMathMenu:!1}}),MathJax.Hub.Configured(),MathJax.Hub.Queue(e)}))},exports.interactiveSizes=K,exports.isItemRenderableByVersion=function(e,t){if(null==e||null==t)throw new re("missing parameter to Perseus.isRenderable.item",se.InvalidInput);if(e._multi){const n=ob(e);let o=!0;return nb(e,n,(e=>{sb(e,t)||(o=!1)})),o}return sb(e.question,t)},exports.itemDataVersion=pb,exports.itemToTree=Zy,exports.itemVersion=ry,exports.mediaQueries=Wr,exports.preprocessTex=Js,exports.registerAllWidgetsForTesting=()=>{ci(iy)},exports.shapes=Uy,exports.traverse=qy,exports.violatingWidgets=function(e){const t=[];if(e._multi){const n=rb(e);ib(e,n,(e=>ab(e,t)))}else ab(e.question,t);return M.default.uniq(t)},exports.widgets=iy;
|
|
7
|
+
*/!function(){var e;function t(){if(t.is(arguments[0],I)){for(var e=arguments[0],n=qe[h](t,e.splice(0,3+t.is(e[0],M))),s=n.set(),i=0,r=e[y];i<r;i++){var l=e[i]||{};o[a](l.type)&&s[N](n[l.type]().attr(l))}return s}return qe[h](t,arguments)}e="".trim?function(e,t,n){e.setAttribute(t,String(n).trim())}:function(e,t,n){e.setAttribute(t,String(n))},t.version="1.5.2";var n,s=/[, ]+/,o={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},i=/\{(\d+)\}/g,r="prototype",a="hasOwnProperty",l=document,c=window,p={was:Object[r][a].call(c,"Raphael"),is:c.Raphael},d=function(){this.customAttributes={}},h="apply",u="createTouch"in l,f="",m=" ",g=String,v="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend".split(m),b={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},y="length",x=g[r].toLowerCase,C=Math,w=C.max,k=C.min,S=C.abs,E=C.pow,_=C.PI,M="number",T="string",I="array",P="fill",A=Object[r].toString,N="push",R=/^url\(['"]?([^\)]+?)['"]?\)$/i,F=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,D={NaN:1,Infinity:1,"-Infinity":1},O=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,L=C.round,B=parseFloat,z=parseInt,q=" progid:DXImageTransform.Microsoft",H=g[r].toUpperCase,W={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},U={along:"along",blur:M,"clip-rect":"csv",cx:M,cy:M,fill:"colour","fill-opacity":M,"font-size":M,height:M,opacity:M,path:"path",r:M,rotation:"csv",rx:M,ry:M,scale:"csv",stroke:"colour","stroke-opacity":M,"stroke-width":M,translation:"csv",width:M,x:M,y:M},G="replace",V=/^(from|to|\d+%?)$/,j=/\s*,\s*/,Y={hs:1,rg:1},X=/,?([achlmqrstvxz]),?/gi,$=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/gi,K=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/gi,Z=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,J=function(e,t){return e.key-t.key};if(t.type=c.SVGAngle||l.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML","VML"==t.type){var Q,ee=l.createElement("div");if(ee.innerHTML='<v:shape adj="1"/>',(Q=ee.firstChild).style.behavior="url(#default#VML)",!Q||"object"!=typeof Q.adj)return t.type=null;ee=null}function te(){for(var e=[],t=0;t<32;t++)e[t]=(~~(16*C.random())).toString(16);return e[12]=4,e[16]=(3&e[16]|8).toString(16),"r-"+e.join("")}t.svg=!(t.vml="VML"==t.type),d[r]=t[r],n=d[r],t._id=0,t._oid=0,t.fn={},t.is=function(e,t){return"finite"==(t=x.call(t))?!D[a](+e):"null"==t&&null===e||t==typeof e||"object"==t&&e===Object(e)||"array"==t&&Array.isArray&&Array.isArray(e)||A.call(e).slice(8,-1).toLowerCase()==t},t.angle=function(e,n,s,o,i,r){if(null==i){var a=e-s,l=n-o;return a||l?(180*(a<0)+180*C.atan(-l/-a)/_+360)%360:0}return t.angle(e,n,i,r)-t.angle(s,o,i,r)},t.rad=function(e){return e%360*_/180},t.deg=function(e){return 180*e/_%360},t.snapTo=function(e,n,s){if(s=t.is(s,"finite")?s:10,t.is(e,I)){for(var o=e.length;o--;)if(S(e[o]-n)<=s)return e[o]}else{var i=n%(e=+e);if(i<s)return n-i;if(i>e-s)return n-i+e}return n},t.setWindow=function(e){l=(c=e).document};var ne=function(e){if(t.vml){var n,s=/^\s+|\s+$/g;try{var o=new ActiveXObject("htmlfile");o.write("<body>"),o.close(),n=o.body}catch(e){n=createPopup().document.body}var i=n.createTextRange();ne=re((function(e){try{n.style.color=g(e)[G](s,f);var t=i.queryCommandValue("ForeColor");return"#"+("000000"+(t=(255&t)<<16|65280&t|(16711680&t)>>>16).toString(16)).slice(-6)}catch(e){return"none"}}))}else{var r=l.createElement("i");r.title="Raphaël Colour Picker",r.style.display="none",l.body.appendChild(r),ne=re((function(e){return r.style.color=e,l.defaultView.getComputedStyle(r,f).getPropertyValue("color")}))}return ne(e)},se=function(){return"hsb("+[this.h,this.s,this.b]+")"},oe=function(){return"hsl("+[this.h,this.s,this.l]+")"},ie=function(){return this.hex};function re(e,t,n){return function s(){var o=Array[r].slice.call(arguments,0),i=o.join("►"),l=s.cache=s.cache||{},c=s.count=s.count||[];return l[a](i)||(c[y]>=1e3&&delete l[c.shift()],c[N](i),l[i]=e[h](t,o)),n?n(l[i]):l[i]}}t.hsb2rgb=function(e,n,s,o){return t.is(e,"object")&&"h"in e&&"s"in e&&"b"in e&&(s=e.b,n=e.s,o=(e=e.h).o),t.hsl2rgb(e,n,s/2,o)},t.hsl2rgb=function(e,n,s,o){t.is(e,"object")&&"h"in e&&"s"in e&&"l"in e&&(s=e.l,n=e.s,e=e.h),(e>1||n>1||s>1)&&(e/=360,n/=100,s/=100);var i,r,a,l={},c=["r","g","b"];if(n){r=2*s-(i=s<.5?s*(1+n):s+n-s*n);for(var p=0;p<3;p++)(a=e+1/3*-(p-1))<0&&a++,a>1&&a--,l[c[p]]=6*a<1?r+6*(i-r)*a:2*a<1?i:3*a<2?r+(i-r)*(2/3-a)*6:r}else l={r:s,g:s,b:s};return l.r*=255,l.g*=255,l.b*=255,l.hex="#"+(16777216|l.b|l.g<<8|l.r<<16).toString(16).slice(1),t.is(o,"finite")&&(l.opacity=o),l.toString=ie,l},t.rgb2hsb=function(e,n,s){if(null==n&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(s=e.b,n=e.g,e=e.r),null==n&&t.is(e,T)){var o=t.getRGB(e);e=o.r,n=o.g,s=o.b}(e>1||n>1||s>1)&&(e/=255,n/=255,s/=255);var i,r=w(e,n,s),a=k(e,n,s);if(a==r)return{h:0,s:0,b:r,toString:se};var l=r-a;return i=e==r?(n-s)/l:n==r?2+(s-e)/l:4+(e-n)/l,(i/=6)<0&&i++,i>1&&i--,{h:i,s:l/r,b:r,toString:se}},t.rgb2hsl=function(e,n,s){if(null==n&&t.is(e,"object")&&"r"in e&&"g"in e&&"b"in e&&(s=e.b,n=e.g,e=e.r),null==n&&t.is(e,T)){var o=t.getRGB(e);e=o.r,n=o.g,s=o.b}(e>1||n>1||s>1)&&(e/=255,n/=255,s/=255);var i,r,a=w(e,n,s),l=k(e,n,s),c=(a+l)/2;if(l==a)r={h:0,s:0,l:c};else{var p=a-l;i=e==a?(n-s)/p:n==a?2+(s-e)/p:4+(e-n)/p,(i/=6)<0&&i++,i>1&&i--,r={h:i,s:c<.5?p/(a+l):p/(2-a-l),l:c}}return r.toString=oe,r},t._path2string=function(){return this.join(",")[G](X,"$1")},t.getRGB=re((function(e){if(!e||(e=g(e)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if("none"==e)return{r:-1,g:-1,b:-1,hex:"none"};!Y[a](e.toLowerCase().substring(0,2))&&"#"!=e.charAt()&&(e=ne(e));var n,s,o,i,r,l,c=e.match(F);return c?(c[2]&&(o=z(c[2].substring(5),16),s=z(c[2].substring(3,5),16),n=z(c[2].substring(1,3),16)),c[3]&&(o=z((r=c[3].charAt(3))+r,16),s=z((r=c[3].charAt(2))+r,16),n=z((r=c[3].charAt(1))+r,16)),c[4]&&(l=c[4].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),s=B(l[1]),"%"==l[1].slice(-1)&&(s*=2.55),o=B(l[2]),"%"==l[2].slice(-1)&&(o*=2.55),"rgba"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100)),c[5]?(l=c[5].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),s=B(l[1]),"%"==l[1].slice(-1)&&(s*=2.55),o=B(l[2]),"%"==l[2].slice(-1)&&(o*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(n/=360),"hsba"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100),t.hsb2rgb(n,s,o,i)):c[6]?(l=c[6].split(j),n=B(l[0]),"%"==l[0].slice(-1)&&(n*=2.55),s=B(l[1]),"%"==l[1].slice(-1)&&(s*=2.55),o=B(l[2]),"%"==l[2].slice(-1)&&(o*=2.55),("deg"==l[0].slice(-3)||"°"==l[0].slice(-1))&&(n/=360),"hsla"==c[1].toLowerCase().slice(0,4)&&(i=B(l[3])),l[3]&&"%"==l[3].slice(-1)&&(i/=100),t.hsl2rgb(n,s,o,i)):((c={r:n,g:s,b:o}).hex="#"+(16777216|o|s<<8|n<<16).toString(16).slice(1),t.is(i,"finite")&&(c.opacity=i),c)):{r:-1,g:-1,b:-1,hex:"none",error:1}}),t),t.getColor=function(e){var t=this.getColor.start=this.getColor.start||{h:0,s:1,b:e||.75},n=this.hsb2rgb(t.h,t.s,t.b);return t.h+=.075,t.h>1&&(t.h=0,t.s-=.2,t.s<=0&&(this.getColor.start={h:0,s:1,b:t.b})),n.hex},t.getColor.reset=function(){delete this.start},t.parsePathString=re((function(e){if(!e)return null;var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},s=[];return t.is(e,I)&&t.is(e[0],I)&&(s=le(e)),s[y]||g(e)[G]($,(function(e,t,o){var i=[],r=x.call(t);for(o[G](K,(function(e,t){t&&i[N](+t)})),"m"==r&&i[y]>2&&(s[N]([t].concat(i.splice(0,2))),r="l",t="m"==t?"l":"L");i[y]>=n[r]&&(s[N]([t].concat(i.splice(0,n[r]))),n[r]););})),s.toString=t._path2string,s})),t.findDotsAtSegment=function(e,t,n,s,o,i,r,a,l){var c=1-l,p=E(c,3)*e+3*E(c,2)*l*n+3*c*l*l*o+E(l,3)*r,d=E(c,3)*t+3*E(c,2)*l*s+3*c*l*l*i+E(l,3)*a,h=e+2*l*(n-e)+l*l*(o-2*n+e),u=t+2*l*(s-t)+l*l*(i-2*s+t),f=n+2*l*(o-n)+l*l*(r-2*o+n),m=s+2*l*(i-s)+l*l*(a-2*i+s),g=(1-l)*e+l*n,v=(1-l)*t+l*s,b=(1-l)*o+l*r,y=(1-l)*i+l*a,x=90-180*C.atan((h-f)/(u-m))/_;return(h>f||u<m)&&(x+=180),{x:p,y:d,m:{x:h,y:u},n:{x:f,y:m},start:{x:g,y:v},end:{x:b,y:y},alpha:x}};var ae=re((function(e){if(!e)return{x:0,y:0,width:0,height:0};for(var t,n=0,s=0,o=[],i=[],r=0,a=(e=ge(e))[y];r<a;r++)if("M"==(t=e[r])[0])n=t[1],s=t[2],o[N](n),i[N](s);else{var l=me(n,s,t[1],t[2],t[3],t[4],t[5],t[6]);o=o.concat(l.min.x,l.max.x),i=i.concat(l.min.y,l.max.y),n=t[5],s=t[6]}var c=k[h](0,o),p=k[h](0,i);return{x:c,y:p,width:w[h](0,o)-c,height:w[h](0,i)-p}})),le=function(e){var n=[];t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));for(var s=0,o=e[y];s<o;s++){n[s]=[];for(var i=0,r=e[s][y];i<r;i++)n[s][i]=e[s][i]}return n.toString=t._path2string,n},ce=re((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var n=[],s=0,o=0,i=0,r=0,a=0;"M"==e[0][0]&&(i=s=e[0][1],r=o=e[0][2],a++,n[N](["M",s,o]));for(var l=a,c=e[y];l<c;l++){var p=n[l]=[],d=e[l];if(d[0]!=x.call(d[0]))switch(p[0]=x.call(d[0]),p[0]){case"a":p[1]=d[1],p[2]=d[2],p[3]=d[3],p[4]=d[4],p[5]=d[5],p[6]=+(d[6]-s).toFixed(3),p[7]=+(d[7]-o).toFixed(3);break;case"v":p[1]=+(d[1]-o).toFixed(3);break;case"m":i=d[1],r=d[2];default:for(var h=1,u=d[y];h<u;h++)p[h]=+(d[h]-(h%2?s:o)).toFixed(3)}else{p=n[l]=[],"m"==d[0]&&(i=d[1]+s,r=d[2]+o);for(var f=0,m=d[y];f<m;f++)n[l][f]=d[f]}var g=n[l][y];switch(n[l][0]){case"z":s=i,o=r;break;case"h":s+=+n[l][g-1];break;case"v":o+=+n[l][g-1];break;default:s+=+n[l][g-2],o+=+n[l][g-1]}}return n.toString=t._path2string,n}),0,le),pe=re((function(e){t.is(e,I)&&t.is(e&&e[0],I)||(e=t.parsePathString(e));var n=[],s=0,o=0,i=0,r=0,a=0;"M"==e[0][0]&&(i=s=+e[0][1],r=o=+e[0][2],a++,n[0]=["M",s,o]);for(var l=a,c=e[y];l<c;l++){var p=n[l]=[],d=e[l];if(d[0]!=H.call(d[0]))switch(p[0]=H.call(d[0]),p[0]){case"A":p[1]=d[1],p[2]=d[2],p[3]=d[3],p[4]=d[4],p[5]=d[5],p[6]=+(d[6]+s),p[7]=+(d[7]+o);break;case"V":p[1]=+d[1]+o;break;case"H":p[1]=+d[1]+s;break;case"M":i=+d[1]+s,r=+d[2]+o;default:for(var h=1,u=d[y];h<u;h++)p[h]=+d[h]+(h%2?s:o)}else for(var f=0,m=d[y];f<m;f++)n[l][f]=d[f];switch(p[0]){case"Z":s=i,o=r;break;case"H":s=p[1];break;case"V":o=p[1];break;case"M":i=n[l][n[l][y]-2],r=n[l][n[l][y]-1];default:s=n[l][n[l][y]-2],o=n[l][n[l][y]-1]}}return n.toString=t._path2string,n}),null,le),de=function(e,t,n,s){return[e,t,n,s,n,s]},he=function(e,t,n,s,o,i){var r=1/3,a=2/3;return[r*e+a*n,r*t+a*s,r*o+a*n,r*i+a*s,o,i]},ue=function(e,t,n,s,o,i,r,a,l,c){var p,d=120*_/180,h=_/180*(+o||0),u=[],f=re((function(e,t,n){return{x:e*C.cos(n)-t*C.sin(n),y:e*C.sin(n)+t*C.cos(n)}}));if(c)M=c[0],T=c[1],k=c[2],E=c[3];else{e=(p=f(e,t,-h)).x,t=p.y;var m=(e-(a=(p=f(a,l,-h)).x))/2,g=(t-(l=p.y))/2,v=m*m/(n*n)+g*g/(s*s);v>1&&(n*=v=C.sqrt(v),s*=v);var b=n*n,x=s*s,w=(i==r?-1:1)*C.sqrt(S((b*x-b*g*g-x*m*m)/(b*g*g+x*m*m))),k=w*n*g/s+(e+a)/2,E=w*-s*m/n+(t+l)/2,M=C.asin(((t-E)/s).toFixed(9)),T=C.asin(((l-E)/s).toFixed(9));(M=e<k?_-M:M)<0&&(M=2*_+M),(T=a<k?_-T:T)<0&&(T=2*_+T),r&&M>T&&(M-=2*_),!r&&T>M&&(T-=2*_)}var I=T-M;if(S(I)>d){var P=T,A=a,N=l;T=M+d*(r&&T>M?1:-1),a=k+n*C.cos(T),l=E+s*C.sin(T),u=ue(a,l,n,s,o,0,r,A,N,[T,P,k,E])}I=T-M;var R=C.cos(M),F=C.sin(M),D=C.cos(T),O=C.sin(T),L=C.tan(I/4),B=4/3*n*L,z=4/3*s*L,q=[e,t],H=[e+B*F,t-z*R],W=[a+B*O,l-z*D],U=[a,l];if(H[0]=2*q[0]-H[0],H[1]=2*q[1]-H[1],c)return[H,W,U].concat(u);for(var G=[],V=0,j=(u=[H,W,U].concat(u).join().split(","))[y];V<j;V++)G[V]=V%2?f(u[V-1],u[V],h).y:f(u[V],u[V+1],h).x;return G},fe=function(e,t,n,s,o,i,r,a,l){var c=1-l;return{x:E(c,3)*e+3*E(c,2)*l*n+3*c*l*l*o+E(l,3)*r,y:E(c,3)*t+3*E(c,2)*l*s+3*c*l*l*i+E(l,3)*a}},me=re((function(e,t,n,s,o,i,r,a){var l,c=o-2*n+e-(r-2*o+n),p=2*(n-e)-2*(o-n),d=e-n,u=(-p+C.sqrt(p*p-4*c*d))/2/c,f=(-p-C.sqrt(p*p-4*c*d))/2/c,m=[t,a],g=[e,r];return S(u)>"1e12"&&(u=.5),S(f)>"1e12"&&(f=.5),u>0&&u<1&&(l=fe(e,t,n,s,o,i,r,a,u),g[N](l.x),m[N](l.y)),f>0&&f<1&&(l=fe(e,t,n,s,o,i,r,a,f),g[N](l.x),m[N](l.y)),c=i-2*s+t-(a-2*i+s),d=t-s,u=(-(p=2*(s-t)-2*(i-s))+C.sqrt(p*p-4*c*d))/2/c,f=(-p-C.sqrt(p*p-4*c*d))/2/c,S(u)>"1e12"&&(u=.5),S(f)>"1e12"&&(f=.5),u>0&&u<1&&(l=fe(e,t,n,s,o,i,r,a,u),g[N](l.x),m[N](l.y)),f>0&&f<1&&(l=fe(e,t,n,s,o,i,r,a,f),g[N](l.x),m[N](l.y)),{min:{x:k[h](0,g),y:k[h](0,m)},max:{x:w[h](0,g),y:w[h](0,m)}}})),ge=re((function(e,t){for(var n=pe(e),s=t&&pe(t),o={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},r=function(e,t){if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C"].concat(ue[h](0,[t.x,t.y].concat(e.slice(1))));break;case"S":e=["C",t.x+(t.x-(t.bx||t.x)),t.y+(t.y-(t.by||t.y))].concat(e.slice(1));break;case"T":t.qx=t.x+(t.x-(t.qx||t.x)),t.qy=t.y+(t.y-(t.qy||t.y)),e=["C"].concat(he(t.x,t.y,t.qx,t.qy,e[1],e[2]));break;case"Q":t.qx=e[1],t.qy=e[2],e=["C"].concat(he(t.x,t.y,e[1],e[2],e[3],e[4]));break;case"L":e=["C"].concat(de(t.x,t.y,e[1],e[2]));break;case"H":e=["C"].concat(de(t.x,t.y,e[1],t.y));break;case"V":e=["C"].concat(de(t.x,t.y,t.x,e[1]));break;case"Z":e=["C"].concat(de(t.x,t.y,t.X,t.Y))}return e},a=function(e,t){if(e[t][y]>7){e[t].shift();for(var o=e[t];o[y];)e.splice(t++,0,["C"].concat(o.splice(0,6)));e.splice(t,1),p=w(n[y],s&&s[y]||0)}},l=function(e,t,o,i,r){e&&t&&"M"==e[r][0]&&"M"!=t[r][0]&&(t.splice(r,0,["M",i.x,i.y]),o.bx=0,o.by=0,o.x=e[r][1],o.y=e[r][2],p=w(n[y],s&&s[y]||0))},c=0,p=w(n[y],s&&s[y]||0);c<p;c++){n[c]=r(n[c],o),a(n,c),s&&(s[c]=r(s[c],i)),s&&a(s,c),l(n,s,o,i,c),l(s,n,i,o,c);var d=n[c],u=s&&s[c],f=d[y],m=s&&u[y];o.x=d[f-2],o.y=d[f-1],o.bx=B(d[f-4])||o.x,o.by=B(d[f-3])||o.y,i.bx=s&&(B(u[m-4])||i.x),i.by=s&&(B(u[m-3])||i.y),i.x=s&&u[m-2],i.y=s&&u[m-1]}return s?[n,s]:n}),null,le),ve=re((function(e){for(var n=[],s=0,o=e[y];s<o;s++){var i={},r=e[s].match(/^([^:]*):?([\d\.]*)/);if(i.color=t.getRGB(r[1]),i.color.error)return null;i.color=i.color.hex,r[2]&&(i.offset=r[2]+"%"),n[N](i)}for(s=1,o=n[y]-1;s<o;s++)if(!n[s].offset){for(var a=B(n[s-1].offset||0),l=0,c=s+1;c<o;c++)if(n[c].offset){l=n[c].offset;break}l||(l=100,c=o);for(var p=((l=B(l))-a)/(c-s+1);s<c;s++)a+=p,n[s].offset=a+"%"}return n})),be=function(e,n,s,o){var i;return t.is(e,T)||t.is(e,"object")?(i=t.is(e,T)?l.getElementById(e):e).tagName?null==n?{container:i,width:i.style.pixelWidth||i.offsetWidth,height:i.style.pixelHeight||i.offsetHeight}:{container:i,width:n,height:s}:void 0:{container:1,x:e,y:n,width:s,height:o}},ye=function(e,t){var n=this;for(var s in t)if(t[a](s)&&!(s in e))switch(typeof t[s]){case"function":!function(t){e[s]=e===n?t:function(){return t[h](n,arguments)}}(t[s]);break;case"object":e[s]=e[s]||{},ye.call(this,e[s],t[s]);break;default:e[s]=t[s]}},xe=function(e,t){e==t.top&&(t.top=e.prev),e==t.bottom&&(t.bottom=e.next),e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next)},Ce=function(e,t){t.top!==e&&(xe(e,t),e.next=null,e.prev=t.top,t.top.next=e,t.top=e)},we=function(e,t){t.bottom!==e&&(xe(e,t),e.next=t.bottom,e.prev=null,t.bottom.prev=e,t.bottom=e)},ke=function(e,t,n){xe(e,n),t==n.top&&(n.top=e),t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e},Se=function(e,t,n){xe(e,n),t==n.bottom&&(n.bottom=e),t.prev&&(t.prev.next=e),e.prev=t.prev,t.prev=e,e.next=t},Ee=function(e){return function(){throw new Error("Raphaël: you are calling to method “"+e+"” of removed object")}};if(t.pathToRelative=ce,t.svg){n.svgns="http://www.w3.org/2000/svg",n.xlink="http://www.w3.org/1999/xlink",L=function(e){return+e+.5*(~~e===e)};var _e=function(t,s){if(!s)return(t=l.createElementNS(n.svgns,t)).style.webkitTapHighlightColor="rgba(0,0,0,0)",t;for(var o in s)s[a](o)&&e(t,o,g(s[o]))};t.toString=function(){return"Your browser supports SVG.\nYou are running Raphaël "+this.version};var Me=function(e,t){var n=_e("path");t.canvas&&t.canvas.appendChild(n);var s=new Ne(n,t);return s.type="path",Pe(s,{fill:"none",stroke:"#000",path:e}),s},Te=function(e,t,n){var s="linear",o=.5,i=.5,r=e.style;if(t=(t=g(t)[G](Z,(function(e,t,n){if(s="radial",t&&n){o=B(t);var r=2*((i=B(n))>.5)-1;E(o-.5,2)+E(i-.5,2)>.25&&(i=C.sqrt(.25-E(o-.5,2))*r+.5)&&.5!=i&&(i=i.toFixed(5)-1e-5*r)}return f}))).split(/\s*\-\s*/),"linear"==s){var a=t.shift();if(a=-B(a),isNaN(a))return null;var c=[0,0,C.cos(a*_/180),C.sin(a*_/180)],p=1/(w(S(c[2]),S(c[3]))||1);c[2]*=p,c[3]*=p,c[2]<0&&(c[0]=-c[2],c[2]=0),c[3]<0&&(c[1]=-c[3],c[3]=0)}var d=ve(t);if(!d)return null;var h=e.getAttribute(P);(h=h.match(/^url\(#(.*)\)$/))&&n.defs.removeChild(l.getElementById(h[1]));var u=_e(s+"Gradient");u.id=te(),_e(u,"radial"==s?{fx:o,fy:i}:{x1:c[0],y1:c[1],x2:c[2],y2:c[3]}),n.defs.appendChild(u);for(var m=0,v=d[y];m<v;m++){var b=_e("stop");_e(b,{offset:d[m].offset?d[m].offset:m?"100%":"0%","stop-color":d[m].color||"#fff"}),u.appendChild(b)}return _e(e,{fill:"url(#"+u.id+")",opacity:1,"fill-opacity":1}),r.fill=f,r.opacity=1,r.fillOpacity=1,1},Ie=function(e){var n=e.getBBox();_e(e.pattern,{patternTransform:t.format("translate({0},{1})",n.x,n.y)})},Pe=function(n,o){var i={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},r=n.node,c=n.attrs,p=n.rotate(),d=function(e,t){if(t=i[x.call(t)]){for(var n=e.attrs["stroke-width"]||"1",s={round:n,square:n,butt:0}[e.attrs["stroke-linecap"]||o["stroke-linecap"]]||0,a=[],l=t[y];l--;)a[l]=t[l]*n+(l%2?1:-1)*s;_e(r,{"stroke-dasharray":a.join(",")})}};o[a]("rotation")&&(p=o.rotation);var h=g(p).split(s);for(var u in h.length-1?(h[1]=+h[1],h[2]=+h[2]):h=null,B(p)&&n.rotate(0,!0),o)if(o[a](u)){if(!W[a](u))continue;var v=o[u];switch(c[u]=v,u){case"blur":n.blur(v);break;case"rotation":n.rotate(v,!0);break;case"href":case"title":case"target":var b=r.parentNode;if("a"!=x.call(b.tagName)){var C=_e("a");b.insertBefore(C,r),C.appendChild(r),b=C}"target"==u&&"blank"==v?b.setAttributeNS(n.paper.xlink,"show","new"):b.setAttributeNS(n.paper.xlink,u,v);break;case"cursor":r.style.cursor=v;break;case"clip-rect":var w=g(v).split(s);if(4==w[y]){n.clip&&n.clip.parentNode.parentNode.removeChild(n.clip.parentNode);var k=_e("clipPath"),S=_e("rect");k.id=te(),_e(S,{x:w[0],y:w[1],width:w[2],height:w[3]}),k.appendChild(S),n.paper.defs.appendChild(k),_e(r,{"clip-path":"url(#"+k.id+")"}),n.clip=S}if(!v){var E=l.getElementById(r.getAttribute("clip-path")[G](/(^url\(#|\)$)/g,f));E&&E.parentNode.removeChild(E),_e(r,{"clip-path":f}),delete n.clip}break;case"path":"path"==n.type&&_e(r,{d:v?c.path=pe(v):"M0,0"});break;case"width":if(e(r,u,v),!c.fx)break;u="x",v=c.x;case"x":c.fx&&(v=-c.x-(c.width||0));case"rx":if("rx"==u&&"rect"==n.type)break;case"cx":h&&("x"==u||"cx"==u)&&(h[1]+=v-c[u]),e(r,u,v),n.pattern&&Ie(n);break;case"height":if(e(r,u,v),!c.fy)break;u="y",v=c.y;case"y":c.fy&&(v=-c.y-(c.height||0));case"ry":if("ry"==u&&"rect"==n.type)break;case"cy":h&&("y"==u||"cy"==u)&&(h[2]+=v-c[u]),e(r,u,v),n.pattern&&Ie(n);break;case"r":"rect"==n.type?_e(r,{rx:v,ry:v}):e(r,u,v);break;case"src":"image"==n.type&&r.setAttributeNS(n.paper.xlink,"href",v);break;case"stroke-width":r.style.strokeWidth=v,e(r,u,v),c["stroke-dasharray"]&&d(n,c["stroke-dasharray"]);break;case"stroke-dasharray":d(n,v);break;case"translation":var _=g(v).split(s);_[0]=+_[0]||0,_[1]=+_[1]||0,h&&(h[1]+=_[0],h[2]+=_[1]),gt.call(n,_[0],_[1]);break;case"scale":_=g(v).split(s),n.scale(+_[0]||1,+_[1]||+_[0]||1,isNaN(B(_[2]))?null:+_[2],isNaN(B(_[3]))?null:+_[3]);break;case P:var M=g(v).match(R);if(M){k=_e("pattern");var T=_e("image");k.id=te(),_e(k,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1}),_e(T,{x:0,y:0}),T.setAttributeNS(n.paper.xlink,"href",M[1]),k.appendChild(T);var I=l.createElement("img");I.style.cssText="position:absolute;left:-9999em;top-9999em",I.onload=function(){_e(k,{width:this.offsetWidth,height:this.offsetHeight}),_e(T,{width:this.offsetWidth,height:this.offsetHeight}),l.body.removeChild(this),n.paper.safari()},l.body.appendChild(I),I.src=M[1],n.paper.defs.appendChild(k),r.style.fill="url(#"+k.id+")",_e(r,{fill:"url(#"+k.id+")"}),n.pattern=k,n.pattern&&Ie(n);break}var A=t.getRGB(v);if(A.error){if(({circle:1,ellipse:1}[a](n.type)||"r"!=g(v).charAt())&&Te(r,v,n.paper)){c.gradient=v,c.fill="none";break}}else delete o.gradient,delete c.gradient,!t.is(c.opacity,"undefined")&&t.is(o.opacity,"undefined")&&_e(r,{opacity:c.opacity}),!t.is(c["fill-opacity"],"undefined")&&t.is(o["fill-opacity"],"undefined")&&_e(r,{"fill-opacity":c["fill-opacity"]});A[a]("opacity")&&_e(r,{"fill-opacity":A.opacity>1?A.opacity/100:A.opacity});case"stroke":A=t.getRGB(v),e(r,u,A.hex),"stroke"==u&&A[a]("opacity")&&_e(r,{"stroke-opacity":A.opacity>1?A.opacity/100:A.opacity});break;case"gradient":({circle:1,ellipse:1}[a](n.type)||"r"!=g(v).charAt())&&Te(r,v,n.paper);break;case"opacity":c.gradient&&!c[a]("stroke-opacity")&&_e(r,{"stroke-opacity":v>1?v/100:v});case"fill-opacity":if(c.gradient){var N=l.getElementById(r.getAttribute(P)[G](/^url\(#|\)$/g,f));if(N){var F=N.getElementsByTagName("stop");e(F[F[y]-1],"stop-opacity",v)}break}default:"font-size"==u&&(v=z(v,10)+"px");var D=u[G](/(\-.)/g,(function(e){return H.call(e.substring(1))}));r.style[D]=v,e(r,u,v)}}Ae(n,o),h?n.rotate(h.join(m)):B(p)&&n.rotate(p,!0)},Ae=function(e,n){if("text"==e.type&&(n[a]("text")||n[a]("font")||n[a]("font-size")||n[a]("x")||n[a]("y"))){var s=e.attrs,o=e.node,i=o.firstChild?z(l.defaultView.getComputedStyle(o.firstChild,f).getPropertyValue("font-size"),10):10;if(n[a]("text")){for(s.text=n.text;o.firstChild;)o.removeChild(o.firstChild);for(var r=g(n.text).split("\n"),c=0,p=r[y];c<p;c++)if(r[c]){var d=_e("tspan");c&&_e(d,{dy:1.2*i,x:s.x}),d.appendChild(l.createTextNode(r[c])),o.appendChild(d)}}else for(c=0,p=(r=o.getElementsByTagName("tspan"))[y];c<p;c++)c&&_e(r[c],{dy:1.2*i,x:s.x});_e(o,{y:s.y});var h=e.getBBox(),u=s.y-(h.y+h.height/2);u&&t.is(u,"finite")&&_e(o,{y:s.y+u})}},Ne=function(e,n){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.paper=n,this.attrs=this.attrs||{},this.transformations=[],this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1},!n.bottom&&(n.bottom=this),this.prev=n.top,n.top&&(n.top.next=this),n.top=this,this.next=null},Re=Ne[r];Ne[r].rotate=function(e,n,o){if(this.removed)return this;if(null==e)return this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(m):this._.rt.deg;var i=this.getBBox();return(e=g(e).split(s))[y]-1&&(n=B(e[1]),o=B(e[2])),e=B(e[0]),null!=n&&!1!==n?this._.rt.deg=e:this._.rt.deg+=e,null==o&&(n=null),this._.rt.cx=n,this._.rt.cy=o,n=null==n?i.x+i.width/2:n,o=null==o?i.y+i.height/2:o,this._.rt.deg?(this.transformations[0]=t.format("rotate({0} {1} {2})",this._.rt.deg,n,o),this.clip&&_e(this.clip,{transform:t.format("rotate({0} {1} {2})",-this._.rt.deg,n,o)})):(this.transformations[0]=f,this.clip&&_e(this.clip,{transform:f})),_e(this.node,{transform:this.transformations.join(m)}),this},Ne[r].hide=function(){return!this.removed&&(this.node.style.display="none"),this},Ne[r].show=function(){return!this.removed&&(this.node.style.display=""),this},Ne[r].remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this)delete this[e];this.removed=!0}},Ne[r].getBBox=function(){if(this.removed)return this;if("path"==this.type)return ae(this.attrs.path);if("none"==this.node.style.display){this.show();var e=!0}var t={};try{t=this.node.getBBox()}catch(e){}finally{t=t||{}}if("text"==this.type){t={x:t.x,y:1/0,width:0,height:0};for(var n=0,s=this.node.getNumberOfChars();n<s;n++){var o=this.node.getExtentOfChar(n);o.y<t.y&&(t.y=o.y),o.y+o.height-t.y>t.height&&(t.height=o.y+o.height-t.y),o.x+o.width-t.x>t.width&&(t.width=o.x+o.width-t.x)}}return e&&this.hide(),t},Ne[r].attr=function(e,n){if(this.removed)return this;if(null==e){var s={};for(var o in this.attrs)this.attrs[a](o)&&(s[o]=this.attrs[o]);return this._.rt.deg&&(s.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(s.scale=this.scale()),s.gradient&&"none"==s.fill&&(s.fill=s.gradient)&&delete s.gradient,s}if(null==n&&t.is(e,T))return"translation"==e?gt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(null==n&&t.is(e,I)){for(var i={},r=0,l=e.length;r<l;r++)i[e[r]]=this.attr(e[r]);return i}if(null!=n){var c={};c[e]=n}else null!=e&&t.is(e,"object")&&(c=e);for(var p in this.paper.customAttributes)if(this.paper.customAttributes[a](p)&&c[a](p)&&t.is(this.paper.customAttributes[p],"function")){var d=this.paper.customAttributes[p].apply(this,[].concat(c[p]));for(var h in this.attrs[p]=c[p],d)d[a](h)&&(c[h]=d[h])}return Pe(this,c),this},Ne[r].toFront=function(){if(this.removed)return this;this.node.parentNode.appendChild(this.node);var e=this.paper;return e.top!=this&&Ce(this,e),this},Ne[r].toBack=function(){return this.removed||this.node.parentNode.firstChild!=this.node&&(this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild),we(this,this.paper),this.paper),this},Ne[r].insertAfter=function(e){if(this.removed)return this;var t=e.node||e[e.length-1].node;return t.nextSibling?t.parentNode.insertBefore(this.node,t.nextSibling):t.parentNode.appendChild(this.node),ke(this,e,this.paper),this},Ne[r].insertBefore=function(e){if(this.removed)return this;var t=e.node||e[0].node;return t.parentNode.insertBefore(this.node,t),Se(this,e,this.paper),this},Ne[r].blur=function(e){var t=this;if(0!=+e){var n=_e("filter"),s=_e("feGaussianBlur");t.attrs.blur=e,n.id=te(),_e(s,{stdDeviation:+e||1.5}),n.appendChild(s),t.paper.defs.appendChild(n),t._blur=n,_e(t.node,{filter:"url(#"+n.id+")"})}else t._blur&&(t._blur.parentNode.removeChild(t._blur),delete t._blur,delete t.attrs.blur),t.node.removeAttribute("filter")};var Fe=function(e,t,n,s){var o=_e("circle");e.canvas&&e.canvas.appendChild(o);var i=new Ne(o,e);return i.attrs={cx:t,cy:n,r:s,fill:"none",stroke:"#000"},i.type="circle",_e(o,i.attrs),i},De=function(e,t,n,s,o,i){var r=_e("rect");e.canvas&&e.canvas.appendChild(r);var a=new Ne(r,e);return a.attrs={x:t,y:n,width:s,height:o,r:i||0,rx:i||0,ry:i||0,fill:"none",stroke:"#000"},a.type="rect",_e(r,a.attrs),a},Oe=function(e,t,n,s,o){var i=_e("ellipse");e.canvas&&e.canvas.appendChild(i);var r=new Ne(i,e);return r.attrs={cx:t,cy:n,rx:s,ry:o,fill:"none",stroke:"#000"},r.type="ellipse",_e(i,r.attrs),r},Le=function(e,t,n,s,o,i){var r=_e("image");_e(r,{x:n,y:s,width:o,height:i,preserveAspectRatio:"none"}),r.setAttributeNS(e.xlink,"href",t),e.canvas&&e.canvas.appendChild(r);var a=new Ne(r,e);return a.attrs={x:n,y:s,width:o,height:i,src:t},a.type="image",a},Be=function(e,t,n,s){var o=_e("text");_e(o,{x:t,y:n,"text-anchor":"middle"}),e.canvas&&e.canvas.appendChild(o);var i=new Ne(o,e);return i.attrs={x:t,y:n,"text-anchor":"middle",text:s,font:W.font,stroke:"none",fill:"#000"},i.type="text",Pe(i,i.attrs),i},ze=function(t,n){return this.width=t||this.width,this.height=n||this.height,e(this.canvas,"width",this.width),e(this.canvas,"height",this.height),this},qe=function(){var e=be[h](0,arguments),n=e&&e.container,s=e.x,o=e.y,i=e.width,r=e.height;if(!n)throw new Error("SVG container not found.");var a=_e("svg");return s=s||0,o=o||0,_e(a,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:i=i||512,height:r=r||342}),1==n?(a.style.cssText="position:absolute;left:"+s+"px;top:"+o+"px",l.body.appendChild(a)):n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),(n=new d).width=i,n.height=r,n.canvas=a,ye.call(n,n,t.fn),n.clear(),n};n.clear=function(){for(var e=this.canvas;e.firstChild;)e.removeChild(e.firstChild);this.bottom=this.top=null,(this.desc=_e("desc")).appendChild(l.createTextNode("Created with Raphaël")),e.appendChild(this.desc),e.appendChild(this.defs=_e("defs"))},n.remove=function(){for(var e in this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Ee(e)}}if(t.vml){var He,We={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},Ue=/([clmz]),?([^clmz]*)/gi,Ge=/ progid:\S+Blur\([^\)]+\)/g,Ve=/-?[^,\s-]+/g,je="1000 1000",Ye=10,Xe={path:1,rect:1};function Ct(e,n,s,o,i){return i?t.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",e+i,n,s-2*i,i,-i,o-2*i,2*i-s,2*i-o):t.format("M{0},{1}l{2},0,0,{3},{4},0z",e,n,s,o,-s)}t.toString=function(){return"Your browser doesn’t support SVG. Falling down to VML.\nYou are running Raphaël "+this.version},Me=function(e,t){var n=He("group");n.style.cssText="position:absolute;left:0;top:0;width:"+t.width+"px;height:"+t.height+"px",n.coordsize=t.coordsize,n.coordorigin=t.coordorigin;var s=He("shape"),o=s.style;o.width=t.width+"px",o.height=t.height+"px",s.coordsize=je,s.coordorigin=t.coordorigin,n.appendChild(s);var i=new Ne(s,n,t),r={fill:"none",stroke:"#000"};return e&&(r.path=e),i.type="path",i.path=[],i.Path=f,Pe(i,r),t.canvas.appendChild(n),i},Pe=function(e,n){e.attrs=e.attrs||{};var o,i=e.node,r=e.attrs,c=i.style,p=(n.x!=r.x||n.y!=r.y||n.width!=r.width||n.height!=r.height||n.r!=r.r)&&"rect"==e.type,d=e;for(var h in n)n[a](h)&&(r[h]=n[h]);if(p&&(r.path=Ct(r.x,r.y,r.width,r.height,r.r),e.X=r.x,e.Y=r.y,e.W=r.width,e.H=r.height),n.href&&(i.href=n.href),n.title&&(i.title=n.title),n.target&&(i.target=n.target),n.cursor&&(c.cursor=n.cursor),"blur"in n&&e.blur(n.blur),(n.path&&"path"==e.type||p)&&(i.path=function(e){var t=/[ahqstv]/gi,n=pe;if(g(e).match(t)&&(n=ge),t=/[clmz]/g,n==pe&&!g(e).match(t)){var s=g(e)[G](Ue,(function(e,t,n){var s=[],o="m"==x.call(t),i=We[t];return n[G](Ve,(function(e){o&&2==s[y]&&(i+=s+We["m"==t?"l":"L"],s=[]),s[N](L(e*Ye))})),i+s}));return s}var o,i,r=n(e);s=[];for(var a=0,l=r[y];a<l;a++){o=r[a],"z"==(i=x.call(r[a][0]))&&(i="x");for(var c=1,p=o[y];c<p;c++)i+=L(o[c]*Ye)+(c!=p-1?",":f);s[N](i)}return s.join(m)}(r.path)),null!=n.rotation&&e.rotate(n.rotation,!0),n.translation&&(o=g(n.translation).split(s),gt.call(e,o[0],o[1]),null!=e._.rt.cx&&(e._.rt.cx+=+o[0],e._.rt.cy+=+o[1],e.setBox(e.attrs,o[0],o[1]))),n.scale&&(o=g(n.scale).split(s),e.scale(+o[0]||1,+o[1]||+o[0]||1,+o[2]||null,+o[3]||null)),"clip-rect"in n){var u=g(n["clip-rect"]).split(s);if(4==u[y]){u[2]=+u[2]+ +u[0],u[3]=+u[3]+ +u[1];var v=i.clipRect||l.createElement("div"),b=v.style,C=i.parentNode;b.clip=t.format("rect({1}px {2}px {3}px {0}px)",u),i.clipRect||(b.position="absolute",b.top=0,b.left=0,b.width=e.paper.width+"px",b.height=e.paper.height+"px",C.parentNode.insertBefore(v,C),v.appendChild(C),i.clipRect=v)}n["clip-rect"]||i.clipRect&&(i.clipRect.style.clip=f)}if("image"==e.type&&n.src&&(i.src=n.src),"image"==e.type&&n.opacity&&(i.filterOpacity=q+".Alpha(opacity="+100*n.opacity+")",c.filter=(i.filterMatrix||f)+(i.filterOpacity||f)),n.font&&(c.font=n.font),n["font-family"]&&(c.fontFamily='"'+n["font-family"].split(",")[0][G](/^['"]+|['"]+$/g,f)+'"'),n["font-size"]&&(c.fontSize=n["font-size"]),n["font-weight"]&&(c.fontWeight=n["font-weight"]),n["font-style"]&&(c.fontStyle=n["font-style"]),null!=n.opacity||null!=n["stroke-width"]||null!=n.fill||null!=n.stroke||null!=n["stroke-width"]||null!=n["stroke-opacity"]||null!=n["fill-opacity"]||null!=n["stroke-dasharray"]||null!=n["stroke-miterlimit"]||null!=n["stroke-linejoin"]||null!=n["stroke-linecap"]){var S=(i=e.shape||i).getElementsByTagName(P)&&i.getElementsByTagName(P)[0],E=!1;if(!S&&(E=S=He(P)),"fill-opacity"in n||"opacity"in n){var _=((+r["fill-opacity"]+1||2)-1)*((+r.opacity+1||2)-1)*((+t.getRGB(n.fill).o+1||2)-1);_=k(w(_,0),1),S.opacity=_}if(n.fill&&(S.on=!0),null!=S.on&&"none"!=n.fill||(S.on=!1),S.on&&n.fill){var M=n.fill.match(R);M?(S.src=M[1],S.type="tile"):(S.color=t.getRGB(n.fill).hex,S.src=f,S.type="solid",t.getRGB(n.fill).error&&(d.type in{circle:1,ellipse:1}||"r"!=g(n.fill).charAt())&&Te(d,n.fill)&&(r.fill="none",r.gradient=n.fill))}E&&i.appendChild(S);var T=i.getElementsByTagName("stroke")&&i.getElementsByTagName("stroke")[0],I=!1;!T&&(I=T=He("stroke")),(n.stroke&&"none"!=n.stroke||n["stroke-width"]||null!=n["stroke-opacity"]||n["stroke-dasharray"]||n["stroke-miterlimit"]||n["stroke-linejoin"]||n["stroke-linecap"])&&(T.on=!0),("none"==n.stroke||null==T.on||0==n.stroke||0==n["stroke-width"])&&(T.on=!1);var A=t.getRGB(n.stroke);T.on&&n.stroke&&(T.color=A.hex),_=((+r["stroke-opacity"]+1||2)-1)*((+r.opacity+1||2)-1)*((+A.o+1||2)-1);var F=.75*(B(n["stroke-width"])||1);if(_=k(w(_,0),1),null==n["stroke-width"]&&(F=r["stroke-width"]),n["stroke-width"]&&(T.weight=F),F&&F<1&&(_*=F)&&(T.weight=1),T.opacity=_,n["stroke-linejoin"]&&(T.joinstyle=n["stroke-linejoin"]||"miter"),T.miterlimit=n["stroke-miterlimit"]||8,n["stroke-linecap"]&&(T.endcap="butt"==n["stroke-linecap"]?"flat":"square"==n["stroke-linecap"]?"square":"round"),n["stroke-dasharray"]){var D={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};T.dashstyle=D[a](n["stroke-dasharray"])?D[n["stroke-dasharray"]]:f}I&&i.appendChild(T)}if("text"==d.type)switch(c=d.paper.span.style,r.font&&(c.font=r.font),r["font-family"]&&(c.fontFamily=r["font-family"]),r["font-size"]&&(c.fontSize=r["font-size"]),r["font-weight"]&&(c.fontWeight=r["font-weight"]),r["font-style"]&&(c.fontStyle=r["font-style"]),d.node.string&&(d.paper.span.innerHTML=g(d.node.string)[G](/</g,"<")[G](/&/g,"&")[G](/\n/g,"<br>")),d.W=r.w=d.paper.span.offsetWidth,d.H=r.h=d.paper.span.offsetHeight,d.X=r.x,d.Y=r.y+L(d.H/2),r["text-anchor"]){case"start":d.node.style["v-text-align"]="left",d.bbx=L(d.W/2);break;case"end":d.node.style["v-text-align"]="right",d.bbx=-L(d.W/2);break;default:d.node.style["v-text-align"]="center"}},Te=function(e,t){e.attrs=e.attrs||{},e.attrs;var n,s="linear",o=".5 .5";if(e.attrs.gradient=t,t=(t=g(t)[G](Z,(function(e,t,n){return s="radial",t&&n&&(t=B(t),n=B(n),E(t-.5,2)+E(n-.5,2)>.25&&(n=C.sqrt(.25-E(t-.5,2))*(2*(n>.5)-1)+.5),o=t+m+n),f}))).split(/\s*\-\s*/),"linear"==s){var i=t.shift();if(i=-B(i),isNaN(i))return null}var r=ve(t);if(!r)return null;if(!(n=(e=e.shape||e.node).getElementsByTagName(P)[0]||He(P)).parentNode&&e.appendChild(n),r[y]){n.on=!0,n.method="none",n.color=r[0].color,n.color2=r[r[y]-1].color;for(var a=[],l=0,c=r[y];l<c;l++)r[l].offset&&a[N](r[l].offset+m+r[l].color);n.colors&&(n.colors.value=a[y]?a.join():"0% "+n.color),"radial"==s?(n.type="gradientradial",n.focus="100%",n.focussize=o,n.focusposition=o):(n.type="gradient",n.angle=(270-i)%360)}return 1},(Re=(Ne=function(e,n,s){this[0]=e,this.id=t._oid++,this.node=e,e.raphael=this,this.X=0,this.Y=0,this.attrs={},this.Group=n,this.paper=s,this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1},!s.bottom&&(s.bottom=this),this.prev=s.top,s.top&&(s.top.next=this),s.top=this,this.next=null})[r]).rotate=function(e,t,n){return this.removed?this:null==e?this._.rt.cx?[this._.rt.deg,this._.rt.cx,this._.rt.cy].join(m):this._.rt.deg:((e=g(e).split(s))[y]-1&&(t=B(e[1]),n=B(e[2])),e=B(e[0]),null!=t?this._.rt.deg=e:this._.rt.deg+=e,null==n&&(t=null),this._.rt.cx=t,this._.rt.cy=n,this.setBox(this.attrs,t,n),this.Group.style.rotation=this._.rt.deg,this)},Re.setBox=function(e,t,n){if(this.removed)return this;var s=this.Group.style,o=this.shape&&this.shape.style||this.node.style;for(var i in e=e||{})e[a](i)&&(this.attrs[i]=e[i]);t=t||this._.rt.cx,n=n||this._.rt.cy;var r,l,c,p,d=this.attrs;switch(this.type){case"circle":r=d.cx-d.r,l=d.cy-d.r,c=p=2*d.r;break;case"ellipse":r=d.cx-d.rx,l=d.cy-d.ry,c=2*d.rx,p=2*d.ry;break;case"image":r=+d.x,l=+d.y,c=d.width||0,p=d.height||0;break;case"text":this.textpath.v=["m",L(d.x),", ",L(d.y-2),"l",L(d.x)+1,", ",L(d.y-2)].join(f),r=d.x-L(this.W/2),l=d.y-this.H/2,c=this.W,p=this.H;break;case"rect":case"path":if(this.attrs.path){var h=ae(this.attrs.path);r=h.x,l=h.y,c=h.width,p=h.height}else r=0,l=0,c=this.paper.width,p=this.paper.height;break;default:r=0,l=0,c=this.paper.width,p=this.paper.height}n=null==n?l+p/2:n;var u,m=(t=null==t?r+c/2:t)-this.paper.width/2,g=n-this.paper.height/2;s.left!=(u=m+"px")&&(s.left=u),s.top!=(u=g+"px")&&(s.top=u),this.X=Xe[a](this.type)?-m:r,this.Y=Xe[a](this.type)?-g:l,this.W=c,this.H=p,Xe[a](this.type)?(o.left!=(u=-m*Ye+"px")&&(o.left=u),o.top!=(u=-g*Ye+"px")&&(o.top=u)):"text"==this.type?(o.left!=(u=-m+"px")&&(o.left=u),o.top!=(u=-g+"px")&&(o.top=u)):(s.width!=(u=this.paper.width+"px")&&(s.width=u),s.height!=(u=this.paper.height+"px")&&(s.height=u),o.left!=(u=r-m+"px")&&(o.left=u),o.top!=(u=l-g+"px")&&(o.top=u),o.width!=(u=c+"px")&&(o.width=u),o.height!=(u=p+"px")&&(o.height=u))},Re.hide=function(){return!this.removed&&(this.Group.style.display="none"),this},Re.show=function(){return!this.removed&&(this.Group.style.display="block"),this},Re.getBBox=function(){return this.removed?this:Xe[a](this.type)?ae(this.attrs.path):{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H}},Re.remove=function(){if(!this.removed){for(var e in xe(this,this.paper),this.node.parentNode.removeChild(this.node),this.Group.parentNode.removeChild(this.Group),this.shape&&this.shape.parentNode.removeChild(this.shape),this)delete this[e];this.removed=!0}},Re.attr=function(e,n){if(this.removed)return this;if(null==e){var s={};for(var o in this.attrs)this.attrs[a](o)&&(s[o]=this.attrs[o]);return this._.rt.deg&&(s.rotation=this.rotate()),(1!=this._.sx||1!=this._.sy)&&(s.scale=this.scale()),s.gradient&&"none"==s.fill&&(s.fill=s.gradient)&&delete s.gradient,s}if(null==n&&t.is(e,"string"))return"translation"==e?gt.call(this):"rotation"==e?this.rotate():"scale"==e?this.scale():e==P&&"none"==this.attrs.fill&&this.attrs.gradient?this.attrs.gradient:this.attrs[e];if(this.attrs&&null==n&&t.is(e,I)){var i,r={};for(o=0,i=e[y];o<i;o++)r[e[o]]=this.attr(e[o]);return r}var l;if(null!=n&&((l={})[e]=n),null==n&&t.is(e,"object")&&(l=e),l){for(var c in this.paper.customAttributes)if(this.paper.customAttributes[a](c)&&l[a](c)&&t.is(this.paper.customAttributes[c],"function")){var p=this.paper.customAttributes[c].apply(this,[].concat(l[c]));for(var d in this.attrs[c]=l[c],p)p[a](d)&&(l[d]=p[d])}l.text&&"text"==this.type&&(this.node.string=l.text),Pe(this,l),l.gradient&&({circle:1,ellipse:1}[a](this.type)||"r"!=g(l.gradient).charAt())&&Te(this,l.gradient),(!Xe[a](this.type)||this._.rt.deg)&&this.setBox(this.attrs)}return this},Re.toFront=function(){return!this.removed&&this.Group.parentNode.appendChild(this.Group),this.paper.top!=this&&Ce(this,this.paper),this},Re.toBack=function(){return this.removed||this.Group.parentNode.firstChild!=this.Group&&(this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild),we(this,this.paper)),this},Re.insertAfter=function(e){return this.removed||(e.constructor==yt&&(e=e[e.length-1]),e.Group.nextSibling?e.Group.parentNode.insertBefore(this.Group,e.Group.nextSibling):e.Group.parentNode.appendChild(this.Group),ke(this,e,this.paper)),this},Re.insertBefore=function(e){return this.removed||(e.constructor==yt&&(e=e[0]),e.Group.parentNode.insertBefore(this.Group,e.Group),Se(this,e,this.paper)),this},Re.blur=function(e){var n=this.node.runtimeStyle,s=n.filter;s=s.replace(Ge,f),0!=+e?(this.attrs.blur=e,n.filter=s+m+q+".Blur(pixelradius="+(+e||1.5)+")",n.margin=t.format("-{0}px 0 0 -{0}px",L(+e||1.5))):(n.filter=s,n.margin=0,delete this.attrs.blur)},Fe=function(e,t,n,s){var o=He("group"),i=He("oval");i.style,o.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",o.coordsize=je,o.coordorigin=e.coordorigin,o.appendChild(i);var r=new Ne(i,o,e);return r.type="circle",Pe(r,{stroke:"#000",fill:"none"}),r.attrs.cx=t,r.attrs.cy=n,r.attrs.r=s,r.setBox({x:t-s,y:n-s,width:2*s,height:2*s}),e.canvas.appendChild(o),r},De=function(e,t,n,s,o,i){var r=Ct(t,n,s,o,i),a=e.path(r),l=a.attrs;return a.X=l.x=t,a.Y=l.y=n,a.W=l.width=s,a.H=l.height=o,l.r=i,l.path=r,a.type="rect",a},Oe=function(e,t,n,s,o){var i=He("group"),r=He("oval");r.style,i.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",i.coordsize=je,i.coordorigin=e.coordorigin,i.appendChild(r);var a=new Ne(r,i,e);return a.type="ellipse",Pe(a,{stroke:"#000"}),a.attrs.cx=t,a.attrs.cy=n,a.attrs.rx=s,a.attrs.ry=o,a.setBox({x:t-s,y:n-o,width:2*s,height:2*o}),e.canvas.appendChild(i),a},Le=function(e,t,n,s,o,i){var r=He("group"),a=He("image");r.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",r.coordsize=je,r.coordorigin=e.coordorigin,a.src=t,r.appendChild(a);var l=new Ne(a,r,e);return l.type="image",l.attrs.src=t,l.attrs.x=n,l.attrs.y=s,l.attrs.w=o,l.attrs.h=i,l.setBox({x:n,y:s,width:o,height:i}),e.canvas.appendChild(r),l},Be=function(e,n,s,o){var i=He("group"),r=He("shape"),a=r.style,l=He("path");l.style;var c=He("textpath");i.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px",i.coordsize=je,i.coordorigin=e.coordorigin,l.v=t.format("m{0},{1}l{2},{1}",L(10*n),L(10*s),L(10*n)+1),l.textpathok=!0,a.width=e.width,a.height=e.height,c.string=g(o),c.on=!0,r.appendChild(c),r.appendChild(l),i.appendChild(r);var p=new Ne(c,i,e);return p.shape=r,p.textpath=l,p.type="text",p.attrs.text=o,p.attrs.x=n,p.attrs.y=s,p.attrs.w=1,p.attrs.h=1,Pe(p,{font:W.font,stroke:"none",fill:"#000"}),p.setBox(),e.canvas.appendChild(i),p},ze=function(e,t){var n=this.canvas.style;return e==+e&&(e+="px"),t==+t&&(t+="px"),n.width=e,n.height=t,n.clip="rect(0 "+e+" "+t+" 0)",this},l.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!l.namespaces.rvml&&l.namespaces.add("rvml","urn:schemas-microsoft-com:vml"),He=function(e){return l.createElement("<rvml:"+e+' class="rvml">')}}catch(wt){He=function(e){return l.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}qe=function(){var e=be[h](0,arguments),n=e.container,s=e.height,o=e.width,i=e.x,r=e.y;if(!n)throw new Error("VML container not found.");var a=new d,c=a.canvas=l.createElement("div"),p=c.style;return i=i||0,r=r||0,(o=o||512)==+o&&(o+="px"),(s=s||342)==+s&&(s+="px"),a.width=1e3,a.height=1e3,a.coordsize="10000 10000",a.coordorigin="0 0",a.span=l.createElement("span"),a.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",c.appendChild(a.span),p.cssText=t.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",o,s),1==n?(l.body.appendChild(c),p.left=i+"px",p.top=r+"px",p.position="absolute"):n.firstChild?n.insertBefore(c,n.firstChild):n.appendChild(c),ye.call(a,a,t.fn),a},n.clear=function(){this.canvas.innerHTML=f,this.span=l.createElement("span"),this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;",this.canvas.appendChild(this.span),this.bottom=this.top=null},n.remove=function(){for(var e in this.canvas.parentNode.removeChild(this.canvas),this)this[e]=Ee(e);return!0}}var $e=navigator.userAgent.match(/Version\/(.*?)\s/);"Apple Computer, Inc."==navigator.vendor&&($e&&$e[1]<4||"iP"==navigator.platform.slice(0,2))?n.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});c.setTimeout((function(){e.remove()}))}:n.safari=function(){};for(var Ke=function(){this.returnValue=!1},Ze=function(){return this.originalEvent.preventDefault()},Je=function(){this.cancelBubble=!0},Qe=function(){return this.originalEvent.stopPropagation()},et=l.addEventListener?function(e,t,n,s){var o=u&&b[t]?b[t]:t,i=function(o){if(u&&b[a](t))for(var i=0,r=o.targetTouches&&o.targetTouches.length;i<r;i++)if(o.targetTouches[i].target==e){var l=o;(o=o.targetTouches[i]).originalEvent=l,o.preventDefault=Ze,o.stopPropagation=Qe;break}return n.call(s,o)};return e.addEventListener(o,i,!1),function(){return e.removeEventListener(o,i,!1),!0}}:l.attachEvent?function(e,t,n,s){var o=function(e){return(e=e||c.event).preventDefault=e.preventDefault||Ke,e.stopPropagation=e.stopPropagation||Je,n.call(s,e)};return e.attachEvent("on"+t,o),function(){return e.detachEvent("on"+t,o),!0}}:void 0,tt=[],nt=function(e){for(var t,n=e.clientX,s=e.clientY,o=l.documentElement.scrollTop||l.body.scrollTop,i=l.documentElement.scrollLeft||l.body.scrollLeft,r=tt.length;r--;){if(t=tt[r],u){for(var a,c=e.touches.length;c--;)if((a=e.touches[c]).identifier==t.el._drag.id){n=a.clientX,s=a.clientY,(e.originalEvent?e.originalEvent:e).preventDefault();break}}else e.preventDefault();n+=i,s+=o,t.move&&t.move.call(t.move_scope||t.el,n-t.el._drag.x,s-t.el._drag.y,n,s,e)}},st=function(e){t.unmousemove(nt).unmouseup(st);for(var n,s=tt.length;s--;)(n=tt[s]).el._drag={},n.end&&n.end.call(n.end_scope||n.start_scope||n.move_scope||n.el,e);tt=[]},ot=v[y];ot--;)!function(e){t[e]=Ne[r][e]=function(n,s){return t.is(n,"function")&&(this.events=this.events||[],this.events.push({name:e,f:n,unbind:et(this.shape||this.node||l,e,n,s||this)})),this},t["un"+e]=Ne[r]["un"+e]=function(t){for(var n=this.events,s=n[y];s--;)if(n[s].name==e&&n[s].f==t)return n[s].unbind(),n.splice(s,1),!n.length&&delete this.events,this;return this}}(v[ot]);function it(){return this.x+m+this.y}Re.hover=function(e,t,n,s){return this.mouseover(e,n).mouseout(t,s||n)},Re.unhover=function(e,t){return this.unmouseover(e).unmouseout(t)},Re.drag=function(e,n,s,o,i,r){return this._drag={},this.mousedown((function(a){(a.originalEvent||a).preventDefault();var c=l.documentElement.scrollTop||l.body.scrollTop,p=l.documentElement.scrollLeft||l.body.scrollLeft;this._drag.x=a.clientX+p,this._drag.y=a.clientY+c,this._drag.id=a.identifier,n&&n.call(i||o||this,a.clientX+p,a.clientY+c,a),!tt.length&&t.mousemove(nt).mouseup(st),tt.push({el:this,move:e,end:s,move_scope:o,start_scope:i,end_scope:r})})),this},Re.undrag=function(e,n,s){for(var o=tt.length;o--;)tt[o].el==this&&tt[o].move==e&&tt[o].end==s&&tt.splice(o++,1);!tt.length&&t.unmousemove(nt).unmouseup(st)},n.circle=function(e,t,n){return Fe(this,e||0,t||0,n||0)},n.rect=function(e,t,n,s,o){return De(this,e||0,t||0,n||0,s||0,o||0)},n.ellipse=function(e,t,n,s){return Oe(this,e||0,t||0,n||0,s||0)},n.path=function(e){return e&&!t.is(e,T)&&!t.is(e[0],I)&&(e+=f),Me(t.format[h](t,arguments),this)},n.image=function(e,t,n,s,o){return Le(this,e||"about:blank",t||0,n||0,s||0,o||0)},n.text=function(e,t,n){return Be(this,e||0,t||0,g(n))},n.set=function(e){return arguments[y]>1&&(e=Array[r].splice.call(arguments,0,arguments[y])),new yt(e)},n.setSize=ze,n.top=n.bottom=null,n.raphael=t,Re.resetScale=function(){if(this.removed)return this;this._.sx=1,this._.sy=1,this.attrs.scale="1 1"},Re.scale=function(t,n,s,o){if(this.removed)return this;if(null==t&&null==n)return{x:this._.sx,y:this._.sy,toString:it};!+(n=n||t)&&(n=t);var i,r,a=this.attrs;if(0!=t){var l=this.getBBox(),c=l.x+l.width/2,p=l.y+l.height/2,d=S(t/this._.sx),h=S(n/this._.sy);s=+s||0==s?s:c,o=+o||0==o?o:p;var u=this._.sx>0,g=this._.sy>0,v=~~(t/S(t)),b=~~(n/S(n)),x=d*v,C=h*b,w=this.node.style,k=s+S(c-s)*x*(c>s==u?1:-1),E=o+S(p-o)*C*(p>o==g?1:-1),_=t*v>n*b?h:d;switch(this.type){case"rect":case"image":var M=a.width*d,T=a.height*h;this.attr({height:T,r:a.r*_,width:M,x:k-M/2,y:E-T/2});break;case"circle":case"ellipse":this.attr({rx:a.rx*d,ry:a.ry*h,r:a.r*_,cx:k,cy:E});break;case"text":this.attr({x:k,y:E});break;case"path":for(var I=ce(a.path),P=!0,A=u?x:d,N=g?C:h,R=0,F=I[y];R<F;R++){var D=I[R],O=H.call(D[0]);if("M"!=O||!P)if(P=!1,"A"==O)D[I[R][y]-2]*=A,D[I[R][y]-1]*=N,D[1]*=d,D[2]*=h,D[5]=+(v+b?!!+D[5]:!+D[5]);else if("H"==O)for(var L=1,B=D[y];L<B;L++)D[L]*=A;else if("V"==O)for(L=1,B=D[y];L<B;L++)D[L]*=N;else for(L=1,B=D[y];L<B;L++)D[L]*=L%2?A:N}var z=ae(I);i=k-z.x-z.width/2,r=E-z.y-z.height/2,I[0][1]+=i,I[0][2]+=r,this.attr({path:I})}!(this.type in{text:1,image:1})||1==v&&1==b?this.transformations?(this.transformations[2]=f,e(this.node,"transform",this.transformations.join(m)),a.fx=0,a.fy=0):(this.node.filterMatrix=f,w.filter=(this.node.filterMatrix||f)+(this.node.filterOpacity||f)):this.transformations?(this.transformations[2]="scale(".concat(v,",",b,")"),e(this.node,"transform",this.transformations.join(m)),i=-1==v?-a.x-(M||0):a.x,r=-1==b?-a.y-(T||0):a.y,this.attr({x:i,y:r}),a.fx=v-1,a.fy=b-1):(this.node.filterMatrix=q+".Matrix(M11=".concat(v,", M12=0, M21=0, M22=",b,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')"),w.filter=(this.node.filterMatrix||f)+(this.node.filterOpacity||f)),a.scale=[t,n,s,o].join(m),this._.sx=t,this._.sy=n}return this},Re.clone=function(){if(this.removed)return null;var e=this.attr();return delete e.scale,delete e.translation,this.paper[this.type]().attr(e)};var rt={},at=function(e,n,s,o,i,r,a,l,c){if(e===s&&n===o&&i===a&&r==l){var p=a-e,d=l-n,h=Math.sqrt(p*p+d*d);if(null==c)return h;var u=c/h;return{start:{x:e,y:n},m:{x:e,y:n},n:{x:a,y:l},end:{x:a,y:l},x:e+u*p,y:n+u*d,alpha:90-180*C.atan(p/d)/_}}var f,m,g=0,v=100,b=[e,n,s,o,i,r,a,l].join(),y=rt[b];(!y&&(rt[b]=y={data:[]}),y.timer&&clearTimeout(y.timer),y.timer=setTimeout((function(){delete rt[b]}),2e3),null!=c)&&(v=10*~~at(e,n,s,o,i,r,a,l));for(var x=0;x<v+1;x++){if(y.data[c]>x?m=y.data[x*v]:(m=t.findDotsAtSegment(e,n,s,o,i,r,a,l,x/v),y.data[x]=m),x&&(g+=E(E(f.x-m.x,2)+E(f.y-m.y,2),.5)),null!=c&&g>=c)return m;f=m}if(null==c)return g},lt=function(e,n){return function(s,o,i){for(var r,a,l,c,p,d="",h={},u=0,f=0,m=(s=ge(s)).length;f<m;f++){if("M"==(l=s[f])[0])r=+l[1],a=+l[2];else{if(u+(c=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6]))>o){if(n&&!h.start){if(d+=["C",(p=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6],o-u)).start.x,p.start.y,p.m.x,p.m.y,p.x,p.y],i)return d;h.start=d,d=["M",p.x,p.y+"C",p.n.x,p.n.y,p.end.x,p.end.y,l[5],l[6]].join(),u+=c,r=+l[5],a=+l[6];continue}if(!e&&!n)return{x:(p=at(r,a,l[1],l[2],l[3],l[4],l[5],l[6],o-u)).x,y:p.y,alpha:p.alpha}}u+=c,r=+l[5],a=+l[6]}d+=l}return h.end=d,(p=e?u:n?h:t.findDotsAtSegment(r,a,l[1],l[2],l[3],l[4],l[5],l[6],1)).alpha&&(p={x:p.x,y:p.y,alpha:p.alpha}),p}},ct=lt(1),pt=lt(),dt=lt(0,1);Re.getTotalLength=function(){if("path"==this.type)return this.node.getTotalLength?this.node.getTotalLength():ct(this.attrs.path)},Re.getPointAtLength=function(e){if("path"==this.type)return pt(this.attrs.path,e)},Re.getSubpath=function(e,t){if("path"==this.type){if(S(this.getTotalLength()-t)<"1e-6")return dt(this.attrs.path,e).end;var n=dt(this.attrs.path,t,1);return e?dt(n,e).end:n}},t.easing_formulas={linear:function(e){return e},"<":function(e){return E(e,3)},">":function(e){return E(e-1,3)+1},"<>":function(e){return(e*=2)<1?E(e,3)/2:(E(e-=2,3)+2)/2},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return(e-=1)*e*((t+1)*e+t)+1},elastic:function(e){if(0==e||1==e)return e;return E(2,-10*e)*C.sin(2*_*(e-.075)/.3)+1},bounce:function(e){var t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375}};var ht=[],ut=function(){for(var e=+new Date,n=0;n<ht[y];n++){var s=ht[n];if(!s.stop&&!s.el.removed){var o,i=e-s.start,r=s.ms,l=s.easing,c=s.from,p=s.diff,d=s.to,h=s.t,u=s.el,g={};if(i<r){var v=l(i/r);for(var b in c)if(c[a](b)){switch(U[b]){case"along":o=v*r*p[b],d.back&&(o=d.len-o);var x=pt(d[b],o);u.translate(p.sx-p.x||0,p.sy-p.y||0),p.x=x.x,p.y=x.y,u.translate(x.x-p.sx,x.y-p.sy),d.rot&&u.rotate(p.r+x.alpha,x.x,x.y);break;case M:o=+c[b]+v*r*p[b];break;case"colour":o="rgb("+[mt(L(c[b].r+v*r*p[b].r)),mt(L(c[b].g+v*r*p[b].g)),mt(L(c[b].b+v*r*p[b].b))].join(",")+")";break;case"path":o=[];for(var C=0,w=c[b][y];C<w;C++){o[C]=[c[b][C][0]];for(var k=1,S=c[b][C][y];k<S;k++)o[C][k]=+c[b][C][k]+v*r*p[b][C][k];o[C]=o[C].join(m)}o=o.join(m);break;case"csv":switch(b){case"translation":var E=v*r*p[b][0]-h.x,_=v*r*p[b][1]-h.y;h.x+=E,h.y+=_,o=E+m+_;break;case"rotation":o=+c[b][0]+v*r*p[b][0],c[b][1]&&(o+=","+c[b][1]+","+c[b][2]);break;case"scale":o=[+c[b][0]+v*r*p[b][0],+c[b][1]+v*r*p[b][1],2 in d[b]?d[b][2]:f,3 in d[b]?d[b][3]:f].join(m);break;case"clip-rect":for(o=[],C=4;C--;)o[C]=+c[b][C]+v*r*p[b][C]}break;default:var T=[].concat(c[b]);for(o=[],C=u.paper.customAttributes[b].length;C--;)o[C]=+T[C]+v*r*p[b][C]}g[b]=o}u.attr(g),u._run&&u._run.call(u)}else d.along&&(x=pt(d.along,d.len*!d.back),u.translate(p.sx-(p.x||0)+x.x-p.sx,p.sy-(p.y||0)+x.y-p.sy),d.rot&&u.rotate(p.r+x.alpha,x.x,x.y)),(h.x||h.y)&&u.translate(-h.x,-h.y),d.scale&&(d.scale+=f),u.attr(d),ht.splice(n--,1)}}t.svg&&u&&u.paper&&u.paper.safari(),ht[y]&&setTimeout(ut)},ft=function(e,n,s,o,i){var r=s-o;n.timeouts.push(setTimeout((function(){t.is(i,"function")&&i.call(n),n.animate(e,r,e.easing)}),o))},mt=function(e){return w(k(e,255),0)},gt=function(e,t){if(null==e)return{x:this._.tx,y:this._.ty,toString:it};switch(this._.tx+=+e,this._.ty+=+t,this.type){case"circle":case"ellipse":this.attr({cx:+e+this.attrs.cx,cy:+t+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+e+this.attrs.x,y:+t+this.attrs.y});break;case"path":var n=ce(this.attrs.path);n[0][1]+=+e,n[0][2]+=+t,this.attr({path:n})}return this};function vt(e){return function(n,s,o,i){var r={back:e};return t.is(o,"function")?i=o:r.rot=o,n&&n.constructor==Ne&&(n=n.attrs.path),n&&(r.along=n),this.animate(r,s,i)}}function bt(e,t,n,s,o,i){var r=3*t,a=3*(s-t)-r,l=1-r-a,c=3*n,p=3*(o-n)-c,d=1-c-p;function h(e){return((l*e+a)*e+r)*e}return function(e,t){var n=function(e,t){var n,s,o,i,c,p;for(o=e,p=0;p<8;p++){if(i=h(o)-e,S(i)<t)return o;if(S(c=(3*l*o+2*a)*o+r)<1e-6)break;o-=i/c}if(s=1,(o=e)<(n=0))return n;if(o>s)return s;for(;n<s;){if(i=h(o),S(i-e)<t)return o;e>i?n=o:s=o,o=(s-n)/2+n}return o}(e,t);return((d*n+p)*n+c)*n}(e,1/(200*i))}Re.animateWith=function(e,t,n,s,o){for(var i=0,r=ht.length;i<r;i++)ht[i].el.id==e.id&&(t.start=ht[i].start);return this.animate(t,n,s,o)},Re.animateAlong=vt(),Re.animateAlongBack=vt(1),Re.onAnimation=function(e){return this._run=e||0,this},Re.animate=function(e,n,o,i){var r=this;if(r.timeouts=r.timeouts||[],!t.is(o,"function")&&o||(i=o||null),r.removed)return i&&i.call(r),r;var l={},c={},p=!1,d={};for(var h in e)if(e[a](h)&&(U[a](h)||r.paper.customAttributes[a](h)))switch(p=!0,l[h]=r.attr(h),null==l[h]&&(l[h]=W[h]),c[h]=e[h],U[h]){case"along":var u=ct(e[h]),f=pt(e[h],u*!!e.back),m=r.getBBox();d[h]=u/n,d.tx=m.x,d.ty=m.y,d.sx=f.x,d.sy=f.y,c.rot=e.rot,c.back=e.back,c.len=u,e.rot&&(d.r=B(r.rotate())||0);break;case M:d[h]=(c[h]-l[h])/n;break;case"colour":l[h]=t.getRGB(l[h]);var v=t.getRGB(c[h]);d[h]={r:(v.r-l[h].r)/n,g:(v.g-l[h].g)/n,b:(v.b-l[h].b)/n};break;case"path":var b=ge(l[h],c[h]);l[h]=b[0];var x=b[1];d[h]=[];for(var C=0,w=l[h][y];C<w;C++){d[h][C]=[0];for(var k=1,S=l[h][C][y];k<S;k++)d[h][C][k]=(x[C][k]-l[h][C][k])/n}break;case"csv":var E=g(e[h]).split(s),_=g(l[h]).split(s);switch(h){case"translation":l[h]=[0,0],d[h]=[E[0]/n,E[1]/n];break;case"rotation":l[h]=_[1]==E[1]&&_[2]==E[2]?_:[0,E[1],E[2]],d[h]=[(E[0]-l[h][0])/n,0,0];break;case"scale":e[h]=E,l[h]=g(l[h]).split(s),d[h]=[(E[0]-l[h][0])/n,(E[1]-l[h][1])/n,0,0];break;case"clip-rect":for(l[h]=g(l[h]).split(s),d[h]=[],C=4;C--;)d[h][C]=(E[C]-l[h][C])/n}c[h]=E;break;default:for(E=[].concat(e[h]),_=[].concat(l[h]),d[h]=[],C=r.paper.customAttributes[h][y];C--;)d[h][C]=((E[C]||0)-(_[C]||0))/n}if(p){var T=t.easing_formulas[o];if(!T)if((T=g(o).match(O))&&5==T[y]){var I=T;T=function(e){return bt(e,+I[1],+I[2],+I[3],+I[4],n)}}else T=function(e){return e};ht.push({start:e.start||+new Date,ms:n,easing:T,from:l,diff:d,to:c,el:r,t:{x:0,y:0}}),t.is(i,"function")&&(r._ac=setTimeout((function(){i.call(r)}),n)),1==ht[y]&&setTimeout(ut)}else{var P,A=[];for(var N in e)e[a](N)&&V.test(N)&&(h={value:e[N]},"from"==N&&(N=0),"to"==N&&(N=100),h.key=z(N,10),A.push(h));for(A.sort(J),A[0].key&&A.unshift({key:0,value:r.attrs}),C=0,w=A[y];C<w;C++)ft(A[C].value,r,n/100*A[C].key,n/100*(A[C-1]&&A[C-1].key||0),A[C-1]&&A[C-1].value.callback);(P=A[A[y]-1].value.callback)&&r.timeouts.push(setTimeout((function(){P.call(r)}),n))}return this},Re.stop=function(){for(var e=0;e<ht.length;e++)ht[e].el.id==this.id&&ht.splice(e--,1);for(e=0,ii=this.timeouts&&this.timeouts.length;e<ii;e++)clearTimeout(this.timeouts[e]);return this.timeouts=[],clearTimeout(this._ac),delete this._ac,this},Re.translate=function(e,t){return this.attr({translation:e+" "+t})},Re.toString=function(){return"Raphaël’s object"},t.ae=ht;var yt=function(e){if(this.items=[],this[y]=0,this.type="set",e)for(var t=0,n=e[y];t<n;t++)!e[t]||e[t].constructor!=Ne&&e[t].constructor!=yt||(this[this.items[y]]=this.items[this.items[y]]=e[t],this[y]++)};for(var xt in yt[r][N]=function(){for(var e,t,n=0,s=arguments[y];n<s;n++)!(e=arguments[n])||e.constructor!=Ne&&e.constructor!=yt||(this[t=this.items[y]]=this.items[t]=e,this[y]++);return this},yt[r].pop=function(){return delete this[this[y]--],this.items.pop()},Re)Re[a](xt)&&(yt[r][xt]=function(e){return function(){for(var t=0,n=this.items[y];t<n;t++)this.items[t][e][h](this.items[t],arguments);return this}}(xt));yt[r].attr=function(e,n){if(e&&t.is(e,I)&&t.is(e[0],"object"))for(var s=0,o=e[y];s<o;s++)this.items[s].attr(e[s]);else for(var i=0,r=this.items[y];i<r;i++)this.items[i].attr(e,n);return this},yt[r].animate=function(e,n,s,o){(t.is(s,"function")||!s)&&(o=s||null);var i,r,a=this.items[y],l=a,c=this;for(o&&(r=function(){!--a&&o.call(c)}),s=t.is(s,T)?s:r,i=this.items[--l].animate(e,n,s,r);l--;)this.items[l]&&!this.items[l].removed&&this.items[l].animateWith(i,e,n,s,r);return this},yt[r].insertAfter=function(e){for(var t=this.items[y];t--;)this.items[t].insertAfter(e);return this},yt[r].getBBox=function(){for(var e=[],t=[],n=[],s=[],o=this.items[y];o--;){var i=this.items[o].getBBox();e[N](i.x),t[N](i.y),n[N](i.x+i.width),s[N](i.y+i.height)}return{x:e=k[h](0,e),y:t=k[h](0,t),width:w[h](0,n)-e,height:w[h](0,s)-t}},yt[r].clone=function(e){e=new yt;for(var t=0,n=this.items[y];t<n;t++)e[N](this.items[t].clone());return e},t.registerFont=function(e){if(!e.face)return e;this.fonts=this.fonts||{};var t={w:e.w,face:{},glyphs:{}},n=e.face["font-family"];for(var s in e.face)e.face[a](s)&&(t.face[s]=e.face[s]);if(this.fonts[n]?this.fonts[n][N](t):this.fonts[n]=[t],!e.svg)for(var o in t.face["units-per-em"]=z(e.face["units-per-em"],10),e.glyphs)if(e.glyphs[a](o)){var i=e.glyphs[o];if(t.glyphs[o]={w:i.w,k:{},d:i.d&&"M"+i.d[G](/[mlcxtrv]/g,(function(e){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[e]||"M"}))+"z"},i.k)for(var r in i.k)i[a](r)&&(t.glyphs[o].k[r]=i.k[r])}return e},n.getFont=function(e,n,s,o){if(o=o||"normal",s=s||"normal",n=+n||{normal:400,bold:700,lighter:300,bolder:800}[n]||400,t.fonts){var i,r=t.fonts[e];if(!r){var l=new RegExp("(^|\\s)"+e[G](/[^\w\d\s+!~.:_-]/g,f)+"(\\s|$)","i");for(var c in t.fonts)if(t.fonts[a](c)&&l.test(c)){r=t.fonts[c];break}}if(r)for(var p=0,d=r[y];p<d&&((i=r[p]).face["font-weight"]!=n||i.face["font-style"]!=s&&i.face["font-style"]||i.face["font-stretch"]!=o);p++);return i}},n.print=function(e,n,o,i,r,a,l){a=a||"middle",l=w(k(l||0,1),-1);var c,p=this.set(),d=g(o).split(f),h=0;if(t.is(i,o)&&(i=this.getFont(i)),i){c=(r||16)/i.face["units-per-em"];for(var u=i.face.bbox.split(s),m=+u[0],v=+u[1]+("baseline"==a?u[3]-u[1]+ +i.face.descent:(u[3]-u[1])/2),b=0,x=d[y];b<x;b++){var C=b&&i.glyphs[d[b-1]]||{},S=i.glyphs[d[b]];h+=b?(C.w||i.w)+(C.k&&C.k[d[b]]||0)+i.w*l:0,S&&S.d&&p[N](this.path(S.d).attr({fill:"#000",stroke:"none",translation:[h,0]}))}p.scale(c,c,m,v).translate(e-m,n-v)}return p},t.format=function(e,n){var s=t.is(n,I)?[0].concat(n):arguments;return e&&t.is(e,T)&&s[y]-1&&(e=e[G](i,(function(e,t){return null==s[++t]?f:s[t]}))),e||f},t.ninja=function(){return p.was?c.Raphael=p.is:Raphael=void 0,t},t.el=Re,t.st=yt[r],mn.exports=t}();const gn={BLUE:"#6495ED",ORANGE:"#FFA500",PINK:"#FF00AF",GREEN:"#28AE7B",PURPLE:"#9D38BD",RED:"#DF0030",GRAY:"gray",BLACK:"black",LIGHT_BLUE:"#9AB8ED",LIGHT_ORANGE:"#EDD19B",LIGHT_PINK:"#ED9BD3",LIGHT_GREEN:"#9BEDCE",LIGHT_PURPLE:"#DA9BED",LIGHT_RED:"#ED9AAC",LIGHT_GRAY:"#ED9B9B",LIGHT_BLACK:"#ED9B9B",GRAY10:"#D6D6D6",GRAY20:"#CDCDCD",GRAY30:"#B3B3B3",GRAY40:"#9A9A9A",GRAY50:"#808080",GRAY60:"#666666",GRAY70:"#4D4D4D",GRAY80:"#333333",GRAY90:"#1A1A1A",BLUE_A:"#CCFAFF",BLUE_B:"#80F6FF",BLUE_C:"#63D9EA",BLUE_D:"#11ACCD",BLUE_E:"#0C7F99",TEAL_A:"#94FFF5",TEAL_B:"#26EDD5",TEAL_C:"#01D1C1",TEAL_D:"#01A995",TEAL_E:"#208170",GREEN_A:"#B6FFB0",GREEN_B:"#8AF281",GREEN_C:"#74CF70",GREEN_D:"#1FAB54",GREEN_E:"#0D923F",GOLD_A:"#FFD0A9",GOLD_B:"#FFBB71",GOLD_C:"#FF9C39",GOLD_D:"#E07D10",GOLD_E:"#A75A05",RED_A:"#FCA9A9",RED_B:"#FF8482",RED_C:"#F9685D",RED_D:"#E84D39",RED_E:"#BC2612",MAROON_A:"#FFBDE0",MAROON_B:"#FF92C6",MAROON_C:"#ED5FA6",MAROON_D:"#CA337C",MAROON_E:"#9E034E",PURPLE_A:"#DDD7FF",PURPLE_B:"#C6B9FC",PURPLE_C:"#AA87FF",PURPLE_D:"#7854AB",PURPLE_E:"#543B78",MINT_A:"#F5F9E8",MINT_B:"#EDF2DF",MINT_C:"#E0E5CC",GRAY_A:"#F6F7F7",GRAY_B:"#F0F1F2",GRAY_C:"#E3E5E6",GRAY_D:"#D6D8DA",GRAY_E:"#BABEC2",GRAY_F:"#888D93",GRAY_G:"#626569",GRAY_H:"#3B3E40",GRAY_I:"#21242C",KA_BLUE:"#314453",KA_GREEN:"#71B307",_BACKGROUND:"#FDFDFD",INTERACTING:"#71B307",INTERACTIVE:"#71B307",DYNAMIC:"#6495ED"};function vn(e,t){const n=L.default(e).find("."+t);return 0===n.length?L.default("<span>").addClass(t).appendTo(L.default(e)):n}function bn(e,t){let n=0;!function s(){e.scrollHeight>18||n>=10?t():(n++,setTimeout(s,100))}()}var yn={processMath:async function(e,t,n,s){const o=L.default(e);if(null==o.attr("data-math-formula")||n){const n=vn(o,"katex-holder"),i=vn(o,"mathjax-holder"),r=i.find("script[type='math/tex']")[0];null==t&&(o.attr("data-math-formula")?t=o.attr("data-math-formula"):r&&(t=r.text||r.textContent)),t=null!=t?t+"":"",t=ue.cleanMath(t),o.attr("data-math-formula",t);const a=await le().getKaTeX();try{if(a.render(t,n[0],{colorIsTextColor:!0}),"mathjax"===o.attr("data-math-type")&&"undefined"!=typeof MathJax){const e=MathJax.Hub.getJaxFor(r);if(e){const t=e.SourceElement();t.previousSibling&&t.previousSibling.className&&e.Remove()}}return o.attr("data-math-type","katex"),void(s&&bn(e,s))}catch(e){if(le().logKaTeXError(t,e),e instanceof a.ParseError)throw e}o.attr("data-math-type","mathjax"),r?"text"in r?r.text=t:r.textContent=t:i.append("<script type='math/tex'>"+t.replace(/<\//g,"< /")+"<\/script>"),"undefined"!=typeof MathJax&&(MathJax.Hub.Queue(["Reprocess",MathJax.Hub,i[0]]),s&&MathJax.Hub.Queue((function(){const t=MathJax.Callback((function(){}));return bn(e,(function(){s(),t()})),t})))}},cleanupMath:function(e){const t=L.default(e);if(t.attr("data-math-formula")){if("undefined"!=typeof MathJax){const e=MathJax.Hub.getJaxFor(t.find("script")[0]);if(e){const t=e.SourceElement();t.previousSibling&&t.previousSibling.className&&e.Remove()}}t.text(t.attr("data-math-formula")),t.attr("data-math-formula",null),t.attr("data-math-type",null)}return e},retrieveMathFormula:function(e){return L.default(e).attr("data-math-formula")}};const{processMath:xn}=yn;function Cn(e,t){return"number"==typeof e&&(e=[e,e]),t=t*Math.PI/180,[e[0]*Math.cos(t),e[1]*Math.sin(t)]}const wn={unscaledSvgPath:function(e){return!0===e[0]?"":L.default.map(e,(function(e,t){return!0===e?"z":(0===t?"M":"L")+e[0]+" "+e[1]})).join("")},getDistance:function(e,t){return d.point.distanceToPoint(e,t)},coordDiff:function(e,t){return N.default.map(t,(function(n,s){return t[s]-e[s]}))},snapCoord:function(e,t){return N.default.map(e,(function(e,n){return ue.roundToNearest(t[n],e)}))},findAngle:function(e,t,n){if(void 0===n){const n=e[0]-t[0],s=e[1]-t[1];return n||s?(180+180*Math.atan2(-s,-n)/Math.PI+360)%360:0}return wn.findAngle(e,n)-wn.findAngle(t,n)},graphs:{}},kn=wn.Graphie=function(){};N.default.extend(kn.prototype,{cartToPolar:function(e,t){const n=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2));let s=Math.atan2(e[1],e[0]);return s<0&&(s+=2*Math.PI),t||(s=180*s/Math.PI),[n,s]},polar:Cn});const Sn={center:[-.5,-.5],above:[-.5,-1],"above right":[0,-1],right:[0,-.5],"below right":[0,0],below:[-.5,0],"below left":[-1,0],left:[-1,-.5],"above left":[-1,-1]},En={"stroke-width":null};wn.createGraphie=function(e){let t,n,s=40,o=40;L.default(e).css("position","relative");const i=mn.exports(e);L.default(e).children("div").css("position","absolute");let r={"stroke-width":2,fill:"none"};const a=function(e){if("number"==typeof e)return a([e,e]);const t=e[0],n=e[1];return[t*s,n*o]},l=function e(i){if("number"==typeof i)return e([i,i]);const r=i[0],a=i[1];return[(r-t[0])*s,(n[1]-a)*o]},c=function(e){if("number"==typeof e)return c([e,e]);const i=e[0],r=e[1];return[i/s+t[0],n[1]-r/o]},p=function(e){return"number"==typeof e?p([e,e]):[e[0]/s,e[1]/o]},h=function(e,t){const n=L.default(e),s=n.data("labelDirection");let[o,i]=t;if(0===o&&0===i&&([o,i]=[1,1],de.log("Label size was 0x0 in graphie.js; using 1x1 instead")),n.css("visibility",""),"number"==typeof s){const e=Math.cos(s),t=Math.sin(s),r=Math.min(o/2/Math.abs(e),i/2/Math.abs(t));n.css({marginLeft:-o/2+e*r,marginTop:-i/2-t*r})}else{const e=Sn[s||"center"];n.css({marginLeft:Math.round(o*e[0]),marginTop:Math.round(i*e[1])})}},u=function(e,t){return L.default.map(e,(function(e,n){if(!0===e)return"z";const s=t?e:l(e);return(0===n?"M":"L")+ue.bound(s[0])+" "+ue.bound(s[1])})).join("")},f=function(e,n,s){const o=function(t){return(e*t+n)*t+s};if(0===e){const e=N.default.map(t,(function(e){return[e,o(e)]}));return u(e)}const i=-n/(2*e),r=i+Math.max(Math.abs(i-t[0]),Math.abs(i-t[1])),a=[i,o(i)],c=[r,o(r)],p=[a[0],a[1]-(c[1]-a[1])],d=Math.abs(a[0]-c[0]),h=[a[0]-d,c[1]],f=[a[0]+d,c[1]],m=N.default.map([h,p,f],l),g=N.default.map(N.default.flatten(m),ue.bound);return"M"+g[0]+","+g[1]+" Q"+g[2]+","+g[3]+" "+g[4]+","+g[5]},m=function(e,n,s,o){const i=Math.abs(Math.PI/(2*n)),r=function(t){return e*Math.sin(n*t-s)+o},a=function(t){return e*n*Math.cos(s-n*t)},c=function(e,t){const n=e+i*t,s=n+i,o=[n,2*n/3+1*s/3,1*n/3+2*s/3,s],c=[r(n),r(n)+a(n)*(s-n)/3,r(s)-a(s)*(s-n)/3,r(s)];return N.default.map(N.default.zip(o,c),l)},p=t[1]-t[0],d=Math.ceil(p/i)+1;let h=s/n;const u=h-t[0];h-=i*Math.ceil(u/i);let f=c(h,0),m="M"+f[0][0]+","+f[0][1]+" C"+f[1][0]+","+f[1][1]+" "+f[2][0]+","+f[2][1]+" "+f[3][0]+","+f[3][1];for(let e=1;e<d;e++)f=c(h,e),m+=" C"+f[1][0]+","+f[1][1]+" "+f[2][0]+","+f[2][1]+" "+f[3][0]+","+f[3][1];return m};wn.svgPath=u;const g=function(e){const r={scale:function(e){"number"==typeof e&&(e=[e,e]),s=e[0],o=e[1],i.setSize((t[1]-t[0])*s,(n[1]-n[0])*o)},clipRect:function(e){const t=e[0],n=e[1];return t[1]+=n[1],{"clip-rect":l(t).concat(a(n)).join(" ")}},strokeWidth:function(e){return{"stroke-width":parseFloat(e)}},rx:function(e){return{rx:a([e,0])[0]}},ry:function(e){return{ry:a([0,e])[1]}},r:function(e){const t=a([e,e]);return{rx:t[0],ry:t[1]}}},c={};return L.default.each(e||{},(function(e,t){const n=r[e];if("function"==typeof n)L.default.extend(c,n(t));else{const n=e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase();c[n]=t}})),c},v=function e(t){const n=t.constructor.prototype;if(n===mn.exports.el){if("path"===t.type&&void 0===t.arrowheadsDrawn){const e=.6+.4*t.attr("stroke-width"),n=t.getTotalLength(),s=i.set(),o=i.path(y.isMobile?"M-4,4 C-4,4 -0.25,0 -0.25,0 C-0.25,0 -4,-4 -4,-4":"M-3 4 C-2.75 2.5 0 0.25 0.75 0C0 -0.25 -2.75 -2.5 -3 -4"),r=t.getPointAtLength(n-.4),a=t.getPointAtLength(n-.75*e),l=180*Math.atan2(r.y-a.y,r.x-a.x)/Math.PI,c=t.attr();delete c.path;let p=t.getSubpath(0,n-.75*e);return p=i.path(p).attr(c),p.arrowheadsDrawn=!0,t.remove(),o.rotate(l,y.isMobile?1e-5:.75,0).scale(e,e,.75,0).translate(a.x,a.y).attr(c).attr({"stroke-linejoin":"round","stroke-linecap":"round"}),o.arrowheadsDrawn=!0,s.push(p),s.push(o),s}}else if(n===mn.exports.st)for(let n=0,s=t.items.length;n<s;n++)e(t.items[n]);return t},b={circle:function(e,t){return i.ellipse(...l(e).concat(a([t,t])))},rect:function(e,t,n,s){const o=l([e,t+s]),r=a([n,s]),c=i.rect(...o.concat(r));return y.isMobile&&(c.node.style.shapeRendering="crispEdges"),c},ellipse:function(e,t){return i.ellipse(...l(e).concat(a(t)))},fixedEllipse:function(e,t,n,s){const o=l(e),i=a(t),r=2*i[0]*n+s,c=2*i[1]*n+s,p=o[0]-r/2,d=o[1]-c/2,h=document.createElement("div");L.default(h).css({position:"absolute",width:r+"px",height:c+"px",left:p+"px",top:d+"px"});return{wrapper:h,visibleShape:mn.exports(h,r,c).ellipse(r/2,c/2,i[0],i[1])}},arc:function(e,t,n,s,o){n=(n%360+360)%360,s=(s%360+360)%360;const r=l(e),c=a(t),p=Cn(t,n),d=Cn(t,s),h=l([e[0]+p[0],e[1]+p[1]]),u=l([e[0]+d[0],e[1]+d[1]]),f=((s-n)%360+360)%360>180;return i.path("M"+h.join(" ")+"A"+c.join(" ")+" 0 "+(f?1:0)+" 0 "+u.join(" ")+(o?"L"+r.join(" ")+"z":""))},path:function(e){const t=i.path(u(e));return t.graphiePath=e,t},fixedPath:function(e,t,n){e=N.default.map(e,l),t=t?l(t):null,n=n||u;const s=N.default.min(N.default.pluck(e,0)),o=N.default.max(N.default.pluck(e,0)),i=N.default.min(N.default.pluck(e,1)),r=N.default.max(N.default.pluck(e,1)),a=[4,4],c=[s,i];e=N.default.map(e,(function(e){return d.vector.add(d.vector.subtract(e,c),d.vector.scale(a,.5))}));const p=o-s+a[0],h=r-i+a[1],f=c[0]-a[0]/2,m=c[1]-a[1]/2,g=document.createElement("div");L.default(g).css({position:"absolute",width:p+"px",height:h+"px",left:f+"px",top:m+"px",transformOrigin:t?p/2+t[0]+"px "+(h/2+t[1])+"px":null});return{wrapper:g,visibleShape:mn.exports(g,p,h).path(n(e))}},scaledPath:function(e){const t=i.path(u(e,!0));return t.graphiePath=e,t},line:function(e,t){const n=this.path([e,t]);return y.isMobile&&(n.node.style.shapeRendering="crispEdges"),n},parabola:function(e,t,n){return i.path(f(e,t,n))},fixedLine:function(e,t,n){const s=[n,n];e=l(e),t=l(t);const o=[Math.min(e[0],t[0]),Math.min(e[1],t[1])];e=d.vector.add(d.vector.subtract(e,o),d.vector.scale(s,.5)),t=d.vector.add(d.vector.subtract(t,o),d.vector.scale(s,.5));const i=o[0]-s[0]/2,r=o[1]-s[1]/2,a=Math.abs(e[0]-t[0])+s[0],c=Math.abs(e[1]-t[1])+s[1],p=document.createElement("div");L.default(p).css({position:"absolute",width:a+"px",height:c+"px",left:i+"px",top:r+"px",transformOrigin:e[0]+"px "+e[1]+"px"});const h=mn.exports(p,a,c),u="M"+e[0]+" "+e[1]+" L"+t[0]+" "+t[1],f=h.path(u);return f.graphiePath=[e,t],{wrapper:p,visibleShape:f}},sinusoid:function(e,t,n,s){return i.path(m(e,t,n,s))},grid:function(e,t){const n=r.step||[1,1],s=i.set();let o=n[0]*Math.ceil(e[0]/n[0]);for(;o<=e[1];o+=n[0])s.push(this.line([o,t[0]],[o,t[1]]));let a=n[1]*Math.ceil(t[0]/n[1]);for(;a<=t[1];a+=n[1])s.push(this.line([e[0],a],[e[1],a]));return s},label:function(t,n,s,o){o=void 0===o||o;const i=L.default("<span>").addClass("graphie-label"),a=r["label-distance"];i.css(L.default.extend({},{position:"absolute",padding:(null!=a?a:7)+"px",color:"black"})).data("labelDirection",s).appendTo(e),i.setPosition=function(e){const t=l(e);i.css({left:t[0],top:t[1]})},i.setPosition(t);const c=i[0];return i.processMath=function(e,t){xn(c,e,t,(function(){const e=c.scrollWidth,t=c.scrollHeight;h(c,[e,t])}))},i.processText=function(e){i.html(e);const t=c.scrollWidth,n=c.scrollHeight;h(c,[t,n])},o?i.processMath(n,!1):i.processText(n),i},plotParametric:function(e,t,n,s){s=s||function(e){return[e,0]};const a=e=>Math.abs(e[1])>5e5?[e[0],Math.min(Math.max(e[1],-5e5),5e5)]:e,l=t=>a(e(t)),c=e=>a(s(e));r.strokeLinejoin||(r.strokeLinejoin="round"),r.strokeLinecap||(r.strokeLinecap="round");const p=t[0],d=t[1];let h=(d-p)/(r["plot-points"]||800);0===h&&(h=1);const u=i.set();let f=[],m=wn.coordDiff(l(p),c(p)),g=p;for(let e=p;e<=d;e+=h){const t=l(e),s=c(e),i=wn.coordDiff(t,s);if(i[1]<0!=m[1]<0&&Math.abs(i[1]-m[1])>2*o||isNaN(i[1])){if(n){f.push(t);for(let t=e-h;t>=g;t-=h)f.push(c(t));g=e}u.push(this.path(f)),f=[],n&&f.push(t)}else f.push(t);m=i}if(n)for(let e=d-h;e>=g;e-=h)f.push(c(e));return u.push(this.path(f)),u},plotPolar:function(e,t){const n=t[0],o=t[1];return r["plot-points"]||(r["plot-points"]=2*(o-n)*s),this.plotParametric((function(t){return Cn(e(t),180*t/Math.PI)}),t)},plot:function(e,t,n,o,i){const a=t[0],l=t[1];if(r["plot-points"]||(r["plot-points"]=2*(l-a)*s),n){if(i)throw new he("Can't shade area between functions with swapped axes.",pe.Internal);return this.plotParametric((function(t){return[e(t),t]}),t,o)}if(i){if(o)return this.plotParametric((function(t){return[t,e(t)]}),t,o,(function(e){return[e,i(e)]}));throw new he("fn2 should only be set when 'shade' is True.",pe.Internal)}return this.plotParametric((function(t){return[t,e(t)]}),t,o)},plotPiecewise:function(e,t){const n=i.set(),s=this;return N.default.times(e.length,(function(o){const i=e[o],r=t[o],a=s.plotParametric((function(e){return[e,i(e)]}),r);N.default.each(a,(function(e){n.push(e)}))})),n},plotEndpointCircles:function(e){const t=i.set(),n=this;return N.default.each(e,(function(e,s){t.push(n.circle(e,.15))})),t},plotAsymptotes:function(e,t){const n=t[0],s=t[1],a=(s-n)/(r["plot-points"]||800),l=i.set();let c=e(n);for(let t=n;t<=s;t+=a){const n=e(t);n<0!=c<0&&Math.abs(n-c)>2*o&&l.push(this.line([t,o],[t,-o])),c=n}return l}},y=new kn;return N.default.extend(y,{raphael:i,init:function(r){let a=r.scale||[40,40];if(a="number"==typeof a?[a,a]:a,s=a[0],o=a[1],null==r.range)throw new he("range should be specified in graph init",pe.Internal);t=r.range[0],n=r.range[1];const l=(t[1]-t[0])*s,c=(n[1]-n[0])*o;return i.setSize(l,c),L.default(e).css({width:l,height:c}),this.range=r.range,this.scale=a,this.dimensions=[l,c],this.xpixels=l,this.ypixels=c,this.isMobile=r.isMobile,this},style:function(e,t){const n=g(e);if("function"==typeof t){const e=r;r=L.default.extend({},r,n);const s=t.call(y);return r=e,s}L.default.extend(r,n)},scalePoint:l,scaleVector:a,unscalePoint:c,unscaleVector:p,svgPath:u,svgParabolaPath:f,svgSinusoidPath:m}),L.default.each(b,(function(e){y[e]=function(){const t=arguments[arguments.length-1],n=r;let s;if("object"!=typeof t||N.default.isArray(t))r=L.default.extend({},r),s=b[e](...arguments);else{r={...r,...g(t)};const n=[].slice.call(arguments,0,arguments.length-1);s=b[e](...n)}const o=s.constructor.prototype;return o===mn.exports.el||o===mn.exports.st?(s.attr(r),r.arrows&&(s=v(s))):s instanceof L.default&&s.css({...r,...En}),r=n,s}})),y.graphInit=function(e){e=e||{},L.default.each(e,(function(t,n){t.match(/.*Opacity$/)||"range"===t||"number"!=typeof n||(e[t]=[n,n]),"range"!==t&&"gridRange"!==t||(n.constructor===Array?n[0].constructor!==Array&&(e[t]=[[-n[0],n[0]],[-n[1],n[1]]]):"number"==typeof n&&(e[t]=[[-n,n],[-n,n]]))}));const t=e.range||[[-10,10],[-10,10]],n=e.gridRange||e.range,s=e.scale||[20,20],o=null==e.grid||e.grid,i=e.gridOpacity||.1,r=e.gridStep||[1,1],a=null==e.axes||e.axes,l=e.axisArrows||"",c=e.axisOpacity||1,p=e.axisCenter||[Math.min(Math.max(t[0][0],0),t[0][1]),Math.min(Math.max(t[1][0],0),t[1][1])],d=null!=e.axisLabels&&e.axisLabels,h=null==e.ticks||e.ticks,u=e.tickStep||[2,2],f=e.tickLen||[5,5],m=e.tickOpacity||1,g=e.labels||e.labelStep||!1,v=e.labelStep||[1,1],b=e.labelOpacity||1;let y=e.unityLabels||!1;const x=e.labelFormat||function(e){return e};let C=e.xLabelFormat||x,w=e.yLabelFormat||x;const k=null==e.smartLabelPositioning||e.smartLabelPositioning,S=[[t[0][0]-(t[0][0]>0?1:0),t[0][1]+(t[0][1]<0?1:0)],[t[1][0]-(t[1][0]>0?1:0),t[1][1]+(t[1][1]<0?1:0)]];if(N.default.isArray(y)||(y=[y,y]),k){const e=function(e){return function(t){return(e(t)+"").replace(/-(\d)/g,"\\llap{-}$1")}};C=e(C),w=e(w)}if(this.init({range:S,scale:s,isMobile:e.isMobile}),o&&this.grid(n[0],n[1],{stroke:e.isMobile?gn.GRAY_C:"#000000",opacity:e.isMobile?1:i,step:r,strokeWidth:e.isMobile?1:2}),a&&("<->"===l||!0===l?this.style({stroke:e.isMobile?gn.GRAY_G:"#000000",opacity:e.isMobile?1:c,strokeWidth:e.isMobile?1:2,arrows:"->"},(function(){t[1][0]<0&&t[1][1]>0&&(this.path([p,[n[0][0],p[1]]]),this.path([p,[n[0][1],p[1]]])),t[0][0]<0&&t[0][1]>0&&(this.path([p,[p[0],n[1][0]]]),this.path([p,[p[0],n[1][1]]]))})):"->"!==l&&""!==l||this.style({stroke:"#000000",opacity:c,strokeWidth:2,arrows:l},(function(){this.path([[n[0][0],p[1]],[n[0][1],p[1]]]),this.path([[p[0],n[1][0]],[p[0],n[1][1]]])})),d&&2===d.length&&(this.label([n[0][1],p[1]],d[0],"right"),this.label([p[0],n[1][1]],d[1],"above"))),h){const o=e.isMobile;this.style({stroke:e.isMobile?gn.GRAY_G:"#000000",opacity:e.isMobile?1:m,strokeWidth:1},(function(){let e=r[0]*u[0],i=f[0]/s[1],a=n[0][0],c=n[0][1];if(t[1][0]<0&&t[1][1]>0){for(let t=e+p[0];t<=c;t+=e)(t<c||!l)&&this.line([t,-i+p[1]],[t,o?0:i+p[1]]);for(let t=-e+p[0];t>=a;t-=e)(t>a||!l)&&this.line([t,-i+p[1]],[t,o?0:i+p[1]])}if(e=r[1]*u[1],i=f[1]/s[0],a=n[1][0],c=n[1][1],t[0][0]<0&&t[0][1]>0){for(let t=e+p[1];t<=c;t+=e)(t<c||!l)&&this.line([-i+p[0],t],[o?0:i+p[0],t]);for(let t=-e+p[1];t>=a;t-=e)(t>a||!l)&&this.line([-i+p[0],t],[o?0:i+p[0],t])}}))}g&&this.style({stroke:e.isMobile?gn.GRAY_G:"#000000",opacity:e.isMobile?1:b},(function(){let e=r[0]*u[0]*v[0],t=n[0][0],s=n[0][1];const o=p[0]<0?"above":"below",i=p[0]<0?"right":"left",a=0===p[0]&&0!==p[1],c=0!==p[0]&&0===p[1],d=0!==p[0]||0!==p[1],h=y[0]||d,f=y[1]||d;for(let t=(a?0:e)+p[0];t<=s;t+=e)(t<s||!l)&&this.label([t,p[1]],C(t),o);for(let n=-e*(h?1:2)+p[0];n>=t;n-=e)(n>t||!l)&&this.label([n,p[1]],C(n),o);e=r[1]*u[1]*v[1],t=n[1][0],s=n[1][1];for(let t=(c?0:e)+p[1];t<=s;t+=e)(t<s||!l)&&this.label([p[0],t],w(t),i);for(let n=-e*(f?1:2)+p[1];n>=t;n-=e)(n>t||!l)&&this.label([p[0],n],w(n),i)}))},y},function(e,t,n,s){if(void 0!==e){var o="virtualMouseBindings",i="virtualTouchID",r="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),a="clientX clientY pageX pageY screenX screenY".split(" "),l=e.event.mouseHooks?e.event.mouseHooks.props:[],c=e.event.props.concat(l),p={},d=0,h=0,u=0,f=!1,m=[],g=!1,v=!1,b="addEventListener"in n,y=e(n),x=1,C=0;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(var w=0;w<r.length;w++)e.event.special[r[w]]=L(r[w]);b&&n.addEventListener("click",(function(t){var n,s,o,r,a,l=m.length,c=t.target;if(l)for(n=t.clientX,s=t.clientY,threshold=e.vmouse.clickDistanceThreshold,o=c;o;){for(r=0;r<l;r++)if(a=m[r],o===c&&Math.abs(a.x-n)<threshold&&Math.abs(a.y-s)<threshold||e.data(o,i)===a.touchID)return t.preventDefault(),void t.stopPropagation();o=o.parentNode}}),!0)}function k(e){for(;e&&void 0!==e.originalEvent;)e=e.originalEvent;return e}function S(t){for(var n,s,i={};t;){for(s in n=e.data(t,o))n[s]&&(i[s]=i.hasVirtualBinding=!0);t=t.parentNode}return i}function E(){v=!0}function _(){v=!1}function M(){T(),d=setTimeout((function(){d=0,C=0,m.length=0,g=!1,E()}),e.vmouse.resetTimerDuration)}function T(){d&&(clearTimeout(d),d=0)}function I(t,n,s){var i;return(s&&s[t]||!s&&function(t,n){for(var s;t;){if((s=e.data(t,o))&&(!n||s[n]))return t;t=t.parentNode}return null}(n.target,t))&&(i=function(t,n){var s,o,i,r,l,p,d,h,u,f=t.type;if((t=e.Event(t)).type=n,s=t.originalEvent,o=e.event.props,f.search(/mouse/)>-1&&(o=c),s)for(d=o.length;d;)t[r=o[--d]]=s[r];if(f.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1),-1!==f.search(/^touch/)&&(f=(i=k(s)).touches,l=i.changedTouches,p=f&&f.length?f[0]:l&&l.length?l[0]:void 0))for(h=0,u=a.length;h<u;h++)t[r=a[h]]=p[r];return t}(n,t),e(n.target).trigger(i)),i}function P(t){var n=e.data(t.target,i);if(!(g||C&&C===n)){var s=I("v"+t.type,t);s&&(s.isDefaultPrevented()&&t.preventDefault(),s.isPropagationStopped()&&t.stopPropagation(),s.isImmediatePropagationStopped()&&t.stopImmediatePropagation())}}function A(t){var n,s,o=k(t).touches;if(o&&1===o.length&&(s=S(n=t.target)).hasVirtualBinding){C=x++,e.data(n,i,C),T(),_(),f=!1;var r=k(t).touches[0];h=r.pageX,u=r.pageY,I("vmouseover",t,s),I("vmousedown",t,s)}}function N(e){v||(f||I("vmousecancel",e,S(e.target)),f=!0,M())}function R(t){if(!v){var n=k(t).touches[0],s=i,o=e.vmouse.moveDistanceThreshold,i=i||Math.abs(n.pageX-h)>o||Math.abs(n.pageY-u)>o,r=S(t.target);i&&!s&&I("vmousecancel",t,r),I("vmousemove",t,r),M()}}function F(e){if(!v){E();var t,n=S(e.target);if(I("vmouseup",e,n),!f){var s=I("vclick",e,n);s&&s.isDefaultPrevented()&&(t=k(e).changedTouches[0],m.push({touchID:C,x:t.clientX,y:t.clientY}),g=!0)}I("vmouseout",e,n),f=!1,M()}}function D(t){var n,s=e.data(t,o);if(s)for(n in s)if(s[n])return!0;return!1}function O(){}function L(t){var n=t.substr(1);return{setup:function(s,i){D(this)||e.data(this,o,{}),e.data(this,o)[t]=!0,p[t]=(p[t]||0)+1,1===p[t]&&y.bind(n,P),e(this).bind(n,O),b&&(p.touchstart=(p.touchstart||0)+1,1===p.touchstart&&y.bind("touchstart",A).bind("touchend",F).bind("touchmove",R).bind("scroll",N))},teardown:function(s,i){--p[t],p[t]||y.unbind(n,P),b&&(--p.touchstart,p.touchstart||y.unbind("touchstart",A).unbind("touchmove",R).unbind("touchend",F).unbind("scroll",N));var r=e(this),a=e.data(this,o);a&&(a[t]=!1),r.unbind(n,O),D(this)||r.removeData(o)}}}}(window.jQuery,window,document);var _n={pluck:function(e,t){return N.default.object(N.default.map(e,(function(e,n){return[n,e[t]]})))},mapObject:function(e,t){const n={};return N.default.each(N.default.keys(e),(function(s){n[s]=t(e[s],s)})),n},mapObjectFromArray:function(e,t){const n={};return N.default.each(e,(function(e){n[e]=t(e)})),n}};const Mn=N.default.extend({transform:function(e){const t=un.getPrefixedTransform();this.wrapper.style[t]=e},toFront:function(){const e=this.wrapper.parentNode;e&&e.appendChild(this.wrapper)},toBack:function(){const e=this.wrapper.parentNode;e.firstChild!==this.wrapper&&e.insertBefore(this.wrapper,e.firstChild)},remove:function(){this.visibleShape.remove(),L.default(this.wrapper).remove()},getMouseTarget:function(){return this.visibleShape[0]},moveTo:function(e){const t=d.vector.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),n=un.getCanUse3dTransform(),s="translateX("+t[0]+"px) translateY("+t[1]+"px)"+(n?" translateZ(0)":"");this.transform(s)},hide:function(){this.visibleShape.hide()},show:function(){this.visibleShape.show()}},_n.mapObjectFromArray(["attr","animate"],(function(e){return function(){this.visibleShape[e](...arguments)}}))),Tn={maxScale:1,mouselayer:!1,shadow:!1,disableMouseEventsOnWrapper:!1},In=function(e,t,n,s){s=N.default.extend({},Tn,s);const o=e.fixedEllipse(t,n,s.maxScale,s.padding);if(N.default.extend(this,o,{graphie:e,initialPoint:t}),s.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",s.interactiveKindForTesting),s.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),s.shadow){const e="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))",t=this.wrapper;t.style.webkitFilter=e,t.style.filter=e,this.moveTo=function(e){const t=d.vector.subtract(this.graphie.scalePoint(e),this.graphie.scalePoint(this.initialPoint)),n=un.getCanUse3dTransform(),s="translateX("+Math.round(t[0])+"px) translateY("+Math.round(t[1])+"px)"+(n?" translateZ(0)":"");this.transform(s)}}s.disableMouseEventsOnWrapper&&(this.wrapper.style.pointerEvents="none",this.visibleShape.node.style.pointerEvents="auto")};N.default.extend(In.prototype,Mn);const Pn={thickness:2,mouselayer:!1},An=function(e,t,n,s){s=N.default.extend({},Pn,s);const o=[e.range[0][0],0],i=[e.range[0][1],0];N.default.extend(this,e.fixedLine(o,i,s.thickness)),s.interactiveKindForTesting&&this.wrapper.setAttribute("data-interactive-kind-for-testing",s.interactiveKindForTesting),this.visibleShape.attr(s.normalStyle),N.default.extend(this,{graphie:e,initialPoint:e.scalePoint(o),initialLength:d.point.distanceToPoint(e.scalePoint(o),e.scalePoint(i))}),s.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper),this.moveTo(t,n)};N.default.extend(An.prototype,Mn,{getMouseTarget:function(){return this.wrapper},moveTo:function(e,t){const n=this.graphie.scalePoint(e),s=this.graphie.scalePoint(t),o=d.vector.polarDegFromCart(d.vector.subtract(s,n)),i=o[0],r=ue.bound(o[1]),a=d.vector.subtract(n,this.initialPoint),l=ue.bound(i/this.initialLength),c=un.getCanUse3dTransform(),p="translateX("+a[0]+"px) translateY("+a[1]+"px) "+(c?" translateZ(0)":"")+"rotate("+r+"deg) scaleX("+l+") scaleY(1)";this.transform(p)}});const Nn={center:null,createPath:null,mouselayer:!1},Rn=function(e,t,n){n=N.default.extend({},Nn,n),N.default.extend(this,e.fixedPath(t,n.center,n.createPath)),N.default.extend(this,{graphie:e,initialPoint:e.scalePoint(N.default.head(t))}),n.mouselayer?(this.wrapper.style.touchAction="none",this.graphie.addToMouseLayerWrapper(this.wrapper)):this.graphie.addToVisibleLayerWrapper(this.wrapper)};N.default.extend(Rn.prototype,Mn);const{getCanUse3dTransform:Fn}=un;function Dn(e){return N.default.reduce(e,(function(e,t){return e+t}),0)}function On(){const e=N.default.zip(...arguments);return N.default.map(e,Dn)}function Ln(e){return N.default.map(e,(function(e){return-1*e}))}function Bn(e){const t=11.374597405497571;return 58.919514629750836*Math.exp(-.037587715462826674*e)+t}function zn(e,t){return[e*Math.cos(t),e*Math.sin(t)*-1]}function qn(e,t){return zn(e,t*Math.PI/180)}let Hn=!1;const Wn={animate:function(){},attr:function(){},remove:function(){}};function Un(e,t){this.set=e.raphael.set(),this.cx=t[0],this.cy=t[1];const n=this,s=e.unscaleVector(180.5)[0],o=e.scalePoint([this.cx-s,this.cy+s-e.unscaleVector(10.5)[1]]),i=e.mouselayer.image("https://ka-perseus-graphie.s3.amazonaws.com/e9d032f2ab8b95979f674fbfa67056442ba1ff6a.png",o[0],o[1],360,180);this.set.push(i),i.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});const r=function(n,o){const i=e.scaleVector(s);i[0]-=16,i[1]-=16;const r=e.scalePoint(t);return Math.sin((n+90)*Math.PI/180)*(i[0]+o)+r[0]+","+(Math.cos((n+90)*Math.PI/180)*(i[1]+o)+r[1])},a=e.raphael.path(" M"+r(180,6)+" L"+r(180,2)+" L"+r(183,10)+" L"+r(180,18)+" L"+r(180,14)+" A"+(e.scaleVector(s)[0]+10)+","+(e.scaleVector(s)[1]+10)+",0,0,1,"+r(170,14)+" L"+r(170,18)+" L"+r(167,10)+" L"+r(170,2)+" L"+r(170,6)+" A"+(e.scaleVector(s)[0]+10)+","+(e.scaleVector(s)[1]+10)+",0,0,0,"+r(180,6)+" Z").attr({stroke:null,fill:gn.INTERACTIVE});this.set.push(a),this.centerPoint=e.addMovablePoint({coord:t,visible:!1}),this.rotateHandle=e.addMovablePoint({bounded:!1,coord:[Math.sin(275*Math.PI/180)*s+this.cx,Math.cos(275*Math.PI/180)*s+this.cy],onMove:function(e,t){const s=180*Math.atan2(n.centerPoint.coord[1]-t,n.centerPoint.coord[0]-e)/Math.PI;n.rotate(-s-5,!0)}}),this.rotateHandle.constraints.fixedDistance.dist=s,this.rotateHandle.constraints.fixedDistance.point=this.centerPoint,this.rotateHandle.visibleShape.remove(),this.rotateHandle.mouseTarget.attr({scale:2});let l=!1,c=!1;const p=function(){return c||l},d=L.default(this.rotateHandle.mouseTarget.getMouseTarget());d.bind("vmousedown",(function(e){l=!0,d.css("cursor","-webkit-grabbing"),d.css("cursor","grabbing"),a.animate({scale:1.5,fill:gn.INTERACTING},50),L.default(document).bind("vmouseup.rotateHandle",(function(e){l=!1,d.css("cursor","-webkit-grab"),d.css("cursor","grab"),p()||a.animate({scale:1,fill:gn.INTERACTIVE},50),L.default(document).unbind("vmouseup.rotateHandle")}))})),d.bind("vmouseover",(function(e){c=!0,a.animate({scale:1.5,fill:gn.INTERACTING},50)})),d.bind("vmouseout",(function(e){c=!1,p()||a.animate({scale:1,fill:gn.INTERACTIVE},50)}));const h=L.default.map(this.set,(function(e){return e.node}));return this.makeTranslatable=function(){L.default(h).css("cursor","move"),d.css("cursor","-webkit-grab"),d.css("cursor","grab"),L.default(h).bind("vmousedown",(function(t){t.preventDefault();let s=t.pageX-L.default(e.raphael.canvas.parentNode).offset().left,o=t.pageY-L.default(e.raphael.canvas.parentNode).offset().top;L.default(document).bind("vmousemove.protractor",(function(t){let i=t.pageX-L.default(e.raphael.canvas.parentNode).offset().left,r=t.pageY-L.default(e.raphael.canvas.parentNode).offset().top;i=Math.max(10,Math.min(e.xpixels-10,i)),r=Math.max(10,Math.min(e.ypixels-10,r));const a=i-s,l=r-o;L.default.each(n.set.items,(function(){this.translate(a,l)})),n.centerPoint.setCoord([n.centerPoint.coord[0]+a/e.scale[0],n.centerPoint.coord[1]-l/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+a/e.scale[0],n.rotateHandle.coord[1]-l/e.scale[1]]),s=i,o=r})),L.default(document).one("vmouseup",(function(e){L.default(document).unbind("vmousemove.protractor")}))}))},this.rotation=0,this.rotate=function(t,n){const s=e.scalePoint(this.centerPoint.coord);return n&&(this.rotation=0),this.set.rotate(this.rotation+t,s[0],s[1]),this.rotation=this.rotation+t,this},this.moveTo=function(t,s){const o=e.scalePoint(n.centerPoint.coord),i=e.scalePoint([t,s]),r=2*wn.getDistance(o,i);L.default({x:o[0],y:o[1]}).animate({x:i[0],y:i[1]},{duration:r,step:function(t,s){let o=0,i=0;"x"===s.prop?o=t-e.scalePoint(n.centerPoint.coord)[0]:"y"===s.prop&&(i=t-e.scalePoint(n.centerPoint.coord)[1]),L.default.each(n.set.items,(function(){this.translate(o,i)})),n.centerPoint.setCoord([n.centerPoint.coord[0]+o/e.scale[0],n.centerPoint.coord[1]-i/e.scale[1]]),n.rotateHandle.setCoord([n.rotateHandle.coord[0]+o/e.scale[0],n.rotateHandle.coord[1]-i/e.scale[1]])}})},this.rotateTo=function(e){Math.abs(this.rotation-e)>180&&(this.rotation+=360);const t=5*Math.abs(this.rotation-e);L.default({0:this.rotation}).animate({0:e},{duration:t,step:function(e,t){n.rotate(e,!0),n.rotateHandle.setCoord([Math.sin((e+275)*Math.PI/180)*s+n.centerPoint.coord[0],Math.cos((e+275)*Math.PI/180)*s+n.centerPoint.coord[1]])}})},this.remove=function(){this.set.remove()},this.makeTranslatable(),this}function Gn(e,t){N.default.defaults(t,{center:[0,0],pixelsPerUnit:40,ticksPerUnit:10,units:10,label:"",style:{fill:null,stroke:gn.GRAY}});const n=N.default.extend({},t.style,{strokeWidth:1}),s=N.default.extend({},t.style,{strokeWidth:2}),o=t.units*t.pixelsPerUnit,i=e.unscalePoint(d.vector.subtract(e.scalePoint(t.center),d.vector.scale([o,-50],.5))),r=t.pixelsPerUnit/e.scale[0],a=50/e.scale[0],l=d.vector.add(i,[t.units*r,a]);let c;if(10===t.ticksPerUnit)c={10:1,5:.55,1:.35};else{const e=[1,.6,.45,.3];c={};for(let n=t.ticksPerUnit;n>=1;n/=2)c[n]=1*(e.shift()||.2)}const p=N.default.keys(c).sort((function(e,t){return t-e}));const h=i[0],u=i[1],f=l[0],m=l[1],g=t.units*t.ticksPerUnit+1,v=e.raphael.set(),b=1/e.scale[0];v.push(e.line([h-b,u],[f+b,u],s)),v.push(e.line([h-b,m],[f+b,m],s)),N.default.times(g,(function(o){const i=o/t.ticksPerUnit,l=h+i*r,d=function(e){for(let t=0;t<p.length;t++){const n=p[t];if(e%n==0)return c[n]}return 0}(o)*a,f=0===o||o===g-1?s:n;if(v.push(e.line([l,u],[l,u+d],f)),i%1==0){const n=e.scalePoint([l,m]);let s,o;0===i?(s=t.label,o={mm:13,cm:11,m:8,km:11,in:8,ft:8,yd:10,mi:10}[s]||3*s.toString().length):(s=i,o=-3*(i.toString().length+1));const r=e.raphael.text(n[0]+o,n[1]+10,s);r.attr({"font-family":"KaTeX_Main","font-size":"12px",color:"#444"}),v.push(r)}}));const y=e.mouselayer.path(wn.svgPath([i,[h,m],l,[f,u],!0]));y.attr({fill:"#000",opacity:0,stroke:"#000","stroke-width":2}),v.push(y),y.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1});const x=L.default.map(v,(function(e){return e.node}));L.default(x).css("cursor","move"),L.default(x).bind("vmousedown",(function(t){t.preventDefault();let n=t.pageX-L.default(e.raphael.canvas.parentNode).offset().left,s=t.pageY-L.default(e.raphael.canvas.parentNode).offset().top;L.default(document).bind("vmousemove.ruler",(function(t){let o=t.pageX-L.default(e.raphael.canvas.parentNode).offset().left,i=t.pageY-L.default(e.raphael.canvas.parentNode).offset().top;o=Math.max(10,Math.min(e.xpixels-10,o)),i=Math.max(10,Math.min(e.ypixels-10,i));const r=o-n,a=i-s;v.translate(r,a),C.setCoord([C.coord[0]+r/e.scale[0],C.coord[1]-a/e.scale[1]]),w.setCoord([w.coord[0]+r/e.scale[0],w.coord[1]-a/e.scale[1]]),n=o,s=i})),L.default(document).one("vmouseup",(function(e){L.default(document).unbind("vmousemove.ruler")}))}));const C=e.addMovablePoint({coord:i,normalStyle:{fill:gn.INTERACTIVE,"fill-opacity":0,stroke:gn.INTERACTIVE},highlightStyle:{fill:gn.INTERACTING,"fill-opacity":.1,stroke:gn.INTERACTING},pointSize:6,onMove:function(t,n){const s=w.coord[1]-n,o=w.coord[0]-t,i=180*Math.atan2(s,o)/Math.PI,r=d.vector.scale(d.vector.add([t,n],w.coord),.5),a=e.scalePoint(r),l=d.vector.scale(d.vector.add(C.coord,w.coord),.5),c=e.scalePoint(l),p=d.vector.subtract(a,c);v.rotate(-i,c[0],c[1]),v.translate(p[0],p[1])}}),w=e.addMovablePoint({coord:[f,u],normalStyle:{fill:gn.INTERACTIVE,"fill-opacity":0,stroke:gn.INTERACTIVE},highlightStyle:{fill:gn.INTERACTING,"fill-opacity":.1,stroke:gn.INTERACTING},pointSize:6,onMove:function(t,n){const s=n-C.coord[1],o=t-C.coord[0],i=180*Math.atan2(s,o)/Math.PI,r=d.vector.scale(d.vector.add([t,n],C.coord),.5),a=e.scalePoint(r),l=d.vector.scale(d.vector.add(C.coord,w.coord),.5),c=e.scalePoint(l),p=d.vector.subtract(a,c);v.rotate(-i,c[0],c[1]),v.translate(p[0],p[1])}});return C.constraints.fixedDistance.dist=o/e.scale[0],C.constraints.fixedDistance.point=w,w.constraints.fixedDistance.dist=o/e.scale[0],w.constraints.fixedDistance.point=C,this.remove=function(){v.remove(),C.remove(),w.remove()},this}function Vn(e,t){if(this.graphie=e,N.default.extend(this,t),N.default.defaults(this,{normalStyle:{stroke:gn.INTERACTIVE,"stroke-width":2,fill:gn.INTERACTIVE},highlightStyle:{stroke:gn.INTERACTING,"stroke-width":2,fill:gn.INTERACTING},labelStyle:{stroke:gn.DYNAMIC,"stroke-width":1,color:gn.DYNAMIC},angleStyle:{stroke:gn.DYNAMIC,"stroke-width":1,color:gn.DYNAMIC},allowReflex:!0}),!this.points||3!==this.points.length)throw new he("MovableAngle requires 3 points",pe.InvalidInput);this.points=N.default.map(t.points,(function(t){return N.default.isArray(t)?e.addMovablePoint({coord:t,visible:!1,constraints:{fixed:!0},normalStyle:this.normalStyle}):t}),this),this.coords=N.default.pluck(this.points,"coord"),null==this.reflex&&(this.allowReflex?this.reflex=this._getClockwiseAngle(this.coords)>180:this.reflex=!1),this.rays=N.default.map([0,2],(function(t){return e.addMovableLineSegment({pointA:this.points[1],pointZ:this.points[t],fixed:!0,extendRay:!0})}),this),this.temp=[],this.labeledAngle=e.label([0,0],"","center",this.labelStyle),this.fixed||(this.addMoveHandlers(),this.addHighlightHandlers()),this.update()}N.default.extend(wn.Graphie.prototype,{addMouseLayer:function(e){const t=this;e=N.default.extend({allowScratchpad:!1,setDrawingAreaAvailable:function(){}},e);if(t.mouselayer=mn.exports(t.raphael.canvas.parentNode,t.xpixels,t.ypixels),L.default(t.mouselayer.canvas).css("z-index",2),e.onClick||e.onMouseDown||e.onMouseMove||e.onMouseOver||e.onMouseOut){const n=t.mouselayer.rect(0,0,t.xpixels,t.ypixels).attr({fill:"#000",opacity:0});let s=!1;L.default(t.mouselayer.canvas).on("vmousedown",(function(o){o.target===n[0]&&(e.onMouseDown&&e.onMouseDown(t.getMouseCoord(o)),s=!0,e.onMouseMove&&L.default(document).bind("vmousemove.mouseLayer",(function(n){s&&(n.preventDefault(),e.onMouseMove(t.getMouseCoord(n)))})),L.default(document).bind("vmouseup.mouseLayer",(function(n){L.default(document).unbind(".mouseLayer"),s&&e.onClick&&e.onClick(t.getMouseCoord(n)),s=!1})))})),e.onMouseOver&&L.default(t.mouselayer.canvas).on("vmouseover",(function(n){e.onMouseOver(t.getMouseCoord(n))})),e.onMouseOut&&L.default(t.mouselayer.canvas).on("vmouseout",(function(n){e.onMouseOut(t.getMouseCoord(n))}))}e.allowScratchpad||e.setDrawingAreaAvailable(!1),t._mouselayerWrapper=document.createElement("div"),L.default(t._mouselayerWrapper).css({position:"absolute",left:0,top:0,zIndex:2}),t._visiblelayerWrapper=document.createElement("div"),L.default(t._visiblelayerWrapper).css({position:"absolute",left:0,top:0});const n=t.raphael.canvas.parentNode;n.appendChild(t._visiblelayerWrapper),n.appendChild(t._mouselayerWrapper),t.addToMouseLayerWrapper=function(e){this._mouselayerWrapper.appendChild(e)},t.addToVisibleLayerWrapper=function(e){this._visiblelayerWrapper.appendChild(e)}},getMousePx:function(e){return[e.pageX-L.default(this.raphael.canvas.parentNode).offset().left,e.pageY-L.default(this.raphael.canvas.parentNode).offset().top]},getMouseCoord:function(e){return this.unscalePoint(this.getMousePx(e))},labelAngle:function(e){const t=this;N.default.defaults(e,{point1:[0,0],vertex:[0,0],point3:[0,0],label:null,numArcs:1,showRightAngleMarker:!0,pushOut:0,clockwise:!1,style:{}});let n=void 0===e.text?"":e.text;const s=e.vertex,o=t.scalePoint(s);let i,r;e.clockwise?(i=e.point1,r=e.point3):(i=e.point3,r=e.point1);const a=wn.findAngle(i,s),l=wn.findAngle(r,s),c=(l+360-a)%360,p=(a+c/2)%360;let d=5*e.pushOut+Bn(c);const h=[];if(Math.abs(c-90)<1e-9&&e.showRightAngleMarker){const n=On(o,qn(d,a)),s=On(o,qn(d,l));d*=Math.SQRT2;const i=On(o,qn(d,p));N.default.each([n,s],(function(n){h.push(t.scaledPath([n,i],e.style))}))}else N.default.times(e.numArcs,(function(n){h.push(t.arc(s,t.unscaleVector(d),a,l,e.style)),d+=3}));if(n){const s=n.match(/\$deg(\d)?/);if(s){const e=s[1]||1;n=n.replace(s[0],ue.toFixedApprox(c,e)+"^{\\circ}")}const i=On(o,qn(d+15,p)),r=t.unscalePoint(i);e.label?(e.label.setPosition(r),e.label.processMath(n,!0)):t.label(r,n,"center",e.style)}return h},labelSide:function(e){const t=this;let n,s;N.default.defaults(e,{point1:[0,0],point2:[0,0],label:null,text:"",numTicks:0,numArrows:0,clockwise:!1,style:{}}),e.clockwise?(n=e.point1,s=e.point2):(n=e.point2,s=e.point1);const o=[(n[0]+s[0])/2,(n[1]+s[1])/2],i=t.scalePoint(o),r=Math.atan2(s[1]-n[1],s[0]-n[0]),a=r+Math.PI/2,l=[];let c=0;if(e.numTicks){const n=e.numTicks,s=5,o=5,p=N.default.extend({},e.style,{strokeWidth:2});N.default.times(n,(function(e){const c=zn(s*(e-(n-1)/2),r),d=zn(o,a),h=[On(i,c,d),On(i,c,Ln(d))];l.push(t.scaledPath(h,p))})),c+=s*(n-1)+15}if(e.numArrows){const o=e.numArrows,a=[n,s].sort((function(e,t){return e[1]===t[1]?e[0]-t[0]:e[1]-t[1]}))[0],p=t.scalePoint(a),d=N.default.extend({},e.style,{arrows:"->",strokeWidth:2}),h=5;N.default.times(o,(function(e){let s=zn(c+h*e,r);a!==n&&(s=Ln(s));const o=On(i,s);l.push(t.scaledPath([p,o],d))}))}let p=e.text;if(p){const o=p.match(/\$len(\d)?/);if(o){const e=wn.getDistance(n,s),t=o[1]||1;p=p.replace(o[0],ue.toFixedApprox(e,t))}const r=zn(20,a),l=On(i,r),c=t.unscalePoint(l);e.label?(e.label.setPosition(c),e.label.processMath(p,!0)):t.label(c,p,"center",e.style)}return l},labelVertex:function(e){const t=this;if(N.default.defaults(e,{point1:null,vertex:[0,0],point3:null,label:null,text:"",clockwise:!1,style:{}}),!e.text)return;const n=e.vertex,s=t.scalePoint(n);let o,i;e.clockwise?(o=e.point1,i=e.point3):(o=e.point3,i=e.point1);let r,a=135;if(o&&i){const e=wn.findAngle(o,n);a=(wn.findAngle(i,n)+360-e)%360,r=(e+a/2+180)%360}else if(o){r=wn.findAngle(n,o)+90}else if(i){r=wn.findAngle(i,n)+90}else r=135;const l=On(s,qn(10+Bn(360-a),r)),c=t.unscalePoint(l);e.label?(e.label.setPosition(c),e.label.processMath(e.text,!0)):t.label(c,e.text,"center",e.style)},addMovablePoint:function(e){const t=L.default.extend(!0,{graph:this,coord:[0,0],snapX:0,snapY:0,pointSize:4,highlight:!1,dragging:!1,visible:!0,bounded:!0,constraints:{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},lineStarts:[],lineEnds:[],polygonVertices:[],normalStyle:{},highlightStyle:{fill:gn.INTERACTING,stroke:gn.INTERACTING},labelStyle:{color:gn.INTERACTIVE},vertexLabel:"",mouseTarget:null},e),n=t.constraints.fixed?gn.DYNAMIC:gn.INTERACTIVE;t.normalStyle=N.default.extend({},{fill:n,stroke:n},e.normalStyle),void 0!==e.coordX&&(t.coord[0]=e.coordX),void 0!==e.coordY&&(t.coord[1]=e.coordY);const s=t.graph,o=function(e){t.visible&&t.bounded&&!t.constraints.fixed&&(e=s.constrainToBounds(e,10));let n=e[0],o=e[1];if(0!==t.snapX&&(n=Math.round(n/t.snapX)*t.snapX),0!==t.snapY&&(o=Math.round(o/t.snapY)*t.snapY),t.constraints.fixedDistance.snapPoints){const i=s.scalePoint(e);let r=i[0],a=i[1];const l=2*Math.PI/t.constraints.fixedDistance.snapPoints,c=t.constraints.fixedDistance.dist,p=t.constraints.fixedDistance.point,d=(p[0]-s.range[0][0])*s.scale[0],h=(-p[1]+s.range[1][1])*s.scale[1];let u=r-d,f=-a+h,m=Math.atan(f/u);u<0&&(m+=Math.PI),m=Math.round(m/l)*l,u=c*Math.cos(m),f=c*Math.sin(m),r=u+d,a=-f+h,n=ue.roundTo(5,r/s.scale[0]+s.range[0][0]),o=ue.roundTo(5,s.range[1][1]-a/s.scale[1])}return t.applyConstraint([n,o])};t.applyConstraint=function(e,n,s){let o=e.slice();const i={};if(s?L.default.extend(i,{fixed:!1,constrainX:!1,constrainY:!1,fixedAngle:{},fixedDistance:{}},n):L.default.extend(i,this.constraints,n),i.constrainX)o=[this.coord[0],e[1]];else if(i.constrainY)o=[e[0],this.coord[1]];else if("number"==typeof i.fixedAngle.angle&&"number"==typeof i.fixedDistance.dist){const e=i.fixedAngle.vertex.coord||i.fixedAngle.vertex,t=i.fixedAngle.ref.coord||i.fixedAngle.ref,n=i.fixedDistance.point.coord||i.fixedDistance.point,s=(i.fixedAngle.angle+wn.findAngle(t,e))*Math.PI/180,r=i.fixedDistance.dist;o[0]=r*Math.cos(s)+n[0],o[1]=r*Math.sin(s)+n[1]}else if("number"==typeof i.fixedAngle.angle){const t=i.fixedAngle.vertex.coord||i.fixedAngle.vertex,n=i.fixedAngle.ref.coord||i.fixedAngle.ref,s=(i.fixedAngle.angle+wn.findAngle(n,t))*Math.PI/180,r=wn.findAngle(e,t)*Math.PI/180;let a=wn.getDistance(e,t)*Math.cos(s-r);a=a<1?1:a,o[0]=a*Math.cos(s)+t[0],o[1]=a*Math.sin(s)+t[1]}else if("number"==typeof i.fixedDistance.dist){const t=i.fixedDistance.point.coord||i.fixedDistance.point;let n=wn.findAngle(e,t);const s=i.fixedDistance.dist;n=n*Math.PI/180,o[0]=s*Math.cos(n)+t[0],o[1]=s*Math.sin(n)+t[1]}else i.fixed&&(o=t.coord);return o},t.coord=o(t.coord);if(t.visible&&s.style(t.normalStyle,(function(){const e=[t.pointSize/s.scale[0],t.pointSize/s.scale[1]],n={maxScale:2,padding:2};t.visibleShape=new In(s,t.coord,e,n),t.visibleShape.attr(N.default.omit(t.normalStyle,"scale")),t.visibleShape.toFront()})),t.normalStyle.scale=1,t.highlightStyle.scale=2,t.vertexLabel&&(t.labeledVertex=this.label([0,0],"","center",t.labelStyle)),t.drawLabel=function(){t.vertexLabel&&t.graph.labelVertex({vertex:t.coord,label:t.labeledVertex,text:t.vertexLabel,style:t.labelStyle})},t.drawLabel(),t.grab=function(e){e=e||[0,0],L.default(document).bind("vmousemove.point vmouseup.point",(function(n){n.preventDefault(),t.dragging=!0,Hn=!0;let i=d.vector.add(s.getMouseCoord(n),e);i=o(i);let r,a,l=i[0],c=i[1];if("vmousemove"===n.type){let e=!0;if(N.default.isFunction(t.onMove)){const n=t.onMove(l,c);!1===n&&(e=!1),N.default.isArray(n)&&(l=n[0],c=n[1])}if(r=(l-s.range[0][0])*s.scale[0],a=(-c+s.range[1][1])*s.scale[1],e){const e=s.unscalePoint([r,a]);t.visibleShape.moveTo(e),t.mouseTarget.moveTo(e),t.coord=[l,c],t.updateLineEnds(),L.default(t).trigger("move")}t.drawLabel()}else if("vmouseup"===n.type){if(L.default(document).unbind(".point"),t.dragging=!1,Hn=!1,N.default.isFunction(t.onMoveEnd)){const e=t.onMoveEnd(l,c);if(N.default.isArray(e)){l=e[0],c=e[1],r=(l-s.range[0][0])*s.scale[0],a=(-c+s.range[1][1])*s.scale[1];const n=s.unscalePoint([r,a]);t.visibleShape.moveTo(n),t.mouseTarget.moveTo(n),t.coord=[l,c]}}t.highlight||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight())}}))},t.visible&&!t.constraints.fixed){if(!t.mouseTarget){const e=s.unscaleVector(16),n={mouselayer:!0,padding:0,disableMouseEventsOnWrapper:!0,interactiveKindForTesting:"movable-point"};t.mouseTarget=new In(s,t.coord,e,n),t.mouseTarget.attr({fill:"#000",opacity:0})}const e=L.default(t.mouseTarget.getMouseTarget());e.css("cursor","move"),e.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)t.highlight=!0,Hn||(t.visibleShape.animate(t.highlightStyle,50),t.onHighlight&&t.onHighlight());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||Hn||(t.visibleShape.animate(t.normalStyle,50),t.onUnhighlight&&t.onUnhighlight());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();const n=t.coord,o=s.getMouseCoord(e),i=!("ontouchstart"in window)?[0,0]:d.vector.subtract(n,o);t.grab(i)}}))}return t.moveTo=function(e,n,s){const o=5*wn.getDistance(this.graph.scalePoint([e,n]),this.graph.scalePoint(this.coord)),i=s&&function(e){t.coord=e,t.updateLineEnds()};this.visibleShape.animateTo([e,n],o,i),this.mouseTarget.animateTo([e,n],o,i),this.coord=[e,n],N.default.isFunction(this.onMove)&&this.onMove(e,n)},t.updateLineEnds=function(){L.default(this.lineStarts).each((function(){this.coordA=t.coord,this.transform()})),L.default(this.lineEnds).each((function(){this.coordZ=t.coord,this.transform()})),L.default(this.polygonVertices).each((function(){this.transform()}))},t.setCoord=function(e){this.visible&&(this.visibleShape.moveTo(e),null!=this.mouseTarget&&this.mouseTarget.moveTo(e)),this.coord=e.slice()},t.setCoordConstrained=function(e){this.setCoord(o(e))},t.toBack=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toBack(),this.visibleShape.toBack())},t.toFront=function(){this.visible&&(null!=this.mouseTarget&&this.mouseTarget.toFront(),this.visibleShape.toFront())},t.remove=function(){this.visibleShape&&this.visibleShape.remove(),this.mouseTarget&&this.mouseTarget.remove(),this.labeledVertex&&this.labeledVertex.remove()},t},addMovableLineSegment:function(e){const t=L.default.extend({graph:this,coordA:[0,0],coordZ:[1,1],snapX:0,snapY:0,fixed:!1,ticks:0,normalStyle:{},highlightStyle:{stroke:gn.INTERACTING,"stroke-width":6},labelStyle:{stroke:gn.INTERACTIVE,color:gn.INTERACTIVE},highlight:!1,dragging:!1,tick:[],extendLine:!1,extendRay:!1,constraints:{fixed:!1,constrainX:!1,constrainY:!1},sideLabel:"",vertexLabels:[],numArrows:0,numTicks:0,movePointsWithLine:!1},e),n=t.fixed?gn.DYNAMIC:gn.INTERACTIVE;t.normalStyle=N.default.extend({},{"stroke-width":2,stroke:n},e.normalStyle),t.arrowStyle=N.default.extend({},t.normalStyle,{color:t.normalStyle.stroke}),void 0!==e.pointA?(t.coordA=e.pointA.coord,t.pointA.lineStarts.push(t)):void 0!==e.coordA&&(t.coordA=e.coordA.slice()),void 0!==e.pointZ?(t.coordZ=e.pointZ.coord,t.pointZ.lineEnds.push(t)):void 0!==e.coordA&&(t.coordA=t.coordA.slice());const s=t.graph;s.style(t.normalStyle);for(let e=0;e<t.ticks;++e)t.tick[e]=Wn;let o=wn.unscaledSvgPath([[0,0],[1,0]]);for(let e=0;e<t.ticks;++e){const n=.5-(t.ticks-1+2*e)/s.scale[0];o+=wn.unscaledSvgPath([[n,-7],[n,7]])}if(e={thickness:Math.max(t.normalStyle["stroke-width"],t.highlightStyle["stroke-width"])},t.visibleLine=new An(s,[0,0],[1,0],e),t.visibleLine.attr(t.normalStyle),!t.fixed){const e={thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"};t.mouseTarget=new An(s,[0,0],[1,0],e),t.mouseTarget.attr({fill:"#000",opacity:0})}if(t.transform=function(e){e&&("object"==typeof this.pointA&&(this.coordA=this.pointA.coord),"object"==typeof this.pointZ&&(this.coordZ=this.pointZ.coord));const n=function(e,n,s){const o=(e=t.graph).range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),i=e.unscaleVector(d.vector.cartFromPolarDeg(1,s)),r=d.vector.scale(d.vector.normalize(i),o),a=d.vector.add(n,r),l=d.vector.polarDegFromCart(i)[1];return e.constrainToBoundsOnAngle(a,4,l*Math.PI/180)},o=function(e){const t=e.graph.scalePoint(e.coordA),n=e.graph.scalePoint(e.coordZ);return d.vector.polarDegFromCart(d.vector.subtract(n,t))[1]}(this);let i=this.coordA,r=this.coordZ;this.extendLine?(i=n(s,i,360-o),r=n(s,r,(540-o)%360)):this.extendRay&&(r=n(s,i,360-o));const a=[this.visibleLine];this.fixed||a.push(this.mouseTarget),N.default.each(a,(function(e){e.moveTo(i,r)}));const l=function(e,t){const s=[.75,0];let o=[[-3,4],[-2.75,2.5],[0,.25],s,[0,-.25],[-2.75,-2.5],[-3,-4]];o=N.default.map(o,(function(e){const t=d.vector.subtract(e,s),n=d.vector.scale(t,1.4);return d.vector.add(s,n)}));const i=N.default.map(o,e.unscalePoint),r={center:e.unscalePoint(s),createPath:function(e){let t="M"+e[0][0]+" "+e[0][1];for(let n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t}},a=new Rn(e,i,r);return a.attr(N.default.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),a.toCoordAtAngle=function(t,o){const i=e.scalePoint(n(e,t,o)),r=Fn();a.transform("translateX("+(i[0]+1.4*s[0])+"px) translateY("+(i[1]+1.4*s[1])+"px) "+(r?"translateZ(0) ":"")+"rotate("+(360-ue.bound(o))+"deg)")},a};null==this._arrows&&(this._arrows=[],this.extendLine?(this._arrows.push(l(s,this.normalStyle)),this._arrows.push(l(s,this.normalStyle))):this.extendRay&&this._arrows.push(l(s,this.normalStyle)));const c=[this.coordA,this.coordZ],p=[360-o,(540-o)%360];N.default.each(this._arrows,(function(e,t){e.toCoordAtAngle(c[t],p[t])})),N.default.invoke(this.temp,"remove"),this.temp=[];const h=this.coordA[0]<this.coordZ[0]||this.coordA[0]===this.coordZ[0]&&this.coordA[1]>this.coordZ[1];this.sideLabel&&this.temp.push(this.graph.labelSide({point1:this.coordA,point2:this.coordZ,label:this.labeledSide,text:this.sideLabel,numArrows:this.numArrows,numTicks:this.numTicks,clockwise:h,style:this.labelStyle})),this.vertexLabels.length&&(this.graph.labelVertex({vertex:this.coordA,point3:this.coordZ,label:this.labeledVertices[0],text:this.vertexLabels[0],clockwise:h,style:this.labelStyle}),this.graph.labelVertex({point1:this.coordA,vertex:this.coordZ,label:this.labeledVertices[1],text:this.vertexLabels[1],clockwise:h,style:this.labelStyle})),this.temp=N.default.flatten(this.temp)},t.toBack=function(){t.fixed||t.mouseTarget.toBack(),t.visibleLine.toBack()},t.toFront=function(){t.fixed||t.mouseTarget.toFront(),t.visibleLine.toFront()},t.remove=function(){t.fixed||t.mouseTarget.remove(),t.visibleLine.remove(),t.labeledSide&&t.labeledSide.remove(),t.labeledVertices&&N.default.invoke(t.labeledVertices,"remove"),t._arrows&&N.default.invoke(t._arrows,"remove"),t.temp.length&&N.default.invoke(t.temp,"remove")},t.hide=function(){t.visibleLine.hide(),t.temp.length&&N.default.invoke(t.temp,"hide"),t._arrows&&N.default.invoke(t._arrows,"hide")},t.show=function(){t.visibleLine.show(),t.temp.length&&N.default.invoke(t.temp,"show"),t._arrows&&N.default.invoke(t._arrows,"show")},t.sideLabel&&(t.labeledSide=this.label([0,0],"","center",t.labelStyle)),t.vertexLabels.length&&(t.labeledVertices=N.default.map(t.vertexLabels,(function(e){return this.label([0,0],"","center",t.labelStyle)}),this)),!t.fixed&&!t.constraints.fixed){const e=L.default(t.mouseTarget.getMouseTarget());e.css("cursor","move"),e.bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Hn||(t.highlight=!0,t.visibleLine.animate(t.highlightStyle,50),t.arrowStyle=N.default.extend({},t.arrowStyle,{color:t.highlightStyle.stroke,stroke:t.highlightStyle.stroke}),t.transform());else if("vmouseout"===e.type)t.highlight=!1,t.dragging||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=N.default.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform());else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault();let n=(e.pageX-L.default(s.raphael.canvas.parentNode).offset().left)/s.scale[0]+s.range[0][0],o=s.range[1][1]-(e.pageY-L.default(s.raphael.canvas.parentNode).offset().top)/s.scale[1];t.snapX>0&&(n=Math.round(n/t.snapX)*t.snapX),t.snapY>0&&(o=Math.round(o/t.snapY)*t.snapY);const i=[t.coordA[0]-n,t.coordA[1]-o],r=[t.coordZ[0]-n,t.coordZ[1]-o],a=-Math.min(s.scaleVector(i)[0],s.scaleVector(r)[0]),l=Math.max(s.scaleVector(i)[0],s.scaleVector(r)[0]),c=Math.max(s.scaleVector(i)[1],s.scaleVector(r)[1]),p=-Math.min(s.scaleVector(i)[1],s.scaleVector(r)[1]);L.default(document).bind("vmousemove.lineSegment vmouseup.lineSegment",(function(e){e.preventDefault(),t.dragging=!0,Hn=!0;let n=e.pageX-L.default(s.raphael.canvas.parentNode).offset().left,o=e.pageY-L.default(s.raphael.canvas.parentNode).offset().top;n=Math.max(a+10,Math.min(s.xpixels-10-l,n)),o=Math.max(c+10,Math.min(s.ypixels-10-p,o));let d=n/s.scale[0]+s.range[0][0],h=s.range[1][1]-o/s.scale[1];if(t.snapX>0&&(d=Math.round(d/t.snapX)*t.snapX),t.snapY>0&&(h=Math.round(h/t.snapY)*t.snapY),"vmousemove"===e.type){t.constraints.constrainX&&(d=t.coordA[0]-i[0]),t.constraints.constrainY&&(h=t.coordA[1]-i[1]);const e=d+i[0]-t.coordA[0],n=h+i[1]-t.coordA[1];t.coordA=[d+i[0],h+i[1]],t.coordZ=[d+r[0],h+r[1]],t.transform(),t.movePointsWithLine&&("object"==typeof t.pointA&&t.pointA.setCoord([t.pointA.coord[0]+e,t.pointA.coord[1]+n]),"object"==typeof t.pointZ&&t.pointZ.setCoord([t.pointZ.coord[0]+e,t.pointZ.coord[1]+n])),N.default.isFunction(t.onMove)&&t.onMove(e,n)}else"vmouseup"===e.type&&(L.default(document).unbind(".lineSegment"),t.dragging=!1,Hn=!1,t.highlight||(t.visibleLine.animate(t.normalStyle,50),t.arrowStyle=N.default.extend({},t.arrowStyle,{color:t.normalStyle.stroke,stroke:t.normalStyle.stroke}),t.transform()),N.default.isFunction(t.onMoveEnd)&&t.onMoveEnd());L.default(t).trigger("move")}))}}))}return void 0!==t.pointA&&t.pointA.toFront(),void 0!==t.pointZ&&t.pointZ.toFront(),t.transform(),t},addMovablePolygon:function(e){const t=this,n=L.default.extend({snapX:0,snapY:0,fixed:!1,constrainToGraph:!0,normalStyle:{},highlightStyle:{stroke:gn.INTERACTING,"stroke-width":2,fill:gn.INTERACTING,"fill-opacity":.05},pointHighlightStyle:{fill:gn.INTERACTING,stroke:gn.INTERACTING},labelStyle:{stroke:gn.DYNAMIC,"stroke-width":1,color:gn.DYNAMIC},angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],updateOnPointMove:!0,closed:!0},N.default.omit(e,"points")),s=n.fixed?gn.DYNAMIC:gn.INTERACTIVE;n.normalStyle=N.default.extend({"stroke-width":2,"fill-opacity":0,fill:s,stroke:s},e.normalStyle),n.points=e.points;const o=function(e){return!N.default.isArray(e)};if(n.update=function(){const e=n.points.length;n.coords=N.default.map(n.points,(function(e,t){return o(e)?e.coord:e})),n.left=N.default.min(N.default.pluck(n.coords,0)),n.right=N.default.max(N.default.pluck(n.coords,0)),n.top=N.default.max(N.default.pluck(n.coords,1)),n.bottom=N.default.min(N.default.pluck(n.coords,1));let s=N.default.map(n.coords,(function(e){return t.scalePoint(e)}));n.closed?s.push(!0):s=s.concat(N.default.clone(s).reverse()),n.path=wn.unscaledSvgPath(s),N.default.invoke(n.temp,"remove"),n.temp=[];const i=function(e){const t=N.default.zip(e,e.slice(1).concat(e.slice(0,1)));return Dn(N.default.map(t,(function(e){const t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])})))>0}(n.coords);(n.angleLabels.length||n.showRightAngleMarkers.length)&&N.default.each(n.labeledAngles,(function(s,o){n.temp.push(t.labelAngle({point1:n.coords[(o-1+e)%e],vertex:n.coords[o],point3:n.coords[(o+1)%e],label:s,text:n.angleLabels[o],showRightAngleMarker:n.showRightAngleMarkers[o],numArcs:n.numArcs[o],clockwise:i,style:n.labelStyle}))})),n.sideLabels.length&&N.default.each(n.labeledSides,(function(s,o){n.temp.push(t.labelSide({point1:n.coords[o],point2:n.coords[(o+1)%e],label:s,text:n.sideLabels[o],numArrows:n.numArrows[o],numTicks:n.numTicks[o],clockwise:i,style:n.labelStyle}))})),n.vertexLabels.length&&N.default.each(n.labeledVertices,(function(s,o){t.labelVertex({point1:n.coords[(o-1+e)%e],vertex:n.coords[o],point3:n.coords[(o+1)%e],label:s,text:n.vertexLabels[o],clockwise:i,style:n.labelStyle})})),n.temp=N.default.flatten(n.temp)},n.transform=function(){n.update(),n.visibleShape.attr({path:n.path}),n.fixed||n.mouseTarget.attr({path:n.path})},n.remove=function(){n.visibleShape.remove(),n.fixed||n.mouseTarget.remove(),n.labeledAngles&&N.default.invoke(n.labeledAngles,"remove"),n.labeledSides&&N.default.invoke(n.labeledSides,"remove"),n.labeledVertices&&N.default.invoke(n.labeledVertices,"remove"),n.temp.length&&N.default.invoke(n.temp,"remove")},n.toBack=function(){n.fixed||n.mouseTarget.toBack(),n.visibleShape.toBack()},n.toFront=function(){n.fixed||n.mouseTarget.toFront(),n.visibleShape.toFront()},n.updateOnPointMove&&N.default.each(N.default.filter(n.points,o),(function(e){e.polygonVertices.push(n)})),n.coords=new Array(n.points.length),n.angleLabels.length){const e=Math.max(n.angleLabels.length,n.showRightAngleMarkers.length);n.labeledAngles=N.default.times(e,(function(){return this.label([0,0],"","center",n.labelStyle)}),this)}return n.sideLabels.length&&(n.labeledSides=N.default.map(n.sideLabels,(function(e){return this.label([0,0],"","center",n.labelStyle)}),this)),n.vertexLabels.length&&(n.labeledVertices=N.default.map(n.vertexLabels,(function(e){return this.label([0,0],"","center",n.labelStyle)}),this)),n.update(),n.visibleShape=t.raphael.path(n.path),n.visibleShape.attr(n.normalStyle),n.fixed||(n.mouseTarget=t.mouselayer.path(n.path),n.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"}),L.default(n.mouseTarget[0]).bind("vmousedown vmouseover vmouseout",(function(e){if("vmouseover"===e.type)Hn&&!n.dragging||(n.highlight=!0,n.visibleShape.animate(n.highlightStyle,50),N.default.each(N.default.filter(n.points,o),(function(e){e.visibleShape.animate(n.pointHighlightStyle,50)})));else if("vmouseout"===e.type){if(n.highlight=!1,!n.dragging){n.visibleShape.animate(n.normalStyle,50);const e=N.default.filter(n.points,o);N.default.any(N.default.pluck(e,"dragging"))||N.default.each(e,(function(e){e.visibleShape.animate(e.normalStyle,50)}))}}else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),N.default.each(N.default.filter(n.points,o),(function(e){e.dragging=!0}));let s=(e.pageX-L.default(t.raphael.canvas.parentNode).offset().left)/t.scale[0]+t.range[0][0],i=t.range[1][1]-(e.pageY-L.default(t.raphael.canvas.parentNode).offset().top)/t.scale[1];n.snapX>0&&(s=Math.round(s/n.snapX)*n.snapX),n.snapY>0&&(i=Math.round(i/n.snapY)*n.snapY);let r=s,a=i;const l=n.coords.slice(),c=(s-n.left)*t.scale[0],p=(n.right-s)*t.scale[0],d=(n.top-i)*t.scale[1],h=(i-n.bottom)*t.scale[1];L.default(document).bind("vmousemove.polygon vmouseup.polygon",(function(e){e.preventDefault(),n.dragging=!0,Hn=!0;let u=e.pageX-L.default(t.raphael.canvas.parentNode).offset().left,f=e.pageY-L.default(t.raphael.canvas.parentNode).offset().top;n.constrainToGraph&&(u=Math.max(c+10,Math.min(t.xpixels-10-p,u)),f=Math.max(d+10,Math.min(t.ypixels-10-h,f)));let m=u/t.scale[0]+t.range[0][0],g=t.range[1][1]-f/t.scale[1];if(n.snapX>0&&(m=Math.round(m/n.snapX)*n.snapX),n.snapY>0&&(g=Math.round(g/n.snapY)*n.snapY),"vmousemove"===e.type){let e=m-s,t=g-i,c=!0;if(N.default.isFunction(n.onMove)){const o=n.onMove(e,t);!1===o?c=!1:N.default.isArray(o)&&(e=o[0],t=o[1],m=s+e,g=i+t)}const p=function(n){return[l[n][0]+e,l[n][1]+t]};c&&(N.default.each(n.points,(function(e,t){o(e)?e.setCoord(p(t)):n.points[t]=p(t)})),n.transform(),L.default(n).trigger("move"),r=m,a=g)}else if("vmouseup"===e.type){L.default(document).unbind(".polygon");const e=N.default.filter(n.points,o);N.default.each(e,(function(e){e.dragging=!1})),n.dragging=!1,Hn=!1,n.highlight||(n.visibleShape.animate(n.normalStyle,50),N.default.each(e,(function(e){e.visibleShape.animate(e.normalStyle,50)}))),N.default.isFunction(n.onMoveEnd)&&n.onMoveEnd(r-s,a-i)}}))}}))),N.default.invoke(N.default.filter(n.points,o),"toFront"),n},constrainToBounds:function(e,t){const n=this.unscalePoint([t,this.ypixels-t]),s=this.unscalePoint([this.xpixels-t,t]);return[Math.max(n[0],Math.min(s[0],e[0])),Math.max(n[1],Math.min(s[1],e[1]))]},constrainToBoundsOnAngle:function(e,t,n){const s=this.unscalePoint([t,this.ypixels-t]),o=this.unscalePoint([this.xpixels-t,t]);let i=e.slice();return i[0]<s[0]?i=[s[0],i[1]+(s[0]-i[0])*Math.tan(n)]:i[0]>o[0]&&(i=[o[0],i[1]-(i[0]-o[0])*Math.tan(n)]),i[1]<s[1]?i=[i[0]+(s[1]-i[1])/Math.tan(n),s[1]]:i[1]>o[1]&&(i=[i[0]-(i[1]-o[1])/Math.tan(n),o[1]]),i},addMovableAngle:function(e){return new Vn(this,e)},addCircleGraph:function(e){const t=this,n=L.default.extend({center:[0,0],radius:2,snapX:.5,snapY:.5,snapRadius:.5,minRadius:1,centerConstraints:{},centerNormalStyle:{},centerHighlightStyle:{stroke:gn.INTERACTING,fill:gn.INTERACTING},circleNormalStyle:{stroke:gn.INTERACTIVE,"fill-opacity":0},circleHighlightStyle:{stroke:gn.INTERACTING,fill:gn.INTERACTING,"fill-opacity":.05}},e),s=n.centerConstraints.fixed?gn.DYNAMIC:gn.INTERACTIVE,o=e?e.centerNormalStyle:null;n.centerNormalStyle=N.default.extend({},{fill:s,stroke:s},o),n.centerPoint=t.addMovablePoint({graph:t,coord:n.center,normalStyle:n.centerNormalStyle,snapX:n.snapX,snapY:n.snapY,constraints:n.centerConstraints}),n.circ=t.circle(n.center,n.radius,n.circleNormalStyle),n.perim=t.mouselayer.circle(t.scalePoint(n.center)[0],t.scalePoint(n.center)[1],t.scaleVector(n.radius)[0]).attr({"stroke-width":20,opacity:.002}),n.centerConstraints.fixed||L.default(n.centerPoint.mouseTarget.getMouseTarget()).on("vmouseover vmouseout",(function(e){n.centerPoint.highlight||n.centerPoint.dragging?n.circ.animate(n.circleHighlightStyle,50):n.circ.animate(n.circleNormalStyle,50)})),n.toFront=function(){n.circ.toFront(),n.perim.toFront(),n.centerPoint.visibleShape.toFront(),n.centerConstraints.fixed||n.centerPoint.mouseTarget.toFront()},n.centerPoint.onMove=function(e,s){n.toFront(),n.circ.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(s)[1]}),n.perim.attr({cx:t.scalePoint(e)[0],cy:t.scalePoint(s)[1]}),n.onMove&&n.onMove(e,s)},L.default(n.centerPoint).on("move",(function(){n.center=this.coord,L.default(n).trigger("move")})),n.setCenter=function(e,t){n.centerPoint.setCoord([e,t]),n.centerPoint.onMove(e,t),n.center=[e,t]},n.setRadius=function(e){n.radius=e,n.perim.attr({r:t.scaleVector(e)[0]}),n.circ.attr({rx:t.scaleVector(e)[0],ry:t.scaleVector(e)[1]})},n.remove=function(){n.centerPoint.remove(),n.circ.remove(),n.perim.remove()};const i=[[-1*Math.PI,-.875*Math.PI,"ew-resize"],[-.875*Math.PI,-.625*Math.PI,"nesw-resize"],[-.625*Math.PI,-.375*Math.PI,"ns-resize"],[-.375*Math.PI,-.125*Math.PI,"nwse-resize"],[-.125*Math.PI,.125*Math.PI,"ew-resize"],[.125*Math.PI,.375*Math.PI,"nesw-resize"],[.375*Math.PI,.625*Math.PI,"ns-resize"],[.625*Math.PI,.875*Math.PI,"nwse-resize"],[.875*Math.PI,1*Math.PI,"ew-resize"]];return L.default(n.perim.node).on("vmousemove",(e=>{let[t,s]=this.getMouseCoord(e);t-=n.center[0],s-=n.center[1];const o=Math.atan2(s,t);i.forEach((function(e){const[t,s,i]=e;o>=t&&o<s&&L.default(n.perim.node).css("cursor",i)}))})),L.default(n.perim.node).css("cursor","nesw-resize"),n.perim.node.addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),L.default(n.perim.node).on("vmouseover vmouseout vmousedown",(function(e){if("vmouseover"===e.type)n.highlight=!0,Hn||(n.circ.animate(n.circleHighlightStyle,50),n.centerPoint.visibleShape.animate(n.centerHighlightStyle,50));else if("vmouseout"===e.type)n.highlight=!1,n.dragging||n.centerPoint.dragging||(n.circ.animate(n.circleNormalStyle,50),n.centerPoint.visibleShape.animate(n.centerNormalStyle,50));else if("vmousedown"===e.type&&(1===e.which||0===e.which)){e.preventDefault(),n.toFront();const s=n.radius;L.default(document).on("vmousemove vmouseup",(function(e){if(e.preventDefault(),n.dragging=!0,Hn=!0,"vmousemove"===e.type){const s=t.constrainToBounds(t.getMouseCoord(e),10);let o=wn.getDistance(n.centerPoint.coord,s);o=Math.max(n.minRadius,Math.round(o/n.snapRadius)*n.snapRadius);const i=n.radius;let r=!0;if(n.onResize){const e=n.onResize(o,i);N.default.isNumber(e)?o=e:!1===e&&(r=!1)}r&&(n.setRadius(o),L.default(n).trigger("move"))}else"vmouseup"===e.type&&(L.default(document).off("vmousemove vmouseup"),n.dragging=!1,Hn=!1,n.onResizeEnd&&n.onResizeEnd(n.radius,s))}))}})),n},addRotateHandle:function(e){const t=this;let n=e.center;const s=e.radius,o=e.lengthAngle||30,i=e.hideArrow||!1,r=e.mouseTarget,a=N.default.uniqueId("rotateHandle");N.default.isArray(n)&&(n={coord:n});const l=t.addMovablePoint({coord:d.point.addVector(n.coord,d.vector.cartFromPolarDeg(s,e.angleDeg||0)),constraints:{fixedDistance:{dist:s,point:n}},mouseTarget:r});n.toFront();let c,p=n.coord,h=l.coord,u=h,f=!1,m=!1;const g=function(s){if(i)return;const r=d.vector.subtract(s,n.coord),a=d.vector.polarDegFromCart(r)[1];c&&c.remove(),c=function(e,t,n,s,o,i,r){const a=function(s,o){const r=n+o,a=d.vector.cartFromPolarDeg(r,i+s),l=d.vector.add(t,a),c=e.scalePoint(l);return c[0]+","+c[1]},l=e.scaleVector(n-s),c=e.scaleVector(n+s);return e.raphael.path(" M"+a(o,-s)+" L"+a(o,-3*s)+" L"+a(2*o,0)+" L"+a(o,3*s)+" L"+a(o,s)+" A"+c[0]+","+c[1]+",0,0,1,"+a(-o,s)+" L"+a(-o,3*s)+" L"+a(-2*o,0)+" L"+a(-o,-3*s)+" L"+a(-o,-s)+" A"+l[0]+","+l[1]+",0,0,0,"+a(o,-s)+" Z").attr({stroke:null,fill:r?gn.INTERACTING:gn.INTERACTIVE})}(t,n.coord,e.radius,f||m?e.hoverWidth/2:e.width/2,o,a,f||m)};L.default(n).on("move."+a,(function(){const e=d.vector.subtract(n.coord,p);l.setCoord(d.vector.add(l.coord,e)),g(l.coord),p=n.coord,l.constraints.fixedDistance.point=n,h=l.coord})),l.onMove=function(t,s){f||(u=h,f=!0);let o=[t,s];if(e.onMove){const t=d.vector.polarDegFromCart(d.vector.subtract(h,n.coord)),s=d.vector.polarDegFromCart(d.vector.subtract(o,n.coord)),i=t[1],r=s[1];let a=e.onMove(r,i);null!=a&&!0!==a&&(!1===a&&(a=i),o=d.vector.add(n.coord,d.vector.cartFromPolarDeg(t[0],a)))}return g(o),h=o,o},l.onMoveEnd=function(){if(f=!1,g(l.coord),e.onMoveEnd){const t=d.vector.polarDegFromCart(d.vector.subtract(u,n.coord)),s=d.vector.polarDegFromCart(d.vector.subtract(l.coord,n.coord));e.onMoveEnd(s[1],t[1])}},l.visibleShape.remove(),r||l.mouseTarget.attr({scale:2});const v=L.default(l.mouseTarget.getMouseTarget());v.bind("vmouseover",(function(e){m=!0,g(l.coord)})),v.bind("vmouseout",(function(e){m=!1,g(l.coord)})),g(l.coord);const b=l.remove;return l.remove=function(){b.call(l),c&&c.remove(),L.default(n).off("move."+a)},l.update=function(){g(l.coord)},l},addReflectButton:function(e){const t=this,n=e.line,s=t.addMovablePoint({constraints:e.constraints,coord:d.line.midpoint([n.pointA.coord,n.pointZ.coord]),snapX:t.snap[0],snapY:t.snap[1],onMove:function(e,t){return!1},onMoveEnd:function(t,n){e.onMoveEnd&&e.onMoveEnd.call(this,t,n)}});let o,i=!1,r=!1;const a=function(){return i},l=N.default.map([0,1],(function(t){const n=t?e.highlightStyle:e.normalStyle;return N.default.map([0,1],(function(e){return N.default.defaults({"fill-opacity":e},n)}))})),c=function(e){return r&&(e=!e),l[+a()][+e]},p=function(n,s){o&&o.remove(),o=function(e,t,n,s,o,i,r){d.point.equal(n[0],n[1])&&(n=[n[0],d.point.addVector(n[0],[1,1])]);const a=d.vector.normalize(d.vector.subtract(n[1],n[0])),l=d.vector.scale(a,s/2),c=d.vector.scale(a,o),p=d.vector.rotateDeg(c,90),h=d.vector.rotateDeg(c,-90),u=d.vector.negate(l),f=d.vector.rotateDeg(l,90),m=d.vector.rotateDeg(l,-90),g=d.point.addVectors(t,p),v=d.point.addVectors(t,h),b=d.point.addVectors(t,p,l,f),y=d.point.addVectors(t,p,u,f),x=d.point.addVectors(t,h,l,m),C=d.point.addVectors(t,h,u,m),w=e.path([g,b,y,!0],i),k=e.path([v,x,C,!0],r);return{remove:function(){w.remove(),k.remove()}}}(t,n,s,a()?1.5*e.size:e.size,a()?.125*e.size:.25,c(0),c(1))},h=function(e,t){e=e||n.pointA.coord,t=t||n.pointZ.coord;const o=d.line.midpoint([e,t]);s.setCoord(o),p(o,[e,t])};L.default(n).on("move",N.default.bind(h,s,null,null));const u=L.default(s.mouseTarget.getMouseTarget());u.on("vclick",(function(){!1!==e.onClick()&&(r=!r,p(s.coord,[n.pointA.coord,n.pointZ.coord]))})),n.pointA.toFront(),n.pointZ.toFront(),s.visibleShape.remove();const f=t.scaleVector(e.size)[0]/20;s.mouseTarget.attr({scale:1.5*f}),u.css("cursor","pointer"),u.bind("vmouseover",(function(e){i=!0,p(s.coord,[n.pointA.coord,n.pointZ.coord])})),u.bind("vmouseout",(function(e){i=!1,p(s.coord,[n.pointA.coord,n.pointZ.coord])}));const m=s.remove;return s.remove=function(){o.remove(),m.call(s)},s.update=h,s.isFlipped=function(){return r},h(),s},protractor:function(e){return new Un(this,e)},ruler:function(e){return new Gn(this,e||{})},addPoints:On}),N.default.extend(Vn.prototype,{points:[],snapDegrees:0,snapOffsetDeg:0,angleLabel:"",numArcs:1,pushOut:0,fixed:!1,addMoveHandlers:function(){const e=this.graphie;function t(t,n){return wn.getDistance(e.scalePoint(t),e.scalePoint(n))<30}const n=this.points;n[1].onMove=function(s,o){const i=n[1].coord,r=[s,o],a=On(r,Ln(i));let l=!0;const c={};return N.default.each([0,2],(function(s){let o=On(n[s].coord,a),i=wn.findAngle(r,o);i*=Math.PI/180,o=e.constrainToBoundsOnAngle(o,10,i),c[s]=o,t(r,o)&&(l=!1)})),l&&N.default.each(c,(function(e,t){n[t].setCoord(e)})),l};const s=this.snapDegrees,o=this.snapOffsetDeg;N.default.each([0,2],(function(i){n[i].onMove=function(i,r){const a=[i,r],l=n[1].coord;if(t(l,a))return!1;if(s){let t=wn.findAngle(a,l);t=Math.round((t-o)/s)*s+o;const n=wn.getDistance(a,l);return On(l,e.polar(n,t))}return!0}})),L.default(n).on("move",function(){this.update(),L.default(this).trigger("move")}.bind(this))},addHighlightHandlers:function(){const e=this.points[1];e.onHighlight=function(){N.default.each(this.points,(function(e){e.visibleShape.animate(this.highlightStyle,50)}),this),N.default.each(this.rays,(function(e){e.visibleLine.animate(this.highlightStyle,50),e.arrowStyle=N.default.extend({},e.arrowStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke})}),this),this.angleStyle=N.default.extend({},this.angleStyle,{color:this.highlightStyle.stroke,stroke:this.highlightStyle.stroke}),this.update()}.bind(this),e.onUnhighlight=function(){N.default.each(this.points,(function(e){e.visibleShape.animate(this.normalStyle,50)}),this),N.default.each(this.rays,(function(e){e.visibleLine.animate(e.normalStyle,50),e.arrowStyle=N.default.extend({},e.arrowStyle,{color:e.normalStyle.stroke,stroke:e.normalStyle.stroke})}),this),this.angleStyle=N.default.extend({},this.angleStyle,{color:gn.DYNAMIC,stroke:gn.DYNAMIC}),this.update()}.bind(this)},_getClockwiseAngle:function(e){return wn.findAngle(e[2],e[0],e[1])+0},isReflex:function(){return this.reflex},isClockwise:function(){return this._getClockwiseAngle(this.coords)>180===this.reflex},getClockwiseCoords:function(){return this.isClockwise()?N.default.clone(this.coords):N.default.clone(this.coords).reverse()},update:function(e){const t=this.coords;this.coords=N.default.pluck(this.points,"coord"),N.default.invoke(this.points,"updateLineEnds");const n=this._getClockwiseAngle(t),s=this._getClockwiseAngle(this.coords),o=n>180,i=s>180;this.allowReflex&&(null==e&&(e=o!==i&&Math.abs(s-n)<180),e&&(this.reflex=!this.reflex)),N.default.invoke(this.temp,"remove"),this.temp=this.graphie.labelAngle({point1:this.coords[0],vertex:this.coords[1],point3:this.coords[2],label:this.labeledAngle,text:this.angleLabel,numArcs:this.numArcs,pushOut:this.pushOut,clockwise:this.reflex===i,style:this.angleStyle})},remove:function(){N.default.invoke(this.rays,"remove"),N.default.invoke(this.temp,"remove"),this.labeledAngle.remove()}});const jn=Be.nestedMap,Yn=Be.deepEq;function Xn(e){N.default.extend(this,e)}const $n=function(){throw new he("Abstract method! Must be implemented by Graphie Movable"+this.constructor.displayName,pe.NotAllowed)};N.default.extend(Xn.prototype,{movableProps:[],add:$n,modify:$n,remove:$n,toFront:function(){},componentDidMount:function(){}});const Kn=function(e){const t=function(e){if(!(this instanceof t))throw new he("Use createElement or JSX with graphie movables",pe.NotAllowed);return this.props=function(e,t){return N.default.extend({},e,{children:N.default.filter(N.default.flatten(t),N.default.identity)})}(e,e.children||[]),this};return e.displayName=e.displayName||N.default.uniqueId("GraphieClass"),t.displayName=e.displayName,t.prototype=new Xn(e),t.prototype.constructor=t,t};var Zn={GraphieMovable:Xn,createClass:Kn,createSimpleClass:function(e){return Kn({displayName:e.name||N.default.uniqueId("GraphieSimpleClass"),movableProps:["children"],add:function(t){this._elements=e(t,this.props),this._prevProps=this.props},modify:function(e){if(!Yn(this.props,this._prevProps))return this.remove(),this.add(e),this._prevProps=this.props,"reordered"},remove:function(){jn(this._elements,(e=>{e&&e.remove()})),this._elements=null,this._prevProps=null},toFront:function(){jn(this._elements,(e=>{N.default.isFunction(e.toFront)&&e.toFront()}))}})}};const Jn=function(e){const t=e.graphie.scalePoint(e.coord(0)),n=e.graphie.scalePoint(e.coord(1));return d.vector.polarDegFromCart(d.vector.subtract(n,t))[1]},Qn=function(e,t,n){const s=e.range[0][1]-e.range[0][0]+(e.range[1][1]-e.range[1][0]),o=e.unscaleVector(d.vector.cartFromPolarDeg(1,n)),i=d.vector.scale(d.vector.normalize(o),s),r=d.vector.add(t,i),a=d.vector.polarDegFromCart(o)[1];return e.constrainToBoundsOnAngle(r,4,a*Math.PI/180)},es=function(e,t){const n=[.75,0];let s=[[-3,4],[-2.75,2.5],[0,.25],n,[0,-.25],[-2.75,-2.5],[-3,-4]];s=N.default.map(s,(function(e){const t=d.vector.subtract(e,n),s=d.vector.scale(t,1.4);return d.vector.add(n,s)}));const o=N.default.map(s,e.unscalePoint),i={center:e.unscalePoint(n),createPath:function(e){let t="M"+e[0][0]+" "+e[0][1];for(let n=1;n<e.length;n+=3)t+="C"+e[n][0]+" "+e[n][1]+" "+e[n+1][0]+" "+e[n+1][1]+" "+e[n+2][0]+" "+e[n+2][1];return t}},r=new Rn(e,o,i);return r.attr(N.default.extend({"stroke-linejoin":"round","stroke-linecap":"round","stroke-dasharray":""},t)),r.toCoordAtAngle=function(t,s){const o=e.scalePoint(Qn(e,t,s));r.transform("translateX("+(o[0]+1.4*n[0])+"px) translateY("+(o[1]+1.4*n[1])+"px) translateZ(0) rotate("+(360-ue.bound(s))+"deg)")},r},ts={draw:function(){this.draw()},pointsToFront:function(e){N.default.invoke(e.points,"toFront")}};ts.standard=[ts.draw,ts.pointsToFront];const ns={draw:function(){this.draw()}};ns.standard=[ns.draw];const ss={basic:function(e){const t=this.graphie;let n=this.coord(0),s=this.coord(1);if(!this.state.visibleShape){const e={thickness:10};this.state.visibleShape=new An(t,n,s,e),this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}const o=Jn(this);e.extendLine?(n=Qn(t,n,360-o),s=Qn(t,s,(540-o)%360)):e.extendRay&&(s=Qn(t,s,360-o));const i=[this.state.visibleShape];this.mouseTarget()&&i.push(this.mouseTarget()),N.default.each(i,(function(e){e.moveTo(n,s)}))},arrows:function(e){null==this._arrows&&(this._arrows=[],e.extendLine?(this._arrows.push(es(this.graphie,this.normalStyle())),this._arrows.push(es(this.graphie,this.normalStyle()))):e.extendRay&&this._arrows.push(es(this.graphie,this.normalStyle())));const t=Jn(this),n=[360-t,(540-t)%360];N.default.each(this._arrows,(function(e,t){e.toCoordAtAngle(this.coord(t),n[t])}),this)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(e.highlightStyle,50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(e.normalStyle,50)}};ss.standard=[ss.basic,ss.arrows,ss.highlight];const os={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},arrows:function(){null!=this._arrows&&N.default.invoke(this._arrows,"remove"),this._arrows=null}};os.standard=[os.basic,os.arrows];const is={fixed:function(){return function(){return!1}},snap:function(e){return function(t,n){if(null===e)return!0;let s=d.vector.subtract(t,n);return e=e||this.graphie.snap,s=d.point.roundTo(s,e),d.vector.add(n,s)}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(s,o){const i=this.graphie,r=d.vector.subtract(s,o);e=e||i.range,void 0===t&&(t=i.snap);let a=i.unscalePoint([n,i.ypixels-n]),l=i.unscalePoint([i.xpixels-n,n]);t&&(a=d.point.ceilTo(a,t),l=d.point.floorTo(l,t));const c=N.default.map(this.coords(),(function(e,t){const n=d.vector.subtract(l,e);return[d.vector.subtract(a,e),n]})),p=N.default.reduce(c,(function(e,t){const n=t[0],s=t[1];return[Math.max(n[0],Math.min(s[0],e[0])),Math.max(n[1],Math.min(s[1],e[1]))]}),r);return d.vector.add(o,p)}},standard:null},rs={updatePoints:function(e,t){const n=d.vector.subtract(e,t);N.default.each(this.state.points,(function(e){e.setCoord(d.vector.add(e.coord(),n))}))},standard:null};var as={add:ts,modify:ns,draw:ss,remove:os,onMoveStart:{standard:null},constraints:is,onMove:rs,onMoveEnd:{standard:null}};const ls=un.assert,cs=un.normalizeOptions,ps=["add","draw","remove","onMoveStart","constraints","onMove","onMoveEnd"],ds={points:null,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,extendLine:!1,extendRay:!1},hs={visibleShape:null,mouseTarget:null},us=function(e,t,n){ls(null!=e),ls(null!=n),N.default.extend(this,{graphie:e,movable:t,state:{id:N.default.uniqueId("movableLine")}}),this.modify(N.default.extend({},hs,n))};N.default.extend(us,as),un.createGettersFor(us,N.default.extend({},ds,hs)),un.addMovableHelperMethodsTo(us),N.default.extend(us.prototype,{cloneState:function(){return N.default.extend(this.movable.cloneState(),{coords:this.coords()},this.state)},_createDefaultState:function(){return N.default.extend({id:this.state.id},cs(ps,_n.pluck(as,"standard")),ds)},modify:function(e){this.update(N.default.extend(this._createDefaultState(),e))},update:function(e){const t=this,n=this.graphie,s=t.state=N.default.extend(t.state,cs(ps,e)),o=s.static?gn.DYNAMIC:gn.INTERACTIVE;if(s.normalStyle=N.default.extend({stroke:o,"stroke-width":2},s.normalStyle),s.highlightStyle=N.default.extend({stroke:gn.INTERACTING,"stroke-width":3},s.highlightStyle),!s.static&&!s.mouseTarget){const e={thickness:30,mouselayer:!0,interactiveKindForTesting:"movable-line"};s.mouseTarget=new An(n,this.coord(0),this.coord(1),e),s.mouseTarget.attr({fill:"#000",opacity:0})}s.static&&s.mouseTarget&&(s.mouseTarget.remove(),s.mouseTarget=null),t.movable.modify(N.default.extend({},s,{mouseTarget:s.mouseTarget,add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){const s=d.vector.subtract(e,n);t._totalDelta=d.vector.add(t._totalDelta,s);let o=d.vector.add(t._initialRefCoord,t._totalDelta);o=t._applyConstraints(o,t._prevRefCoord),!1!==o&&(t._fireEvent(t.state.onMove,o,t._prevRefCoord),t._prevRefCoord=o)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),s.added||(t.prevState={},t._fireEvent(s.add,t.cloneState(),t.prevState),s.added=!0,N.default.invoke(s.points,"listen","onMove",s.id,t.draw.bind(t)),t.prevState=t.cloneState()),t._fireEvent(s.modify,t.cloneState(),t.prevState)},coords:function(){return N.default.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.points&&N.default.invoke(this.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove()},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}});const fs={path:"M8.70710678,12.2928932 C8.31658249,11.9023689 7.68341751,11.9023689 7.29289322,12.2928932 C6.90236893,12.6834175 6.90236893,13.3165825 7.29289322,13.7071068 L9.82842712,16.2426407 C10.2207367,16.6349502 10.8574274,16.6328935 11.2471942,16.2380576 L16.7116603,10.7025237 C17.0996535,10.3094846 17.0955629,9.67633279 16.7025237,9.28833966 C16.3094846,8.90034653 15.6763328,8.90443714 15.2883397,9.29747629 L10.5309507,14.1167372 L8.70710678,12.2928932 Z",width:24,height:24},ms={path:"M6.072 10.4l6.175-7.058a1 1 0 1 1 1.506 1.317L6.769 12.64a1 1 0 0 1-1.55-.054L2.203 8.604a1 1 0 1 1 1.594-1.208L6.072 10.4z",width:16,height:16},gs={path:"M99.669 13.048q0 3.36-2.352 5.712l-41.664 41.664q-2.408 2.408-5.88 2.408t-5.712-2.408l-41.664-41.664q-2.408-2.24-2.408-5.712t2.408-5.88l4.76-4.816q2.52-2.352 5.88-2.352t5.656 2.352l31.136 31.136 31.08-31.136q2.352-2.352 5.712-2.352t5.88 2.352l4.816 4.816q2.352 2.52 2.352 5.88z",width:100,height:63.034},vs={path:"M62.808 49.728q0 3.36-2.352 5.88l-41.72 41.664q-2.352 2.408-5.768 2.408t-5.768-2.408l-4.872-4.76q-2.352-2.52-2.352-5.88t2.352-5.712l31.08-31.136-31.08-31.024q-2.352-2.52-2.352-5.88t2.352-5.712l4.872-4.76q2.296-2.408 5.768-2.408t5.768 2.408l41.72 41.664q2.352 2.296 2.352 5.656z",width:63.034,height:100},bs={path:"M100.035 50.046q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},ys={path:"M50.046 83.676q1.767 0 2.907-1.14l29.526-29.526q1.197-1.197 1.197-2.907t-1.197-2.964l-5.928-5.928q-1.197-1.14-2.964-1.14t-2.907 1.14l-12.312 12.312l0-32.661q0-1.71-1.254-2.964t-2.907-1.254l-8.322 0q-1.71 0-2.964 1.254t-1.254 2.964l0 32.661l-12.312-12.312q-1.197-1.254-2.907-1.254t-2.907 1.254l-5.928 5.928q-1.197 1.197-1.197 2.964t1.197 2.907l29.469 29.526q1.197 1.14 2.964 1.14zm49.989-33.63q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},xs={path:"M54.207 83.391q1.653 0 2.907-1.254t1.254-2.907l0-32.718l12.312 12.312q1.254 1.254 2.964 1.254t2.907-1.254l5.928-5.928q1.197-1.197 1.14-2.964 0-1.767-1.14-2.907l-29.526-29.526q-1.197-1.14-2.907-1.14t-2.964 1.14l-29.469 29.526q-1.197 1.254-1.197 2.964t1.197 2.907l5.928 5.928q1.197 1.197 2.907 1.197t2.907-1.197l12.312-12.312l0 32.718q0 1.653 1.254 2.907t2.964 1.254l8.322 0zm45.828-33.345q.057 13.623-6.669 25.137t-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.669 25.137z",width:100,height:100},Cs={path:"M50.046 8.322q-8.493 0-16.188 3.306-15.561 6.669-22.173 22.23-3.363 7.695-3.363 16.188t3.306 16.188 8.949 13.281q5.586 5.586 13.281 8.892t16.188 3.306 16.188-3.306 13.281-8.892 8.892-13.281 3.306-16.188-3.306-16.188-8.892-13.281-13.281-8.949q-7.695-3.306-16.188-3.306zm0 91.713q-13.623 0-25.137-6.726t-18.183-18.183q-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.126q-11.514 6.726-25.08 6.726z",width:100,height:99.944},ws={path:"M58.368 81.225l0-12.369q0-.912-.57-1.539t-1.425-.627l-12.54 0q-.855-.057-1.482.627t-.684 1.539l0 12.369q-.057.855.627 1.482t1.539.684l12.54 0q.855 0 1.425-.627t.57-1.539zm1.026-62.871q0-1.596-2.223-1.71l-14.307 0q-2.109 0-2.223 1.71l1.14 40.47q0 .627.627 1.14t1.539.456l12.084 0q.912-.057 1.539-.513t.684-1.083zm-9.348-18.354q13.566 0 25.08 6.726 11.514 6.669 18.24 18.183t6.726 25.137-6.726 25.137-18.24 18.183-25.08 6.669-25.137-6.726q-11.514-6.726-18.183-18.183-6.726-11.571-6.726-25.137t6.726-25.08 18.24-18.24 25.08-6.669z",width:100,height:99.944},ks={path:"M37.964 76.048q-2.576 0-4.368-1.792l-31.864-31.864q-1.792-1.792-1.792-4.368t1.792-4.368l8.736-8.68q1.792-1.792 4.368-1.792t4.312 1.792l18.816 18.872 42-42.056q1.792-1.792 4.368-1.792t4.312 1.792l8.736 8.736q1.792 1.792 1.792 4.368t-1.792 4.312l-55.048 55.048q-1.792 1.792-4.368 1.792z",width:100,height:76.637},Ss={path:"M99.758 43.09l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-29.45 0l0 29.45q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-29.45l-29.45 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l29.45 0l0-29.45q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836l0 29.45l29.45 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:100},Es={path:"M100.464 80.808q0 3.404-2.368 5.772l-11.47 11.544q-2.368 2.368-5.772 2.368t-5.698-2.368l-24.864-24.864-24.864 24.864q-2.368 2.368-5.772 2.368t-5.772-2.368l-11.47-11.544q-2.368-2.368-2.368-5.772t2.368-5.698l24.864-24.864-24.864-24.864q-2.368-2.368-2.368-5.772t2.368-5.772l11.47-11.47q2.368-2.368 5.772-2.368t5.772 2.368l24.864 24.864 24.864-24.864q2.294-2.368 5.698-2.368t5.772 2.368l11.47 11.47q2.368 2.368 2.368 5.772t-2.368 5.772l-24.864 24.864 24.864 24.864q2.368 2.294 2.368 5.698z",width:100,height:100},_s={path:"M15.1052249,9.55978547 L22.0028147,9.55978545 C23.6568673,9.55978545 23.9349557,10.3753626 22.6181351,11.3858845 L16.9943688,15.7015366 L19.2518801,22.8294455 C19.7526645,24.4106317 19.0984455,24.8825885 17.769353,23.8673293 L12.0490577,19.4977438 L6.5116497,23.8422153 C5.20921411,24.8640642 4.53299569,24.4067544 5.00266927,22.8160582 L7.10332364,15.7015366 L1.42794544,11.3634306 C0.110226041,10.3562014 0.383967283,9.54239221 2.0409646,9.54574013 L8.9924676,9.55978547 L11.1485117,2.72669438 C11.6458693,1.15043244 12.4548928,1.15900049 12.9494787,2.72669438 L15.1052249,9.55978547 Z",width:24,height:24},Ms={path:"M3.74890556,17.9799506 C2.19251241,16.1970909 1.10103636,13.4971457 1.13090903,11.1491783 C1.17160478,7.95052637 4.01704076,0.865059407 11.7028044,0.865059407 C19.388568,0.865059407 22.3026521,7.35203035 22.3026521,11.5879453 C22.3026521,15.8238603 19.386629,20.5574509 13.6832464,21.7131548 L13.6757539,17.3722171 C17.0812986,16.2190517 18.331158,14.1944123 18.3311578,11.5879451 C18.3311574,8.16554692 15.6664205,5.03476549 11.7028048,5.20494205 C7.73918903,5.37511861 5.59244567,8.66930079 5.59244567,11.1491783 C5.59244567,12.9090077 6.11128139,14.1753512 6.93640437,15.3053215 L8.14052356,14.2949456 C8.98559348,13.5858477 9.6994861,13.9070448 9.73489556,15.0076413 L9.91284941,20.5388014 C9.94832683,21.6415103 9.09967118,22.3514475 8.02194403,22.1254594 L2.60571602,20.9897332 C1.5259204,20.7633114 1.34338662,19.9984207 2.18070755,19.295825 L3.74890556,17.9799506 Z",width:23,height:23},Ts={path:"M31.293 37.506q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.218 0q-.912-.057-1.482-.627t-.57-1.482l0-37.506q0-2.109 2.052-2.109l4.218 0zm18.753 2.109l0 37.506q0 .912-.57 1.482t-1.539.627l-4.161 0q-1.995 0-2.109-2.109l0-37.506q.057-.912.627-1.482t1.482-.627l4.161 0q.969.057 1.539.627t.57 1.482zm14.592-2.109q2.052 0 2.052 2.109l0 37.506q0 1.995-2.052 2.109l-4.161 0q-.969-.057-1.539-.627t-.57-1.482l0-37.506q0-2.109 2.109-2.109l4.161 0zm10.431 49.248l0-61.731l-58.368 0l0 61.731q.057 2.679.969 3.819t1.083 1.14l54.207 0q.171 0 1.14-1.083t.969-3.876zm-43.776-70.11l29.184 0l-3.135-7.581q-.456-.57-1.14-.741l-20.634 0q-.627.114-1.083.741zm-31.293 2.109q0-1.995 2.109-2.109l20.121 0l4.56-10.83q.969-2.394 3.477-4.104 2.565-1.71 5.187-1.71l20.805 0q2.622 0 5.187 1.71t3.477 4.104l4.56 10.83l20.178 0q.912.057 1.482.627t.57 1.482l0 4.161q0 1.995-2.052 2.109l-6.27 0l0 61.731q0 5.415-3.078 9.348t-7.353 3.933l-54.207 0q-4.275 0-7.353-3.819t-3.078-9.177l0-62.016l-6.213 0q-.969 0-1.539-.57t-.57-1.539l0-4.161z",width:91.681,height:100},Is={path:"M10,6.6C10,7.2,9.8,8,9.3,9.1c0,0,0,0.1-0.1,0.1S9.2,9.3,9.2,9.4c0,0,0,0.1-0.1,0.1C9,9.6,9,9.6,8.9,9.6 c-0.1,0-0.1,0-0.1-0.1c0,0,0-0.1,0-0.1c0,0,0-0.1,0-0.1s0-0.1,0-0.1c0-0.3,0-0.5,0-0.7c0-0.4,0-0.7-0.1-1C8.6,7.1,8.5,6.9,8.4,6.7S8.2,6.3,8,6.1C7.8,5.9,7.6,5.8,7.4,5.7S6.9,5.5,6.7,5.5S6.1,5.4,5.8,5.4c-0.3,0-0.6,0-1,0H3.6v1.4c0,0.1,0,0.2-0.1,0.3C3.4,7.1,3.3,7.1,3.2,7.1C3.1,7.1,3,7.1,3,7L0.1,4.1C0,4.1,0,4,0,3.9s0-0.2,0.1-0.3L3,0.8C3,0.7,3.1,0.7,3.2,0.7c0.1,0,0.2,0,0.3,0.1C3.5,0.9,3.6,0.9,3.6,1v1.4h1.2c2.6,0,4.3,0.7,4.9,2.2C9.9,5.2,10,5.8,10,6.6z",width:10,height:10},Ps={path:"M8,13 L16,13 C16.5522847,13 17,12.5522847 17,12 C17,11.4477153 16.5522847,11 16,11 L8,11 C7.44771525,11 7,11.4477153 7,12 C7,12.5522847 7.44771525,13 8,13 Z",width:24,height:24};var As=Object.freeze({__proto__:null,iconCheck:fs,iconCheckMedium:ms,iconChevronDown:gs,iconChevronRight:vs,iconCircle:bs,iconCircleArrowDown:ys,iconCircleArrowUp:xs,iconCircleThin:Cs,iconDesktop:{path:"M94.208 52.119l0-43.746q0-.69-.506-1.15t-1.196-.506l-84.088 0q-.69 0-1.196.506t-.506 1.15l0 43.746q0 .69.506 1.196t1.196.506l84.088 0q.69 0 1.196-.506t.506-1.196zm6.716-43.746l0 57.224q0 3.45-2.484 5.934t-5.934 2.484l-28.566 0q0 3.128 2.53 7.774.828 1.61.828 2.622t-1.012 2.07q-1.012 1.012-2.346.966l-26.91 0q-1.38 0-2.392-1.012t-1.012-2.024q0-1.058 1.656-4.14t1.748-6.256l-28.612 0q-3.45 0-5.934-2.484t-2.484-5.934l0-57.224q0-3.45 2.484-5.934t5.934-2.438l84.088 0q3.45 0 5.98 2.438 2.438 2.484 2.438 5.934z",width:100,height:86.648},iconDropdownArrow:{path:"M9 9.8c0 .5.7 1.7 1.5 2.8 1.5 1.9 1.5 1.9 3 0C15.7 9.7 15.4 9 12 9c-1.6 0-3 .4-3 .8z",width:24,height:24},iconExclamationSign:ws,iconGear:{path:"M1152 896q0-106-75-181t-181-75-181 75-75 181 75 181 181 75 181-75 75-181zm512-109v222q0 12-8 23t-20 13l-185 28q-19 54-39 91 35 50 107 138 10 12 10 25t-9 23q-27 37-99 108t-94 71q-12 0-26-9l-138-108q-44 23-91 38-16 136-29 186-7 28-36 28h-222q-14 0-24.5-8.5t-11.5-21.5l-28-184q-49-16-90-37l-141 107q-10 9-25 9-14 0-25-11-126-114-165-168-7-10-7-23 0-12 8-23 15-21 51-66.5t54-70.5q-27-50-41-99l-183-27q-13-2-21-12.5t-8-23.5v-222q0-12 8-23t19-13l186-28q14-46 39-92-40-57-107-138-10-12-10-24 0-10 9-23 26-36 98.5-107.5t94.5-71.5q13 0 26 10l138 107q44-23 91-38 16-136 29-186 7-28 36-28h222q14 0 24.5 8.5t11.5 21.5l28 184q49 16 90 37l142-107q9-9 24-9 13 0 25 10 129 119 165 170 7 8 7 22 0 12-8 23-15 21-51 66.5t-54 70.5q26 50 41 98l183 28q13 2 21 12.5t8 23.5z",width:1792,height:1792},iconMobilePhone:{path:"M36.04 89.557q0-2.584-1.836-4.42t-4.42-1.836-4.352 1.836q-1.836 1.836-1.836 4.42t1.836 4.352 4.42 1.836q2.652-.068 4.42-1.836t1.768-4.352zm16.184-12.444l0-54.74q0-1.088-.748-1.768t-1.768-.68l-39.78 0q-1.088 0-1.768.748t-.68 1.7l0 54.74q0 1.02.748 1.768t1.7.68l39.78 0q1.02-.068 1.768-.748t.748-1.7zm-14.892-65.892q0-1.224-1.292-1.292l-12.444 0q-1.224.068-1.224 1.292t1.224 1.224l12.444 0q1.292 0 1.292-1.224zm22.372-1.292l0 79.628q0 3.944-2.992 6.936t-7.004 2.992l-39.78 0q-4.012 0-7.004-2.924-2.924-2.924-2.924-7.004l0-79.628q0-4.012 2.924-6.936t7.004-2.992l39.78 0q4.012-.068 7.004 2.924t2.992 7.004z",width:60.013,height:100},iconOk:ks,iconPlus:Ss,iconRemove:Es,iconStar:_s,iconTryAgain:Ms,iconTablet:{path:"M45.322 90.706q0-1.86-1.302-3.224-1.364-1.364-3.224-1.364t-3.224 1.364-1.302 3.224q0 1.86 1.364 3.224 1.302 1.364 3.162 1.302 1.86.062 3.224-1.302t1.302-3.224zm27.218-11.346l0-68.014q0-.93-.682-1.612t-1.55-.682l-58.962 0q-.93 0-1.612.682t-.682 1.612l0 68.014q0 .93.682 1.612t1.612.62l58.962 0q.992-.062 1.612-.682t.62-1.55zm9.114-68.014l0 77.066q0 4.65-3.348 7.998t-7.998 3.348l-58.962 0q-4.65 0-7.998-3.348t-3.348-7.998l0-77.066q0-4.65 3.348-7.998t7.998-3.348l58.962 0q4.65 0 7.998 3.348t3.348 7.998z",width:81.852,height:100},iconTrash:Ts,iconUndo:Is,iconMinus:Ps});const Ns={constrain:function(){this.constrain()}};Ns.standard=[Ns.constrain];const Rs={draw:function(){this.draw()}};Rs.standard=[Rs.draw];const Fs={basic:function(e,t){const n=this.graphie;if(!this.state.visibleShape){const t=[this.pointSize()/n.scale[0],this.pointSize()/n.scale[1]],s={maxScale:Math.max(this.highlightStyle().scale,this.normalStyle().scale),padding:10,shadow:e.shadow};this.state.visibleShape=new In(n,this.coord(),t,s),this.state.visibleShape.attr(N.default.omit(this.normalStyle(),"scale")),this.state.visibleShape.toFront(),this.mouseTarget()&&this.mouseTarget().toFront()}e.normalStyle===t.normalStyle||N.default.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.moveTo(this.coord()),this.mouseTarget()&&this.mouseTarget().moveTo(this.coord())},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};Fs.standard=[Fs.basic,Fs.highlight];const Ds={basic:function(){this.state.visibleShape&&(this.state.visibleShape.remove(),this.state.visibleShape=null)}};Ds.standard=Ds.basic;const Os={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,d.point.roundTo(t,e))}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(s,o,i){const r=this.graphie;e=e||r.range,void 0===t&&(t=r.snap);let a=r.unscalePoint([n,r.ypixels-n]),l=r.unscalePoint([r.xpixels-n,n]);if(t&&(a=d.point.ceilTo(a,t),l=d.point.floorTo(l,t)),i&&i.onOutOfBounds)return(s[0]>l[0]||s[0]<a[0]||s[1]>l[1]||s[1]<a[1])&&(i.onSkipRemaining(),i.onOutOfBounds()),s;return[Math.max(a[0],Math.min(l[0],s[0])),Math.max(a[1],Math.min(l[1],s[1]))]}},standard:null};var Ls={add:Ns,modify:Rs,draw:Fs,remove:Ds,onMoveStart:{standard:null},constraints:Os,onMove:{standard:null},onMoveEnd:{standard:null},onClick:{standard:null}};const Bs=un.assert,zs=un.normalizeOptions,{processMath:qs}=yn,Hs=N.default.keys(Ls),Ws={coord:[0,0],pointSize:4,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,shadow:!1,tooltip:!1},Us={added:!1,hasMoved:!1,visibleShape:null,outOfBounds:!1,mouseTarget:null,touchOffset:null},Gs=[],Vs=function(e,t,n){N.default.extend(this,{graphie:e,movable:t,state:{id:N.default.uniqueId("movablePoint")}}),this.modify(N.default.extend({},Us,n))};function js(e){const t=N.default.zip(e,e.slice(1).concat(e.slice(0,1))),n=N.default.map(t,(function(e){const t=e[0],n=e[1];return(n[0]-t[0])*(n[1]+t[1])}));return s=n,N.default.reduce(s,(function(e,t){return e+t}),0)>0;var s}N.default.extend(Vs,Ls),un.createGettersFor(Vs,N.default.extend({},Ws,Us)),un.addMovableHelperMethodsTo(Vs),N.default.extend(Vs.prototype,{cloneState:function(){return N.default.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return N.default.extend({id:this.state.id},zs(Hs,_n.pluck(Ls,"standard")),Ws)},modify:function(e){this.update(N.default.extend(this._createDefaultState(),e))},_showTooltip:function(e){this._tooltip||(this._tooltip=document.createElement("div"),this._tooltip.className="tooltip-content",this.state.visibleShape.wrapper.className="tooltip",this.state.visibleShape.wrapper.appendChild(this._tooltip),Gs.push((()=>{this.state.added&&this._hideTooltip()}))),this._tooltip.firstChild&&this._tooltip.removeChild(this._tooltip.firstChild),this.state.visibleShape.wrapper.className="tooltip visible",this._tooltip.appendChild(document.createElement("span")),"string"==typeof e?qs(this._tooltip.firstChild,e,!1):"function"==typeof e?e(this._tooltip.firstChild):this._tooltip.firstChild.appendChild(e)},_hideTooltip:function(){this._tooltip&&(this.state.visibleShape.wrapper.className="tooltip")},update:function(e){const t=this,n=t.graphie,s=N.default.extend(t.state,zs(Hs,e));Bs(d.point.is(s.coord));const o=s.static?gn.DYNAMIC:gn.INTERACTIVE;if(s.normalStyle=N.default.extend({fill:o,stroke:o,scale:1},s.normalStyle),s.highlightStyle=N.default.extend({fill:gn.INTERACTING,stroke:gn.INTERACTING,scale:2},s.highlightStyle),!s.static&&!s.mouseTarget){const e=t.state.coord,o=n.unscaleVector(24),i={mouselayer:!0,padding:0,interactiveKindForTesting:"movable-point"};s.mouseTarget=new In(n,e,o,i),s.mouseTarget.attr({fill:"#000",opacity:0})}const i=()=>{this._showTooltip((e=>{O.render(A.createElement("span",{style:{fontSize:"2em"}},A.createElement(K,$({},Ts,{style:{position:"static",color:gn.INTERACTIVE,marginLeft:9,marginRight:9}}))),e)}))};let r=s.coord;t.movable.modify(N.default.extend({},s,{add:null,modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:e=>{if(s.hasMoved=!1,r=s.coord,null==s.touchOffset){const t=!("ontouchstart"in window);s.touchOffset=t?[0,0]:d.vector.subtract(r,e)}const n=s.visibleShape.wrapper;if(s.shadow){const e="none";n.style.webkitFilter=e,n.style.filter=e}if(s.showHairlines&&s.showHairlines(s.coord),Gs.forEach((e=>e())),s.tooltip&&(s.xOnlyTooltip?this._showTooltip("".concat(s.coord[0])):this._showTooltip("(".concat(s.coord[0],", ").concat(s.coord[1],")")),s.shadow)){const e=n.getElementsByClassName("tooltip-content")[0],t="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=t,e.style.filter=t}t._fireEvent(s.onMoveStart,r,r),t.draw()},onMove:(e,n)=>{const o=d.vector.add(e,s.touchOffset);t.moveTo(o),s.showHairlines&&(this.state.outOfBounds?s.hideHairlines():s.showHairlines(s.coord)),s.tooltip&&(this.state.outOfBounds||(s.xOnlyTooltip?this._showTooltip("".concat(s.coord[0])):this._showTooltip("(".concat(s.coord[0],", ").concat(s.coord[1],")")))),s.onRemove&&this.state.outOfBounds&&i()},onMoveEnd:()=>{t.isHovering()&&!s.hasMoved&&t._fireEvent(s.onClick,s.coord,r);const e=s.visibleShape.wrapper;if(s.shadow){const t="drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.5))";e.style.webkitFilter=t,e.style.filter=t}if(s.hideHairlines&&s.hideHairlines(),s.hasMoved)this._hideTooltip();else if(s.onRemove){i();const t=e.getElementsByClassName("tooltip-content")[0];t.style.webkitFilter="none",t.style.filter="none",this._tooltip.firstChild.addEventListener("touchstart",(e=>{e.stopPropagation()}),!0),this._tooltip.firstChild.addEventListener("touchend",(e=>{s.onRemove(),e.stopPropagation()}),!0)}else s.tooltip&&this._hideTooltip();s.outOfBounds&&s.onRemove(),t._fireEvent(s.onMoveEnd,s.coord,r),s.hasMoved=!1,s.touchOffset=null,t.draw()}})),s.added||(t.prevState={},t._fireEvent(s.add,t.cloneState(),t.prevState),s.added=!0,t.prevState=t.cloneState()),t._fireEvent(s.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){const e=this._applyConstraints(this.coord(),this.coord());return d.point.is(e)&&this.setCoord(e),!1!==e},setCoord:function(e){Bs(d.point.is(e,2)),this.state.coord=N.default.clone(e),this.draw()},setCoordConstrained:function(e){Bs(d.point.is(e,2));const t=this._applyConstraints(e,this.coord());!1!==t&&(this.state.coord=N.default.clone(t),this.draw())},moveTo:function(e){const t=this.state;this.state.outOfBounds=!1;const n=this._applyConstraints(e,t.coord,t.onRemove?{onOutOfBounds:()=>{this.state.outOfBounds=!0}}:{});if(!1!==n&&(d.point.is(n)&&(e=n),!d.point.equal(e,t.coord))){const n=t.coord;t.coord=e,t.hasMoved=!0,this._fireEvent(t.onMove,t.coord,n),this.draw()}},normalStyle:function(){return N.default.clone(this.state.normalStyle)},highlightStyle:function(){return N.default.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()},grab:function(e){this.state.touchOffset=[0,0],this.movable.grab(e),this.moveTo(e)}});const Ys={constrain:function(){this.constrain()},pointsToFront:function(e){N.default.invoke(e.points,"toFront")}};Ys.standard=[Ys.constrain,Ys.pointsToFront];const Xs={draw:function(){this.draw()}};Xs.standard=[Xs.draw];const $s={basic:function(e,t){const n=this.graphie,s=this.path(e);this.state.visibleShape||(this.state.visibleShape=n.raphael.path(s),this.state.visibleShape.attr(this.normalStyle())),e.normalStyle===t.normalStyle||N.default.isEqual(e.normalStyle,t.normalStyle)||this.state.visibleShape.attr(this.normalStyle()),this.state.visibleShape.attr({path:s}),this.mouseTarget()&&this.mouseTarget().attr({path:s})},labels:function(e,t){const n=this.graphie,s=this,o=N.default.invoke(e.points,"coord"),i=js(o),r=o.length;null!=s.state._labelCache&&N.default.invoke(s.state._labelCache,"remove"),s.state._labelCache=[],(e.angleLabels.length||e.showRightAngleMarkers.length)&&(null==s.state._labeledAngles&&(s.state._labeledAngles=N.default.times(Math.max(e.angleLabels.length,e.showRightAngleMarkers.length),(function(){return n.label([0,0],"","center",e.labelStyle)}))),N.default.each(s.state._labeledAngles,(function(t,a){s.state._labelCache.push(n.labelAngle({point1:o[(a-1+r)%r],vertex:o[a],point3:o[(a+1)%r],label:t,text:e.angleLabels[a],showRightAngleMarker:e.showRightAngleMarkers[a],numArcs:e.numArcs[a],clockwise:i,style:e.labelStyle}))}))),e.sideLabels.length&&(null==s.state._labeledSides&&(s.state._labeledSides=N.default.map(e.sideLabels,(function(t){return n.label([0,0],"","center",e.labelStyle)}))),N.default.each(s.state._labeledSides,(function(t,a){s.state._labelCache.push(n.labelSide({point1:o[a],point2:o[(a+1)%r],label:t,text:e.sideLabels[a],numArrows:e.numArrows[a],numTicks:e.numTicks[a],clockwise:i,style:e.labelStyle}))}))),e.vertexLabels.length&&(null==s.state._labeledVertices&&(s.state._labeledVertices=N.default.map(e.vertexLabels,(function(t){return n.label([0,0],"","center",e.labelStyle)}))),N.default.each(s.state._labeledVertices,(function(t,a){s.state._labelCache.push(n.labelVertex({point1:o[(a-1+r)%r],vertex:o[a],point3:o[(a+1)%r],label:t,text:e.vertexLabels[a],clockwise:i,style:e.labelStyle}))}))),s.state._labelCache=N.default.flatten(s.state._labelCache)},highlight:function(e,t){e.isHovering&&!t.isHovering?e.visibleShape.animate(this.highlightStyle(),50):!e.isHovering&&t.isHovering&&e.visibleShape.animate(this.normalStyle(),50)}};$s.standard=[$s.basic,$s.labels,$s.highlight];const Ks={basic:function(){this.state.visibleShape&&this.state.visibleShape.remove()},labels:function(){const e=[this.state._labeledSides,this.state._labeledVertices,this.state._labeledAngles,this.state._labelCache];N.default.each(e,(function(e){null!=e&&e.length&&N.default.invoke(e,"remove")}))}};Ks.standard=[Ks.basic,Ks.labels];const Zs={fixed:function(){return function(){return!1}},snap:function(e){return function(t){return null===e||(e=e||this.graphie.snap,d.point.roundTo(t,e))}},bound:function(e,t,n){return void 0===n&&(n=void 0===e?10:0),function(s,o){const i=this.graphie,r=d.vector.subtract(s,o);e=e||i.range,void 0===t&&(t=i.snap);let a=i.unscalePoint([n,i.ypixels-n]),l=i.unscalePoint([i.xpixels-n,n]);t&&(a=d.point.ceilTo(a,t),l=d.point.floorTo(l,t));const c=N.default.map(this.coords(),(function(e,t){const n=d.vector.subtract(l,e);return[d.vector.subtract(a,e),n]})),p=N.default.reduce(c,(function(e,t){const n=t[0],s=t[1];return[Math.max(n[0],Math.min(s[0],e[0])),Math.max(n[1],Math.min(s[1],e[1]))]}),r);return d.vector.add(o,p)}},standard:null},Js={updatePoints:function(e,t){const n=d.vector.subtract(e,t);N.default.each(this.state.points,(function(e){e.setCoord(d.vector.add(e.coord(),n))}))},standard:null};var Qs={add:Ys,modify:Xs,draw:$s,remove:Ks,onMoveStart:{standard:null},constraints:Zs,onMove:Js,onMoveEnd:{standard:null},onClick:{standard:null}};const eo=un.assert,to=un.normalizeOptions,no=N.default.keys(Qs),so={points:null,angleLabels:[],showRightAngleMarkers:[],sideLabels:[],vertexLabels:[],numArcs:[],numArrows:[],numTicks:[],closed:!0,static:!1,cursor:"move",normalStyle:null,highlightStyle:null,labelStyle:null},oo={added:!1,hasMoved:!1,visibleShape:null,mouseTarget:null},io=function(e,t,n){eo(null!=e),eo(null!=n),N.default.extend(this,{graphie:e,movable:t,state:{id:N.default.uniqueId("movablePolygon")}}),this.modify(N.default.extend({},oo,n))};N.default.extend(io,Qs),un.createGettersFor(io,N.default.extend({},so,oo)),un.addMovableHelperMethodsTo(io),N.default.extend(io.prototype,{cloneState:function(){return N.default.extend(this.movable.cloneState(),this.state)},_createDefaultState:function(){return N.default.extend({id:this.state.id},to(no,_n.pluck(Qs,"standard")),so)},modify:function(e){this.update(N.default.extend(this._createDefaultState(),e))},update:function(e){const t=this,n=t.graphie,s=N.default.extend(t.state,to(no,e)),o=s.static?gn.DYNAMIC:gn.INTERACTIVE;s.normalStyle=N.default.extend({},s.normalStyle,{"stroke-width":2,"fill-opacity":0,fill:o,stroke:o},e.normalStyle),s.highlightStyle=N.default.extend({},{stroke:gn.INTERACTING,"stroke-width":2,fill:gn.INTERACTING,"fill-opacity":.05},s.highlightStyle),s.labelStyle=N.default.extend({},{stroke:gn.DYNAMIC,"stroke-width":1,color:gn.DYNAMIC},s.labelStyle),s.static||s.mouseTarget||(s.mouseTarget=n.mouselayer.path(this.path()),s.mouseTarget.attr({fill:"#000",opacity:0,cursor:"move"})),t.movable.modify(N.default.extend({},s,{modify:null,draw:t.draw.bind(t),remove:null,onMoveStart:function(){t._initialRefCoord=t.coord(0),t._prevRefCoord=t._initialRefCoord,t._totalDelta=[0,0],t._fireEvent(t.state.onMoveStart,t.coord(0),t.coord(0))},onMove:function(e,n){const s=d.vector.subtract(e,n);t._totalDelta=d.vector.add(t._totalDelta,s);let o=d.vector.add(t._initialRefCoord,t._totalDelta);o=t._applyConstraints(o,t._prevRefCoord),!1!==o&&(t._fireEvent(t.state.onMove,o,t._prevRefCoord),t._prevRefCoord=o)},onMoveEnd:function(){t._fireEvent(t.state.onMoveEnd,t._prevRefCoord,t._initialRefCoord)}})),N.default.invoke(s.points,"listen","onMove",s.id,t.draw.bind(t)),s.added||(t.prevState={},t._fireEvent(s.add,t.cloneState(),t.prevState),s.added=!0,t.prevState=t.cloneState()),t._fireEvent(s.modify,t.cloneState(),t.prevState)},path:function(e){const t=this.graphie;e=e||this.state;let n=N.default.map(e.points,(function(e){return t.scalePoint(e.coord())}));return e.closed?n.push(!0):n=n.concat(N.default.clone(n).reverse()),wn.unscaledSvgPath(n)},coords:function(){return N.default.invoke(this.state.points,"coord")},point:function(e){return this.state.points[e]},coord:function(e){return this.point(e).coord()},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.points&&N.default.invoke(this.state.points,"unlisten","onMove",this.state.id),this.movable&&this.movable.remove(),this.state.mouseTarget=null},constrain:function(){if(null==this.points||0===this.points.length)return;const e=this.coord(0),t=this._applyConstraints(e,e);!1!==t&&this._fireEvent(this.state.onMove,t,e)},normalStyle:function(){return N.default.clone(this.state.normalStyle)},highlightStyle:function(){return N.default.clone(this.state.highlightStyle)},toBack:function(){this.movable.toBack(),this.state.visibleShape&&this.state.visibleShape.toBack()},toFront:function(){this.state.visibleShape&&this.state.visibleShape.toFront(),this.movable.toFront()},isHovering:function(){return this.movable.isHovering()},isDragging:function(){return this.movable.isDragging()},mouseTarget:function(){return this.movable.mouseTarget()}});const ro=un.normalizeOptions,ao=un.assert,lo=["add","modify","draw","remove","onMoveStart","onMove","onMoveEnd","onClick"],co={cursor:null},po={added:!1,isHovering:!1,isMouseOver:!1,isDragging:!1,mouseTarget:null},ho=function(e,t){N.default.extend(this,{graphie:e,state:{id:N.default.uniqueId("movable")}}),this.modify(N.default.extend({},po,t))};un.createGettersFor(ho,N.default.extend({},co,po)),un.addMovableHelperMethodsTo(ho),N.default.extend(ho.prototype,{cloneState:function(){return N.default.clone(this.state)},_createDefaultState:function(){return N.default.extend({id:this.state.id,add:[],modify:[],draw:[],remove:[],onMoveStart:[],onMove:[],onMoveEnd:[],onClick:[]},co)},modify:function(e){this.update(N.default.extend({},this._createDefaultState(),e))},grab:function(e){ao(d.point.is(e));const t=this,n=t.graphie,s=t.state;s.isHovering=!0,s.isDragging=!0,n.isDragging=!0;const o=e;let i=o;t._fireEvent(s.onMoveStart,o,o);const r=function(e){e.preventDefault();const o=n.getMouseCoord(e);t._fireEvent(s.onMove,o,i),t.draw(),i=o},a=function(e){L.default(document).unbind("vmousemove",r),L.default(document).unbind("vmouseup",a),s.isHovering&&t._fireEvent(s.onClick,i,o),s.isHovering=t.state.isMouseOver,s.isDragging=!1,n.isDragging=!1,t._fireEvent(s.onMoveEnd,i,o),t.draw()};L.default(document).bind("vmousemove",r),L.default(document).bind("vmouseup",a)},update:function(e){const t=this,n=t.graphie,s=t.cloneState(),o=N.default.extend(t.state,ro(lo,e));if(o.mouseTarget&&!s.mouseTarget){let e;e=o.mouseTarget.getMouseTarget?L.default(o.mouseTarget.getMouseTarget()):L.default(o.mouseTarget[0]);!("ontouchstart"in window)&&(e.on("vmouseover",(function(){o.isMouseOver=!0,n.isDragging||(o.isHovering=!0),t.state.added&&t.draw()})),e.on("vmouseout",(function(){o.isMouseOver=!1,o.isDragging||(o.isHovering=!1),t.state.added&&t.draw()}))),e[0].addEventListener("touchstart",(function(e){e.preventDefault()}),{passive:!1}),e.on("vmousedown",(function(e){if(0!==e.which&&1!==e.which)return;e.preventDefault();const s=n.getMouseCoord(e);t.grab(s)}))}if(o.mouseTarget&&void 0!==o.cursor){let e;e=o.mouseTarget.getMouseTarget?L.default(o.mouseTarget.getMouseTarget()):L.default(o.mouseTarget[0]),e.css("cursor",o.cursor||"")}o.added||(t._fireEvent(o.modify,t.cloneState(),{}),o.added=!0,t.prevState=t.cloneState()),t._fireEvent(o.modify,t.cloneState(),t.prevState)},remove:function(){this.state.added=!1,this._fireEvent(this.state.remove),this.state.mouseTarget&&(L.default(this.state.mouseTarget).off(),this.state.mouseTarget.remove(),this.state.mouseTarget=null)},toBack:function(){this.state.mouseTarget&&this.state.mouseTarget.toBack()},toFront:function(){this.state.mouseTarget&&this.state.mouseTarget.toFront()}});const uo={MovablePoint:Vs,addMovablePoint:function(e,t){const n=new ho(e,{});return new Vs(e,n,t)},MovableLine:us,addMovableLine:function(e,t){const n=new ho(e,{});return new us(e,n,t)},MovablePolygon:io,addMovablePolygon:function(e,t){const n=new ho(e,{});return new io(e,n,t)},addMaybeMobileMovablePoint:function(e,t){const n=e.props.apiOptions.isMobile,s=n?{stroke:"#ffffff","stroke-width":3,fill:gn.INTERACTIVE}:{stroke:gn.INTERACTIVE,fill:gn.INTERACTIVE},o=Object.assign(s,t.normalStyle),i=Object.assign(n?{...s,"stroke-width":0,scale:.75}:{},t.highlightStyle),r=Object.assign({normalStyle:o,highlightStyle:i,shadow:n,tooltip:n&&e.props.showTooltips,showHairlines:e.showHairlines,hideHairlines:e.hideHairlines},n?{pointSize:7}:{});return uo.addMovablePoint(e.graphie,Object.assign(t,r))}},fo=Zn.createClass({displayName:"MovablePoint",movableProps:["children"],_getProps:function(){if(this.props.isMobile){const e=this.props.isMobile,t=e?{stroke:"#ffffff","stroke-width":3,fill:gn.INTERACTIVE}:{stroke:gn.INTERACTIVE,fill:gn.INTERACTIVE},n=e?Object.assign(t,this.props.mobileStyleOverride||{}):Object.assign(t,this.props.normalStyle),s=e?{...t,"stroke-width":0,scale:.75}:this.props.highlightStyle,o=Object.assign({normalStyle:n,highlightStyle:s,shadow:e,tooltip:e&&this.props.showTooltips},e?{pointSize:7}:{});return Object.assign(this.props,o)}return this.props},add:function(e){this.point=uo.addMovablePoint(e,this._getProps())},modify:function(){this.point.modify(this._getProps())},remove:function(){this.point.remove()},toFront:function(){this.point.toFront()},grab:function(e){this.point.grab(e)}});N.default.extend(fo,uo.MovablePoint);const mo=Zn.createClass({displayName:"MovableLine",movableProps:["children"],add:function(e){const t=N.default.pluck(this.props.children,"point"),n=N.default.extend({},this.props,{points:t});this.line=uo.addMovableLine(e,n)},modify:function(){const e=N.default.pluck(this.props.children,"point"),t=N.default.extend({},this.props,{points:e});this.line.modify(t)},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}});N.default.extend(mo,uo.MovableLine);const go=Zn.createSimpleClass(((e,t)=>{let n=t.coord;t.unscaled&&(n=e.unscalePoint(n));let s=null;return le().JIPT.useJIPT?(s=e.label(n,t.text,t.direction,!1,t.style),le().graphieMovablesJiptLabels.addLabel(s,t.tex)):s=e.label(n,t.text,t.direction,t.tex,t.style),s})),vo=Zn.createClass({displayName:"Line",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.line=this.graphie.line(t.start,t.end,t.style)},modify:function(){const e=this.props,t=this.graphie.svgPath([e.start,e.end]);this.line.attr(N.default.extend({},e.style,{path:t}))},remove:function(){this.line.remove()},toFront:function(){this.line.toFront()}}),bo=Zn.createClass({displayName:"Parabola",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.parabola=this.graphie.parabola(t.a,t.b,t.c,t.style)},modify:function(){const e=this.props,t=this.graphie.svgParabolaPath(e.a,e.b,e.c);this.parabola.attr(N.default.extend({},e.style,{path:t}))},remove:function(){this.parabola.remove()},toFront:function(){this.parabola.toFront()}}),yo=Zn.createClass({displayName:"Sinusoid",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.sinusoid=this.graphie.sinusoid(t.a,t.b,t.c,t.d,t.style)},modify:function(){const e=this.props,t=this.graphie.svgSinusoidPath(e.a,e.b,e.c,e.d);this.sinusoid.attr(N.default.extend({},e.style,{path:t}))},remove:function(){this.sinusoid.remove()},toFront:function(){this.sinusoid.toFront()}}),xo=Zn.createSimpleClass(((e,t)=>e.plot(t.fn,t.range,t.style))),Co=Zn.createSimpleClass(((e,t)=>e.plotParametric(t.fn,t.range,t.style))),wo=Zn.createSimpleClass(((e,t)=>e.ellipse(t.coord,e.unscaleVector([4,4]),{fill:t.color||gn.BLACK,stroke:t.color||gn.BLACK}))),ko=Zn.createClass({displayName:"Path",movableProps:["children"],add:function(e){const t=this.props;this.graphie=e,this.path=this.graphie.path(t.coords,t.style)},modify:function(){const e=this.props,t=this.graphie.svgPath(e.coords);this.path.attr({path:t})},remove:function(){this.path.remove()},toFront:function(){this.path.toFront()}});var So={Arc:Zn.createSimpleClass(((e,t)=>{let n=t.center,s=t.radius;return t.unscaled&&(n=e.unscalePoint(n),s=e.unscaleVector(s)),e.arc(n,s,t.startAngle,t.endAngle,t.sector,t.style)})),Circle:Zn.createSimpleClass(((e,t)=>e.circle(t.center,t.radius,t.style))),Label:go,Line:vo,MovableLine:mo,MovablePoint:fo,Parabola:bo,Path:ko,Plot:xo,PlotParametric:Co,Point:wo,Sinusoid:yo,Rect:Zn.createSimpleClass(((e,t)=>e.rect(t.x,t.y,t.width,t.height,t.style)))};const Eo=Zn.GraphieMovable,_o=wn.createGraphie,{deepEq:Mo,nestedMap:To}=Be,{assert:Io}=un;class Po extends A.Component{constructor(){super(...arguments),X(this,"getGraphie",(()=>this._graphie)),X(this,"_range",(()=>N.default.map(this.props.range,(e=>e[0]>=e[1]?[-10,10]:e)))),X(this,"_box",(()=>N.default.map(this.props.box,(e=>e>0?e:340)))),X(this,"_scale",(()=>{const e=this._box(),t=this._range();return N.default.map(e,((e,n)=>e/(t[n][1]-t[n][0])))})),X(this,"_setupGraphie",(()=>{this._removeMovables();const e=D.default.findDOMNode(this.refs.graphieDiv);L.default(e).empty();const t=this._graphie=_o(e);t.init({range:this._range(),scale:this._scale(),isMobile:this.props.isMobile}),this.props.addMouseLayer&&t.addMouseLayer({onClick:this.props.onClick,onMouseDown:this.props.onMouseDown,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),t.snap=this.props.options.snapStep||[1,1],this.props.responsive&&(L.default(e).css({width:"100%",height:"100%"}),t.raphael.setSize("100%","100%")),this.props.setup(t,N.default.extend({range:this._range(),scale:this._scale()},this.props.options))})),X(this,"_removeMovables",(()=>{N.default.invoke(this._movables,"remove"),this._movables={}})),X(this,"_renderMovables",((e,t)=>{const n=t.graphie,s=t.oldMovables,o=t.newMovables,i=e=>{N.default.each(e.movableProps,(n=>{e.props[n]=this._renderMovables(e.props[n],t)}))};let r=!1;return To(e,(e=>{if(!e)return t.nextKey++,e;const a=new e.type(e.props);Io(a instanceof Eo,"All children of a Graphie component must be Graphie movables");const l=e.key,c=null==l?"_no_id_"+t.nextKey:l;t.nextKey++;const p=e.ref;i(a);const d=s[c];if(d)if(a.constructor===d.constructor){d.props=a.props;"reordered"===d.modify(n)&&(r=!0),o[c]=d}else null==l&&de.error("Replacing a <Graphie> child with a child of a different type. Please add keys to your <Graphie> children",pe.Internal),d.remove(),a.add(n),r=!0,o[c]=a;else a.add(n),r=!0,o[c]=a;return r&&o[c].toFront(),p&&(this.movables[p]=o[c]),o[c]}))})),X(this,"_updateMovables",(()=>{const e=this._graphie,t=this._movables,n={};this._movables=n,this.movables={},this._renderMovables(this.props.children,{nextKey:1,graphie:e,oldMovables:t,newMovables:n}),N.default.each(t,((e,t)=>{n[t]||e.remove()}))}))}componentDidMount(){this._setupGraphie(),this._updateMovables()}shouldComponentUpdate(e){return!N.default.isEqual(this.props,e)}componentDidUpdate(e){this.props.setup!==e.setup&&de.error("<Graphie> was given a new setup function. This is a bad idea; please refactor your code to give the same setup function reference to <Graphie> on every render.",pe.Internal),Mo(this.props.options,e.options)&&Mo(this.props.box,e.box)&&Mo(this.props.range,e.range)||this._setupGraphie(),this._updateMovables()}render(){return A.createElement("div",{className:"graphie-container"},A.createElement("div",{className:"graphie",ref:"graphieDiv"}))}}X(Po,"propTypes",{addMouseLayer:R.default.bool,box:R.default.arrayOf(R.default.number).isRequired,children:R.default.node,isMobile:R.default.bool,onClick:R.default.func,onMouseDown:R.default.func,onMouseMove:R.default.func,onMouseUp:R.default.func,options:R.default.shape({snapStep:R.default.arrayOf(R.default.number)}),range:R.default.arrayOf(R.default.arrayOf(R.default.number)),responsive:R.default.bool,setDrawingAreaAvailable:R.default.func,setup:R.default.func.isRequired}),X(Po,"defaultProps",{range:[[-10,10],[-10,10]],options:{},responsive:!1,addMouseLayer:!0}),N.default.extend(Po,Zn),N.default.extend(Po,So);const Ao="pending",No="loading",Ro="loaded",Fo="failed";class Do extends A.Component{constructor(e){super(e),X(this,"img",void 0),X(this,"createLoader",(()=>{this.destroyLoader(),this.img=new Image,this.img.onload=this.handleLoad,this.img.onerror=this.handleError,this.img.src=this.props.src})),X(this,"destroyLoader",(()=>{this.img&&(this.img.onload=null,this.img.onerror=null,this.img=null)})),X(this,"handleLoad",(e=>{this.destroyLoader(),this.setState({status:Ro}),this.props.onLoad&&this.props.onLoad(e)})),X(this,"handleError",(e=>{this.destroyLoader(),this.setState({status:Fo}),this.props.onError&&this.props.onError(e)})),X(this,"renderImg",(()=>{const{src:e,imgProps:t}=this.props;let n=null,s=null;null!=t.onClick&&(n=e=>{13!==e.keyCode&&32!==e.keyCode||t.onClick&&t.onClick(e)},s=e=>{32===e.keyCode&&e.preventDefault()});const o=le().staticUrl;return A.createElement("img",$({src:o(e),onKeyUp:n,onKeyDown:s},t))})),this.state={status:e.src?No:Ao}}componentDidMount(){this.state.status===No&&this.createLoader()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({status:e.src?No:Ao})}componentDidUpdate(e,t){this.state.status!==No||this.img||this.createLoader(),t.status!==this.state.status&&this.props.onUpdate(this.state.status)}componentWillUnmount(){this.destroyLoader()}render(){switch(this.state.status){case Ro:return this.renderImg();case Fo:if(this.props.children)return this.props.children;break;default:if(this.props.preloader)return this.props.preloader()}return null}}const Oo={},Lo=/^file\+graphie\:/,Bo=/\/([^/]+)$/;function zo(e){return/\.(jpg|jpeg)$/i.test(e)}function qo(){const{JIPT:e,kaLocale:t}=le();return e.useJIPT?"en-pt":t}function Ho(){return"en"!==qo()}const Wo=/\/(?=[^/]+$)/;function Uo(e){return A.createElement("span",{style:{background:"url(/images/spinner.gif) no-repeat",backgroundPosition:"center",width:"100%",height:"100%",position:"absolute",minWidth:"20px"}})}class Go extends A.Component{constructor(e){super(e),X(this,"_isMounted",void 0),X(this,"onDataLoaded",((e,t)=>{if(this._isMounted&&e.labels&&e.range){const n=e.labels.reduce(((e,t)=>({...e,[t.content]:!1})),{});this.setState({dataLoaded:!0,labelDataIsLocalized:t,labelsRendered:n,labels:e.labels,range:e.range})}})),X(this,"onImageLoad",(()=>{this.sizeProvided()?this.setState({imageLoaded:!0}):Be.getImageSize(this.props.src,((e,t)=>{this._isMounted&&this.setState({imageLoaded:!0,imageDimensions:[e,t]})}))})),X(this,"setupGraphie",((e,t)=>{N.default.map(t.labels,(t=>{const{JIPT:n}=le();if(n.useJIPT&&this.state.labelDataIsLocalized){const n=e.label(t.coordinates,t.content,t.alignment,!1);le().svgImageJiptLabels.addLabel(n,t.typesetAsMath)}else if(t.coordinates){const n=e.label(t.coordinates,t.content,t.alignment,t.typesetAsMath,{"font-size":100*this.props.scale+"%"}),s=n[0].style;let o=this._tryGetPixels(s.top),i=this._tryGetPixels(s.left);if(null===o||null===i){const e=n.position();o=e.top,i=e.left}const r=(this.props.height||0)*this.props.scale,a=(this.props.width||0)*this.props.scale;n.css({top:o/r*100+"%",left:i/a*100+"%"}),N.default.each(t.style,((e,t)=>{n.css(t,e)}))}this.setState({labelsRendered:{...this.state.labelsRendered,[t.content]:!0}})}))})),X(this,"_handleZoomClick",(e=>{(L.default(e.target).width()<this.props.width||this.props.zoomToFullSizeOnMobile)&&an.handleZoomClick(e,this.props.zoomToFullSizeOnMobile),this.props.trackInteraction&&this.props.trackInteraction()})),X(this,"handleUpdate",(e=>{this.props.onUpdate(),Be.isLabeledSVG(this.props.src)||"loaded"!==e||this.setState({imageLoaded:!0})})),e.setAssetStatus(e.src,!1),this._isMounted=!1,this.state={imageLoaded:!1,imageDimensions:null,dataLoaded:!1,labelDataIsLocalized:!1,labels:[],labelsRendered:{},range:[[0,0],[0,0]]}}componentDidMount(){this._isMounted=!0,Be.isLabeledSVG(this.props.src)&&this.loadResources()}UNSAFE_componentWillReceiveProps(e){this.props.src!==e.src&&this.setState({imageLoaded:!1,dataLoaded:!1})}shouldComponentUpdate(e,t){if(!N.default.isEqual(this.props,e))return!0;return this.isLoadedInState(this.state)!==this.isLoadedInState(t)}componentDidUpdate(e,t){const n=this.isLoadedInState(t),s=this.isLoadedInState(this.state);Be.isLabeledSVG(this.props.src)&&!s&&this.loadResources(),!n&&s&&this.props.setAssetStatus(this.props.src,!0)}componentWillUnmount(){this._isMounted=!1}isLoadedInState(e){return Be.isLabeledSVG(this.props.src)?e.imageLoaded&&e.dataLoaded:e.imageLoaded}loadResources(){const e=function(e){const t=e.match(Bo);if(null==t)throw new he("not a valid URL",pe.InvalidInput);return t&&t[1]}(this.props.src);if(Oo[e])if(Oo[e].loaded){const{data:t,localized:n}=Oo[e];this.onDataLoaded(t,n)}else Oo[e].dataCallbacks.push(this.onDataLoaded);else{const t={loaded:!1,dataCallbacks:[this.onDataLoaded],data:null,localized:Ho()};Oo[e]=t;const n=(n,s)=>{!function(e,t){t={callbackName:"callback",success:L.default.noop,error:L.default.noop,...t};const n=document.createElement("script");function s(){document.head&&document.head.removeChild(n),delete window[t.callbackName]}n.setAttribute("async",""),n.setAttribute("src",e),window[t.callbackName]=function(){s(),t.success.apply(null,arguments)},n.addEventListener("error",(function(){s(),t.error.apply(null,arguments)})),document.head&&document.head.appendChild(n)}(n,{callbackName:"svgData"+e,success:e=>{t.data=e,t.loaded=!0,N.default.each(t.dataCallbacks,(e=>{e(t.data,t.localized)}))},error:s})};Ho()?n(function(e){if(Lo.test(e))return Be.getDataUrl(e);const[t,n]=Be.getBaseUrl(e).split(Wo);return"".concat(t,"/").concat(qo(),"/").concat(n,"-data.json")}(this.props.src),((e,s,o)=>{t.localized=!1,n(Be.getDataUrl(this.props.src),((e,t,n)=>{de.error("Data load failed for svg-image",pe.Service,{cause:n,loggedMetadata:{dataUrl:Be.getDataUrl(this.props.src),status:t}})}))})):n(Be.getDataUrl(this.props.src),((e,t,n)=>{de.error("Data load failed for svg-image",pe.Service,{cause:n,loggedMetadata:{dataUrl:Be.getDataUrl(this.props.src),status:t}})}))}}sizeProvided(){return null!=this.props.width&&null!=this.props.height}_tryGetPixels(e){return(e=e||"").endsWith("px")&&parseFloat(e)||null}render(){const e=this.props.src,t={alt:this.props.alt,title:this.props.title,tabIndex:"0"};this.props.alt&&this.props.overrideAriaHidden&&(t["aria-hidden"]=!0);const n=this.props.width&&this.props.width*this.props.scale,s=this.props.height&&this.props.height*this.props.scale,o={width:n,height:s},i=this.props.responsive&&!(!n||!s);let r;this.props.extraGraphie&&this.props.extraGraphie.labels.length&&(r=A.createElement(Po,{box:this.props.extraGraphie.box,range:this.props.extraGraphie.range,options:{labels:this.props.extraGraphie.labels},responsive:!0,addMouseLayer:!1,setup:this.setupGraphie}));const a=void 0===this.props.preloader?Uo:this.props.preloader,l=a?()=>a(o):null;if(!Be.isLabeledSVG(e)){if(i){const o=P.default({zoomable:(n||0)>700,"svg-image":!0});return t.onClick=this._handleZoomClick,A.createElement(ln,{className:o,width:n,height:s,constrainHeight:this.props.constrainHeight,allowFullBleed:this.props.allowFullBleed&&zo(e)},A.createElement(Do,{src:e,imgProps:t,preloader:l,onUpdate:this.handleUpdate}),r)}return t.style=o,A.createElement(Do,{src:e,preloader:l,imgProps:t,onUpdate:this.handleUpdate})}const c=Be.getSvgUrl(e);let p;if(this.isLoadedInState(this.state)){let e;if(this.sizeProvided())e=[n,s];else{if(!this.state.imageDimensions)throw new he("svg-image has no dimensions",pe.InvalidInput,{metadata:{src:this.props.src}});e=[this.state.imageDimensions[0]*this.props.scale,this.state.imageDimensions[1]*this.props.scale]}const t=[40*this.props.scale,40*this.props.scale];p=A.createElement(Po,{ref:"graphie",box:e,scale:t,range:this.state.range,options:N.default.pick(this.state,"labels"),responsive:i,addMouseLayer:!1,setup:this.setupGraphie})}return i?A.createElement(ln,{className:"svg-image",width:n,height:s,constrainHeight:this.props.constrainHeight},A.createElement(Do,{src:c,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:l,imgProps:t}),p,r):(t.style=o,A.createElement("div",{className:"unresponsive-svg-image",style:o},A.createElement(Do,{src:c,onLoad:this.onImageLoad,onUpdate:this.handleUpdate,preloader:l,imgProps:t}),p))}}X(Go,"defaultProps",{constrainHeight:!1,onUpdate:()=>{},responsive:!0,src:"",scale:1,zoomToFullSizeOnMobile:!1,setAssetStatus:(e,t)=>{}});class Vo extends A.Component{constructor(e){super(e),X(this,"_hasRendered",void 0),X(this,"handleRender",(()=>{this.props.onRender(),this.setState({rendered:!0}),this.props.onRender(),this._hasRendered||(this._hasRendered=!0,this.props.setAssetStatus(this.props.children,!0))})),this.props.setAssetStatus(this.props.children,!1),this.state={rendered:!1},this._hasRendered=!1}render(){const{TeX:e}=le();return A.createElement(e,{onRender:this.handleRender},this.props.children)}}X(Vo,"defaultProps",{onRender:()=>{},setAssetStatus:(e,t)=>{}});class jo extends A.Component{constructor(){super(...arguments),X(this,"_isMounted",void 0),X(this,"_observer",void 0),X(this,"_measuringInitialized",void 0),X(this,"_originalWidth",void 0),X(this,"_node",void 0),X(this,"state",{visible:!1,marginBottomPx:0,zoomed:!0}),X(this,"reset",(()=>{this._isMounted&&this.state.visible&&(this._originalWidth=null,this.setState({visible:!1,compactHeight:null,expandedHeight:null,zoomed:!0},(()=>{this.measureAndScaleChildToFit(!1)})))})),X(this,"stopPropagationIfZoomed",(e=>{this.state.zoomed||e.stopPropagation()})),X(this,"handleClickIfZoomed",(e=>{this.state.zoomed||(e.stopPropagation(),this.handleClick())})),X(this,"handleClick",(()=>{this.setState({zoomed:!this.state.zoomed})}))}componentDidMount(){this._isMounted=!0,this.maybeInitializeMeasuring()}componentDidUpdate(){this.maybeInitializeMeasuring()}componentWillUnmount(){window.removeEventListener("resize",this.reset),this._observer&&this._observer.disconnect(),this._isMounted=!1}maybeInitializeMeasuring(){const e=this.props.readyToMeasure&&!this._measuringInitialized;this._isMounted&&e&&(this._measuringInitialized=!0,this._node=D.default.findDOMNode(this),setTimeout((()=>this.measureAndScaleChildToFit(!1)),0),window.MutationObserver&&(this._observer=new MutationObserver((e=>{if(this._isMounted)for(const t of e)if(t.target!==this._node){this.measureAndScaleChildToFit(this.state.zoomed);break}})),this._observer.observe(this._node,{childList:!0,subtree:!0,attributes:!0})),window.addEventListener("resize",this.reset))}measureAndScaleChildToFit(e){if(!this._isMounted)return;const t={width:this._node.offsetWidth,height:this._node.offsetHeight},n=this.props.computeChildBounds(this._node,t),s=n.width+1,o=n.height+1;if(s>t.width){const n=t.width/s;this.setState({scale:n,zoomed:e,compactHeight:Math.ceil(n*o),expandedHeight:o}),setTimeout((()=>{this._isMounted&&this.setState({visible:!0})}))}else this.setState({visible:!0})}render(){const{visible:e,scale:t,compactHeight:n,expandedHeight:s,zoomed:o}=this.state,{animateHeight:i}=this.props,r=i?"opacity transform height":"opacity transform",a=e?{transitionProperty:r,WebkitTransitionProperty:r,msTransitionProperty:r,transitionDuration:"0.3s",WebkitTransitionDuration:"0.3s",msTransitionDuration:"0.3s",transitionTimingFunction:"ease-out",WebkitTransitionTimingfunction:"ease-out",msTransitionTmingFunction:"ease-out"}:{},l=e?"":" translate(0, 8px)",c=(null!=t?t:1).toString(),p=o?"scale(1, 1) ".concat(l):"scale(".concat(c,", ").concat(c,") ").concat(l),d={display:"block",width:"100%",height:o?s:n,transform:p,WebkitTransform:p,msTransform:p,transformOrigin:"0 0",WebkitTransformOrigin:"0 0",msTransformOrigin:"0 0",opacity:e?1:0,WebkitTapHighlightColor:"transparent",...a};return A.createElement("span",{onClick:this.handleClick,onClickCapture:this.handleClickIfZoomed,onTouchCancelCapture:this.stopPropagationIfZoomed,onTouchEndCapture:this.stopPropagationIfZoomed,onTouchStartCapture:this.stopPropagationIfZoomed,style:d},this.props.children)}}X(jo,"defaultProps",{animateHeight:!1,readyToMeasure:!0,computeChildBounds:e=>{const t=e.firstElementChild;return{width:t.offsetWidth,height:t.offsetHeight}}});const Yo=(e,t)=>{const n=e.querySelector(".katex-html")||e.querySelector(".MathJax"),s={width:n.offsetWidth,height:n.offsetHeight};return{width:Math.max(t.width,s.width),height:Math.max(t.height,s.height)}};class Xo extends A.Component{constructor(){super(),X(this,"handleRender",(()=>{this.setState({isRendered:!0})})),this.state={isRendered:!1}}render(){return A.createElement(jo,{readyToMeasure:this.state.isRendered,computeChildBounds:Yo},A.createElement(nn.Consumer,null,(e=>{let{setAssetStatus:t}=e;return A.createElement(Vo,{onRender:this.handleRender,setAssetStatus:t},this.props.children)})))}}class $o extends A.Component{constructor(e){super(e),this.state={error:""}}componentDidCatch(e,t){this.setState({error:e.toString()}),de.error("Perseus error boundary caught error",pe.Internal,{cause:e,loggedMetadata:{info:t.toString()}})}render(){return this.state.error?A.createElement("svg",{height:"16",width:"16",viewBox:"0 0 16 16"},A.createElement("path",{d:"m8 16c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm0-3c0.55 0 1-0.45 1-1s-0.45-1-1-1-1 0.45-1 1 0.45 1 1 1zm0-9c-0.55 0-1 0.45-1 1v4c0 0.55.45 1 1 1s1-0.45 1-1v-4c0-0.55-0.45-1-1-1z",fill:"#d92916",fillRule:"evenodd"})):this.props.children}}function Ko(){}class Zo{constructor(e,t,n,s){X(this,"_tracked",void 0),X(this,"setting",void 0),X(this,"track",void 0),X(this,"trackApi",void 0),X(this,"widgetID",void 0),X(this,"widgetType",void 0),X(this,"_track",(e=>{this._tracked&&!this.setting||(this._tracked=!0,this.trackApi({type:this.widgetType,id:this.widgetID,...e}))})),e?(this._tracked=!1,this.trackApi=e,this.widgetType=t,this.widgetID=n,this.setting=s,this.track=this._track):this.track=Ko}}const Jo={fence:{match:F.default.defaultRules.fence.match,order:1,parse:(e,t,n)=>e[3]},paragraph:{match:F.default.defaultRules.paragraph.match,order:2,parse:(e,t,n)=>e[1]}},Qo=F.default.parserFor(Jo);var ei={parseToArray:e=>{const t=e.replace(/^\n\s*\n/,"")+"\n\n";return Qo(t,{inline:!1})},joinFromArray:e=>e.join("\n\n")};class ti{constructor(){X(this,"previousContent",null),X(this,"runLinter",i.debounce(((e,t)=>{"undefined"!=typeof KA&&e!==this.previousContent&&(this.previousContent=e,""!==e?fetch("/api/internal/translations/lint_poentry?preview=1&lang=en",{headers:{"Content-Type":"application/json"},body:JSON.stringify({msgid:e,msgstr:e,format:"perseus_text",filename:""}),method:"POST"}).then((e=>e.status>=400?{status:"error",message:"Could not run i18n linter."}:e.json()),(e=>({status:"error",message:"Could not run i18n linter."}))).then((e=>{"error"===e.status?t(["Some part of this text makes it untranslatable. The specific message from the i18n linter was: "+e.message.replace(/\n/g," ")]):t([])})):t([]))}),1e3))}applyLintErrors(e,t){if(t.length){const n=t.join("\n\n");e.unshift({content:{type:"text",content:""},insideTable:!1,message:n,ruleName:"legacy-error",severity:lt.Severity.ERROR,type:"lint"})}}}class ni extends A.Component{render(){const e=this.props.className?"paragraph "+this.props.className:"paragraph";return A.createElement("div",{className:e,"data-perseus-component-index":this.props.translationIndex,"data-perseus-paragraph-index":this.props.paragraphIndex},this.props.children)}}var si=e=>e.replace(/\{align[*]?\}/g,"{aligned}").replace(/[\u00a0]/g," ");const{interactiveSizes:oi}=se,ri={SMALL:"small",MEDIUM:"medium",LARGE:"large",XLARGE:"xlarge"},ai=e=>e?e<=512?ri.SMALL:e<=688?ri.MEDIUM:ri.LARGE:ri.MEDIUM,li=e=>e===ri.SMALL?[oi.defaultBoxSizeSmall,oi.defaultBoxSizeSmall]:[oi.defaultBoxSize,oi.defaultBoxSize];var ci=Object.freeze({__proto__:null,containerSizeClass:ri,getClassFromWidth:ai,getInteractiveBoxFromSizeClass:li});const pi=["default"],di={},hi={},ui=(e,t)=>{di[e]=t},fi=e=>{e.forEach((e=>{ui(e.name,e)})),Ei()},mi=e=>N.default.has(di,e)?di[e].getWidget?di[e].getWidget():di[e].widget:null,gi=e=>di[e]?di[e].version||{major:0,minor:0}:null,vi=()=>{const e={};return N.default.each(N.default.keys(di),(function(t){e[t]=gi(t)})),e},bi=e=>{const t=di[e.type].accessible;return"function"==typeof t?t(e.options):!!t},yi=e=>{const t=e.type;if(!N.default.isString(t))throw new he("widget type must be a string, but was: "+t,pe.Internal);const n=di[t];if(null==n)return e;const s=e.version||{major:0,minor:0},o=n.version||{major:0,minor:0};if(s.major>o.major||s.major===o.major&&s.minor>o.minor)return e;let i=N.default.clone(e.options)||{};const r=n.propUpgrades||{};if(0!==N.default.keys(i).length)for(let e=s.major+1;e<=o.major;e++)r[String(e)]?i=r[String(e)](i):de.error("No upgrade found for widget. Cannot render.",pe.Internal,{loggedMetadata:{type:t,fromMajorVersion:e-1,toMajorVersion:e}});i={...t in hi?hi[t].defaultProps:{},...i};let a=e.alignment;null!=a&&"default"!==a||(a=wi(t)[0]);let l=e.static;return null==l&&(l=false),N.default.extend({},e,{version:o,graded:null==e.graded||e.graded,alignment:a,static:l,options:i})},xi=(e,t)=>{const n=e.type,s=di[n];if(null==s)return e.options;let o;return o=e.static?_i(n)||N.default.identity:s.transform||N.default.identity,o(e.options,t)},Ci=(e,t)=>{if(!t)throw new he("traverseRenderer must be provided, but was not",pe.Internal);if(!e||!e.type||!di[e.type])return e;const n=di[e.type],s=e.options;if(n.traverseChildWidgets&&s){const o=n.traverseChildWidgets(s,t);return N.default.extend({},e,{options:o})}return e},wi=e=>{const t=di[e];return t&&t.supportedAlignments||pi},ki=e=>{const t=di[e];let n;return t?(n=t.getDefaultAlignment?t.getDefaultAlignment():t.defaultAlignment,n||"block"):"block"},Si=["block","inline-block","inline","float-left","float-right","full-width"],Ei=()=>{N.default.each(di,(function(e){if(e.defaultAlignment&&!N.default.contains(Si,e.defaultAlignment))throw new he("Widget '"+e.displayName+"' has an invalid defaultAlignment value: "+e.defaultAlignment,pe.InvalidInput);if(e.supportedAlignments){const t=N.default.difference(e.supportedAlignments,Si);if(t.length)throw new he("Widget '"+e.displayName+"' has an invalid value for supportedAlignments: "+t.join(" "),pe.InvalidInput)}}))},_i=e=>{const t=di[e];return t&&t.staticTransform},Mi=e=>{const t=di[e];return t&&t.tracking||""},Ti=e=>{const t=di[e];return t&&t.isLintable||false};var Ii=Object.freeze({__proto__:null,registerWidget:ui,registerWidgets:fi,registerEditors:e=>{e.forEach((e=>{if(!e.widgetName)throw new he("Editor ".concat(e.displayName," doesn't have a widgetName property"),pe.Internal);hi[e.widgetName]=e}))},getWidget:mi,getEditor:e=>N.default.has(hi,e)?hi[e]:null,getTransform:e=>N.default.has(di,e)?di[e].transform||N.default.identity:null,getVersion:gi,getVersionVector:vi,getPublicWidgets:()=>N.default.pick(di,N.default.reject(N.default.keys(di),(function(e){return di[e].hidden}))),isAccessible:bi,getAllWidgetTypes:()=>N.default.keys(di),upgradeWidgetInfoToLatestVersion:yi,getRendererPropsForWidgetInfo:xi,traverseChildWidgets:Ci,getSupportedAlignments:wi,getDefaultAlignment:ki,validateAlignments:Ei,supportsStaticMode:e=>{const t=di[e];return t&&null!=t.staticTransform},getStaticTransform:_i,getTracking:Mi,isLintable:Ti});class Pi extends A.Component{constructor(){super(...arguments),X(this,"state",{sizeClass:ri.MEDIUM,widgetProps:this.props.initialProps}),X(this,"getWidget",(()=>this.refs.widget)),X(this,"replaceWidgetProps",(e=>{this.setState({widgetProps:e})}))}componentDidMount(){if(this.state.widgetProps.apiOptions.isMobile){const e=D.default.findDOMNode(this).offsetWidth;this.setState({sizeClass:ai(e)})}}render(){let e=P.default({"perseus-widget-container":!0,"widget-highlight":this.props.shouldHighlight,"widget-nohighlight":!this.props.shouldHighlight});const t=this.props.type,n=mi(t);if(null==n)return console.warn("Widget type '".concat(t,"' not found!")),A.createElement("div",{className:e});let s=this.state.widgetProps.alignment;"default"===s&&(s=ki(t)),e+=" widget-"+s;const o=this.state.widgetProps.apiOptions,i=this.state.widgetProps.static||o.readOnly,r={width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:3},a=Ti(t)?this.props.linterContext:{...this.props.linterContext,highlightLint:!1};return A.createElement("div",{className:e,style:i?{position:"relative",overflow:"visible"}:{}},A.createElement(n,$({},this.state.widgetProps,{linterContext:a,containerSizeClass:this.state.sizeClass,ref:"widget"})),i&&A.createElement("div",{style:r}))}UNSAFE_componentWillReceiveProps(e){if(this.props.type!==e.type)throw new Error("WidgetContainer can't change widget type; set a different key instead to recreate the container.")}shouldComponentUpdate(e,t){return this.props.shouldHighlight!==e.shouldHighlight||this.props.type!==e.type||this.state.widgetProps!==t.widgetProps||this.state.sizeClass!==t.sizeClass}}X(Pi,"defaultProps",{linterContext:Yt});const{mapObject:Ai,mapObjectFromArray:Ni}=_n,Ri=/\S/,Fi=/(web\+graphie|https):\/\/[^\s]*/,Di=()=>{},Oi=["content","problemNum","widgets"];class Li extends A.Component{constructor(e,t){var n;super(e,t),n=this,X(this,"_currentFocus",void 0),X(this,"_foundTextNodes",void 0),X(this,"_interactionTrackers",void 0),X(this,"_isMounted",void 0),X(this,"_isTwoColumn",void 0),X(this,"_notGorgon",void 0),X(this,"lastRenderedMarkdown",void 0),X(this,"reuseMarkdown",void 0),X(this,"translationIndex",void 0),X(this,"widgetIds",void 0),X(this,"getApiOptions",(()=>({...Qt.defaults,...this.props.apiOptions}))),X(this,"_getInitialWidgetState",(e=>{const t=this._getAllWidgetsInfo(e);return{widgetInfo:t,widgetProps:this._getAllWidgetsStartProps(t,e)}})),X(this,"_getAllWidgetsInfo",(e=>Ai(e.widgets,((e,t)=>{if(!e.type||!e.alignment){const n={};e.type||(n.type=t.split(" ")[0]),e.alignment||(n.alignment="default"),e=N.default.extend({},e,n)}return yi(e)})))),X(this,"_getAllWidgetsStartProps",((e,t)=>Ai(e,(e=>xi(e,t.problemNum))))),X(this,"_getDefaultWidgetInfo",(e=>{const t=Be.rTypeFromWidgetId.exec(e);return null==t?{}:{type:t[1],graded:!0,options:{}}})),X(this,"_getWidgetInfo",(e=>this.state.widgetInfo[e]||this._getDefaultWidgetInfo(e))),X(this,"renderWidget",((e,t,n)=>{const s=this.state.widgetInfo[t];if(s&&"full-width"===s.alignment&&(n.foundFullWidth=!0),s){const n=s&&s.type||e,o=N.default.contains(this.props.highlightedWidgets,t);return A.createElement($o,{key:"container:"+t},A.createElement(Pi,{ref:"container:"+t,type:n,initialProps:this.getWidgetProps(t),shouldHighlight:o,linterContext:Vt.pushContextStack(this.props.linterContext,"widget")}))}return null})),X(this,"getWidgetProps",(e=>{const t=this.getApiOptions(),s=this.state.widgetProps[e]||{};let o=null;const i=this.state.widgetInfo[e];this.props.reviewMode&&i&&(o=i.options),this._interactionTrackers||(this._interactionTrackers={});let r=this._interactionTrackers[e];return r||(r=this._interactionTrackers[e]=new Zo(t.trackInteraction,i&&i.type,e,Mi(i&&i.type))),{...s,ref:e,widgetId:e,alignment:i&&i.alignment,static:i&&i.static&&!this.props.problemNum,problemNum:this.props.problemNum,apiOptions:this.getApiOptions(),keypadElement:this.props.keypadElement,questionCompleted:this.props.questionCompleted,onFocus:N.default.partial(this._onWidgetFocus,e),onBlur:N.default.partial(this._onWidgetBlur,e),findWidgets:this.findWidgets,reviewModeRubric:o,onChange:function(t,s){let o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];n._setWidgetProps(e,t,s,o)},trackInteraction:r.track,isLastUsedWidget:e===this.state.lastUsedWidgetId}})),X(this,"getSerializedState",(e=>Ai(e||this.state.widgetProps,((e,t)=>{const n=this.getWidgetInstance(t);return n&&n.getSerializedState?n.getSerializedState():e})))),X(this,"restoreSerializedState",((e,t)=>{const n=N.default.keys(e),s=N.default.keys(this.state.widgetProps);if(n.length!==s.length||N.default.intersection(n,s).length!==n.length)return void de.error("Refusing to restore bad serialized state:",pe.Internal,{loggedMetadata:{serializedState:JSON.stringify(e),currentProps:JSON.stringify(this.state.widgetProps)}});let o=1;const i=()=>{--o,t&&0===o&&t()};this.setState({widgetProps:Ai(e,((e,t)=>{const n=this.getWidgetInstance(t);if(n&&n.restoreSerializedState){++o;const s=n.restoreSerializedState(e,i);return N.default.extend({},this.state.widgetProps[t],s)}return e}))},(()=>{setTimeout(i,0)}))})),X(this,"showRationalesForCurrentlySelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{const t=this.getWidgetInstance(e);t&&t.showRationalesForCurrentlySelectedChoices&&t.showRationalesForCurrentlySelectedChoices(this._getWidgetInfo(e).options)}))})),X(this,"deselectIncorrectSelectedChoices",(()=>{Object.keys(this.props.widgets).forEach((e=>{const t=this.getWidgetInstance(e);t&&t.deselectIncorrectSelectedChoices&&t.deselectIncorrectSelectedChoices()}))})),X(this,"findInternalWidgets",(e=>{let t;if("string"==typeof e)if(-1!==e.indexOf(" ")){const n=e;t=(e,t,s)=>e===n}else{const n=e;t=(e,t,s)=>t.type===n}else t=e;return this.widgetIds.filter((e=>{const n=this._getWidgetInfo(e),s=this.getWidgetInstance(e);return t(e,n,s)})).map(this.getWidgetInstance)})),X(this,"findWidgets",(e=>[...this.findInternalWidgets(e),...this.props.findExternalWidgets(e)])),X(this,"getWidgetInstance",(e=>{const t=this.refs["container:"+e];return t?t.getWidget():null})),X(this,"_onWidgetFocus",(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!N.default.isArray(t))throw new he("widget props.onFocus focusPath must be an Array, but was"+JSON.stringify(t),pe.Internal);n._setCurrentFocus([e].concat(t))})),X(this,"_onWidgetBlur",((e,t)=>{const n=this._currentFocus,s=[e].concat(t);N.default.isEqual(s,n)&&N.default.defer((()=>{N.default.isEqual(this._currentFocus,n)&&this._setCurrentFocus(null)}))})),X(this,"getContent",((e,t)=>t.jiptContent||e.content)),X(this,"shouldRenderJiptPlaceholder",((e,t)=>le().JIPT.useJIPT&&null==t.jiptContent&&-1!==e.content.indexOf("crwdns"))),X(this,"replaceJiptContent",((e,t)=>{if(null==t)this.setState({jiptContent:e});else{/^\s*(`{3,}|~{3,})\s*(\S+)?\s*\n([\s\S]+?)\s*\1\s*$/.test(e)||(/\S\n\s*\n\S/.test(e)?e="$\\large{\\red{\\text{Please translate each paragraph to a single paragraph.}}}$":/^\s*$/.test(e)&&(e="$\\large{\\red{\\text{Translated paragraph is currently empty}}}$"));const n=this.getContent(this.props,this.state),s=ei.parseToArray(n);s[t]=e,this.setState({jiptContent:ei.joinFromArray(s)})}})),X(this,"outputMarkdown",((e,t)=>{if(N.default.isArray(e)){const n=t.key,s=[];let o=!1;for(let n=0;n<e.length;n++){t.key=n,t.paragraphIndex=n;const i=this.outputMarkdown(e[n],t),r="string"==typeof i;"string"==typeof i&&o?s[s.length-1]+=i:s.push(i),o=r}return t.key=n,s}this._foundTextNodes=!1,t.foundFullWidth=!1;const n=this.outputNested(e,t);let s;return s=null!=this.translationIndex?null:P.default({"perseus-paragraph-centered":!this._foundTextNodes,"perseus-paragraph-full-width":t.foundFullWidth&&1===e.content.length}),A.createElement(ni,{key:t.key,className:s,translationIndex:this.translationIndex,paragraphIndex:t.paragraphIndex},A.createElement($o,null,n))})),X(this,"outputNested",((e,t)=>{if(N.default.isArray(e)){const n=t.key,s=[];let o=!1;for(let n=0;n<e.length;n++){t.key=n;const i=this.outputNested(e[n],t),r="string"==typeof i;"string"==typeof i&&o?s[s.length-1]+=i:s.push(i),o=r}return t.key=n,s}return this.outputNode(e,this.outputNested,t)})),X(this,"outputNode",((e,t,n)=>{const s=this.getApiOptions(),o=s.imagePlaceholder;if("widget"===e.type){const t=s.widgetPlaceholder;return t||(this._foundTextNodes=!0,N.default.contains(this.widgetIds,e.id)?A.createElement("span",{key:n.key,className:"renderer-widget-error"},["Widget [[","☃"," ",e.id,"]] already exists."].join("")):(this.widgetIds.push(e.id),this.renderWidget(e.widgetType,e.id,n)))}if("blockMath"===e.type){const t=si(e.content),o={overflowX:"auto",overflowY:"hidden",paddingTop:10,paddingBottom:10,marginTop:-10,marginBottom:-10};if(s.isMobile){const e=16,s={marginLeft:-e,marginRight:-e},i={paddingLeft:e,paddingRight:e},r={...o,...Bi.mobileZoomableParentFix};return A.createElement("div",{key:n.key,className:"perseus-block-math",style:s},A.createElement($o,null,A.createElement("div",{className:"perseus-block-math-inner",style:{...r,...i}},A.createElement(Xo,null,t))))}return A.createElement("div",{key:n.key,className:"perseus-block-math"},A.createElement($o,null,A.createElement("div",{className:"perseus-block-math-inner",style:o},A.createElement(nn.Consumer,null,(e=>{let{setAssetStatus:n}=e;return A.createElement(Vo,{setAssetStatus:n},t)})))))}if("math"===e.type){const t=e.content.replace(/\{align[*]?\}/g,"{aligned}");return A.createElement("span",{key:n.key,style:{whiteSpace:"nowrap"}},A.createElement($o,null,A.createElement("span",null),A.createElement(nn.Consumer,null,(e=>{let{setAssetStatus:n}=e;return A.createElement(Vo,{onRender:this.props.onRender,setAssetStatus:n},t)})),A.createElement("span",null)))}if("image"===e.type){if(o)return o;const t=N.default.has(this.props.images,e.target)?this.props.images[e.target]:null,i=!n.inTable;return A.createElement($o,{key:n.key},A.createElement(nn.Consumer,null,(n=>{let{setAssetStatus:o}=n;return A.createElement(Go,$({setAssetStatus:o,src:Ke.sanitizeUrl(e.target),alt:e.alt,title:e.title,responsive:i,onUpdate:this.props.onRender,zoomToFullSizeOnMobile:s.isMobile&&s.isArticle},t))})))}if("columns"===e.type)return this._isTwoColumn=!0,A.createElement($o,{key:n.key},Ke.ruleOutput(e,t,n));if("text"===e.type)return Ri.test(e.content)&&(this._foundTextNodes=!0),o&&Fi.test(e.content)?o:e.content;if("table"===e.type||"titledTable"===e.type){const o=Ke.ruleOutput(e,t,{...n,isMobile:s.isMobile,inTable:!0});if(!s.isMobile)return o;const i=16,r={marginLeft:-i,marginRight:-i},a={...{paddingLeft:0,paddingRight:0},...Bi.mobileZoomableParentFix},l=A.createElement("div",{style:{...a,overflowX:"auto"}},A.createElement($o,null,A.createElement(jo,{animateHeight:!0},o)));return A.createElement("div",{style:r},l)}return A.createElement($o,{key:n.key},Ke.ruleOutput(e,t,n))})),X(this,"handleRender",(e=>{const t=this.props.onRender,n=e.onRender;if(t!==Di||n!==Di){const e=L.default(D.default.findDOMNode(this)).find("img");n!==Di&&e.off("load",n),t!==Di&&e.on("load",t)}t()})),X(this,"_setCurrentFocus",(e=>{const t=this.getApiOptions();if(n=e,s=this._currentFocus,!(null===n||null===s?n===s:N.default.every(n,((e,t)=>{if(null!=s)return N.default.isEqual(e,s[t])})))){const n=this._currentFocus;n&&this.blurPath(n),this._currentFocus=e,t.onFocusChange(this._currentFocus,n)}var n,s})),X(this,"focus",(()=>{let e,t;for(let n=0;n<this.widgetIds.length;n++){const s=this.widgetIds[n],o=this.getWidgetInstance(s),i=o&&o.focus&&o.focus();if(i){e=s,t=i;break}}if(e){let n;return"object"==typeof t?(n=[e].concat(t.path||[]),de.error("Renderer received a focus result of type 'object' instead of the expected type 'boolean'",pe.Internal,{loggedMetadata:{focusResult:JSON.stringify(t),currentProps:JSON.stringify(this.state.widgetProps)}})):n=[e],this._setCurrentFocus(n),!0}})),X(this,"getDOMNodeForPath",(e=>{const t=N.default.first(e),n=N.default.rest(e),s=this.getWidgetInstance(t),o=s&&s.getDOMNodeForPath;return o?o(n):0===n.length?D.default.findDOMNode(s):void 0})),X(this,"getGrammarTypeForPath",(e=>{const t=N.default.first(e),n=N.default.rest(e),s=this.getWidgetInstance(t);if(s&&s.getGrammarTypeForPath)return s.getGrammarTypeForPath(n)})),X(this,"getInputPaths",(()=>{const e=[];return N.default.each(this.widgetIds,(t=>{const n=this.getWidgetInstance(t);if(n&&n.getInputPaths){const s=n.getInputPaths();N.default.each(s,(n=>{const s=[t].concat(n);e.push(s)}))}})),e})),X(this,"focusPath",(e=>{if(N.default.isEqual(this._currentFocus,e))return;this._currentFocus&&this.blurPath(this._currentFocus);const t=N.default.first(e),n=N.default.rest(e),s=this.getWidgetInstance(t);s&&s.focusInputPath&&s.focusInputPath(n)})),X(this,"blurPath",(e=>{if(!N.default.isEqual(this._currentFocus,e))return;const t=N.default.first(e),n=N.default.rest(e);if(this.getWidgetInstance(t)){const e=this.getWidgetInstance(t);e&&e.blurInputPath&&e.blurInputPath(n)}})),X(this,"blur",(()=>{this._currentFocus&&this.blurPath(this._currentFocus)})),X(this,"serialize",(()=>{const e={};return N.default.each(this.state.widgetInfo,(function(t,n){const s=this.getWidgetInstance(n).serialize();N.default.isEmpty(s)||(e[n]=s)}),this),e})),X(this,"emptyWidgets",(()=>N.default.filter(this.widgetIds,(e=>{const t=this._getWidgetInfo(e);if(t.static)return!1;const n=this.getWidgetInstance(e);if(n&&n.simpleValidate){const e=n.simpleValidate(t.options,null);return Be.scoreIsEmpty(e)}})))),X(this,"_setWidgetProps",((e,t,n,s)=>{this.setState((n=>{const o={...n.widgetProps,[e]:{...n.widgetProps[e],...t}},i=s?n.lastUsedWidgetId:e;return s||this.props.onSerializedStateUpdated(this.getSerializedState(o)),{lastUsedWidgetId:i,widgetProps:o}}),(()=>{setTimeout((()=>{const t=n&&n();s||this.props.onInteractWithWidget(e),!1!==t&&this._setCurrentFocus([e])}),0)}))})),X(this,"setInputValue",((e,t,n)=>{var s;const o=N.default.first(e),i=N.default.rest(e),r=this.getWidgetInstance(o);null==r||null===(s=r.setInputValue)||void 0===s||s.call(r,i,t,n)})),X(this,"getUserInput",(()=>this.widgetIds.map((e=>{const t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),X(this,"getWidgetIds",(()=>this.widgetIds)),X(this,"getUserInputForWidgets",(()=>Ni(this.widgetIds,(e=>{const t=this.getWidgetInstance(e);if(t&&t.getUserInput)return t.getUserInput()})))),X(this,"scoreWidgets",(()=>{const e=this.state.widgetInfo,t=this.getApiOptions().onInputError,n=N.default.filter(this.widgetIds,(t=>{const n=e[t],s=null==(null==n?void 0:n.graded)||n.graded,o=!(null==n||!n.static);return s&&!o})),s={};return N.default.each(n,(n=>{const o=e[n],i=this.getWidgetInstance(n);i&&i.simpleValidate&&(s[n]=i.simpleValidate(null==o?void 0:o.options,t))})),s})),X(this,"score",(()=>N.default.reduce(this.scoreWidgets(),Be.combineScores,Be.noScore))),X(this,"guessAndScore",(()=>[this.getUserInput(),this.score()])),X(this,"examples",(()=>{const e=this.widgetIds,t=N.default.compact(N.default.map(e,(e=>{const t=this.getWidgetInstance(e);return null!=t&&t.examples?t.examples():null})));if(!t.length)return null;return N.default.all(t,(function(e){return N.default.isEqual(t[0],e)}))?t[0]:null})),X(this,"handleNotGorgonLintErrors",(e=>{this._isMounted&&this.setState({notGorgonLintErrors:e})})),this._notGorgon=new ti,this.state={jiptContent:null,notGorgonLintErrors:[],lastUsedWidgetId:null,...this._getInitialWidgetState(e)}}componentDidMount(){this._isMounted=!0,this.handleRender({}),this._currentFocus=null,this.props.serializedState&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}UNSAFE_componentWillReceiveProps(e){N.default.isEqual(N.default.pick(this.props,Oi),N.default.pick(e,Oi))||this.setState(this._getInitialWidgetState(e))}shouldComponentUpdate(e,t){if(this.props.alwaysUpdate)return!0;const n=!N.default.isEqual(this.state,t);return!N.default.isEqual(this.props,e)||n}UNSAFE_componentWillUpdate(e,t){const n=this.shouldRenderJiptPlaceholder(this.props,this.state),s=this.shouldRenderJiptPlaceholder(e,t),o=this.getContent(this.props,this.state),i=this.getContent(e,t),r=this.props.highlightedWidgets,a=e.highlightedWidgets;this.reuseMarkdown=!n&&!s&&o===i&&N.default.isEqual(this.state.notGorgonLintErrors,t.notGorgonLintErrors)&&(!this.props.linterContext.highlightLint||N.default.isEqual(this.props.widgets,e.widgets))&&this.props.linterContext.highlightLint===e.linterContext.highlightLint&&r===a}componentDidUpdate(e,t){this.handleRender(e),N.default.each(this.widgetIds,(e=>{const t=this.refs["container:"+e];t&&t.replaceWidgetProps(this.getWidgetProps(e))})),this.props.serializedState&&!N.default.isEqual(this.props.serializedState,this.getSerializedState())&&this.restoreSerializedState(this.props.serializedState),this.props.linterContext.highlightLint&&this._notGorgon.runLinter(this.props.content,this.handleNotGorgonLintErrors)}componentWillUnmount(){this.widgetIds=[],null!=this.translationIndex&&le().rendererTranslationComponents.removeComponentAtIndex(this.translationIndex),this._isMounted=!1}render(){const e=this.getApiOptions(),{KatexProvider:t}=le();if(this.reuseMarkdown)return this.lastRenderedMarkdown;const n=this.getContent(this.props,this.state);if(this.widgetIds=[],this.shouldRenderJiptPlaceholder(this.props,this.state)&&(this.translationIndex||(this.translationIndex=le().rendererTranslationComponents.addComponent(this)),!e.isArticle))return A.createElement(t,null,A.createElement("div",{"data-perseus-component-index":this.translationIndex},n));this._isTwoColumn=!1;const s=Ke.parse(n,{isJipt:null!=this.translationIndex});if(this.props.linterContext.highlightLint){const e={content:this.props.content,widgets:this.props.widgets,...this.props.linterContext};Vt.runLinter(s,e,!0),this._notGorgon.applyLintErrors(s,[...this.state.notGorgonLintErrors,...this.props.legacyPerseusLint||[]])}const o=this.outputMarkdown(s,{baseElements:e.baseElements}),i=P.default({[en.RENDERER]:!0,[en.RESPONSIVE_RENDERER]:!0,[en.TWO_COLUMN_RENDERER]:this._isTwoColumn});return this.lastRenderedMarkdown=A.createElement(t,null,A.createElement("div",{className:i},o)),this.lastRenderedMarkdown}}X(Li,"defaultProps",{content:"",widgets:{},images:{},highlightedWidgets:[],questionCompleted:!1,onRender:Di,onInteractWithWidget:function(){},findExternalWidgets:()=>[],alwaysUpdate:!1,reviewMode:!1,serializedState:null,onSerializedStateUpdated:()=>{},linterContext:Yt});const Bi={mobileZoomableParentFix:{transform:"translate3d(0,0,0)"}},zi={fontSize:"150%"},qi={fontSize:"120%"},Hi={fontSize:"130%"},Wi=[()=>[A.createElement("span",{key:"plus",style:qi},"+"),"+"],()=>[A.createElement("span",{key:"minus",style:zi},"-"),"-"],e=>{const{TeX:t}=le();return e.convertDotToTimes?[A.createElement(t,{key:"times",style:zi},I.doNotTranslate("\\times")),"\\times"]:[A.createElement(t,{key:"times",style:zi},I.doNotTranslate("\\cdot")),"\\cdot"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"frac",style:zi},I.doNotTranslate("\\frac{x}{y}")),e=>{const t=e.latex();e.typedText("/"),e.latex()===t&&e.cmd("\\frac")}]}],Ui={basic:Wi,"basic+div":Wi.concat([()=>{const{TeX:e}=le();return[A.createElement(e,{key:"div"},I.doNotTranslate("\\div")),"\\div"]}]),trig:[()=>{const{TeX:e}=le();return[A.createElement(e,{key:"sin"},I.doNotTranslate("\\sin")),"\\sin"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"cos"},I.doNotTranslate("\\cos")),"\\cos"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"tan"},I.doNotTranslate("\\tan")),"\\tan"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"theta",style:Hi},I.doNotTranslate("\\theta")),"\\theta"]},()=>{const{TeX:e}=le();return[A.createElement("span",{key:"phi"},A.createElement("span",{className:"perseus-sr-only"},I.doNotTranslate("phi")),A.createElement(e,{key:"pi",style:Hi},I.doNotTranslate("\\phi"))),"\\phi"]}],prealgebra:[()=>{const{TeX:e}=le();return[A.createElement(e,{key:"sqrt"},I.doNotTranslate("\\sqrt{x}")),"\\sqrt"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"nthroot"},I.doNotTranslate("\\sqrt[3]{x}")),e=>{e.typedText("nthroot3"),e.keystroke("Right")}]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"pow",style:qi},I.doNotTranslate("a^b")),e=>{const t=e.latex();e.typedText("^"),e.latex()===t&&e.typedText("a^b")}]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"pi",style:qi},I.doNotTranslate("\\pi")),"\\pi"]}],logarithms:[()=>{const{TeX:e}=le();return[A.createElement(e,{key:"log"},I.doNotTranslate("\\log")),"\\log"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"ln"},I.doNotTranslate("\\ln")),"\\ln"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"log_b"},I.doNotTranslate("\\log_b")),e=>{e.typedText("log_"),e.keystroke("Right"),e.typedText("("),e.keystroke("Left"),e.keystroke("Left")}]}],"basic relations":[()=>{const{TeX:e}=le();return[A.createElement(e,{key:"eq"},"="),"="]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"lt"},I.doNotTranslate("\\lt")),"\\lt"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"gt"},I.doNotTranslate("\\gt")),"\\gt"]}],"advanced relations":[()=>{const{TeX:e}=le();return[A.createElement(e,{key:"neq"},I.doNotTranslate("\\neq")),"\\neq"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"leq"},I.doNotTranslate("\\leq")),"\\leq"]},()=>{const{TeX:e}=le();return[A.createElement(e,{key:"geq"},I.doNotTranslate("\\geq")),"\\geq"]}]},Gi=R.default.arrayOf(R.default.oneOf(N.default(Ui).keys()));class Vi extends A.Component{render(){const e=N.default.sortBy(this.props.sets,(e=>N.default.keys(Ui).indexOf(e))),t=N.default(e).map((e=>Ui[e])),n=N.default(t).map((e=>e.map((e=>{const t=e(this.props);return A.createElement("button",{onClick:()=>this.props.onInsert(t[1]),className:"tex-button",key:t[0].key,type:"button"},t[0])})))),s=N.default(n).map(((e,t)=>A.createElement("div",{className:"clearfix tex-button-row",key:this.props.sets[t]},e)));return A.createElement("div",{className:"".concat(this.props.className||""," preview-measure")},s)}}X(Vi,"propTypes",{sets:Gi.isRequired,onInsert:R.default.func.isRequired,className:R.default.string}),X(Vi,"buttonSets",Ui),X(Vi,"buttonSetsType",Gi);const ji=R.default;class Yi extends A.Component{constructor(){super(...arguments),X(this,"mouseDown",void 0),X(this,"state",{focused:!1}),X(this,"handleFocus",(()=>{this.setState({focused:!0})})),X(this,"handleMouseDown",(e=>{const t=D.default.findDOMNode(this).contains(e.target);this.mouseDown=t,t||this.setState({focused:!1})})),X(this,"handleMouseUp",(()=>{this.mouseDown&&this.focus(),this.mouseDown=!1})),X(this,"handleBlur",(e=>{this.mouseDown||D.default.findDOMNode(this).contains(e.relatedTarget)||this.setState({focused:!1})})),X(this,"_shouldShowButtons",(()=>"always"===this.props.buttonsVisible||"never"!==this.props.buttonsVisible&&this.state.focused)),X(this,"insert",(e=>{const t=this.mathField();N.default(e).isFunction()?e(t):"\\"===e[0]?t.cmd(e).focus():t.write(e).focus(),t.focus()})),X(this,"mathField",(e=>z.default.getInterface(2).MathField(D.default.findDOMNode(this.refs.mathinput),e))),X(this,"focus",(()=>{this.mathField().focus(),this.setState({focused:!0})})),X(this,"blur",(()=>{this.mathField().blur(),this.setState({focused:!1})}))}render(){let e=P.default({"perseus-math-input":!0,"mq-editable-field":!0,"mq-math-mode":!0});this.props.className&&(e=e+" "+this.props.className);let t=null;return this._shouldShowButtons()&&(t=A.createElement(Vi,{sets:this.props.buttonSets,className:"math-input-buttons absolute",convertDotToTimes:this.props.convertDotToTimes,onInsert:this.insert})),A.createElement("div",{style:{display:"inline-block"}},A.createElement("div",{style:{display:"inline-block"}},A.createElement("span",{className:e,ref:"mathinput","aria-label":this.props.labelText,onFocus:this.handleFocus,onBlur:this.handleBlur})),A.createElement("div",{style:{position:"relative"},onBlur:this.handleBlur},t))}componentWillUnmount(){window.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}componentDidMount(){window.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp);let e=!1;this.mathField({autoCommands:"pi theta phi sqrt nthroot",charsThatBreakOutOfSupSub:"+-*/=<>≠≤≥",supSubsRequireOperand:!0,spaceBehavesLikeTab:!0,handlers:{edited:t=>{let n=t.latex();if(n=n.replace(/<>/g,"\\ne"),this.props.convertDotToTimes){n=n.replace(/\\cdot/g,"\\times");const e=t.__controller.cursor[z.default.L];e&&"\\cdot "===e.ctrlSeq&&(t.__controller.backspace(),t.cmd("\\times"))}else n=n.replace(/\\times/g,"\\cdot");e&&this.props.value!==n&&this.props.onChange(n)},enter:()=>{L.default(D.default.findDOMNode(this.refs.mathinput)).submit()},upOutOf:e=>{e.typedText("^")}}}),this.mathField().latex(this.props.value),e=!0}}function Xi(e,t,n){const s=e.indexOf("{",t)+1,o=function(e,t){let n=0;for(let s=t,o=e.length;s<o;s++){const t=e[s];if("{"===t?n++:"}"===t&&n--,n<0)return s}return e.length}(e,s);return{endpoint:o,expression:Ki(e.substring(s,o),n)}}function $i(e,t){const n=e.indexOf("\\frac",t),s=e.indexOf("\\dfrac",t);return n>-1&&s>-1?Math.min(n,s):n>-1?n:s>-1?s:-1}function Ki(e,t){if(!e)return"";let n="",s=0,o=$i(e,s);for(;o>-1;){n+=e.substring(s,o),s=o;const i=Xi(e,s,t);s=i.endpoint+1;const r=Xi(e,s,t);s=r.endpoint+1,n.length&&(n+=" "),n+=t(i.expression,r.expression),o=$i(e,s)}return n+=e.slice(s),n}X(Yi,"propTypes",{value:ji.string,onChange:ji.func.isRequired,convertDotToTimes:ji.bool,buttonsVisible:ji.oneOf(["always","never","focused"]),buttonSets:Vi.buttonSetsType.isRequired,labelText:R.default.string,onFocus:ji.func,onBlur:ji.func}),X(Yi,"defaultProps",{value:"",convertDotToTimes:!1,buttonsVisible:"focused"});var Zi=function(e){return Ki(e,(function(e,t){return e+"/"+t})).replace("\\%","%")};const Ji=function(e){function t(e){return e.indexOf("\\frac")>-1||e.indexOf("\\dfrac")>-1}return Ki(e,(function(e,n){let s;return s=t(e)||t(n)?"\\dfrac":"\\frac",s+" {"+e+"}{"+n+"}"}))};class Qi extends A.Component{constructor(){super(...arguments),X(this,"state",{focused:!1,selectorNamespace:N.default.uniqueId("math-output")}),X(this,"_getInputClassName",(()=>{let e="math-output "+en.INPUT+" "+en.INTERACTIVE;return this.state.focused&&(e+=" "+en.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),X(this,"_getDisplayValue",(e=>{let t;return t=null!=e?""+e:"",Ji(t)})),X(this,"getValue",(()=>this.props.value)),X(this,"focus",(()=>{this.state.focused||(this.props.onFocus(),this._bindBlurHandler(),this.setState({focused:!0}))})),X(this,"blur",(()=>{this.state.focused&&(this.props.onBlur(),this._unbindBlurHandler(),this.setState({focused:!1}))})),X(this,"_bindBlurHandler",(()=>{L.default(document).bind("vclick."+this.state.selectorNamespace,(e=>{L.default(e.target).closest(D.default.findDOMNode(this)).length||this.blur()}))})),X(this,"_unbindBlurHandler",(()=>{L.default(document).unbind("."+this.state.selectorNamespace)}))}render(){const{TeX:e}=le();return A.createElement("span",{ref:"input",className:this._getInputClassName(),"aria-label":this.props.labelText,onMouseDown:this.focus,onTouchStart:this.focus},A.createElement("div",{style:{textAlign:"center"}},A.createElement(e,null,this._getDisplayValue(this.props.value))))}componentWillUnmount(){this._unbindBlurHandler()}}X(Qi,"propTypes",{value:R.default.oneOfType([R.default.string,R.default.number]),className:R.default.string,labelText:R.default.string,onFocus:R.default.func,onBlur:R.default.func}),X(Qi,"defaultProps",{value:"",onFocus:function(){},onBlur:function(){}});class er extends A.Component{constructor(){super(...arguments),X(this,"focus",(()=>{D.default.findDOMNode(this).focus()})),X(this,"blur",(()=>{D.default.findDOMNode(this).blur()})),X(this,"getValue",(()=>{var e;return null===(e=D.default.findDOMNode(this))||void 0===e?void 0:e.value})),X(this,"getStringValue",(()=>{var e;return null===(e=D.default.findDOMNode(this))||void 0===e?void 0:e.value.toString()})),X(this,"setSelectionRange",((e,t)=>{D.default.findDOMNode(this).setSelectionRange(e,t)})),X(this,"getSelectionStart",(()=>D.default.findDOMNode(this).selectionStart)),X(this,"getSelectionEnd",(()=>D.default.findDOMNode(this).selectionEnd))}render(){const{labelText:e,...t}=this.props;return A.createElement("input",$({},t,{type:"text","aria-label":e,onChange:e=>this.props.onChange(e.target.value)}))}}X(er,"propTypes",{value:R.default.string,onChange:R.default.func.isRequired,className:R.default.string,labelText:R.default.string,onFocus:R.default.func,onBlur:R.default.func,disabled:R.default.bool}),X(er,"defaultProps",{value:"",disabled:!1});const tr=B.default({displayName:"Triangle",propTypes:{color:R.default.string.isRequired,left:R.default.number.isRequired,top:R.default.number.isRequired,width:R.default.number.isRequired,height:R.default.number.isRequired,horizontalDirection:R.default.oneOf(["left","right"]).isRequired,verticalDirection:R.default.oneOf(["top","bottom"]).isRequired},render:function(){let e,t,n,s;const o="".concat(this.props.width,"px solid transparent");"right"===this.props.horizontalDirection?e=o:t=o;const i="".concat(this.props.height,"px solid ").concat(this.props.color);return"top"===this.props.verticalDirection?n=i:s=i,A.createElement("div",{style:{display:"block",height:0,width:0,position:"absolute",left:this.props.left,top:this.props.top,borderLeft:e,borderRight:t,borderTop:n,borderBottom:s}})}}),nr=B.default({displayName:"TooltipArrow",propTypes:{position:R.default.string,visibility:R.default.string,left:R.default.number,top:R.default.number,color:R.default.string.isRequired,border:R.default.string.isRequired,width:R.default.number.isRequired,height:R.default.number.isRequired,horizontalDirection:R.default.oneOf(["left","right"]).isRequired,verticalDirection:R.default.oneOf(["top","bottom"]).isRequired},getDefaultProps:function(){return{position:"relative",visibility:"visible",left:0,top:0}},render:function(){const e="top"===this.props.verticalDirection,t=e?0:1,n=e?0:-1;return A.createElement("div",{style:{display:"block",position:this.props.position,visibility:this.props.visibility,left:this.props.left,top:this.props.top,width:this.props.width+2,height:this.props.height+1,marginTop:-1,marginBottom:-2,zIndex:10}},A.createElement(tr,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.border,left:0,top:n,width:this.props.width+2,height:this.props.height+2}),A.createElement(tr,{horizontalDirection:this.props.horizontalDirection,verticalDirection:this.props.verticalDirection,color:this.props.color,left:1,top:t,width:this.props.width,height:this.props.height}))}}),sr={top:{top:"-100%"},bottom:{top:0}},or={left:{targetLeft:0},right:{targetLeft:"100%"}},ir={left:{tooltipLeft:0,arrowLeft:e=>0},right:{tooltipLeft:"-100%",arrowLeft:e=>-e-2}},rr=B.default({displayName:"Tooltip",propTypes:{show:R.default.bool.isRequired,className:R.default.string,arrowSize:R.default.number,borderColor:R.default.string,verticalPosition:R.default.oneOf(Object.keys(sr)),horizontalPosition:R.default.oneOf(Object.keys(or)),horizontalAlign:R.default.oneOf(Object.keys(ir)),children:R.default.arrayOf(R.default.element).isRequired,targetContainerStyle:R.default.any},getDefaultProps:function(){return{className:"",arrowSize:10,borderColor:"#ccc",verticalPosition:"bottom",horizontalPosition:"left",horizontalAlign:"left",targetContainerStyle:{}}},getInitialState:function(){return{height:null}},componentDidMount:function(){this._updateHeight()},UNSAFE_componentWillReceiveProps:function(){this.setState({height:null})},componentDidUpdate:function(){this._updateHeight()},_renderToolTipDiv:function(e){const t=Object.assign({},or[this.props.horizontalPosition],ir[this.props.horizontalAlign],sr[this.props.verticalPosition]);let n,s;return e?(n=A.createElement(nr,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,position:"absolute",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:2-this.props.arrowSize,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),s=A.createElement(nr,{verticalDirection:"top",horizontalDirection:this.props.horizontalAlign,visibility:"hidden",color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10})):(n=A.createElement(nr,{verticalDirection:"bottom",horizontalDirection:this.props.horizontalAlign,color:"white",border:this.props.borderColor,left:t.arrowLeft(this.props.arrowSize),top:-1,width:this.props.arrowSize,height:this.props.arrowSize,zIndex:10}),s=null),A.createElement("div",{style:{position:"relative",height:0,display:this.props.show?"block":"none"}},A.createElement("div",{ref:"tooltipContainer",className:"tooltipContainer",style:{position:"absolute",height:this.state.height||void 0,left:t.targetLeft}},n,A.createElement("div",{className:this.props.className,ref:"tooltipContent",style:{position:"relative",top:t.top,left:t.tooltipLeft,border:"1px solid "+this.props.borderColor,WebkitBoxShadow:"0 1px 3px "+this.props.borderColor,MozBoxShadow:"0 1px 3px "+this.props.borderColor,boxShadow:"0 1px 3px "+this.props.borderColor,zIndex:9}},this.props.children.slice(1)),s))},_updateHeight:function(){const e=D.default.findDOMNode(this.refs.tooltipContainer).offsetHeight;e!==this.state.height&&this.setState({height:e})},render:function(){const e="top"===this.props.verticalPosition;return A.createElement("span",null,e&&this._renderToolTipDiv(e),A.createElement("div",{style:this.props.targetContainerStyle},this.props.children[0]),!e&&this._renderToolTipDiv())}}),{captureScratchpadTouchStart:ar}=Be;class lr extends A.Component{constructor(){super(...arguments),X(this,"state",{focused:!1,showExamples:!1}),X(this,"_getUniqueId",(()=>"input-with-examples-".concat(btoa(this.props.id).replace(/=/g,"")))),X(this,"_getInputClassName",(()=>{if("tex"===this.props.type)return this.props.className;let e=en.INPUT+" "+en.INTERACTIVE;return this.state.focused&&(e+=" "+en.FOCUSED),this.props.className&&(e+=" "+this.props.className),e})),X(this,"_getPropsForInputType",(()=>{const e={"aria-describedby":this._getUniqueId(),ref:"input",className:this._getInputClassName(),labelText:this.props.labelText,value:this.props.value,onFocus:this._handleFocus,onBlur:this._handleBlur,disabled:this.props.disabled};return"tex"===this.props.type?e:(N.default.extend(e,{onChange:this.props.onChange,onTouchStart:ar}),"math"===this.props.type?N.default.extend({buttonSet:this.props.buttonSet,buttonsVisible:this.props.buttonsVisible,convertDotToTimes:this.props.convertDotToTimes},e):"text"===this.props.type?N.default.extend({autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:"false"},e):void 0)})),X(this,"_getComponentForInputType",(()=>{switch(this.props.type){case"tex":return Qi;case"math":return Yi;case"text":return er;default:return null}})),X(this,"_renderInput",(()=>{const e=this._getPropsForInputType(),t=this._getComponentForInputType();return A.createElement(t,e)})),X(this,"_handleFocus",(()=>{this.props.onFocus(),this.setState({focused:!0,showExamples:!0})})),X(this,"show",(()=>{this.setState({showExamples:!0})})),X(this,"hide",(()=>{this.setState({showExamples:!1})})),X(this,"_handleBlur",(()=>{this.props.onBlur(),this.setState({focused:!1,showExamples:!1})})),X(this,"focus",(()=>{this.refs.input.focus()})),X(this,"blur",(()=>{this.refs.input.blur()})),X(this,"handleChange",(e=>{this.props.onChange(e.target.value)}))}render(){const e=this._renderInput();if("tex"===this.props.type)return e;const t=N.default.map(this.props.examples,(e=>"- "+e)).join("\n"),n=this.props.shouldShowExamples&&this.state.showExamples;return A.createElement(rr,{ref:"tooltip",className:"perseus-formats-tooltip preview-measure",horizontalPosition:"left",horizontalAlign:"left",verticalPosition:"bottom",arrowSize:10,borderColor:"#ccc",show:n},e,A.createElement("div",{id:this._getUniqueId()},A.createElement(Li,{content:t,linterContext:Vt.pushContextStack(this.props.linterContext,"input-with-examples")})))}}X(lr,"propTypes",{type:R.default.oneOf(["math","text","tex"]),value:R.default.string,onChange:R.default.func.isRequired,className:R.default.string,examples:R.default.arrayOf(R.default.string).isRequired,shouldShowExamples:R.default.bool,convertDotToTimes:R.default.bool,buttonSet:R.default.string,buttonsVisible:R.default.oneOf(["always","never","focused"]),labelText:R.default.string,onFocus:R.default.func,onBlur:R.default.func,disabled:R.default.bool,id:R.default.string.isRequired,linterContext:jt}),X(lr,"defaultProps",{type:"text",shouldShowExamples:!0,onFocus:function(){},onBlur:function(){},disabled:!1,linterContext:Yt});var cr=["key","ref","containerSizeClass","widgetId","onChange","problemNum","apiOptions","questionCompleted","findWidgets","onRemove","id","onBlur","onFocus","trackInteraction","keypadElement"];const pr='Usage:\n this.change({propName: 5}, callback);\n this.change("propName", 5, callback);\n this.change("propName")',dr=function(e,t,n){const s=N.default.omit(e.props,cr),o=N.default.extend(s,t);e.props.onChange(o,n)},hr=function(e,t,n,s){if(void 0===n)return N.default.partial(hr,e,t);const o={};o[t]=n,dr(e,o,s)},ur=function(e,t,n){if(N.default.isObject(e)&&void 0===n)return dr(this,e,n=t);if("string"==typeof e)return hr(this,e,t,n);throw new he("Invalid types sent to this.change(): "+N.default.toArray(arguments).join()+"\n"+pr,pe.Internal)},fr={onChange:R.default.func.isRequired};var mr=Object.freeze({__proto__:null,change:ur,propTypes:fr});const gr=I._("Sorry, I don't understand that!"),vr=e=>e.replace(/([_^])([^{])/g,"$1{$2}");class br extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"displayName","Expression"),X(this,"state",{showErrorTooltip:!1,showErrorText:!1}),X(this,"componentDidMount",(()=>{this._isMounted=!0})),X(this,"componentDidUpdate",(e=>{N.default.isEqual(this.props.value,e.value)&&N.default.isEqual(this.props.functions,e.functions)||(clearTimeout(this.errorTimeout),this.parse(this.props.value,this.props).parsed?this.setState({showErrorTooltip:!1}):this.errorTimeout=setTimeout((()=>{!1!==this.props.apiOptions.onInputError(null,this.props.value,gr)&&this.setState({showErrorTooltip:!0})}),2e3))})),X(this,"componentWillUnmount",(()=>{clearTimeout(this.errorTimeout),this._isMounted=!1})),X(this,"_isMounted",!1),X(this,"errorTimeout",null),X(this,"simpleValidate",((e,t)=>(t=t||function(){},br.validate(this.getUserInput(),e,t)))),X(this,"getUserInput",(()=>br.getUserInputFromProps(this.props))),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"parse",((e,t)=>{const n=N.default.pick(t||this.props,"functions");return N.default.extend(n,{decimal_separator:I.getDecimalSeparator()}),T.parse(vr(e),n)})),X(this,"changeAndTrack",((e,t)=>{this.change("value",e,t),this.props.trackInteraction()})),X(this,"_handleFocus",(()=>{this.props.onFocus([])})),X(this,"_handleBlur",(()=>{this.props.onBlur([])})),X(this,"focus",(()=>(this.props.apiOptions.customKeypad&&this.refs.input.focus(),!0))),X(this,"focusInputPath",(e=>{this.refs.input.focus()})),X(this,"blurInputPath",(e=>{this.refs.input.blur()})),X(this,"insert",(e=>{this.props.apiOptions.staticRender||this.refs.input.insert(e)})),X(this,"getInputPaths",(()=>[[]])),X(this,"getGrammarTypeForPath",(e=>"expression")),X(this,"setInputValue",((e,t,n)=>{this.props.onChange({value:t},n)}))}static validate(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};const s=N.default.clone(t);N.default.extend(s,{decimal_separator:I.getDecimalSeparator()});const o=e=>{const n=T.parse(e.value,t);return n.parsed?ge.expression.createValidatorFunctional(n.expr,N.default({}).extend(s,{simplify:e.simplify,form:e.form})):(de.error("Unable to parse solution answer for expression",pe.InvalidInput,{loggedMetadata:{rubric:JSON.stringify(t)}}),null)};let i,r,a,l=!0;for(const n of t.answerForms||[]){const t=o(n);if(!t)continue;const s=t(e);if(s.correct){i=n,r=s.message||"";break}l=l&&s.empty,"correct"===n.considered&&s.ungraded&&!a&&(a=s)}if(!i)return a?{type:"invalid",message:a.message,suppressAlmostThere:a.suppressAlmostThere}:l?{type:"invalid",message:null}:{type:"points",earned:0,total:1};if("ungraded"===i.considered){return{type:"invalid",message:!1===n(null,e,r)?null:r}}return{type:"points",earned:"correct"===i.considered?1:0,total:1,message:r}}static getUserInputFromProps(e){return vr(e.value)}static getOneCorrectAnswerFromRubric(e){const t=(e.answerForms||[]).filter((e=>"correct"===e.considered));if(0!==t.length)return t[0].value}render(){if(this.props.apiOptions.customKeypad)return A.createElement(t.KeypadInput,{ref:"input",value:this.props.value,keypadElement:this.props.keypadElement,onChange:this.changeAndTrack,onFocus:()=>{var e;null===(e=this.props.keypadElement)||void 0===e||e.configure(this.props.keypadConfiguration,(()=>{this._isMounted&&this._handleFocus()}))},onBlur:this._handleBlur});if(this.props.apiOptions.staticRender)return A.createElement(lr,{ref:"input",value:this.props.value,type:"tex",examples:[],shouldShowExamples:!1,onChange:this.changeAndTrack,onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,linterContext:this.props.linterContext});const e=A.createElement("span",{className:"error-tooltip",role:"tooltip"},A.createElement(rr,{className:"error-text-container",horizontalPosition:"right",horizontalAlign:"left",verticalPosition:"top",arrowSize:10,borderColor:"#fcc335",show:this.state.showErrorText},A.createElement("span",{className:"error-icon","data-test-id":"test-error-icon",onMouseEnter:()=>{this.setState({showErrorText:!0})},onMouseLeave:()=>{this.setState({showErrorText:!1})},onClick:()=>{this.setState({showErrorText:!this.state.showErrorText})}},A.createElement(K,ws)),A.createElement("div",{className:"error-text"},gr))),n=P.default({"perseus-widget-expression":!0,"show-error-tooltip":this.state.showErrorTooltip});return A.createElement("div",{className:n},A.createElement(Yi,{ref:"input",className:en.INTERACTIVE,value:this.props.value,onChange:this.changeAndTrack,convertDotToTimes:this.props.times,buttonsVisible:this.props.buttonsVisible||"focused",buttonSets:this.props.buttonSets,onFocus:this._handleFocus,onBlur:this._handleBlur}),this.state.showErrorTooltip&&e)}}X(br,"defaultProps",{value:"",times:!1,functions:[],buttonSets:["basic","trig","prealgebra","logarithms"],onFocus:()=>{},onBlur:()=>{},apiOptions:Qt.defaults,linterContext:Yt});const yr=e=>{const n=t.KeypadTypes.EXPRESSION,s={},o={};for(const t of e.answerForms){const n=T.parse(t.value,e);if(n.parsed){const e=n.expr,t=e=>"pi"===e||"theta"===e,i=e=>t(e)?e.toUpperCase():e;for(const t of e.getVars())s[i(t)]=!0;for(const t of e.getConsts())o[i(t)]=!0}}const i=Object.keys(s);i.sort();const r=Object.keys(o);r.sort();const a=[...i,...r];return a.length||a.push("PI"),{keypadType:n,extraKeys:a}};var xr={name:"expression",displayName:"Expression / Equation",defaultAlignment:"inline-block",widget:br,transform:e=>{const{times:t,functions:n,buttonSets:s,buttonsVisible:o}=e;return{keypadConfiguration:yr(e),times:t,functions:n,buttonSets:s,buttonsVisible:o}},version:{major:1,minor:0},propUpgrades:{1:e=>({times:e.times,buttonSets:e.buttonSets,functions:e.functions,buttonsVisible:e.buttonsVisible,answerForms:[{considered:"correct",form:e.form,simplify:e.simplify,value:e.value}]})},isLintable:!0};class Cr extends A.Component{render(){const e=N.default.uniq(this.props.answers),t=N.default.map(e,(e=>A.createElement("dd",{key:e},e)));return A.createElement("dl",{className:"perseus-possible-answers"},A.createElement("dt",null,I.doNotTranslate("Correct Answer")),t)}}X(Cr,"propTypes",{answers:R.default.arrayOf(R.default.string)});const wr=B.default({displayName:"SimpleKeypadInput",propTypes:{keypadElement:t.keypadElementPropType,onFocus:R.default.func,value:R.default.oneOfType([R.default.string,R.default.number])},componentDidMount:function(){this._isMounted=!0},componentWillUnmount:function(){this._isMounted=!1},focus(){this.refs.input.focus()},blur(){this.refs.input.blur()},getValue:function(){return this.props.value},render(){const e=this,{keypadElement:n,onFocus:s,value:o,...i}=e.props;return A.createElement(t.KeypadInput,$({ref:"input",keypadElement:n,onFocus:()=>{n?n.configure({keypadType:t.KeypadTypes.FRACTION},(()=>{e._isMounted&&s&&s()})):s&&s()},value:null==o?"":""+o},i))}}),kr=Zi,Sr={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"}},Er={integer:function(e){return I._("an integer, like $6$")},proper:function(e){return"optional"===e.simplify?I._("a *proper* fraction, like $1/2$ or $6/10$"):I._("a *simplified proper* fraction, like $3/5$")},improper:function(e){return"optional"===e.simplify?I._("an *improper* fraction, like $10/7$ or $14/8$"):I._("a *simplified improper* fraction, like $7/4$")},mixed:function(e){return I._("a mixed number, like $1\\ 3/4$")},decimal:function(e){return I._("an *exact* decimal, like $0.75$")},percent:function(e){return I._("a percent, like $12.34\\%$")},pi:function(e){return I._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")}};class _r extends A.Component{constructor(){super(...arguments),X(this,"shouldShowExamples",(()=>"number"!==this.props.answerType&&!this.props.apiOptions.staticRender)),X(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t)})),X(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),X(this,"_handleFocus",(()=>{this.props.onFocus([]);const{interactionCallback:e}=this.props.apiOptions;e&&e()})),X(this,"_handleBlur",(()=>{this.props.onBlur([])})),X(this,"focus",(()=>(this.refs.input.focus(),!0))),X(this,"focusInputPath",(e=>{this.refs.input.focus()})),X(this,"blurInputPath",(e=>{this.refs.input.blur()})),X(this,"getInputPaths",(()=>[[]])),X(this,"getGrammarTypeForPath",(e=>"number")),X(this,"setInputValue",((e,t,n)=>{this.props.onChange({currentValue:t},n)})),X(this,"getUserInput",(()=>_r.getUserInputFromProps(this.props))),X(this,"simpleValidate",((e,t)=>(t=t||function(){},_r.validate(this.getUserInput(),e,t)))),X(this,"examples",(()=>{const e=this.props.answerType,t=Sr[e].forms.split(/\s*,\s*/),n=N.default.map(t,(function(e){return Er[e](this.props)}),this);return[I._("**Your answer should be** ")].concat(n)}))}render(){if(this.props.apiOptions.customKeypad){const e=A.createElement(wr,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur});return this.props.rightAlign?A.createElement("div",{className:"perseus-input-right-align"},e):e}const e=this.props.reviewModeRubric;let t=null,n=null;if(this.props.apiOptions.satStyling&&e){const s=this.simpleValidate(e);if(t="points"===s.type&&s.earned===s.total,!t){let t=String(e.value);e.inexact&&e.maxError&&(t+=" ± "+e.maxError);const s=[t];n=A.createElement(Cr,{answers:s})}}const s={};s["perseus-input-size-"+this.props.size]=!0,s["perseus-input-right-align"]=this.props.rightAlign,s[en.CORRECT]=e&&t&&this.props.currentValue,s[en.INCORRECT]=e&&!t&&this.props.currentValue,s[en.UNANSWERED]=e&&!this.props.currentValue;const o=A.createElement(lr,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:P.default(s),type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,linterContext:this.props.linterContext});return n?A.createElement("span",{className:"perseus-input-with-answer-blurb"},o,n):o}static validate(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>{};null==t.answerType&&(t.answerType="number");const s=ge.number.createValidatorFunctional(t.value,{simplify:t.simplify,inexact:t.inexact||void 0,maxError:t.maxError,forms:Sr[t.answerType].forms})(kr(e.currentValue));if(s.empty){return{type:"invalid",message:!1===(null==n?void 0:n(null,e.currentValue,s.message))?null:s.message}}return{type:"points",earned:s.correct?1:0,total:1,message:s.message}}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){if(null==e.value)return;let t=String(e.value);return e.inexact&&e.maxError&&(t+=" ± "+e.maxError),t}}X(_r,"defaultProps",{currentValue:"",size:"normal",answerType:"number",rightAlign:!1,apiOptions:Qt.defaults,linterContext:Yt});var Mr={name:"input-number",displayName:"Number text box (old)",defaultAlignment:"inline-block",hidden:!0,widget:_r,transform:e=>{const{simplify:t,size:n,answerType:s,rightAlign:o}=e;return{simplify:t,size:n,answerType:s,rightAlign:o}},isLintable:!0};const Tr=Zi,Ir=[{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:"π"}],Pr={integer:()=>I._("an integer, like $6$"),proper:e=>"optional"===e.simplify?I._("a *proper* fraction, like $1/2$ or $6/10$"):I._("a *simplified proper* fraction, like $3/5$"),improper:e=>"optional"===e.simplify?I._("an *improper* fraction, like $10/7$ or $14/8$"):I._("a *simplified improper* fraction, like $7/4$"),mixed:()=>I._("a mixed number, like $1\\ 3/4$"),decimal:()=>I._("an *exact* decimal, like $0.75$"),pi:()=>I._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$")};class Ar extends A.Component{constructor(){super(...arguments),X(this,"state",{previousValues:[""]}),X(this,"getAnswerBlurb",(e=>{let t,n;if(this.props.apiOptions.satStyling&&e){const s=this.simpleValidate(e);if(t="points"===s.type&&s.earned===s.total,!t){const t=N.default.filter(e.answers,(e=>"correct"===e.status)),s=N.default.map(t,(e=>{let t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);let n=ue.toNumericString(e.value,t);return e.maxError&&(n+=" ± "+ue.toNumericString(e.maxError,t)),n}));n=A.createElement(Cr,{answers:s})}}return[n,!!t]})),X(this,"getClasses",((e,t)=>{const n={};return n["perseus-input-size-"+this.props.size]=!0,n["perseus-input-right-align"]=this.props.rightAlign,n[en.CORRECT]=t&&e&&this.props.currentValue,n[en.INCORRECT]=t&&!e&&this.props.currentValue,n[en.UNANSWERED]=t&&!this.props.currentValue,n})),X(this,"examples",(()=>{var e;const t=0!==(null===(e=this.props.answerForms)||void 0===e?void 0:e.length)?this.props.answerForms:N.default.map(N.default.keys(Pr),(e=>({name:e,simplify:"required"})));let n=N.default.map(t,(e=>Pr[e.name](e)));return n=N.default.uniq(n),[I._("**Your answer should be** ")].concat(n)})),X(this,"shouldShowExamples",(()=>{var e,t;const n=0===(null===(e=this.props.answerForms)||void 0===e?void 0:e.length),s=N.default.uniq(null===(t=this.props.answerForms)||void 0===t?void 0:t.map((e=>e.name))).length>=N.default.size(Pr);return!n&&!s})),X(this,"simpleValidate",(e=>Ar.validate(this.getUserInput(),e))),X(this,"focus",(()=>(this.refs.input.focus(),!0))),X(this,"focusInputPath",(e=>{this.refs.input.focus()})),X(this,"blurInputPath",(e=>{this.refs.input.blur()})),X(this,"getInputPaths",(()=>[[]])),X(this,"getGrammarTypeForPath",(e=>"number")),X(this,"setInputValue",((e,t,n)=>{this.props.onChange({currentValue:t},n)})),X(this,"getUserInput",(()=>Ar.getUserInputFromProps(this.props))),X(this,"handleChange",((e,t)=>{this.props.onChange({currentValue:e},t),this.props.trackInteraction()})),X(this,"_getInputType",(()=>this.props.apiOptions.staticRender?"tex":"text")),X(this,"_handleFocus",(()=>{this.props.onFocus([]);const{interactionCallback:e}=this.props.apiOptions;e&&e()})),X(this,"_handleBlur",(()=>{this.props.onBlur([])}))}static getUserInputFromProps(e){return{currentValue:e.currentValue}}static getOneCorrectAnswerFromRubric(e){const t=N.default.filter(e.answers,(e=>"correct"===e.status)),n=N.default.map(t,(e=>{let t="decimal";e.answerForms&&e.answerForms[0]&&(t=e.answerForms[0]);let n=ue.toNumericString(e.value,t);return e.maxError&&(n+=" ± "+ue.toNumericString(e.maxError,t)),n}));if(0!==n.length)return n[0]}static validate(e,t){const n=N.default.pluck(Ir,"value"),s=e=>ge.number.createValidatorFunctional(e.value,{message:e.message,simplify:"correct"===e.status?e.simplify:"optional",inexact:!0,maxError:e.maxError,forms:e.strict&&e.answerForms&&0!==e.answerForms.length?e.answerForms:n}),o=Tr(e.currentValue),i=N.default.where(t.answers,{status:"correct"}),r=i.every((e=>Math.abs(e.value)<=1));let a=N.default.find(N.default.map(i,(e=>{let n=o;t.coefficient&&(n?"-"===n&&(n=-1):n=1);return s(e)(Rr(n,r))})),(e=>e.correct||e.empty));if(!a){const e=[].concat(N.default.where(t.answers,{status:"ungraded"}),N.default.where(t.answers,{status:"wrong"})),n=N.default.find(e,(e=>s(e)(Rr(o,r)).correct));a={empty:!!n&&"ungraded"===n.status,correct:!!n&&"correct"===n.status,message:n?n.message:null,guess:o}}return a.empty?{type:"invalid",message:a.message}:{type:"points",earned:a.correct?1:0,total:1,message:a.message}}render(){const e=this.props.reviewModeRubric,t=this.getAnswerBlurb(e),n=t[0],s=t[1],o=this.getClasses(s,e);let i=this.props.labelText;null!=i&&""!==i||(i=I._("Your answer:"));const r=e=>this.props.rightAlign?A.createElement("div",{className:"perseus-input-right-align"},e):e;if(this.props.apiOptions.customKeypad)return r(A.createElement(wr,{ref:"input",value:this.props.currentValue,keypadElement:this.props.keypadElement,onChange:this.handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur}));const a=A.createElement(lr,{ref:"input",value:this.props.currentValue,onChange:this.handleChange,className:P.default(o),labelText:i,type:this._getInputType(),examples:this.examples(),shouldShowExamples:this.shouldShowExamples(),onFocus:this._handleFocus,onBlur:this._handleBlur,id:this.props.widgetId,disabled:this.props.apiOptions.readOnly,highlightLint:this.props.highlightLint});return n?A.createElement("span",{className:"perseus-input-with-answer-blurb"},a,n):this.props.apiOptions.satStyling?A.createElement("label",{className:"perseus-input-with-label"},A.createElement("span",{className:"perseus-input-label","aria-hidden":"true"},I.doNotTranslate("Answer:")),a):A.createElement("div",null,a)}}X(Ar,"defaultProps",{currentValue:"",size:"normal",rightAlign:!1,apiOptions:Qt.defaults,coefficient:!1,answerForms:[],labelText:"",linterContext:Yt,multipleNumberInput:!1});const Nr=function(e){const t=N.default.flatten(e),n=(s=t,o=N.default.isEqual,N.default.reduce(s,((e,t)=>N.default.find(e,o.bind(null,t))?e:e.concat([t])),[]));var s,o;return N.default.sortBy(n,(e=>N.default.keys(Pr).indexOf(e.name)))},Rr=(e,t)=>{if("string"!=typeof e||!e.endsWith("%"))return e;const n=parseFloat(e.slice(0,-1));return isNaN(n)?e:t?n/100:n};var Fr={name:"numeric-input",displayName:"Number text box",defaultAlignment:"inline-block",accessible:!0,widget:Ar,transform:function(e){return N.default.extend(N.default.omit(e,"answers"),{answerForms:Nr(N.default.map(e.answers,(e=>N.default.map(e.answerForms,(t=>({simplify:e.simplify,name:t}))))))})},isLintable:!0};const Dr={getUserInput:function(){return N.default.omit(this.props,cr)},getUserInputFromProps:function(e){return N.default.omit(e,cr)}};class Or extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"displayName","PassageRef"),X(this,"_isMounted",void 0),X(this,"_throttledUpdateRange",void 0),X(this,"state",{lineRange:null,content:null}),X(this,"getUserInput",(()=>Dr.getUserInput.call(this))),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"_deferredUpdateRange",(()=>{N.default.defer(this._updateRange)})),X(this,"_updateRange",(()=>{const e=this.props.findWidgets("passage "+this.props.passageNumber)[0];let t=null;e&&(t=e.getReference(this.props.referenceNumber)),this._isMounted&&(t?this.setState({lineRange:[t.startLine,t.endLine],content:t.content}):this.setState({lineRange:null,content:null}))})),X(this,"simpleValidate",(e=>Or.validate(this.getUserInput(),e)))}shouldComponentUpdate(e,t){return!N.default.isEqual(this.props,e)||!N.default.isEqual(this.state,t)}render(){const e=this.state.lineRange;let t,n;if(t=e?e[0]===e[1]?I.$_("line %(lineNumber)s",{lineNumber:e[0]}):I.$_("lines %(lineRange)s",{lineRange:e[0]+"–"+e[1]}):I.$_("lines %(lineRange)s",{lineRange:"?".concat("–","?")}),this.props.summaryText){const e=Ke.parseInline(this.props.summaryText);n=A.createElement("span",{"aria-hidden":!0}," ","(“",Ke.basicOutput(e),"”)")}else n=null;return A.createElement("span",null,t,n,e&&A.createElement("div",{className:"perseus-sr-only"},this.state.content))}componentDidMount(){this._isMounted=!0,this._deferredUpdateRange(),this._throttledUpdateRange=N.default.throttle(this._deferredUpdateRange,500),window.addEventListener("resize",this._throttledUpdateRange)}componentDidUpdate(){this._deferredUpdateRange()}componentWillUnmount(){window.removeEventListener("resize",this._throttledUpdateRange),this._isMounted=!1}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}X(Or,"defaultProps",{passageNumber:1,referenceNumber:1,summaryText:""});var Lr={name:"passage-ref",displayName:"PassageRef (SAT only)",defaultAlignment:"inline",widget:Or,transform:e=>({passageNumber:e.passageNumber,referenceNumber:e.referenceNumber,summaryText:e.summaryText}),version:{major:0,minor:1}};const{pureXsMax:Br,pureSmMin:zr,pureSmMax:qr,pureMdMin:Hr,pureMdMax:Wr,pureLgMin:Ur,pureLgMax:Gr,pureXlMin:Vr}=se;var jr={xs:"@media screen and (max-width: ".concat(Br,")"),sm:"@media screen and (min-width: ".concat(zr,") and ")+"(max-width: ".concat(qr,")"),md:"@media screen and (min-width: ".concat(Hr,") and ")+"(max-width: ".concat(Wr,")"),lg:"@media screen and (min-width: ".concat(Ur,") and ")+"(max-width: ".concat(Gr,")"),xl:"@media screen and (min-width: ".concat(Vr,")"),xsOrSmaller:"@media screen and (max-width: ".concat(Br,")"),smOrSmaller:"@media screen and (max-width: ".concat(qr,")"),mdOrSmaller:"@media screen and (max-width: ".concat(Wr,")"),lgOrSmaller:"@media screen and (max-width: ".concat(Gr,")"),smOrLarger:"@media screen and (min-width: ".concat(zr,")"),mdOrLarger:"@media screen and (min-width: ".concat(Hr,")"),lgOrLarger:"@media screen and (min-width: ".concat(Ur,")"),xlOrLarger:"@media screen and (min-width: ".concat(Vr,")")};const{zIndexAboveScratchpad:Yr,zIndexInteractiveComponent:Xr,radioBorderColor:$r,checkedColor:Kr,circleSize:Zr,radioMarginWidth:Jr}=se;var Qr=l.StyleSheet.create({perseusInteractive:{zIndex:Xr,position:"relative"},aboveScratchpad:{position:"relative",zIndex:Yr},blankBackground:{backgroundColor:"#FDFDFD"},perseusSrOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1},responsiveLabel:{[jr.smOrSmaller]:{fontSize:14,lineHeight:1.3},[jr.md]:{fontSize:17,lineHeight:1.4},[jr.lgOrLarger]:{fontSize:20,lineHeight:1.4}},responsiveInput:{display:"inline-block",WebkitAppearance:"none",appearance:"none","::-ms-check":{display:"none"},backgroundColor:"#fff",border:"2px solid #fff",boxShadow:"0 0px 0px 1px ".concat($r),outline:"none",boxSizing:"border-box",flexShrink:0,marginBottom:1,marginLeft:1,marginRight:1,marginTop:1,height:Zr-2,width:Zr-2},responsiveRadioInput:{borderRadius:"50%",":checked":{backgroundColor:Kr,border:"none",borderRadius:"50%",boxShadow:"inset 0px 0px 0px 2px white, "+"0 0px 0px 2px ".concat(Kr),marginTop:Jr,marginBottom:Jr,marginLeft:Jr,marginRight:Jr,height:Zr-2*Jr,width:Zr-2*Jr}},responsiveRadioInputActive:{backgroundColor:"#fff",border:"2px solid #fff",borderRadius:"50%",boxShadow:"0 0px 0px 2px ".concat(Kr),marginTop:Jr,marginBottom:Jr,marginLeft:Jr,marginRight:Jr,height:Zr-2*Jr,width:Zr-2*Jr,":checked":{backgroundColor:"#fff"}},disableTextSelection:{userSelect:"none"}});"undefined"==typeof HTMLElement||HTMLElement.prototype.scrollTo||(HTMLElement.prototype.scrollTo=function(e,t){this.scrollLeft=e,this.scrollTop=t});const ea=(e,t)=>{"function"==typeof e.scrollTo?e.scrollTo(0,t):"scrollTop"in e&&(e.scrollTop=t)},ta=e=>e===document.body||null==e?window:e.scrollHeight>e.clientHeight?e:ta(e.parentElement),na=(e,t)=>{setTimeout((()=>{const n=ta(e),s=e.getBoundingClientRect(),o=n===window?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect();let i=0;const r=n===window?window.scrollY:n.scrollTop;if(s.bottom>o.bottom){let e=s.bottom-o.bottom;s.top+e<o.top&&(e=s.top-o.top),i=r+e}else if(s.top<o.top){i=r+(s.top-o.top)}!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3?arguments[3]:void 0;const o=e===window?window.pageYOffset:e.scrollTop,i=t,r=i-o,a=17,l=n/a;let c=0;const p=setInterval((function(){if(c<l){const t=c/l,n=(1-Math.cos(Math.PI*t))/2;ea(e,o+r*n),c+=1}else ea(e,i),clearInterval(p),s&&s()}),a)}(n,i,750,t)}),0)};class sa extends A.Component{render(){const e={borderColor:this.props.visible?this.props.color:"transparent"};return A.createElement("span",{className:l.css(oa.ring),style:e},this.props.children)}}X(sa,"defaultProps",{visible:!0,color:"#71B307"});const oa=l.StyleSheet.create({ring:{margin:"auto",display:"inline-block",borderRadius:"50%",borderWidth:2,padding:2,borderStyle:"solid"}});function ia(e){const t=I._("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z").split(" ");return e<t.length?t[e]:" "}class ra extends A.Component{constructStyles(e,t,n){let s,o="#0084CE",i="#0084CE";return e?t?(o="#009900",i=n?J:"#009900",s=n?"#009900":J):n&&(o="#990000",i=J,s="#990000"):n&&(i=J,s="#0084CE"),{color:i,backgroundColor:s,borderColor:o}}render(){const{letter:e,a11yText:t,reviewMode:n,checked:s,correct:o,crossedOut:i}=this.props,{color:r,backgroundColor:a,borderColor:c}=this.constructStyles(n,o,s);return A.createElement("div",{className:l.css(pa.iconWrapper)},A.createElement("div",{className:l.css(pa.satCircle),style:{backgroundColor:a,borderColor:c}}),A.createElement("div",{style:{color:r},className:l.css(pa.letter)},A.createElement("span",{className:"perseus-sr-only"},t),A.createElement("span",{"aria-hidden":"true"},e)),i&&A.createElement(la,{color:c,sat:!0}))}}class aa extends A.Component{getChoiceInner(){const{letter:e,showCorrectness:t,correct:n}=this.props;return t?n?A.createElement(K,$({},fs,{style:{position:"relative",top:-1}})):A.createElement(K,Ps):e}getDynamicStyles(){const{checked:e,showCorrectness:t,pressed:n,primaryProductColor:s,correct:o,transparentBackground:i}=this.props;if(!t&&n)return{borderColor:s,color:s,backgroundColor:i?"transparent":J};if(e){const e=t&&o?"#71B307":s;return{color:J,backgroundColor:e,borderColor:e}}return{borderColor:ee,color:ee}}render(){const{a11yText:e,checked:t,crossedOut:n,showCorrectness:s,correct:o,focused:i,primaryProductColor:r,previouslyAnswered:a}=this.props,c=this.getDynamicStyles();return A.createElement("div",{className:l.css(pa.iconWrapper)},A.createElement(sa,{color:r,visible:i},A.createElement("div",{style:c,className:l.css(pa.libraryCircle,s&&o&&pa.libraryCircleCorrect,s&&!o&&pa.libraryCircleIncorrect,s&&!o&&(t||a)&&pa.libraryCircleIncorrectAnswered),"data-is-radio-icon":!0},A.createElement("div",{className:"perseus-sr-only"},e),A.createElement("div",{"aria-hidden":!0},this.getChoiceInner()))),n&&A.createElement(la,{color:c.borderColor}))}}function la(e){const t=e.sat?29:28;return A.createElement("svg",{width:t,height:t,viewBox:"0 0 ".concat(t," ").concat(t),className:l.css(pa.crossOutLine)},A.createElement("line",{x1:2,x2:t-2,y1:t-2,y2:2,stroke:e.color,strokeWidth:"2",strokeLinecap:"round"}))}class ca extends A.Component{a11yText(e){const{checked:t,correct:n,crossedOut:s,showCorrectness:o}=this.props;return o&&n?t?I._("(Choice %(letter)s, Checked, Correct)",{letter:e}):s?I._("(Choice %(letter)s, Crossed out, Correct)",{letter:e}):I._("(Choice %(letter)s, Correct)",{letter:e}):o&&!n?t?I._("(Choice %(letter)s, Checked, Incorrect)",{letter:e}):s?I._("(Choice %(letter)s, Crossed out, Incorrect)",{letter:e}):I._("(Choice %(letter)s, Incorrect)",{letter:e}):t?I._("(Choice %(letter)s, Checked)",{letter:e}):s?I._("(Choice %(letter)s, Crossed out)",{letter:e}):I._("(Choice %(letter)s)",{letter:e})}render(){const{pos:e,reviewMode:t,checked:n,crossedOut:s,correct:o,product:i,showCorrectness:r,pressed:a,focused:l,primaryProductColor:c,previouslyAnswered:p,transparentBackground:d}=this.props,h=ia(e);return"sat"===i?A.createElement(ra,{letter:h,a11yText:this.a11yText(h),reviewMode:t,checked:n,correct:o,crossedOut:s}):A.createElement(aa,{letter:h,a11yText:this.a11yText(h),reviewMode:t,checked:n,crossedOut:s,pressed:a,focused:l,correct:o,showCorrectness:r,primaryProductColor:c,previouslyAnswered:p,transparentBackground:d})}}X(ca,"defaultProps",{primaryProductColor:"#71B307"});const pa=l.StyleSheet.create({satCircle:{display:"block",borderRadius:25,borderStyle:"solid",borderWidth:2,content:"''",height:25,width:25,top:1,left:1},iconWrapper:{display:"inline-block",position:"relative"},crossOutLine:{position:"absolute",top:"calc(50% - ".concat(14,"px)"),left:"calc(50% - ".concat(14,"px)")},libraryCircle:{width:24,height:24,boxSizing:"border-box",borderRadius:24,borderStyle:"solid",borderWidth:2,fontFamily:"'Proxima Nova',sans-serif",fontWeight:"bold",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1px"},libraryCircleCorrect:{fontSize:24},libraryCircleIncorrect:{fontSize:24,borderColor:ee,color:ee},libraryCircleIncorrectAnswered:{backgroundColor:"#F86700",borderColor:"#F86700",color:J},letter:{border:"2px solid transparent",width:25,height:25,position:"absolute",top:1,display:"flex",alignItems:"center",justifyContent:"center",fontFamily:Z,fontSize:13}});class da extends A.Component{render(){const{color:e,pathClassName:t,className:n,title:s,style:o,alt:i}=this.props;let{icon:r,size:a}=this.props,l="";"string"==typeof r&&(r={path:r,width:10,height:10}),"number"!=typeof a&&(a=1,l="em");const c=a,p=c/r.height*r.width,d=!!this.props.focusable;return A.createElement("svg",{role:"img",alt:i,"aria-label":s,"aria-hidden":!s||null,className:n,style:o,focusable:d.toString(),width:p+l,height:c+l,viewBox:"".concat(0," ").concat(0," ").concat(r.width," ").concat(r.height)},!!s&&A.createElement("title",null,s),A.createElement("path",{className:t,fill:e,d:r.path}))}}X(da,"defaultProps",{color:"currentColor"});var ha=Object.freeze({__proto__:null,black:"#000000",grayDarker:"#333333",grayDark:"#555555",gray:"#999999",grayLight:"#AAAAAA",grayLighter:"#DDDDDD",white:"#FFFFFF",blue:"#005A88",blueDark:"#2C3747",green:"#76A005",red:"#CF5044",yellow:"#FFC40D",orange:"#BF4F04",pink:"#C3325F",purple:"#7A43B6",bodyBackground:"#FFFFFF",textColor:"#444444",linkColor:"#005987",linkColorHover:"#678D00",sansFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",serifFontFamily:"Georgia,'Times New Roman',Times,serif",monoFontFamily:"Monaco,Menlo,Consolas,'Courier New',monospace",baseFontSize:"14px",baseFontFamily:"inherit",baseLineHeight:"20px",altFontFamily:"Georgia,'Times New Roman',Times,serif",headingsFontFamily:"inherit",headingsFontWeight:"bold",headingsColor:"inherit",fontSizeLarge:"18px",fontSizeSmall:"12px",fontSizeMini:"10.5px",paddingLarge:"11px 19px",paddingSmall:"2px 10px",paddingMini:"0 6px",baseBorderRadius:"4px",borderRadiusLarge:"6px",borderRadiusSmall:"3px",tableBackground:"#000000",tableBackgroundAccent:"#F9F9F9",tableBackgroundHover:"#F5F5F5",tableBorder:"#DDDDDD",btnBackground:"#FFFFFF",btnBackgroundHighlight:"rgb(230, 230, 230)",btnBorder:"#CCCCCC",btnPrimaryBackground:"#0088CC",btnPrimaryBackgroundHighlight:"rgb(0, 68, 204)",btnInfoBackground:"#5BC0DE",btnInfoBackgroundHighlight:"#2F96B4",btnSuccessBackground:"#62C462",btnSuccessBackgroundHighlight:"#51A351",btnWarningBackground:"rgb(251, 180, 81)",btnWarningBackgroundHighlight:"#F89406",btnDangerBackground:"#EE5F5B",btnDangerBackgroundHighlight:"#BD362F",btnInverseBackground:"#444444",btnInverseBackgroundHighlight:"#222222",inputBackground:"#FFFFFF",inputBorder:"#CCCCCC",inputBorderRadius:"4px",inputDisabledBackground:"#EEEEEE",formActionsBackground:"#F5F5F5",inputHeight:"30px",dropdownBackground:"#FFFFFF",dropdownBorder:"rgba(0, 0, 0, 0.2)",dropdownDividerTop:"#E5E5E5",dropdownDividerBottom:"#FFFFFF",dropdownLinkColor:"#333333",dropdownLinkColorHover:"#FFFFFF",dropdownLinkColorActive:"#FFFFFF",dropdownLinkBackgroundActive:"#0088CC",dropdownLinkBackgroundHover:"#0088CC",zindexDropdown:1e3,zindexPopover:1010,zindexTooltip:1030,zindexFixedNavbar:1030,zindexHeader:1060,zindexModalBackdrop:1070,zindexModal:1080,zindexAboveModal:1090,iconSpritePath:"../img/glyphicons-halflings.png",iconWhiteSpritePath:"../img/glyphicons-halflings-white.png",placeholderText:"#999999",hrBorder:"#EEEEEE",horizontalComponentOffset:"180px",wellBackground:"#F5F5F5",navbarCollapseWidth:"979px",navbarCollapseDesktopWidth:"980px",navbarHeight:"40px",navbarBackgroundHighlight:"#FFFFFF",navbarBackground:"rgb(242, 242, 242)",navbarBorder:"rgb(212, 212, 212)",navbarText:"#777777",navbarLinkColor:"#777777",navbarLinkColorHover:"#333333",navbarLinkColorActive:"#555555",navbarLinkBackgroundHover:"#000000",navbarLinkBackgroundActive:"rgb(230, 230, 230)",navbarBrandColor:"#777777",navbarInverseBackground:"#111111",navbarInverseBackgroundHighlight:"#222222",navbarInverseBorder:"#252525",navbarInverseText:"#999999",navbarInverseLinkColor:"#999999",navbarInverseLinkColorHover:"#FFFFFF",navbarInverseLinkColorActive:"#FFFFFF",navbarInverseLinkBackgroundHover:"#000000",navbarInverseLinkBackgroundActive:"#111111",navbarInverseSearchBackground:"rgb(82, 82, 82)",navbarInverseSearchBackgroundFocus:"#FFFFFF",navbarInverseSearchBorder:"#111111",navbarInverseSearchPlaceholderColor:"#CCCCCC",navbarInverseBrandColor:"#999999",paginationBackground:"#FFFFFF",paginationBorder:"#DDDDDD",paginationActiveBackground:"#F5F5F5",heroUnitBackground:"#EEEEEE",heroUnitHeadingColor:"inherit",heroUnitLeadColor:"inherit",warningText:"#C09853",warningBackground:"#FCF8E3",warningBorder:"rgb(251, 239, 213)",errorText:"#B94A48",errorBackground:"#F2DEDE",errorBorder:"rgb(238, 211, 215)",successText:"#468847",successBackground:"#DFF0D8",successBorder:"rgb(212, 232, 197)",infoText:"#4A7C17",infoBackground:"#EDF2DF",infoBorder:"rgb(228, 232, 197)",tooltipColor:"#FFFFFF",tooltipBackground:"#000000",tooltipArrowWidth:"5px",tooltipArrowColor:"#000000",popoverBackground:"#FFFFFF",popoverArrowWidth:"10px",popoverArrowColor:"#FFFFFF",popoverTitleBackground:"rgb(247, 247, 247)",popoverArrowOuterWidth:"11px",popoverArrowOuterColor:"rgba(0, 0, 0, 0.25)",gridColumns:"12",gridColumnWidth:"60px",gridGutterWidth:"20px",gridRowWidth:"940px",gridColumnWidth1200:"70px",gridGutterWidth1200:"30px",gridRowWidth1200:"1170px",gridColumnWidth768:"42px",gridGutterWidth768:"20px",gridRowWidth768:"724px",fluidGridColumnWidth:"6.382978723404255%",fluidGridGutterWidth:"2.127659574468085%",fluidGridColumnWidth1200:"5.982905982905983%",fluidGridGutterWidth1200:"2.564102564102564%",fluidGridColumnWidth768:"5.801104972375691%",fluidGridGutterWidth768:"2.7624309392265194%",kaGreen:"#71B307",kaGreenLight:"#BED47A",kaBlue:"#314453",kaBlueLight:"#4D6779",grayExtraDark:"#111111",grayExtraLight:"#EEEEEE",graySuperLight:"#F7F7F7",whiteDark:"#FDFDFD",dark:"#21242C",blueDarkUnsaturated:"#3B414E",blueDarkSaturated:"#1F3043",blueLight:"#A9C0D1",greenLight:"#C6D1AD",greenDark:"#356700",yellowGreen:"#9DB63B",okGreen:"#A7CF5B",alertRed:"#C42420",coral:"#EE6666",grayBlue:"#9AB3B9",lightPageBackground:"#FDFDFD",yclaBlue:"#49BAD5",yclaTeal:"#56D0B3",yclaTealDark:"#50C1A7",yclaGreenDark:"#3D9A82",yclaGreen:"#81C262",learnstormBlue:"#4898FC",homepageBlue:"#46A8BF",backgroundBlue:"#00294A",teacherSignupBlue:"#335d7d",homepageGreen:"#2B8E7B",streakColor:"#F79734",facebookColor:"#1A60A2",blueGoogleColor:"#2CAFE2",redGoogleColor:"#BF4434",homepageColor:"#2D585E",lightTextColor:"#898989",fontSizeTiny:"11px",fontSizeNormal:"14px",fontSizeMedium:"16px",fontSizeExtraLarge:"24px",fontSizeHuge:"36px",fontSizeBakana:"48px",fontSizeBananas:"60px",fixedWidthFontFamily:"'Helvetica Neue',Helvetica,Arial,sans-serif",contentPadding:"20px",primaryButtonBackground:"#89B908",primaryButtonBorder:"#76A005",buttonTextColor:"rgb(122, 122, 122)",buttonBorderRadius:"3px",basicBorderColor:"#CCCCCC",minContainerWidth:"1000px",maxContainerWidth:"1200px",formHintColor:"#999999",guidelineExampleText:"#606060",hoverCardWidth:"450px",menuHighlightColor:"#96AB4F",menuHighlightBorderColor:"#76A005",menuActiveTextColor:"#FFFFFF",menuInactiveTextColor:"#444444",menuSubheaderTextColor:"rgb(120, 120, 120)",menuBorderColor:"#94A170",unreadBackgroundColor:"#ECEEF4",menuLineHeight:"18px",menuSubheaderLineHeight:"17px",menuSubheaderFontSize:"9px",notificationBarColor:"#4858A4",modalBodyTopPadding:"20px",modalDialogPadding:"15px",modalSectionPadding:"9px",mathDomain1:"#11ACCD",mathDomain2:"#63D9EA",mathDomain3:"#027d97",mathDomain4:"#085566",partnerContentDomain1:"#01A995",partnerContentDomain2:"#01D1C1",partnerContentDomain3:"#208170",partnerContentDomain4:"#144F44",csDomain1:"#1FAB54",csDomain2:"#74CF70",csDomain3:"#0D923F",csDomain4:"#085E29",economicsDomain1:"#E07D10",economicsDomain2:"#FFBE26",economicsDomain3:"#A75A05",economicsDomain4:"#953C02",collegeCareersMoreDomain1:"#01A995",collegeCareersMoreDomain2:"#01D1C1",collegeCareersMoreDomain3:"#208170",collegeCareersMoreDomain4:"#144F44",humanitiesDomain1:"#E84D39",humanitiesDomain2:"#FF8482",humanitiesDomain3:"#BE2612",humanitiesDomain4:"#8C1C0D",gtpDomain1:"#1865F2",gtpDomain2:"#1865F2",gtpDomain3:"#1865F2",gtpDomain4:"#1865F2",scienceDomain1:"#CA337C",scienceDomain2:"#FF92C6",scienceDomain3:"#9E034E",scienceDomain4:"#6B0235",testPrepDomain1:"#1865F2",testPrepDomain2:"#1865F2",testPrepDomain3:"#1865F2",testPrepDomain4:"#1865F2",defaultDomain1:"#1865F2",defaultDomain2:"#66afe9",defaultDomain3:"#1152b0",defaultDomain4:"#0d3d82",defaultDomainColor:"#314453",defaultSubjectColor:"#4D6779",defaultTopicColor:"#6A8DA6",defaultHoverColor:"#314453",defaultLinkColor:"#314453",defaultLinkHoverColor:"#6A8DA6",scienceDomainColor:"#94424F",scienceSubjectColor:"#9D4A5A",scienceTopicColor:"#C55F73",scienceHoverColor:"#94424F",scienceLinkColor:"#94424F",scienceLinkHoverColor:"#C55F73",humanitiesDomainColor:"#AD3434",humanitiesSubjectColor:"#C13B31",humanitiesTopicColor:"#D24A45",humanitiesHoverColor:"#AD3434",humanitiesLinkColor:"#AD3434",humanitiesLinkHoverColor:"#D24A45",economicsDomainColor:"#B77033",economicsSubjectColor:"#BF7B34",economicsTopicColor:"#D1933B",economicsHoverColor:"#B77033",economicsLinkColor:"#B77033",economicsLinkHoverColor:"#D1933B",csDomainColor:"#437A39",csSubjectColor:"#53893E",csTopicColor:"#689B51",csHoverColor:"#437A39",csLinkColor:"#437A39",csLinkHoverColor:"#689B51",partnerContentDomainColor:"#218270",partnerContentSubjectColor:"#2C8D7B",partnerContentTopicColor:"#329A86",partnerContentHoverColor:"#218270",partnerContentLinkColor:"#218270",partnerContentLinkHoverColor:"#329A86",essayDomainColor:"#0071B3",mathDomainColor:"#1C758A",mathSubjectColor:"#46A8BF",mathTopicColor:"#4FBAD4",mathHoverColor:"#1C758A",mathLinkColor:"#1C758A",mathLinkHoverColor:"#4FBAD4",testPrepDomainColor:"#644172",testPrepSubjectColor:"#7E5F8E",testPrepTopicColor:"#9A72AC",testPrepHoverColor:"#644172",testPrepLinkColor:"#644172",testPrepLinkHoverColor:"#9A72AC",collegeCareersMoreDomainColor:"#218270",collegeCareersMoreSubjectColor:"#2C8D7B",collegeCareersMoreTopicColor:"#329A86",collegeCareersMoreHoverColor:"#218270",collegeCareersMoreLinkColor:"#218270",collegeCareersMoreLinkHoverColor:"#329A86",satDomainColor:"#0084CE",satSubjectColor:"#0084CE",satTopicColor:"#0084CE",satHoverColor:"#0084CE",satLinkColor:"#0084CE",satLinkHoverColor:"#0084CE",colorProficient:"#1C758A",colorPracticed:"rgb(158, 221, 235)",colorMastery1:"rgb(90, 197, 221)",colorMastery2:"rgb(42, 174, 203)",colorMastery3:"#1C758A",colorSuggested:"#73982C",colorReview:"#E35D04",colorNotStarted:"#CCCCCC",colorStarted:"#C7E5F7",colorStruggling:"#C30202",colorPersonal:"#00809C",colorPractice:"#96D9FF",colorEnergyPoints:"#005987",pureSmMin:"568px",pureMdMin:"768px",pureLgMin:"1024px",pureXlMin:"1200px",pureXsMax:"567px",pureSmMax:"767px",pureMdMax:"1023px",pureLgMax:"1199px"});const ua={white:"#FFFFFF",gray98:"#FAFAFA",gray97:"#F6F7F7",gray95:"#F0F1F2",gray90:"#E3E5E6",gray85:"#D6D8DA",gray76:"#BABEC2",gray72:"#999A9D",gray68:"#888D93",gray55:"#707378",gray41:"#626569",gray25:"#3B3E40",gray17:"#21242C",gray10:"#1499af",black:"#000000",alertRed:"#C42420",homepageBlue:"#46A8BF",kaBlue:"#314453",kaBlueLight:"#4D6779",kaGreen:"#71B307",kaGreenLight:"#BED47A",learnstormBlue:"#4898FC",backgroundBlue:"#00294A",adminGreen:"#78C008",kaBlueExtraLight:"#39c2db",kaBlueHover:"#0c7f99",kaGreenHover:"#518005",skyDark:"#001f4d",recommendationGold:"#ffbe26",starAced:"#ff9c39",google:"#C1432f",modernGoogle:"#be2612",modernGoogleHover:"#8c1c0d",facebook:"#4267B2",modernFacebook:"#4267B2",modernFacebookHover:"#00294a",wonderBlocksGold:"#FFB100",wonderBlocksLightBlue:"#37C5FD",breadcrumbs:"rgba(255, 255, 255, 0.7)"},fa={color:ua.breadcrumbs,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase",MozOsxFontSmoothing:"grayscale",WebkitFontSmoothing:"antialiased"},ma={regular:"inherit"},ga={subjectHeadingDesktop:{fontFamily:"inherit",fontSize:50,fontWeight:"bold",lineHeight:"61px"},subjectHeadingMobile:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingDesktop:{fontFamily:"inherit",fontSize:35,fontWeight:"bold",lineHeight:"37px"},conceptHeadingMobile:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingDesktop:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},subheadingMobile:{fontFamily:"inherit",fontSize:20,fontWeight:"bold",lineHeight:"24px"},smallSubheadingDesktop:{fontFamily:"inherit",fontSize:20,lineHeight:1.25},smallSubheadingMobile:{fontFamily:"inherit",fontSize:15,lineHeight:1.25},smallHeading:{color:ua.gray25,fontFamily:"inherit",fontSize:17,fontWeight:"bold",lineHeight:"23px"},smallHeadingMobile:{color:ua.gray25,fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},accentHeading:{color:ua.gray68,fontFamily:"inherit",fontSize:15,fontWeight:"bold",letterSpacing:.8,lineHeight:"19px",textTransform:"uppercase"},bodyLarge:{fontFamily:ma.regular,fontSize:20,lineHeight:"30px"},bodySmall:{fontFamily:ma.regular,fontSize:17,fontWeight:"normal",lineHeight:"23px"},bodySmallBold:{fontFamily:ma.regular,fontSize:17,fontWeight:"bold",lineHeight:"23px"},bodyXsmall:{fontFamily:ma.regular,fontSize:15,lineHeight:"22px"},bodyXsmallBold:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"22px"},breadcrumb:fa,breadcrumbSmall:{...fa,fontSize:12,lineHeight:"13px"},labelLarge:{fontFamily:"inherit",fontSize:23,fontWeight:"bold",lineHeight:"27px"},labelMedium:{fontFamily:"inherit",fontSize:15,fontWeight:"bold",lineHeight:"18px"},labelSmall:{fontFamily:ma.regular,fontSize:12,lineHeight:"14px"},caption:{fontFamily:ma.regular,fontSize:14,fontStyle:"italic",lineHeight:"17px"},desktopScalingOnMobile:{MozTextSizeAdjust:"100%",MsTextSizeAdjust:"100%",WebkitTextSizeAdjust:"100%"},modalSubtitle:{fontSize:12,lineHeight:1.65,WebkitFontSmoothing:"antialiased",fontWeight:"bold"},wonderBlocksHeader:{paddingLeft:16,paddingRight:16,paddingBottom:24,paddingTop:34,[jr.mdOrLarger]:{paddingBottom:32}},wonderBlocksTitle:{color:ua.white,fontWeight:900,fontSize:28,lineHeight:"32px",margin:0,[jr.mdOrLarger]:{fontSize:36,lineHeight:"40px"}},wonderBlocksLabelLarge:{fontSize:16,lineHeight:"20px",fontWeight:700}};var va=Object.freeze({__proto__:null,colors:ua,borderRadius:4,fonts:ma,typography:ga});class ba extends A.PureComponent{constructor(){super(...arguments),X(this,"_handleTooltipButtonRef",(e=>{e&&this.props.usingKeyboardFocus&&e.focus()}))}_getAriaLabel(){const{crossedOut:e,pos:t}=this.props,n=ia(t);return e?I._("Bring back Choice %(letter)s",{letter:n}):I._("Cross out Choice %(letter)s",{letter:n})}render(){const{crossedOut:e,pos:t,primaryProductColor:n,theme:s}=this.props,o="day"===s?n:q.default.white;return A.createElement("button",{type:"button","aria-label":this._getAriaLabel(),className:l.css([ya.tooltipButton]),onClick:()=>this.props.onClick(),onMouseDown:e=>e.preventDefault(),onFocus:()=>this.props.onFocus(),onBlur:()=>this.props.onBlur(),disabled:this.props.disabled,tabIndex:this.props.tabFocusable?0:-1,ref:this._handleTooltipButtonRef},A.createElement(ca,{pos:t,product:"library",crossedOut:!this.props.crossedOut,primaryProductColor:o,pressed:!0,checked:!1,focused:!1,correct:!1,showCorrectness:!1,reviewMode:!1,previouslyAnswered:!1,transparentBackground:!0}),A.createElement(m.LabelLarge,{style:{color:o}},e?I._("Bring back"):I._("Cross out")))}}X(ba,"defaultProps",{primaryProductColor:ua.kaGreen});const ya=l.StyleSheet.create({tooltipButton:{background:"none",border:"none",font:"inherit",padding:0,cursor:"pointer",textDecoration:"none",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"}});class xa{constructor(e,t,n){X(this,"_intersectionObserver",void 0),X(this,"_onVisibilityChange",void 0),X(this,"_handleIntersection",(e=>{for(const t of e)this._onVisibilityChange(t.isIntersecting,t.rootBounds)})),this._intersectionObserver=new IntersectionObserver(this._handleIntersection,{root:e,threshold:Number.EPSILON,rootMargin:n}),this._onVisibilityChange=t}setTargetElement(e){this._intersectionObserver.disconnect(),this._intersectionObserver.observe(e)}disconnect(){this._intersectionObserver.disconnect()}}class Ca extends A.PureComponent{render(){const{direction:e,pxFromStart:t,pxFromEnd:n}=this.props,s=[wa.wrapper,"horizontal"===e&&wa.wrapperHorizontal,"vertical"===e&&wa.wrapperVertical],o=[wa.content,"horizontal"===e&&wa.contentHorizontal,"vertical"===e&&wa.contentVertical];return 0===t?A.createElement("div",{className:l.css(...s)},A.createElement("div",{className:l.css(...o)},this.props.children)):0===n?A.createElement("div",{className:l.css(...s,wa.wrapperAlignToEnd)},A.createElement("div",{className:l.css(...o)},this.props.children)):A.createElement("div",{className:l.css(...s)},A.createElement("div",{style:{flexShrink:n,flexBasis:t}}),A.createElement("div",{className:l.css(...o)},this.props.children),A.createElement("div",{style:{flexShrink:t,flexBasis:n}}))}}const wa=l.StyleSheet.create({wrapper:{display:"flex",overflow:"hidden"},wrapperHorizontal:{flexDirection:"row",width:"100%"},wrapperVertical:{flexDirection:"column",height:"100%"},wrapperAlignToEnd:{justifyContent:"flex-end"},content:{flex:"0 0 auto"},contentHorizontal:{maxWidth:"100%"},contentVertical:{maxHeight:"100%"}}),ka=parseInt("6px");function Sa(e){const{color:t,inverted:n}=e;return n?{backgroundColor:t,textColor:q.default.white}:{backgroundColor:q.default.white,textColor:t}}class Ea extends A.PureComponent{render(){const{onClick:e,onMouseEnter:t,onMouseLeave:n,side:s}=this.props.tooltipProps,{backgroundColor:o}=Sa(this.props.tooltipProps);let i,r,a;if("top"===s)i=["0,0","".concat(9,",").concat(9),"".concat(18,",0")],r=18,a=9;else if("right"===s)i=["".concat(9,",0"),"0,".concat(9),"".concat(9,",").concat(18)],r=9,a=18;else if("bottom"===s)i=["0,".concat(9),"".concat(9,",0"),"".concat(18,",").concat(9)],r=18,a=9;else{if("left"!==s)throw new he("unexpected side ".concat(s),pe.InvalidInput);i=["0,0","".concat(9,",").concat(9),"0,".concat(18)],r=9,a=18}return A.createElement("svg",{width:r,height:a,className:l.css(_a.tooltipArrow)},A.createElement("filter",{id:"tooltip-dropshadow-".concat(s),height:"150%"},A.createElement("feOffset",{dx:0,dy:1,result:"offsetblur"}),A.createElement("feGaussianBlur",{in:"SourceAlpha",stdDeviation:2}),A.createElement("feComponentTransfer",null,A.createElement("feFuncA",{type:"linear",slope:.1})),A.createElement("feMerge",null,A.createElement("feMergeNode",null),A.createElement("feMergeNode",{in:"SourceGraphic"}))),A.createElement("polyline",{fill:o,stroke:o,points:i.join(" "),className:l.css(e&&_a.tooltipArrowShapeWithOnClick),onClick:e,onMouseEnter:t,onMouseLeave:n}),A.createElement("polyline",{fill:o,points:i.join(" "),stroke:"rgba(0, 0, 0, 0.1)",filter:"url(#tooltip-dropshadow-".concat(s,")")}))}}const _a=l.StyleSheet.create({tooltipArrow:{display:"block",userSelect:"none"},tooltipArrowShapeWithOnClick:{pointerEvents:"auto",cursor:"pointer"}});var Ma=l.StyleSheet.create({srOnly:{border:0,clip:"rect(0,0,0,0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",width:1}});class Ta extends A.PureComponent{constructor(){super(...arguments),X(this,"_handleClickClose",(()=>this.props.dismiss()))}_renderCloseButton(e){const{inverted:t,dismissOnClickClose:n}=this.props.tooltipProps;if(!n)return null;const s=e.get("button-description"),o=this.getA11yHeaderId(e);return A.createElement("button",{className:l.css(Ia.closeIcon),onClick:this._handleClickClose,"aria-describedby":"".concat(s," ").concat(o)},A.createElement(da,{title:I._("Close"),icon:"M6.26353762,4.99851587 L9.73097464,1.53107884 C10.0836373,1.17841618 10.0842213,0.612127047 9.73530496,0.263210718 C9.38395604,-0.0881381913 8.81874474,-0.0837668714 8.46743686,0.267541014 L4.99999981,3.73497806 L1.5325628,0.267541051 C1.1812549,-0.0837668481 0.616043606, -0.0881381955 0.264694717,0.263210694 C-0.0842215912,0.612127004 -0.0836375768,1.17841613 0.269025093,1.5310788 L3.73646206,4.9985158 L0.269025109,8.46595276 C-0.083637537,8.81861541 -0.0842215923, 9.38490462 0.264694642,9.73382106 C0.616043456,10.0851701 1.18125469, 10.0807988 1.53256259,9.72949093 L4.99999988,6.26205363 L8.46743739, 9.72949117 C8.8187453,10.0807991 9.38395655,10.0851704 9.73530537, 9.73382138 C10.0842216,9.38490498 10.0836375,8.81861579 9.73097488, 8.46595313 L6.26353762,4.99851587 Z",size:10,color:t?"rgba(255, 255, 255, 0.7)":"rgba(0, 0, 0, 0.15)"}),A.createElement("div",{id:s,className:l.css(Ma.srOnly)},I._("Closes the tooltip: ")))}getA11yHeaderId(e){const{tooltipProps:{a11y:t}}=this.props;return t&&t.title?"string"==typeof t.title?e.get("header"):t.title.id:this.getA11yContentId(e)}getA11yContentId(e){return e.get("content")}renderTooltip(e){const{content:t,dismissOnClickClose:n,noPadding:s,onClick:o,onMouseEnter:i,onMouseLeave:r,a11y:a,testId:c}=this.props.tooltipProps,p=a&&a.title,d=a&&a.assertiveness,{backgroundColor:h,textColor:u}=Sa(this.props.tooltipProps),f=this.getA11yHeaderId(e),m=this.getA11yContentId(e);return A.createElement("div",{className:l.css(Ia.tooltipBubble,!s&&Ia.tooltipBubbleWithPadding,n&&Ia.tooltipBubbleWithCloseIcon,o&&Ia.tooltipBubbleWithOnClick),onClick:o,onMouseEnter:i,onMouseLeave:r,style:{backgroundColor:h,color:u},role:"region","aria-labelledby":f,"aria-describedby":m===f?null:m,"data-test-id":c},this._renderCloseButton(e),A.createElement("div",{"aria-live":d},"string"==typeof p?A.createElement("div",{className:l.css(Ma.srOnly),id:f},p):null,A.createElement("div",{id:m,className:l.css(Ia.tooltipContent)},t)))}render(){return A.createElement(g.UniqueIDProvider,{mockOnFirstRender:!1,scope:"tooltip-bubble"},(e=>this.renderTooltip(e)))}}const Ia=l.StyleSheet.create({tooltipBubble:{boxSizing:"border-box",position:"relative",...ga.labelMedium,borderRadius:ka,border:"1px solid rgba(0, 0, 0, 0.1)",boxShadow:"".concat(0,"px ").concat(1,"px ")+"".concat(4,"px 0px ")+"rgba(0, 0, 0, ".concat(.1,")"),userSelect:"none"},tooltipBubbleWithPadding:{padding:"10px 23px"},tooltipBubbleWithCloseIcon:{paddingRight:34},tooltipBubbleWithOnClick:{cursor:"pointer"},tooltipContent:{userSelect:"auto"},closeIcon:{display:"block",position:"absolute",right:10,top:10,padding:0,background:"inherit",border:"none"}});class Pa extends A.PureComponent{constructor(){super(...arguments),X(this,"_mountRemeasureTimeout",void 0),X(this,"state",{targetElementClientRect:null,rootElementClientRect:null}),X(this,"_handleScroll",(e=>{const{rootElement:t,targetElement:n}=this.props,s=e.target;t.contains(s)&&s.contains(n)&&this.remeasure()})),X(this,"remeasure",(()=>{const{targetElement:e,rootElement:t}=this.props;this.setState({targetElementClientRect:e.getBoundingClientRect(),rootElementClientRect:t.getBoundingClientRect()})}))}componentDidMount(){this._mountRemeasureTimeout=setTimeout(this.remeasure,0),window.addEventListener("resize",this.remeasure),window.addEventListener("scroll",this._handleScroll,!0)}componentWillUnmount(){this._mountRemeasureTimeout&&clearTimeout(this._mountRemeasureTimeout),window.removeEventListener("resize",this.remeasure),window.removeEventListener("scroll",this._handleScroll,!0)}_computeTargetPointOffsets(e,t){const{offset:n,offsetFrom:s,side:o}=this.props.tooltipProps,i=e,r=t;let a,l=n;if("arrow"===s&&(l+=9),"top"===o)a={left:i.left+i.width/2,top:i.top-l};else if("bottom"===o)a={left:i.left+i.width/2,top:i.bottom+l};else if("left"===o)a={left:i.left-l,top:i.top+i.height/2};else{if("right"!==o)throw new he("unexpected side ".concat(o),pe.InvalidInput);a={left:i.right+l,top:i.top+i.height/2}}return{pxFromTop:a.top-r.top,pxFromBottom:r.bottom-a.top,pxFromLeft:a.left-r.left,pxFromRight:r.right-a.left}}_renderBubble(e){const{isAboveModal:t}=this.props,{side:n,tooltipMargin:s}=this.props.tooltipProps;let o;const i={},r={},a={};if("top"===n||"bottom"===n)o=Aa.tooltipBubblePositionerTopBottom,r.direction="horizontal",r.pxFromStart=e.pxFromLeft,r.pxFromEnd=e.pxFromRight,a.marginLeft=s,a.marginRight=s;else{if("left"!==n&&"right"!==n)throw new he("unexpected side ".concat(n),pe.InvalidInput);o=Aa.tooltipBubblePositionerLeftRight,r.direction="vertical",r.pxFromStart=e.pxFromTop,r.pxFromEnd=e.pxFromBottom,a.marginTop=s,a.marginBottom=s}if("top"===n)i.bottom=e.pxFromBottom;else if("bottom"===n)i.top=e.pxFromTop;else if("left"===n)i.right=e.pxFromRight;else{if("right"!==n)throw new he("unexpected side ".concat(n),pe.InvalidInput);i.left=e.pxFromLeft}return A.createElement("div",{className:l.css(Aa.tooltipBubblePositioner,o,t&&Aa.tooltipAboveModal),style:i},A.createElement(Ca,r,A.createElement("div",{className:l.css(Aa.tooltipBubbleWrapper),style:a},A.createElement(Ta,{tooltipProps:this.props.tooltipProps,dismiss:this.props.dismiss}))))}_renderArrow(e,t){const{isAboveModal:n}=this.props,{side:s,tooltipMargin:o}=this.props.tooltipProps,i={};if("top"===s)i.bottom=e.pxFromBottom-9+1;else if("bottom"===s)i.top=e.pxFromTop-9+1;else if("left"===s)i.right=e.pxFromRight-9+1;else{if("right"!==s)throw new he("unexpected side ".concat(s),pe.InvalidInput);i.left=e.pxFromLeft-9+1}const r=o+ka;if("top"===s||"bottom"===s){const n=r,s=t.width-18-r;i.left=e.pxFromLeft-9,i.left=Math.min(i.left,s),i.left=Math.max(i.left,n)}else{if("left"!==s&&"right"!==s)throw new he("unexpected side ".concat(s),pe.InvalidInput);{const n=r,s=t.height-18-r;i.top=e.pxFromTop-9,i.top=Math.min(i.top,s),i.top=Math.max(i.top,n)}}return A.createElement("div",{className:l.css(Aa.tooltipArrowPositioner,n&&Aa.tooltipAboveModal),style:i},A.createElement(Ea,{tooltipProps:this.props.tooltipProps}))}_buildMediaFilterStyle(){const{media:e}=this.props.tooltipProps;if(!e)return null;return l.StyleSheet.create({mediaFilter:{display:"none",[e]:{display:"block"}}}).mediaFilter}render(){const{targetElementClientRect:e,rootElementClientRect:t}=this.state;if(!e||!t)return null;const n=this._computeTargetPointOffsets(e,t);return A.createElement("div",{className:l.css(this._buildMediaFilterStyle())},this._renderBubble(n),this._renderArrow(n,t))}}const Aa=l.StyleSheet.create({tooltipBubblePositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"},tooltipAboveModal:{zIndex:1090},tooltipBubblePositionerTopBottom:{left:0,width:"100%"},tooltipBubblePositionerLeftRight:{top:0,height:"100%"},tooltipBubbleWrapper:{pointerEvents:"auto"},tooltipArrowPositioner:{position:"absolute",zIndex:1030,pointerEvents:"none"}});class Na extends A.Component{constructor(){super(...arguments),X(this,"_mountNode",void 0),X(this,"_tooltipPositioner",void 0)}componentDidMount(){const e=document.createElement("div");this._mountNode=e,this.props.rootElement.appendChild(e),this._renderInMountNode(e)}componentDidUpdate(){const e=this._mountNode;e&&this._renderInMountNode(e)}componentWillUnmount(){const e=this._mountNode;e&&(D.default.unmountComponentAtNode(e),this.props.rootElement.removeChild(e))}remeasure(){this._tooltipPositioner&&this._tooltipPositioner.remeasure()}_renderInMountNode(e){const{tooltipProps:t,dismiss:n,rootElement:s,targetElement:o,isAboveModal:i}=this.props;D.default.render(A.createElement(Pa,{tooltipProps:t,dismiss:n,rootElement:s,targetElement:o,isAboveModal:i,ref:e=>this._tooltipPositioner=e}),e)}render(){return null}}const Ra=Object.freeze({side:"top",offset:0,offsetFrom:"bubble",tooltipMargin:0,noPadding:!1,color:ua.gray17,inverted:!1,dismissOnClickClose:!1,toggleOnHover:!0,showOnMount:!1});class Fa extends A.PureComponent{constructor(e){super(e),X(this,"_rootElement",void 0),X(this,"_wrapper",void 0),X(this,"_targetElement",void 0),X(this,"_tooltipPortal",void 0),X(this,"_visibilityObserver",void 0),X(this,"_isMounted",void 0),X(this,"_targetElementMountTimeout",void 0),X(this,"_handleVisibilityChange",(e=>{this.setState({targetElementIsVisible:e})})),X(this,"_handleMouseEnter",(()=>{this.setState({hovered:!0})})),X(this,"_handleMouseLeave",(()=>{this.setState({hovered:!1})})),X(this,"_handleDismiss",(()=>{null==this.props.dismissed&&this.setState({dismissed:!0}),this.props.onDismiss&&this.props.onDismiss()})),this._isMounted=!1,this.state={dismissed:null!=e.dismissed&&e.dismissed,hovered:!1,targetElementIsVisible:!1}}componentDidMount(){this._isMounted=!0,this._registerVisibilityObserver()}UNSAFE_componentWillReceiveProps(e){null!=e.dismissed&&this.setState({dismissed:e.dismissed})}UNSAFE_componentWillUpdate(){this._registerVisibilityObserver()}componentWillUnmount(){this._isMounted=!1,this._targetElementMountTimeout&&clearTimeout(this._targetElementMountTimeout),this._visibilityObserver.disconnect()}_findRootElement(){return this.context.modalContainerElement||document.getElementById("mission-task-container")||document.getElementById("outer-wrapper")||document.body}_registerVisibilityObserver(){const e=this._findRootElement();if(!e)throw new he("Failed to mount NewTooltip: we need a #outer-wrapper or document.body element.",pe.Internal);if(e===this._rootElement)return;this._rootElement=e,this._visibilityObserver&&this._visibilityObserver.disconnect(),this._visibilityObserver=function(e,t,n){return new xa(e,t,n)}(e,this._handleVisibilityChange);const t=this._wrapper;if(!t)throw new he("NewTooltip expected a wrapper element after mount",pe.Internal);let n=t;for(;n.hasAttribute("data-tooltip-wrapper");)if(n=n.childNodes[0],!n)throw new he("NewTooltip expected wrapper element to have a child",pe.Internal);this._targetElement=n,this._targetElementMountTimeout=setTimeout((()=>{const e=this._targetElement;if(!e)throw new he("NewTooltip should have a target element after mounting.",pe.Internal);le().isDevServer&&"inline"===getComputedStyle(e).display&&(de.error("Warning: The children of a NewTooltip element must be block-like, but this element seems to have `display: inline`. This could break position tracking.",pe.Internal),de.log("NewTooltip Target Element:",{targetElement:e.outerHTML})),this._visibilityObserver.setTargetElement(e),this.forceUpdate()}),0)}_shouldShowTooltip(){const{toggleOnHover:e,showOnMount:t}=this.props,{dismissed:n,targetElementIsVisible:s}=this.state;return!1!==s&&(!n&&(!!t||!(!e||!this.state.hovered)))}remeasure(){this._tooltipPortal&&this._tooltipPortal.remeasure()}render(){const{children:e,toggleOnHover:t}=this.props,{children:n,...s}=this.props;return A.createElement("div",{className:l.css(Da.targetElement),onMouseEnter:t?this._handleMouseEnter:void 0,onMouseLeave:t?this._handleMouseLeave:void 0,ref:e=>this._wrapper=e,"data-tooltip-wrapper":!0,"data-test-id":"question-id"},e,this._targetElement&&this._shouldShowTooltip()&&A.createElement(Na,{tooltipProps:s,dismiss:this._handleDismiss,rootElement:this._rootElement,targetElement:this._targetElement,isAboveModal:!!this.context.modalContainerElement,ref:e=>this._tooltipPortal=e}))}}X(Fa,"defaultProps",Ra),Fa.contextTypes={modalContainerElement:R.default.instanceOf(HTMLElement)};const Da=l.StyleSheet.create({targetElement:{display:"inline"}});class Oa extends A.PureComponent{constructor(){super(...arguments),X(this,"_handleKeyDown",(e=>{"Tab"===e.key&&(this.props.onDismiss(),e.preventDefault())}))}_renderTooltipContent(){return A.createElement("div",{onKeyDown:this._handleKeyDown},A.createElement(ba,this.props.buttonProps))}render(){return A.createElement("div",null,A.createElement(Fa,{content:this._renderTooltipContent(),offsetFrom:"arrow",offset:10,dismissed:this.props.dismissed,showOnMount:!0,toggleOnHover:!1,onClick:()=>this.props.buttonProps.onClick(),media:jr.mdOrLarger},this.props.children),!this.props.dismissed&&A.createElement(La,{onDismiss:this.props.onDismiss}))}}class La extends A.PureComponent{constructor(){super(...arguments),X(this,"_handleGlobalClick",(()=>{this.props.onDismiss()})),X(this,"_handleGlobalKeyup",(e=>{"Escape"===e.key&&this.props.onDismiss()}))}componentDidMount(){setTimeout((()=>{window.addEventListener("click",this._handleGlobalClick),window.addEventListener("keyup",this._handleGlobalKeyup)}),0)}componentWillUnmount(){window.removeEventListener("click",this._handleGlobalClick),window.removeEventListener("keyup",this._handleGlobalKeyup)}render(){return null}}const Ba={path:"M27.218 6.82l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836zm36.27 0l0 13.578q0 2.852-1.984 4.836t-4.836 1.984l-13.578 0q-2.852 0-4.836-1.984t-1.984-4.836l0-13.578q0-2.852 1.984-4.836t4.836-1.984l13.578 0q2.852 0 4.836 1.984t1.984 4.836z",width:100,height:27.284};class za extends A.PureComponent{constructor(){super(...arguments),X(this,"_menu",void 0),X(this,"_menuButton",void 0),X(this,"_crossOutButtonIsFocused",void 0),X(this,"state",{hovered:!1,opened:!1,slidePanelCovered:!0,usingKeyboardFocus:!1,wasCrossedOutOnLastOpen:!1}),X(this,"_openMenu",(()=>{const e=null!=this._menu&&this._menu.contains(document.activeElement);this.setState({opened:!0,usingKeyboardFocus:e,wasCrossedOutOnLastOpen:this.props.crossedOut})})),X(this,"_closeMenu",(()=>{this._crossOutButtonIsFocused&&this._menuButton&&this._menuButton.focus(),this.setState({opened:!1,slidePanelCovered:!0})})),X(this,"_handleMenuClick",((e,t)=>{t?this._openMenu():this._closeMenu(),e.preventDefault()})),X(this,"_handleCrossedOutButtonClick",(e=>{this.props.onCrossedOutChange(e),this._closeMenu()})),X(this,"_handleSlideTransitionEnd",(()=>{this.state.opened&&this.setState({slidePanelCovered:!1})}))}UNSAFE_componentWillReceiveProps(e){e.enabled||this._closeMenu()}_getButtonProps(e){const t=this.state.wasCrossedOutOnLastOpen;return{onClick:()=>{this._handleCrossedOutButtonClick(!t)},onFocus:()=>{this._crossOutButtonIsFocused=!0},onBlur:()=>{this._crossOutButtonIsFocused=!1},crossedOut:t,pos:this.props.pos,primaryProductColor:this.props.primaryProductColor,usingKeyboardFocus:this.state.usingKeyboardFocus,theme:e}}_getMenuIconColor(){return this.state.opened?this.props.primaryProductColor:this.state.hovered?q.default.offBlack:q.default.offBlack50}_renderMenu(){const{pos:e,isSatProduct:t}=this.props,{opened:n}=this.state,s=l.css(qa.menu,t&&qa.spacing);return A.createElement("div",{ref:e=>this._menu=e,className:s,onClick:e=>this._handleMenuClick(e,!n),onMouseEnter:()=>this.setState({hovered:!0}),onMouseLeave:()=>this.setState({hovered:!1})},A.createElement(Oa,{dismissed:!this.state.opened,onDismiss:this._closeMenu,buttonProps:this._getButtonProps("day")},A.createElement("button",{type:"button","aria-label":I._("Open menu for Choice %(letter)s",{letter:ia(e)}),className:l.css([qa.menuButton]),onClick:e=>this._handleMenuClick(e,!n),onMouseDown:e=>e.preventDefault(),ref:e=>this._menuButton=e},A.createElement(da,{className:l.css(qa.menuIcon),icon:Ba,size:3,color:this._getMenuIconColor()}))))}_renderSlidePanel(){const e=this._getButtonProps("night"),{slidePanelCovered:t}=this.state;return A.createElement("div",{className:l.css(qa.slidePanel,t&&qa.slidePanelCovered),onClick:e.onClick,"aria-hidden":t},A.createElement(ba,$({},e,{disabled:t,tabFocusable:!t})))}render(){const{enabled:e}=this.props,{opened:t}=this.state;return A.createElement("div",{className:l.css(qa.wrapper)},A.createElement("div",{className:l.css(qa.slidingContent,e&&qa.slidingContentEnabled,t&&qa.slidingContentOpen),onTransitionEnd:this._handleSlideTransitionEnd},A.createElement("div",{className:l.css(qa.content)},this.props.children),e&&this._renderMenu()),e&&this._renderSlidePanel())}}const qa=l.StyleSheet.create({wrapper:{display:"block",position:"relative"},slidingContent:{display:"flex",flexDirection:"row",alignItems:"stretch"},slidingContentEnabled:{[jr.smOrSmaller]:{transition:"transform 0.2s ease-out",backgroundColor:q.default.white}},slidingContentOpen:{[jr.smOrSmaller]:{transform:"translateX(-".concat(96,"px)")}},content:{display:"block",flex:"1 1 0"},menu:{cursor:"pointer",boxSizing:"border-box",width:32,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"center",[jr.smOrSmaller]:{paddingRight:8}},menuButton:{background:"none",border:"none",font:"inherit",padding:0,textAlign:"inherit",cursor:"pointer",display:"flex",flexDirection:"column",justifyContent:"center",height:16},menuIcon:{display:"block"},slidePanel:{position:"absolute",top:0,right:0,boxSizing:"border-box",width:96,height:"100%",paddingLeft:8,paddingRight:8,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",background:q.default.offBlack50,cursor:"pointer",[jr.mdOrLarger]:{display:"none"}},spacing:{paddingRight:12},slidePanelCovered:{zIndex:-1}});class Ha extends A.Component{_renderText(){const{checked:e,correct:t,crossedOut:n}=this.props;return t?e?I._("Correct (selected)"):n?I._("Correct (but you crossed it out)"):I._("Correct"):e?I._("Incorrect (selected)"):I._("Incorrect")}render(){const{checked:e,correct:t,previouslyAnswered:n}=this.props;let s;return s=t?Wa.correct:e||n?Wa.incorrectAnswered:Wa.incorrect,A.createElement("div",{className:l.css(Wa.text,s)},this._renderText())}}const Wa=l.StyleSheet.create({text:{alignItems:"center",display:"flex",fontSize:12,height:32,textTransform:"uppercase"},correct:{color:"#71B307"},incorrectAnswered:{color:"#F86700"},incorrect:{color:ee}});class Ua extends A.Component{constructor(){super(...arguments),X(this,"_inputElement",void 0),X(this,"handleClick",(e=>{this.props.onChecked(!this.props.checked)})),X(this,"handleKeyUp",(e=>{" "===e.key&&(this.props.onChecked(!this.props.checked),e.preventDefault())})),X(this,"handleChange",(e=>{!this.props.checked&&e.target.checked&&this.props.onChecked(!0)})),X(this,"handleKeyDown",(e=>{" "===e.key?e.preventDefault():"ArrowUp"===e.key||"ArrowLeft"===e.key?(this.props.goToPrevChoice(),e.preventDefault()):"ArrowDown"!==e.key&&"ArrowRight"!==e.key||(this.props.goToNextChoice(),e.preventDefault())})),X(this,"handleRef",(e=>{this._inputElement=e,this.props.inputRef&&this.props.inputRef(e)}))}render(){const{inputRef:e,onChecked:t,goToPrevChoice:n,goToNextChoice:s,...o}=this.props;return A.createElement("input",$({},o,{type:"radio",onChange:this.handleChange,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,ref:this.handleRef}))}}X(Ua,"propTypes",{checked:R.default.bool.isRequired,inputRef:R.default.func,onChecked:R.default.func.isRequired,goToPrevChoice:R.default.func.isRequired,goToNextChoice:R.default.func.isRequired});const Ga={backgroundColor:"#E4F3F9",outline:"2px solid ".concat("#0084CE"),zIndex:1};class Va extends A.Component{constructor(){super(...arguments),X(this,"justFinishedTouch",void 0),X(this,"justFinishedTimeoutID",void 0),X(this,"_input",void 0),X(this,"state",{isInputFocused:!1,isInputActive:!1}),X(this,"onInputFocus",(()=>{this.setState({isInputFocused:!0})})),X(this,"onInputBlur",(()=>{this.setState({isInputFocused:!1})})),X(this,"onInputMouseDown",(e=>{"mousedown"===e.type&&this.justFinishedTouch||(this.setState({isInputActive:!0}),this.props.apiOptions.satStyling&&this._input&&this._input.focus())})),X(this,"onInputMouseUp",(e=>{if("mouseup"!==e.type||!this.justFinishedTouch){if("touchend"===e.type)return this.justFinishedTouch=!0,null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID),void(this.justFinishedTimeoutID=setTimeout((()=>{this.setState({isInputActive:!1}),this.justFinishedTouch=!1}),10));this.setState({isInputActive:!1}),this.props.apiOptions.satStyling&&this._input&&this._input.focus()}})),X(this,"onInputMouseOut",(()=>{this.setState({isInputActive:!1})})),X(this,"inputRef",(e=>{this._input=e})),X(this,"renderOptionStatus",(()=>{const{correct:e,checked:t,crossedOut:n,reviewMode:s,previouslyAnswered:o}=this.props;return this.props.apiOptions.satStyling?null:s||o?A.createElement(Ha,{checked:t,correct:e,crossedOut:n,previouslyAnswered:o}):null})),X(this,"renderChoiceIcon",(()=>{const{radioStyleVersion:e,primaryProductColor:t}=this.props.apiOptions.styling;return void 0!==e&&"final"===e||this.props.apiOptions.satStyling?A.createElement(ca,{pos:this.props.pos,correct:this.props.correct,crossedOut:this.props.crossedOut,pressed:this.state.isInputActive,focused:this.state.isInputFocused,checked:this.props.checked,showCorrectness:this.props.showCorrectness,reviewMode:this.props.reviewMode,product:this.props.apiOptions.satStyling?"sat":"library",primaryProductColor:t,previouslyAnswered:this.props.previouslyAnswered}):null})),X(this,"_setChecked",(e=>{e?this._sendChange({checked:!0,crossedOut:!1}):this._sendChange({checked:!1})})),X(this,"_setCrossedOut",(e=>{e?this._sendChange({checked:!1,crossedOut:!0}):this._sendChange({crossedOut:!1})})),X(this,"_sendChange",(e=>{const t=null!=e.checked?e.checked:this.props.checked,n=null!=e.crossedOut?e.crossedOut:this.props.crossedOut;this.props.onChange({checked:t,crossedOut:n})})),X(this,"focusInput",(()=>{var e;null===(e=this._input)||void 0===e||e.focus()}))}UNSAFE_componentWillUpdate(e){this.state.isInputFocused&&e.disabled&&this.setState({isInputFocused:!1})}componentWillUnmount(){null!=this.justFinishedTimeoutID&&clearTimeout(this.justFinishedTimeoutID)}render(){const e=this.props.apiOptions.satStyling,t=this.props.apiOptions.isMobile,{radioStyleVersion:n}=this.props.apiOptions.styling,s=void 0!==n&&"final"===n,o=P.default(this.props.className,"checkbox-label",l.css(ja.label,t&&Qr.disableTextSelection,!e&&ja.responsiveLabel,e&&ja.satLabel)),i=P.default(l.css(this.state.isInputFocused&&ja.satDescriptionInputFocused,this.state.isInputActive&&ja.satDescriptionInputActive)),r=this.props.showCorrectness&&!this.props.correct,a=this.props.checked&&!r,c={type:this.props.type,name:this.props.groupName,id:"".concat(this.props.groupName,"-choice-").concat(this.props.pos),checked:a,disabled:this.props.disabled,onFocus:this.onInputFocus,onBlur:this.onInputBlur,className:l.css(!s&&Qr.perseusInteractive,!s&&ja.input,!s&&Qr.responsiveInput,!s&&!e&&Qr.responsiveRadioInput,!s&&!e&&this.state.isInputActive&&Qr.responsiveRadioInputActive,s&&Qr.perseusSrOnly,e&&Qr.perseusSrOnly,e&&this.props.reviewMode&&ja.satReviewInput)};let p=null;p="radio"===this.props.type?A.createElement(Ua,$({onChecked:e=>this._setChecked(e),goToPrevChoice:this.props.goToPrevChoice,goToNextChoice:this.props.goToNextChoice,inputRef:this.inputRef},c)):A.createElement("input",$({onChange:e=>this._setChecked(e.target.checked),ref:this.inputRef},c));const{reviewMode:d,correct:h,checked:u}=this.props,f=e&&d&&h,m=e&&d&&!h&&u,g=P.default("description",f&&"sat-correct",m&&"sat-incorrect",l.css(!e&&ja.description,e&&ja.satDescription,f&&ja.satDescriptionCorrect,f&&u&&ja.satDescriptionCorrectChecked,m&&ja.satDescriptionIncorrectChecked)),v=P.default("checkbox",l.css(Qr.perseusInteractive,!e&&ja.choiceIconWrapper,e&&ja.satCheckboxOptionContent)),b=P.default("checkbox-and-option",l.css(!e&&ja.intermediateResponsiveCheckbox,!e&&d&&ja.intermediateResponsiveCheckboxReview)),y=P.default("perseus-radio-rationale-content",l.css(ja.rationale,!e&&ja.nonSatRationale,e&&ja.satReviewRationale)),x=this.props.editMode?"div":"label",C=this.props.apiOptions.crossOutEnabled&&!this.props.showCorrectness,w=!e&&!d&&this.props.apiOptions.readOnly||C&&this.props.crossedOut;return A.createElement("div",{className:e?i:void 0},A.createElement(za,{enabled:C,pos:this.props.pos,primaryProductColor:this.props.apiOptions.styling.primaryProductColor,crossedOut:this.props.crossedOut,onCrossedOutChange:this._setCrossedOut,isSatProduct:e},A.createElement(x,{htmlFor:this.props.editMode?void 0:c.id,className:o,style:{opacity:w?.5:1}},A.createElement("div",{className:g,onMouseDown:this.onInputMouseDown,onMouseUp:this.onInputMouseUp,onMouseOut:this.onInputMouseOut,onTouchStart:this.onInputMouseDown,onTouchEnd:this.onInputMouseUp},A.createElement("div",{className:b},A.createElement("span",{className:v},p,this.renderChoiceIcon()),A.createElement("span",{className:P.default(en.RADIO.OPTION_CONTENT,en.INTERACTIVE,l.css(e&&ja.satRadioOptionContent,e&&d&&ja.satReviewRadioOptionContent)),style:{cursor:"default"}},A.createElement("div",{className:l.css(ja.optionStatusContainer)},this.renderOptionStatus()),A.createElement("div",null,this.props.content))),this.props.showRationale&&A.createElement("div",{className:y,"data-test-id":"perseus-radio-rationale-content-".concat(this.props.pos)},this.props.rationale)))))}}X(Va,"propTypes",{apiOptions:R.default.shape({satStyling:R.default.bool,isMobile:R.default.bool,styling:R.default.shape({radioStyleVersion:R.default.oneOf(["intermediate","final"]),primaryProductColor:R.default.string}),readOnly:R.default.bool}),checked:R.default.bool,className:R.default.string,rationale:R.default.node,content:R.default.node,correct:R.default.bool,deselectEnabled:R.default.bool,disabled:R.default.bool,editMode:R.default.bool,groupName:R.default.string,isLastChoice:R.default.bool,pos:R.default.number,reviewMode:R.default.bool,showRationale:R.default.bool,showCorrectness:R.default.bool,type:R.default.string,crossedOut:R.default.bool,previouslyAnswered:R.default.bool,onChange:R.default.func,goToPrevChoice:R.default.func.isRequired,goToNextChoice:R.default.func.isRequired}),X(Va,"defaultProps",{apiOptions:{styling:{}},checked:!1,classSet:{},correct:!1,disabled:!1,editMode:!1,onChange:function(){},showRationale:!1,type:"radio",pos:0,previouslyAnswered:!1});const ja=l.StyleSheet.create({description:{display:"inline-block",width:"100%"},satDescription:{display:"block",position:"relative",boxSizing:"border-box",cursor:"pointer",marginLeft:0,padding:"17px 14px"},satDescriptionInputFocused:{...Ga,display:"block"},satDescriptionInputActive:{...Ga,backgroundColor:"#D0EDF4"},satDescriptionCorrect:{color:"#009900"},satDescriptionCorrectChecked:{backgroundColor:"#E4F7E4"},satDescriptionIncorrectChecked:{color:"#990000",backgroundColor:"#F2EBEB"},input:{display:"inline-block",width:20,margin:3,marginLeft:-20,marginRight:0,float:"none"},satReviewInput:{pointerEvents:"none"},satRadioOptionContent:{userSelect:"text",display:"block",marginLeft:45,cursor:"inherit"},satReviewRadioOptionContent:{fontWeight:"bold"},satCheckboxOptionContent:{position:"absolute",display:"block",top:"50%",margin:"-16px 0 0 0",width:"auto"},choiceIconWrapper:{display:"flex",marginRight:12,flexShrink:0},optionStatusContainer:{display:"block"},rationale:{display:"block"},nonSatRationale:{padding:"16px 16px",paddingTop:0,marginLeft:44,[jr.smOrSmaller]:{padding:"12px 16px",paddingTop:0}},satReviewRationale:{marginTop:13,marginLeft:45},label:{display:"block",transition:"opacity 0.2s ease-out"},responsiveLabel:{WebkitTapHighlightColor:"transparent",display:"flex",alignItems:"stretch"},satLabel:{cursor:"pointer"},intermediateResponsiveCheckbox:{display:"flex",alignItems:"center",padding:"16px 16px",[jr.smOrSmaller]:{padding:"12px 16px"}},intermediateResponsiveCheckboxReview:{alignItems:"flex-start"}});class Ya extends A.Component{constructor(){super(...arguments),X(this,"_choice",void 0),X(this,"focusInput",(()=>{this._choice.focusInput()}))}render(){const e={...this.props,className:P.default(this.props.className,"none-of-above"),content:this.props.showContent?this.props.content:A.createElement(Li,{key:"noneOfTheAboveRenderer",content:I._("None of the above")}),ref:e=>this._choice=e};return A.createElement(Va,e)}}X(Ya,"propTypes",{className:R.default.string,content:R.default.node,showContent:R.default.bool}),X(Ya,"defaultProps",{showContent:!0});const{captureScratchpadTouchStart:Xa}=Be,$a=R.default.arrayOf(R.default.shape({checked:R.default.bool,crossedOut:R.default.bool,content:R.default.node,rationale:R.default.node,hasRationale:R.default.bool,showRationale:R.default.bool,showCorrectness:R.default.bool,correct:R.default.bool,originalIndex:R.default.number,isNoneOfTheAbove:R.default.bool}));class Ka extends A.Component{constructor(){super(...arguments),X(this,"state",{radioGroupName:N.default.uniqueId("perseus_radio_")}),X(this,"updateChoice",((e,t)=>{let n;n=t.checked&&!this.props.multipleSelect?this.props.choices.map((e=>!1)):this.props.choices.map((e=>e.checked));const s=this.props.choices.map((e=>e.crossedOut));n[e]=t.checked,s[e]=t.crossedOut,this.props.onChange({checked:n,crossedOut:s})})),X(this,"focus",(e=>(D.default.findDOMNode(this.refs["radio"+(e||0)]).focus(),!0))),X(this,"getInstructionsText",(()=>this.props.multipleSelect?this.props.countChoices?I._("Choose %(numCorrect)s answers:",{numCorrect:this.props.numCorrect}):I._("Choose all answers that apply:"):I._("Choose 1 answer:"))),X(this,"deselectEnabled",(()=>this.props.apiOptions.isMobile||this.props.deselectEnabled)),X(this,"goToChoice",(e=>{const t=this.props.choices.length;e<0&&(e+=t),e>=t&&(e-=t);const n=this.refs["radio".concat(e)];if(!n)return void de.error("found no choice at index ".concat(e,", even after ")+"wrapping it to be within bounds",pe.Internal,{loggedMetadata:{choices:JSON.stringify(this.props.choices)}});n.focusInput();const s=this.props.choices.map((e=>e.crossedOut)),o=this.props.choices.map((e=>!1));this.props.choices[e].crossedOut||(o[e]=!0),this.props.onChange({checked:o,crossedOut:s})}))}componentDidUpdate(e){const{apiOptions:t,choices:n,isLastUsedWidget:s,reviewModeRubric:o}=this.props;if(t.canScrollPage&&s&&o&&!e.reviewModeRubric){const e=n.findIndex((e=>e.checked));if(e>=0){const t=D.default.findDOMNode(this.refs["radio"+e]);na(t)}}}render(){const e=this.props.multipleSelect?"checkbox":"radio",t=this.props.reviewModeRubric,n=!!t,s=Ka.styles,o=this.props.apiOptions.satStyling,i=this.props.apiOptions.isMobile,r=this.props.choices,a=r[0].highlighted,c=r[r.length-1].highlighted,p=P.default("perseus-widget-radio",!this.props.editMode&&"perseus-rendered-radio",l.css(s.radio,!o&&s.responsiveRadioContainer,!o&&a&&i&&s.radioContainerFirstHighlighted,!o&&c&&i&&s.radioContainerLastHighlighted,o&&s.satRadio)),d=P.default("instructions",l.css(s.instructions,i&&s.instructionsMobile)),h=this.getInstructionsText(),u=!o,f=l.css(s.responsiveFieldset),m=A.createElement("fieldset",{className:"perseus-widget-radio-fieldset ".concat(f)},A.createElement("legend",{className:"perseus-sr-only"},h),u&&A.createElement("div",{className:d},h),A.createElement("ul",{className:p},this.props.choices.map((function(i,r){let a=Va;const c={ref:"radio".concat(r),apiOptions:this.props.apiOptions,checked:i.checked,crossedOut:i.crossedOut,previouslyAnswered:i.previouslyAnswered,reviewMode:n,correct:i.correct,rationale:i.rationale,content:i.content,disabled:this.props.apiOptions.readOnly||i.disabled,editMode:this.props.editMode,groupName:this.state.radioGroupName,isLastChoice:r===this.props.choices.length-1,showCorrectness:n||!!i.showCorrectness,showRationale:i.hasRationale&&(n||i.showRationale),type:e,pos:r,deselectEnabled:this.deselectEnabled(),onChange:e=>{this.updateChoice(r,e)},goToPrevChoice:()=>this.goToChoice(r-1),goToNextChoice:()=>this.goToChoice(r+1)};i.isNoneOfTheAbove&&(a=Ya,N.default.extend(c,{showContent:i.revealNoneOfTheAbove}));const p=this.props.choices[r+1],d=!!p&&p.highlighted,h=e=>{const r=o&&n&&e,a=o&&n&&p&&p.checked;return l.css(Qr.aboveScratchpad,s.item,!o&&s.responsiveItem,!o&&e&&s.selectedItem,!o&&e&&i.highlighted&&s.aboveBackdrop,!o&&e&&i.highlighted&&this.props.apiOptions.isMobile&&s.aboveBackdropMobile,!o&&d&&this.props.apiOptions.isMobile&&s.nextHighlighted,o&&s.satRadioOption,r&&!i.correct&&s.satRadioOptionIncorrect,r&&i.correct&&s.satRadioOptionCorrect,a&&!p.correct&&s.satRadioOptionNextIncorrect,a&&p.correct&&s.satRadioOptionNextCorrect,o&&t&&s.satReviewRadioOption)};h(!0);const u=P.default(h(i.checked),en.RADIO.OPTION,i.checked&&en.RADIO.SELECTED,n&&t.choices[r].correct&&en.CORRECT,n&&!t.choices[r].correct&&en.INCORRECT);let f=null,m=null;return this.props.editMode&&(m=e=>{let t=e.target;for(;t&&t!==f;){if(t.getAttribute("data-is-radio-icon"))return void this.updateChoice(r,{checked:!i.checked});t=t.parentNode}}),A.createElement("li",{key:r,ref:e=>f=e,className:u,onClick:m,onTouchStart:this.props.labelWrap?Xa:null},A.createElement(a,c))}),this)));return A.createElement("div",{className:l.css(!o&&s.responsiveContainer)},m)}}X(Ka,"propTypes",{apiOptions:R.default.shape({readOnly:R.default.bool,satStyling:R.default.bool,isMobile:R.default.bool,styling:R.default.shape({radioStyleVersion:R.default.oneOf(["intermediate","final"])}),canScrollPage:R.default.bool}),choices:$a,deselectEnabled:R.default.bool,editMode:R.default.bool,labelWrap:R.default.bool,countChoices:R.default.bool,numCorrect:R.default.number,multipleSelect:R.default.bool,reviewModeRubric:R.default.shape({choices:$a}),onChange:R.default.func,isLastUsedWidget:R.default.bool}),X(Ka,"styles",l.StyleSheet.create({instructions:{display:"block",color:te,fontSize:14,lineHeight:1.25,fontStyle:"normal",fontWeight:"bold",marginBottom:16},instructionsMobile:{fontSize:18,[jr.smOrSmaller]:{fontSize:16},[jr.xl]:{fontSize:20}},radio:{width:"100%"},responsiveRadioContainer:{borderBottom:"1px solid ".concat("#BABEC2"),borderTop:"1px solid ".concat("#BABEC2"),width:"auto",[jr.smOrSmaller]:{marginLeft:-16,marginRight:-16}},radioContainerFirstHighlighted:{borderTop:"1px solid rgba(0, 0, 0, 0)"},radioContainerLastHighlighted:{borderBottom:"1px solid rgba(0, 0, 0, 0)"},satRadio:{background:"none",marginLeft:0,userSelect:"none"},satRadioOption:{margin:0,padding:0,borderBottom:"1px solid #ccc",":first-child":{borderTop:"1px solid #ccc"}},satRadioOptionCorrect:{borderBottomColor:"#00CC00",":first-child":{borderTopColor:"#00CC00"}},satRadioOptionIncorrect:{borderBottomColor:"#CC5252",":first-child":{borderTopColor:"#CC5252"}},satRadioOptionNextCorrect:{borderBottomColor:"#00CC00"},satRadioOptionNextIncorrect:{borderBottomColor:"#CC5252"},satReviewRadioOption:{pointerEvents:"none"},item:{marginLeft:20},inlineItem:{display:"inline-block",paddingLeft:20,verticalAlign:"middle"},responsiveItem:{marginLeft:0,padding:0,":not(:last-child)":{borderBottom:"1px solid ".concat("#BABEC2")}},selectedItem:{background:"white"},aboveBackdrop:{position:"relative",zIndex:1062},aboveBackdropMobile:{boxShadow:"0 0 4px 0 rgba(0, 0, 0, 0.2),0 0 2px 0 rgba(0, 0, 0, 0.1)",":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},nextHighlighted:{":not(:last-child)":{borderBottom:"1px solid rgba(0, 0, 0, 0)"}},responsiveContainer:{overflow:"auto",marginLeft:-16,marginRight:-16,paddingLeft:16},responsiveFieldset:{paddingRight:16}})),X(Ka,"defaultProps",{editMode:!1});class Za extends A.Component{constructor(){super(...arguments),X(this,"_renderRenderer",(e=>{let t=1;const n={},s=(e=e||"").replace(/\{\{passage-ref (\d+) (\d+)(?: "([^"]*)")?\}\}/g,((e,s,o,i)=>{const r="passage-ref "+t;return t++,n[r]={type:"passage-ref",graded:!1,options:{passageNumber:parseInt(s),referenceNumber:parseInt(o),summaryText:i},version:Lr.version},"[["+Be.snowman+" "+r+"]]"}));return A.createElement(Li,{key:"choiceContentRenderer",content:s,widgets:n,findExternalWidgets:this.props.findWidgets,alwaysUpdate:!0,linterContext:{...this.props.linterContext,blockHighlight:!0}})})),X(this,"focus",(e=>this.refs.baseRadio.focus(e))),X(this,"updateChoices",(e=>{const{choiceStates:t,choices:n}=this.props;let s;s=t?t.map((e=>({...e}))):n.map((()=>({selected:!1,crossedOut:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1,readOnly:!1}))),s.forEach(((t,n)=>{t.selected=e.checked[n],t.crossedOut=e.crossedOut[n]})),this.props.onChange({choiceStates:s}),this.props.trackInteraction()})),X(this,"getUserInput",(()=>Za.getUserInputFromProps(this.props))),X(this,"simpleValidate",(e=>Za.validate(this.getUserInput(),e))),X(this,"showRationalesForCurrentlySelectedChoices",(e=>{const{choiceStates:t}=this.props;if(t){const n=this.simpleValidate(e),s="points"===n.type&&n.total===n.earned,o=t.map((e=>({...e,highlighted:e.selected,rationaleShown:e.selected||e.rationaleShown||s,readOnly:e.selected||e.readOnly||s,correctnessShown:e.selected||e.correctnessShown,previouslyAnswered:e.previouslyAnswered||e.selected})));this.props.onChange({choiceStates:o},null,!0)}})),X(this,"deselectIncorrectSelectedChoices",(()=>{if(this.props.choiceStates){const e=this.props.choiceStates.map(((e,t)=>({...e,selected:e.selected&&!!this.props.choices[t].correct,highlighted:!1})));this.props.onChange({choiceStates:e},null,!1)}}))}render(){let e,t=this.props.choices;return e=this.props.static?N.default.map(t,(e=>({selected:e.correct,crossedOut:e.crossedOut,readOnly:!0,highlighted:!1,rationaleShown:!0,correctnessShown:!0,previouslyAnswered:!1}))):this.props.choiceStates?this.props.choiceStates:this.props.values?N.default.map(this.props.values,(e=>({selected:e,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))):N.default.map(t,(()=>({selected:!1,crossedOut:!1,readOnly:!1,highlighted:!1,rationaleShown:!1,correctnessShown:!1,previouslyAnswered:!1}))),t=N.default.map(t,((t,n)=>{const s=t.isNoneOfTheAbove&&!t.content?I._("None of the above"):t.content,{selected:o,crossedOut:i,rationaleShown:r,correctnessShown:a,readOnly:l,highlighted:c,previouslyAnswered:p}=e[n],d=this.props.reviewModeRubric&&this.props.reviewModeRubric.choices[n];return{content:this._renderRenderer(s),checked:o,correct:void 0===t.correct?!!d&&d.correct:t.correct,disabled:l,hasRationale:!!t.clue,rationale:this._renderRenderer(t.clue),showRationale:r,showCorrectness:a,isNoneOfTheAbove:t.isNoneOfTheAbove,revealNoneOfTheAbove:this.props.questionCompleted&&o,crossedOut:i,highlighted:c,previouslyAnswered:p}})),A.createElement(Ka,{ref:"baseRadio",labelWrap:!0,multipleSelect:this.props.multipleSelect,countChoices:this.props.countChoices,numCorrect:this.props.numCorrect,choices:t,onChange:this.updateChoices,reviewModeRubric:this.props.reviewModeRubric,deselectEnabled:this.props.deselectEnabled,apiOptions:this.props.apiOptions,isLastUsedWidget:this.props.isLastUsedWidget})}static validate(e,t){const n=N.default.reduce(e.choicesSelected,((e,t)=>e+(t?1:0)),0);if(0===n)return{type:"invalid",message:null};if(e.numCorrect>1&&n!==e.numCorrect)return{type:"invalid",message:I._("Please choose the correct number of answers.")};if(e.noneOfTheAboveSelected&&n>1)return{type:"invalid",message:I._("'None of the above' may not be selected when other answers are selected.")};return{type:"points",earned:N.default.all(e.choicesSelected,((n,s)=>{let o;return o=e.noneOfTheAboveIndex===s?N.default.all(t.choices,((e,t)=>s===t||!e.correct)):!!t.choices[s].correct,o===n}))?1:0,total:1,message:null}}static getUserInputFromProps(e){if(e.choiceStates){let t=null,n=!1;const s=e.choiceStates,o=s.map((()=>!1)),i=e.countChoices,r=e.numCorrect;for(let i=0;i<o.length;i++){const r=e.choices[i].originalIndex;o[r]=s[i].selected,e.choices[i].isNoneOfTheAbove&&(t=r,o[i]&&(n=!0))}return{countChoices:i,choicesSelected:o,numCorrect:r,noneOfTheAboveIndex:t,noneOfTheAboveSelected:n}}if(e.values){let t=null,n=!1;const s=e.values.slice(),o=e.countChoices,i=e.numCorrect;for(let o=0;o<e.values.length;o++){const i=e.choices[o].originalIndex;s[i]=e.values[o],e.choices[o].isNoneOfTheAbove&&(t=i,s[o]&&(n=!0))}return{choicesSelected:s,noneOfTheAboveIndex:t,noneOfTheAboveSelected:n,countChoices:o,numCorrect:i}}return{choicesSelected:N.default.map(e.choices,(()=>!1))}}}X(Za,"defaultProps",{choices:[{}],displayCount:null,multipleSelect:!1,countChoices:!1,deselectEnabled:!1,linterContext:Yt});const{shuffle:Ja,random:Qa}=Be,el=[[I._("False"),I._("True")],[I._("No"),I._("Yes")]],tl=(e,t)=>{const n=((e,t)=>{let n=e.choices.slice();return n=N.default.map(n,((e,t)=>N.default.extend({},e,{originalIndex:t,correct:Boolean(e.correct)}))),function(e){let t=null;const n=N.default.reject(e,(function(e,n){if(e.isNoneOfTheAbove)return t=e,!0}));return t&&n.push(t),n}((e=>{const t=e.map((e=>e.content));return el.some((e=>N.default.isEqual(t,e)))?[e[1],e[0]]:e})(function(n){const s=void 0===t?Qa:t;return e.randomize?Ja(n,null!=s?s:0):n}(n)))})(e,t),s=N.default.reduce(e.choices,(function(e,t){return t.correct?e+1:e}),0),{hasNoneOfTheAbove:o,multipleSelect:i,countChoices:r,deselectEnabled:a}=e;return{numCorrect:s,hasNoneOfTheAbove:o,multipleSelect:i,countChoices:r,deselectEnabled:a,choices:n,selectedChoices:N.default.pluck(n,"correct")}};var nl={name:"radio",displayName:"Multiple choice",accessible:!0,widget:Za,transform:tl,staticTransform:tl,version:{major:1,minor:0},propUpgrades:{1:e=>{let t,n;if(e.noneOfTheAbove)throw new Error("radio widget v0 no longer supports auto noneOfTheAbove");return t=e.choices,n=!1,N.default.extend(N.default.omit(e,"noneOfTheAbove"),{choices:t,hasNoneOfTheAbove:n})}},isLintable:!0},sl=[nl,Mr,Fr,xr];class ol extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"state",{uniqueId:N.default.uniqueId("perseus_radio_")}),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"getUserInput",(()=>ol.getUserInputFromProps(this.props))),X(this,"onChange",((e,t)=>{const n=[...this.props.values];n[e]=t,this.change("values",n),this.props.trackInteraction()})),X(this,"simpleValidate",(e=>ol.validate(this.getUserInput(),e)))}render(){const e=this,t=this.props.apiOptions.isMobile;let n=this.props.items.map(((e,t)=>[e,t]));this.props.randomizeItems&&(n=Be.shuffle(n,this.props.problemNum));const s=A.createElement("table",{className:"categorizer-table "+l.css(il.mobileTable)},A.createElement("thead",null,A.createElement("tr",null,A.createElement("th",null," "),this.props.categories.map(((e,t)=>A.createElement("th",{className:l.css(il.header),key:t},A.createElement(Li,{content:e,linterContext:this.props.linterContext})))))),A.createElement("tbody",null,n.map((n=>{const s=n[0],o=n[1],i=e.state.uniqueId+"_"+o;return A.createElement("tr",{key:o},A.createElement("td",null,A.createElement(Li,{content:s,linterContext:this.props.linterContext})),e.props.categories.map(((n,s)=>{const r=e.props.values[o]===s;return A.createElement("td",{className:"category "+l.css(il.cell),key:s},A.createElement("div",{className:en.INTERACTIVE,role:"button","aria-label":n,onClick:this.onChange.bind(this,o,s)},t&&A.createElement("input",{type:"radio",name:i,className:l.css(Qr.responsiveInput,Qr.responsiveRadioInput),checked:r,onChange:this.onChange.bind(this,o,s),onClick:e=>e.stopPropagation()}),!t&&A.createElement("span",{className:l.css(il.radioSpan,r&&il.checkedRadioSpan,this.props.static&&r&&il.staticCheckedRadioSpan)},r?A.createElement(K,bs):A.createElement(K,Cs))))})))})))),o=P.default({"categorizer-container":!0,"static-mode":this.props.static}),i=this.props.apiOptions.isMobile?[il.fullBleedContainer]:[];return A.createElement("div",{className:o+" "+l.css(...i)},s)}static validate(e,t){let n=!0,s=!0;return N.default.each(t.values,(function(t,o){null==e.values[o]&&(n=!1),e.values[o]!==t&&(s=!1)})),n?{type:"points",earned:s?1:0,total:1,message:null}:{type:"invalid",message:I._("Make sure you select something for every row.")}}static getUserInputFromProps(e){return Dr.getUserInputFromProps(e)}}X(ol,"defaultProps",{items:[],categories:[],values:[],linterContext:Yt});const il=l.StyleSheet.create({mobileTable:{[jr.smOrSmaller]:{minWidth:"auto"}},fullBleedContainer:{[jr.mdOrSmaller]:{marginLeft:-16,marginRight:-16,overflowX:"auto"}},header:{textAlign:"center",verticalAlign:"bottom"},cell:{textAlign:"center",padding:0,color:"#ccc",verticalAlign:"middle"},radioSpan:{fontSize:30,paddingRight:3,":hover":{color:"#999"}},checkedRadioSpan:{color:"#333"},staticCheckedRadioSpan:{color:"#888"}});var rl={name:"categorizer",displayName:"Categorizer",widget:ol,transform:e=>N.default.pick(e,"items","categories","randomizeItems"),staticTransform:e=>N.default.pick(e,"items","categories","values","randomizeItems"),isLintable:!0};let al;const ll=e=>new URL(e,(al||(al=window.location),al).origin),{updateQueryString:cl}=Be;function pl(e){const{InitialRequestUrl:t}=le(),n="/computer-programming/program/"+"".concat(e,"/embedded?embed=yes&author=no");return(s=t.protocol)&&"file:"===s.toLowerCase()?"https://khanacademy.org".concat(n):ll(n).href;var s}class dl extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"handleMessageEvent",(e=>{let t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(N.default.isUndefined(t.testsPassed))return;const n=t.testsPassed?"correct":"incorrect";this.change({status:n,message:t.message})})),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"simpleValidate",(e=>dl.validate({status:this.props.status,message:this.props.message},e)))}static validate(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}componentDidMount(){L.default(window).on("message",this.handleMessageEvent)}componentWillUnmount(){L.default(window).off("message",this.handleMessageEvent)}render(){if(!this.props.programID)return A.createElement("div",null);let e,t=!1,n=pl(this.props.programID);const s={height:this.props.height,width:"100%"};if(this.props.showEditor?(n+="&editor=yes",e="perseus-scratchpad-editor"):(n+="&editor=no&width=".concat(688),e="perseus-scratchpad","webpage"!==this.props.programType&&(t=!0)),this.props.showButtons?(n+="&buttons=yes",s.height+=67):n+="&buttons=no",this.props.settings){const e={};N.default.each(this.props.settings,(function(t){t.name&&t.value&&(e[t.name]=t.value)})),n=cl(n,"settings",JSON.stringify(e))}const o=["allow-popups","allow-same-origin","allow-scripts","allow-top-navigation"].join(" ");return A.createElement("div",{className:l.css(hl.widthOverride,t&&hl.container)},A.createElement("iframe",{sandbox:o,src:n,style:s,className:e,allowFullScreen:!0}))}}X(dl,"propTypes",{...fr,programID:R.default.string,programType:R.default.oneOf(["pjs","sql","webpage"]),width:R.default.number,height:R.default.number,settings:R.default.array,showEditor:R.default.bool,showButtons:R.default.bool,status:R.default.oneOf(["incomplete","incorrect","correct"]),message:R.default.string}),X(dl,"defaultProps",{showEditor:!1,showButtons:!1,status:"incomplete",message:null});const hl=l.StyleSheet.create({widthOverride:{width:820},container:{margin:"auto"}});var ul={name:"cs-program",displayName:"CS Program",supportedAlignments:["block","full-width"],widget:dl,hidden:!0};class fl extends A.Component{componentDidMount(){this.props.trackInteraction()}render(){return A.createElement(g.View,{style:gl.tooltipBody},A.createElement(Li,{apiOptions:this.props.apiOptions,content:this.props.content,widgets:this.props.widgets}))}}X(fl,"propTypes",{apiOptions:Qt.propTypes,content:R.default.string,trackInteraction:R.default.func.isRequired,widgets:R.default.objectOf(R.default.any)});class ml extends A.Component{constructor(){super(...arguments),X(this,"getUserInput",(()=>({}))),X(this,"simpleValidate",(e=>ml.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const e=A.createElement(fl,{apiOptions:this.props.apiOptions,content:this.props.definition,key:this.props.definition,trackInteraction:this.props.trackInteraction,widgets:this.props.widgets});return A.createElement(W.default,{content:e,placement:"top"},A.createElement("span",{className:"perseus-widget-definition"},A.createElement(g.View,{style:gl.definitionLink},this.props.togglePrompt)))}}X(ml,"defaultProps",{togglePrompt:"define me",definition:"definition goes here"});const gl={tooltipBody:{color:q.default.offBlack,display:"block",fontSize:20,fontWeight:500,lineHeight:"30px",margin:H.default.xSmall_8},definitionLink:{borderBottom:"dashed 1px ".concat(q.default.blue),color:q.default.blue,cursor:"pointer",display:"inline-block",textDecoration:"none"}};var vl={name:"definition",displayName:"Definition",accessible:!0,defaultAlignment:"inline",widget:ml,transform:N.default.identity};class bl extends A.Component{constructor(){super(...arguments),X(this,"focus",(()=>(D.default.findDOMNode(this).focus(),!0))),X(this,"_handleChangeEvent",(e=>{this._handleChange(parseInt(e.target.value))})),X(this,"_handleChange",(e=>{this.props.trackInteraction(),this.props.onChange({selected:e})})),X(this,"getUserInput",(()=>({value:this.props.selected}))),X(this,"simpleValidate",(e=>bl.validate(this.getUserInput(),e)))}static validate(e,t){const n=e.value;if(0===n)return{type:"invalid",message:null};return{type:"points",earned:t.choices[n-1].correct?1:0,total:1,message:null}}render(){const e=[A.createElement(y.OptionItem,{key:"placeholder",value:"0",disabled:!0,label:this.props.placeholder}),...this.props.choices.map(((e,t)=>A.createElement(y.OptionItem,{key:String(t+1),value:String(t+1),label:e})))];return A.createElement("div",{onClick:e=>{e.stopPropagation()},onTouchStart:e=>{e.stopPropagation()}},A.createElement(y.SingleSelect,{onChange:e=>this._handleChange(parseInt(e)),selectedValue:String(this.props.selected),disabled:this.props.apiOptions.readOnly},e))}}X(bl,"defaultProps",{choices:[],selected:0,placeholder:"",apiOptions:Qt.defaults});var yl={name:"dropdown",displayName:"Drop down",defaultAlignment:"inline-block",accessible:!0,widget:bl,transform:e=>({placeholder:e.placeholder,choices:N.default.map(e.choices,(e=>e.content))})};class xl extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"state",{expanded:!1}),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"_onClick",(()=>{this.setState({expanded:!this.state.expanded}),this.props.trackInteraction()})),X(this,"getUserInput",(()=>({}))),X(this,"simpleValidate",(e=>xl.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const{Link:e}=this.props.apiOptions.baseElements,{isArticle:t,isMobile:n}=this.props.apiOptions,s=this.state.expanded?this.props.hidePrompt:this.props.showPrompt;let o;const i="javascript:void(0)",r=this._onClick;o=n?A.createElement("div",{className:l.css(Sl.linkContainer)},A.createElement("a",{className:l.css(Sl.mobileExplanationLink),href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},s),this.state.expanded&&A.createElement("svg",{className:l.css(Sl.disclosureArrow)},A.createElement("polygon",{style:{fill:kl},points:"0,".concat(wl," ")+"".concat(Cl,",").concat(wl," ")+"".concat(Cl/2,",0")}))):t?A.createElement("div",{className:l.css(Sl.linkContainer,Sl.articleLink)},A.createElement(e,{className:l.css(Sl.explanationLink),style:Sl.explanationLink,href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},"[".concat(s,"]"))):A.createElement("div",{className:l.css(Sl.linkContainer,Sl.exerciseLink)},A.createElement(e,{className:l.css(Sl.explanationLink),href:i,onClick:r,role:"button","aria-expanded":this.state.expanded},"[".concat(s,"]")));const a=n?Sl.contentExpandedMobile:Sl.contentExpanded;return A.createElement("div",{className:l.css(Sl.container)},o,this.state.expanded&&A.createElement("div",{className:l.css(Sl.content,n&&Sl.contentMobile,this.state.expanded&&a),ref:"content"},A.createElement(Li,{apiOptions:this.props.apiOptions,content:this.props.explanation,widgets:this.props.widgets,linterContext:this.props.linterContext})))}}X(xl,"defaultProps",{showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{},linterContext:Yt});const Cl=30,wl=14,kl="#F0F1F2",Sl=l.StyleSheet.create({container:{display:"inline",position:"relative"},linkContainer:{display:"inline-block"},explanationLink:{fontStyle:"italic",color:"#007d96"},articleLink:{fontSize:20,lineHeight:"30px"},exerciseLink:{fontSize:14,lineHeight:"19.6px"},mobileExplanationLink:{color:"#71B307",borderBottom:"dashed 1px ".concat("#71B307"),textDecoration:"none",[jr.xl]:{fontSize:22,lineHeight:1.4},[jr.lgOrSmaller]:{fontSize:20,lineHeight:1.5},[jr.smOrSmaller]:{fontSize:18,lineHeight:1.2}},content:{position:"relative",transition:"margin-top 0.1s"},contentExpanded:{borderLeft:"5px solid #ccc",marginLeft:-23,paddingLeft:23,paddingBottom:10,marginBottom:wl,marginTop:wl},contentExpandedMobile:{boxSizing:"content-box",paddingTop:32,paddingBottom:32,marginTop:wl},contentMobile:{background:kl,marginLeft:-16,marginRight:-16,paddingLeft:16,paddingRight:16},disclosureArrow:{bottom:-(wl+5),height:wl,left:"50%",marginLeft:-Cl/2,position:"absolute",width:Cl}});var El={name:"explanation",displayName:"Explanation",accessible:!0,defaultAlignment:"inline",widget:xl,transform:N.default.identity,isLintable:!0};class _l extends A.Component{render(){const{apiOptions:e,answerBarState:t,onCheckAnswer:n,onNextQuestion:s}=this.props,o={...Ml.answerBar,backgroundColor:"CORRECT"===t?q.default.offWhite:"white",justifyContent:"CORRECT"!==t||s?"space-between":"center"},i="INCORRECT"===t?A.createElement("span",{style:Ml.text},A.createElement("span",{style:Ml.tryAgainIcon},A.createElement(K,Ms)),A.createElement("span",{style:{marginLeft:8}},I._("Keep trying"))):A.createElement("span",null);if("CORRECT"!==t){const s="INCORRECT"===t?I._("Try again"):I._("Check");return A.createElement("div",{style:o},i,A.createElement(U.default,{disabled:e.readOnly||"ACTIVE"!==t,onClick:n},s))}return A.createElement("div",{style:o},A.createElement("span",{style:Ml.text},A.createElement("span",{style:{fontSize:28,color:q.default.green}},A.createElement(K,$({},_s,{style:{marginBottom:5}}))),A.createElement("span",{role:"alert","aria-label":I._("Correct!"),style:{marginLeft:8}},I._("Correct!"))),s&&A.createElement(U.default,{onClick:s},I._("Next question")))}}const Ml={answerBar:{display:"flex",alignItems:"center",height:68,marginLeft:-16,marginRight:-16,marginBottom:-16,marginTop:16,paddingLeft:16,paddingRight:10,borderTop:"1px solid ".concat(q.default.offBlack50)},tryAgainIcon:{fontSize:28,color:"#63D9EA",transform:"scale(-1,1) rotate(-268deg)"},text:{display:"flex",flexDirection:"row",alignItems:"center",fontWeight:"bold",fontSize:17}},Tl="ungraded",Il="correct",Pl="incorrect",Al="invalid",Nl=(e,t)=>{switch(e){case"HIDDEN":case"INACTIVE":return t?"ACTIVE":e;case"ACTIVE":return t?e:"INACTIVE";case"INCORRECT":return t?"ACTIVE":"INACTIVE";default:return e}},Rl=I._("We couldn't grade your answer."),Fl=I._("It looks like you left something blank or ")+I._("entered in an invalid answer.");class Dl extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"state",{status:Tl,showHint:!1,message:"",answerBarState:"HIDDEN"}),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"_onInteractWithWidget",(e=>{if(this.setState({status:Tl,message:""}),this.refs.renderer){this.change("widgets",this.props.widgets);const e=0===this.refs.renderer.emptyWidgets().length,t=this.state.answerBarState;this.setState({answerBarState:Nl(t,e)})}})),X(this,"_checkAnswer",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices();const e=this.refs.renderer.score(),t="points"===e.type?e.total===e.earned?Il:Pl:Al,n="points"===e.type?e.message||"":e.message?"".concat(Rl," ").concat(e.message):"".concat(Rl," ").concat(Fl);this.setState({status:t,message:n,answerBarState:"correct"===t?"CORRECT":"INCORRECT"}),this.props.trackInteraction({status:t})})),X(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),X(this,"setInputValue",((e,t,n)=>this.refs.renderer.setInputValue(e,t,n))),X(this,"focus",(()=>this.refs.renderer.focus())),X(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),X(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){const e=N.default.extend({},Qt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}});let t=null,n=null;this.state.status===Il?(n=A.createElement(K,$({},ks,{style:{color:"#526f03"}})),t=I._("Correct")):this.state.status===Pl&&(n=A.createElement(K,$({},Es,{style:{color:"#ff5454"}})),t=I._("Incorrect"));const s=this.props.inGradedGroupSet?l.css(Ol.gradedGroupInSet):l.css(Ol.gradedGroup),o=P.default({[s]:e.isMobile,"perseus-graded-group":!0,"answer-correct":!e.isMobile&&this.state.status===Il,"answer-incorrect":!e.isMobile&&this.state.status===Pl}),{answerBarState:i}=this.state,r="CORRECT"===i,a=e.readOnly||e.isMobile&&r;return A.createElement("div",{className:o},!!this.props.title&&A.createElement("div",{className:l.css(Ol.title)},this.props.title),A.createElement(Li,$({},this.props,{ref:"renderer",apiOptions:{...e,readOnly:a},onInteractWithWidget:this._onInteractWithWidget,linterContext:this.props.linterContext})),!e.isMobile&&n&&A.createElement("div",{className:"group-icon"},n),!e.isMobile&&t&&A.createElement("div",{className:l.css(Ma.srOnly),role:"alert","aria-label":t},t),!e.isMobile&&A.createElement("p",null,this.state.message),!e.isMobile&&A.createElement(U.default,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this._checkAnswer},I._("Check")),!e.isMobile&&r&&this.props.onNextQuestion&&A.createElement(U.default,{kind:"secondary",disabled:this.props.apiOptions.readOnly,onClick:this.props.onNextQuestion,style:{marginLeft:5}},I._("Next question")),this.props.hint&&this.props.hint.content&&(this.state.showHint?A.createElement("div",null,A.createElement("button",{tabIndex:"0",className:l.css(Ol.explanationTitle),onClick:()=>this.setState({showHint:!1}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!1})}},I._("Hide explanation")),A.createElement(Li,$({},this.props.hint,{ref:"hints-renderer",apiOptions:e,linterContext:this.props.linterContext}))):A.createElement("button",{tabIndex:"0",onClick:()=>this.setState({showHint:!0}),onKeyPress:e=>{e.preventDefault(),this.setState({showHint:!0})},className:l.css(Ol.showHintLink)},I._("Explain"))),e.isMobile&&"HIDDEN"!==i&&A.createElement(_l,{apiOptions:e,answerBarState:i,onCheckAnswer:this._checkAnswer,onNextQuestion:this.props.onNextQuestion}))}}X(Dl,"defaultProps",{title:"",content:"",widgets:{},images:{},hint:null,hasHint:!1,linterContext:Yt});const Ol=l.StyleSheet.create({gradedGroupInSet:{marginLeft:0,paddingLeft:0},gradedGroup:{borderTop:"1px solid ".concat(Q),borderBottom:"1px solid ".concat(Q),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"},showHintLink:{backgroundColor:"unset",fontSize:14,padding:0,border:"none",marginTop:20,color:"#71B307",cursor:"pointer",display:"block",clear:"both"},explanationTitle:{backgroundColor:"unset",marginTop:20,color:"#71B307",marginBottom:10,cursor:"pointer",fontSize:14,padding:0,border:"none",display:"block",clear:"both"},title:{fontSize:12,color:Q,textTransform:"uppercase",marginBottom:11,letterSpacing:.8}});var Ll={name:"graded-group",displayName:"Graded group (articles only)",widget:Dl,traverseChildWidgets:function(e,t){return N.default.extend({},e,t(e))},hidden:!1,tracking:"all",isLintable:!0};const Bl=Ll.widget;class zl extends A.Component{render(){const e=[];for(let t=0;t<this.props.numGroups;t++)e.push(A.createElement("div",{role:"button","aria-label":I._("Skip to %(title)s",{title:this.props.groupTitles[t]}),key:t,className:l.css(Wl.indicator,t===this.props.currentGroup&&Wl.selectedIndicator),onClick:()=>this.props.onChangeCurrentGroup(t)}));return A.createElement("div",{className:l.css(Wl.indicatorContainer)},e)}}class ql extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"_childGroup",void 0),X(this,"state",{currentGroup:0}),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"getInputPaths",(()=>this._childGroup.getInputPaths())),X(this,"setInputValue",((e,t,n)=>this._childGroup.setInputValue(e,t,n))),X(this,"focus",(()=>this._childGroup.focus())),X(this,"focusInputPath",(e=>{this._childGroup.focusInputPath(e)})),X(this,"blurInputPath",(e=>{this._childGroup.blurInputPath(e)})),X(this,"handleNextQuestion",(()=>{const{currentGroup:e}=this.state;e<this.props.gradedGroups.length-1&&this.setState({currentGroup:e+1})}))}shouldComponentUpdate(e,t){return e.gradedGroups,e!==this.props||t!==this.state}render(){const{JIPT:e}=le();if(e.useJIPT&&this.props.gradedGroups.length>1)return A.createElement("div",{className:l.css(Wl.container)},this.props.gradedGroups.map(((e,t)=>A.createElement(Bl,$({key:t},this.props,e,{inGradedGroupSet:!1,linterContext:this.props.linterContext})))));const t=this.props.gradedGroups[this.state.currentGroup];if(!t)return A.createElement("span",null,I.doNotTranslate("No current group..."));const n=this.props.gradedGroups.length,s=this.state.currentGroup<n-1?this.handleNextQuestion:null;return A.createElement("div",{className:l.css(Wl.container)},A.createElement("div",{className:l.css(Wl.top)},A.createElement("div",{className:l.css(Wl.title)},t.title),A.createElement("div",{className:l.css(Wl.spacer)}),A.createElement(zl,{numGroups:n,currentGroup:this.state.currentGroup,groupTitles:this.props.gradedGroups.map((e=>e.title)),onChangeCurrentGroup:e=>this.setState({currentGroup:e})})),A.createElement(Bl,$({key:this.state.currentGroup,ref:e=>this._childGroup=e},this.props,t,{inGradedGroupSet:!0,title:null,onNextQuestion:s,linterContext:this.props.linterContext})))}}X(ql,"defaultProps",{gradedGroups:[],linterContext:Yt});var Hl={name:"graded-group-set",displayName:"Graded group set (articles only)",widget:ql,traverseChildWidgets:function(e,t){return{groups:e.gradedGroups.map(t)}},hidden:!1,tracking:"all",isLintable:!0};const Wl=l.StyleSheet.create({top:{display:"flex",flexDirection:"row"},spacer:{flex:1},title:{fontSize:12,color:Q,textTransform:"uppercase",marginBottom:11,letterSpacing:.8},indicatorContainer:{display:"flex",flexDirection:"row"},indicator:{width:10,height:10,borderRadius:5,backgroundColor:"#AAAAAA",marginLeft:5,cursor:"pointer"},selectedIndicator:{backgroundColor:"#71B307"},container:{borderTop:"1px solid ".concat(Q),borderBottom:"1px solid ".concat(Q),backgroundColor:"#F9F9F9",marginLeft:-16,marginRight:-16,paddingBottom:16,paddingLeft:16,paddingRight:16,paddingTop:10,width:"auto"}});class Ul extends A.Component{constructor(){super(...arguments),X(this,"container",void 0)}componentWillUnmount(){this.container=null}focus(){if(this.container)return this.container.focus(),!0}toggleSelect(e){const t=this.props.value;this.props.allowEmpty?this.props.onChange(t!==e?e:null):this.props.onChange(e)}render(){const e=this.props.value,t=this.props.buttons.map(((t,n)=>A.createElement("button",{title:t.title,type:"button",id:""+n,ref:"button"+n,key:""+n,className:l.css(Gl.buttonStyle,t.value===e&&Gl.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)));return A.createElement("div",{style:{display:"inline-block"},ref:e=>this.container=e},t)}}X(Ul,"defaultProps",{value:null,allowEmpty:!0});const Gl=l.StyleSheet.create({buttonStyle:{backgroundColor:"white",border:"1px solid #ccc",borderLeft:"0",cursor:"pointer",margin:"0",padding:"5px 10px",position:"relative",":first-child":{borderLeft:"1px solid #ccc",borderTopLeftRadius:"3px",borderBottomLeftRadius:"3px"},":last-child":{borderRight:"1px solid #ccc",borderTopRightRadius:"3px",borderBottomRightRadius:"3px"},":hover":{backgroundColor:"#ccc"},":focus":{zIndex:2}},selectedStyle:{backgroundColor:"#ddd"}}),Vl={url:null};function jl(e){let t=e[0],n=e[1],s=e[2];const o=e[3];t<0&&(t*=-1,n*=-1,s*=-1);const i=2*Math.PI;for(n<0&&(n*=-1,s*=-1,s+=i/2);s>0;)s-=i;for(;s<0;)s+=i;return[t,n,s,o]}function Yl(e){let t=e[0],n=e[1],s=e[2];const o=e[3];t<0&&(t*=-1,n*=-1,s*=-1);const i=Math.PI;for(n<0&&(n*=-1,s*=-1,s+=i/2);s>0;)s-=i;for(;s<0;)s+=i;return[t,n,s,o]}const Xl={areEqual:function(e,t){return Be.deepEq(e,t)},Movable:Po.Plot,getPropsForCoeffs:function(e){return{fn:N.default.partial(this.getFunctionForCoeffs,e)}}},$l=N.default.extend({},Xl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/67aaf581e6d9ef9038c10558a1f70ac21c11c9f8.png",defaultCoords:[[.25,.75],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],s=n[0]-t[0],o=n[1]-t[1];if(0===s)return;const i=o/s;return[i,n[1]-i*n[0]]},getFunctionForCoeffs:function(e,t){return e[0]*t+e[1]},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],s=t[1];return"y = "+n.toFixed(3)+"x + "+s.toFixed(3)}}),Kl=N.default.extend({},Xl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/e23d36e6fc29ee37174e92c9daba2a66677128ab.png",defaultCoords:[[.5,.5],[.75,.75]],Movable:Po.Parabola,getCoefficients:function(e){const t=e[0],n=e[1],s=t[0],o=t[1],i=(n[1]-o)/((n[0]-s)*(n[0]-s));return[i,-2*s*i,i*s*s+o]},getFunctionForCoeffs:function(e,t){return(e[0]*t+e[1])*t+e[2]},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2]}},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],s=t[1],o=t[2];return"y = "+n.toFixed(3)+"x^2 + "+s.toFixed(3)+"x + "+o.toFixed(3)}}),Zl=N.default.extend({},Xl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/3d68e7718498475f53b206c2ab285626baf8857e.png",defaultCoords:[[.5,.5],[.6,.6]],Movable:Po.Sinusoid,getCoefficients:function(e){const t=e[0],n=e[1],s=n[1]-t[1],o=Math.PI/(2*(n[0]-t[0]));return[s,o,t[0]*o,t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],s=e[1],o=e[2],i=e[3];return n*Math.sin(s*t-o)+i},getPropsForCoeffs:function(e){return{a:e[0],b:e[1],c:e[2],d:e[3]}},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],s=t[1],o=t[2],i=t[3];return"y = "+n.toFixed(3)+" sin("+s.toFixed(3)+"x - "+o.toFixed(3)+") + "+i.toFixed(3)},areEqual:function(e,t){return Be.deepEq(jl(e),jl(t))}}),Jl=N.default.extend({},Xl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/7db80d23c35214f98659fe1cf0765811c1bbfbba.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],s=n[1]-t[1],o=Math.PI/(4*(n[0]-t[0]));return[s,o,t[0]*o,t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],s=e[1],o=e[2],i=e[3];return n*Math.tan(s*t-o)+i},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],s=t[1],o=t[2],i=t[3];return"y = "+n.toFixed(3)+" sin("+s.toFixed(3)+"x - "+o.toFixed(3)+") + "+i.toFixed(3)},areEqual:function(e,t){return Be.deepEq(Yl(e),Yl(t))}}),Ql=N.default.extend({},Xl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/9cbfad55525e3ce755a31a631b074670a5dad611.png",defaultCoords:[[.5,.55],[.75,.75]],defaultAsymptote:[[0,.5],[1,.5]],extraCoordConstraint:function(e,t,n,s,o){const i=N.default.head(s)[1];return N.default.all(n,(e=>e[1]!==i))},extraAsymptoteConstraint:function(e,t,n,s,o){const i=e[1];if(N.default.all(n,(e=>e[1]>i))||N.default.all(n,(e=>e[1]<i)))return[t[0],i];const r=t[1];if(N.default.all(n,(e=>e[1]>r))){const e=N.default.min(N.default.map(n,(e=>e[1])));return[t[0],e-o.snapStep[1]]}const a=N.default.max(N.default.map(n,(e=>e[1])));return[t[0],a+o.snapStep[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){const n=e[0],s=e[1],o=N.default.head(t)[1],i=Math.log((n[1]-o)/(s[1]-o))/(n[0]-s[0]);return[(n[1]-o)/Math.exp(i*n[0]),i,o]},getFunctionForCoeffs:function(e,t){const n=e[0],s=e[1],o=e[2];return n*Math.exp(s*t)+o},getEquationString:function(e,t){if(!t)return null;const n=this.getCoefficients(e,t),s=n[0],o=n[1],i=n[2];return"y = "+s.toFixed(3)+"e^("+o.toFixed(3)+"x) + "+i.toFixed(3)}}),ec=N.default.extend({},Xl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/f6491e99d34af34d924bfe0231728ad912068dc3.png",defaultCoords:[[.55,.5],[.75,.75]],defaultAsymptote:[[.5,0],[.5,1]],extraCoordConstraint:function(e,t,n,s,o){const i=N.default.head(s)[0];return N.default.all(n,(e=>e[0]!==i))&&n[0][1]!==n[1][1]},extraAsymptoteConstraint:function(e,t,n,s,o){const i=e[0];if(N.default.all(n,(e=>e[0]>i))||N.default.all(n,(e=>e[0]<i)))return[i,t[1]];const r=t[0];if(N.default.all(n,(e=>e[0]>r))){return[N.default.min(N.default.map(n,(e=>e[0])))-o.snapStep[0],t[1]]}return[N.default.max(N.default.map(n,(e=>e[0])))+o.snapStep[0],t[1]]},allowReflectOverAsymptote:!0,getCoefficients:function(e,t){const n=e=>[e[1],e[0]],s=Ql.getCoefficients(N.default.map(e,n),N.default.map(t,n)),o=-s[2]/s[0],i=1/s[0];return[1/s[1],i,o]},getFunctionForCoeffs:function(e,t,n){const s=e[0],o=e[1],i=e[2];return s*Math.log(o*t+i)},getEquationString:function(e,t){if(!t)return null;const n=this.getCoefficients(e,t),s=n[0],o=n[1],i=n[2];return"y = ln("+s.toFixed(3)+"x + "+o.toFixed(3)+") + "+i.toFixed(3)}}),tc=N.default.extend({},Xl,{url:"https://ka-perseus-graphie.s3.amazonaws.com/8256a630175a0cb1d11de223d6de0266daf98721.png",defaultCoords:[[.5,.5],[.75,.75]],getCoefficients:function(e){const t=e[0],n=e[1],s=n[0]-t[0],o=n[1]-t[1];if(0===s)return;let i=Math.abs(o/s);n[1]<t[1]&&(i*=-1);return[i,t[0],t[1]]},getFunctionForCoeffs:function(e,t){const n=e[0],s=e[1],o=e[2];return n*Math.abs(t-s)+o},getEquationString:function(e){const t=this.getCoefficients(e),n=t[0],s=t[1],o=t[2];return"y = "+n.toFixed(3)+"| x - "+s.toFixed(3)+"| + "+o.toFixed(3)}}),nc={linear:$l,quadratic:Kl,sinusoid:Zl,tangent:Jl,exponential:Ql,logarithm:ec,absolute_value:tc},sc=N.default.keys(nc);function oc(e){return nc[e]}const ic=(e,t)=>{if(e.type!==t.correct.type)return{type:"points",earned:0,total:1,message:null};if(null==e.coords)return{type:"invalid",message:null};const n=oc(e.type),s=n.getCoefficients(e.coords,e.asymptote),o=n.getCoefficients(t.correct.coords,t.correct.asymptote);return null==s||null==o?{type:"invalid",message:null}:n.areEqual(s,o)?{type:"points",earned:1,total:1,message:null}:{type:"points",earned:0,total:1,message:null}},rc=(e,t,n,s)=>e.map((e=>{const o=e.map(((e,s)=>{const o=t[s],i=n[s],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(o,i),a=Math.round(e*r);return o[0]+i*a}));return d.point.roundTo(o,s)})),ac=(e,t,n,s)=>e?rc(e,t,n,s):e,lc=(e,t)=>{const n=oc(e),s=Be.snapStepFromGridStep([1,1]);return{type:e,asymptote:ac(n.defaultAsymptote,t.range,t.step,s),coords:null}},cc=N.default.first,pc=(e,t)=>{const n=e.gridStep||Be.getGridStep(e.range,e.step,t);return{gridStep:n,snapStep:e.snapStep||Be.snapStepFromGridStep(n)}},dc={labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:Vl,markings:"graph",rulerLabel:"",rulerTicks:10,valid:!0,showTooltips:!1},hc=lc("linear",dc),uc={graph:dc,plot:hc,availableTypes:[hc.type]},fc=e=>{const t=e.charAt(0).toUpperCase()+e.substring(1),n=le().staticUrl;return{value:e,title:t,content:A.createElement("img",{src:n(oc(e).url),alt:t})}};var mc=Object.freeze({__proto__:null,DEFAULT_BACKGROUND_IMAGE:Vl,allTypes:sc,functionForType:oc,validate:ic,getEquationString:e=>{const t=e.plot;if(t.type&&t.coords){return oc(t.type).getEquationString(t.coords,t.asymptote)||""}return""},pointsFromNormalized:rc,maybePointsFromNormalized:ac,defaultPlotProps:lc,chooseType:cc,getGridAndSnapSteps:pc,DEFAULT_GRAPHER_PROPS:uc,typeToButton:fc});const gc=Po.MovablePoint,vc=Po.MovableLine;const bc={padding:"5px 5px"};class yc extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"_coords",(()=>{const e=this.props,t=e.graph,n=e.model&&ac(e.model.defaultCoords,t.range,t.step,t.snapStep);return e.coords||n||null})),X(this,"_asymptote",(()=>this.props.asymptote)),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"renderPlot",(()=>{const e=this.props.model,t=this.props.graph.range[0],n={stroke:this.props.isMobile?gn.BLUE_C:gn.DYNAMIC,...this.props.isMobile?{"stroke-width":3}:{}},s=e.getCoefficients(this._coords(),this._asymptote());if(!s)return;const o=e.getPropsForCoeffs(s,t);return A.createElement(e.Movable,$({},o,{key:this.props.model.url,range:t,style:n}))})),X(this,"renderAsymptote",(()=>{const e=this.props.model,t=this.props.graph,n=this._asymptote(),s={strokeDasharray:"- "};return n&&A.createElement(vc,{onMove:(e,t)=>{const n=d.vector.subtract(e,t),s=N.default.map(this._asymptote(),(e=>d.vector.add(e,n)));this.props.onChange({asymptote:s})},constraints:[uo.MovableLine.constraints.bound(),uo.MovableLine.constraints.snap(),(n,s)=>{const o=d.vector.subtract(n,s),i=N.default.map(this._asymptote(),(e=>d.vector.add(e,o)));return!e.extraAsymptoteConstraint||e.extraAsymptoteConstraint(n,s,this._coords(),i,t)}],normalStyle:s,highlightStyle:s},N.default.map(n,((e,t)=>A.createElement(gc,{key:"asymptoteCoord-".concat(t),coord:e,static:!0,draw:null,extendLine:!0,showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))))}))}render(){const e=N.default.map(this._coords(),((e,t)=>A.createElement(gc,{key:t,coord:e,static:this.props.static,constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),e=>{const n=N.default.all(this._coords(),((n,s)=>t===s||!n||!d.number.equal(e[0],n[0])));if(!n)return!1;if(this.props.model&&this.props.model.extraCoordConstraint){const n=this.props.model.extraCoordConstraint,s=N.default.clone(this._coords()),o=N.default.clone(s[t]);return s[t]=e,n(e,o,s,this._asymptote(),this.props.graph)}return n}],onMove:(e,n)=>{let s;const o=this._asymptote();s=o&&this.props.model.allowReflectOverAsymptote&&function(e,t,n){const s=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1]);return s(n[0],n[1],t)>0!=s(n[0],n[1],e)>0}(e,n,o)?N.default.map(this._coords(),(e=>d.point.reflectOverLine(e,o))):N.default.clone(this._coords()),s[t]=e,this.props.onChange({coords:s})},showHairlines:this.props.showHairlines,hideHairlines:this.props.hideHairlines,showTooltips:this.props.showTooltips,isMobile:this.props.isMobile}))),t=this.props.graph.box,n=this.props.graph.backgroundImage;let s=null;if(n.url){const e=t[0]/ne.defaultBoxSize;s=A.createElement(Go,{src:n.url,width:n.width,height:n.height,scale:e})}return A.createElement("div",{className:"perseus-widget perseus-widget-grapher",style:{width:t[0],height:t[1],boxSizing:"initial"}},A.createElement("div",{className:"graphie-container above-scratchpad",style:{width:t[0],height:t[1]}},s,A.createElement(Po,$({},this.props.graph,{setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this.props.model&&this.renderPlot(),this.props.model&&this.renderAsymptote(),this.props.model&&e)))}}X(yc,"defaultProps",{graph:{range:[[-10,10],[-10,10]],step:[1,1]},coords:null,asymptote:null,isMobile:!1});class xc extends A.Component{constructor(){super(...arguments),X(this,"horizHairline",void 0),X(this,"vertHairline",void 0),X(this,"handlePlotChanges",(e=>{const t=N.default.extend({},this.props.plot,e);this.props.onChange({plot:t}),this.props.trackInteraction()})),X(this,"handleActiveTypeChange",(e=>{const t=this.props.graph,n=N.default.extend({},this.props.plot,lc(e,t));this.props.onChange({plot:n})})),X(this,"_setupGraphie",((e,t)=>{const n=this.props.apiOptions.isMobile;if("graph"===t.markings?(e.graphInit({range:t.range,scale:N.default.pluck(t.gridConfig,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:t.gridStep,snapStep:t.snapStep,tickStep:n?this._calculateMobileTickStep(t.gridStep,t.step,t.range):N.default.pluck(t.gridConfig,"tickStep"),labelStep:1,unityLabels:N.default.pluck(t.gridConfig,"unityLabel"),isMobile:n}),e.label([0,t.range[1][1]],t.labels[1],n?"below right":"above"),e.label([t.range[0][1],0],t.labels[0],n?"above left":"right")):"grid"===t.markings?e.graphInit({range:t.range,scale:N.default.pluck(t.gridConfig,"scale"),gridStep:t.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:n}):"none"===t.markings&&e.init({range:t.range,scale:N.default.pluck(t.gridConfig,"scale")}),this.props.apiOptions.isMobile){const t={normalStyle:{strokeWidth:1}};this.horizHairline=new An(e,[0,0],[0,0],t),this.horizHairline.attr({stroke:gn.INTERACTIVE}),this.horizHairline.hide(),this.vertHairline=new An(e,[0,0],[0,0],t),this.vertHairline.attr({stroke:gn.INTERACTIVE}),this.vertHairline.hide()}})),X(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.props.graph.range[0][0],e[1]],[this.props.graph.range[0][1],e[1]]),this.horizHairline.show(),this.vertHairline.moveTo([e[0],this.props.graph.range[1][0]],[e[0],this.props.graph.range[1][1]]),this.vertHairline.show())})),X(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&(this.horizHairline.hide(),this.vertHairline.hide())}))}render(){const e=this.props.plot.type,t=this.props.plot.coords,n=this.props.plot.asymptote,s=A.createElement("div",{style:bc,className:"above-scratchpad"},A.createElement(Ul,{value:e,allowEmpty:!0,buttons:N.default.map(this.props.availableTypes,fc),onChange:this.handleActiveTypeChange})),o=li(this.props.containerSizeClass),i={...this.props.graph,...pc(this.props.graph,o[0]),gridConfig:this._getGridConfig({...this.props.graph,box:o,...pc(this.props.graph,o[0])})},r={graph:{box:o,range:i.range,step:i.step,snapStep:i.snapStep,backgroundImage:i.backgroundImage,options:i,setup:this._setupGraphie},onChange:this.handlePlotChanges,model:e&&oc(e),coords:t,asymptote:n,static:this.props.static,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile,showTooltips:this.props.graph.showTooltips,showHairlines:this.showHairlines,hideHairlines:this.hideHairlines};return A.createElement("div",null,A.createElement(yc,r),this.props.availableTypes.length>1&&s)}_getGridConfig(e){return e.step.map(((t,n)=>Be.gridDimensionConfig(t,e.range[n],e.box[n],e.gridStep[n])))}_calculateMobileTickStep(e,t,n){const s=Be.constrainedTickStepsFromTickSteps(t,n);return s[0]=s[0]/e[0],s[1]=s[1]/e[1],s}simpleValidate(e){return ic(this.getUserInput(),e)}getUserInput(){return xc.getUserInputFromProps(this.props)}focus(){}static validate(e,t){return ic(e,t)}static getUserInputFromProps(e){return e.plot}}X(xc,"defaultProps",uc);const Cc=e=>{const t={availableTypes:e.availableTypes,graph:e.graph};if(1===t.availableTypes.length){const e=t.graph,n=cc(t.availableTypes);t.plot=lc(n,e)}return t};var wc={name:"grapher",displayName:"Grapher",widget:xc,transform:Cc,staticTransform:e=>({...Cc(e),availableTypes:[e.correct.type],plot:e.correct})};class kc extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"getUserInput",(()=>this.refs.renderer.getUserInput())),X(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),X(this,"restoreSerializedState",((e,t)=>(this.refs.renderer.restoreSerializedState(e,t),null))),X(this,"simpleValidate",(e=>this.refs.renderer.score())),X(this,"getInputPaths",(()=>this.refs.renderer.getInputPaths())),X(this,"setInputValue",((e,t,n)=>this.refs.renderer.setInputValue(e,t,n))),X(this,"focus",(()=>this.refs.renderer.focus())),X(this,"focusInputPath",(e=>{this.refs.renderer.focusPath(e)})),X(this,"blurInputPath",(e=>{this.refs.renderer.blurPath(e)})),X(this,"showRationalesForCurrentlySelectedChoices",(()=>{this.refs.renderer.showRationalesForCurrentlySelectedChoices()}))}componentDidMount(){this.forceUpdate()}render(){const e=N.default.extend({},Qt.defaults,this.props.apiOptions,{onFocusChange:(e,t)=>{t&&this.props.onBlur(t),e&&this.props.onFocus(e)}}),t=N.default.indexOf(this.props.findWidgets("group"),this),n=this.props.apiOptions.groupAnnotator(t,this.props.widgetId),s=this.refs.renderer&&this.refs.renderer.score(),o=s&&"invalid"!==s.type,i=s&&"invalid"===s.type;return A.createElement("div",{className:P.default({"perseus-group":!0,"perseus-group-valid-answer":o,"perseus-group-invalid-answer":i})},n,A.createElement(Li,$({},this.props,{ref:"renderer",apiOptions:e,findExternalWidgets:this.props.findWidgets,reviewMode:!!this.props.reviewModeRubric,onInteractWithWidget:e=>{this.refs.renderer&&this.change("widgets",this.refs.renderer.props.widgets)},linterContext:this.props.linterContext})),this.props.icon&&A.createElement("div",{className:"group-icon"},this.props.icon))}}X(kc,"defaultProps",{content:"",widgets:{},images:{},linterContext:Yt});var Sc={name:"group",displayName:"Group (SAT only)",widget:kc,traverseChildWidgets:function(e,t){return N.default.extend({},e,t(e))},hidden:!1,isLintable:!0};const{updateQueryString:Ec}=Be;class _c extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"getUserInput",(()=>Dr.getUserInput.call(this))),X(this,"handleMessageEvent",(e=>{let t={};try{t=JSON.parse(e.originalEvent.data)}catch(e){return}if(N.default.isUndefined(t.testsPassed))return;const n=t.testsPassed?"correct":"incorrect";this.change({status:n,message:t.message})})),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"simpleValidate",(e=>_c.validate(this.getUserInput(),e)))}componentDidMount(){L.default(window).on("message",this.handleMessageEvent)}componentWillUnmount(){L.default(window).off("message",this.handleMessageEvent)}render(){const e={width:String(this.props.width),height:String(this.props.height)},{InitialRequestUrl:t}=le();Object.entries(e).forEach((t=>{let[n,s]=t;s.endsWith("%")||s.endsWith("px")||(e[n]=s+"px")}));let n=this.props.url;if(n&&n.length&&0!==n.indexOf("http")&&(n="https://www.khanacademy.org/computer-programming/program/"+n+"/embedded?buttons=no&embed=yes&editor=no&author=no",n=Ec(n,"width",this.props.width),n=Ec(n,"height",this.props.height),n=Ec(n,"origin",t.origin)),this.props.settings){const e={};N.default.each(this.props.settings,(function(t){t.name&&t.value&&(e[t.name]=t.value)})),n=Ec(n,"settings",JSON.stringify(e))}let s="allow-same-origin allow-scripts";return s+=" allow-top-navigation",A.createElement("iframe",{sandbox:"allow-same-origin allow-scripts allow-top-navigation",style:e,src:n,allowFullScreen:this.props.allowFullScreen})}}X(_c,"propTypes",{...fr,width:R.default.oneOfType([R.default.string,R.default.number]),height:R.default.oneOfType([R.default.string,R.default.number]),url:R.default.string,settings:R.default.array,status:R.default.oneOf(["incomplete","incorrect","correct"]),message:R.default.string,allowFullScreen:R.default.bool,allowTopNavigation:R.default.bool}),X(_c,"defaultProps",{status:"incomplete",message:null,allowFullScreen:!1,allowTopNavigation:!1}),N.default.extend(_c,{validate:function(e,t){return"correct"===e.status?{type:"points",earned:1,total:1,message:e.message||null}:"incorrect"===e.status?{type:"points",earned:0,total:1,message:e.message||null}:{type:"invalid",message:"Keep going, you're not there yet!"}}});var Mc={name:"iframe",displayName:"Iframe",widget:_c,hidden:!0};const Tc=[0,10];class Ic extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"getUserInput",(()=>null)),X(this,"simpleValidate",(e=>Ic.validate(this.getUserInput(),e))),X(this,"focus",(()=>{}))}render(){let e,t;const{apiOptions:n}=this.props,s=this.props.backgroundImage;if(s.url&&(e=A.createElement(Go,{src:s.url,alt:this.props.alt,overrideAriaHidden:!0,width:s.width,height:s.height,preloader:n.imagePreloader,extraGraphie:{box:this.props.box,range:this.props.range,labels:this.props.labels},trackInteraction:this.props.trackInteraction,zoomToFullSizeOnMobile:n.isMobile,constrainHeight:n.isMobile,allowFullBleed:n.isMobile})),this.props.alt&&(t=A.createElement("span",{className:"perseus-sr-only"},A.createElement(Li,{content:this.props.alt,apiOptions:n,linterContext:this.props.linterContext}))),n.isMobile){let s;if(this.props.title||this.props.caption){let e=this.props.title;e&&(this.props.caption&&!/[.?!"']\s*$/.test(e)&&(e+="."),e="**".concat(e,"** "));const t=P.default({"perseus-image-caption":!0,"has-title":!!e}),o=this.props.alignment,i="block"===o||"full-width"===o?null:"0 !important";s=A.createElement("div",{className:t},A.createElement("div",{className:l.css(Pc.caption),style:{minWidth:i}},A.createElement(Li,{content:e+this.props.caption,apiOptions:n,linterContext:this.props.linterContext})))}return A.createElement("div",{className:"perseus-image-widget"},e,t,s)}let o,i;return this.props.title&&(o=A.createElement("div",{className:"perseus-image-title"},A.createElement(Li,{content:this.props.title,apiOptions:n,linterContext:this.props.linterContext}))),this.props.caption&&(i=A.createElement("div",{className:"perseus-image-caption"},A.createElement(Li,{content:this.props.caption,apiOptions:n,linterContext:this.props.linterContext}))),A.createElement("div",{className:"perseus-image-widget"},o,e,t,i)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}X(Ic,"defaultProps",{alignment:"block",title:"",range:[Tc,Tc],box:[400,400],backgroundImage:{url:null,width:0,height:0},labels:[],alt:"",caption:"",linterContext:Yt});const Pc=l.StyleSheet.create({caption:{display:"inline-block",marginTop:16,maxWidth:640,[jr.lgOrSmaller]:{maxWidth:540},[jr.smOrSmaller]:{maxWidth:450}}});var Ac={name:"image",accessible:e=>{const t=e.backgroundImage;return!(t&&t.url&&!e.alt)},defaultAlignment:"block",supportedAlignments:["block","full-width"],displayName:"Image",widget:Ic,isLintable:!0};const Nc=Po.Label,Rc=Po.Line,Fc=Po.MovablePoint,Dc=Po.MovableLine,Oc=Po.Plot,Lc=Po.PlotParametric,Bc=Po.Point,zc=Po.Rect,{unescapeMathMode:qc}=Be,Hc=(e,t)=>{let n=e+"||"+(t=t||{}).decimal_separator+"||";const s=t.functions,o=s?s.length:0;for(let e=0;e<o;e++)n+=s[e]+"|";return n},Wc=Object.create(null),Uc=(e,t)=>{const n=Hc(e,t);let s=Wc[n];return s||(s=T.parse(e,t),Wc[n]=s,s)},Gc=Object.create(null),Vc=(e,t)=>{const n=Hc(e,t);let s=Gc[n];if(s)return s;const o=T.parse(e,t).expr;return s=o?o.compile():function(){return 0},Gc[n]=s,s};class jc extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"state",{variables:Yc(this.props.elements),functions:Xc(this.props.elements)}),X(this,"_setupGraphie",((e,t)=>{e.graphInit(N.default.extend({},t,{grid:N.default.contains(["graph","grid"],this.props.graph.markings),axes:N.default.contains(["graph"],this.props.graph.markings),ticks:N.default.contains(["graph"],this.props.graph.markings),labels:N.default.contains(["graph"],this.props.graph.markings),labelFormat:function(e){return"\\small{"+e+"}"},axisArrows:"<->",unityLabels:!1}))})),X(this,"_updatePointLocation",((e,t)=>{const n=N.default.clone(this.state.variables);n["x_"+e]=t[0],n["y_"+e]=t[1],this.setState({variables:n}),this.props.trackInteraction()})),X(this,"_updateLineLocation",((e,t)=>{const n=this._eval("("+e.endX+")-("+e.startX+")"),s=this._eval("("+e.endY+")-("+e.startY+")"),o=d.vector.add(t,[n,s]),i=N.default.clone(this.state.variables);i["x_"+e.startSubscript]=t[0],i["y_"+e.startSubscript]=t[1],i["x_"+e.endSubscript]=o[0],i["y_"+e.endSubscript]=o[1],this.setState({variables:i}),this.props.trackInteraction()})),X(this,"_eval",((e,t)=>{const n=Vc(e,{functions:this.state.functions}),s=N.default.extend({},this.state.variables,t);return N.default.each(N.default.keys(s),(e=>{if(N.default.isString(s[e])){const t=Vc(s[e],{functions:this.state.functions});s[e]=function(e){return t(N.default.extend({},s,{x:e}))}}})),n(s)||0})),X(this,"_extractVars",(e=>{if(null==e)return[];let t=[];return N.default.each(e.args(),(function(e){e&&"Expr"===e.constructor.name&&(t=t.concat(this._extractVars(e)))}),this),"Var"===e.name()&&t.push(e.prettyPrint()),t})),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"getUserInput",(()=>({}))),X(this,"simpleValidate",(e=>jc.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){N.default.isEqual(this.props.elements,e.elements)||this.setState({variables:Yc(e.elements),functions:Xc(e.elements)})}render(){const e=this.props.graph.range;let t=this.props.graph.labels;return"graph"===this.props.graph.markings&&(t=this.props.graph.labels.map((e=>e.startsWith("$")&&e.endsWith("$")?e.slice(1,-1):e))),A.createElement(Po,{box:this.props.graph.box,range:this.props.graph.range,options:this.props.graph,setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable},"graph"===this.props.graph.markings&&A.createElement(Nc,{coord:[0,e[1][1]],text:t[1],direction:"above"}),"graph"===this.props.graph.markings&&A.createElement(Nc,{coord:[e[0][1],0],text:t[0],direction:"right"}),N.default.map(this.props.elements,(function(e,t){if("point"===e.type)return A.createElement(Bc,{key:e.key,coord:[this._eval(e.options.coordX),this._eval(e.options.coordY)],color:e.options.color});if("line"===e.type){const t=[this._eval(e.options.startX),this._eval(e.options.startY)],n=[this._eval(e.options.endX),this._eval(e.options.endY)];return A.createElement(Rc,{key:e.key,start:t,end:n,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,arrows:e.options.arrows}})}if("movable-point"===e.type){const t=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];return"snap"===e.options.constraint?t.push(Fc.constraints.snap(e.options.snap)):"x"===e.options.constraint?t.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&t.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})])),A.createElement(Fc,{key:e.key,coord:[this.state.variables["x_"+e.options.varSubscript],this.state.variables["y_"+e.options.varSubscript]],constraints:t,foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap,onMove:N.default.partial(this._updatePointLocation,e.options.varSubscript)})}if("movable-line"===e.type){const t=[t=>[Math.max(this._eval(e.options.constraintXMin),Math.min(this._eval(e.options.constraintXMax),t[0])),Math.max(this._eval(e.options.constraintYMin),Math.min(this._eval(e.options.constraintYMax),t[1]))]];"snap"===e.options.constraint?t.push(Fc.constraints.snap(e.options.snap)):"x"===e.options.constraint?t.push((t=>[this._eval(e.options.constraintFn,{y:t[1]}),t[1]])):"y"===e.options.constraint&&t.push((t=>[t[0],this._eval(e.options.constraintFn,{x:t[0]})]));const n=[this.state.variables["x_"+e.options.startSubscript],this.state.variables["y_"+e.options.startSubscript]],s=[this.state.variables["x_"+e.options.endSubscript],this.state.variables["y_"+e.options.endSubscript]];return A.createElement(Dc,{key:e.key,constraints:t,onMove:N.default.bind(this._updateLineLocation,this,e.options),foo_x:e.options.constraint,foo_y:e.options.constraintFn,foo_z:e.options.snap},A.createElement(Fc,{coord:n,static:!0,normalStyle:{stroke:"none",fill:"none"}}),A.createElement(Fc,{coord:s,static:!0,normalStyle:{stroke:"none",fill:"none"}}))}if("function"===e.type){const t=t=>this._eval(e.options.value,{x:t}),n=N.default.without(this._extractVars(Uc(e.options.value).expr),"x"),s=N.default.object(n,N.default.map(n,(e=>this.state.variables[e]))),o=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return A.createElement(Oc,{key:e.key,fn:t,foo_fn:e.options.value,foo_varvalues:s,range:o,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("parametric"===e.type){const t=t=>[this._eval(e.options.x,{t:t}),this._eval(e.options.y,{t:t})],n=N.default.without(this._extractVars(Uc(e.options.x).expr).concat(this._extractVars(Uc(e.options.y).expr)),"t"),s=N.default.object(n,N.default.map(n,(e=>this.state.variables[e]))),o=[this._eval(e.options.rangeMin,this.state.variables),this._eval(e.options.rangeMax,this.state.variables)];return A.createElement(Lc,{key:e.key,fn:t,foo_fnx:e.options.x,foo_fny:e.options.y,foo_varvalues:s,range:o,style:{stroke:e.options.color,strokeWidth:e.options.strokeWidth,strokeDasharray:e.options.strokeDasharray,plotPoints:100}})}if("label"===e.type){const n=[this._eval(e.options.coordX),this._eval(e.options.coordY)];return A.createElement(Nc,{key:t+1,coord:n,text:qc(e.options.label),style:{color:e.options.color}})}return"rectangle"===e.type?A.createElement(zc,{key:t+1,x:this._eval(e.options.coordX),y:this._eval(e.options.coordY),width:N.default.max([this._eval(e.options.width),0]),height:N.default.max([this._eval(e.options.height),0]),style:{stroke:"none",fill:e.options.color}}):void 0}),this))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}}X(jc,"defaultProps",{graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]});const Yc=e=>{const t={};return N.default.each(N.default.where(e,{type:"movable-point"}),(e=>{const n=e.options.varSubscript,s=Uc(e.options.startX||"0").expr,o=Uc(e.options.startY||"0").expr;let i=0,r=0;s&&(i=s.eval({})||0),o&&(r=o.eval({})||0),t["x_"+n]=i,t["y_"+n]=r})),N.default.each(N.default.where(e,{type:"movable-line"}),(e=>{const n=e.options.startSubscript,s=e.options.endSubscript,o=Uc(e.options.startX||"0").expr,i=Uc(e.options.startY||"0").expr,r=Uc(e.options.endX||"0").expr,a=Uc(e.options.endY||"0").expr;let l=0,c=0,p=0,d=0;o&&(l=o.eval({})||0),i&&(c=i.eval({})||0),r&&(p=r.eval({})||0),a&&(d=a.eval({})||0),t["x_"+n]=l,t["y_"+n]=c,t["x_"+s]=p,t["y_"+s]=d})),N.default.each(N.default.where(e,{type:"function"}),(e=>{t[e.options.funcName]=e.options.value})),t},Xc=e=>N.default.map(N.default.where(e,{type:"function"}),(e=>e.options.funcName));var $c={name:"interaction",displayName:"Interaction",widget:jc,transform:N.default.identity,hidden:!0};const Kc={fontStyle:"italic",fontWeight:"bold",fontSize:"32px",width:"100%",height:"100%",textAlign:"center",backgroundColor:"white",position:"absolute",zIndex:1,transition:"opacity .25s ease-in-out","-moz-transition":"opacity .25s ease-in-out","-webkit-transition":"opacity .25s ease-in-out"},Zc={position:"relative",top:"25%"};class Jc extends A.Component{constructor(){super(...arguments),X(this,"protractor",void 0),X(this,"ruler",void 0),X(this,"_graphie",void 0),X(this,"_hasSetupGraphieThisUpdate",void 0),X(this,"_shouldSetupGraphie",void 0),X(this,"reset",(()=>{this._setupGraphie(!1)})),X(this,"graphie",(()=>this._graphie)),X(this,"pointsFromNormalized",((e,t)=>{const n=this;return N.default.map(e,(function(e){return N.default.map(e,(function(e,s){const o=n.props.range[s];if(t)return o[0]+(o[1]-o[0])*e;const i=n.props.step[s],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(o,i),a=Math.round(e*r);return o[0]+i*a}))}))})),X(this,"_setupGraphie",(e=>{if(this._hasSetupGraphieThisUpdate)return;const t=D.default.findDOMNode(this.refs.graphieDiv);L.default(t).empty();const n=this.props.labels.map((e=>Be.unescapeMathMode(e))),s=this.props.range,o=this._graphie=wn.createGraphie(t),i=this._getGridConfig();o.snap=this.props.snapStep,"graph"===this.props.markings?(o.graphInit({range:s,scale:N.default.pluck(i,"scale"),axisArrows:"<->",labelFormat:function(e){return"\\small{"+e+"}"},gridStep:this.props.gridStep,tickStep:N.default.pluck(i,"tickStep"),labelStep:1,unityLabels:N.default.pluck(i,"unityLabel"),isMobile:this.props.isMobile}),o.label([0,s[1][1]],n[1],this.props.isMobile?"below right":"above"),o.label([s[0][1],0],n[0],this.props.isMobile?"above left":"right")):"grid"===this.props.markings?o.graphInit({range:s,scale:N.default.pluck(i,"scale"),gridStep:this.props.gridStep,axes:!1,ticks:!1,labels:!1,isMobile:this.props.isMobile}):"none"===this.props.markings&&o.init({range:s,scale:N.default.pluck(i,"scale"),isMobile:this.props.isMobile});let r;if(this.props.instructions){r=L.default("<div/>"),N.default.each(Kc,(function(e,t){r.css(t,e)})),r.css("opacity",.5);const e=L.default("<span/>",{text:this.props.instructions});N.default.each(Zc,(function(t,n){e.css(n,t)})),r.append(e),L.default(t).append(r)}else r=void 0;const a=r||this.props.onMouseDown?N.default.bind((function(e){r&&(r.remove(),r=null),this.props.onMouseDown(e)}),this):null,l=r?function(){r&&r.css("opacity",0)}:null,c=r?function(){r&&r.css("opacity",.5)}:null;o.addMouseLayer({onClick:this.props.onClick,onMouseDown:a,onMouseOver:l,onMouseOut:c,onMouseUp:this.props.onMouseUp,onMouseMove:this.props.onMouseMove,allowScratchpad:!0,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable}),this._updateProtractor(),this._updateRuler(),this._hasSetupGraphieThisUpdate=!0,!e&&this.props.onGraphieUpdated&&this.props.onGraphieUpdated(o)})),X(this,"_getGridConfig",(()=>{const e=this;return N.default.map(e.props.step,(function(t,n){return Be.gridDimensionConfig(t,e.props.range[n],e.props.box[n],e.props.gridStep[n])}))})),X(this,"_updateProtractor",(()=>{if(this.protractor&&this.protractor.remove(),this.props.showProtractor){const e=this.pointsFromNormalized([[.5,.05]])[0];this.protractor=this._graphie.protractor(e)}})),X(this,"_updateRuler",(()=>{if(this.ruler&&this.ruler.remove(),this.props.showRuler){const e=this.pointsFromNormalized([[.5,.25]])[0],t=this._graphie.range[0][1]-this._graphie.range[0][0];this.ruler=this._graphie.ruler({center:e,label:this.props.rulerLabel,pixelsPerUnit:this._graphie.scale[0],ticksPerUnit:this.props.rulerTicks,units:Math.round(.8*t)})}})),X(this,"toJSON",(()=>N.default.pick(this.props,"range","step","markings","labels","backgroundImage","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep")))}render(){let e;const t=this.props.backgroundImage;if(t.url){const n=this.props.box[0]/ne.defaultBoxSize;e=A.createElement(Go,{src:t.url,width:t.width,height:t.height,scale:n,responsive:!1})}else e=null;return A.createElement("div",{className:"graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]},onMouseOut:this.onMouseOut,onMouseOver:this.onMouseOver,onClick:this.onClick},e,A.createElement("div",{className:"graphie",ref:"graphieDiv"}))}componentDidMount(){this._setupGraphie(!0)}componentDidUpdate(){this._hasSetupGraphieThisUpdate=!1,this._shouldSetupGraphie&&(this._setupGraphie(!1),this._shouldSetupGraphie=!1)}UNSAFE_componentWillReceiveProps(e){const t=this;N.default.each(["labels","range","step","markings","showProtractor","showRuler","rulerLabel","rulerTicks","gridStep","snapStep"],(function(n){N.default.isEqual(t.props[n],e[n])||(t._shouldSetupGraphie=!0)}))}}X(Jc,"propTypes",{box:R.default.array.isRequired,labels:R.default.arrayOf(R.default.string),range:R.default.arrayOf(R.default.arrayOf(R.default.number)),step:R.default.arrayOf(R.default.number),gridStep:R.default.arrayOf(R.default.number),snapStep:R.default.arrayOf(R.default.number),markings:R.default.string,backgroundImage:R.default.shape({url:R.default.string}),showProtractor:R.default.bool,showRuler:R.default.bool,rulerLabel:R.default.string,rulerTicks:R.default.number,onGraphieUpdated:R.default.func,instructions:R.default.string,onClick:R.default.func,setDrawingAreaAvailable:R.default.func,isMobile:R.default.bool}),X(Jc,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],gridStep:[1,1],snapStep:[.5,.5],markings:"graph",backgroundImage:{url:null},showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,instructions:null,onGraphieUpdated:null,onClick:null,onMouseDown:null,isMobile:!1});const{DeprecationMixin:Qc}=Be,ep=Be.eq,tp=Be.deepEq;function np(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])}function sp(e,t,n){return ep(np(e,t,n),0)}function op(e){return ep(e,0)?0:e>0?1:-1}function ip(e,t,n){return n[0]<=Math.max(e[0],t[0])&&n[0]>=Math.min(e[0],t[0])&&n[1]<=Math.max(e[1],t[1])&&n[1]>=Math.min(e[1],t[1])}function rp(e,t){const n=[[e[0],e[1],t[0]],[e[0],e[1],t[1]],[t[0],t[1],e[0]],[t[0],t[1],e[1]]],s=N.default.map(n,(function(e){return op(np(...e))}));if(s[0]!==s[1]&&s[2]!==s[3])return!0;for(let e=0;e<4;e++)if(0===s[e]&&ip(...n[e]))return!0;return!1}function ap(e,t){return N.default.map(N.default.zip(e,t),(function(e){return e[0]-e[1]}))}function lp(e){return Math.sqrt(N.default.reduce(e,(function(e,t){return e+Math.pow(t,2)}),0))}function cp(e){return N.default.zip(e,fp(e)).map((function(e){return lp(ap(...e))}))}function pp(e){const t=N.default.zip(fp(e,-1),e,fp(e,1)),n=N.default.map(t,(function(e){const t=ap(e[1],e[0]),n=ap(e[2],e[1]),s=Math.acos((o=t,i=n,N.default.reduce(N.default.zip(o,i),(function(e,t){return e+t[0]*t[1]}),0)/(lp(t)*lp(n))));var o,i;return op(np(...e))>0?s:-s})),s=N.default.reduce(n,(function(e,t){return e+t}),0);return N.default.map(n,(function(e){return s>0?Math.PI-e:Math.PI+e}))}function dp(e,t,n){if(e.length!==t.length)return!1;const s=e.length,o=pp(e),i=pp(t),r=cp(e),a=cp(t);for(let e=0;e<2*s;e++){let t=i.slice(),l=a.slice();if(e>=s&&(t.reverse(),l.reverse(),l=fp(l,1)),t=fp(t,e),l=fp(l,e),tp(o,t)){const e=N.default.zip(r,l),t=N.default.map(e,(function(e){return e[0]/e[1]})),s=N.default.all(t,(function(e){return ep(t[0],e)})),o=N.default.all(e,(function(e){return d.number.equal(e[0],e[1],n)}));if(s&&o)return!0}}return!1}function hp(e,t){return e<t||ep(e,t)}function up(e){let[t,n,s,o]=e;t<0&&(t*=-1,n*=-1,s*=-1);const i=2*Math.PI;for(n<0&&(n*=-1,s*=-1,s+=i/2);s>0;)s-=i;for(;s<0;)s+=i;return[t,n,s,o]}function fp(e,t){return t=void 0===t?1:t%e.length,e.slice(t).concat(e.slice(0,t))}function mp(e){return e.replace(/(?:^|-)(.)/g,(function(e,t){return t.toUpperCase()}))}function gp(e,t){if(ep(e[0],t[0]))return"x = "+e[0].toFixed(3);const n=(t[1]-e[1])/(t[0]-e[0]),s=e[1]-n*e[0];return"y = "+n.toFixed(3)+"x + "+s.toFixed(3)}const vp={showGraph:function(e){return{markings:e.showGraph?"graph":"none"}}},bp=e=>yp(e)&&(null==e.graph.coords||0===e.graph.coords.length),yp=e=>"point"===e.graph.type&&"unlimited"===e.graph.numPoints||"polygon"===e.graph.type&&"unlimited"===e.graph.numSides,xp=(e,t)=>new he("".concat(e," called but current graph type is not a '").concat(t,"'"),pe.NotAllowed,{metadata:{graphType:t}});class Cp extends A.Component{constructor(){super(...arguments),X(this,"angle",void 0),X(this,"circle",void 0),X(this,"graphie",void 0),X(this,"horizHairline",void 0),X(this,"line",void 0),X(this,"lines",void 0),X(this,"parabola",void 0),X(this,"pointA",void 0),X(this,"pointB",void 0),X(this,"pointC",void 0),X(this,"points",void 0),X(this,"polygon",void 0),X(this,"shouldResetGraphie",void 0),X(this,"sinusoid",void 0),X(this,"trashCan",void 0),X(this,"vertHairline",void 0),X(this,"state",{shouldShowInstructions:bp(this.props)}),X(this,"_getShouldShowInstructions",(e=>(e=e||this.props,this.isClickToAddPoints(e)&&(null==e.graph.coords||0===e.graph.coords.length)))),X(this,"deprecatedProps",vp),X(this,"setGraphie",(e=>{this.graphie=e,this.setupGraphie()})),X(this,"handleAddPointsMouseDown",(e=>{if(!this.isClickToAddPoints())throw new he("handleAddPointsClick should not be registeredwhen isClickToAddPoints() is false",pe.NotAllowed);if(!this.isCoordInTrash(e)){let n;if("point"===this.props.graph.type){if(n=this.createPointForPointsType(e,this.points.length),!n.constrain())return void n.remove();this.points.push(n);const t=this.points.length-1;this.points[t].grab(e),this.updateCoordsFromPoints()}else if("polygon"===this.props.graph.type){var t;if(null!==(t=this.polygon)&&void 0!==t&&t.closed())return;n=this.createPointForPolygonType(e,this.points.length),this.points.push(n);const s=this.points.length-1;this.points[s].grab(e),this.updatePolygon()}this.setState({shouldShowInstructions:!1})}})),X(this,"resetGraphie",(()=>{this.shouldResetGraphie=!1,this.parabola=null,this.sinusoid=null,this.refs.graph.reset()})),X(this,"setupGraphie",(()=>{var e,t;(this.setTrashCanVisibility(0),this.isClickToAddPoints()&&this.setTrashCanVisibility(.5),this.props.apiOptions.isMobile)&&(this.horizHairline=new An(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:gn.INTERACTIVE}),null===(e=this.horizHairline)||void 0===e||e.hide(),this.vertHairline=new An(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.vertHairline.attr({stroke:gn.INTERACTIVE}),null===(t=this.vertHairline)||void 0===t||t.hide());this["add"+mp(this.props.graph.type)+"Controls"]()})),X(this,"showHairlines",(e=>{var t,n,s,o;this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(null===(t=this.horizHairline)||void 0===t||t.moveTo([this.props.range[0][0],e[1]],[this.props.range[0][1],e[1]]),null===(n=this.horizHairline)||void 0===n||n.show(),null===(s=this.vertHairline)||void 0===s||s.moveTo([e[0],this.props.range[1][0]],[e[0],this.props.range[1][1]]),null===(o=this.vertHairline)||void 0===o||o.show())})),X(this,"hideHairlines",(()=>{var e,t;this.props.apiOptions.isMobile&&(null===(e=this.horizHairline)||void 0===e||e.hide(),null===(t=this.vertHairline)||void 0===t||t.hide())})),X(this,"setTrashCanVisibility",(e=>{const t=this.graphie;if(d.number.equal(e,0))this.trashCan&&(this.trashCan.remove(),this.trashCan=null);else if(!this.props.apiOptions.isMobile){var n,s;if(!this.trashCan)this.trashCan=null==t||null===(s=t.raphael)||void 0===s?void 0:s.image("https://ka-perseus-graphie.s3.amazonaws.com/b1452c0d79fd0f7ff4c3af9488474a0a0decb361.png",t.xpixels-40,t.ypixels-40,40,40);null===(n=this.trashCan)||void 0===n||n.attr({opacity:e})}})),X(this,"isClickToAddPoints",(e=>(e=e||this.props,yp(e)))),X(this,"_lineStroke",(()=>this.props.isMobile?{"stroke-width":3}:{})),X(this,"addLine",(e=>{const t=this,n=t.graphie,s=Cp.getLineCoords(t.props.graph,t.props),o=t.points=N.default.map(s,(e=>uo.addMaybeMobileMovablePoint(this,{coord:e,constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap()],onMove:()=>{const e=N.default.extend({},t.props.graph,{coords:N.default.invoke(o,"coord")});t.onChange({graph:e})}}))),i={points:o,static:!0,normalStyle:{stroke:this.props.apiOptions.isMobile?gn.BLUE_C:gn.INTERACTIVE,...this._lineStroke()}};"line"===e?i.extendLine=!0:"ray"===e&&(i.extendRay=!0),t.line=uo.addMovableLine(n,i),o[0].listen("constraints","isLine",(e=>!d.point.equal(e,o[1].coord()))),o[1].listen("constraints","isLine",(e=>!d.point.equal(e,o[0].coord())))})),X(this,"removeLine",(()=>{var e;N.default.invoke(this.points,"remove"),null===(e=this.line)||void 0===e||e.remove()})),X(this,"addLinearControls",(()=>{this.addLine("line")})),X(this,"removeLinearControls",(()=>{this.removeLine()})),X(this,"addQuadraticControls",(()=>{if("quadratic"!==this.props.graph.type)throw xp("addQuadraticControls","quadratic");let e=this.props.graph.coords;e||(e=Cp.defaultQuadraticCoords(this.props));const t=()=>{const e=N.default.extend({},this.props.graph,{coords:[n.coord(),s.coord(),o.coord()]});this.onChange({graph:e}),this.updateQuadratic()};let n=null;n=this.pointA=uo.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),e=>!n||e[0]!==s.coord()[0]&&e[0]!==o.coord()[0]],onMove:t});let s=null;s=this.pointB=uo.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),e=>!s||e[0]!==n.coord()[0]&&e[0]!==o.coord()[0]],onMove:t});let o=null;o=this.pointC=uo.addMaybeMobileMovablePoint(this,{coord:e[2],constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),e=>!o||e[0]!==n.coord()[0]&&e[0]!==s.coord()[0]],onMove:t}),this.updateQuadratic()})),X(this,"updateQuadratic",(()=>{const e=Cp.getCurrentQuadraticCoefficients(this.props);if(!e)return;const t=e[0],n=e[1],s=e[2];if(this.parabola){var o,i;const e=null===(o=this.graphie)||void 0===o?void 0:o.svgParabolaPath(t,n,s);null===(i=this.parabola)||void 0===i||i.attr({path:e})}else{var r,a,l;this.parabola=null===(r=this.graphie)||void 0===r?void 0:r.parabola(t,n,s),null===(a=this.parabola)||void 0===a||a.attr({stroke:this.props.apiOptions.isMobile?gn.BLUE_C:gn.DYNAMIC,...this._lineStroke()}),null===(l=this.parabola)||void 0===l||l.toBack()}})),X(this,"removeQuadraticControls",(()=>{var e,t,n;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),null===(n=this.pointC)||void 0===n||n.remove(),this.parabola&&(this.parabola.remove(),this.parabola=null)})),X(this,"addSinusoidControls",(()=>{if("sinusoid"!==this.props.graph.type)throw xp("addSinusoidControls","sinusoid");let e=this.props.graph.coords;e||(e=Cp.defaultSinusoidCoords(this.props));const t=()=>{const e=N.default.extend({},this.props.graph,{coords:[n.coord(),s.coord()]});this.onChange({graph:e}),this.updateSinusoid()};let n=null;n=this.pointA=uo.addMaybeMobileMovablePoint(this,{coord:e[0],constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),e=>!n||e[0]!==s.coord()[0]],onMove:t});const s=this.pointB=uo.addMaybeMobileMovablePoint(this,{coord:e[1],constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),e=>!n||e[0]!==n.coord()[0]],onMove:t});this.updateSinusoid()})),X(this,"updateSinusoid",(()=>{const e=Cp.getCurrentSinusoidCoefficients(this.props);if(!e)return;const t=e[0],n=e[1],s=e[2],o=e[3];if(this.sinusoid){var i,r;const e=null===(i=this.graphie)||void 0===i?void 0:i.svgSinusoidPath(t,n,s,o);null===(r=this.sinusoid)||void 0===r||r.attr({path:e})}else{var a,l,c;this.sinusoid=null===(a=this.graphie)||void 0===a?void 0:a.sinusoid(t,n,s,o),null===(l=this.sinusoid)||void 0===l||l.attr({stroke:this.props.apiOptions.isMobile?gn.BLUE_C:gn.DYNAMIC,...this._lineStroke()}),null===(c=this.sinusoid)||void 0===c||c.toBack()}})),X(this,"removeSinusoidControls",(()=>{var e,t;null===(e=this.pointA)||void 0===e||e.remove(),null===(t=this.pointB)||void 0===t||t.remove(),this.sinusoid&&(this.sinusoid.remove(),this.sinusoid=null)})),X(this,"addCircleControls",(()=>{const e=this.graphie,t=N.default.min(e.snap),n=this.circle=null==e?void 0:e.addCircleGraph({center:this.props.graph.center||[0,0],radius:this.props.graph.radius||N.default.min(this.props.step),snapX:e.snap[0],snapY:e.snap[1],minRadius:t,snapRadius:t});L.default(n).on("move",(()=>{const e=N.default.extend({},this.props.graph,{center:n.center,radius:n.radius});this.onChange({graph:e})}))})),X(this,"removeCircleControls",(()=>{var e;null===(e=this.circle)||void 0===e||e.remove()})),X(this,"addLinearSystemControls",(()=>{const e=this.graphie,t=Cp.getLinearSystemCoords(this.props.graph,this.props),n=[gn.INTERACTIVE,gn.GREEN],s=this.points=N.default.map(t,((e,t)=>{const s=[];for(let o=0;o<e.length;o+=1){const i=e[o];s.push(uo.addMaybeMobileMovablePoint(this,{coord:i,constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),e=>{const t=s[1-o];if(t)return!d.point.equal(e,t.coord())}],onMove:()=>{const e=N.default.extend({},this.props.graph,{coords:N.default.map(this.points,(e=>N.default.invoke(e,"coord")))});this.onChange({graph:e})},normalStyle:{fill:n[t]},highlightStyle:{fill:n[t]}}))}return s}));this.lines=N.default.map(s,((t,s)=>uo.addMovableLine(e,{points:t,static:!0,extendLine:!0,normalStyle:{stroke:n[s]}})))})),X(this,"removeLinearSystemControls",(()=>{N.default.invoke(this.lines,"remove"),N.default.map(this.points,(e=>N.default.invoke(e,"remove")))})),X(this,"isCoordInTrash",(e=>{if(this.props.apiOptions.isMobile)return!1;const t=this.graphie,n=null==t?void 0:t.scalePoint(e);return n[0]>=t.xpixels-40&&n[1]>=t.ypixels-40})),X(this,"createPointForPointsType",((e,t)=>{const n=this,s=()=>{n.points=N.default.filter(n.points,(function(e){return e!==o})),n.updateCoordsFromPoints(),setTimeout(o.remove.bind(o),0)};let o=null;return o=uo.addMaybeMobileMovablePoint(this,{coord:e,constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),function(e){return N.default.all(n.points,(function(t){return o===t||!d.point.equal(e,t.coord())}))}],onMoveStart:function(){n.isClickToAddPoints()&&n.setTrashCanVisibility(1)},onMove:n.updateCoordsFromPoints,onMoveEnd:function(e){n.isClickToAddPoints()&&(n.isCoordInTrash(e)&&s(),n.setTrashCanVisibility(.5))},...this.props.apiOptions.isMobile&&n.isClickToAddPoints()?{onRemove:s}:{}}),o})),X(this,"removePoint",(e=>{let t=null;return this.points=N.default.filter(this.points,(function(n,s){return n!==e||(t=s,!1)})),t})),X(this,"createPointForPolygonType",((e,t)=>{if("polygon"!==this.props.graph.type)throw xp("createPointForPolygonType","polygon");const n=!N.default.contains(["angles","sides"],this.props.graph.snapTo),s=e=>(t+e+this.points.length)%this.points.length,o=()=>{var e;const t=this.removePoint(r);var n;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&(this.points=fp(this.points,t),null===(n=this.polygon)||void 0===n||n.update({closed:!1}));this.updatePolygon(),this.clearCoords(),setTimeout(r.remove.bind(r),0)},i=G.default(((e,t)=>{e.state.isInitialMove=t}),1e3),r=uo.addMaybeMobileMovablePoint(this,{coord:e,constraints:[uo.MovablePoint.constraints.bound(),n?uo.MovablePoint.constraints.snap():null,e=>{if(null==this.points||0===this.points.length)return!0;const n=N.default.invoke(this.points,"coord");if(n[t]=e,!this.isClickToAddPoints()){if(sp(n[s(-2)],n[s(-1)],n[t])||sp(n[s(-1)],n[t],n[s(1)])||sp(n[t],n[s(1)],n[s(2)]))return!1;const e=N.default.zip(n,fp(n));if(this.points.length>3)for(let t=-1;t<=0;t++){const n=e[s(t)],o=N.default.without(e,n,e[s(t-1)],e[s(t+1)]);for(let e=0;e<o.length;e++){if(rp(n,o[e]))return!1}}}if("angles"===this.props.graph.snapTo&&this.points.length>2){var o,i;const e=N.default.map(pp(n),(function(e){return 180*e/Math.PI}));N.default.each([-1,1],(function(t){e[s(t)]=Math.round(e[s(t)])}));const r=function(e,t,o){return(wn.findAngle(n[s(e)],n[s(o)],n[s(t)])+360)%360},a=[e[s(-1)]-r(-2,-1,1),e[s(1)]-r(-1,1,2)];if(a[2]=180-(a[0]+a[1]),N.default.any(a,(function(e){return hp(e,1)})))return!1;const l=lp(ap(n[s(-1)],n[s(1)])),c=1===op(np(n[s(-1)],n[s(1)],n[t])),p=Math.sin(a[1]*Math.PI/180)/Math.sin(a[2]*Math.PI/180)*l,d=wn.findAngle(n[s(1)],n[s(-1)]),h=null===(o=this.graphie)||void 0===o?void 0:o.polar(p,d+(c?1:-1)*a[0]);return null===(i=this.graphie)||void 0===i?void 0:i.addPoints(n[s(-1)],h)}if("sides"===this.props.graph.snapTo&&this.points.length>1){var r,a;const e=N.default.map([[n[s(-1)],n[t]],[n[t],n[s(1)]],[n[s(-1)],n[s(1)]]],(function(e){return lp(ap(...e))}));if(N.default.each([0,1],(function(t){e[t]=Math.round(e[t])})),hp(e[1]+e[2],e[0])||hp(e[0]+e[2],e[1])||hp(e[0]+e[1],e[2]))return!1;const o=(l=e[0],c=e[2],p=e[1],180*Math.acos((l*l+c*c-p*p)/(2*l*c))/Math.PI),i=wn.findAngle(n[s(1)],n[s(-1)]),d=1===op(np(n[s(-1)],n[s(1)],n[t])),h=null===(r=this.graphie)||void 0===r?void 0:r.polar(e[0],i+(d?1:-1)*o);return null===(a=this.graphie)||void 0===a?void 0:a.addPoints(n[s(-1)],h)}var l,c,p;return!0}],onMoveStart:()=>{this.isClickToAddPoints()&&this.setTrashCanVisibility(1)},onMove:()=>{var e;null!==(e=this.polygon)&&void 0!==e&&e.closed()&&this.updateCoordsFromPoints()},onMoveEnd:e=>{const t=this.points.length>1&&(r===this.points[0]&&d.point.equal(e,N.default.last(this.points).coord())||r===N.default.last(this.points)&&d.point.equal(e,this.points[0].coord()));if(this.isClickToAddPoints()){if(this.isCoordInTrash(e))o();else if(t){const e=this.points.pop();var n,s;if(this.points.length>2)null===(n=this.polygon)||void 0===n||n.update({closed:!0}),this.updateCoordsFromPoints();else null===(s=this.polygon)||void 0===s||s.update({closed:!1}),this.clearCoords();this.updatePolygon(),setTimeout(e.remove.bind(e),0)}else{if(N.default.any(this.points,(function(t){return t!==r&&d.point.equal(t.coord(),e)}))){var a,l;if(this.removePoint(r),this.points.length<3)null===(l=this.polygon)||void 0===l||l.update({closed:!1}),this.clearCoords();else null!==(a=this.polygon)&&void 0!==a&&a.closed()&&this.updateCoordsFromPoints();this.updatePolygon(),setTimeout(r.remove.bind(r),0)}else{var c;const e=r===N.default.head(this.points)||r===N.default.last(this.points),t=!r.hasMoved(),n=!r.state.isInitialMove,s=!(null!==(c=this.polygon)&&void 0!==c&&c.closed()),o=this.points.length>2;var p;if(e&&t&&n&&s&&o)null===(p=this.polygon)||void 0===p||p.update({closed:!0}),this.updatePolygon(),this.updateCoordsFromPoints()}}this.setTrashCanVisibility(.5)}i(r,!1)},...this.props.apiOptions.isMobile&&this.isClickToAddPoints()?{onRemove:o}:{}});return r.state.isInitialMove=!0,r})),X(this,"updateCoordsFromPoints",(()=>{const e=N.default.extend({},this.props.graph,{coords:N.default.map(this.points,(function(e){return N.default.result(e,"coord")}))});this.onChange({graph:e})})),X(this,"clearCoords",(()=>{const e=N.default.extend({},this.props.graph,{coords:null});this.onChange({graph:e})})),X(this,"onChange",(e=>{this.props.onChange(e),this.props.trackInteraction()})),X(this,"addPointControls",(()=>{if("point"!==this.props.graph.type)throw xp("addPointControls","point");const e=Cp.getPointCoords(this.props.graph,this.props);this.points=[],this.points=N.default.map(e,this.createPointForPointsType,this)})),X(this,"removePointControls",(()=>{N.default.invoke(this.points,"remove")})),X(this,"addSegmentControls",(()=>{if("segment"!==this.props.graph.type)throw xp("addSegmentControls","segment");const e=this,t=this.graphie,n=Cp.getSegmentCoords(this.props.graph,this.props),s=e=>uo.addMaybeMobileMovablePoint(this,e);this.points=[],this.lines=N.default.map(n,(function(n,o){const i=function(){const t=N.default.extend({},e.props.graph,{coords:N.default.invoke(e.lines,"coords")});e.onChange({graph:t})},r=[];for(let e=0;e<n.length;e+=1){const t=n[e];r.push(s({coord:t,constraints:[uo.MovablePoint.constraints.bound(),uo.MovablePoint.constraints.snap(),t=>{const n=r[1-e];return!!n&&!d.point.equal(t,n.coord())}],onMove:i}))}e.points=e.points.concat(r);const a=uo.addMovableLine(t,{points:r,static:!1,constraints:[uo.MovableLine.constraints.bound(),uo.MovableLine.constraints.snap()],onMove:[uo.MovableLine.onMove.updatePoints,i],normalStyle:{stroke:this.props.apiOptions.isMobile?gn.BLUE_C:gn.INTERACTIVE,...this._lineStroke()},highlightStyle:{stroke:this.props.apiOptions.isMobile?gn.BLUE_C:gn.INTERACTING,...this._lineStroke()}});return N.default.invoke(r,"toFront"),a}),this)})),X(this,"removeSegmentControls",(()=>{N.default.invoke(this.points,"remove"),N.default.invoke(this.lines,"remove")})),X(this,"addRayControls",(()=>{this.addLine("ray")})),X(this,"removeRayControls",(()=>{this.removeLine()})),X(this,"addPolygonControls",(()=>{this.polygon=null;const e=Cp.getPolygonCoords(this.props.graph,this.props);this.points=[],this.points=N.default.map(e,this.createPointForPolygonType,this),this.updatePolygon()})),X(this,"updatePolygon",(()=>{if("polygon"!==this.props.graph.type)throw xp("updatePolygon","polygon");let e;e=this.polygon?this.polygon.closed():this.points.length>=3;const t=this.graphie,n=this.points.length,s=!N.default.contains(["angles","sides"],this.props.graph.snapTo),o=N.default.times(n,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==n-1)?"angles"===this.props.graph.snapTo?"$deg0":"$deg1":""}),this),i=N.default.times(n,(function(t){return e||0!==t&&t!==n-1}),this),r=N.default.times(n,(function(t){return this.props.graph.showAngles&&(e||0!==t&&t!==n-1)?1:0}),this),a=N.default.times(n,(function(t){return!this.props.graph.showSides||!e&&t===n-1?"":"sides"===this.props.graph.snapTo?"$len0":"$len1"}),this);if(null==this.polygon){const n=this;n.polygon=uo.addMovablePolygon(t,{constraints:[uo.MovablePolygon.constraints.bound(),s?uo.MovablePolygon.constraints.snap():null],closed:e,points:n.points,angleLabels:o,showRightAngleMarkers:i,numArcs:r,sideLabels:a,onMove:[uo.MovablePolygon.onMove.updatePoints,function(){this.closed()&&n.updateCoordsFromPoints()}],normalStyle:{stroke:this.props.apiOptions.isMobile?gn.BLUE_C:gn.INTERACTIVE,...this._lineStroke()}})}else this.polygon.update({closed:e,points:this.points,angleLabels:o,showRightAngleMarkers:i,numArcs:r,sideLabels:a})})),X(this,"removePolygonControls",(()=>{var e;N.default.invoke(this.points,"remove"),null===(e=this.polygon)||void 0===e||e.remove()})),X(this,"addAngleControls",(()=>{if("angle"!==this.props.graph.type)throw xp("addAngleControls","angle");const e=this.props.graph,t=this.graphie,n=Cp.getAngleCoords(this.props.graph,this.props);var s,o;this.points=n.map((function(e,n){return null==t?void 0:t.addMovablePoint(N.default.extend({coord:e,normalStyle:{stroke:gn.INTERACTIVE,fill:gn.INTERACTIVE}},1===n?{snapX:t.snap[0],snapY:t.snap[1]}:{}))})),this.angle=null==t?void 0:t.addMovableAngle({points:this.points,snapDegrees:e.snapDegrees||1,snapOffsetDeg:e.angleOffsetDeg||0,angleLabel:e.showAngles?"$deg0":"",pushOut:2,allowReflex:(s=e.allowReflexAngles,o=!0,null==s?o:s)}),L.default(this.angle).on("move",(()=>{var t;this.onChange({graph:{...e,coords:null===(t=this.angle)||void 0===t?void 0:t.getClockwiseCoords()}})}))})),X(this,"removeAngleControls",(()=>{var e;N.default.invoke(this.points,"remove"),null===(e=this.angle)||void 0===e||e.remove()})),X(this,"toggleShowAngles",(()=>{if("polygon"!==this.props.graph.type)throw xp("toggleShowAngles","polygon");const e=N.default.extend({},this.props.graph,{showAngles:!this.props.graph.showAngles});this.onChange({graph:e})})),X(this,"toggleShowSides",(()=>{if("polygon"!==this.props.graph.type)throw xp("toggleShowSides","polygon");const e=N.default.extend({},this.props.graph,{showSides:!this.props.graph.showSides});this.onChange({graph:e})})),X(this,"getUserInput",(()=>Cp.getUserInputFromProps(this.props))),X(this,"simpleValidate",(e=>Cp.validate(this.getUserInput(),e,this))),X(this,"focus",L.default.noop)}UNSAFE_componentWillMount(){Qc.UNSAFE_componentWillMount.call(this)}componentDidMount(){this.setGraphie(this.refs.graph.graphie())}UNSAFE_componentWillReceiveProps(e){var t,n;this.isClickToAddPoints()!==this.isClickToAddPoints(e)&&(this.shouldResetGraphie=!0,this.setState({shouldShowInstructions:bp(e)})),(null===(t=this.props.backgroundImage)||void 0===t?void 0:t.url)===(null===(n=e.backgroundImage)||void 0===n?void 0:n.url)&&this.props.backgroundImage===e.backgroundImage&&this.props.containerSizeClass===e.containerSizeClass||(this.shouldResetGraphie=!0)}componentDidUpdate(e,t){const n=e.graph.type,s=this.props.graph.type;(n!==s||"angle"===e.graph.type&&"angle"===this.props.graph.type&&this.areAngleGraphsEqual(e.graph,this.props.graph)||"point"===e.graph.type&&"point"===this.props.graph.type&&this.arePointGraphsEqual(e.graph,this.props.graph)||"polygon"===e.graph.type&&"polygon"===this.props.graph.type&&this.arePolygonGraphsEqual(e.graph,this.props.graph)||"segment"===e.graph.type&&"segment"===this.props.graph.type&&this.areSegmentGraphsEqual(e.graph,this.props.graph))&&(this["remove"+mp(n)+"Controls"](),this["add"+mp(s)+"Controls"]()),this.shouldResetGraphie&&this.resetGraphie()}areAngleGraphsEqual(e,t){return e.allowReflexAngles!==t.allowReflexAngles||e.angleOffsetDeg!==t.angleOffsetDeg||e.snapDegrees!==t.snapDegrees}arePointGraphsEqual(e,t){return e.numPoints!==t.numPoints}arePolygonGraphsEqual(e,t){return e.numSides!==t.numSides||e.showAngles!==t.showAngles||e.showSides!==t.showSides||e.snapTo!==t.snapTo}areSegmentGraphsEqual(e,t){return e.numSegments!==t.numSegments}render(){const e=li(this.props.containerSizeClass);let t;this.isClickToAddPoints()&&this.state.shouldShowInstructions?"point"===this.props.graph.type?t=I._("Click to add points"):"polygon"===this.props.graph.type&&(t=I._("Click to add vertices")):t=void 0;const n=this.isClickToAddPoints()?this.handleAddPointsMouseDown:null,s=this.props.gridStep||Be.getGridStep(this.props.range,this.props.step,e[0]),o=this.props.snapStep||Be.snapStepFromGridStep(s),i=this.props.apiOptions.isMobile;return A.createElement("div",{className:"perseus-widget perseus-widget-interactive-graph",style:{width:e[0],height:e[1]}},A.createElement(Jc,{instructions:t,ref:"graph",box:e,labels:this.props.labels,range:this.props.range,step:i?Be.constrainedTickStepsFromTickSteps(this.props.step,this.props.range):this.props.step,gridStep:s,snapStep:o,markings:this.props.markings,backgroundImage:this.props.backgroundImage,showProtractor:this.props.showProtractor,showRuler:this.props.showRuler,rulerLabel:this.props.rulerLabel,rulerTicks:this.props.rulerTicks,onMouseDown:n,onGraphieUpdated:this.setGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:i}))}static getQuadraticCoefficients(e){const t=e[0],n=e[1],s=e[2],o=(t[0]-n[0])*(t[0]-s[0])*(n[0]-s[0]);if(0===o)return;return[(s[0]*(n[1]-t[1])+n[0]*(t[1]-s[1])+t[0]*(s[1]-n[1]))/o,(s[0]*s[0]*(t[1]-n[1])+n[0]*n[0]*(s[1]-t[1])+t[0]*t[0]*(n[1]-s[1]))/o,(n[0]*s[0]*(n[0]-s[0])*t[1]+s[0]*t[0]*(s[0]-t[0])*n[1]+t[0]*n[0]*(t[0]-n[0])*s[1])/o]}static getSinusoidCoefficients(e){const t=e[0],n=e[1],s=n[1]-t[1],o=Math.PI/(2*(n[0]-t[0]));return[s,o,t[0]*o,t[1]]}static getLineCoords(e,t){return e.coords||Cp.pointsFromNormalized(t,[[.25,.75],[.75,.75]])}static getPointCoords(e,t){const n=e.numPoints||1;let s=e.coords;if(s)return s;switch(n){case 1:s=[e.coord||[0,0]];break;case 2:s=[[-5,0],[5,0]];break;case 3:s=[[-5,0],[0,0],[5,0]];break;case 4:s=[[-6,0],[-2,0],[2,0],[6,0]];break;case 5:s=[[-6,0],[-3,0],[0,0],[3,0],[6,0]];break;case 6:s=[[-5,0],[-3,0],[-1,0],[1,0],[3,0],[5,0]];break;case"unlimited":s=[]}const o=Cp.normalizeCoords(s,[[-10,10],[-10,10]]);return Cp.pointsFromNormalized(t,o)}static getLinearSystemCoords(e,t){return e.coords||N.default.map([[[.25,.75],[.75,.75]],[[.25,.25],[.75,.25]]],(e=>Cp.pointsFromNormalized(t,e)))}static getPolygonCoords(e,t){if("polygon"!==e.type)throw xp("toggleShowSides","polygon");let n=e.coords;if(n)return n;const s=e.numSides||3;if("unlimited"===s)n=[];else{const t=2*Math.PI/s,o=(1/s-.5)*Math.PI,i="sides"===e.snapTo?Math.sqrt(3)/3*7:4;n=N.default.times(s,(function(e){return[i*Math.cos(e*t+o),i*Math.sin(e*t+o)]}))}n=Cp.normalizeCoords(n,[[-10,10],[-10,10]]);const o=!N.default.contains(["angles","sides"],e.snapTo);return n=Cp.pointsFromNormalized(t,n,!o),n}static getSegmentCoords(e,t){const n=e.coords;if(n)return n;const s=e.numSegments||1,o=[[-10,10],[-10,10]];return{1:[5],2:[5,-5],3:[5,0,-5],4:[6,2,-2,-6],5:[6,3,0,-3,-6],6:[5,3,1,-1,-3,-5]}[s].map((function(e){let n=[[-5,e],[5,e]];return n=Cp.normalizeCoords(n,o),n=Cp.pointsFromNormalized(t,n),n}))}static getAngleCoords(e,t){let n=e.coords;if(n)return n;const s=e.snapDegrees||1;let o=s;for(;o<20;)o+=s;o=o*Math.PI/180;const i=(e.angleOffsetDeg||0)*Math.PI/180;n=Cp.pointsFromNormalized(t,[[.85,.5],[.5,.5]]);const r=lp(ap(...n));return n[0]=[n[1][0]+r*Math.cos(i),n[1][1]+r*Math.sin(i)],n[2]=[n[1][0]+r*Math.cos(o+i),n[1][1]+r*Math.sin(o+i)],n}static normalizeCoords(e,t){return N.default.map(e,(function(e){return N.default.map(e,(function(e,n){const s=t[n][1]-t[n][0];return(e+t[n][1])/s}))}))}static getEquationString(e){const t="get"+mp(e.graph.type)+"EquationString";return Cp[t](e)}static pointsFromNormalized(e,t,n){return N.default.map(t,(function(t){return N.default.map(t,(function(t,s){const o=e.range[s];if(n)return o[0]+(o[1]-o[0])*t;const i=e.step[s],r=function(e,t){return Math.floor((e[1]-e[0])/t)}(o,i),a=Math.round(t*r);return o[0]+i*a}))}))}static getLinearEquationString(e){const t=Cp.getLineCoords(e.graph,e);if(ep(t[0][0],t[1][0]))return"x = "+t[0][0].toFixed(3);const n=(t[1][1]-t[0][1])/(t[1][0]-t[0][0]),s=t[0][1]-n*t[0][0];return ep(n,0)?"y = "+s.toFixed(3):"y = "+n.toFixed(3)+"x + "+s.toFixed(3)}static getCurrentQuadraticCoefficients(e){const t=e.graph.coords||Cp.defaultQuadraticCoords(e);return Cp.getQuadraticCoefficients(t)}static defaultQuadraticCoords(e){return Cp.pointsFromNormalized(e,[[.25,.75],[.5,.25],[.75,.75]])}static getQuadraticEquationString(e){const t=Cp.getCurrentQuadraticCoefficients(e);return"y = "+t[0].toFixed(3)+"x^2 + "+t[1].toFixed(3)+"x + "+t[2].toFixed(3)}static getCurrentSinusoidCoefficients(e){const t=e.graph.coords||Cp.defaultSinusoidCoords(e);return Cp.getSinusoidCoefficients(t)}static defaultSinusoidCoords(e){return Cp.pointsFromNormalized(e,[[.5,.5],[.65,.6]])}static getSinusoidEquationString(e){const t=Cp.getCurrentSinusoidCoefficients(e);return"y = "+t[0].toFixed(3)+"sin("+t[1].toFixed(3)+"x - "+t[2].toFixed(3)+") + "+t[3].toFixed(3)}static getCircleEquationString(e){const t=e.graph,n=t.center||[0,0],s=t.radius||2;return"center ("+n[0]+", "+n[1]+"), radius "+s}static getLinearSystemEquationString(e){const t=Cp.getLinearSystemCoords(e.graph,e);return"\n"+gp(t[0][0],t[0][1])+"\n"+gp(t[1][0],t[1][1])+"\n"+function(e,t){const n=e[0][0],s=e[0][1],o=e[1][0],i=e[1][1],r=t[0][0],a=t[0][1],l=t[1][0],c=t[1][1],p=(n-o)*(a-c)-(s-i)*(r-l);if(Math.abs(p)<1e-9)return"Lines are parallel";const d=((n*i-s*o)*(a-c)-(s-i)*(r*c-a*l))/p;return"Intersection: ("+(((n*i-s*o)*(r-l)-(n-o)*(r*c-a*l))/p).toFixed(3)+", "+d.toFixed(3)+")"}(t[0],t[1])}static getPointEquationString(e){if("point"!==e.graph.type)throw xp("getPointEquationString","point");return Cp.getPointCoords(e.graph,e).map((function(e){return"("+e[0]+", "+e[1]+")"})).join(", ")}static getSegmentEquationString(e){if("segment"!==e.graph.type)throw xp("getSegmentEquationString","segment");const t=Cp.getSegmentCoords(e.graph,e);return N.default.map(t,(function(e){return"["+N.default.map(e,(function(e){return"("+e.join(", ")+")"})).join(" ")+"]"})).join(" ")}static getRayEquationString(e){if("ray"!==e.graph.type)throw xp("createPointForPolygonType","ray");const t=Cp.getLineCoords(e.graph,e),n=t[0],s=t[1];let o=Cp.getLinearEquationString(e);return n[0]>s[0]?o+=" (for x <= "+n[0].toFixed(3)+")":n[0]<s[0]?o+=" (for x >= "+n[0].toFixed(3)+")":n[1]>s[1]?o+=" (for y <= "+n[1].toFixed(3)+")":o+=" (for y >= "+n[1].toFixed(3)+")",o}static getPolygonEquationString(e){if("polygon"!==e.graph.type)throw xp("getPolygonEquationString","polygon");const t=Cp.getPolygonCoords(e.graph,e);return N.default.map(t,(function(e){return"("+e.join(", ")+")"})).join(" ")}static getAngleEquationString(e){if("angle"!==e.graph.type)throw xp("getAngleEquationString","angle");const t=Cp.getAngleCoords(e.graph,e);return wn.findAngle(t[2],t[0],t[1]).toFixed(0)+"° angle at ("+t[1].join(", ")+")"}static validate(e,t,n){const s=!!(e.coords||e.center&&e.radius);if(e.type===t.correct.type&&s)if("linear"===e.type&&"linear"===t.correct.type&&null!=e.coords){const n=e.coords,s=t.correct.coords;if(sp(s[0],s[1],n[0])&&sp(s[0],s[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("linear-system"===e.type&&"linear-system"===t.correct.type&&null!=e.coords){const n=e.coords,s=t.correct.coords;if(sp(s[0][0],s[0][1],n[0][0])&&sp(s[0][0],s[0][1],n[0][1])&&sp(s[1][0],s[1][1],n[1][0])&&sp(s[1][0],s[1][1],n[1][1])||sp(s[0][0],s[0][1],n[1][0])&&sp(s[0][0],s[0][1],n[1][1])&&sp(s[1][0],s[1][1],n[0][0])&&sp(s[1][0],s[1][1],n[0][1]))return{type:"points",earned:1,total:1,message:null}}else if("quadratic"===e.type&&"quadratic"===t.correct.type&&null!=e.coords){const n=this.getQuadraticCoefficients(e.coords),s=this.getQuadraticCoefficients(t.correct.coords);if(tp(n,s))return{type:"points",earned:1,total:1,message:null}}else if("sinusoid"===e.type&&"sinusoid"===t.correct.type&&null!=e.coords){const n=this.getSinusoidCoefficients(e.coords),s=this.getSinusoidCoefficients(t.correct.coords),o=up(n),i=up(s);if(tp(o,i))return{type:"points",earned:1,total:1,message:null}}else if("circle"===e.type&&"circle"===t.correct.type){if(tp(e.center,t.correct.center)&&ep(e.radius,t.correct.radius))return{type:"points",earned:1,total:1,message:null}}else if("point"===e.type&&"point"===t.correct.type&&null!=e.coords){var o;let s=Cp.getPointCoords(t.correct,n);const i=null===(o=e.coords)||void 0===o?void 0:o.slice();if(s=s.slice(),null==i||i.sort(),s.sort(),tp(i,s))return{type:"points",earned:1,total:1,message:null}}else if("polygon"===e.type&&"polygon"===t.correct.type&&null!=e.coords){var i,r;const n=null===(i=e.coords)||void 0===i?void 0:i.slice(),s=null===(r=t.correct.coords)||void 0===r?void 0:r.slice();let o;if("similar"===t.correct.match?o=dp(n,s,Number.POSITIVE_INFINITY):"congruent"===t.correct.match?o=dp(n,s,d.number.DEFAULT_TOLERANCE):"approx"===t.correct.match?o=dp(n,s,.1):(n.sort(),s.sort(),o=tp(n,s)),o)return{type:"points",earned:1,total:1,message:null}}else if("segment"===e.type&&"segment"===t.correct.type&&null!=e.coords){var a;let n=e.coords.slice(),s=null===(a=t.correct.coords)||void 0===a?void 0:a.slice();if(n=N.default.invoke(n,"sort").sort(),s=N.default.invoke(s,"sort").sort(),tp(n,s))return{type:"points",earned:1,total:1,message:null}}else if("ray"===e.type&&"ray"===t.correct.type&&null!=e.coords){const n=e.coords,s=t.correct.coords;if(tp(n[0],s[0])&&sp(s[0],s[1],n[1]))return{type:"points",earned:1,total:1,message:null}}else if("angle"===e.type&&"angle"===t.correct.type){const n=e.coords,s=t.correct.coords;let o;if("congruent"===t.correct.match){const e=N.default.map([n,s],(function(e){return(wn.findAngle(e[2],e[0],e[1])+360)%360}));o=ep(...e)}else o=tp(n[1],s[1])&&sp(s[1],s[0],n[0])&&sp(s[1],s[2],n[2]);if(o)return{type:"points",earned:1,total:1,message:null}}return!s||N.default.isEqual(e,t.graph)?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}static getUserInputFromProps(e){return e.graph}}X(Cp,"defaultProps",{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showTooltips:!1,showProtractor:!1,showRuler:!1,rulerLabel:"",rulerTicks:10,graph:{type:"linear"}});var wp={name:"interactive-graph",displayName:"Interactive graph",widget:Cp};class kp extends A.Component{constructor(){super(...arguments),X(this,"_input",void 0),X(this,"state",{isInputFocused:!1})}focusInput(){this._input&&this._input.focus()}handleClick(e){const{checked:t,onChange:n}=this.props;e.preventDefault(),this.focusInput(),n(!t)}handleKeyDown(e){const{onFocusPrevAnswer:t,onFocusNextAnswer:n}=this.props;switch(e.key){case"ArrowUp":e.preventDefault(),t();break;case"ArrowDown":e.preventDefault(),n()}}handleInputChange(e){e.preventDefault()}handleInputFocus(){this.setState({isInputFocused:!0})}handleInputBlur(){this.setState({isInputFocused:!1})}renderCheckmark(){const{checked:e}=this.props;return A.createElement("span",{className:l.css(Ep.checkmarkContainer)},e&&A.createElement(da,{icon:ms,size:16,color:q.default.offBlack}))}render(){const{content:e,checked:t,groupName:n,index:s,inputType:o}=this.props,{isInputFocused:i}=this.state,r="".concat(n,"-").concat(s);return A.createElement("div",{className:l.css(Ep.answerChoice,i&&Ep.answerFocused),onClick:e=>this.handleClick(e),onKeyDown:e=>this.handleKeyDown(e)},A.createElement("span",{className:l.css(Ep.answerInputWrapper)},A.createElement("input",{className:l.css(Qr.perseusSrOnly),checked:t,name:n,id:r,type:o,onChange:e=>this.handleInputChange(e),onFocus:()=>this.handleInputFocus(),onBlur:()=>this.handleInputBlur(),ref:e=>this._input=e}),this.renderCheckmark()),A.createElement("label",{htmlFor:r},A.createElement(Li,{content:e})))}}class Sp extends A.Component{constructor(e){super(e),X(this,"_choices",void 0),this._choices=[],this.state={groupName:N.default.uniqueId("answer_choices_")}}focusAnswer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=this.props.choices.length;e<0?e+=t:e>=t&&(e-=t);const n=this._choices[e];n&&n.focusInput()}onAnswerChange(e,t){const{choices:n,multipleSelect:s,onChange:o}=this.props,i=[];for(let o=0;o<n.length;o++)i.push(s?o===e?t:n[o].checked:o===e&&t);o(i)}onFocusAnswer(e){this.focusAnswer(e)}render(){const{choices:e,multipleSelect:t}=this.props,{groupName:n}=this.state;return A.createElement("fieldset",null,e.map(((e,s)=>A.createElement(kp,$({},e,{key:e.content,groupName:n,index:s,inputType:t?"checkbox":"radio",onChange:e=>this.onAnswerChange(s,e),onFocusPrevAnswer:()=>this.onFocusAnswer(s-1),onFocusNextAnswer:()=>this.onFocusAnswer(s+1),ref:e=>this._choices[s]=e})))))}}const Ep=l.StyleSheet.create({answerChoice:{display:"flex",alignItems:"center",userSelect:"none",padding:"10px 16px 10px 0px",fontWeight:"bold",border:"solid 2px transparent",borderRadius:2,":active":{backgroundColor:"rgba(33, 36, 44, 0.08)"}},answerFocused:{borderColor:"#1865f2",":active":{borderColor:"transparent"}},answerInputWrapper:{marginRight:8},checkmarkContainer:{display:"flex",position:"relative",width:16,height:16,marginLeft:8}});class _p extends A.Component{constructor(){super(...arguments),X(this,"_icon",void 0),X(this,"state",{isFocused:!1})}handleFocus(){this.setState({isFocused:!0})}handleBlur(){this.setState({isFocused:!1})}renderIcon(){const{selected:e,showCorrectness:t,showSelected:n,showPulsate:s}=this.props,{isFocused:o}=this.state,i=n||o;let r,a;return t?(r=A.createElement(da,{icon:"correct"===t?fs:Ps,size:24,color:q.default.white}),a="correct"===t?[Mp.markerCorrect,i&&Mp.markerCorrectSelected]:[Mp.markerIncorrect,i&&Mp.markerIncorrectSelected]):a=e&&e.length>0?[Mp.markerFilled,i&&Mp.markerFilledSelected]:[i?Mp.markerUnfilledSelected:s&&Mp.markerUnfilledPulsate],A.createElement("div",{className:l.css(Mp.markerIcon,...a),ref:e=>this._icon=e},r)}render(){const{label:e,x:t,y:n,showCorrectness:s}=this.props,o="correct"===s;return A.createElement("button",{"aria-label":e,className:l.css(Mp.unstyledButton,Mp.marker,o&&Mp.disabled),style:{left:"".concat(t,"%"),top:"".concat(n,"%")},tabIndex:o?-1:0,onFocus:()=>this.handleFocus(),onBlur:()=>this.handleBlur(),onClick:e=>this.props.onClick(e),onKeyDown:e=>this.props.onKeyDown(e)},this.renderIcon())}}X(_p,"defaultProps",{selected:[]});const Mp=l.StyleSheet.create({unstyledButton:{padding:0,overflow:"visible",color:"inherit",font:"inherit",lineHeight:"normal",background:"none",border:"none"},marker:{position:"absolute",width:30,height:30,marginLeft:-15,marginTop:-15},disabled:{pointerEvents:"none"},markerIcon:{display:"flex",position:"relative",boxSizing:"content-box",width:16,height:16,marginLeft:5,cursor:"pointer",backgroundColor:"#1865f2",border:"solid 2px #ffffff",borderRadius:16,boxShadow:"0 2px 6px 0 ".concat("rgba(33, 36, 44, 0.32)")},markerUnfilledPulsate:{animationName:{"0%":{transform:"scale(1)"},"100%":{transform:"scale(1.5)"}},animationDirection:"alternate",animationDuration:"0.8s",animationIterationCount:"infinite",animationTimingFunction:"ease-in",transformOrigin:"50% 50%"},markerUnfilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:20,height:20,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:20},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerFilled:{width:8,height:8,marginLeft:9,borderRadius:8,boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerFilledSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:12,height:12,marginLeft:-4,marginTop:-4,border:"solid 2px ".concat("#2552b0"),borderRadius:12},":active":{backgroundColor:"#2552b0",boxShadow:"none","::before":{display:"none"}}},markerCorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#00a60e",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerCorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#167b1f",boxShadow:"none","::before":{display:"none"}}},markerIncorrect:{width:24,height:24,marginLeft:1,marginTop:1,justifyContent:"center",alignItems:"center",background:"#909195",boxShadow:"0 1px 1px 0 ".concat("rgba(33, 36, 44, 0.16)")},markerIncorrectSelected:{"::before":{content:"''",display:"inline-block",position:"absolute",width:28,height:28,border:"solid 2px ".concat("#2552b0"),borderRadius:28},":active":{backgroundColor:"#6c6e73",boxShadow:"none","::before":{display:"none"}}}});class Tp extends A.Component{static gradeMarker(e){const t={hasAnswers:!1,isCorrect:!1};return e.selected&&e.selected.length>0&&(t.hasAnswers=!0),e.answers.length>0?e.selected&&e.selected.length===e.answers.length&&(t.isCorrect=e.selected.every((t=>e.answers.includes(t)))):e.selected&&0!==e.selected.length||(t.isCorrect=!0),t}static validate(e,t){let n=0,s=0;for(const t of e.markers){const e=Tp.gradeMarker(t);e.hasAnswers&&n++,e.isCorrect&&s++}return n!==e.markers.length?{type:"invalid",message:null}:{type:"points",earned:s===e.markers.length?1:0,total:1,message:null}}static pointInTriangle(e,t,n,s){const o=(e,t,n)=>(e.x-n.x)*(t.y-n.y)-(t.x-n.x)*(e.y-n.y),i=o(e,t,n)<0,r=o(e,n,s)<0,a=o(e,s,t)<0;return i===r&&r===a}static imageSideForMarkerPosition(e,t){if(e<20)return"left";if(e>80)return"right";const n={x:20,y:0},s={x:80,y:0},o={x:80,y:100},i={x:20,y:100},r={x:50,y:50},a={top:[n,s,r],right:[r,s,o],bottom:[i,r,o],left:[n,r,i]},l={x:e,y:t};for(const e of Object.keys(a)){const t=a[e];if(Tp.pointInTriangle(l,...t))return e}return"center"}static navigateToMarkerIndex(e,t,n){const s=t[n],o=t.map(((e,t)=>{const n=e.x-s.x,o=e.y-s.y,i=Math.sqrt(n**2+o**2);return{index:t,dist:i,dir:{x:0!==i?n/i:0,y:0!==i?o/i:0}}})).filter((e=>e.index!==n&&"correct"!==t[e.index].showCorrectness)).sort(((t,n)=>{const s=Math.round(t.dist*(e.x*t.dir.x+e.y*t.dir.y)),o=Math.round(n.dist*(e.x*n.dir.x+e.y*n.dir.y));let i,r;return e.x>0?(i=t.dir.x>0&&0!==s,r=n.dir.x>0&&0!==o):e.x<0?(i=t.dir.x<0&&0!==s,r=n.dir.x<0&&0!==o):e.y>0?(i=t.dir.y>0&&0!==s,r=n.dir.y>0&&0!==o):e.y<0&&(i=t.dir.y<0&&0!==s,r=n.dir.y<0&&0!==o),i!==r?i?-1:1:s-o}));return o.length>0?o[0].index:n}constructor(e){super(e),X(this,"_markers",void 0),X(this,"_selectedMarkerPopup",void 0),X(this,"_answerChoices",void 0),X(this,"handleDocumentClick",(e=>{if(this._selectedMarkerPopup&&this._answerChoices){const t=D.default.findDOMNode(this._answerChoices),n=e.target,s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;return e&&(e.contains(n)||t>0&&s(e.parentElement,t-1))};s(t)||this.dismissMarkerPopup()}})),X(this,"handleDocumentKeyDown",(e=>{this._selectedMarkerPopup&&27===e.keyCode&&(e.stopPropagation(),this.dismissMarkerPopup())})),this._markers=[],this.state={selectedMarkerIndex:-1,markersInteracted:!1}}componentDidMount(){document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeyDown,!0)}componentWillUnmount(){document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeyDown,!0)}simpleValidate(e){return Tp.validate(this.getUserInput(),e)}getUserInput(){const{markers:e}=this.props;return{markers:e}}showRationalesForCurrentlySelectedChoices(e){const{markers:t}=this.props,{onChange:n}=this.props;n({markers:t.map((e=>{const t=Tp.gradeMarker(e);return{...e,showCorrectness:t.hasAnswers?t.isCorrect?"correct":"incorrect":void 0}}))},null,!0)}dismissMarkerPopup(){const{selectedMarkerIndex:e}=this.state;-1!==e&&this.setState({selectedMarkerIndex:-1},(()=>{const t=this._markers[e];t&&D.default.findDOMNode(t).focus()}))}handleMarkerChange(e,t){const{markers:n,onChange:s}=this.props;s({markers:[...n.slice(0,e),{...t,showCorrectness:void 0},...n.slice(e+1)]})}handleMarkerClick(e,t){const{selectedMarkerIndex:n}=this.state;t.preventDefault(),n!==e?this.setState({selectedMarkerIndex:e,markersInteracted:!0},(()=>{setTimeout((()=>{this._answerChoices&&this._answerChoices.focusAnswer()}),100)})):this.dismissMarkerPopup()}handleMarkerKeyDown(e,t){const{markers:n}=this.props;if(n.length<2)return;const s={ArrowUp:{x:0,y:-1},ArrowRight:{x:1,y:0},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0}}[t.key];if(!s)return;t.preventDefault();const o=this._markers[Tp.navigateToMarkerIndex(s,n,e)];o&&D.default.findDOMNode(o).focus()}handleAnswerChoicesChangeForMarker(e,t){const{choices:n,markers:s,multipleAnswers:o}=this.props,i=n.filter(((e,n)=>t[n]));this.handleMarkerChange(e,{...s[e],selected:i}),o||this.dismissMarkerPopup()}renderAnswerChoicesForMarker(e,t){const{choices:n,multipleAnswers:s}=this.props,o=t.selected;return A.createElement("div",{className:P.default("perseus-label-image-widget-answer-choices",l.css(Ip.scrollableChoices))},A.createElement(Sp,{choices:n.map((e=>({content:e,checked:!!o&&o.includes(e)}))),multipleSelect:s,onChange:t=>this.handleAnswerChoicesChangeForMarker(e,t),ref:e=>this._answerChoices=e}))}renderMarkers(){const{markers:e,questionCompleted:t}=this.props,{selectedMarkerIndex:n,markersInteracted:s}=this.state;return e.map(((e,o)=>{const i=Tp.gradeMarker(e),r=A.createElement(_p,$({},e,{showCorrectness:t&&i.hasAnswers&&i.isCorrect?"correct":e.showCorrectness,showSelected:o===n,showPulsate:!s,key:"".concat(e.x,".").concat(e.y),onClick:e=>this.handleMarkerClick(o,e),onKeyDown:e=>this.handleMarkerKeyDown(o,e),ref:e=>this._markers[o]=e}));if(o!==n)return r;let a;return a=window.matchMedia(jr.xsOrSmaller.replace("@media ","")).matches?e.y>50?"top":"bottom":{left:"right",top:"bottom",right:"left",bottom:"top",center:"top"}[Tp.imageSideForMarkerPosition(e.x,e.y)],A.createElement(w.Popover,{content:()=>A.createElement(w.PopoverContentCore,{style:Ip.choicesPopover},this.renderAnswerChoicesForMarker(o,e)),placement:a,opened:!0,key:"".concat(e.x,".").concat(e.y),ref:e=>this._selectedMarkerPopup=e},r)}))}renderInstructions(){const{apiOptions:{isMobile:e},choices:t,multipleAnswers:n,hideChoicesFromInstructions:s}=this.props,o=e?n?I._("Tap each dot on the image to select all answers that apply."):I._("Tap each dot on the image to select an answer."):n?I._("Click each dot on the image to select all answers that apply."):I._("Click each dot on the image to select an answer."),i=I._("Choices:");return A.createElement("div",{className:P.default("perseus-label-image-widget-instructions",l.css(Ip.instructions))},A.createElement("div",{className:l.css(Ip.instructionsCaption)},o," ",!s&&i),!s&&A.createElement("div",{className:l.css(Ip.instructionsChoices)},t.map(((e,t)=>A.createElement("div",{className:l.css(Ip.instructionsChoice),key:t},A.createElement(Li,{content:e}))))))}render(){const{imageAlt:e,imageUrl:t,imageWidth:n,imageHeight:s}=this.props,{selectedMarkerIndex:o}=this.state;return A.createElement("div",null,this.renderInstructions(),A.createElement("div",{className:l.css(Ip.markersCanvas),style:{maxWidth:n,maxHeight:s}},A.createElement("div",{className:l.css(Ip.imageContainer,-1!==o&&Ip.imageInteractionDisabled)},A.createElement(nn.Consumer,null,(o=>{let{setAssetStatus:i}=o;return A.createElement(Go,{alt:e,src:t,width:n,height:s,setAssetStatus:i})}))),this.renderMarkers()))}}const Ip=l.StyleSheet.create({instructions:{paddingBottom:16},instructionsCaption:{...ga.bodyXsmallBold,paddingBottom:16},instructionsChoices:{display:"flex",flexWrap:"wrap",margin:"-8px 0"},instructionsChoice:{display:"flex",alignItems:"center",margin:"8px 0",":not(:last-child)":{"::after":{content:"''",display:"inline-block",position:"relative",width:2,height:2,marginLeft:5,marginRight:5,background:"rgba(33, 36, 44, 0.32)",borderRadius:2}}},markersCanvas:{position:"relative"},imageContainer:{display:"flex"},imageInteractionDisabled:{pointerEvents:"none"},scrollableChoices:{paddingTop:8,paddingBottom:8,[jr.xsOrSmaller]:{maxHeight:250,overflowY:"auto"}},choicesPopover:{padding:0}});var Pp={name:"label-image",displayName:"Label Image",widget:Tp,accessible:!0,isLintable:!0};const Ap={display:"table",tableLayout:"fixed"},Np={display:"table-row"},Rp={display:"table-cell",padding:5},Fp={borderRadius:10,cursor:"pointer"},Dp={padding:5,display:"inline-block"},Op={float:"right",paddingRight:5},Lp={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?Lp.x():Lp.plus()};class Bp extends A.Component{constructor(){super(...arguments),X(this,"_flip",(()=>{this.props.onChange(!this.props.value)}))}render(){const e=this.props.value?"#55dd55":"#115511",t=N.default.extend({},Fp,{width:this.props.size,height:this.props.size,backgroundColor:e});return A.createElement("div",{style:t,onClick:this._flip})}}X(Bp,"propTypes",{value:R.default.bool.isRequired,size:R.default.number.isRequired});class zp extends A.Component{render(){return A.createElement("div",{style:Ap,className:"no-select"},N.default.map(this.props.cells,((e,t)=>A.createElement("div",{key:t,style:Np},N.default.map(e,((e,n)=>A.createElement("div",{key:n,style:Rp},A.createElement(Bp,{value:e,size:this.props.size,onChange:N.default.partial(this.props.onChange,t,n)}))))))))}}X(zp,"propTypes",{cells:R.default.arrayOf(R.default.arrayOf(R.default.bool)).isRequired,size:R.default.number.isRequired});const qp=(e,t,n,s)=>((e,t)=>N.default.map(e,((e,n)=>N.default.map(e,((e,s)=>t(n,s)?!e:e)))))(e,((e,o)=>{const i=e-t,r=o-n;return Math.abs(i)<=1&&Math.abs(r)<=1&&s[i+1][r+1]}));class Hp extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"_currPattern",void 0),X(this,"_nextPattern",void 0),X(this,"_patternIndex",void 0),X(this,"getUserInput",(()=>Dr.getUserInput.call(this))),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"_width",(()=>0!==this.props.cells.length?this.props.cells[0].length:0)),X(this,"_initNextPatterns",(()=>{this._currPattern=Lp[this.props.flipPattern](0),this._nextPattern=Lp[this.props.flipPattern](1),this._patternIndex=2})),X(this,"_shiftPatterns",(()=>{this._currPattern=this._nextPattern,this._nextPattern=Lp[this.props.flipPattern](this._patternIndex),this._patternIndex++})),X(this,"_flipTile",((e,t)=>{const n=qp(this.props.cells,e,t,this._currPattern);this._shiftPatterns(),this.change({cells:n,moveCount:this.props.moveCount+1})})),X(this,"_reset",(()=>{this.change({cells:this.props.startCells,moveCount:0})})),X(this,"simpleValidate",(e=>Wp(e,this.getUserInput())))}render(){const e=60*this._width();return A.createElement("div",null,A.createElement(zp,{cells:this.props.cells,size:50,onChange:this._flipTile}),A.createElement("div",{style:{width:e}},A.createElement("div",{style:Dp},I.ngettext("Moves: %(num)s","Moves: %(num)s",this.props.moveCount)),A.createElement("div",{style:Op},A.createElement("input",{type:"button",value:"Reset",onClick:this._reset,className:"simple-button"}))),A.createElement("div",{className:"clearfix"}))}componentDidMount(){this._initNextPatterns()}componentDidUpdate(e){e.flipPattern!==this.props.flipPattern&&this._initNextPatterns()}}X(Hp,"propTypes",{...fr,cells:R.default.arrayOf(R.default.arrayOf(R.default.bool)),startCells:R.default.arrayOf(R.default.arrayOf(R.default.bool)),flipPattern:R.default.string.isRequired,moveCount:R.default.number.isRequired}),X(Hp,"defaultProps",{cells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],startCells:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],flipPattern:"plus",moveCount:0});const Wp=function(e,t){if(N.default.all(t.cells,((t,n)=>N.default.all(t,((t,s)=>t===e.startCells[n][s])))))return{type:"invalid",message:I._("Click on the tiles to change the lights.")};return N.default.all(t.cells,(e=>N.default.all(e,(e=>e))))?{type:"points",earned:1,total:1,message:null}:e.gradeIncompleteAsWrong?{type:"points",earned:0,total:1,message:null}:{type:"invalid",message:I._("You must turn on all of the lights to continue.")}};var Up={name:"lights-puzzle",displayName:"Lights Puzzle",hidden:!0,widget:Hp,transform:function(e){return{cells:e.startCells,startCells:e.startCells,flipPattern:e.flipPattern}}};const Gp=(e,t)=>{const n=e.offsetParent();return{top:t.top+n.scrollTop(),left:t.left+n.scrollLeft()}};class Vp extends A.Component{render(){const{layout:e}=this.props,t=l.css(Xp.card,Xp.placeholder,"horizontal"===e&&Xp.horizontalCard),n={width:this.props.width,height:this.props.height};return null!=this.props.margin&&(n.margin=this.props.margin),A.createElement("li",{className:t,style:n})}}X(Vp,"propTypes",{layout:R.default.oneOf(["horizontal","vertical"]),width:R.default.number.isRequired,height:R.default.number.isRequired});class jp extends A.Component{constructor(){super(...arguments),X(this,"animationFrameRequest",null),X(this,"isMouseMoveUpBound",void 0),X(this,"_mounted",void 0),X(this,"state",{startPosition:{left:0,top:0},startMouse:{left:0,top:0},mouse:{left:0,top:0}}),X(this,"getCurrentPosition",(()=>({left:this.state.startPosition.left+this.state.mouse.left-this.state.startMouse.left,top:this.state.startPosition.top+this.state.mouse.top-this.state.startMouse.top}))),X(this,"bindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!0,L.default(document).on("mousemove",this.onMouseMove),L.default(document).on("mouseup",this.onMouseUp)})),X(this,"unbindMouseMoveUp",(()=>{this.isMouseMoveUpBound=!1,L.default(document).off("mousemove",this.onMouseMove),L.default(document).off("mouseup",this.onMouseUp)})),X(this,"onMouseDown",(e=>{if("static"!==this.props.type)return;if(0!==e.button&&(null==e.touches||1!==e.touches.length))return;e.preventDefault();const t=Be.extractPointerLocation(e);this.animationFrameRequest=requestAnimationFrame((()=>{const e=L.default(D.default.findDOMNode(this)),n=e.position(),s=Gp(e,n);t&&this._mounted&&this.setState({startPosition:s,startMouse:t,mouse:t,dragging:!0},(function(){this.bindMouseMoveUp(),this.props.onMouseDown()}))}))})),X(this,"onMouseMove",(e=>{if("dragging"!==this.props.type||!this.state.dragging)return;e.preventDefault();const t=Be.extractPointerLocation(e);t&&(this.animationFrameRequest=requestAnimationFrame((()=>{this.setState({mouse:t},this.props.onMouseMove)})))})),X(this,"onMouseUp",(e=>{if("dragging"!==this.props.type||!this.state.dragging)return;e.preventDefault();Be.extractPointerLocation(e)&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp())}))}componentDidMount(){this._mounted=!0,this.isMouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!Be.supportsPassiveEvents()&&{passive:!1})}componentWillUnmount(){this._mounted=!1,this.isMouseMoveUpBound&&this.unbindMouseMoveUp(),this.animationFrameRequest&&cancelAnimationFrame(this.animationFrameRequest),document.removeEventListener("touchmove",this.onMouseMove)}render(){const{includePadding:e,layout:t,type:n}=this.props;let s=l.css(Xp.card,Xp.draggable,"horizontal"===t&&Xp.horizontalCard,"vertical"===t&&Xp.verticalCard,"dragging"===n&&Xp.dragging,"disabled"===n&&Xp.disabled,!e&&Xp.unpaddedCard)+" "+en.INTERACTIVE+" perseus-sortable-draggable";e||(s+=" perseus-sortable-draggable-unpadded");const o={position:"static"};return"dragging"!==this.props.type&&"animating"!==this.props.type||N.default.extend(o,{position:"absolute"},this.getCurrentPosition()),this.props.width&&(o.width=this.props.width+1),this.props.height&&(o.height=this.props.height),null!=this.props.margin&&(o.margin=this.props.margin),A.createElement("li",{className:s,style:o,onMouseDown:this.onMouseDown,onTouchStart:this.onMouseDown,onTouchMove:this.onMouseMove,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},A.createElement(Li,{content:this.props.content,linterContext:Vt.pushContextStack(this.props.linterContext,"draggable"),onRender:this.props.onRender}))}componentDidUpdate(e){if(this.props.type!==e.type)if("animating"===this.props.type){const e=this.getCurrentPosition(),t=15*Math.sqrt(Math.sqrt(Math.pow(this.props.endPosition.left-e.left,2)+Math.pow(this.props.endPosition.top-e.top,2)));L.default(D.default.findDOMNode(this)).animate(this.props.endPosition,{duration:Math.max(t,1),complete:this.props.onAnimationEnd})}else"static"===this.props.type&&L.default(D.default.findDOMNode(this)).finish()}}X(jp,"propTypes",{content:R.default.string.isRequired,endPosition:R.default.object.isRequired,includePadding:R.default.bool,layout:R.default.oneOf(["horizontal","vertical"]),onAnimationEnd:R.default.func.isRequired,onMouseDown:R.default.func.isRequired,onMouseMove:R.default.func.isRequired,onMouseUp:R.default.func.isRequired,onRender:R.default.func.isRequired,type:R.default.oneOf(["static","dragging","animating","disabled"]),linterContext:jt}),X(jp,"defaultProps",{includePadding:!0,type:"static",linterContext:Yt});class Yp extends A.Component{constructor(e){super(e),X(this,"remeasureItems",N.default.debounce((()=>{this.setState({items:Yp.clearItemMeasurements(this.state.items)})}),20)),this.state={items:Yp.itemsFromProps(this.props),katex:null}}UNSAFE_componentWillReceiveProps(e){const t=this.props;N.default.isEqual(e.options,t.options)?e.layout===t.layout&&e.padding===t.padding&&e.disabled===t.disabled&&N.default.isEqual(e.constraints,t.constraints)||this.setState({items:Yp.clearItemMeasurements(this.state.items)}):this.setState({items:Yp.itemsFromProps(e)})}componentDidUpdate(){!this.state.items.length||this.state.items[0].width||this.state.items[0].height||setTimeout((()=>{this.measureItems()}),0)}componentDidMount(){le().getKaTeX().then((e=>{this.setState({katex:e})}))}static itemsFromProps(e){const t=e.disabled?"disabled":"static";return e.options.map(((e,n)=>({option:e,key:n,type:t,endPosition:{},width:0,height:0})))}static clearItemMeasurements(e){return e.map((e=>({...e,width:0,height:0})))}measureItems(){let e=N.default.clone(this.state.items);const t=N.default.map(e,(function(e){return L.default(D.default.findDOMNode(this.refs[e.key]))}),this),n=N.default.invoke(t,"outerWidth"),s=N.default.invoke(t,"outerHeight"),{constraints:o,layout:i}=this.props;let r=null;null!=o&&o.width?r=N.default.max(n.concat(o.width)):"vertical"===i&&(r=N.default.max(n));let a=null;null!=o&&o.height?a=N.default.max(s.concat(o.height)):"horizontal"===i&&(a=N.default.max(s)),e=N.default.map(e,(function(e,t){return e.width=r||n[t],e.height=a||s[t],e})),this.setState({items:e},(()=>{this.props.onMeasure&&this.props.onMeasure({widths:n,heights:s})}))}render(){var e,t;if(this.props.waitForKatexLoad&&!this.state.katex)return A.createElement(k.CircularSpinner,null);const n=[],{layout:s}=this.props,o=l.css(Xp.sortable)+" perseus-sortable",i=(null===(e=this.props.constraints)||void 0===e?void 0:e.width)||"vertical"===s,r=(null===(t=this.props.constraints)||void 0===t?void 0:t.height)||"horizontal"===s;return N.default.each(this.state.items,(function(e,t,o){const a=t===o.length-1,l="static"===e.type||"disabled"===e.type;let c;"horizontal"===this.props.layout?c="0 "+this.props.margin+"px 0 0":"vertical"===this.props.layout&&(c="0 0 "+this.props.margin+"px 0"),n.push(A.createElement(jp,{content:e.option,key:e.key,type:e.type,ref:e.key,width:i?e.width:void 0,height:r?e.height:void 0,layout:s,includePadding:this.props.padding,margin:a&&l?0:c,endPosition:e.endPosition,linterContext:Vt.pushContextStack(this.props.linterContext,"sortable"),onRender:this.remeasureItems,onMouseDown:this.onMouseDown.bind(this,e.key),onMouseMove:this.onMouseMove.bind(this,e.key),onMouseUp:this.onMouseUp.bind(this,e.key),onTouchMove:this.onMouseMove.bind(this,e.key),onTouchEnd:this.onMouseUp.bind(this,e.key),onTouchCancel:this.onMouseUp.bind(this,e.key),onAnimationEnd:this.onAnimationEnd.bind(this,e.key)})),"dragging"!==e.type&&"animating"!==e.type||n.push(A.createElement(Vp,{key:"placeholder_"+e.key,ref:"placeholder_"+e.key,width:e.width,height:e.height,layout:s,margin:a?0:c}))}),this),A.createElement("ul",{className:o},n)}onMouseDown(e){const t=N.default.map(this.state.items,(function(t){return t.key===e&&(t.type="dragging"),t}));this.setState({items:t})}moveOptionToIndex(e,t){const{items:n}=this.state;if(t<0||t>n.length)throw new Error("index ".concat(t," out of bounds"));const s=N.default.clone(n),o=n.filter((t=>t.option===e))[0];if(null==o)throw new Error("option ".concat(e," not found"));const i=n.findIndex((e=>e.key===o.key));s.splice(i,1),s.splice(t,0,o),this.setState({items:s}),this.props.onChange&&this.props.onChange({})}onMouseMove(e){const t=L.default(D.default.findDOMNode(this.refs[e])),n=L.default(D.default.findDOMNode(this)),s=N.default.clone(this.state.items),o=N.default.findWhere(this.state.items,{key:e}),i=this.props.margin||0,r=N.default.indexOf(s,o);let a=0;if(s.splice(r,1),"horizontal"===this.props.layout){const e=t.offset().left-n.offset().left;let o,r=0;N.default.each(s,(function(t){o=t.width,e>r+o/2&&(a+=1),r+=o+i}))}else{const e=t.offset().top-n.offset().top;let o,r=0;N.default.each(s,(function(t){o=t.height,e>r+o/2&&(a+=1),r+=o+i}))}a!==r&&(s.splice(a,0,o),this.setState({items:s}))}onMouseUp(e){const t=requestAnimationFrame((()=>{const t=N.default.map(this.state.items,(function(t){if(t.key===e){t.type="animating";const n=L.default(D.default.findDOMNode(this.refs["placeholder_"+e])),s=n.position(),o=Gp(n,s);t.endPosition=o}return t}),this);this.setState({items:t}),this.props.onChange&&this.props.onChange({})}));this.animationFrameRequest=t}onAnimationEnd(e){const t=N.default.map(this.state.items,(function(t){return t.key===e&&(t.type="static"),t}));this.setState({items:t})}getOptions(){return N.default.pluck(this.state.items,"option")}}X(Yp,"defaultProps",{layout:"horizontal",padding:!0,disabled:!1,constraints:{},onMeasure:function(){},margin:5,onChange:function(){},linterContext:Yt,waitForKatexLoad:!0});const Xp=l.StyleSheet.create({sortable:{boxSizing:"border-box",float:"left",padding:0,margin:0},card:{boxSizing:"border-box",background:"#fff",border:"1px solid #ddd",borderRadius:4,cursor:"pointer",minWidth:25,minHeight:44,padding:10,listStyleType:"none",userSelect:"none",touchAction:"none"},placeholder:{background:"#ddd",border:"1px solid #ccc"},draggable:{textAlign:"center"},horizontalCard:{float:"left",cursor:"ew-resize"},verticalCard:{maxWidth:"100%",cursor:"ns-resize"},unpaddedCard:{padding:0},dragging:{background:"#ffedcd",opacity:.8},disabled:{backgroundColor:"inherit",border:"1px solid transparent",cursor:"default"}}),{shuffle:$p,seededRNG:Kp}=Be;class Zp extends A.Component{constructor(){super(...arguments),X(this,"state",{leftHeight:0,rightHeight:0,katex:null}),X(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),X(this,"onMeasureLeft",(e=>{const t=N.default.max(e.heights);this.setState({leftHeight:t})})),X(this,"onMeasureRight",(e=>{const t=N.default.max(e.heights);this.setState({rightHeight:t})})),X(this,"getUserInput",(()=>this.state.katex?{left:this.refs.left.getOptions(),right:this.refs.right.getOptions()}:{left:[],right:[]})),X(this,"moveLeftOptionToIndex",((e,t)=>{this.refs.left.moveOptionToIndex(e,t)})),X(this,"moveRightOptionToIndex",((e,t)=>{this.refs.right.moveOptionToIndex(e,t)})),X(this,"simpleValidate",(e=>Zp.validate(this.getUserInput(),e)))}componentDidMount(){le().getKaTeX().then((e=>this.setState({katex:e})))}render(){if(!this.state.katex)return A.createElement(k.CircularSpinner,null);const e=Kp(this.props.problemNum);let t;t=this.props.orderMatters?$p(this.props.left,e,!0):this.props.left;const n=$p(this.props.right,e,!0),s=N.default.any(this.props.labels),o={height:N.default.max([this.state.leftHeight,this.state.rightHeight])},i=this.props.apiOptions.isMobile?8:5;return A.createElement("table",{className:l.css(Jp.widget)+" perseus-widget-matcher"},A.createElement("tbody",null,s&&A.createElement("tr",{className:l.css(Jp.row)},A.createElement("th",{className:l.css(Jp.column,Jp.columnLabel)},A.createElement(Li,{content:this.props.labels[0]||"...",linterContext:this.props.linterContext})),A.createElement("th",{className:l.css(Jp.column,Jp.columnRight,Jp.columnLabel)},A.createElement(Li,{content:this.props.labels[1]||"...",linterContext:this.props.linterContext}))),A.createElement("tr",{className:l.css(Jp.row)},A.createElement("td",{className:l.css(Jp.column)},A.createElement(Yp,{options:t,layout:"vertical",padding:this.props.padding,disabled:!this.props.orderMatters,constraints:o,onMeasure:this.onMeasureLeft,onChange:this.changeAndTrack,margin:i,linterContext:this.props.linterContext,ref:"left"})),A.createElement("td",{className:l.css(Jp.column,Jp.columnRight)},A.createElement(Yp,{options:n,layout:"vertical",padding:this.props.padding,constraints:o,onMeasure:this.onMeasureRight,onChange:this.changeAndTrack,margin:i,linterContext:this.props.linterContext,ref:"right"})))))}}X(Zp,"propTypes",{apiOptions:Qt.propTypes,labels:R.default.array,left:R.default.array,onChange:R.default.func,orderMatters:R.default.bool,padding:R.default.bool,problemNum:R.default.number,right:R.default.array,trackInteraction:R.default.func.isRequired,linterContext:jt}),X(Zp,"defaultProps",{left:[],right:[],labels:["",""],orderMatters:!1,padding:!0,problemNum:0,onChange:function(){},linterContext:Yt}),N.default.extend(Zp,{validate:function(e,t){return{type:"points",earned:N.default.isEqual(e.left,t.left)&&N.default.isEqual(e.right,t.right)?1:0,total:1,message:null}}});const Jp=l.StyleSheet.create({widget:{paddingTop:5,maxWidth:"100%",minWidth:"auto"},row:{border:0},column:{padding:0,border:0},columnRight:{borderLeft:"1px solid #444"},columnLabel:{fontWeight:"inherit",borderBottom:"1px solid #444",padding:"0 ".concat(5,"px ").concat(5,"px ").concat(5,"px"),textAlign:"center"}});var Qp={name:"matcher",displayName:"Two column matcher",widget:Zp,isLintable:!0};const{firstNumericalParse:ed,captureScratchpadTouchStart:td}=Be,nd=ue.toNumericString,sd=ue.getNumericFormat;class od extends A.Component{constructor(){super(...arguments),X(this,"state",{format:this.props.format}),X(this,"getValue",(()=>this.parseInputValue(D.default.findDOMNode(this.refs.input).value))),X(this,"getStringValue",(()=>D.default.findDOMNode(this.refs.input).value.toString())),X(this,"parseInputValue",(e=>{if(""===e){const e=this.props.placeholder;return N.default.isFinite(e)?+e:null}const t=ed(e);return N.default.isFinite(t)?t:this.props.value})),X(this,"focus",(()=>{D.default.findDOMNode(this.refs.input).focus(),this._handleFocus()})),X(this,"blur",(()=>{D.default.findDOMNode(this.refs.input).blur(),this._handleBlur()})),X(this,"setSelectionRange",((e,t)=>{D.default.findDOMNode(this).setSelectionRange(e,t)})),X(this,"getSelectionStart",(()=>D.default.findDOMNode(this).selectionStart)),X(this,"getSelectionEnd",(()=>D.default.findDOMNode(this).selectionEnd)),X(this,"_checkValidity",(e=>{if(null==e)return!0;const t=ed(e),n=this.props.checkValidity;return N.default.isFinite(t)&&n(t)})),X(this,"_handleChange",(e=>{const t=e.target.value,n=this.parseInputValue(t),s=sd(t);this.props.onChange(n),s&&(this.props.onFormatChange(n,s),this.setState({format:s}))})),X(this,"_handleFocus",(()=>{this.props.onFocus&&this.props.onFocus()})),X(this,"_handleBlur",(e=>{e&&"keypress"===e.type&&13!==e.keyCode||(this._setValue(this.props.value,this.state.format),this.props.onBlur&&this.props.onBlur())})),X(this,"_onKeyDown",(e=>{if(this.props.onKeyDown&&this.props.onKeyDown(e),!this.props.useArrowKeys||!N.default.contains(["ArrowUp","ArrowDown"],e.key))return;let t=this.getValue();t===Math.floor(t)&&("ArrowUp"===e.key?t+=1:"ArrowDown"===e.key&&(t-=1),this._checkValidity(t)&&this.props.onChange(t))})),X(this,"_setValue",((e,t)=>{L.default(D.default.findDOMNode(this.refs.input)).val(nd(e,t))}))}render(){let e=P.default({"number-input":!0,"invalid-input":!this._checkValidity(this.props.value),mini:"mini"===this.props.size,small:"small"===this.props.size,normal:"normal"===this.props.size});null!=this.props.className&&(e=e+" "+this.props.className);const{onFormatChange:t,checkValidity:n,useArrowKeys:s,...o}=this.props;return A.createElement("input",$({},o,{className:e,type:"text",ref:"input",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,onKeyPress:this._handleBlur,onKeyDown:this._onKeyDown,onTouchStart:td,defaultValue:nd(this.props.value,this.state.format),value:void 0}))}componentDidUpdate(e){d.number.equal(this.getValue(),this.props.value)||this._setValue(this.props.value,this.state.format)}}X(od,"propTypes",{value:R.default.number,format:R.default.string,placeholder:R.default.oneOfType([R.default.string,R.default.number]),onChange:R.default.func.isRequired,onFormatChange:R.default.func,checkValidity:R.default.func,size:R.default.string,label:R.default.oneOf(["put your labels outside your inputs!"])}),X(od,"defaultProps",{value:null,placeholder:null,format:null,onFormatChange:()=>null,checkValidity:()=>!0,useArrowKeys:!1});const{assert:id}=un,{stringArrayOfSize:rd}=Be,ad={INPUT_MARGIN:4,INPUT_HEIGHT:38,INPUT_WIDTH:82},ld={INPUT_MARGIN:3,INPUT_HEIGHT:30,INPUT_WIDTH:40},cd={INPUT_MARGIN:4,INPUT_HEIGHT:36,INPUT_WIDTH:64};function pd(e,t){return[""+e,""+t]}const dd=function(){return pd(0,0)},hd=function(e){return id(N.default.isArray(e)&&2===e.length),+e[0]},ud=function(e){return id(N.default.isArray(e)&&2===e.length),+e[1]},fd=function(e){return"answer"+hd(e)+","+ud(e)},md=function(e){const t=[1,1];return N.default(e).each(((e,n)=>{let s=0;N.default(e).each(((e,t)=>{null!=e&&e.toString().length&&(s=t+1)})),t[1]=Math.max(t[1],s),s>0&&(t[0]=Math.max(t[0],n+1))})),t};class gd extends A.Component{constructor(){super(...arguments),X(this,"cursorPosition",void 0),X(this,"state",{enterTheMatrix:0}),X(this,"getInputPaths",(()=>{const e=[],t=this.props.matrixBoardSize[0],n=this.props.matrixBoardSize[1];return N.default(t).times((t=>{N.default(n).times((n=>{const s=pd(t,n);e.push(s)}))})),e})),X(this,"getGrammarTypeForPath",(e=>"number")),X(this,"_handleFocus",((e,t)=>{this.props.onFocus(pd(e,t))})),X(this,"_handleBlur",((e,t)=>{this.props.onBlur(pd(e,t))})),X(this,"focus",(()=>(this.focusInputPath(dd()),!0))),X(this,"focusInputPath",(e=>{const t=fd(e);this.refs[t].focus()})),X(this,"blurInputPath",(e=>{0===e.length&&(e=dd());const t=fd(e);this.refs[t].blur()})),X(this,"getDOMNodeForPath",(e=>{const t=fd(e);return D.default.findDOMNode(this.refs[t])})),X(this,"setInputValue",((e,t,n)=>{const s=hd(e),o=ud(e);this.onValueChange(s,o,t,n)})),X(this,"handleKeyDown",((e,t,n)=>{const s=this.props.matrixBoardSize[0],o=this.props.matrixBoardSize[1];let i=null;const r=this.refs[fd(pd(e,t))],a=r.getStringValue(),l=r.getSelectionStart(),c=r.getSelectionEnd();let p=null;if("ArrowUp"===n.key&&e>0?p=pd(e-1,t):"ArrowDown"===n.key&&e+1<s?p=pd(e+1,t):"ArrowLeft"===n.key&&t>0?0===l&&0===c&&(p=pd(e,t-1)):"ArrowRight"===n.key&&t+1<o?l===a.length&&(p=pd(e,t+1)):"Enter"===n.key?i=this.state.enterTheMatrix+1:"Escape"===n.key&&(i=0),p){n.preventDefault();const e=this.refs[fd(p)],t=2*e.getStringValue().length;e.focus(),"ArrowRight"===n.key?e.setSelectionRange(0,0):e.setSelectionRange(t,t)}null!=i&&this.setState({enterTheMatrix:i})})),X(this,"onValueChange",((e,t,n,s)=>{const o=N.default.map(this.props.answers,N.default.clone);o[e]||(o[e]=[]),o[e][t]=n,this.props.onChange({answers:o},s),this.props.trackInteraction()})),X(this,"getUserInput",(()=>({answers:this.props.answers}))),X(this,"simpleValidate",(e=>gd.validate(this.getUserInput(),e)))}componentDidMount(){this.cursorPosition=[0,0]}render(){let e;e=this.props.apiOptions.customKeypad?cd:this.props.apiOptions.staticRender?ad:ld;const{INPUT_MARGIN:t,INPUT_HEIGHT:n,INPUT_WIDTH:s}=e,o=md(this.props.answers),i=this.props.matrixBoardSize[0],r=this.props.matrixBoardSize[1],a=this.props.cursorPosition[0],l=this.props.cursorPosition[1],c=Math.max(a,o[0]-1),p=Math.max(l,o[1]-1),d=(c+1)*(n+2*t),h=(p+1)*(s+2*t),u=P.default({"perseus-matrix":!0,"static-mode":this.props.static,"the-matrix":this.state.enterTheMatrix>=5});return A.createElement("div",{className:u},this.props.prefix&&A.createElement("div",{className:"matrix-prefix"},A.createElement(Li,{content:this.props.prefix,linterContext:this.props.linterContext})),A.createElement("div",{className:"matrix-input"},A.createElement("div",{className:"matrix-bracket bracket-left",style:{height:d}}),A.createElement("div",{className:"matrix-bracket bracket-right",style:{height:d,left:h}}),N.default(i).times((e=>{const o=this.props.answers[e];return A.createElement("div",{className:"matrix-row",key:e},N.default(r).times((i=>{const r=e>c||i>p,a={className:r?"outside":"inside",ref:fd(pd(e,i)),value:o?o[i]:null,style:{height:n,width:s,margin:t},disabled:this.props.apiOptions.readOnly,onFocus:()=>{this.cursorPosition=[e,i],this.props.onChange({cursorPosition:[e,i]},(()=>!1)),this._handleFocus(e,i)},onBlur:()=>{e===this.cursorPosition[0]&&i===this.cursorPosition[1]&&this.props.onChange({cursorPosition:[0,0]},(()=>!1)),this._handleBlur(e,i)},onKeyDown:t=>{this.handleKeyDown(e,i,t)},onChange:(t,n)=>{this.onValueChange(e,i,t,n)}};let l;if(this.props.apiOptions.customKeypad){const e={margin:t,minWidth:s,minHeight:n,boxSizing:"border-box",backgroundColor:r?"#f3f3f3":"#fff"};l=A.createElement(wr,$({},a,{style:e,scrollable:!0,keypadElement:this.props.keypadElement}))}else l=this.props.apiOptions.staticRender?A.createElement(Qi,a):this.props.numericInput?A.createElement(od,a):A.createElement(er,a);return A.createElement("span",{key:i,className:"matrix-input-field"},l)})))}))),this.props.suffix&&A.createElement("div",{className:"matrix-suffix"},A.createElement(Li,{content:this.props.suffix,linterContext:this.props.linterContext})))}}X(gd,"defaultProps",{matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0],apiOptions:Qt.defaults,linterContext:Yt}),N.default.extend(gd,{validate:function(e,t){const n=t.answers,s=e.answers,o=md(n),i=md(s),r=o[0]!==i[0]||o[1]!==i[1],a=ge.number.createValidatorFunctional;let l=null,c=!1,p=!1;return N.default(i[0]).times((e=>{N.default(i[1]).times((t=>{if(null!=s[e][t]&&0!==s[e][t].toString().length||(c=!0),!r){const o=a(n[e][t],{simplify:!0})(s[e][t]);o.message&&(l=o.message),o.correct||(p=!0)}}))})),c?{type:"invalid",message:I._("Make sure you fill in all cells in the matrix.")}:r?{type:"points",earned:0,total:1,message:null}:{type:"points",earned:p?0:1,total:1,message:l}}});var vd={name:"matrix",displayName:"Matrix",widget:gd,transform:e=>{const t=N.default(e.matrixBoardSize[0]).times((function(){return rd(e.matrixBoardSize[1])}));return e=N.default.pick(e,"matrixBoardSize","prefix","suffix"),N.default.extend(e,{answers:t})},staticTransform:e=>{const t=N.default.pick(e,"matrixBoardSize","prefix","suffix");return t.answers=N.default.map(e.answers,(e=>N.default.map(e,(e=>null!=e?String(e):"")))),t},isLintable:!0};const bd={url:null,top:0,left:0},yd=B.default({displayName:"Measurer",propTypes:{apiOptions:Qt.propTypes,box:R.default.arrayOf(R.default.number),image:R.default.shape({url:R.default.string,top:R.default.number,left:R.default.number}),showProtractor:R.default.bool,protractorX:R.default.number,protractorY:R.default.number,showRuler:R.default.bool,rulerLabel:R.default.string,rulerTicks:R.default.number,rulerPixels:R.default.number,rulerLength:R.default.number},getDefaultProps:function(){return{box:[480,480],image:{},showProtractor:!0,protractorX:7.5,protractorY:.5,showRuler:!1,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10}},getInitialState:function(){return{}},render:function(){const e=N.default.extend({},bd,this.props.image);return A.createElement("div",{className:"perseus-widget perseus-widget-measurer graphie-container above-scratchpad",style:{width:this.props.box[0],height:this.props.box[1]}},e.url&&A.createElement("div",{style:{position:"relative",top:e.top,left:e.left}},A.createElement(Go,{src:e.url})),A.createElement("div",{className:"graphie",ref:"graphieDiv"}))},componentDidMount:function(){this.setupGraphie()},componentDidUpdate:function(e){N.default.any(["box","showProtractor","showRuler","rulerLabel","rulerTicks","rulerPixels","rulerLength"],(function(t){return e[t]!==this.props[t]}),this)&&this.setupGraphie()},setupGraphie:function(){const e=D.default.findDOMNode(this.refs.graphieDiv);L.default(e).empty();const t=this.graphie=wn.createGraphie(e),n=[40,40],s=[[0,this.props.box[0]/n[0]],[0,this.props.box[1]/n[1]]];t.init({range:s,scale:n}),t.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),this.protractor&&this.protractor.remove(),this.props.showProtractor&&(this.protractor=t.protractor([this.props.protractorX,this.props.protractorY])),this.ruler&&this.ruler.remove(),this.props.showRuler&&(this.ruler=t.ruler({center:[(s[0][0]+s[0][1])/2,(s[1][0]+s[1][1])/2],label:this.props.rulerLabel,pixelsPerUnit:this.props.rulerPixels,ticksPerUnit:this.props.rulerTicks,units:this.props.rulerLength}))},getUserInput:function(){return{}},simpleValidate:function(e){return yd.validate(this.getUserInput(),e)},focus:L.default.noop});N.default.extend(yd,{validate:function(e,t){return{type:"points",earned:1,total:1,message:null}}});var xd={name:"measurer",displayName:"Measurer",widget:yd,version:{major:1,minor:0},propUpgrades:{1:e=>N.default(e).chain().omit("imageUrl","imageTop","imageLeft").extend({image:{url:e.imageUrl,top:e.imageTop,left:e.imageLeft}}).value()}};function Cd(e,t){const n=new Path2D;e.lineWidth=_d.lineWidth,e.strokeStyle=_d.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n)}const wd={text:function(e,t){null!==t.value&&(e.fillStyle=_d.fgColor,e.font=_d.font,e.fillText(t.value,t.pos[0]-_d.fontSizePx/2+1,t.pos[1]+_d.fontSizePx/2))},"line:single":Cd,"line:double":function(e,t){let n=new Path2D;e.lineWidth=5*_d.lineWidth,e.strokeStyle=_d.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),n=new Path2D,e.lineWidth=3*_d.lineWidth,e.strokeStyle=_d.bgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n)},"line:triple":function(e,t){let n=new Path2D;e.lineWidth=7*_d.lineWidth,e.strokeStyle=_d.fgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),n=new Path2D,e.lineWidth=5*_d.lineWidth,e.strokeStyle=_d.bgColor,n.moveTo(t.startPos[0],t.startPos[1]),n.lineTo(t.endPos[0],t.endPos[1]),e.stroke(n),Cd(e,t)}};const kd={"line:single":0,"line:double":0,"line:triple":0,text:1};function Sd(e,t){return kd[e.type]-kd[t.type]}function Ed(e,t){t.sort(Sd).forEach(function(e){return function(t){wd[t.type](e,t)}}(e))}const _d={bgColor:"rgb(255, 255, 255)",fgColor:"rgb(0, 0, 0)",fontSizePx:12,lineWidth:1,font:"12px sans"};function Md(e,t,n,s){let o=e.symbol;if("C"===o&&1!==Object.keys(t).length&&(o=null),"1,0"===e.idx){const t=[0,0];return e.pos=t,e.baseAngle=-30+s,{type:"text",value:o,pos:t,idx:e.idx}}const i=t[e.connections.find((function(e){return t[e].pos}))],r=i.connections.indexOf(e.idx);let a=60,l=120;4===i.connections.length?(l=90,a=90):(n.find((t=>"triple"===t.bondType&&t.to===e.idx))||n.find((e=>"triple"===e.bondType&&e.to===i.idx)))&&(l=0,a=0);let c=0;const p=i.idx.split(":"),d=p[p.length-1].split(",")[0];c=parseInt(d)%2!=0?i.baseAngle-(a-l*r):i.baseAngle+(a-l*r);const h=function(e,t,n){const s=e[0],o=e[1];return[s+Math.cos(2*t*Math.PI/360)*n,o+-1*Math.sin(2*t*Math.PI/360)*n]}(i.pos,c,30);return e.pos=h,e.baseAngle=c,{type:"text",value:o,pos:h,idx:e.idx}}function Td(e,t){const n=function(e,t){let n=[e.pos[0],e.pos[1]],s=[t.pos[0],t.pos[1]];return"C"!==e.symbol&&(n=[t.pos[0]-.75*(t.pos[0]-e.pos[0]),t.pos[1]-.75*(t.pos[1]-e.pos[1])]),"C"!==t.symbol&&(s=[e.pos[0]-.75*(e.pos[0]-t.pos[0]),e.pos[1]-.75*(e.pos[1]-t.pos[1])]),[n,s]}(t[e.from],t[e.to]);return{type:"line:"+e.bondType,startPos:n[0],endPos:n[1]}}function Id(e){return e.join(":")}function Pd(e,t,n){if(null===n)return[e,t];if("atom"===n.type){const s=Id(n.idx);e[s]={idx:s,symbol:n.symbol,connections:[]},n.bonds&&n.bonds.forEach((function(n){const o=Id(n.to.idx);e[s].connections.push(o),t.push({from:s,to:o,bondType:n.bondType}),Pd(e,t,n.to),e[o].connections.push(s)}))}return[e,t]}function Ad(e,t,n,s,o){if(0===t.length)return e;const i=t.shift(),r=n[i];return r.connections.forEach((function(e){n[e].pos||t.push(e)})),Ad(e.concat(Md(r,n,s,o)),t,n,s,o)}function Nd(e,t,n){return 0===n.length?e:Nd(e.concat(Td(n[0],t)),t,n.slice(1))}var Rd={layout:function(e,t){const n=Pd({},[],e),s=n[0],o=n[1];return Nd(Ad([],["1,0"],s,o,t),s,o)},_atomLayout:Md,_bondLayout:Td,_bondLength:30,_convertTree:Pd};const Fd=new RegExp("^[A-Za-z\\[\\]()=#+-]*$"),Dd=new RegExp("^(Cl|Br|[CONPSFBI]|\\[)");function Od(e){this.message=e}function Ld(e,t,n){const s=t[0],o=t.slice(1);let i;i=Array.isArray(e)?[...e]:{...e||{}};let r=n;return o.length>0&&(r=Ld(i[s],o,n)),i[s]=r,i}function Bd(e,t){if(0===t.length)return e;if(""===e)throw new Od("Mismatched parentheses");const n=e[0],s=e.slice(1);return Bd(s,"("===n?t.concat(n):")"===n?t.slice(1):t)}function zd(e,t){const n=e[0],s=e.slice(1);if("("===n){let e={...t,parens:t.parens+"("};e=function(e,t){const n=t.reduce((function(e,t){return e[t]}),e);return Ld(e,t,n+1)}(t,["idx",t.idx.length-1,1]);let n=-1;t.idx[t.idx.length-1][0]%2==0&&(n=0);const o=Hd(s,{...e,idx:e.idx.concat([[n,0]]),parens:e.parens.concat("(")}),i=Hd(Bd(s,["("]),e);return[o].concat(i)}if(")"===n){if("("!==t.parens[t.parens.length-1])throw new Od("Mismatched parentheses");return null}throw new Od("Invalid bare character: "+n)}function qd(e,t){const n=function(e,t){let n=null,s=null;if("["===e[0]){const t=e.indexOf("]");if(-1===t)return["",e];n=e.slice(1,t),s=e.slice(t+1)}else n=Dd.exec(e)[1],s=e.slice(n.length);return[n,s]}(e),s=n[0];if(""===s)return["error","Unable to parse bracketed atom."];const o=n[1],i=Ld(t,["idx",t.idx.length-1],[1+t.idx[t.idx.length-1][0],0]);let r=Hd(o,Ld(i,["bond","bondType"],"single"));!Array.isArray(r)&&r&&(r=[r]);const a={type:"atom",symbol:s,bonds:r,idx:i.idx};return t.bond?{type:"bond",bondType:t.bond.bondType,to:a}:a}function Hd(e,t){if(!function(e){return Fd.test(e)}(e))throw new Od("Invalid input.");return e&&0!==e.length?(n=e,Dd.test(n)?qd(e,t||{idx:[[0,0]],parens:[],stack:[],bondModifiers:[]}):function(e){return"="===e||"#"===e}(e[0])?function(e,t){const n=e[0],s=e.slice(1);if("="===n)return Hd(s,Ld(t,["bond","bondType"],"double"));if("#"===n)return Hd(s,Ld(t,["bond","bondType"],"triple"));throw new Od("Invalid character: "+n)}(e,t):zd(e,t)):null;var n}var Wd=Hd,Ud=Od;const{layout:Gd}=Rd,Vd=Wd,jd=Ud;class Yd extends A.Component{constructor(){super(...arguments),X(this,"state",{parsedSmiles:null,error:null}),X(this,"stateFromSmiles",(e=>{try{this.setState({parsedSmiles:Vd(e),error:null})}catch(e){if(!(e instanceof jd))throw e;this.setState({error:e.message})}})),X(this,"setCanvasBounds",((e,t)=>{const n=Math.max(...t.map((e=>e.pos?e.pos[0]:-1/0))),s=Math.max(...t.map((e=>e.pos?e.pos[1]:-1/0))),o=Math.min(...t.map((e=>e.pos?e.pos[0]:1/0))),i=Math.min(...t.map((e=>e.pos?e.pos[1]:1/0))),r=n-o+60,a=s-i+60;return e.width=r,e.height=a,[30-o,30-i]})),X(this,"canvasRender",(()=>{if(this.state.error||!this.state.parsedSmiles)return;const e=Gd(this.state.parsedSmiles,this.props.rotationAngle),t=this.refs.canvas,n=this.setCanvasBounds(t,e),s=t.getContext("2d");s.clearRect(0,0,t.width,t.height),s.save(),s.translate(n[0],n[1]),Ed(s,e),s.restore()}))}UNSAFE_componentWillMount(){this.stateFromSmiles(this.props.smiles)}componentDidMount(){this.canvasRender()}UNSAFE_componentWillReceiveProps(e){this.stateFromSmiles(e.smiles)}componentDidUpdate(){this.canvasRender()}render(){let e=A.createElement("canvas",{className:"molecule-canvas",id:this.props.id+"-molecule",ref:"canvas"},I.$_("A molecular structure drawing. SMILES notation: %(content)s",{content:this.props.smiles}));return this.state.error&&(e=A.createElement("div",{className:"error"},this.state.error)),A.createElement("div",{className:"molecule-canvas"},e)}}X(Yd,"propTypes",{id:R.default.string.isRequired,rotationAngle:R.default.number,smiles:R.default.string});class Xd extends A.Component{constructor(){super(...arguments),X(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),X(this,"getUserInput",(()=>[])),X(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null})))}render(){return A.createElement(Yd,{id:this.props.widgetId,smiles:this.props.smiles,rotationAngle:this.props.rotationAngle})}}X(Xd,"propTypes",{rotationAngle:R.default.number,smiles:R.default.string,widgetId:R.default.string}),X(Xd,"defaultProps",{rotationAngle:0});var $d={name:"molecule-renderer",displayName:"Molecule renderer",hidden:!0,widget:Xd};const Kd=Po.MovablePoint,Zd=Po.Line,{assert:Jd}=un,Qd={ge:"le",gt:"lt",le:"ge",lt:"gt"},eh={ge:"gt",gt:"ge",le:"lt",lt:"le"};function th(e,t){return 1===t?""+e:"\\dfrac{".concat(e,"}{").concat(t,"}")}function nh(e,t){if(e<0)return"-"+nh(-e,t);const n=Math.floor(e/t);return 0===n?th(e,t):e-n*t==0?""+n:n+th(e-n*t,t)}const sh=(e,t,n,s,o)=>{if(s=s||n,"decimal"===t||"decimal ticks"===t)return e.label([n,-.53],Math.round(100*s)/100,"center");if("improper"===t){const t=ue.toFraction(s);return e.label([n,-.17],th(t[0],t[1]),"below")}if("mixed"===t){const t=ue.toFraction(s);return e.label([n,-.17],nh(t[0],t[1]),"below")}if("non-reduced"===t){const t=ue.toFraction(s);return e.label([n,-.17],function(e,t,n){return th(e*Math.floor(n/t),n)}(t[0],t[1],o),"below")}},oh=Po.createSimpleClass(((e,t)=>{if(!N.default.isFinite(t.tickStep)||t.tickStep<=0)return[];const n=[],s=t.range,o=t.labelRange,i=null==o[0]?s[0]:o[0],r=null==o[1]?s[1]:o[1];let a;if("non-reduced"===t.labelStyle){const e=[i,r];for(let n=0;n<=t.numDivisions;n++){const o=s[0]+n*t.tickStep;e.push(o)}const n=e=>d.number.toFraction(e)[1],o=N.default.map(e,n);a=N.default.reduce(o,((e,t)=>ue.getLCM(e,t)))}else a=void 0;for(let o=0;o<=t.numDivisions;o++){const i=s[0]+o*t.tickStep;n.push(e.line([i,-.2],[i,.2]));(t.labelTicks||"decimal ticks"===t.labelStyle)&&n.push(sh(e,t.labelStyle,i,i,a))}return n.push(e.style(t.isMobile?{color:gn.BLUE_D}:{},(()=>sh(e,t.labelStyle,i,i,a)))),n.push(e.style(t.isMobile?{color:gn.BLUE_D}:{},(()=>sh(e,t.labelStyle,r,r,a)))),e.style({stroke:t.isMobile?gn.BLUE_D:gn.DYNAMIC,strokeWidth:3.5},(()=>{n.push(e.line([i,-.2],[i,.2])),n.push(e.line([r,-.2],[r,.2]))})),n}));class ih extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"state",{numDivisionsEmpty:!1}),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"isValid",(()=>{const e=this.props.range;let t=this.props.numLinePosition;const n=this.props.divisionRange;return t=null==t?e[0]:t,e[0]<e[1]&&d.number.sign(t-e[0])>=0&&d.number.sign(t-e[1])<=0&&n[0]<n[1]&&0<this.props.numDivisions&&0<this.props.snapDivisions})),X(this,"onNumDivisionsChange",((e,t)=>{const n=this.props.divisionRange.slice(),s=this.props.range[1]-this.props.range[0];if(e=(e=Math.round(e))<0?-1*e:e){const o=N.default.extend({},this.props,{tickStep:s/e}),i=this.snapNumLinePosition(o,this.props.numLinePosition);this.setState({numDivisionsEmpty:!1},(()=>{this.props.onChange({divisionRange:n,numDivisions:e,numLinePosition:i},t)}))}else this.setState({numDivisionsEmpty:!0},t)})),X(this,"_handleTickCtrlFocus",(()=>{this.props.onFocus(["tick-ctrl"])})),X(this,"_handleTickCtrlBlur",(()=>{this.props.onBlur(["tick-ctrl"])})),X(this,"focus",(()=>{if(this.props.isTickCtrl)return this.refs["tick-ctrl"].focus(),!0})),X(this,"focusInputPath",(e=>{1===e.length&&this.refs[e[0]].focus()})),X(this,"blurInputPath",(e=>{1===e.length&&this.refs[e[0]].blur()})),X(this,"getInputPaths",(()=>this.props.isTickCtrl?[["tick-ctrl"]]:[])),X(this,"getDOMNodeForPath",(e=>{if(1===e.length)return D.default.findDOMNode(this.refs[e[0]])})),X(this,"getGrammarTypeForPath",(e=>{if(1===e.length&&"tick-ctrl"===e[0])return"number"})),X(this,"setInputValue",((e,t,n)=>{1===e.length&&"tick-ctrl"===e[0]&&this.onNumDivisionsChange(t,n)})),X(this,"_renderGraphie",(()=>{const e=this.props.range,t=e[1]-e[0],n=N.default.pick(this.props,["range","isTickCtrl"]),s=N.default.extend({},this.props,{tickStep:t/this.props.numDivisions});return A.createElement(Po,{ref:"graphie",key:this.props.labelStyle,box:[this.props.apiOptions.isMobile?288:460,80],options:n,onMouseDown:e=>{this.refs.graphie.movables.numberLinePoint.grab(e)},setup:this._setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable,isMobile:this.props.apiOptions.isMobile},A.createElement(oh,$({},N.default.pick(s,["range","numDivisions","labelTicks","labelStyle","labelRange","tickStep"]),{isMobile:this.props.apiOptions.isMobile})),this._renderInequality(s),this._renderNumberLinePoint(s))})),X(this,"snapNumLinePosition",((e,t)=>{const n=e.range[0],s=e.range[1],o=e.tickStep/e.snapDivisions;let i=((e,t,n)=>Math.min(Math.max(e,t),n))(t,n,s);return i=n+d.number.roundTo(i-n,o),Jd(N.default.isFinite(i)),i})),X(this,"movePosition",(e=>{this.change({numLinePosition:e}),this.props.trackInteraction()})),X(this,"_renderNumberLinePoint",(e=>{const t=N.default(["lt","gt"]).contains(e.rel);let n;n=t?gn._BACKGROUND:e.static?gn.DYNAMIC:gn.INTERACTIVE;const s={fill:n,stroke:e.static?gn.DYNAMIC:gn.INTERACTIVE,"stroke-width":t?3:1},o={fill:t?gn._BACKGROUND:gn.INTERACTING,"stroke-width":t?3:1},i=e.isInequality?{stroke:gn.INTERACTIVE,"fill-opacity":t?0:1}:{};return A.createElement(Kd,{ref:"numberLinePoint",pointSize:6,coord:[e.numLinePosition,0],constraints:[(e,t)=>[e[0],t[1]],(t,n)=>[this.snapNumLinePosition(e,t[0]),t[1]]],normalStyle:s,highlightStyle:o,onMove:e=>{this.movePosition(e[0])},isMobile:this.props.apiOptions.isMobile,mobileStyleOverride:i,showTooltips:this.props.showTooltips,xOnlyTooltip:!0})})),X(this,"handleReverse",(()=>{const e=Qd[this.props.rel];this.props.onChange({rel:e})})),X(this,"handleToggleStrict",(()=>{const e=eh[this.props.rel];this.props.onChange({rel:e})})),X(this,"_getInequalityEndpoint",(e=>{const t=N.default(["ge","gt"]).contains(e.rel),n=e.range,s=30*((n[1]-n[0])/400),o=n[0]-s,i=n[1]+s;return t?[i,0]:[o,0]})),X(this,"_renderInequality",(e=>{if(e.isInequality){const t=this._getInequalityEndpoint(e),n={arrows:"->",stroke:this.props.apiOptions.isMobile?gn.INTERACTIVE:gn.DYNAMIC,strokeWidth:3.5},s=["ge","gt"].includes(e.rel);return A.createElement(Zd,{start:[(s?.4:-.4)+e.numLinePosition,0],end:t,style:n})}return null})),X(this,"_setupGraphie",((e,t)=>{if(!this.isValid())return;const n=this.props.apiOptions.isMobile?228:400,s=t.range,o=(s[1]-s[0])/n,i=30*o,r=s[0]-i,a=s[1]+i,l="improper"===this.props.labelStyle||"mixed"===this.props.labelStyle||"non-reduced"===this.props.labelStyle?-1.5:-1;e.init({range:[[r,a],[l,1]],scale:[1/o,40],isMobile:this.props.apiOptions.isMobile});const c=(s[0]+s[1])/2;e.line([c,0],[a,0],{arrows:"->"}),e.line([c,0],[r,0],{arrows:"->"})})),X(this,"getUserInput",(()=>({numLinePosition:this.props.numLinePosition,rel:this.props.isInequality?this.props.rel:"eq",numDivisions:this.props.numDivisions,divisionRange:this.props.divisionRange}))),X(this,"simpleValidate",(e=>ih.validate(this.getUserInput(),e)))}render(){const e=this.props.divisionRange,t=e[0]+"–"+e[1],n=this.props.numDivisions<e[0]||this.props.numDivisions>e[1],s=A.createElement("div",null,A.createElement("input",{type:"button",className:"simple-button",value:I._("Switch direction"),onClick:this.handleReverse}),A.createElement("input",{type:"button",className:"simple-button",value:N.default(["le","ge"]).contains(this.props.rel)?I._("Make circle open"):I._("Make circle filled"),onClick:this.handleToggleStrict}));let o;if(this.props.isTickCtrl){let t;t=this.props.apiOptions.customKeypad?wr:this.props.apiOptions.staticRender?Qi:od,o=A.createElement("label",null,I._("Number of divisions:")," ",A.createElement(t,{ref:"tick-ctrl",value:this.state.numDivisionsEmpty?null:this.props.numDivisions||e[0],checkValidity:t=>t>=e[0]&&t<=e[1],onChange:this.onNumDivisionsChange,onFocus:this._handleTickCtrlFocus,onBlur:this._handleTickCtrlBlur,useArrowKeys:!0,keypadElement:this.props.keypadElement}))}return A.createElement("div",{className:"perseus-widget perseus-widget-interactive-number-line"},o,this.isValid()?this.props.isTickCtrl&&n?A.createElement("div",{className:"perseus-error"},I.$_("Please make sure the number of divisions is in the range %(divRangeString)s.",{divRangeString:t})):this._renderGraphie():A.createElement("div",{className:"perseus-error"},I.doNotTranslate("Invalid number line configuration.")),!this.props.static&&this.props.isInequality&&s)}}X(ih,"defaultProps",{range:[0,10],labelStyle:"decimal",labelRange:[null,null],divisionRange:[1,12],labelTicks:!0,isTickCtrl:!1,isInequality:!1,numLinePosition:0,snapDivisions:2,showTooltips:!1,rel:"ge",apiOptions:Qt.defaults}),N.default.extend(ih,{validate:function(e,t){const n=t.range,s=e.divisionRange,o=null!=t.initialX?t.initialX:n[0],i=t.isInequality?"ge":"eq",r=t.correctRel||"eq",a=d.number.equal(e.numLinePosition,t.correctX||0),l=e.numDivisions>s[1]||e.numDivisions<s[0];return e.isTickCrtl&&l?{type:"invalid",message:"Number of divisions is outside the allowed range."}:a&&r===e.rel?{type:"points",earned:1,total:1,message:null}:e.numLinePosition===o&&e.rel===i?{type:"invalid",message:null}:{type:"points",earned:0,total:1,message:null}}});var rh={name:"number-line",displayName:"Number line",widget:ih,transform:e=>{const t=N.default.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isTickCtrl","isInequality","showTooltips"]),n=null!=e.initialX?e.initialX:e.range[0],s=e.range[1]-e.range[0];let o;return o=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?s/e.tickStep:void 0,N.default.extend(t,{numLinePosition:n,numDivisions:o,snapDivisions:t.snapDivisions||void 0}),t},staticTransform:e=>{const t=N.default.pick(e,["range","labelRange","labelStyle","labelTicks","divisionRange","snapDivisions","isInequality"]),n=null!=e.correctX?e.correctX:e.range[0],s=e.range[1]-e.range[0];let o;return o=null!=e.numDivisions?e.numDivisions:null!=e.tickStep?s/e.tickStep:void 0,N.default.extend(t,{numLinePosition:n,numDivisions:o,rel:e.isInequality?e.correctRel:null,snapDivisions:t.snapDivisions||void 0}),t}};class ah extends A.Component{render(){return A.createElement("div",{className:"card-wrap "+en.INTERACTIVE,style:{width:this.props.width}},A.createElement("div",{className:"card placeholder",style:{height:this.props.height}}))}}X(ah,"propTypes",{width:R.default.number.isRequired,height:R.default.number.isRequired});class lh extends A.Component{render(){return A.createElement("div",{className:"card-wrap "+en.INTERACTIVE},A.createElement("div",{className:"card drag-hint"}))}}const ch=R.default.shape({left:R.default.number,top:R.default.number});class ph extends A.Component{constructor(){super(...arguments),X(this,"mouseMoveUpBound",void 0),X(this,"state",{dragging:!1}),X(this,"bindMouseMoveUp",(()=>{this.mouseMoveUpBound=!0,L.default(document).on("mousemove",this.onMouseMove),L.default(document).on("mouseup",this.onMouseUp)})),X(this,"unbindMouseMoveUp",(()=>{this.mouseMoveUpBound=!1,L.default(document).off("mousemove",this.onMouseMove),L.default(document).off("mouseup",this.onMouseUp)})),X(this,"onMouseDown",(e=>{e.preventDefault();const t=Be.extractPointerLocation(e);t&&(this.setState({dragging:!0}),this.bindMouseMoveUp(),this.props.onMouseDown&&this.props.onMouseDown(t,this))})),X(this,"onMouseMove",(e=>{if(!this.state.dragging)return;e.preventDefault();const t=Be.extractPointerLocation(e);t&&this.props.onMouseMove&&this.props.onMouseMove(t)})),X(this,"onMouseUp",(e=>{e.preventDefault();const t=Be.extractPointerLocation(e);t&&(this.setState({dragging:!1}),this.unbindMouseMoveUp(),this.props.onMouseUp&&this.props.onMouseUp(t))}))}render(){let e={};this.props.floating&&(e={position:"absolute",left:this.props.startOffset.left,top:this.props.startOffset.top}),this.props.width&&(e.width=this.props.width);const t=["card"];this.props.stack&&t.push("stack"),this.props.floating&&!this.props.animating&&(t.push("dragging"),e.left+=this.props.mouse.left-this.props.startMouse.left,e.top+=this.props.mouse.top-this.props.startMouse.top);const n=N.default.pick(this.props,"content"),s=this.props.animating?L.default.noop:this.onMouseDown;return A.createElement("div",{className:"card-wrap "+en.INTERACTIVE,style:e,onMouseDown:s,onTouchStart:s,onTouchEnd:this.onMouseUp,onTouchCancel:this.onMouseUp},A.createElement("div",{className:t.join(" ")},A.createElement(Li,$({},n,{linterContext:this.props.linterContext}))))}shouldComponentUpdate(e,t){return this.props.floating||e.floating||this.props.content!==e.content||this.props.fakeRef!==e.fakeRef}componentDidMount(){this.mouseMoveUpBound=!1,document.addEventListener("touchmove",this.onMouseMove,!!Be.supportsPassiveEvents()&&{passive:!1})}componentDidUpdate(e,t){if(this.props.animating&&!e.animating){const e=15*Math.sqrt(Math.sqrt(Math.pow(this.props.animateTo.left-this.props.startOffset.left,2)+Math.pow(this.props.animateTo.top-this.props.startOffset.top,2)));L.default(D.default.findDOMNode(this)).animate(this.props.animateTo,Math.max(e,1),this.props.onAnimationEnd)}}componentWillUnmount(){this.mouseMoveUpBound&&(de.error("Removing an element with bound event handlers.",pe.Internal),this.unbindMouseMoveUp(),Be.resetTouchHandlers()),document.removeEventListener("touchmove",this.onMouseMove)}}X(ph,"propTypes",{floating:R.default.bool.isRequired,animating:R.default.bool,width:R.default.number,stack:R.default.bool,onMouseDown:R.default.func,onMouseMove:R.default.func,onMouseUp:R.default.func,startMouse:ch,startOffset:ch,animateTo:ch,onAnimationEnd:R.default.func,linterContext:jt}),X(ph,"defaultProps",{stack:!1,animating:!1,linterContext:Yt});class dh extends A.Component{constructor(){super(...arguments),X(this,"state",{current:[],dragging:!1,placeholderIndex:null,dragKey:null,animating:!1,dragContent:null,dragWidth:null,dragHeight:null,offsetPos:null,animateTo:null,grabPos:null}),X(this,"onClick",((e,t,n,s)=>{const o=L.default(D.default.findDOMNode(s)),i=this.state.current.slice();let r,a=null;"current"===e?(i.splice(t,1),r=this.state.current[t],a=t):"bank"===e&&(r=this.props.options[t]),this.setState({current:i,dragging:!0,placeholderIndex:a,dragKey:r.key,dragContent:r.content,dragWidth:o.width(),dragHeight:o.height(),grabPos:n,mousePos:n,offsetPos:o.position()})})),X(this,"onRelease",(e=>{const t=this.refs.dragging;if(null==t)return;const n=this.isCardInBank(t),s=this.state.placeholderIndex||0,o=()=>{const e=this.state.current.slice();if(!n){const t={content:this.state.dragContent,key:N.default.uniqueId("perseus_draggable_card_"),width:this.state.dragWidth};e.splice(s,0,t)}this.props.onChange({current:e}),this.setState({current:e,dragging:!1,placeholderIndex:null,animating:!1}),this.props.trackInteraction()},i=L.default(D.default.findDOMNode(t)).position();let r=null;n?N.default.each(this.props.options,(function(e,t){if(e.content===this.state.dragContent){const e=D.default.findDOMNode(this.refs["bank"+t]);r=L.default(e).position()}}),this):null!=this.refs.placeholder&&(r=L.default(D.default.findDOMNode(this.refs.placeholder)).position()),null==r?o():this.setState({offsetPos:i,animateTo:r,onAnimationEnd:o,animating:!0,dragging:!1})})),X(this,"onMouseMove",(e=>{const t=this.refs.dragging;if(null==t)return;let n;n=this.isCardInBank(t)?null:this.findCorrectIndex(t,this.state.current),this.setState({mousePos:e,placeholderIndex:n})})),X(this,"findCorrectIndex",((e,t)=>{const n="horizontal"===this.props.layout,s=L.default(D.default.findDOMNode(this.refs.dragList)),o=s.offset().left,i=s.offset().top,r=L.default(D.default.findDOMNode(e)).offset().left-o,a=L.default(D.default.findDOMNode(e)).offset().top-i;let l=0,c=0,p=0;return n?N.default.each(t,(function(e,t){const n=D.default.findDOMNode(this.refs["sortable"+t]),s=L.default(n).outerWidth(!0);r>c+s/2&&(l+=1),c+=s}),this):N.default.each(t,(function(e,t){const n=D.default.findDOMNode(this.refs["sortable"+t]),s=L.default(n).outerHeight(!0);a>p+s/2&&(l+=1),p+=s}),this),l})),X(this,"isCardInBank",(e=>{if(null==e)return!1;const t="horizontal"===this.props.layout,n=L.default(D.default.findDOMNode(e)),s=L.default(D.default.findDOMNode(this.refs.bank)),o=n.offset(),i=s.offset(),r=n.outerHeight(!0),a=s.outerHeight(!0),l=s.outerWidth(!0),c=D.default.findDOMNode(this.refs.dragList);L.default(c).width();const p=n.outerWidth(!0);return t?o.top+r/2<i.top+a:o.left+p/2<i.left+l})),X(this,"setListValues",(e=>{const t=e.map((e=>({content:e})));this.props.onChange({current:t}),this.setState({current:t})})),X(this,"getUserInput",(()=>({current:N.default.map(this.props.current,(function(e){return e.content}))}))),X(this,"simpleValidate",(e=>dh.validate(this.getUserInput(),e)))}UNSAFE_componentWillReceiveProps(e){N.default.isEqual(this.props.current,e.current)||this.setState({current:e.current})}render(){const e=this.state.dragging&&A.createElement(ph,{ref:"dragging",floating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,startMouse:this.state.grabPos,mouse:this.state.mousePos,width:this.state.dragWidth,onMouseUp:this.onRelease,onMouseMove:this.onMouseMove,key:this.state.dragKey||"draggingCard",linterContext:this.props.linterContext}),t=this.state.animating&&A.createElement(ph,{floating:!0,animating:!0,content:this.state.dragContent,startOffset:this.state.offsetPos,width:this.state.dragWidth,animateTo:this.state.animateTo,onAnimationEnd:this.state.onAnimationEnd,key:this.state.dragKey||"draggingCard",linterContext:this.props.linterContext}),n=N.default.map(this.state.current,(function(e,t){return A.createElement(ph,{key:"sortableCard".concat(t),ref:"sortable"+t,fakeRef:"sortable"+t,floating:!1,content:e.content,width:e.width,linterContext:this.props.linterContext,onMouseDown:this.state.animating?L.default.noop:this.onClick.bind(null,"current",t)})}),this);if(null!=this.state.placeholderIndex){const e=A.createElement(ah,{ref:"placeholder",width:this.state.dragWidth,height:this.state.dragHeight,key:"placeholder"});n.splice(this.state.placeholderIndex,0,e)}const s=n.length>0;n.push(e,t);const o=A.createElement("div",{className:"perseus-clearfix draggable-box"},!s&&A.createElement(lh,null),A.createElement("div",{ref:"dragList"},n)),i=A.createElement("div",{ref:"bank",className:"bank perseus-clearfix"},N.default.map(this.props.options,((e,t)=>A.createElement(ph,{ref:"bank"+t,floating:!1,content:e.content,stack:!0,key:t,linterContext:this.props.linterContext,onMouseDown:this.state.animating?L.default.noop:this.onClick.bind(null,"bank",t),onMouseMove:this.onMouseMove,onMouseUp:this.onRelease})),this));return A.createElement("div",{className:"draggy-boxy-thing orderer height-"+this.props.height+" layout-"+this.props.layout+" above-scratchpad blank-background perseus-clearfix "+en.INTERACTIVE,ref:"orderer"},i,o)}}X(dh,"defaultProps",{current:[],options:[],correctOptions:[],height:"normal",layout:"horizontal",linterContext:Yt}),N.default.extend(dh,{validate:function(e,t){if(0===e.current.length)return{type:"invalid",message:null};return{type:"points",earned:N.default.isEqual(e.current,N.default.pluck(t.correctOptions,"content"))?1:0,total:1,message:null}}});var hh={name:"orderer",displayName:"Orderer",widget:dh,isLintable:!0};class uh extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"getUserInput",(()=>Dr.getUserInput.call(this))),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"simpleValidate",(e=>uh.validate(this.getUserInput(),e)))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){return A.createElement(Li,{content:this.props.content,inline:!0,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext})}}X(uh,"propTypes",{...fr,content:R.default.string,linterContext:jt}),X(uh,"defaultProps",{content:"",linterContext:Yt});var fh={name:"passage-ref-target",displayName:"PassageRefTarget",defaultAlignment:"inline",widget:uh,hidden:!0,transform:e=>N.default.pick(e,"content"),version:{major:0,minor:0},isLintable:!0};function mh(e,t,n,s){let o;return o="start"===t&&"start"===s?Range.START_TO_START:"start"===t&&"end"===s?Range.END_TO_START:"end"===t&&"start"===s?Range.START_TO_END:Range.END_TO_END,e.compareBoundaryPoints(o,n)}function gh(e,t){const n=e.cloneRange();return n.setEnd(t.endContainer,t.endOffset),n}function vh(e,t){return!(mh(e,"end",t,"start")<0||mh(t,"end",e,"start")<0)}function bh(e,t){if(!vh(e,t))return null;return gh(mh(e,"start",t,"start")<0?e:t,mh(e,"end",t,"end")>0?e:t)}function yh(e,t,n,s,o){let i=-1,r=s,a=o,l=0;for(;r<=a;){if(l++,l>2*t.length)throw new Error("Assertion error: Binary search isn't terminating? "+"lower=".concat(r,", upper=").concat(a));const s=Math.floor((r+a)/2);if("first"===n){mh(t[s],"end",e,"start")<=0?r=s+1:(i=s,a=s-1)}else{mh(t[s],"start",e,"end")>=0?a=s-1:(i=s,r=s+1)}}return i}function xh(e,t){const n={};let s=t.domRange,o=t.firstWordIndex,i=t.lastWordIndex;for(const t of Object.keys(e)){const r=e[t],a=bh(r.domRange,s);a?(s=a,o=Math.min(r.firstWordIndex,o),i=Math.max(r.lastWordIndex,i)):n[t]=r}const r={firstWordIndex:o,lastWordIndex:i,domRange:s},a=function(e){const t="".concat((new Date).getTime());if(!e.includes(t))return t;let n,s=0;do{n="".concat(t,"-").concat(s),s++}while(e.includes(n));return n}(Object.keys(n));return n[a]=r,n}function Ch(e,t,n){for(const t of Object.keys(e)){const i=e[t].domRange;if(mh(s=i,"start",o=n,"start")<=0&&mh(s,"end",o,"end")>=0)return null}var s,o;const i=function(e,t){const n=yh(e,t,"first",0,t.length-1);if(n<0)return null;const s=yh(e,t,"last",n,t.length-1);return s<0?null:[n,s]}(n,t);if(!i)return null;const[r,a]=i;return{firstWordIndex:r,lastWordIndex:a,domRange:gh(t[r],t[a])}}function wh(e,t){const{firstWordIndex:n,lastWordIndex:s}=e.range,o=t[n];if(!o)throw new he("first word index ".concat(o," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),pe.InvalidInput,{metadata:{firstWord:o,wordRanges:JSON.stringify(t)}});const i=t[s];if(!i)throw new he("last word index ".concat(i," is out of bounds: ")+"must be 0–".concat(t.length-1," inclusive"),pe.InvalidInput,{metadata:{lastWord:i,wordRanges:JSON.stringify(t)}});return{firstWordIndex:n,lastWordIndex:s,domRange:gh(o,i)}}function kh(e){const{firstWordIndex:t,lastWordIndex:n}=e;return{range:{type:"word-indexes",firstWordIndex:t,lastWordIndex:n}}}function Sh(e,t){return{left:e.left-t.left,top:e.top-t.top}}function Eh(e,t){let{left:n,top:s,width:o,height:i}=e;return{...Sh({left:n,top:s},t),width:o,height:i}}function _h(e){const t=[];return Mh(e.commonAncestorContainer,e,t),t}function Mh(e,t,n){const s=new Range;if(s.selectNodeContents(e),e.nodeType===Node.TEXT_NODE){const r=vh(o=t,i=s)?gh(mh(o,"start",i,"start")>0?o:i,mh(o,"end",i,"end")<0?o:i):null;r&&function(e,t,n){const s=e.parentElement,o=window.getComputedStyle(s);let i=null;if("string"==typeof o.lineHeight&&o.lineHeight.endsWith("px")){const e=parseFloat(o.lineHeight);isNaN(e)||(i=e)}const r=Array.from(t.getClientRects());for(const e of r){const t={left:e.left,top:e.top,height:e.height,width:e.width};if(null!==i){const e=i-t.height;t.top-=e,t.height=i}n.push(t)}}(e,r,n)}else if(e.nodeType===Node.ELEMENT_NODE){if(!vh(t,s))return;for(const s of Array.from(e.childNodes))Mh(s,t,n)}var o,i}class Th extends A.PureComponent{constructor(){super(...arguments),X(this,"state",{cachedHighlightRects:this._computeRects(this.props),tooltipIsHovered:!1})}UNSAFE_componentWillReceiveProps(e){this.props.highlight===e.highlight&&this.props.offsetParent===e.offsetParent||this.setState({cachedHighlightRects:this._computeRects(e)})}_computeRects(e){const{highlight:t,offsetParent:n}=e,s=_h(t.domRange),{left:o,top:i}=n.getBoundingClientRect();return s.map((e=>Eh(e,{left:o,top:i})))}_rectIsHovered(e,t){const n=Sh(t,{left:e.left,top:e.top});return 0<=n.left&&n.left<e.width&&0<=n.top&&n.top<e.height}isHovered(e){if(!e)return!1;const{offsetParent:t}=this.props,{cachedHighlightRects:n}=this.state,{left:s,top:o}=t.getBoundingClientRect(),i=Sh(e,{left:s,top:o});return n.some((e=>this._rectIsHovered(e,i)))}render(){const e=this.state.cachedHighlightRects;return A.createElement("div",null,e.map(((e,t)=>A.createElement("div",{key:t,className:l.css(Ih.highlightRect),style:{position:"absolute",width:e.width,height:e.height,top:e.top,left:e.left,zIndex:this.props.zIndexes.belowContent}}))))}}const Ih=l.StyleSheet.create({highlightRect:{background:"#fffabe"}});class Ph extends A.PureComponent{constructor(){super(...arguments),X(this,"_tooltip",void 0)}componentDidUpdate(e){var t;this.props.focusNode===e.focusNode&&this.props.focusOffset===e.focusOffset&&this.props.offsetParent===e.offsetParent||(null===(t=this._tooltip)||void 0===t||t.remeasure())}_getFocusRect(){const{focusNode:e,focusOffset:t,offsetParent:n}=this.props,s=document.createRange();s.setStart(e,t),s.setEnd(e,t);const o=s.getClientRects()[0];if(!o)return de.log('[Highlighting] Known bug: Could not determine the focus position, so did not show an "Add Highlight" tooltip. https://app.asana.com/0/329800276300868/413878480039713 (see also /r/asana-links)'),null;const{left:i,top:r}=n.getBoundingClientRect();return Eh({left:o.left,top:o.top,width:o.width,height:o.height},{left:i,top:r})}render(){const e=this._getFocusRect();if(!e)return null;const t=A.createElement("div",{className:l.css(Ah.tooltipLabel)},this.props.label);return A.createElement(Fa,{content:t,color:ua.kaBlue,inverted:!0,onClick:this.props.onClick,onMouseEnter:this.props.onMouseEnter,onMouseLeave:this.props.onMouseLeave,toggleOnHover:!1,showOnMount:!0,ref:e=>this._tooltip=e},A.createElement("div",{style:{position:"absolute",left:e.left,top:e.top,height:e.height}}))}}const Ah=l.StyleSheet.create({tooltipLabel:{userSelect:"none"}});class Nh extends A.PureComponent{constructor(){super(...arguments),X(this,"state",{hoveredHighlightKey:null,hoveringTooltipFor:null}),X(this,"_highlightRenderers",{}),X(this,"_handleMouseMove",(e=>{const t={left:e.clientX,top:e.clientY},n=this._getHoveredHighlightKey(t);this.setState({hoveredHighlightKey:n})}))}componentDidMount(){this._updateEditListeners(!1,this.props.editable)}UNSAFE_componentWillReceiveProps(e){this._updateEditListeners(this.props.editable,e.editable),null==this.state.hoveredHighlightKey||this.state.hoveredHighlightKey in e.highlights||this.setState({hoveredHighlightKey:null}),null==this.state.hoveringTooltipFor||this.state.hoveringTooltipFor in e.highlights||this.setState({hoveringTooltipFor:null})}componentWillUnmount(){this._updateEditListeners(this.props.editable,!1)}_updateEditListeners(e,t){!e&&t?window.addEventListener("mousemove",this._handleMouseMove):e&&!t&&(window.removeEventListener("mousemove",this._handleMouseMove),this.setState({hoveredHighlightKey:null,hoveringTooltipFor:null}))}_getHoveredHighlightKey(e){const{hoveringTooltipFor:t}=this.state;if("string"==typeof t)return t;return Object.keys(this.props.highlights).find((t=>{const n=this._highlightRenderers[t];return n&&n.isHovered(e)}))}_renderTooltip(){const{hoveredHighlightKey:e}=this.state;if(null==e)return null;const t=this.props.highlights[e];return A.createElement(Ph,{label:I._("Remove highlight"),focusNode:t.domRange.endContainer,focusOffset:t.domRange.endOffset,offsetParent:this.props.offsetParent,onClick:()=>this.props.onRemoveHighlight(e),onMouseEnter:()=>this.setState({hoveringTooltipFor:e}),onMouseLeave:()=>this.setState({hoveringTooltipFor:null})})}render(){return A.createElement("div",null,Object.keys(this.props.highlights).map((e=>A.createElement(Th,{ref:t=>{t?this._highlightRenderers[e]=t:delete this._highlightRenderers[e]},key:e,highlight:this.props.highlights[e],highlightKey:e,offsetParent:this.props.offsetParent,zIndexes:this.props.zIndexes}))),this.props.editable&&this._renderTooltip())}}class Rh extends A.PureComponent{constructor(){super(...arguments),X(this,"state",{mouseState:"up",trackedSelection:null}),X(this,"_handleSelectionChange",(()=>{this._updateTrackedSelection(this.props.buildHighlight),"down"===this.state.mouseState&&this.setState({mouseState:"down-and-selecting"})})),X(this,"_handleMouseDown",(()=>{this.setState({mouseState:"down"})})),X(this,"_handleMouseUp",(()=>{this.setState({mouseState:"up"})}))}componentDidMount(){this._updateListeners(!1,this.props.enabled)}UNSAFE_componentWillReceiveProps(e){this.props.buildHighlight!==e.buildHighlight&&this._updateTrackedSelection(e.buildHighlight),this._updateListeners(this.props.enabled,e.enabled)}componentWillUnmount(){this._updateListeners(this.props.enabled,!1)}_updateListeners(e,t){!e&&t?(window.addEventListener("mousedown",this._handleMouseDown),window.addEventListener("mouseup",this._handleMouseUp),document.addEventListener("selectionchange",this._handleSelectionChange)):e&&!t&&(window.removeEventListener("mousedown",this._handleMouseDown),window.removeEventListener("mouseup",this._handleMouseUp),document.removeEventListener("selectionchange",this._handleSelectionChange),this.setState({mouseState:"up",trackedSelection:null}))}_computeFocusAndRange(){const e=document.getSelection();if(!e||0===e.rangeCount)return null;const t=e.getRangeAt(0);if(t.collapsed)return null;return{focusNode:e.focusNode,focusOffset:e.focusOffset,range:t}}_computeTrackedSelection(e){const t=this._computeFocusAndRange();if(!t)return null;const{focusNode:n,focusOffset:s,range:o}=t,i=e(o);return i?{focusNode:n,focusOffset:s,proposedHighlight:i}:null}_updateTrackedSelection(e){const t=this._computeTrackedSelection(e);this.setState({trackedSelection:t})}render(){const{mouseState:e,trackedSelection:t}=this.state,n="down-and-selecting"===e;return this.props.children?A.createElement("div",null,this.props.children(t,n)):null}}class Fh extends A.PureComponent{_handleAddHighlight(e){this.props.onAddHighlight(e);const t=document.getSelection();t&&t.collapseToEnd()}_selectionIsValid(e){if(!e)return!1;const{contentNode:t}=this.props,n=new Range;n.selectNodeContents(t);const s=new Range;s.setStart(e.focusNode,e.focusOffset),s.collapse(!0);return vh(n,s)}render(){return A.createElement(Rh,{buildHighlight:this.props.buildHighlight,enabled:this.props.editable},((e,t)=>A.createElement("div",null,A.createElement(Nh,{editable:this.props.editable&&!this._selectionIsValid(e),highlights:this.props.highlights,offsetParent:this.props.offsetParent,onRemoveHighlight:this.props.onRemoveHighlight,zIndexes:this.props.zIndexes}),this._selectionIsValid(e)&&!t&&A.createElement(Ph,{label:I._("Add highlight"),onClick:()=>this._handleAddHighlight(e.proposedHighlight),focusNode:e.focusNode,focusOffset:e.focusOffset,offsetParent:this.props.offsetParent}))))}}class Dh extends A.PureComponent{constructor(){super(...arguments),X(this,"_container",void 0)}componentDidMount(){this._sendWordsUpdate()}componentDidUpdate(){this._sendWordsUpdate()}_sendWordsUpdate(){this.props.onWordsUpdate(this._getWordRanges())}_getWordRanges(){const e=this._container;if(!e)throw new he("invariant violation: `this._container` is not defined, but this method is only called after mount/update",pe.NotAllowed);const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,(()=>NodeFilter.FILTER_ACCEPT),!1),n=[];let s=null;for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){"inline"!==getComputedStyle(e).display&&(s=null)}else if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue,o=/\S+/g;let i,r=null;for(;null!==(i=o.exec(t));){const o=i.index,a=i.index+i[0].length;let l;0===o&&s?(l=s,l.setEnd(e,a)):(l=e.ownerDocument.createRange(),l.setStart(e,o),l.setEnd(e,a),n.push(l)),a===t.length&&(r=l)}s=r}}return n}render(){return A.createElement("div",{ref:e=>this._container=e},this.props.children)}}class Oh extends A.PureComponent{constructor(){super(...arguments),X(this,"_container",void 0),X(this,"_content",void 0),X(this,"state",{wordRanges:[]}),X(this,"_handleAddHighlight",(e=>{const t=xh(this._getDOMHighlights(),e),n={};for(const e of Object.keys(t))n[e]=kh(t[e]);this.props.onSerializedHighlightsUpdate(n)})),X(this,"_handleRemoveHighlight",(e=>{const{serializedHighlights:t}=this.props,n={...t};delete n[e],this.props.onSerializedHighlightsUpdate(n)})),X(this,"_handleWordsUpdate",(e=>{this.setState({wordRanges:e})}))}_buildHighlight(e){return Ch(this._getDOMHighlights(),this.state.wordRanges,e)}_getDOMHighlights(){const{serializedHighlights:e}=this.props,{wordRanges:t}=this.state,n={};for(const s of Object.keys(e))n[s]=wh(e[s],t);return n}render(){const e=this._getDOMHighlights();return A.createElement("div",{className:l.css(Lh.container),ref:e=>this._container=e},A.createElement("div",null,this.props.enabled&&this._container&&this._content&&A.createElement(Fh,{buildHighlight:e=>this._buildHighlight(e),contentNode:this._content,editable:this.props.editable,highlights:e,offsetParent:this._container,zIndexes:{belowContent:0},onAddHighlight:this._handleAddHighlight,onRemoveHighlight:this._handleRemoveHighlight})),A.createElement("div",{className:l.css(Lh.content),ref:e=>this._content=e},A.createElement(Dh,{onWordsUpdate:this._handleWordsUpdate},this.props.children)))}}const Lh=l.StyleSheet.create({container:{position:"relative",zIndex:0},content:{position:"relative",zIndex:1}}),Bh={display:"inline-block",width:0,visibility:"hidden"},zh={display:"inline",whiteSpace:"nowrap"},qh={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",paddingLeft:10,paddingRight:10,userSelect:"none",WebkitUserSelect:"none"},Hh={display:"inline-block",color:"rgb(255, 255, 255)",backgroundColor:"rgb(90, 90, 90)",userSelect:"none",WebkitUserSelect:"none",width:22,height:22,borderRadius:"50%",textAlign:"center"};class Wh extends A.Component{constructor(){super(...arguments),X(this,"getRefContent",(()=>this.props.refContent))}render(){return A.createElement("span",{style:Bh},I.doNotTranslate("_"))}}X(Wh,"propTypes",{refContent:R.default.node.isRequired});class Uh extends A.Component{render(){return A.createElement("span",{style:Bh},I.doNotTranslate("_"))}}const Gh={newline:F.default.defaultRules.newline,paragraph:F.default.defaultRules.paragraph,escape:F.default.defaultRules.escape,passageFootnote:{order:F.default.defaultRules.escape.order+.1,match:F.default.inlineRegex(/^\^/),parse:(e,t,n)=>{const s=n.lastFootnote.id+1,o={id:s,text:1===s?"*":""+s};return"*"===n.lastFootnote.text&&(n.lastFootnote.text=""+n.lastFootnote.id),n.lastFootnote=o,o},react:(e,t,n)=>A.createElement("sup",{key:n.key},e.text)},refStart:{order:F.default.defaultRules.escape.order+.2,match:function(e,t){const n=/^\{\{/.exec(e);if(n){let t=2,s=0;for(;t<e.length;){const n=e.slice(t,t+2);if("{{"===n)s++,t++;else if("}}"===n){if(!(s>0))break;s--,t++}t++}const o=e.slice(2,t);return[n[0],o]}return null},parse:(e,t,n)=>{if(!n.useRefs)return{ref:null,refContent:null};const s=n.lastRef+1;n.lastRef=s,n.currentRef.push(s);return{ref:s,refContent:t("(“"+e[1]+"”)\n\n",N.default.defaults({useRefs:!1},Vh))}},react:(e,t,n)=>{if(null==e.ref)return null;const s=t(e.refContent,{});return A.createElement(Wh,{ref:"start-ref-"+e.ref,key:"start-ref-"+e.ref,refContent:s})}},refEnd:{order:F.default.defaultRules.escape.order+.3,match:F.default.inlineRegex(/^\}\}/),parse:(e,t,n)=>{if(!n.useRefs)return{ref:null};return{ref:n.currentRef.pop()||null}},react:(e,t,n)=>null!=e.ref?A.createElement(Uh,{ref:"end-ref-"+e.ref,key:"end-ref-"+e.ref}):null},squareLabel:{order:F.default.defaultRules.escape.order+.4,match:F.default.inlineRegex(/^\[\[(\w+)\]\]( *)/),parse:(e,t,n)=>(n.firstQuestionRef||(n.firstQuestionRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,n)=>[A.createElement("span",{key:"visual-square",className:"perseus-passage-square-label",style:zh,"aria-hidden":"true"},A.createElement("span",{style:qh},e.content)),A.createElement("span",{key:"alt-text",className:"perseus-sr-only"},I.$_("[Marker for question %(number)s]",{number:e.content})),e.space?" ":null]},circleLabel:{order:F.default.defaultRules.escape.order+.5,match:F.default.inlineRegex(/^\(\((\w+)\)\)( *)/),parse:(e,t,n)=>({content:e[1],space:e[2].length>0}),react:(e,t,n)=>[A.createElement("span",{key:"visual-circle",className:"perseus-passage-circle-label",style:zh,"aria-hidden":!0},A.createElement("span",{style:Hh},e.content)),A.createElement("span",{key:"alt-text",className:"perseus-sr-only"},I.$_("[Circle marker %(number)s]",{number:e.content})),e.space?" ":null]},squareBracketRef:{order:F.default.defaultRules.escape.order+.6,match:F.default.inlineRegex(/^\[(\d+)\]( *)/),parse:(e,t,n)=>(n.firstSentenceRef||(n.firstSentenceRef=e[1]),{content:e[1],space:e[2].length>0}),react:(e,t,n)=>[A.createElement("span",{key:"visual-brackets",className:"perseus-passage-bracket-label","aria-hidden":"true"},"[",e.content,"]"),A.createElement("span",{key:"alt-text",className:"perseus-sr-only"},I.$_("[Sentence %(number)s]",{number:e.content})),e.space?" ":null]},highlight:{order:F.default.defaultRules.escape.order+.7,match:F.default.inlineRegex(/^{highlighting.start}(.+?){highlighting.end}/),parse:(e,t,n)=>({content:e[1]}),react:(e,t,n)=>[A.createElement("span",{key:0,className:"perseus-highlight"},e.content)]},reviewHighlight:{order:F.default.defaultRules.escape.order+.7,match:F.default.inlineRegex(/^{review-highlighting.start}(.+?){review-highlighting.end}/),parse:(e,t,n)=>({content:e[1]}),react:(e,t,n)=>[A.createElement("span",{key:0,className:"perseus-review-highlight"},e.content)]},strong:F.default.defaultRules.strong,u:F.default.defaultRules.u,em:F.default.defaultRules.em,del:F.default.defaultRules.del,text:{...F.default.defaultRules.text,react:(e,t,n)=>A.createElement("span",{key:n.key},e.content)}},Vh={currentRef:[],useRefs:!0,lastRef:0,lastFootnote:{id:0,text:""}},jh=F.default.parserFor(Gh);var Yh={parse:(e,t)=>{t=t||{};return jh(e+"\n\n",N.default.extend(t,Vh))},output:F.default.reactFor(F.default.ruleOutput(Gh,"react")),START_REF_PREFIX:"start-ref-",END_REF_PREFIX:"end-ref-",_rulesForTesting:Gh};class Xh extends A.Component{constructor(){super(...arguments),X(this,"_cachedLineHeight",void 0),X(this,"$body",void 0),X(this,"$end",void 0)}measureLineHeight(){return"number"!=typeof this._cachedLineHeight&&this.forceMeasureLineHeight(),this._cachedLineHeight}forceMeasureLineHeight(){var e;this.$body.text(" "),this._cachedLineHeight=(e=this.$body,this.$end.offset().top-e.offset().top),this.$body.text("")}render(){return A.createElement("div",{className:l.css($h.measurer)},A.createElement("div",null,A.createElement("div",{ref:e=>this.$body=L.default(e),className:"paragraph"}),A.createElement("div",{ref:e=>this.$end=L.default(e)})))}}const $h=l.StyleSheet.create({measurer:{position:"absolute",width:"100%",top:0,left:0}});class Kh extends A.Component{constructor(){super(...arguments),X(this,"_onResize",void 0),X(this,"_lineHeightMeasurer",void 0),X(this,"_stylesAppiedTimer",void 0),X(this,"state",{nLines:null,startLineNumbersAfter:0,stylesAreApplied:!1}),X(this,"_handleSerializedHighlightsUpdate",(e=>{this.props.onChange({highlights:e})}))}componentDidMount(){this._updateState(),this._onResize=N.default.throttle((()=>{this.shouldRenderJipt()||(this._lineHeightMeasurer.forceMeasureLineHeight(),this._updateState())}),500),window.addEventListener("resize",this._onResize),this._stylesAppiedTimer=window.setTimeout((()=>{this.setState({stylesAreApplied:!0})}),0)}shouldComponentUpdate(e,t){return!N.default.isEqual(this.props,e)||!N.default.isEqual(this.state,t)}componentDidUpdate(){this._updateState()}componentWillUnmount(){window.removeEventListener("resize",this._onResize),clearTimeout(this._stylesAppiedTimer)}_updateState(){this.shouldRenderJipt()||this.setState({nLines:this._measureLines(),startLineNumbersAfter:this._getInitialLineNumber()})}_measureLines(){const e=L.default(D.default.findDOMNode(this.refs.content)).height(),t=this._getLineHeight();return Math.round(e/t)}_getInitialLineNumber(){let e=!0;return this.props.findWidgets(((t,n)=>"passage"===n.type&&(t===this.props.widgetId&&(e=!1),e))).map((e=>e.getLineCount())).reduce(((e,t)=>e+t),0)}_getLineHeight(){return this._lineHeightMeasurer.measureLineHeight()}getLineCount(){return null!=this.state.nLines?this.state.nLines:this._measureLines()}_getStartRefLineNumber(e){const t=Yh.START_REF_PREFIX+e,n=this.refs[t];if(!n)return null;const s=L.default(D.default.findDOMNode(n));let o=s.next();0===o.length&&(o=s);const i=o.offset().top;return this.state.startLineNumbersAfter+1+this._convertPosToLineNumber(i)}_getEndRefLineNumber(e){const t=Yh.END_REF_PREFIX+e,n=this.refs[t];if(!n)return null;const s=L.default(D.default.findDOMNode(n));let o=s.prev();0===o.length&&(o=s);const i=o.height(),r=o.offset().top;let a=this._convertPosToLineNumber(r+i);return 0===i&&(a+=1),this.state.startLineNumbersAfter+a}_convertPosToLineNumber(e){const t=e-L.default(D.default.findDOMNode(this.refs.content)).offset().top,n=this._getLineHeight();return Math.round(t/n)}_getRefContent(e){const t=Yh.START_REF_PREFIX+e,n=this.refs[t];return n?n.getRefContent():null}getReference(e){const t=this._getStartRefLineNumber(e),n=this._getEndRefLineNumber(e);if(null==t||null==n)return null;return{startLine:t,endLine:n,content:this._getRefContent(e)}}getUserInput(){return null}simpleValidate(e){return Kh.validate(this.getUserInput(),e)}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}_renderInstructions(e){const t=e.firstQuestionRef,n=e.firstSentenceRef;let s="";t&&(s+=I._("The symbol %(questionSymbol)s indicates that question %(questionNumber)s references this portion of the passage.",{questionSymbol:"[["+t+"]]",questionNumber:t})),n&&(s+=I._(" The symbol %(sentenceSymbol)s indicates that the following sentence is referenced in a question.",{sentenceSymbol:"["+n+"]"}));const o=Yh.parse(s);return A.createElement("div",{className:"perseus-widget-passage-instructions"},Yh.output(o))}shouldRenderJipt(){const{JIPT:e}=le();return e.useJIPT&&-1!==this.props.passageText.indexOf("crwdns")}_renderContent(e){const t=this.state.stylesAreApplied,n=!this.props.reviewModeRubric;return A.createElement(Oh,{editable:n,enabled:t,onSerializedHighlightsUpdate:this._handleSerializedHighlightsUpdate,serializedHighlights:this.props.highlights},A.createElement("div",{ref:"content"},A.createElement(Xh,{ref:e=>this._lineHeightMeasurer=e}),Yh.output(e)))}_hasFootnotes(){const e=this.props.footnotes;return!/^\s*$/.test(e)}_renderFootnotes(){const e=this.props.footnotes,t=Yh.parse(e);return Yh.output(t)}render(){let e;const t=this.state.nLines;this.props.showLineNumbers&&t&&(e=N.default.range(1,t+1).map((e=>{const t=e+this.state.startLineNumbersAfter;if(4===t){const e=I._("Line ");return A.createElement("span",{key:"line-marker",className:"line-marker"},e)}return A.createElement("span",{key:e},t)})));const n={firstSentenceRef:null,firstQuestionRef:null},s=this.props.passageText.replace(/("{1})([^"]*)("{1})/g,"“$2”"),o=Yh.parse(s,n),i=/\S/.test(this.props.passageTitle);return A.createElement("div",null,A.createElement("div",{className:"perseus-widget-passage-container"},this._renderInstructions(n),A.createElement("div",{className:"perseus-widget-passage"},i&&A.createElement("h3",{className:"passage-title"},A.createElement(Li,{content:this.props.passageTitle,linterContext:this.props.linterContext})),e&&A.createElement("div",{className:"line-numbers","aria-hidden":!0},e),!i&&A.createElement("h3",{className:"perseus-sr-only"},I._("Beginning of reading passage.")),A.createElement("div",{className:"passage-text"},this.shouldRenderJipt()?A.createElement(Li,{content:this.props.passageText}):this._renderContent(o)),this._hasFootnotes()&&[A.createElement("h4",{key:"footnote-start",className:"perseus-sr-only"},I._("Beginning of reading passage footnotes.")),A.createElement("div",{key:"footnotes",className:"footnotes"},this._renderFootnotes())],A.createElement("div",{className:"perseus-sr-only"},I._("End of reading passage.")))))}}X(Kh,"defaultProps",{passageTitle:"",passageText:"",footnotes:"",showLineNumbers:!0,highlights:{},linterContext:Yt});var Zh={name:"passage",displayName:"Passage (SAT only)",widget:Kh,transform:e=>N.default.pick(e,"passageTitle","passageText","footnotes","showLineNumbers"),isLintable:!0};const{deepEq:Jh}=Be;R.default.oneOf(["bar","line","pic","histogram","dotplot"]),R.default.arrayOf(R.default.string),R.default.arrayOf(R.default.oneOfType([R.default.number,R.default.string])),R.default.number,R.default.number,R.default.number,R.default.number,R.default.number,R.default.string,R.default.arrayOf(R.default.number),R.default.number,R.default.arrayOf(R.default.number),R.default.bool;class Qh extends A.Component{constructor(){super(...arguments),X(this,"shouldSetupGraphie",void 0),X(this,"_isMounted",!1),X(this,"horizHairline",void 0),X(this,"hairlineRange",void 0),X(this,"graphie",void 0),X(this,"state",{values:this.props.starting||[1],categoryHeights:{}}),X(this,"DOT_PLOT_POINT_SIZE",(()=>this.props.apiOptions.isMobile?6:4)),X(this,"DOT_PLOT_POINT_PADDING",(()=>8)),X(this,"DOT_TICK_POINT_SIZE",(()=>2)),X(this,"setupGraphie",(e=>{const t=this;t.shouldSetupGraphie=!1;const n=D.default.findDOMNode(t.refs.graphieDiv);L.default(n).empty();const s=wn.createGraphie(n);t.graphie=s,t.graphie.pics=[],t.graphie.dotTicks=[];const o="bar"===t.props.type,i="line"===t.props.type,r="pic"===t.props.type,a="histogram"===t.props.type,l="dotplot"===t.props.type,c=r||l,p={},d=p,h=this.props.apiOptions.isMobile;d.graph={lines:[],bars:[],points:[],dividers:[]},d.scaleY=t.props.scaleY,d.dimX=t.props.categories.length;const u=h?[288,336]:t.props.plotDimensions;if(i)d.dimX+=h?-.2:1;else if(a)d.barPad=0,d.barWidth=1;else if(o)d.barPad=h?.08:.15,d.barWidth=1-2*d.barPad,d.dimX+=(h?-2:2)*d.barPad;else if(c){d.picBoxHeight=t.props.picBoxHeight,d.picBoxWidthPx=u[0]/t.props.categories.length;const e=u[0]-d.dimX*d.picBoxWidthPx;d.picPad=e/(2*d.dimX+2);const n=d.picBoxWidthPx+2*d.picPad;d.picPad=d.picPad/n,d.picBoxWidth=d.picBoxWidthPx/n,d.dimX+=2*d.picPad}l&&(d.picBoxHeight=2*this.DOT_PLOT_POINT_SIZE()+this.DOT_PLOT_POINT_PADDING()),d.dimY=Math.ceil(t.props.maxY/d.scaleY)*d.scaleY;let f=25;(o||i)&&h&&(f=0!==t.props.labels[1].length?17:11),l&&(f/=2),h&&c&&0===t.props.labels[1].length&&(f=0);let m=25,g=75;if(h&&(o||c)){const e=Math.max(0,...Object.values(t.state.categoryHeights));if(e){let t=25;c&&(t+=10),g=t+e}}if(d.scale=h?[(u[0]-4*f)/d.dimX,(u[1]-(m+g))/d.dimY]:N.default.map([d.dimX,d.dimY],(function(e,t){return u[t]/e})),c&&(d.scale[1]=d.picBoxHeight/d.scaleY),f/=d.scale[0],m/=d.scale[1],g/=d.scale[1],s.init({range:[[-3*f,d.dimX+f],[-g,d.dimY+m]],scale:d.scale,isMobile:this.props.apiOptions.isMobile}),s.addMouseLayer({allowScratchpad:!0,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!c){for(let e=h?d.scaleY:0;e<=d.dimY;e+=d.scaleY)s.label([0,e],ue.roundToApprox(e,2),"left",!0),s.style({stroke:h?"#e9ebec":"#000",strokeWidth:1,opacity:h?1:.3},(function(){s.line([0,e],[d.dimX,e])}))}(o||i)&&h&&(t.graphie.dragPrompt=s.label([d.dimX/2,d.dimY/2],I._("Drag handles to make graph"),"center",!1).css("font-weight","bold").css("color",gn.KA_GREEN).css("display","none")),t.setupCategories(p),c&&h&&(t.graphie.dotPrompt=s.label([d.dimX/2,d.dimY/2],I._("Tap to add points"),"center",!1).css("font-weight","bold").css("color",gn.KA_GREEN).css("display","none")),c&&t.drawPicHeights(t.state.values,e.values),s.style({stroke:"#000",strokeWidth:2,opacity:1},(function(){c?l?s.style({stroke:h?gn.GRAY_G:"#000",strokeWidth:h?1:2},(()=>s.line([h?0:.5,0],[d.dimX-(h?0:.5),0]))):(s.line([0,0],[d.dimX,0]),0===t.props.labels[1].length&&h||s.style({stroke:h?gn.GRAY_G:"#000",strokeWidth:h?1:2},(()=>s.line([0,0],[0,d.dimY])))):(s.style({stroke:h?gn.GRAY_G:"#000",strokeWidth:h?1:2},(()=>s.line([h?3*-f:0,0],[d.dimX+(h?f:0),0]))),(o||i)&&h||s.style({stroke:h?gn.GRAY_G:"#000",strokeWidth:h?1:2},(()=>s.line([0,0],[0,d.dimY]))))})),s.label([d.dimX/2,h?-g:-35/d.scale[1]],t.props.labels[0],h?"above":"below",!1).css("font-weight","bold").css("color",h&&gn.GRAY_F),s.label([(h?-35:-60)/d.scale[0],d.dimY/2],t.props.labels[1],"center",!1).css("font-weight","bold").css("color",h&&gn.GRAY_F).addClass("rotate"),this.props.apiOptions.isMobile&&(this.horizHairline=new An(this.graphie,[0,0],[0,0],{normalStyle:{strokeWidth:1}}),this.horizHairline.attr({stroke:gn.INTERACTIVE}),this.horizHairline.hide(),this.hairlineRange=[[0,d.dimX],[0,d.dimY]])})),X(this,"showHairlines",(e=>{this.props.apiOptions.isMobile&&"none"!==this.props.markings&&(this.horizHairline.moveTo([this.hairlineRange[0][0],e[1]],[this.hairlineRange[0][1],e[1]]),this.horizHairline.show())})),X(this,"hideHairlines",(()=>{this.props.apiOptions.isMobile&&this.horizHairline.hide()})),X(this,"labelCategory",((e,t)=>{const n=this.props.apiOptions.isMobile,s=this.graphie;let o=!1;const i=(t+="").match(/^\$(.*)\$$/);i&&(t=i[1],o=!0);const r=Math.PI/180*45,a="translateX(-50%) translateX(".concat(5,"px) ")+"translateY(-50%) rotate(-".concat(45,"deg)"),l=n&&!i;return new Promise((i=>{s.style({color:n?gn.GRAY_G:"inherit",transform:l?a:"none",transformOrigin:"100%"},(()=>{const a=s.label([e,n?-.5:0],t,"below",o),c=14+(l?Math.round(a.height()*Math.cos(r)+(a.width()+5)*Math.sin(r)):a.height());i({category:t,height:c})}))}))})),X(this,"setupCategories",(e=>{const t=this,n=e,s=t.graphie,o=this.props.apiOptions.isMobile,i=[];"histogram"===t.props.type?(N.default.times(t.props.categories.length-1,(function(n){t.setupBar({index:n,startHeight:t.state.values[n],config:e,isHistogram:!0})})),N.default.each(t.props.categories,(function(e,r){const a=.5+r*n.barWidth;i.push(t.labelCategory(a,e));const l=6/n.scale[1];s.style({stroke:"#000",strokeWidth:o?1:2,opacity:1},(function(){s.line([a,-l],[a,0])}))}))):N.default.each(t.props.categories,(function(r,a){const l=t.state.values[a];let c;"bar"===t.props.type?c=t.setupBar({index:a,startHeight:l,config:e,isHistogram:!1}):"line"===t.props.type?c=t.setupLine(a,l,e):"pic"===t.props.type?c=t.setupPic(a,e):"dotplot"===t.props.type&&(c=t.setupDotplot(a,e));let p=0,d=-6/n.scale[1];"dotplot"!==t.props.type||o||(p=-d),"dotplot"===t.props.type?a%t.props.labelInterval!=0&&a!==t.props.categories.length-1||(i.push(t.labelCategory(c,r)),p*=1.5,d*=1.5):i.push(t.labelCategory(c,r)),s.style({stroke:o?gn.GRAY_G:"#000",strokeWidth:o?1:2,opacity:1},(function(){s.line([c,p],[c,d])}))})),Promise.all(i).then((e=>{if(t._isMounted){const n={};e.forEach((e=>{let{category:t,height:s}=e;return n[t]=s})),t.setState({categoryHeights:n})}}))})),X(this,"_clampValue",((e,t,n)=>Math.max(Math.min(e,n),t))),X(this,"_maybeShowDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="inline")})),X(this,"_maybeHideDragPrompt",(()=>{null!=this.graphie.dragPrompt&&(this.graphie.dragPrompt[0].style.display="none")})),X(this,"setupBar",(e=>{const t=this.props.apiOptions.isMobile,n=e.index,s=e.startHeight,o=e.config,i=e.isHistogram,r=this,a=r.graphie,l=o.barWidth/2;let c;c=i?.5+n*o.barWidth+l:(t?l:.5+o.barPad)+n;const p=function(e,n){const s=a.scalePoint(0);if(o.graph.bars[e].scale(1,Math.max(t?.2:.01,n/o.scaleY),s[0],s[1]),i){const t=o.graph.dividers[e-1],i=o.graph.dividers[e];if(t){const i=Math.min(r.state.values[e-1],n);t.scale(1,Math.max(.01,i/o.scaleY),s[0],s[1])}if(i){const t=Math.min(r.state.values[e+1],n);i.scale(1,Math.max(.01,t/o.scaleY),s[0],s[1])}}};if(a.style({stroke:"none",fill:t?gn.BLUE_C:gn.LIGHT_BLUE,opacity:1},(function(){o.graph.bars[n]=a.path([[c-l,0],[c-l,o.scaleY],[c+l,o.scaleY],[c+l,0],[c-l,0]])})),i&&n>0&&a.style({stroke:"#000",strokeWidth:1,opacity:.3},(function(){o.graph.dividers.push(a.path([[c-l,0],[c-l,o.scaleY]]))})),t){const e=o.scaleY/r.props.snapsPerLine;o.graph.lines[n]=uo.addMaybeMobileMovablePoint(this,{coord:[c,s],constraints:[(t,n,s)=>[c,this._clampValue(Math.round(t[1]/e)*e,0,o.dimY)]],onMoveStart:function(){o.graph.bars[n].attr({fill:gn.INTERACTIVE})},onMove:function(){const e=o.graph.lines[n].coord()[1],t=N.default.clone(r.state.values);t[n]=e,r.setState({values:t}),r.changeAndTrack({values:t}),r._maybeHideDragPrompt(),p(n,e)},onMoveEnd:function(){o.graph.bars[n].attr({fill:gn.BLUE_C})}}),o.graph.lines[n].state.visibleShape.wrapper.style.zIndex="1",r._maybeShowDragPrompt()}else o.graph.lines[n]=a.addMovableLineSegment({coordA:[c-l,s],coordZ:[c+l,s],snapY:o.scaleY/r.props.snapsPerLine,constraints:{constrainX:!0},normalStyle:{stroke:gn.INTERACTIVE,"stroke-width":this.props.static?0:4}}),o.graph.lines[n].onMove=function(e,t){let s=this.coordA[1];(s<0||s>o.dimY)&&(s=Math.min(Math.max(s,0),o.dimY),this.coordA[1]=this.coordZ[1]=s,this.transform());const i=N.default.clone(r.state.values);i[n]=s,r.setState({values:i}),r.changeAndTrack({values:i}),p(n,s)};return p(n,s),c})),X(this,"setupLine",((e,t,n)=>{const s=this.props.apiOptions.isMobile,o=this,i=n,r=o.graphie,a=e+(s?.4:1);if(s){const s=n.scaleY/o.props.snapsPerLine;i.graph.points[e]=uo.addMaybeMobileMovablePoint(this,{coord:[a,t],constraints:[(e,t,o)=>[a,this._clampValue(Math.round(e[1]/s)*s,0,n.dimY)]],onMove:function(){const t=i.graph.points[e].coord()[1],n=N.default.clone(o.state.values);n[e]=t,o.setState({values:n}),o.changeAndTrack({values:n}),o._maybeHideDragPrompt()}}),o._maybeShowDragPrompt(),e>0&&(i.graph.lines[e]=uo.addMovableLine(r,{points:[i.graph.points[e-1],i.graph.points[e]],constraints:uo.MovablePoint.constraints.fixed(),normalStyle:{stroke:gn.BLUE_C,"stroke-width":2},highlightStyle:{stroke:gn.BLUE_C,"stroke-width":2}}))}else i.graph.points[e]=r.addMovablePoint({coord:[a,t],constraints:{constrainX:!0},normalStyle:{fill:gn.INTERACTIVE,stroke:gn.INTERACTIVE},snapY:i.scaleY/o.props.snapsPerLine}),i.graph.points[e].onMove=function(t,n){n=Math.min(Math.max(n,0),i.dimY);const s=N.default.clone(o.state.values);return s[e]=n,o.setState({values:s}),o.changeAndTrack({values:s}),[t,n]},e>0&&(i.graph.lines[e]=r.addMovableLineSegment({pointA:i.graph.points[e-1],pointZ:i.graph.points[e],constraints:{fixed:!0},normalStyle:{stroke:"#9ab8ed","stroke-width":2}}));return a})),X(this,"setupDotplot",((e,t)=>{const n=this.graphie,s=this.props.apiOptions.isMobile;return this.setupTiledPlot(e,s?.5:1,t,((e,t)=>n.ellipse([e,t],[this.DOT_PLOT_POINT_SIZE()/n.scale[0],this.DOT_PLOT_POINT_SIZE()/n.scale[1]],{fill:gn.INTERACTIVE,stroke:gn.INTERACTIVE})))})),X(this,"setupPic",((e,t)=>{const n=this.graphie;return this.setupTiledPlot(e,0,t,((e,t)=>{const s=n.scalePoint([e,t]),o=this.props.picSize;return n.raphael.image(this.props.picUrl,s[0]-o/2,s[1]-o/2,o,o)}))})),X(this,"setupTiledPlot",((e,t,n,s)=>{const o=this,i=n,r=o.graphie,a=r.pics,l=r.dotTicks,c=e+.5+i.picPad;r.mouselayer.canvas.style.touchAction="none",a[e]=[],l[e]=[];const p=Math.round(i.dimY/i.scaleY)+1;return N.default(p).times((function(n){const p=((n-=1)+.5)*i.scaleY,d=c-i.picBoxWidth/2,h=p+.5*i.scaleY,u=r.scalePoint([d,h+t]),f=r.mouselayer.rect(u[0],u[1],i.picBoxWidthPx,i.picBoxHeight);L.default(f[0]).css({fill:"#000",opacity:0,cursor:"pointer"}).on("vmousedown",(function(n){n.preventDefault(),o.whichPicClicked=e,o.setPicHeight(e,h),L.default(document).on("vmouseup.plotTile",(function(e){L.default(document).unbind(".plotTile")})),L.default(document).on("vmousemove.plotTile",(function(e){e.preventDefault();const n=r.getMouseCoord(e)[1],s=Math.floor(n-t),a=(Math.max(-1,Math.floor(s/i.scaleY))+.5)*i.scaleY,l=Math.min(a+.5*i.scaleY,i.dimY);o.setPicHeight(o.whichPicClicked,l)}))})),n<0||(a[e][n]=s(c,p+t),l[e][n]=r.ellipse([c,p+t],[o.DOT_TICK_POINT_SIZE()/r.scale[0],o.DOT_TICK_POINT_SIZE()/r.scale[1]],{fill:"#dee1e3",stroke:"#dee1e3"}))})),c})),X(this,"setPicHeight",((e,t)=>{const n=N.default.clone(this.state.values);n[e]=t,this.drawPicHeights(n,this.state.values),this.setState({values:n}),this.changeAndTrack({values:n})})),X(this,"changeAndTrack",(e=>{this.props.onChange(e),this.props.trackInteraction()})),X(this,"drawPicHeights",((e,t)=>{const n=this,s=n.graphie,o=s.pics,i=this.props.apiOptions.isMobile;if(i){const t=e.every((e=>0===e));s.dotPrompt[0].style.display=t?"inline":"none"}N.default.each(o,(function(o,r){N.default.each(o,(function(o,a){const l=(a+1)*n.props.scaleY,c=l<=e[r];if("dotplot"===n.props.type){const e=l<=t[r];c&&!e&&o.animate({"stroke-width":8},75,(()=>o.animate({"stroke-width":2},75)))}L.default(o[0]).css({display:c?"inline":"none"}),s.dotTicks[r][a][0].style.display=c||!i?"none":"inline"}))}))})),X(this,"getUserInput",(()=>this.state.values)),X(this,"simpleValidate",(e=>Qh.validate(this.getUserInput(),e)))}render(){const e={marginBottom:this.props.labels[0]?75:0};return A.createElement("div",{className:"perseus-widget-plotter graphie "+en.INTERACTIVE,ref:"graphieDiv",style:e})}componentDidUpdate(e,t){this.shouldSetupGraphie=this.shouldSetupGraphie||!N.default.isEqual(this.state.categoryHeights,t.categoryHeights),this.shouldSetupGraphie&&this.setupGraphie(t)}componentDidMount(){this._isMounted=!0,this.setupGraphie(this.state)}UNSAFE_componentWillReceiveProps(e){this.shouldSetupGraphie=N.default.any(["type","labels","categories","scaleY","maxY","snapsPerLine","picUrl","labelInterval","static"],(function(t){return!N.default.isEqual(this.props[t],e[t])}),this),N.default.isEqual(this.props.starting,e.starting)||N.default.isEqual(this.state.values,e.starting)||(this.shouldSetupGraphie=!0,this.setState({values:e.starting}))}componentWillUnmount(){this._isMounted=!1}}X(Qh,"propTypes",{onChange:R.default.func.isRequired,trackInteraction:R.default.func.isRequired}),X(Qh,"defaultProps",{type:"bar",labels:["",""],categories:[""],scaleY:1,maxY:10,snapsPerLine:2,picSize:40,picBoxHeight:48,picUrl:"",plotDimensions:[380,300],labelInterval:1}),N.default.extend(Qh,{validate:function(e,t){return Jh(e,t.starting)?{type:"invalid",message:null}:{type:"points",earned:Jh(e,t.correct)?1:0,total:1,message:null}}});const eu=N.default.identity;var tu={name:"plotter",displayName:"Plotter",widget:Qh,staticTransform:eu};class nu extends A.Component{constructor(){super(...arguments),X(this,"arrowLength",100),X(this,"drawArrow",(()=>{const e=this.refs["arrowCanvas"+this.props.index],t=e.getContext("2d");t.clearRect(0,0,e.width,e.height);const n=new Path2D;t.strokeStyle="rgb(0,0,0)",t.lineWidth=1.2,t.lineCap="round";n.moveTo(5,e.height/2),n.lineTo(e.width-5,e.height/2),n.moveTo(e.width-10,e.height/2-5),n.lineTo(e.width-5,e.height/2),n.moveTo(e.width-10,e.height/2+5),n.lineTo(e.width-5,e.height/2),t.stroke(n)}))}componentDidMount(){this.drawArrow()}componentDidUpdate(){this.drawArrow()}render(){return A.createElement("div",{className:"arrow-container"},A.createElement("div",{className:"above-text"},this.props.data.topText),A.createElement("canvas",{height:"30",id:"arrowCanvas"+this.props.index,ref:"arrowCanvas"+this.props.index,width:this.arrowLength},I._("Reaction arrow pointing to the right.")),A.createElement("div",{className:"below-text"},this.props.data.bottomText))}}X(nu,"propTypes",{data:R.default.any,index:R.default.number});class su extends A.Component{constructor(){super(...arguments),X(this,"simpleValidate",(()=>({type:"points",earned:0,total:0,message:null}))),X(this,"getUserInput",(()=>[])),X(this,"validate",((e,t)=>({type:"points",earned:0,total:0,message:null}))),X(this,"focus",(()=>!0))}render(){return A.createElement("div",{className:"reaction",ref:"reaction"},this.props.smiles.map(((e,t)=>{const n=this.props.widgetId+"-"+t;return A.createElement("div",{key:n,className:"molecule-container"},A.createElement(Yd,{id:n,rotationAngle:this.props.rotationAngle[t],smiles:e}),t===this.props.smiles.length-1?null:A.createElement(nu,{data:this.props.separators[t],index:t}))})))}}X(su,"propTypes",{rotationAngle:R.default.arrayOf(R.default.number),separators:R.default.arrayOf(R.default.object),smiles:R.default.arrayOf(R.default.string),widgetId:R.default.string}),X(su,"defaultProps",{smiles:[],rotationAngle:[],separators:[]});var ou={name:"reaction-diagram",displayName:"Chemical reaction",hidden:!0,widget:su};class iu extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"state",{visible:1}),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"_handleInteraction",(e=>{const t=parseInt(e.split(" ")[1]);if(t===this.state.visible-1){const e=this.refs.renderer.getWidgetInstance("group "+t);e.showRationalesForCurrentlySelectedChoices();const n=e.simpleValidate();"points"===n.type&&n.total===n.earned&&(this.setState({visible:this.state.visible+1}),this.props.trackInteraction({visible:this.state.visible+1}))}}))}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}render(){const e=A.createElement(K,$({},ks,{style:{color:"green"}})),t=N.default.chain(this.props.json).first(this.state.visible).map(((e,t)=>"[[".concat(Be.snowman," group ").concat(t,"]]"))).join("\n\n").value(),n={};return N.default.each(this.props.json,((t,s)=>{const o="group ".concat(s);n[o]={type:"group",graded:!0,version:{major:0,minor:0},options:N.default.extend({},t,{icon:s<this.state.visible-1?e:null})}})),A.createElement("div",{className:"perseus-sequence"},A.createElement(Li,{ref:"renderer",content:t,widgets:n,onInteractWithWidget:this._handleInteraction,apiOptions:this.props.apiOptions,linterContext:this.props.linterContext}))}}X(iu,"propTypes",{...fr,apiOptions:Qt.propTypes,json:R.default.arrayOf(R.default.shape({content:R.default.string,images:R.default.objectOf(R.default.any),widgets:R.default.objectOf(R.default.any)})),trackInteraction:R.default.func.isRequired,linterContext:jt}),X(iu,"defaultProps",{json:[{content:"",widgets:{},images:{}}],linterContext:Yt});var ru={name:"sequence",displayName:"Graded Sequence",widget:iu,traverseChildWidgets:function(e,t){let n=e.json;N.default.isArray(n)||(n=[n]);const s=N.default.map(n,(e=>t(e)));return N.default.extend({},e,{json:s})},tracking:"all",hidden:!0,isLintable:!0};const au="#aaa",lu="#ccc",cu="#fff",pu={borderBottom:"9px solid transparent",borderTop:"9px solid transparent",content:'" "',height:"0",position:"absolute",top:"0",width:"0"},du=l.StyleSheet.create({infoTip:{display:"inline-block",marginLeft:"5px",position:"relative"},infoTipContainer:{position:"absolute",top:"-12px",left:"22px",zIndex:1e3},infoTipTriangle:{height:"10px",left:"0",position:"absolute",top:"8px",width:"0",zIndex:1,":before":{...pu,borderRight:"9px solid #bbb",right:"0"},":after":{...pu,borderRight:"9px solid ".concat(cu),right:"-1px"}},verticalShadow:{border:"1px solid ".concat(lu),boxShadow:"0 1px 3px ".concat(lu),borderBottom:"1px solid ".concat(au)},infoTipContentContainer:{background:cu,padding:"5px 10px",width:"240px"}});class hu extends A.Component{constructor(){super(...arguments),X(this,"state",{hover:!1}),X(this,"handleMouseEnter",(()=>{this.setState({hover:!0})})),X(this,"handleMouseLeave",(()=>{this.setState({hover:!1})}))}render(){return A.createElement("div",{className:l.css(du.infoTip)},A.createElement("img",{alt:"",width:10,height:10,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo2N2M3NTAxYS04YmVlLTQ0M2MtYmRiNS04OGM2N2IxN2NhYzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OUJCRTk4Qjc4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OUJCRTk4QjY4NjAwMTFFMzg3QUJDNEI4Mzk2QTRGQkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NGE5ZDI0OTMtODk1NC00OGFkLTlhMTgtZDAwM2MwYWNjNDJlIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjY3Yzc1MDFhLThiZWUtNDQzYy1iZGI1LTg4YzY3YjE3Y2FjMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pqm89uYAAADMSURBVHjaXJA9DoJAEIUH1M4TUHIFsCMGen9OwCGw1YRGW2ntKel0exsojHIBC0ouQAyUviFDstmXfNmZeS+zm7XSNCXRFiRgJf0bXIHixpbhGdxBBJYC1w/xaA424MhNEATkui71fU9KqfEU78UbD9PdbJRlOdae55GmhIP+1NV1TcMwkOM41DSNHvRtMhTHMRVFQW3b6mOLgx99kue5GRp/gIOZuZGvNpTNwjD8oliANU+qqqKu6/TQBdymN57AHjzBT+B6Jx79BRgAvc49kQA4yxgAAAAASUVORK5CYII=",onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave}),A.createElement("div",{className:l.css(du.infoTipContainer),style:{display:this.state.hover?"block":"none"}},A.createElement("div",{className:l.css(du.infoTipTriangle)}),A.createElement("div",{className:l.css(du.verticalShadow,du.infoTipContentContainer)},this.props.children)))}}class uu extends A.Component{constructor(){super(...arguments),X(this,"state",{didMount:!1})}componentDidMount(){this.setState({didMount:!0})}render(){return this.state.didMount?A.createElement(hu,this.props):A.createElement("div",null)}}const{assert:fu}=un,{Path:mu,Arc:gu,Circle:vu,Label:bu,Line:yu,MovablePoint:xu,MovableLine:Cu}=Po;class wu extends A.Component{constructor(){super(...arguments),X(this,"_renderThresholdLine",(()=>{const e=[0,this._range()[1][1]],t=N.default.map(e,(e=>[this.state.threshold,e]));return A.createElement(Cu,{onMove:this.handleMouseInteraction},N.default.map(t,((e,t)=>A.createElement(xu,{key:t,static:!0,coord:e,normalStyle:{stroke:"none",fill:"none"}}))))})),X(this,"_renderCircle",(()=>{const e=this.props.data,t=N.default.reduce(e,((e,t)=>e+t),0),n=N.default.reduce(e,((e,t,n)=>null!=this.state.threshold&&n<=this.state.threshold?e+t:e),0),s=n/t,o=1e-5,i=[this.props.box[0]-30,30],r=this._range()[0],a=Math.min(Math.max(this.state.threshold,r[0]),r[1]).toFixed(2);return[s>0&&(()=>{const e={key:"below",center:i,radius:20,startAngle:0,endAngle:s<1?360*s:359.99999,sector:1!==s,unscaled:!0,style:{fill:gn.LIGHT_RED,stroke:gn.RED}};return A.createElement(gu,e)})(),s<1&&(()=>{const e={key:"above",center:i,radius:20,startAngle:s>0?360*s:o,endAngle:360,sector:0!==s,unscaled:!0,style:{fill:gn.LIGHT_BLUE,stroke:gn.BLUE}};return A.createElement(gu,e)})(),(()=>{const e={key:"label",coord:[i[0],i[1]+30],text:n+" of "+t+" results below "+a+"%",direction:"center",tex:!1,unscaled:!0,style:{fontSize:"12px"}};return A.createElement(bu,e)})()]})),X(this,"_renderData",(()=>{const e=this.props.data;this._range();return N.default.map(e,((e,t)=>{if(!e)return;const n=null!=this.state.threshold&&t<=this.state.threshold,s={fill:n?gn.LIGHT_RED:gn.LIGHT_BLUE,stroke:n?gn.RED:gn.BLUE},o=[[t,0],[t,e],[t+1,e],[t+1,0]];return A.createElement(mu,{key:t,coords:o,style:s})}))})),X(this,"_setupGraphie",((e,t)=>{const n=t.data,s=t.range,o=t.scale,i=s[0][1]-s[0][0],r=s[1][1]-0,a=Math.ceil(r/20);if(N.default.each(N.default.range(0,s[1][1],a),(t=>{n&&e.label([s[0][0],t],ue.roundToApprox(t,2),"left",!0),e.line([s[0][0],t],[s[0][1],t],{stroke:"#000",strokeWidth:1,opacity:.3})})),n){const t=15,n=Math.ceil(i/t);N.default.each(N.default.range(s[0][0],s[0][1],n),(t=>{e.label([t,0],d.number.round(t,2),"below",!0);e.line([t,0],[t,-8/o[1]],{stroke:"#000",strokeWidth:1})}))}const l=[s[0][0],0],c=[s[0][0],s[1][1]];e.line(l,c,{stroke:"#000",strokeWidth:2,opacity:1});const p=s[0][0]+i/2,h=n?25:0;e.label([p,-h/o[1]],t.xAxisLabel,"below",!1).css("font-weight","bold");const u=0+r/2,f=n?55:28;e.label([s[0][0]-f/o[0],u],t.yAxisLabel,"center",!1).css("font-weight","bold").css("-webkit-transform","rotate(-90deg)")})),X(this,"handleMouseInteraction",(e=>{this.setState({threshold:e[0]})})),X(this,"_range",(e=>(e=e||this.props).data?this._getRangeForData(e.data):[[0,100],[-1,10]])),X(this,"_getRangeForData",(e=>{const t=N.default.indexOf(e,N.default.find(e,(e=>e>0))),n=Math.max(0,t-10),s=N.default.lastIndexOf(e,N.default.last(N.default.filter(e,(e=>e>0))));return[[n,Math.min(101,s+1+10)],[-1,N.default.max(e)]]})),X(this,"_getInitialThreshold",(e=>{const t=e[0];return t[0]+(t[1]-t[0])/3})),X(this,"state",{threshold:this._getInitialThreshold(this._range())})}UNSAFE_componentWillReceiveProps(e){const t=this._range(),n=this._range(e);Be.deepEq(t,n)||this.setState({threshold:this._getInitialThreshold(n)})}render(){const e=this.props.data,t=this._range(),n={xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,box:this.props.box,range:t,data:e,scale:[Be.scaleFromExtent(t[0],this.props.box[0]),Be.scaleFromExtent(t[1],this.props.box[1])]},s=[t[0][0],0],o=[t[0][1],0];return A.createElement(Po,{box:n.box,range:n.range,options:n,setup:this._setupGraphie,onMouseMove:this.handleMouseInteraction,onMouseDown:this.handleMouseInteraction,setDrawingAreaAvailable:this.props.setDrawingAreaAvailable},A.createElement(yu,{start:s,end:o,style:{stroke:"#000",strokeWidth:1,opacity:1}}),e&&this._renderData(),e&&this._renderCircle(),e&&this._renderThresholdLine())}}X(wu,"propTypes",{data:R.default.arrayOf(R.default.number),xAxisLabel:R.default.string,yAxisLabel:R.default.string,box:R.default.arrayOf(R.default.number)}),X(wu,"defaultProps",{data:null,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",box:[400,400]});class ku extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"generateNumber",void 0),X(this,"state",{invalidInput:!1}),X(this,"calculateDisplayProportion",(()=>{const e=this.props.userProportion;return"percentage"===this.props.proportionOrPercentage?Math.round(100*e):e})),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"checkProportionValidity",(e=>e>=0&&"proportion"===this.props.proportionOrPercentage&&e<=1||"percentage"===this.props.proportionOrPercentage&&e<=100)),X(this,"handleUserProportionChange",((e,t)=>{let n;n="percentage"===this.props.proportionOrPercentage?e/100:e,null!=n&&(n=Math.min(1,Math.max(0,n))),this.props.onChange({userProportion:n},t)})),X(this,"handleSampleSizeChange",((e,t)=>{null!=e&&(e=Math.min(1e3,Math.max(0,Math.floor(e)))),this.props.onChange({sampleSize:e},t)})),X(this,"handleRunSimulation",(()=>{null!=this.props.numTrials&&null!=this.props.userProportion&&null!=this.props.sampleSize?(this.setState({invalidInput:!1}),this.props.onChange({data:this.generateData()}),this.props.trackInteraction()):this.setState({invalidInput:!0})})),X(this,"generateData",(e=>((e,t,n)=>{const s=()=>this.generateNumber()<n,o=N.default.times(101,(()=>0));return N.default.times(t,(()=>{const t=N.default.times(e,s),n=N.default.filter(t,N.default.identity).length,i=Math.floor(100*n/e);o[i]++})),o})((e=e||this.props).sampleSize,e.numTrials,e.userProportion))),X(this,"getInputPaths",(()=>[["userProportion"],["sampleSize"]])),X(this,"focus",(()=>{const e=N.default.head(this.getInputPaths());return this.focusInputPath(e),!0})),X(this,"focusInputPath",(e=>{fu(e.length>0);const t=N.default.head(e);this.refs[t].focus()})),X(this,"blurInputPath",(e=>{fu(e.length>0);const t=N.default.head(e);this.refs[t].blur()})),X(this,"getDOMNodeForPath",(e=>{fu(e.length>0);const t=N.default.head(e);return D.default.findDOMNode(this.refs[t])})),X(this,"getGrammarTypeForPath",(e=>(fu(e.length>0),"number"))),X(this,"setInputValue",((e,t,n)=>{fu(e.length>0);const s=N.default.head(e);this["handle"+(s.charAt(0).toUpperCase()+s.slice(1))+"Change"](t,n)})),X(this,"getUserInput",(()=>null)),X(this,"simpleValidate",(e=>ku.validate(this.getUserInput(),e)))}UNSAFE_componentWillMount(){null!=this.props.randomSeed&&(this.generateNumber=Be.seededRNG(this.props.randomSeed))}UNSAFE_componentWillReceiveProps(e){e.randomSeed!==this.props.randomSeed&&(this.generateNumber=Be.seededRNG(e.randomSeed))}render(){const e={marginLeft:"5px"},t="0px 0px 0px 2px rgba(255, 165, 0, 1)",n=N.default.extend({},e,{WebkitBoxShadow:t,MozBoxShadow:t,boxShadow:t,transition:"all 0.15s"}),s=N.default.extend({},e,{transition:"all 0.15s"}),o=this.state.invalidInput?n:s,i=this.props.apiOptions.staticRender?Qi:od,r=A.createElement("div",null,A.createElement(i,{ref:"userProportion",style:o,value:this.calculateDisplayProportion(),checkValidity:this.checkProportionValidity,disabled:this.props.apiOptions.readOnly,onChange:this.handleUserProportionChange,onFocus:()=>this.props.onFocus(["userProportion"]),onBlur:()=>this.props.onBlur(["userProportion"])}),A.createElement(uu,null,A.createElement("p",null,I._("This controls the proportion or percentage that will be used in your simulation.")))),a=A.createElement("div",null,A.createElement(i,{ref:"sampleSize",style:o,value:this.props.sampleSize,checkValidity:e=>e>=0,disabled:this.props.apiOptions.readOnly,onChange:this.handleSampleSizeChange,onFocus:()=>this.props.onFocus(["sampleSize"]),onBlur:()=>this.props.onBlur(["sampleSize"])}),A.createElement(uu,null,A.createElement("p",null,I._("This controls the sample size that will be used in your simulation. For example, if you set this to 100, then for each trial, responses from 100 participants will be simulated.")))),l=A.createElement("div",{style:{textAlign:"right"}},A.createElement("b",null,this.props.numTrials),A.createElement(uu,null,A.createElement("p",null,I._("This is the number of trials used in the simulation. For example, if set to 50, then the survey will be conducted 50 times.")))),c=[{title:this.props.proportionLabel+":",value:r},{title:I._("Sample size:"),value:a},{title:I._("Number of trials:"),value:l}],p=A.createElement("button",{className:"simple-button",style:{margin:"20px 0"},disabled:this.props.apiOptions.readOnly,onClick:this.handleRunSimulation},I._("Run simulation")),d={paddingBottom:this.props.data?40:0},h=A.createElement("div",{style:d},A.createElement(wu,{data:this.props.data,xAxisLabel:this.props.xAxisLabel,yAxisLabel:this.props.yAxisLabel,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}));return A.createElement("div",null,(e=>{const t=A.createElement("thead",null,A.createElement("tr",null,A.createElement("th",null,I._("Parameter")),A.createElement("th",null,I._("Value")))),n=A.createElement("tbody",null,N.default.map(e,((e,t)=>A.createElement("tr",{key:t},A.createElement("td",null,e.title),A.createElement("td",null,e.value)))));return A.createElement("table",null,t,n)})(c),p,h)}}X(ku,"propTypes",{...fr,apiOptions:Qt.propTypes,data:R.default.arrayOf(R.default.number),numTrials:R.default.number,proportionLabel:R.default.string,proportionOrPercentage:R.default.string,randomSeed:R.default.number,sampleSize:R.default.number,trackInteraction:R.default.func.isRequired,userProportion:R.default.number,xAxisLabel:R.default.string,yAxisLabel:R.default.string}),X(ku,"defaultProps",{data:null,userProportion:null,sampleSize:null,numTrials:null,randomSeed:0,xAxisLabel:"Proportion (%)",yAxisLabel:"Number of times seen",proportionLabel:"Underlying proportion",proportionOrPercentage:"proportion",apiOptions:Qt.defaults}),N.default.extend(ku,{validate:function(e,t){return{type:"points",earned:0,total:0,message:null}}});var Su={name:"simulator",displayName:"Simulator",widget:ku,transform:e=>{const t=N.default.clone(e);return t.randomSeed=e.problemNum,t},hidden:!0};const{shuffle:Eu}=Be;class _u extends A.Component{constructor(){super(...arguments),X(this,"_isMounted",void 0),X(this,"state",{changed:!1}),X(this,"handleChange",(e=>{this._isMounted&&this.setState({changed:!0},(()=>{setTimeout((()=>{this.props.onChange(e),this.props.trackInteraction()}),0)}))})),X(this,"getUserInput",(()=>({options:this.refs.sortable.getOptions()}))),X(this,"moveOptionToIndex",((e,t)=>{this.refs.sortable.moveOptionToIndex(e,t)})),X(this,"simpleValidate",(e=>this.state.changed?_u.validate(this.getUserInput(),e):{type:"invalid",message:null}))}static validate(e,t){return{type:"points",earned:N.default.isEqual(e.options,t.correct)?1:0,total:1,message:null}}componentDidMount(){this._isMounted=!0}componentWillUnmount(){this._isMounted=!1}render(){const e=Eu(this.props.correct,this.props.problemNum,!0),{apiOptions:t}=this.props,n=t.isMobile?8:5;return A.createElement("div",{className:"perseus-widget-sorter perseus-clearfix"},A.createElement(Yp,{options:e,layout:this.props.layout,margin:n,padding:this.props.padding,onChange:this.handleChange,linterContext:this.props.linterContext,ref:"sortable"}))}}X(_u,"propTypes",{apiOptions:Qt.propTypes,correct:R.default.array,layout:R.default.oneOf(["horizontal","vertical"]),onChange:R.default.func,padding:R.default.bool,problemNum:R.default.number,trackInteraction:R.default.func.isRequired,linterContext:jt}),X(_u,"defaultProps",{correct:[],layout:"horizontal",padding:!0,problemNum:0,onChange:function(){},linterContext:Yt});var Mu={name:"sorter",displayName:"Sorter",widget:_u,isLintable:!0};const{assert:Tu}=un,Iu=function(e,t){return[""+e,""+t]},Pu=function(e){return Tu(N.default.isArray(e)&&2===e.length),+e[0]},Au=function(e){return Tu(N.default.isArray(e)&&2===e.length),+e[1]},Nu=function(e){return"answer"+Pu(e)+","+Au(e)};class Ru extends A.Component{constructor(){super(...arguments),X(this,"_getRows",(()=>this.props.answers.length)),X(this,"_getColumns",(()=>this.props.answers[0].length)),X(this,"getUserInput",(()=>N.default.map(this.props.answers,N.default.clone))),X(this,"onValueChange",((e,t,n)=>{const s=N.default.map(this.props.answers,N.default.clone);s[e][t]=n.target?n.target.value:n,this.props.onChange({answers:s}),this.props.trackInteraction()})),X(this,"onHeaderChange",((e,t)=>{const n=this.props.headers.slice();n[e]=t.content,this.props.onChange({headers:n})})),X(this,"simpleValidate",(e=>Ru.validate(this.getUserInput(),e))),X(this,"_handleFocus",(e=>{this.props.onFocus(e)})),X(this,"_handleBlur",(e=>{this.props.onBlur(e)})),X(this,"focus",(()=>(this.focusInputPath(Iu(0,0)),!0))),X(this,"focusInputPath",(e=>{const t=Nu(e),n=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?n.focus():D.default.findDOMNode(n).focus()})),X(this,"blurInputPath",(e=>{const t=Nu(e),n=this.refs[t];this.props.apiOptions.customKeypad||this.props.apiOptions.staticRender?n.blur():D.default.findDOMNode(n).blur()})),X(this,"getDOMNodeForPath",(e=>{const t=Nu(e);return D.default.findDOMNode(this.refs[t])})),X(this,"getInputPaths",(()=>{const e=this._getRows(),t=this._getColumns(),n=[];return N.default(e).times((e=>{N.default(t).times((t=>{const s=Iu(e,t);n.push(s)}))})),n})),X(this,"getGrammarTypeForPath",(e=>"number")),X(this,"setInputValue",((e,t,n)=>{const s=Pu(e),o=Au(e),i=N.default.map(this.props.answers,N.default.clone);i[s][o]=t,this.props.onChange({answers:i},n)}))}render(){const e=this._getRows(),t=this._getColumns(),n=this.props.headers;let s,o;const i={};return this.props.apiOptions.customKeypad?(s=wr,o={width:80},i.keypadElement=this.props.keypadElement):this.props.apiOptions.staticRender?(s=Qi,o={}):(s="input",o={}),A.createElement("table",{className:"perseus-widget-table-of-values non-markdown"},A.createElement("thead",null,A.createElement("tr",null,N.default.map(n,((e,t)=>this.props.editableHeaders?A.createElement("th",{key:t},A.createElement(this.props.Editor,{ref:"columnHeader"+t,apiOptions:this.props.apiOptions,content:e,widgetEnabled:!1,onChange:N.default.partial(this.onHeaderChange,t)})):A.createElement("th",{key:t},A.createElement(Li,{content:e,linterContext:this.props.linterContext})))))),A.createElement("tbody",null,N.default(e).times((e=>A.createElement("tr",{key:e},N.default(t).times((t=>A.createElement("td",{key:t},A.createElement(s,$({ref:Nu(Iu(e,t)),type:"text",value:this.props.answers[e][t],disabled:this.props.apiOptions.readOnly,onFocus:N.default.partial(this._handleFocus,Iu(e,t)),onBlur:N.default.partial(this._handleBlur,Iu(e,t)),onChange:N.default.partial(this.onValueChange,e,t),style:o},i))))))))))}}X(Ru,"propTypes",{answers:R.default.arrayOf(R.default.arrayOf(R.default.string)),editableHeaders:R.default.bool,Editor:R.default.func,headers:R.default.arrayOf(R.default.string),keypadElement:t.keypadElementPropType,trackInteraction:R.default.func.isRequired,linterContext:jt}),X(Ru,"defaultProps",function(){const e=N.default(4).times((function(){return Be.stringArrayOfSize(1)}));return{apiOptions:Qt.defaults,headers:[""],editableHeaders:!1,rows:4,columns:1,answers:e,linterContext:Yt}}()),N.default.extend(Ru,{validate:function(e,t){const n=function(e){return N.default.filter(e,(function(e){return N.default.some(e,N.default.identity)}))},s=n(t.answers),o=n(e);if(N.default.some(o,(function(e){return N.default.some(e,(function(e){return""===e}))}))||!o.length)return{type:"invalid",message:null};if(o.length!==s.length)return{type:"points",earned:0,total:1,message:null};const i=ge.number.createValidatorFunctional;let r=null;return{type:"points",earned:N.default.every(s,(function(e){let t;for(t=0;t<o.length;t++){const n=o[t],s=N.default.every(n,(function(t,n){const s=e[n],o=i(s,{simplify:!0})(t);return o.message&&(r=o.message),o.correct}));if(s)return o.splice(t,1),!0}return!1}))?1:0,total:1,message:r}}});var Fu={name:"table",displayName:"Table of values",accessible:!0,widget:Ru,transform:e=>{const t=e.answers.length,n=e.answers[0].length,s=N.default(t).times((function(){return Be.stringArrayOfSize(n)}));return N.default.extend({},e,{answers:s})},hidden:!0,isLintable:!0};const{deepEq:Du,getGridStep:Ou,captureScratchpadTouchStart:Lu}=Be,{assert:Bu}=un,zu={url:null};const qu={apiOptions:Qt.defaults,gradeEmpty:!1,graphMode:"interactive",listMode:"dynamic",graph:{},tools:{translation:{enabled:!0,required:!1,constraints:{}},rotation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[1,6]},reflection:{enabled:!0,required:!1,constraints:{fixed:!1},coords:[[2,-4],[2,2]]},dilation:{enabled:!0,required:!1,constraints:{fixed:!1},coord:[6,6]}},drawSolutionShape:!0,starting:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]},correct:{shape:{type:"polygon-3",coords:[[2,2],[2,6],[7,2]]},transformations:[]}};function Hu(e){return e.constraints.fixed?gn.DYNAMIC:gn.INTERACTIVE}function Wu(e){return String(ue.roundTo(9,e))}function Uu(e){const{TeX:t}=le();return[A.createElement(t,{key:"("},"("),Wu(e[0]),A.createElement(t,{key:","},", {}"),Wu(e[1]),A.createElement(t,{key:")"},")")]}function Gu(e){const{TeX:t}=le();return[A.createElement(t,{key:"<"},I.doNotTranslate("\\langle")),Wu(e[0]),A.createElement(t,{key:","},", {}"),Wu(e[1]),A.createElement(t,{key:">"},I.doNotTranslate("\\rangle"))]}function Vu(e,t){return e=N.default.clone(e).sort(d.point.compare),t=N.default.clone(t).sort(d.point.compare),N.default.all(N.default.map(e,(function(e,n){const s=t[n];return d.point.equal(e,s)})))}const ju=e=>e.customKeypad?wr:e.staticRender?Qi:od,Yu={apply:function(e){return Xu[e.type].isValid(e)?Xu[e.type].apply(e):N.default.identity},append:function(e,t){const n=Yu._appendAndCollapseLastTwo(e,t);return Yu._collapseFinalNoOps(n)},_collapseFinalNoOps:function(e){return e.length&&Yu.isNoOp(N.default.last(e))?N.default.initial(e):e},_appendAndCollapseLastTwo:function(e,t){if(!e.length)return[t];const n=Yu.collapse(N.default.last(e),t);return N.default.initial(e).concat(n)},isNoOp:function(e){return Xu[e.type].isNoOp(e)},collapse:function(e,t){return e.type!==t.type?[e,t]:Yu.isEmpty(e)&&Yu.isEmpty(t)?[]:Yu.isValid(e)&&Yu.isValid(t)?Yu._collapseValidMonotypedTransforms(e,t):[e,t]},isValid:function(e){return Xu[e.type].isValid(e)},isEmpty:function(e){return Xu[e.type].isEmpty(e)},_collapseValidMonotypedTransforms:function(e,t){let n=Xu[e.type].collapse(e,t);return n?(N.default.isArray(n)||(n=[n]),N.default.each(n,(function(t){t.type=e.type})),n):[e,t]},toTeX:function(e){return Xu[e.type].toTeX(e)},ListItem:B.default({displayName:"ListItem",render:function(){if("dynamic"===this.props.mode)return A.createElement("div",null,Yu.toTeX(this.props.transform));if("interactive"===this.props.mode){const e=Xu[this.props.transform.type].Input;return A.createElement(e,$({ref:"transform",onChange:this.handleChange,onFocus:this.props.onFocus,onBlur:this.props.onBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions},this.props.transform))}throw new he("Invalid mode: "+this.props.mode,pe.InvalidInput)},value:function(){return"interactive"===this.props.mode?N.default.extend({type:this.props.transform.type},this.refs.transform.value()):this.props.transform},handleChange:N.default.debounce((function(e){this.props.onChange(this.value(),e)}),300),_getComponentAtPath:function(e){const t=this.refs.transform,n=N.default.head(e);return t.refs[n]},focus:function(){const e=this.refs.transform,t=N.default.head(e.getInputPaths());t&&this.focusInputPath(t)},focusInputPath:function(e){this._getComponentAtPath(e).focus()},blurInputPath:function(e){this._getComponentAtPath(e).blur()},getDOMNodeForPath:function(e){return D.default.findDOMNode(this._getComponentAtPath(e))},getGrammarTypeForPath:function(e){return"number"},setInputValue:function(e,t,n){t.length&&(t=parseFloat(t),isNaN(t))||this.refs.transform.setInputValue(e,t,n)},getInputPaths:function(){return"dynamic"===this.props.mode?[]:this.refs.transform.getInputPaths()}})},Xu={translation:{verbName:I._("Translate"),nounName:I._("Translation"),lowerNounName:I._("translation"),apply:function(e){return function(t){return d.vector.add(t,e.vector)}},isValid:function(e){return N.default.isFinite(e.vector[0])&&N.default.isFinite(e.vector[1])},isEmpty:function(e){return null===e.vector[0]&&null===e.vector[1]},isNoOp:function(e){return d.vector.equal(e.vector,[0,0])},collapse:function(e,t){return{vector:d.vector.add(e.vector,t.vector)}},toTeX:function(e){return I.$_("Translation by %(vector)s",{vector:Gu(e.vector)})},Input:class extends A.Component{constructor(){super(...arguments),X(this,"state",{vector:this.props.vector||[null,null]}),X(this,"value",(()=>({vector:[this.refs.x.getValue(),this.refs.y.getValue()]}))),X(this,"setInputValue",((e,t,n)=>{const s=N.default.first(e),o=N.default.clone(this.state.vector);"x"===s?o[0]=t:"y"===s&&(o[1]=t),this.setState({vector:o},(()=>{this.props.onChange(n)}))})),X(this,"getInputPaths",(()=>[["x"],["y"]]))}componentDidUpdate(e){Du(this.props,e)||this.setState({vector:this.props.vector})}render(){const e=ju(this.props.apiOptions),{TeX:t}=le(),n=[A.createElement(t,{key:"<"},I.doNotTranslate("\\langle")),A.createElement(e,{key:"vec_x",ref:"x",placeholder:0,value:this.state.vector[0],useArrowKeys:!0,onChange:e=>{const t=this.state.vector[1];this.setState({vector:[e,t]},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"x"),onBlur:N.default.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:","},", {}"),A.createElement(e,{key:"vec_y",ref:"y",placeholder:0,value:this.state.vector[1],useArrowKeys:!0,onChange:e=>{const t=this.state.vector[0];this.setState({vector:[t,e]},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"y"),onBlur:N.default.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:">"},I.doNotTranslate("\\rangle"))];return A.createElement("div",null,I.$_("Translation by %(vector)s",{vector:n}))}}},rotation:{verbName:I._("Rotate"),nounName:I._("Rotation"),lowerNounName:I._("rotation"),apply:function(e){return function(t){return d.point.rotateDeg(t,e.angleDeg,e.center)}},isValid:function(e){return N.default.isFinite(e.angleDeg)&&N.default.isFinite(e.center[0])&&N.default.isFinite(e.center[1])},isEmpty:function(e){return null===e.angleDeg&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return d.number.equal(e.angleDeg,0)},collapse:function(e,t){return!!d.point.equal(e.center,t.center)&&{center:e.center,angleDeg:e.angleDeg+t.angleDeg}},toTeX:function(e){return I.$_("Rotation by %(degrees)s about %(point)s",{degrees:(t=e.angleDeg,Wu(t)+"°"),point:Uu(e.center)});var t},Input:class extends A.Component{constructor(){super(...arguments),X(this,"state",{center:this.props.center||[null,null],angleDeg:this.props.angleDeg||null}),X(this,"value",(()=>({angleDeg:this.refs.angleDeg.getValue(),center:[this.refs.centerX.getValue(),this.refs.centerY.getValue()]}))),X(this,"setInputValue",((e,t,n)=>{const s=N.default.first(e);let o=N.default.clone(this.state.angleDeg);const i=N.default.clone(this.state.center);"angleDeg"===s?o=t:"centerX"===s?i[0]=t:"centerY"===s&&(i[1]=t),this.setState({angleDeg:o,center:i},(()=>{this.props.onChange(n)}))})),X(this,"getInputPaths",(()=>[["centerX"],["centerY"],["angleDeg"]]))}componentDidUpdate(e){Du(this.props,e)||this.setState({center:this.props.center,angleDeg:this.props.angleDeg})}render(){const e=ju(this.props.apiOptions),{TeX:t}=le(),n=[A.createElement(t,{key:"("},"("),A.createElement(e,{key:"X",ref:"centerX",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{const t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"centerX"),onBlur:N.default.partial(this.props.onBlur,"centerX"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:","},", {}"),A.createElement(e,{key:"Y",ref:"centerY",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{const t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"centerY"),onBlur:N.default.partial(this.props.onBlur,"centerY"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:")"},")")],s=[A.createElement(e,{key:"deg",ref:"angleDeg",placeholder:0,value:this.state.angleDeg,useArrowKeys:!0,onChange:e=>{this.setState({angleDeg:e},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"angleDeg"),onBlur:N.default.partial(this.props.onBlur,"angleDeg"),keypadElement:this.props.keypadElement}),"°"],o=I.$_("Rotation about %(point)s by %(degrees)s",{point:n,degrees:s});return A.createElement("div",null,o)}}},reflection:{verbName:I._("Reflect"),nounName:I._("Reflection"),lowerNounName:I._("reflection"),apply:function(e){return function(t){return d.point.reflectOverLine(t,e.line)}},isValid:function(e){return N.default.all(N.default.flatten(e.line),N.default.isFinite)&&!d.point.equal(e.line[0],e.line[1])},isEmpty:function(e){return N.default.all(N.default.flatten(e.line),N.default.isNull)},isNoOp:function(e){return!1},collapse:function(e,t){return!!d.line.equal(e.line,t.line)&&[]},toTeX:function(e){const t=e.line[0],n=e.line[1];return I.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:Uu(t),point2:Uu(n)})},Input:class extends A.Component{constructor(){super(...arguments),X(this,"state",{line:this.props.line||[[null,null],[null,null]]}),X(this,"changePoint",((e,t,n,s)=>{const o=N.default.map(this.state.line,N.default.clone);o[e][t]=n,this.setState({line:o},(()=>{this.props.onChange(s)}))})),X(this,"value",(()=>({line:[[this.refs.x1.getValue(),this.refs.y1.getValue()],[this.refs.x2.getValue(),this.refs.y2.getValue()]]}))),X(this,"setInputValue",((e,t,n)=>{const s=N.default.first(e);let o,i;"x"===s[0]?o=0:"y"===s[0]&&(o=1),"1"===s[1]?i=0:"2"===s[1]&&(i=1),this.changePoint(i,o,t,n)})),X(this,"getInputPaths",(()=>[["x1"],["y1"],["x2"],["y2"]]))}componentDidUpdate(e){Du(this.props,e)||this.setState({line:this.props.line})}render(){const e=ju(this.props.apiOptions),{TeX:t}=le(),n=[A.createElement(t,{key:"("},"("),A.createElement(e,{key:"x1",ref:"x1",value:this.state.line[0][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,0),onFocus:N.default.partial(this.props.onFocus,"x1"),onBlur:N.default.partial(this.props.onBlur,"x1"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:","},", {}"),A.createElement(e,{key:"y1",ref:"y1",value:this.state.line[0][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,0,1),onFocus:N.default.partial(this.props.onFocus,"y1"),onBlur:N.default.partial(this.props.onBlur,"y1"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:")"},")")],s=[A.createElement(t,{key:"("},"("),A.createElement(e,{key:"x2",ref:"x2",value:this.state.line[1][0],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,0),onFocus:N.default.partial(this.props.onFocus,"x2"),onBlur:N.default.partial(this.props.onBlur,"x2"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:","},", {}"),A.createElement(e,{key:"y2",ref:"y2",value:this.state.line[1][1],useArrowKeys:!0,onChange:this.changePoint.bind(this,1,1),onFocus:N.default.partial(this.props.onFocus,"y2"),onBlur:N.default.partial(this.props.onBlur,"y2"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:")"},")")];return A.createElement("div",null,I.$_("Reflection over the line from %(point1)s to %(point2)s",{point1:n,point2:s}))}}},dilation:{verbName:I._("Dilate"),nounName:I._("Dilation"),lowerNounName:I._("dilation"),apply:function(e){return function(t){return function(e,t,n){const s=d.vector.subtract(e,t),o=d.vector.scale(s,n);return d.vector.add(t,o)}(t,e.center,e.scale)}},isValid:function(e){return N.default.isFinite(e.scale)&&N.default.isFinite(e.center[0])&&N.default.isFinite(e.center[1])},isEmpty:function(e){return null===e.scale&&null===e.center[0]&&null===e.center[1]},isNoOp:function(e){return d.number.equal(e.scale,1)},collapse:function(e,t){return!!d.point.equal(e.center,t.center)&&{center:e.center,scale:e.scale*t.scale}},toTeX:function(e){const t=function(e){const t=ue.toFraction(e,d.number.DEFAULT_TOLERANCE);return 1===t[1]?Wu(e):Wu(t[0])+"/"+Wu(t[1])}(e.scale);return I.$_("Dilation of scale %(scale)s about %(point)s",{scale:t,point:Uu(e.center)})},Input:class extends A.Component{constructor(){super(...arguments),X(this,"state",{center:this.props.center||[null,null],scale:this.props.scale||null}),X(this,"value",(()=>({scale:this.refs.scale.getValue(),center:[this.refs.x.getValue(),this.refs.y.getValue()]}))),X(this,"setInputValue",((e,t,n)=>{const s=N.default.first(e);let o=this.state.scale;const i=N.default.clone(this.state.center);"x"===s?i[0]=t:"y"===s?i[1]=t:"scale"===s&&(o=t),this.setState({scale:o,center:i},(()=>{this.props.onChange(n)}))})),X(this,"getInputPaths",(()=>[["x"],["y"],["scale"]]))}componentDidUpdate(e){Du(this.props,e)||this.setState({center:this.props.center,scale:this.props.scale})}render(){const e=ju(this.props.apiOptions),{TeX:t}=le(),n=[A.createElement(t,{key:"("},"("),A.createElement(e,{key:"point_x",ref:"x",placeholder:0,value:this.state.center[0],useArrowKeys:!0,onChange:e=>{const t=this.state.center[1];this.setState({center:[e,t]},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"x"),onBlur:N.default.partial(this.props.onBlur,"x"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:","},", {}"),A.createElement(e,{key:"point_y",ref:"y",placeholder:0,value:this.state.center[1],useArrowKeys:!0,onChange:e=>{const t=this.state.center[0];this.setState({center:[t,e]},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"y"),onBlur:N.default.partial(this.props.onBlur,"y"),keypadElement:this.props.keypadElement}),A.createElement(t,{key:")"},")")],s=A.createElement(e,{ref:"scale",placeholder:1,value:this.state.scale,useArrowKeys:!0,onChange:e=>{this.setState({scale:e},(()=>{this.props.onChange()}))},onFocus:N.default.partial(this.props.onFocus,"scale"),onBlur:N.default.partial(this.props.onBlur,"scale"),keypadElement:this.props.keypadElement});return A.createElement("div",null,I.$_("Dilation about %(point)s by %(scale)s",{point:n,scale:s}))}}}},$u={getPointCountForType:function(e){const t=e.split("-");return"polygon"===t[0]?t[1]||3:"line"===t[0]||"lineSegment"===t[0]?2:"angle"===t[0]?3:"circle"===t[0]?2:"point"===t[0]?1:void 0},addMovableShape:function(e,t){if(t.editable&&t.translatable)throw new he("It doesn't make sense to have a movable shape where you can stretch the points and translate them simultaneously. options: "+JSON.stringify(t),pe.InvalidInput);const n=N.default.map(t.shape.coords,(function(o){let i=!1,r=o;const a=e.addMovablePoint({coord:o,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,o){i||(r=a.coord,i=!0);let l=d.vector.subtract([e,o],a.coord);t.onMove&&(l=t.onMove(l[0],l[1])),t.translatable&&N.default.each(n,(function(e){e!==a&&e.setCoord(d.vector.add(e.coord,l))}));const c=a.coord,p=d.vector.add(a.coord,l);return a.coord=p,s.update(),a.coord=c,p},onMoveEnd:function(){if(t.onMoveEnd&&i){i=!1;const e=d.vector.subtract(a.coord,r);t.onMoveEnd(e[0],e[1])}s.update()}});return a.bounded=!0,a})),s=$u.addShape(e,t,n),o=s.remove;return s.remove=function(){o.apply(s),N.default.invoke(n,"remove")},s},addShape:function(e,t,n){n=n||t.shape.coords;const s=$u._typesOf(t.shape),o=t.shape.options||$u.defaultOptions(s),i=$u._mapTypes(s,n,(function(n,s,i){const r=N.default.extend({},t,o[i]);return $u._addType(e,n,s,r)})),r=N.default.filter(N.default.pluck(i,"update"),N.default.identity),a=N.default.filter(N.default.pluck(i,"remove"),N.default.identity),l=function(){return N.default.map(i,(function(e){return e.getOptions?e.getOptions():{}}))};return{type:s,points:n,update:function(){N.default.invoke(r,"call")},remove:function(){N.default.invoke(a,"call")},toJSON:function(){const e=N.default.map(n,(function(e){return N.default.isArray(e)?e:e.coord}));return{type:s,coords:e,options:l()}},getOptions:l}},equal:function(e,t){const n=$u._typesOf(e),s=$u._typesOf(t);if(n.length!==s.length)return!1;const o=$u._mapTypes(n,e.coords,$u._combine),i=$u._mapTypes(s,t.coords,$u._combine);return N.default.all(N.default.map(o,(function(e,t){const n=i[t];return e.type===n.type&&$u._forType(e.type).equal(e.coords,n.coords)})))},_typesOf:function(e){let t=e.type;return N.default.isArray(t)||(t=[t]),N.default.map(t,(function(e){return"polygon"===e?"polygon-3":e}))},defaultOptions:function(e){return N.default.map(e,(function(e){const t=$u._forType(e).defaultOptions;return N.default.extend({},t)}))},_forType:function(e){const t=e.split("-")[0];return $u[t]},_mapTypes:function(e,t,n,s){return N.default.map(e,(function(e,o){const i=$u.getPointCountForType(e),r=N.default.first(t,i);return t=N.default.rest(t,i),n.call(s,e,r,o)}))},_addType:function(e,t,n,s){const o=N.default.isArray(n[0])?{coordA:n[0],coordZ:n[1]}:{pointA:n[0],pointZ:n[1]};if("polygon"===(t=t.split("-")[0])){const t=e.addMovablePolygon(N.default.extend({},s,{fixed:!s.editable,snapX:s.snap&&s.snap[0]||0,snapY:s.snap&&s.snap[1]||0,points:n,constrainToGraph:!1}));return{update:t.transform.bind(t),remove:t.remove.bind(t)}}if("line"===t||"lineSegment"===t){const n=e.addMovableLineSegment(N.default.extend({},s,o,{movePointsWithLine:!0,fixed:!0,constraints:{fixed:!0},extendLine:"line"===t}));return{update:n.transform.bind(n,!0),remove:n.remove.bind(n)}}if("angle"===t){const t=!!s.editable&&null,o=e.addMovableAngle({angleLabel:"$deg0",fixed:!0,points:n,normalStyle:s.normalStyle,reflex:s.reflex});return N.default.isArray(n[0])||s.editable||(n[0].remove(),n[2].remove()),{update:o.update.bind(o,t),remove:o.remove.bind(o),getOptions:function(){return{reflex:o.isReflex()}}}}if("circle"===t){let t={remove:N.default.identity};const o=function(){const o=n[0].coord||n[0],i=n[1].coord||n[1],r=d.point.distanceToPoint(o,i);t.remove(),t=e.circle(o,r,N.default.extend({stroke:gn.DYNAMIC,"stroke-width":2},s.normalStyle))};return o(),n[1].remove&&!s.editable&&n[1].remove(),{update:o,remove:function(){t.remove()}}}if("point"===t)return{update:null,remove:null};throw new he("Invalid shape type "+t,pe.InvalidInput)},_combine:function(e,t){return{type:e,coords:t}},polygon:{equal:Vu},line:{equal:d.line.equal},lineSegment:{equal:Vu},angle:{equal:function(e,t){if(!d.point.equal(e[1],t[1]))return!1;const n=[e[1],e[0]],s=[e[1],e[2]],o=[t[1],t[0]],i=[t[1],t[2]],r=d.ray.equal(n,o)&&d.ray.equal(s,i),a=d.ray.equal(n,i)&&d.ray.equal(s,o);return r||a},defaultOptions:{reflex:!1}},circle:{equal:function(e,t){const n=d.point.distanceToPoint(e[0],e[1]),s=d.point.distanceToPoint(t[0],t[1]);return d.point.equal(e[0],t[0])&&d.number.equal(n,s)}},point:{equal:d.point.equal}},Ku=Yu.ListItem;class Zu extends A.Component{constructor(){super(...arguments),X(this,"_transformationRefs",(()=>N.default.times(this.props.transformations.length,(e=>this.refs["transformation"+e])))),X(this,"value",(()=>N.default.invoke(this._transformationRefs(),"value"))),X(this,"handleChange",((e,t)=>{this.props.onChange(this.value(),t)})),X(this,"focusLast",(()=>{const e=this._transformationRefs();0!==e.length&&N.default.last(e).focus()}))}render(){if("static"===this.props.mode)return A.createElement("span",null);const e=N.default.map(this.props.transformations,(function(e,t){return A.createElement(Ku,{ref:"transformation"+t,key:"transformation"+t,transform:e,mode:this.props.mode,onChange:this.handleChange,onFocus:N.default.partial(this.props.onFocus,""+t),onBlur:N.default.partial(this.props.onBlur,""+t),keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions})}),this);return A.createElement("div",{className:"perseus-transformation-list"},e)}}class Ju extends A.Component{render(){const e=this.props.toggled?"simple-button exercise-orange toggled highlighted-tool-button":"simple-button";return A.createElement("button",{type:"button",className:e,disabled:this.props.disabled,onClick:this.props.onClick,onTouchStart:Lu},this.props.children)}}class Qu extends A.Component{constructor(){super(...arguments),X(this,"state",{selected:null}),X(this,"changeSelected",(e=>{this.props.removeTool(this.state.selected),e&&e!==this.state.selected?(this.props.addTool(e),this.setState({selected:e})):this.setState({selected:null})}))}render(){const e=N.default.map(Xu,(function(e,t){if(this.props.enabled[t])return A.createElement(Ju,{key:t,disabled:this.props.apiOptions.readOnly,toggled:this.state.selected===t,onClick:this.changeSelected.bind(this,t)},e.verbName)}),this);return A.createElement("div",{className:"transformer-tools-bar"},A.createElement("span",{className:"simple-button-group"},e),A.createElement("button",{className:"transformer-undo-button simple-button",type:"button",disabled:this.props.apiOptions.readOnly,onClick:this.props.onUndoClick,onTouchStart:Lu},A.createElement(K,Is)," "+I._("Undo")),A.createElement("div",{className:"clear"}))}}class ef extends A.Component{constructor(){super(...arguments),X(this,"changeSelected",(e=>{e&&this.props.addTool(e)}))}render(){const e=N.default.map(Xu,(function(e,t){if(this.props.enabled[t])return A.createElement(Ju,{key:t,toggled:!1,disabled:this.props.apiOptions.readOnly,onClick:this.changeSelected.bind(this,t)},A.createElement(K,Ss)," ",e.nounName)}),this);return A.createElement("div",{className:"transformer-tools-bar"},e,A.createElement("button",{className:"transformer-undo-button simple-button",type:"button",onClick:this.props.onUndoClick,disabled:this.props.apiOptions.readOnly,onTouchStart:Lu},A.createElement(K,Is)," "+I._("Undo")),A.createElement("div",{className:"clear"}))}}class tf extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"tools",void 0),X(this,"currentTool",void 0),X(this,"transformations",void 0),X(this,"shape",void 0),X(this,"dilationCircle",void 0),X(this,"rotatePoint",void 0),X(this,"rotateHandle",void 0),X(this,"shouldSetupGraphie",((e,t)=>!Du(t.starting,e.starting)||(t.graphMode!==e.graphMode||(t.listMode!==e.listMode||(t.drawSolutionShape!==e.drawSolutionShape||(!(!e.drawSolutionShape||Du(t.correct.shape,e.correct.shape))||!Du(this.tools,e.tools))))))),X(this,"graphie",(()=>this.refs.graph.graphie())),X(this,"setupGraphie",(e=>{this.props.drawSolutionShape&&this.props.correct.shape&&this.props.correct.shape.coords&&$u.addShape(e,{fixed:!0,shape:this.props.correct.shape,normalStyle:{stroke:gn.GRAY,"stroke-dasharray":"","stroke-width":2}}),this.currentTool=null,this.refs.toolsBar.changeSelected(null),this.addTransformerShape(this.props.starting.shape,!1),this.setTransformations(this.props.transformations),this.tools={translation:N.default.clone(this.props.tools.translation),rotation:N.default.clone(this.props.tools.rotation),reflection:N.default.clone(this.props.tools.reflection),dilation:N.default.clone(this.props.tools.dilation)}})),X(this,"setTransformations",(e=>{this.resetCoords(),this.transformations=N.default.clone(e),N.default.each(this.transformations,this.applyTransform)})),X(this,"addTransformerShape",((e,t)=>{const n=this,s=this.graphie();this.shape=$u.addMovableShape(s,{shape:e,editable:!1,showPoints:"static"!==this.props.graphMode,translatable:t,onMove:function(e,t){return e=ue.roundToNearest(s.snap[0],e),t=ue.roundToNearest(s.snap[1],t),n.addTransform({type:"translation",vector:[e,t]}),[e,t]},normalPointStyle:{fill:t?gn.INTERACTIVE:gn.DYNAMIC,stroke:t?gn.INTERACTIVE:gn.DYNAMIC},highlightPointStyle:{fill:gn.INTERACTING,stroke:gn.INTERACTING}})})),X(this,"addTool",(e=>{const t=this;if("interactive"===this.props.graphMode)if("translation"===e)this.currentTool=this.addTranslationTool();else if("rotation"===e)this.currentTool=this.addRotationTool();else if("reflection"===e)this.currentTool=this.addReflectionTool();else{if("dilation"!==e)throw new he("Invalid tool id: "+e,pe.InvalidInput);this.currentTool=this.addDilationTool()}else{let n;if("translation"===e)n={type:"translation",vector:[null,null]};else if("rotation"===e)n={type:"rotation",center:[null,null],angleDeg:null};else if("reflection"===e)n={type:"reflection",line:[[null,null],[null,null]]};else{if("dilation"!==e)throw new he("Invalid tool id: "+e,pe.InvalidInput);n={type:"dilation",center:[null,null],scale:null}}this.doTransform(n,(function(){t.refs.transformationList.focusLast()}))}})),X(this,"removeTool",(e=>{this.currentTool&&this.currentTool.remove(),this.currentTool=null})),X(this,"addTranslationTool",(()=>{var e,t;const n=this;return null===(e=this.shape)||void 0===e||e.remove(),this.addTransformerShape(null===(t=this.shape)||void 0===t?void 0:t.toJSON(),!0),{remove:function(){var e,t;null===(e=n.shape)||void 0===e||e.remove(),n.addTransformerShape(null===(t=n.shape)||void 0===t?void 0:t.toJSON(),!1)}}})),X(this,"snapCoord",(e=>{const t=this.graphie();return N.default.map(e,(function(e,n){return ue.roundToNearest(t.snap[n],e)}))})),X(this,"normalizeReflectionCoords",(e=>{const t=this.snapCoord(d.line.midpoint(e)),n=d.vector.polarDegFromCart(d.vector.subtract(e[0],e[1])),s=d.vector.cartFromPolarDeg(1,ue.roundToNearest(45,n[1]));return N.default.map([-1,1],(function(e){const n=d.vector.add(t,d.vector.scale(s,e*this.scaleToCurrentRange(2)));return this.snapCoord(n)}),this)})),X(this,"addReflectionTool",(()=>{const e=this.props.tools.reflection;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),s=function(){t.changeTool("reflection",{coords:N.default.pluck(i,"coord")})},o=this.normalizeReflectionCoords(e.coords),i=N.default.map(o,(function(e){return n.addMovablePoint({coord:e,visible:!1})}),this);let r;const a=Hu(e);n.style({},(function(){r=n.addMovableLineSegment({fixed:e.constraints.fixed,constraints:e.constraints,pointA:i[0],pointZ:i[1],snapX:n.snap[0],snapY:n.snap[1],extendLine:!0,normalStyle:{stroke:a,"stroke-width":2,"stroke-dasharray":"- "},highlightStyle:{stroke:gn.INTERACTING,"stroke-width":2,"stroke-dasharray":"- "},movePointsWithLine:!0,onMoveEnd:s})}));const l=n.addReflectButton({fixed:e.constraints.fixed,line:r,size:this.scaleToCurrentRange(1),onClick:function(){t.doTransform({type:"reflection",line:N.default.pluck(i,"coord")}),c&&(c.setCoord(d.vector.add(l.coord,d.vector.subtract(l.coord,c.coord))),c.update())},normalStyle:{stroke:a,"stroke-width":2,fill:a},highlightStyle:{stroke:gn.INTERACTING,"stroke-width":3,fill:gn.INTERACTING},onMoveEnd:s});let c=null;if(!e.constraints.fixed){const e=d.vector.polarDegFromCart(d.vector.subtract(i[1].coord,i[0].coord))[1]+90;c=n.addRotateHandle({center:l,radius:this.scaleToCurrentRange(2),angleDeg:e,width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),lengthAngle:17,onMove:function(e){return ue.roundToNearest(45,e)},onMoveEnd:s})}return L.default(r).on("move",(function(){l.update(),L.default(l).trigger("move")})),c&&L.default(c).on("move",(function(){const e=t.snapCoord(c.coord),n=d.vector.subtract(e,l.coord),s=l.isFlipped()?1:0;i[s].setCoord(d.vector.add(l.coord,d.vector.rotateDeg(n,90))),i[1-s].setCoord(d.vector.add(l.coord,d.vector.rotateDeg(n,-90))),r.transform(!0),l.update()})),{remove:function(){l.remove(),c&&c.remove(),r.remove(),i[0].remove(),i[1].remove()}}})),X(this,"scaleToCurrentRange",(e=>function(e,t){const n=t[0][1]-t[0][0],s=t[1][1]-t[1][0];return e*Math.max(n,s)/20}(e,this.refs.graph.props.range))),X(this,"addRotationTool",(()=>{const e=this.props.tools.rotation;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),s=Hu(e);return this.rotatePoint=n.addMovablePoint({constraints:e.constraints,coord:e.coord,snapX:n.snap[0],snapY:n.snap[1],normalStyle:{"stroke-dasharray":"",stroke:s,fill:s},highlightStyle:{"stroke-dasharray":"",stroke:gn.INTERACTING,fill:gn.INTERACTING}}),this.rotateHandle=n.addRotateHandle({center:this.rotatePoint,radius:this.scaleToCurrentRange(1.5),width:this.scaleToCurrentRange(.24),hoverWidth:this.scaleToCurrentRange(.4),onMove:function(e,n){const s=t.getRotationTransformFromAngle(t.rotatePoint.coord,e-n);return t.doTransform(s),n+s.angleDeg}}),this.rotatePoint.onMoveEnd=(e,n)=>{t.changeTool("rotation",{coord:[e,n]})},{remove:function(){var e,n;null===(e=t.rotateHandle)||void 0===e||e.remove(),null===(n=t.rotatePoint)||void 0===n||n.remove()}}})),X(this,"addDilationTool",(()=>{const e=this.props.tools.dilation;if(!e.enabled)return;const t=this,n=this.refs.graph.graphie(),s=Hu(e);t.dilationCircle=n.addCircleGraph({centerConstraints:e.constraints,center:e.coord,radius:t.scaleToCurrentRange(2),snapX:n.snap[0],snapY:n.snap[1],minRadius:t.scaleToCurrentRange(1),snapRadius:t.scaleToCurrentRange(.5),onResize:function(e,n){t.doTransform({type:"dilation",center:t.dilationCircle.centerPoint.coord,scale:e/n})},circleNormalStyle:{stroke:s,"stroke-width":2,"stroke-dasharray":"- ","fill-opacity":0},circleHighlightStyle:{stroke:gn.INTERACTING,"stroke-width":2,"stroke-dasharray":"",fill:gn.INTERACTING,"fill-opacity":.05},centerNormalStyle:{stroke:s,fill:s,"stroke-width":2,"stroke-dasharray":""},centerHighlightStyle:{stroke:s,fill:s,"stroke-width":2,"stroke-dasharray":""}});const o=this.dilationCircle.centerPoint.onMoveEnd;return this.dilationCircle.centerPoint.onMoveEnd=function(){if(o){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];o(n)}t.changeTool("dilation",{coord:t.dilationCircle.centerPoint.coord})},{remove:function(){var e;null===(e=t.dilationCircle)||void 0===e||e.remove()}}})),X(this,"getRotationTransformFromAngle",((e,t)=>{(t=(t+360)%360)>180&&(t-=360);return{type:"rotation",center:e,angleDeg:15*Math.round(t/15)}})),X(this,"doTransform",((e,t)=>{this.applyTransform(e),this.addTransform(e,t)})),X(this,"applyTransform",(e=>{if("static"!==this.props.graphMode){const t=Yu.apply(e);this.applyCoordTransformation(t)}})),X(this,"applyCoordTransformation",(e=>{var t;N.default.each(this.shape.points,(function(t){const n=e(t.coord);t.setCoord(n)})),null===(t=this.shape)||void 0===t||t.update()})),X(this,"resetCoords",(()=>{var e;const t=this.props.starting.shape.coords;N.default.each(this.shape.points,(function(e,n){e.setCoord(t[n])})),null===(e=this.shape)||void 0===e||e.update()})),X(this,"handleUndoClick",(()=>{this.refs.toolsBar.changeSelected(null),this.props.transformations.length&&this.props.onChange({transformations:N.default.initial(this.props.transformations)})})),X(this,"setTransformationProps",((e,t)=>{this.props.onChange({transformations:e},t)})),X(this,"addTransform",((e,t)=>{this.transformations=Yu.append(this.transformations,e),this.props.onChange({transformations:N.default.clone(this.transformations)},t)})),X(this,"changeTool",((e,t)=>{const n=N.default.clone(this.props.tools);n[e]=N.default.extend({},this.props.tools[e],t),this.tools[e]=N.default.clone(n[e]),this.props.onChange({tools:n}),this.props.trackInteraction()})),X(this,"simpleValidate",(e=>tf.validate(this.getUserInput(),e))),X(this,"getCoords",(()=>{const e=this.props.starting.shape.coords,t=this.props.transformations;return N.default.reduce(t,(function(e,t){return N.default.map(e,Yu.apply(t))}),e)})),X(this,"getEditorJSON",(()=>{const e=N.default.pick(this.props,"grading","starting","graphMode","listMode","tools","drawSolutionShape","gradeEmpty");return e.graph=this.refs.graph.toJSON(),e.version=1.2,e.answer=this.getUserInput(),e})),X(this,"getUserInput",(()=>{var e;return{transformations:this.props.transformations,shape:{type:this.shape.type,coords:this.getCoords(),options:null===(e=this.shape)||void 0===e?void 0:e.getOptions()}}})),X(this,"_handleFocus",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];e.props.onFocus(n)})),X(this,"_handleBlur",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];e.props.onBlur(n)})),X(this,"_getTransformationForID",(e=>{const t=["transformationList","transformation"+e];let n=this;return N.default.each(t,(e=>{n=n.refs[e]})),n})),X(this,"getInputPaths",(()=>{if("static"===this.props.listMode)return[];let e=[];return N.default.each(this.props.transformations,((t,n)=>{const s=this._getTransformationForID(n).getInputPaths(),o=N.default.map(s,(e=>[""+n].concat(e)));e=e.concat(o)})),e})),X(this,"_passToInner",(function(e,t){if(!t||!t.length)return;const n=N.default.rest(t),s=N.default.head(t),o=this._getTransformationForID(s);for(var i=arguments.length,r=new Array(i>2?i-2:0),a=2;a<i;a++)r[a-2]=arguments[a];return o[e](n,...r)})),X(this,"focus",(()=>{const e=this.getInputPaths();return e.length>0&&(this.focusInputPath(e[0]),!0)})),X(this,"focusInputPath",(e=>0!==e.length&&(Bu(e.length>=2),this._passToInner("focusInputPath",e)))),X(this,"blurInputPath",(e=>0!==e.length&&(Bu(e.length>=2),this._passToInner("blurInputPath",e)))),X(this,"setInputValue",((e,t,n)=>(Bu(e.length>=2),this._passToInner("setInputValue",e,t,n)))),X(this,"getDOMNodeForPath",(e=>(Bu(e.length>=2),this._passToInner("getDOMNodeForPath",e)))),X(this,"getGrammarTypeForPath",(e=>(Bu(e.length>=2),this._passToInner("getGrammarTypeForPath",e))))}render(){const e=N.default.extend(function(e,t){const n=(e=e||{}).labels||["x","y"],s=e.range||[[-10,10],[-10,10]],o=e.step||[1,1];return{box:[t,t],labels:n,range:s,step:o,gridStep:e.gridStep||Ou(s,o,t),valid:!0,backgroundImage:zu,markings:"grid",showProtractor:!1}}(this.props.graph,400),this.props.graph),t="interactive"===this.props.graphMode,n=t?Qu:ef,s=A.createElement("div",{style:{width:e.box[0]}},A.createElement(n,{ref:"toolsBar",enabled:(o=this.props.tools,i="enabled",N.default.object(N.default.map(o,(function(e,t){return[t,e[i]]})))),apiOptions:this.props.apiOptions,addTool:this.addTool,removeTool:this.removeTool,onUndoClick:this.handleUndoClick}));var o,i;return A.createElement("div",{className:"perseus-widget perseus-widget-transformer"},A.createElement(Jc,{ref:"graph",box:e.box,range:e.range,labels:e.labels,step:e.step,gridStep:e.gridStep,markings:e.markings,backgroundImage:e.backgroundImage,showProtractor:e.showProtractor,onGraphieUpdated:this.setupGraphie,setDrawingAreaAvailable:this.props.apiOptions.setDrawingAreaAvailable}),!t&&I._("Add transformations below:"),"static"===this.props.graphMode&&[A.createElement("br",{key:"static-br"}),A.createElement("em",{key:"static-nomove"}," ",I._("Note: For this question, the shape will not move.")," ")],t&&s,A.createElement(Zu,{ref:"transformationList",mode:this.props.listMode,transformations:this.props.transformations,onChange:this.setTransformationProps,onFocus:this._handleFocus,onBlur:this._handleBlur,keypadElement:this.props.keypadElement,apiOptions:this.props.apiOptions}),!t&&s)}componentDidMount(){this.setupGraphie(this.graphie())}componentDidUpdate(e){this.shouldSetupGraphie(this.props,e)?this.refs.graph.reset():Du(this.props.transformations,this.transformations)||this.setTransformations(this.props.transformations)}static validate(e,t){for(const n in Xu)if(t.tools[n].required){const t=N.default.any(N.default.map(e.transformations,(function(e){return e.type===n&&!Yu.isEmpty(e)&&!Yu.isNoOp(e)})));if(!t)return{type:"invalid",message:I._("Your transformation must use a %(type)s.",{type:Xu[n].lowerNounName})}}return $u.equal(e.shape,t.correct.shape)?{type:"points",earned:1,total:1,message:null}:!t.gradeEmpty&&Du(e.shape.coords,t.starting.shape.coords)?{type:"invalid",message:I._("Use the interactive graph to define a correct transformation.")}:{type:"points",earned:0,total:1,message:null}}}X(tf,"defaultProps",N.default.defaults({transformations:[]},qu));var nf,sf={name:"transformer",displayName:"Transformer",widget:tf},of={exports:{}};nf=function(){return function(e){var t={};function n(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:s})},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)},s=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var s in n)e[s]=n[s]}return e};e.exports={isObject:n,merge:s,clone:function(e){return n(e)?Array.isArray(e)?e.slice():s(e):e}}},function(e,t,n){var s=n(0),o=s.clone,i=s.isObject,r=s.merge,a=n(2),l=n(3),c=n(4),p=function(e){return Array.isArray(e)?a:i(e)?l:"string"==typeof e?c:void 0},d=function(e){if(e instanceof d)return e;if(!(this instanceof d))return new d(e);var t=p(e);this._wrapped=t.thaw?t.thaw(e):e};d.prototype.freeze=function(){var e=this._wrapped,t=p(e);return t.freeze?t.freeze(e):e},d.prototype.zoom=function(e){return void 0===this._zoomStack&&(this._zoomStack=[]),this._zoomStack.push({zoom:e,wrapped:this._wrapped}),this._wrapped=d(this._wrapped).get(e),this},d.prototype.deZoom=function(){var e=this._zoomStack.pop();return this._wrapped=d(e.wrapped).set(e.zoom,this._wrapped).freeze(),this},d.prototype.get=function(e){for(var t=this._wrapped,n=0;n<e.length;n++)t=p(t).get(t,e[n]);return t},d.prototype.mod=function(e,t){var n=this._wrapped,s=o(n),i=p(n);if(0===e.length)this._wrapped=t(this._wrapped);else if(1===e.length)this._wrapped=i.mod(s,e[0],t);else{var r=e[0],a=e.slice(1);s[r]=d(n[r]).mod(a,t).freeze(),this._wrapped=s}return this},d.prototype.merge=function(e,t){return this._wrapped=d(this._wrapped).mod(e,(function(e){return r(e,t)})).freeze(),this},d.prototype.del=function(e){var t=this._wrapped,n=p(t);if(1===e.length)this._wrapped=n.del(t,e[0]);else{var s=e[0],i=e.slice(1),r=o(t);r[s]=d(t[s]).del(i).freeze(),this._wrapped=r}return this},d.prototype.set=function(e,t){return this.mod(e,(function(){return t}))},e.exports=d},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var s=e.splice();return s[t]=n,s},mod:function(e,t,n){var s=e.slice();return s[t]=n(e[t]),s},del:function(e,t){var n=e.slice();return n.splice(t,1),n}}},function(e,t,n){var s=n(0).clone;e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var o=s(e);return o[t]=n,o},mod:function(e,t,n){var o=s(e);return o[t]=n(e[t]),o},del:function(e,t){var n=s(e);return delete n[t],n}}},function(e,t){e.exports={get:function(e,t){return e[t]},set:function(e,t,n){var s=e.splice();return s[t]=n,s},mod:function(e,t,n){var s=e.splice();return s[t]=n(e[t]),s},del:function(e,t){var n=e.slice();return n.splice(t),n}}}])};var rf=fn(of.exports=nf());class af{constructor(e){X(this,"order",void 0),X(this,"mantissa",void 0),X(this,"positive",void 0),X(this,"sigFigs",void 0),X(this,"sigDecs",void 0),this.order=df(e),this.mantissa=pf(e),this.positive=cf(e),this.sigFigs=this.mantissa.length,this.sigDecs=this.order-this.mantissa.length}}function lf(e){let t=0;for(let n=e.length-1;n>=0;n--){if("0"!=e.charAt(n))return t;t++}return t}function cf(e){let t=!0,n=!1,s=!1,o="",i="",r=!0;for(let a=0;a<e.length;a++){const l=e.charAt(a);l>="1"&&l<="9"?(i+=o+l,o="",s=!0,t=!1):"0"==l?(n?s&&(i+=o+l,o=""):s&&(o+=l),t=!1):n||"."!=l?"e"==l||"E"==l&&a+1<e.length?(parseInt(e.substring(a+1,e.length)),a=e.length):!t||"+"!=l&&"-"!=l||"-"==l&&(r=!r):(i+=o,o="",n=!0,t=!1)}return""==i||r}function pf(e){let t=!1,n=!1,s="",o="",i="";for(let r=0;r<e.length;r++){const a=e.charAt(r);a>="1"&&a<="9"?(i+=s+a,s="",n=!0):"0"==a?t?n?(i+=s+a,s=""):o+=a:n?(o+=a,s+=a):o+=a:t||"."!=a?("e"==a||"E"==a&&r+1<e.length)&&(parseInt(e.substring(r+1,e.length)),r=e.length):(i+=s,s="",t=!0)}return""==i?o:i}function df(e){let t=!1,n=!1,s="",o="",i=0,r=0;for(let a=0;a<e.length;a++){const l=e.charAt(a);if(l>="1"&&l<="9")o+=s+l,s="",n=!0,t||(r++,i++);else if("0"==l)t?n?(o+=s+l,s=""):i--:(r++,n&&(i++,s+=l));else if(t||"."!=l){if("e"==l||"E"==l&&a+1<e.length){const t=parseInt(e.substring(a+1,e.length));i+=t,r+=t,a=e.length}}else o+=s,s="",t=!0}return""==o?r:i}function hf(e,t){const n=e.length-t-1;if(n<0)return"";if(n>=e.length-1)return e;const s=e.charAt(n+1),o=e.charAt(n);let i=!1;if(s>"5")i=!0;else if("5"==s){for(let t=n+2;t<e.length;t++)"0"!=e.charAt(t)&&(i=!0);o%2==1&&(i=!0)}let r="";for(let t=n;t>=0;t--){const n=e.charAt(t);if(i){let e;if("9"==n)e="0";else{switch(n){case"0":e="1";break;case"1":e="2";break;case"2":e="3";break;case"3":e="4";break;case"4":e="5";break;case"5":e="6";break;case"6":e="7";break;case"7":e="8";break;case"8":e="9"}i=!1}r=e+r}else r=n+r}return i&&(r="1"+r),r}class uf extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"_errorTimeout",void 0),X(this,"_showError",(()=>{if(""===this.props.value)return;const e=L.default(D.default.findDOMNode(this.refs.error));e.is(":visible")||e.css({top:50,opacity:.1}).show().animate({top:0,opacity:1},300)})),X(this,"_hideError",(()=>{const e=L.default(D.default.findDOMNode(this.refs.error));e.is(":visible")&&e.animate({top:50,opacity:.1},300,(function(){L.default(this).hide()}))})),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)})),X(this,"handleBlur",(()=>{this.props.onBlur([]),clearTimeout(this._errorTimeout),T.unitParse(this.props.value).parsed||this._showError()})),X(this,"handleChange",(e=>{this._hideError(),this.props.onChange({value:e.target.value})})),X(this,"simpleValidate",((e,t)=>uf.validate(this.getUserInput(),e))),X(this,"getUserInput",(()=>this.props.value)),X(this,"getInputPaths",(()=>[[]])),X(this,"focusInputPath",(e=>{const t=D.default.findDOMNode(this.refs.input);t&&t.focus()})),X(this,"handleFocus",(()=>{this.props.onFocus([])})),X(this,"blurInputPath",(e=>{const t=D.default.findDOMNode(this.refs.input);t&&t.blur()})),X(this,"setInputValue",((e,t,n)=>{this.props.onChange({value:t},n)})),X(this,"getDOMNodeForPath",(()=>D.default.findDOMNode(this.refs.input))),X(this,"getGrammarTypeForPath",(e=>"unit"))}static validate(e,t){const n=T.unitParse(t.value).expr,s=T.unitParse(e);if(!s.parsed)return{type:"invalid",message:I._("I couldn't understand those units.")};let o=null;const i=t.sigfigs,r=(a=s.coefficient,new af(a).sigFigs===i);var a;let l,c;r||(o=I._("Check your significant figures."));try{const e=new T.Var("x"),t=new T.Eq(n.simplify(),"=",new T.Mul(e,s.expr.simplify())).solveLinearEquationForVariable(e);l=Number(t.eval()).toPrecision(i)===Number(1).toPrecision(i)}catch(e){l=!1}l||(o=I._("That answer is numerically incorrect."));const p=ff(s.expr.simplify()),d=ff(n.simplify());c="all"===t.accepting?T.compare(p,d).equal:N.default(t.acceptingUnits).any((e=>{const t=ff(T.unitParse(e).unit.simplify());return T.compare(t,p).equal})),c||(o=I._("Check your units."));return{type:"points",earned:c&&l&&r?1:0,total:1,message:o}}render(){const e=this.props.apiOptions.staticRender?A.createElement(Qi,{onChange:this.handleChange,ref:"input",className:en.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur}):A.createElement("input",{onChange:this.handleChange,ref:"input",className:en.INTERACTIVE,value:this.props.value,onFocus:this.handleFocus,onBlur:this.handleBlur});return A.createElement("div",{className:"old-unit-input"},e,A.createElement("div",{ref:"error",className:"error",style:{display:"none"}},I._("I don't understand that")))}componentDidUpdate(){clearTimeout(this._errorTimeout),T.unitParse(this.props.value).parsed?this._hideError():this._errorTimeout=setTimeout(this._showError,2e3)}componentWillUnmount(){clearTimeout(this._errorTimeout)}}X(uf,"defaultProps",{apiOptions:Qt.defaults,value:""});const ff=function(e){return e.simplify().asMul().partition()[1].flatten().simplify()};var mf={name:"unit-input",displayName:"Unit",defaultAlignment:"inline-block",widget:uf,transform:e=>rf(e).del(["value"]).freeze(),version:{major:0,minor:1},hidden:!0};const gf=/^https?:\/\//,vf=e=>{const t=e.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/);return t&&11===t[7].length?t[7]:"videoNotFound"},bf=e=>{const{location:t}=e,{useVideo:n}=le(),[s,o]=gf.test(t)?[vf(t),"YOUTUBE_ID"]:[t,"READABLE_ID"],i=n(s,o);switch(i.status){case"loading":return A.createElement(g.View,null,I._("Loading..."));case"success":{var r;const e=null===(r=i.data)||void 0===r?void 0:r.video;return A.createElement(g.View,{style:yf.transcriptLink},A.createElement(g.Text,null,null==e?void 0:e.title),A.createElement(S.Strut,{size:10}),A.createElement(V.default,{href:"/transcript/"+((null==e?void 0:e.contentId)||"videoNotFound"),target:"_blank",className:"visited-no-recolor"},I._("See video transcript")))}default:return A.createElement(g.View,null,I._("Something went wrong."))}},yf=l.StyleSheet.create({transcriptLink:{flexDirection:"row",width:"100%",justifyContent:"center"}}),xf="{host}/embed_video?slug={slug}&internal_video_only=1",Cf=/^https?:\/\//,wf=/(khanacademy\.org|localhost)/;class kf extends A.Component{constructor(){var e;super(...arguments),e=this,X(this,"getUserInput",(()=>null)),X(this,"simpleValidate",(e=>kf.validate(null,e))),X(this,"change",(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ur.apply(e,n)}))}static validate(e,t){return{type:"points",earned:0,total:0,message:null}}render(){const{InitialRequestUrl:e}=le(),t=this.props.location;if(!t)return A.createElement("div",null);let n;if(Cf.test(t))n=t;else{n=xf.replace("{slug}",t);let s="https://www.khanacademy.org";wf.test(e.host)&&(s=e.origin),n=n.replace("{host}",s)}return A.createElement(g.View,null,A.createElement(ln,{width:1280,height:720,key:t+this.props.alignment},A.createElement(g.View,{style:Ma.srOnly},I._("Khan Academy video wrapper")),A.createElement("iframe",{className:"perseus-video-widget",sandbox:"allow-same-origin allow-scripts",width:1280,height:720,src:n,allowFullScreen:!0})),A.createElement(bf,{location:t}))}}var Sf=[rl,ul,yl,El,vl,wc,Ll,Hl,Sc,Mc,Ac,$c,wp,Pp,Up,vd,Qp,xd,$d,rh,hh,Zh,Lr,fh,tu,ou,ru,Su,Mu,Fu,sf,mf,{name:"video",displayName:"Video",defaultAlignment:"block",supportedAlignments:["block","float-left","float-right","full-width"],widget:kf}];var Ef=[...sl,...Sf];fi(Ef);const _f=vi();_f["::renderer::"]=Y;const Mf={propTypes:{apiOptions:R.default.shape({customKeypad:R.default.bool,nativeKeypadProxy:R.default.func}),keypadStyle:R.default.any},getInitialState(){const e=this;let t=null;return e.props.apiOptions&&e.props.apiOptions.customKeypad&&e.props.apiOptions.nativeKeypadProxy&&(t=e.props.apiOptions.nativeKeypadProxy((()=>e.blur&&e.blur()))),{keypadElement:t}},componentDidMount(){const e=this;var n;e.props.apiOptions&&e.props.apiOptions.customKeypad&&!e.props.apiOptions.nativeKeypadProxy&&(e._keypadContainer=document.createElement("div"),null===(n=document.body)||void 0===n||n.appendChild(e._keypadContainer),D.default.render(A.createElement(t.Keypad,{onElementMounted:t=>{e.setState({keypadElement:t})},onDismiss:()=>{e.blur&&e.blur()},style:e.props.keypadStyle}),e._keypadContainer))},componentWillUnmount(){const e=this;e._keypadContainer&&(D.default.unmountComponentAtNode(e._keypadContainer),e._keypadContainer.parentNode&&e._keypadContainer.parentNode.removeChild(e._keypadContainer),e._keypadContainer=null)},keypadElement(){return this.state.keypadElement}},Tf=R.default.shape({content:R.default.string,widgets:R.default.objectOf(R.default.any),images:R.default.objectOf(R.default.any)});class If extends A.Component{constructor(e){super(e),X(this,"_currentFocus",void 0),X(this,"keypadElement",(()=>Mf.keypadElement.call(this))),X(this,"_handleFocusChange",((e,t)=>{e?this._setCurrentFocus(e):this._onRendererBlur(t)})),X(this,"_setCurrentFocus",(e=>{const t=this.keypadElement(),n=this._currentFocus;this._currentFocus=e;let s=!1;if(this._currentFocus){const[e,...t]=this._currentFocus;s=this.refs[e].getInputPaths().some((e=>Be.inputPathsEqual(e,t)))}null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,n,s&&t&&t.getDOMNode()),t&&(s?t.activate():t.dismiss())})),X(this,"_onRendererBlur",(e=>{const t=this._currentFocus;Be.inputPathsEqual(e,t)&&setTimeout((()=>{Be.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))})),X(this,"blur",(()=>{if(this._currentFocus){const[e,...t]=this._currentFocus;this.refs[e].blurPath(t)}})),X(this,"_sections",(()=>Array.isArray(this.props.json)?this.props.json:[this.props.json])),this.state=Mf.getInitialState.call(this)}componentDidMount(){Mf.componentDidMount.call(this),this._currentFocus=null}shouldComponentUpdate(e,t){return e!==this.props||t!==this.state}componentWillUnmount(){Mf.componentWillUnmount.call(this)}render(){const e={...Qt.defaults,...this.props.apiOptions,isArticle:!0},t=P.default({"framework-perseus":!0,"perseus-article":!0,"bibliotron-article":this.props.useNewStyles,[en.MOBILE]:e.isMobile}),n=this._sections().map(((t,n)=>{const s="section-".concat(n);return A.createElement("div",{key:n,className:"clearfix"},A.createElement(Li,$({},t,{ref:s,key:n,key_:n,keypadElement:this.keypadElement(),apiOptions:{...e,onFocusChange:(e,t)=>{this._handleFocusChange(e&&[s].concat(e),t&&[s].concat(t))}},linterContext:Vt.pushContextStack(this.props.linterContext,"article"),legacyPerseusLint:this.props.legacyPerseusLint})))}));return A.createElement("div",{className:t},n)}}X(If,"propTypes",{...Mf.propTypes,apiOptions:R.default.shape({onFocusChange:R.default.func,isMobile:R.default.bool}),json:R.default.oneOfType([Tf,R.default.arrayOf(Tf)]).isRequired,useNewStyles:R.default.bool,linterContext:jt,legacyPerseusLint:R.default.arrayOf(R.default.string)}),X(If,"defaultProps",{apiOptions:{},useNewStyles:!1,linterContext:Yt});class Pf extends A.Component{constructor(){super(...arguments),X(this,"getSerializedState",(()=>this.refs.renderer.getSerializedState())),X(this,"restoreSerializedState",((e,t)=>{this.refs.renderer.restoreSerializedState(e,t)}))}render(){const{apiOptions:e,className:t,hint:n,lastHint:s,lastRendered:o,pos:i,totalHints:r}=this.props,{isMobile:a}=e,c=P.default(!a&&"perseus-hint-renderer",a&&l.css(Af.newHint),a&&o&&l.css(Af.lastRenderedNewHint),s&&"last-hint",o&&"last-rendered",t),p={...e,customKeypad:!1,staticRender:!1};return A.createElement("div",{className:c,tabIndex:"-1"},!e.isMobile&&A.createElement("span",{className:"perseus-sr-only"},I._("Hint #%(pos)s",{pos:i+1})),!e.isMobile&&!e.satStyling&&r&&null!=i&&A.createElement("span",{className:"perseus-hint-label",style:{display:"block",color:e.hintProgressColor}},"".concat(i+1," / ").concat(r)),A.createElement(Li,{ref:"renderer",widgets:n.widgets,content:n.content||"",images:n.images,apiOptions:p,findExternalWidgets:this.props.findExternalWidgets,linterContext:Vt.pushContextStack(this.props.linterContext,"hint")}))}}X(Pf,"defaultProps",{linterContext:Yt});const Af=l.StyleSheet.create({newHint:{marginBottom:24,borderLeftColor:"#F6F7F7",borderLeftStyle:"solid",borderLeftWidth:4,[jr.lgOrSmaller]:{paddingLeft:16},[jr.smOrSmaller]:{paddingLeft:0},":focus":{outline:"none"}},lastRenderedNewHint:{marginBottom:0,borderLeftColor:"#71B307"}});class Nf extends A.Component{constructor(){super(...arguments),X(this,"state",{isFinalHelpPage:!1}),X(this,"_hintsVisible",(()=>null==this.props.hintsVisible||-1===this.props.hintsVisible?this.props.hints.length:this.props.hintsVisible)),X(this,"_cacheImagesInHint",(e=>{N.default.each(e.images,((e,t)=>{(new Image).src=Be.getRealImageUrl(t)}))})),X(this,"_cacheHintImages",(()=>{this._hintsVisible()>0?N.default.each(this.props.hints,this._cacheImagesInHint):this.props.hints.length>0&&this._cacheImagesInHint(this.props.hints[0])})),X(this,"getApiOptions",(()=>({...Qt.defaults,...this.props.apiOptions,readOnly:!1}))),X(this,"getSerializedState",(()=>N.default.times(this._hintsVisible(),(e=>this.refs["hintRenderer"+e].getSerializedState())))),X(this,"restoreSerializedState",((e,t)=>{let n=1;const s=()=>{--n,t&&0===n&&t()};N.default.each(e,((e,t)=>{const o=this.refs["hintRenderer"+t];o&&(++n,o.restoreSerializedState(e,s))})),s()}))}componentDidMount(){this._cacheHintImages()}UNSAFE_componentWillReceiveProps(e){e.hintsVisible-this.props.hintsVisible>1&&this.setState({isFinalHelpPage:!0})}componentDidUpdate(e,t){if(N.default.isEqual(e.hints,this.props.hints)&&e.hintsVisible===this.props.hintsVisible||this._cacheHintImages(),e.hintsVisible<this.props.hintsVisible){const e=this.props.hintsVisible-1;D.default.findDOMNode(this.refs["hintRenderer"+e]).focus()}}render(){const e=this.getApiOptions(),t=this._hintsVisible(),n=[],s=this.state.isFinalHelpPage;this.props.hints.slice(0,t).forEach(((o,i)=>{const r=i===this.props.hints.length-1&&!/\*\*/.test(o.content),a=i===t-1,l=A.createElement(Pf,{lastHint:r,lastRendered:a,hint:o,pos:i,totalHints:this.props.hints.length,ref:"hintRenderer"+i,key:"hintRenderer"+i,apiOptions:e,findExternalWidgets:this.props.findExternalWidgets,linterContext:Vt.pushContextStack(this.props.linterContext,"hints["+i+"]")});s?n.push(l):o.replace&&n.length>0?n[n.length-1]=l:n.push(l)}));const{getAnotherHint:o}=e,i=o&&t>0&&t<this.props.hints.length,r="(".concat(t,"/").concat(this.props.hints.length,")"),a=P.default(this.props.className,e.isMobile&&t>0&&l.css(Rf.mobileHintStylesHintsRenderer));return A.createElement("div",{className:a},e.isMobile&&t>0&&A.createElement("div",{className:l.css(Rf.mobileHintStylesHintTitle,Qr.responsiveLabel)},I._("Hints")),n,i&&A.createElement("button",{rel:"button",className:l.css(Rf.linkButton,Rf.getAnotherHintButton,e.isMobile&&Rf.mobileHintStylesGetAnotherHintButton),onClick:e=>{e.preventDefault(),e.stopPropagation(),o&&o()}},A.createElement("span",{className:l.css(Rf.plusText,e.isMobile&&Rf.mobileHintStylesPlusText)},"+"),A.createElement("span",{className:l.css(Rf.getAnotherHintText)},I._("Get another hint")," ",r)))}}X(Nf,"defaultProps",{linterContext:Yt});const Rf=l.StyleSheet.create({rendererMargins:{marginTop:16},linkButton:{cursor:"pointer",border:"none",backgroundColor:"transparent",fontSize:"100%",fontFamily:"inherit",fontWeight:"bold",color:"#71B307",padding:0,position:"relative"},plusText:{fontSize:20,position:"absolute",top:-3,left:0},getAnotherHintText:{marginLeft:16},mobileHintStylesHintsRenderer:{marginTop:64,border:"solid ".concat("#D6D8DA"),borderWidth:"1px 0 0 0",position:"relative",":before":{content:'""',display:"table",clear:"both"},":after":{content:'""',display:"table",clear:"both"}},mobileHintStylesHintTitle:{fontFamily:"inherit",fontStyle:"normal",fontWeight:"bold",color:te,paddingTop:16,paddingBottom:24,[jr.lgOrSmaller]:{paddingLeft:0},[jr.smOrSmaller]:{paddingLeft:20}},getAnotherHintButton:{marginTop:24},mobileHintStylesGetAnotherHintButton:{[jr.lgOrSmaller]:{paddingLeft:0},[jr.smOrSmaller]:{paddingLeft:20}},mobileHintStylesPlusText:{[jr.lgOrSmaller]:{left:0},[jr.smOrSmaller]:{left:20}}}),{mapObject:Ff}=_n;class Df extends A.Component{constructor(e){super(e),X(this,"questionRenderer",void 0),X(this,"hintsRenderer",void 0),X(this,"_currentFocus",void 0),X(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),X(this,"handleInteractWithWidget",(e=>{const t=N.default.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),this.state={...Mf.getInitialState.call(this),hintsVisible:e.initialHintsVisible||0,questionCompleted:!1,questionHighlightedWidgets:[]}}componentDidMount(){Mf.componentDidMount.call(this),this.props.controlPeripherals&&this.props.apiOptions.setDrawingAreaAvailable&&this.props.apiOptions.setDrawingAreaAvailable(!0),this._currentFocus=null,this.update()}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(){this.update()}componentWillUnmount(){Mf.componentWillUnmount.call(this);const e=document.querySelector(this.props.workAreaSelector);null!=e&&O.unmountComponentAtNode(e);const t=document.querySelector(this.props.hintsAreaSelector);if(null!=t&&O.unmountComponentAtNode(t),this.props.controlPeripherals){const e=this.props.item.answerArea||{};e.calculator&&L.default("#calculator").hide(),e.periodicTable&&L.default(".periodic-table-info-box").hide(),e.zTable&&L.default(".z-table-info-box").hide(),e.tTable&&L.default(".t-table-info-box").hide(),e.chi2Table&&L.default(".chi2-table-info-box").hide()}}keypadElement(){return Mf.keypadElement.call(this)}update(){const e={...Qt.defaults,...this.props.apiOptions,onFocusChange:this._handleFocusChange},t=document.querySelector(this.props.workAreaSelector),n=document.querySelector(this.props.hintsAreaSelector);if(!t||!n)return;O.render(A.createElement(Li,$({ref:t=>{if(!t)return;this.questionRenderer=t;const{answerableCallback:n}=e;if(n){n(0===this.questionRenderer.emptyWidgets().length)}},keypadElement:this.keypadElement(),problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,savedState:this.props.savedState,linterContext:Vt.pushContextStack(this.props.linterContext,"question")},this.props.item.question,{legacyPerseusLint:this.props.legacyPerseusLint})),t),O.render(A.createElement(Nf,{ref:e=>this.hintsRenderer=e,hints:this.props.item.hints,hintsVisible:this.state.hintsVisible,apiOptions:e,linterContext:Vt.pushContextStack(this.props.linterContext,"hints")}),n);const s=this.props.item.answerArea||{};this.props.controlPeripherals?(L.default("#calculator").toggle(s.calculator||!1),L.default(".periodic-table-info-box").toggle(s.periodicTable||!1),L.default(".z-table-info-box").toggle(s.zTable||!1),L.default(".t-table-info-box").toggle(s.tTable||!1),L.default(".chi2-table-info-box").toggle(s.chi2Table||!1)):(s.calculator&&this.props.onShowCalculator&&this.props.onShowCalculator(),s.periodicTable&&this.props.onShowPeriodicTable&&this.props.onShowPeriodicTable(),s.zTable&&this.props.onShowZTable&&this.props.onShowZTable(),s.tTable&&this.props.onShowTTable&&this.props.onShowTTable(),s.chi2Table&&this.props.onShowChi2Table&&this.props.onShowChi2Table())}_setCurrentFocus(e){const t=this.keypadElement(),n=this._currentFocus;this._currentFocus=e;const s=this.getInputPaths(),o=this._currentFocus&&s.some((e=>Be.inputPathsEqual(e,this._currentFocus)));null!=this.props.apiOptions.onFocusChange&&this.props.apiOptions.onFocusChange(this._currentFocus,n,o&&t&&t.getDOMNode()),t&&(o?t.activate():t.dismiss())}_onRendererBlur(e){const t=this._currentFocus;Be.inputPathsEqual(e,t)&&setTimeout((()=>{Be.inputPathsEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}))}_setWidgetProps(e,t,n){this.questionRenderer._setWidgetProps(e,t,n)}setInputValue(e,t,n){return this.questionRenderer.setInputValue(e,t,n)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}showHint(){this.state.hintsVisible<this.getNumHints()&&this.setState({hintsVisible:this.state.hintsVisible+1})}getNumHints(){return this.props.item.hints.length}scoreInput(){const e=this.questionRenderer.guessAndScore(),t=e[0],n=e[1],s=[t,[]],o=Be.keScoreFromPerseusScore(n,s,this.questionRenderer.getSerializedState()),i=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:o.correct,questionHighlightedWidgets:i}),o}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){const e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),n=this.questionRenderer.getSerializedState();return Ff(e,((e,s)=>Be.keScoreFromPerseusScore(e,t[s],n[s])))}getSerializedState(){var e;return{question:this.questionRenderer.getSerializedState(),hints:null===(e=this.hintsRenderer)||void 0===e?void 0:e.getSerializedState()}}restoreSerializedState(e,t){var n;let s=2;const o=()=>{--s,t&&0===s&&t()};this.questionRenderer.restoreSerializedState(e.question,o),null===(n=this.hintsRenderer)||void 0===n||n.restoreSerializedState(e.hints,o)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){return A.createElement("div",null)}}X(Df,"defaultProps",{apiOptions:Qt.defaults,controlPeripherals:!0,hintsAreaSelector:"#hintsarea",initialHintsVisible:0,workAreaSelector:"#workarea",reviewMode:!1,linterContext:Yt});const Of={onRendered:e=>{}},Lf=A.createContext(Of),{mapObject:Bf}=_n;class zf extends A.Component{constructor(e){super(e),X(this,"questionRenderer",void 0),X(this,"hintsRenderer",void 0),X(this,"_currentFocus",void 0),X(this,"_fullyRendered",void 0),X(this,"blurTimeoutID",void 0),X(this,"_handleFocusChange",((e,t)=>{null!=e?this._setCurrentFocus(e):this._onRendererBlur(t)})),X(this,"handleInteractWithWidget",(e=>{const t=N.default.difference(this.state.questionHighlightedWidgets,[e]);this.setState({questionCompleted:!1,questionHighlightedWidgets:t}),this.props.apiOptions.interactionCallback&&this.props.apiOptions.interactionCallback()})),X(this,"setAssetStatus",((e,t)=>{const n={...this.state.assetStatuses,[e]:t};this.setState({assetStatuses:n})})),this.state={questionCompleted:!1,questionHighlightedWidgets:[],assetStatuses:{}},this._fullyRendered=!1}componentDidMount(){this._currentFocus=null,this._fullyRendered=!1}UNSAFE_componentWillReceiveProps(e){this.setState({questionHighlightedWidgets:[]})}componentDidUpdate(e,t){if(this.props.apiOptions.answerableCallback){const e=0===this.questionRenderer.emptyWidgets().length,{answerableCallback:t}=this.props.apiOptions;t&&t(e)}if(!this._fullyRendered){Object.values(this.state.assetStatuses).every(Boolean)&&(this._fullyRendered=!0,this.props.onRendered(!0))}}componentWillUnmount(){null!=this.blurTimeoutID&&(clearTimeout(this.blurTimeoutID),this.blurTimeoutID=null)}_setCurrentFocus(e){const{apiOptions:{isMobile:t,onFocusChange:n},keypadElement:s}=this.props,o=this._currentFocus;this._currentFocus=e;const i=this.getInputPaths(),r=this._currentFocus&&i.some((e=>Be.inputPathsEqual(e,this._currentFocus)));null!=n&&n(this._currentFocus,o,r&&s&&s.getDOMNode(),r&&this.questionRenderer.getDOMNodeForPath(e)),s&&t&&(r?s.activate():s.dismiss())}_onRendererBlur(e){const t=this._currentFocus;N.default.isEqual(e,t)&&(this.blurTimeoutID=setTimeout((()=>{N.default.isEqual(this._currentFocus,t)&&this._setCurrentFocus(null)}),0))}_setWidgetProps(e,t,n){this.questionRenderer._setWidgetProps(e,t,n)}setInputValue(e,t,n){return this.questionRenderer.setInputValue(e,t,n)}focusPath(e){return this.questionRenderer.focusPath(e)}blurPath(e){return this.questionRenderer.blurPath(e)}getDOMNodeForPath(e){return this.questionRenderer.getDOMNodeForPath(e)}getGrammarTypeForPath(e){return this.questionRenderer.getGrammarTypeForPath(e)}getInputPaths(){return this.questionRenderer.getInputPaths()}focus(){return this.questionRenderer.focus()}blur(){this._currentFocus&&this.blurPath(this._currentFocus)}getNumHints(){return this.props.item.hints.length}scoreInput(){const e=this.questionRenderer.guessAndScore(),t=e[0],n=e[1],s=[t,[]],o=Be.keScoreFromPerseusScore(n,s,this.questionRenderer.getSerializedState()),i=this.questionRenderer.emptyWidgets();return this.setState({questionCompleted:o.correct,questionHighlightedWidgets:i}),o}getWidgetIds(){return this.questionRenderer.getWidgetIds()}scoreWidgets(){const e=this.questionRenderer.scoreWidgets(),t=this.questionRenderer.getUserInputForWidgets(),n=this.questionRenderer.getSerializedState();return Bf(e,((e,s)=>Be.keScoreFromPerseusScore(e,t[s],n)))}getSerializedState(){return{question:this.questionRenderer.getSerializedState(),hints:this.hintsRenderer.getSerializedState()}}restoreSerializedState(e,t){let n=2;const s=()=>{--n,t&&0===n&&t()};this.questionRenderer.restoreSerializedState(e.question,s),this.hintsRenderer.restoreSerializedState(e.hints,s)}showRationalesForCurrentlySelectedChoices(){this.questionRenderer.showRationalesForCurrentlySelectedChoices()}deselectIncorrectSelectedChoices(){this.questionRenderer.deselectIncorrectSelectedChoices()}render(){const e={...Qt.defaults,...this.props.apiOptions,onFocusChange:this._handleFocusChange},t={assetStatuses:this.state.assetStatuses,setAssetStatus:this.setAssetStatus},n=A.createElement(nn.Provider,{value:t},A.createElement(Li,{keypadElement:this.props.keypadElement,problemNum:this.props.problemNum,onInteractWithWidget:this.handleInteractWithWidget,highlightedWidgets:this.state.questionHighlightedWidgets,apiOptions:e,questionCompleted:this.state.questionCompleted,reviewMode:this.props.reviewMode,ref:e=>{null!=e&&(this.questionRenderer=e)},content:this.props.item.question.content,widgets:this.props.item.question.widgets,images:this.props.item.question.images})),s=A.createElement(Nf,{hints:this.props.item.hints,hintsVisible:this.props.hintsVisible,apiOptions:e,ref:e=>this.hintsRenderer=e});return A.createElement("div",null,A.createElement("div",null,n),A.createElement("div",{className:e.isMobile?void 0:l.css(qf.hintsContainer)},s))}}X(zf,"defaultProps",{apiOptions:{},onRendered:e=>{}});const qf=l.StyleSheet.create({hintsContainer:{marginLeft:50}}),Hf=A.forwardRef(((e,t)=>A.createElement(Lf.Consumer,null,(n=>{let{onRendered:s}=n;return A.createElement(zf,$({},e,{onRendered:s,ref:t}))}))));class Wf extends A.Component{render(){return A.createElement(Ul,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:A.createElement("span",null,"—")},{value:"->",content:A.createElement("span",null,"→")}],onChange:this.props.onChange})}}X(Wf,"defaultProps",{value:""});const Uf=[gn.BLACK,gn.BLUE,gn.GREEN,gn.PINK,gn.PURPLE,gn.RED,gn.GRAY],Gf=[gn.LIGHT_BLUE,gn.LIGHT_ORANGE,gn.LIGHT_PINK,gn.LIGHT_GREEN,gn.LIGHT_PURPLE,gn.LIGHT_RED,"#fff"];class Vf extends A.Component{render(){const e=this.props.lightColors?Gf:Uf;return A.createElement(Ul,{value:this.props.value,allowEmpty:!1,buttons:N.default.map(e,(e=>({value:e,content:A.createElement("span",null,A.createElement("span",{className:"colorpicker-circle",style:{background:e}})," ")}))),onChange:this.props.onChange})}}X(Vf,"defaultProps",{value:gn.BLACK,lightColors:!1});class jf extends A.Component{render(){return A.createElement(Ul,{value:this.props.value,allowEmpty:!1,buttons:[{value:"",content:A.createElement("span",null,"—")},{value:"-",content:A.createElement("span",null,"–––")},{value:"- ",content:A.createElement("span",null,"– –")},{value:".",content:A.createElement("span",null,"····")},{value:". ",content:A.createElement("span",null,"· · ·")}],onChange:this.props.onChange})}}X(jf,"defaultProps",{value:""});class Yf extends A.Component{constructor(e){super(e),X(this,"toggle",(e=>{e.preventDefault(),this.setState({show:!this.state.show})})),this.state={show:e.initiallyVisible}}render(){return A.createElement("div",{className:"perseus-interaction-element"},A.createElement("a",{href:"#",className:"perseus-interaction-element-title "+(this.state.show?"open":"closed"),onClick:this.toggle},this.state.show?A.createElement(K,gs):A.createElement(K,vs),this.props.title),A.createElement("div",{className:"perseus-interaction-element-content "+(this.state.show?"enter":"leave")},this.props.children,(null!=this.props.onUp||null!=this.props.onDown||null!=this.props.onDelete)&&A.createElement("div",{className:"edit-controls"},null!=this.props.onUp&&A.createElement("button",{onClick:this.props.onUp},A.createElement(K,xs)),null!=this.props.onDown&&A.createElement("button",{onClick:this.props.onDown},A.createElement(K,ys)),null!=this.props.onDelete&&A.createElement("button",{onClick:this.props.onDelete},A.createElement(K,Ts)))))}}X(Yf,"defaultProps",{initiallyVisible:!1,title:"More"});class Xf extends A.Component{constructor(){super(...arguments),X(this,"renderVisibleIcon",(()=>A.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:l.css($f.icon)},A.createElement("defs",null,A.createElement("path",{id:"a",d:"M7.401 10.035c-1.424.748-2.599 1.905-3.544 3.48a1 1 0 0 1-1.714-1.03C4.325 8.849 7.652 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48a5 5 0 1 1-9.198 0zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"})),A.createElement("g",{fill:"none",fillRule:"evenodd"},A.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),A.createElement("mask",{id:"b",fill:"#fff"},A.createElement("use",{href:"#a"})),A.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),A.createElement("g",{fill:"#fff",mask:"url(#b)"},A.createElement("path",{d:"M0 0h24v24H0z"})))))),X(this,"renderHiddenIcon",(()=>A.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:l.css($f.icon)},A.createElement("defs",null,A.createElement("path",{id:"a",d:"M8.794 7.38C9.791 7.127 10.86 7 12 7c4.348 0 7.675 1.848 9.857 5.486a1 1 0 0 1-1.714 1.028c-.945-1.574-2.12-2.73-3.544-3.48.258.604.401 1.268.401 1.966 0 1.02-.305 1.967-.828 2.757l2.535 2.536a1 1 0 0 1-1.414 1.414l-12-12a1 1 0 0 1 1.414-1.414L8.794 7.38zm5.914 5.913a3 3 0 0 0-4.001-4.001l4 4.001zM6.072 8.486l2.976 2.976a3 3 0 0 0 3.49 3.49l1.579 1.58A5 5 0 0 1 7.4 10.035c-1.424.747-2.599 1.904-3.544 3.478a1 1 0 0 1-1.714-1.028c1.049-1.75 2.363-3.085 3.929-4z"})),A.createElement("g",{fill:"none",fillRule:"evenodd"},A.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),A.createElement("mask",{id:"b",fill:"#fff"},A.createElement("use",{href:"#a"})),A.createElement("use",{fill:"#fff",fillRule:"nonzero",href:"#a"}),A.createElement("g",{fill:"#fff",mask:"url(#b)"},A.createElement("path",{d:"M0 0h24v24H0z"}))))))}render(){let e,t;return this.props.enabled?(e=$f.enabled,t=this.renderVisibleIcon()):(e=$f.disabled,t=this.renderHiddenIcon()),A.createElement("button",{className:l.css($f.hud,this.props.fixedPosition&&$f.hudFixedPosition,e),onClick:e=>{this.props.onClick()}},t,this.props.message)}}X(Xf,"propTypes",{message:R.default.string.isRequired,enabled:R.default.bool.isRequired,onClick:R.default.func.isRequired,fixedPosition:R.default.bool}),X(Xf,"defaultProps",{fixedPosition:!0});const $f=l.StyleSheet.create({hud:{boxSizing:"border-box",height:36,padding:"9px 16px",borderRadius:18,fontFamily:Z,fontSize:"15px",lineHeight:"18px",color:J,userSelect:"none",borderWidth:0},hudFixedPosition:{bottom:20,position:"fixed",right:20,zIndex:1},icon:{width:24,height:24,marginRight:8,marginTop:-3,verticalAlign:"middle"},enabled:{backgroundColor:"#f86700",":hover":{backgroundColor:"#df5c00"},":active":{backgroundColor:"#c75300"}},disabled:{backgroundColor:Q,":hover":{backgroundColor:"#a1a5a9"},":active":{backgroundColor:ee}}});class Kf extends A.Component{constructor(){super(...arguments),X(this,"toggleSelect",(e=>{const t=(this.props.values||[]).slice(0),n=this.props.allowEmpty;t.indexOf(e)>=0&&(t.length>1||n)?t.splice(t.indexOf(e),1):t.indexOf(e)<0&&t.push(e),this.props.onChange(t)}))}focus(){var e;return null===(e=O.findDOMNode(this))||void 0===e||e.focus(),!0}render(){const e=this.props.values||[],t=this.props.buttons.map(((t,n)=>{const s=e.indexOf(t.value)>=0;return A.createElement("button",{title:t.title,type:"button",id:""+n,key:""+n,ref:"button"+n,className:l.css(Zf.buttonStyle,s&&Zf.selectedStyle),onClick:()=>this.toggleSelect(t.value)},t.content||""+t.value)}));return A.createElement("div",{style:{display:"inline-block"}},t)}}X(Kf,"defaultProps",{values:[],allowEmpty:!0});const Zf=l.StyleSheet.create({buttonStyle:{backgroundColor:"white",border:"1px solid #ccc",borderLeft:"0",cursor:"pointer",margin:"0",padding:"5px 10px",position:"relative",":first-child":{borderLeft:"1px solid #ccc",borderTopLeftRadius:"3px",borderBottomLeftRadius:"3px"},":last-child":{borderRight:"1px solid #ccc",borderTopRightRadius:"3px",borderBottomRightRadius:"3px"},":hover":{backgroundColor:"#ccc"},":focus":{zIndex:2}},selectedStyle:{backgroundColor:"#ddd"}}),Jf=B.default({displayName:"PropCheckBox",propTypes:{labelAlignment:R.default.oneOf(["left","right"])},DEFAULT_PROPS:{label:null,onChange:null,labelAlignment:"left"},getDefaultProps:function(){return this.DEFAULT_PROPS},propName:function(){const e=N.default.find(N.default.keys(this.props),(function(e){return!N.default.has(this.DEFAULT_PROPS,e)}),this);if(!e)throw new he("Attempted to create a PropCheckBox with no prop!",pe.InvalidInput);return e},_labelAlignLeft:function(){return"left"===this.props.labelAlignment},render:function(){const e=this.propName();return A.createElement("label",null,this._labelAlignLeft()&&this.props.label,A.createElement("input",{type:"checkbox",checked:this.props[e],onChange:this.toggle}),!this._labelAlignLeft()&&this.props.label)},toggle:function(){const e=this.propName(),t={};t[e]=!this.props[e],this.props.onChange(t)}}),Qf=()=>!0;class em extends A.Component{constructor(){super(...arguments),X(this,"onChange",((e,t)=>{const n=this.props.value;0===e?this.props.onChange([t,n[1]]):this.props.onChange([n[0],t])}))}render(){const e=this.props.value,t=this.props.checkValidity||Qf;return A.createElement("div",{className:"range-input"},A.createElement(od,$({},this.props,{value:e[0],checkValidity:n=>t([n,e[1]]),onChange:this.onChange.bind(this,0),placeholder:this.props.placeholder[0]})),A.createElement(od,$({},this.props,{value:e[1],checkValidity:n=>t([e[0],n]),onChange:this.onChange.bind(this,1),placeholder:this.props.placeholder[1]})))}}X(em,"propTypes",{value:R.default.array.isRequired,onChange:R.default.func.isRequired,placeholder:R.default.array,checkValidity:R.default.func}),X(em,"defaultProps",{placeholder:[null,null]});var tm=Object.freeze({__proto__:null,ButtonGroup:Ul,Graph:Jc,Graphie:Po,HUD:Xf,Icon:da,InfoTip:uu,InlineIcon:K,MathInput:Yi,MultiButtonGroup:Kf,NumberInput:od,PropCheckBox:Jf,RangeInput:em,SvgImage:Go,TextInput:er,TexButtons:Vi,TextListEditor:Kt});var nm=Object.freeze({__proto__:null,devices:{PHONE:"phone",TABLET:"tablet",DESKTOP:"desktop"},lintGutterWidth:36,perseusFrameBorderWidth:1});const sm=A.createContext({setKeypadElement:e=>{},keypadElement:null,setRenderer:e=>{},renderer:null,setScrollableElement:e=>{},scrollableElement:null}),om=function(){},im=function(e,t,n,s){let o=e.content;if(null!=e.content){const n=t(e.content);void 0!==n&&(o=n)}const i=_n.mapObject(e.widgets||{},(function(e,t){return null==e||null==e.type?e:n(e,t)})),r=N.default.extend({},e,{content:o,widgets:i}),a=s(r);return void 0!==a?a:r},rm=function(e,t,n,s){return im(e,t=t||om,function(e,t,n){const s=function(o,i){var r;const a=yi(o),l=gi(a.type);let c;c=l&&(null===(r=a.version)||void 0===r?void 0:r.major)===l.major?Ci(a,(t=>im(t,e,s,n))):a;const p=t(c,i);return void 0!==p?p:c};return s}(t,n=n||om,s=s||om),s)},am={type:"hint"},lm=e=>({type:"array",elementShape:e});var cm={content:{type:"content"},hint:am,hints:lm(am),tags:{type:"tags"},arrayOf:lm,shape:e=>({type:"object",shape:e})};class pm{constructor(e,t,n){X(this,"content",void 0),X(this,"hint",void 0),X(this,"tags",void 0),X(this,"array",void 0),this.content=e,this.hint=t,this.tags=n,this.array=hm}setContentMapper(e){return new pm(e,this.hint,this.tags)}setHintMapper(e){return new pm(this.content,e,this.tags)}setTagsMapper(e){return new pm(this.content,this.hint,e)}setArrayMapper(e){return new dm(this.content,this.hint,this.tags,e)}mapTree(e,t){return fm(e,t,[],this)}}class dm{constructor(e,t,n,s){X(this,"content",void 0),X(this,"hint",void 0),X(this,"tags",void 0),X(this,"array",void 0),this.content=e,this.hint=t,this.tags=n,this.array=s}setArrayMapper(e){return new dm(this.content,this.hint,this.tags,e)}mapTree(e,t){return fm(e,t,[],this)}}function hm(e){return e}function um(){return new pm(hm,hm,hm)}function fm(e,t,n,s){if("content"===t.type){const o=e;return s.content(o,t,n)}if("hint"===t.type){const o=e;return s.hint(o,t,n)}if("tags"===t.type){const o=e;return s.tags(o,t,n)}if("array"===t.type){const o=e;if(!Array.isArray(o))throw new he('Invalid object of type "'.concat(typeof o,'" found at path ')+"".concat(["<root>"].concat(n).join("."),". Expected array."),pe.Internal);const i=t.elementShape,r=o.map(((e,t)=>fm(e,i,n.concat(t),s)));return s.array(r,o,t,n)}if("object"===t.type){const o=e;if(o&&"object"!=typeof o)throw new he('Invalid object of type "'.concat(typeof o,'" found at ')+"path ".concat(["<root>"].concat(n).join("."),". Expected ")+'"object" type.',pe.InvalidInput);const i=t.shape;if(!i)throw new he("Unexpected shape ".concat(JSON.stringify(t)," at path ")+"".concat(["<root>"].concat(n).join("."),"."),pe.InvalidInput);const r={};return Object.keys(i).forEach((e=>{if(!(e in o))throw new he('Key "'.concat(e,'" is missing from shape at path ')+"".concat(["<root>"].concat(n).join("."),"."),pe.InvalidInput);r[e]=fm(o[e],i[e],n.concat(e),s)})),r}throw new he("unexpected shape type ".concat(t.type),pe.InvalidInput)}function mm(e){if("content"===e.type)return{__type:"content",content:"",images:{},widgets:{}};if("hint"===e.type)return{__type:"hint",replace:!1,content:"",images:{},widgets:{}};if("tags"===e.type)return[];if("array"===e.type)return[];if("object"===e.type){const t=e.shape,n={};return Object.keys(t).forEach((e=>{n[e]=mm(t[e])})),n}throw new he("unexpected shape type ".concat(e.type),pe.InvalidInput)}function gm(e){if(Array.isArray(e))return e.length?"string"==typeof e[0]?cm.tags:cm.arrayOf(gm(e[0])):cm.arrayOf(cm.content);if("object"==typeof e&&("content"===e.__type||"item"===e.__type))return cm.content;if("object"==typeof e&&"hint"===e.__type)return cm.hint;if("object"==typeof e){const t={};return Object.keys(e).forEach((n=>{t[n]=gm(e[n])})),cm.shape(t)}throw new he("unexpected multi-item node ".concat(JSON.stringify(e)),pe.InvalidInput)}function vm(e){return e._multi}class bm extends A.Component{constructor(e){super(e),X(this,"rendererDataTreeMapper",void 0),X(this,"getRenderersMapper",void 0),X(this,"_handleSerializedStateUpdated",((e,t)=>{const{onSerializedStateUpdated:n}=this.props;if(n){const s=this._getSerializedState(this.props.serializedState);n(rf(s).set(e,t).freeze())}})),this.rendererDataTreeMapper=um().setContentMapper(((e,t,n)=>this._makeContentRendererData(e,n))).setHintMapper((e=>this._makeHintRendererData(e))).setTagsMapper((e=>null)),this.getRenderersMapper=um().setContentMapper((e=>e.makeRenderer())).setHintMapper((e=>e.makeRenderer())).setArrayMapper(((e,t,n)=>this._annotateRendererArray(e,t,n))),this.state=this._tryMakeRendererState(this.props)}UNSAFE_componentWillReceiveProps(e){e.item!==this.props.item&&this.setState(this._tryMakeRendererState(e))}_tryMakeRendererState(e){try{return{rendererDataTree:this._makeRendererDataTree(e.item,e.shape),renderError:null}}catch(e){return de.error("Error building tree state",pe.Internal,{cause:e}),{rendererDataTree:null,renderError:e}}}_getRendererProps(){const{item:e,children:t,shape:n,serializedState:s,onSerializedStateUpdated:o,...i}=this.props;return i}_makeContentRendererData(e,t){const n={ref:null,makeRenderer:null},s=e=>n.ref=e,o=e=>this._findWidgets(n,e),i=e=>this._handleSerializedStateUpdated(t,e);return n.makeRenderer=()=>A.createElement(Li,$({},this._getRendererProps(),e,{ref:s,findExternalWidgets:o,serializedState:this.props.serializedState?rf(this.props.serializedState).get(t):null,onSerializedStateUpdated:i})),n}_makeHintRendererData(e){const t=e=>this._findWidgets({},e);return{hint:e,findExternalWidgets:t,ref:null,makeRenderer:()=>A.createElement(Nf,$({},this._getRendererProps(),{findExternalWidgets:t,hints:[e]}))}}_makeRendererDataTree(e,t){const n=vm(e);return this.rendererDataTreeMapper.mapTree(n,t)}_findWidgets(e,t){const n=[];return this._mapRenderers((s=>{e!==s&&s.ref&&n.push(...s.ref.findInternalWidgets(t))})),n}_mapRenderers(e){const{rendererDataTree:t}=this.state;if(!t)return null;return um().setContentMapper(e).setHintMapper(e).mapTree(t,this.props.shape)}_scoreFromRef(e){if(!e)return null;const[t,n]=e.guessAndScore();let s;return e.getSerializedState&&(s=e.getSerializedState()),Be.keScoreFromPerseusScore(n,t,s)}getScores(){return this._mapRenderers((e=>this._scoreFromRef(e.ref)))}score(){const e=[],t=[],n=this._mapRenderers((n=>{var s;return n.ref?(n.ref.getSerializedState&&t.push(n.ref.getSerializedState()),e.push(n.ref.score()),null===(s=n.ref)||void 0===s?void 0:s.getUserInput()):null})),s=e.reduce(Be.combineScores);return Be.keScoreFromPerseusScore(s,n,t)}_getSerializedState(e){return this._mapRenderers(((t,n,s)=>t.ref?t.ref.getSerializedState():e?rf(e).get(s):null))}restoreSerializedState(e,t){let n=0;const s=()=>{n--,t&&0===n&&t()};this._mapRenderers(((t,o,i)=>{var r;if(!t.ref)return;const a=rf(e).get(i);a&&(n++,null===(r=t.ref)||void 0===r||r.restoreSerializedState(a,s))}))}_annotateRendererArray(e,t,n){if("hint"===n.elementShape.type){const n=t;(e=[...e]).firstN=e=>A.createElement(Nf,$({},this._getRendererProps(),{findExternalWidgets:n[0]?n[0].findExternalWidgets:void 0,hints:n.map((e=>e.hint)),hintsVisible:e}))}return e}_getRenderers(){return this.getRenderersMapper.mapTree(this.state.rendererDataTree,this.props.shape)}render(){return this.state.renderError?A.createElement("div",{className:l.css(ym.error)},I.$_("Error rendering: %(error)s",{error:String(this.state.renderError)})):this.props.children({renderers:this._getRenderers()})}}const ym=l.StyleSheet.create({error:{color:"red"}});function xm(e){if("content"===e.type)return R.default.shape({__type:R.default.oneOf(["content","item"]).isRequired,content:R.default.string,images:R.default.objectOf(R.default.any),widgets:R.default.objectOf(R.default.any)});if("hint"===e.type)return R.default.shape({__type:R.default.oneOf(["hint"]).isRequired,content:R.default.string,images:R.default.objectOf(R.default.any),widgets:R.default.objectOf(R.default.any),replace:R.default.bool});if("tags"===e.type)return R.default.arrayOf(R.default.string.isRequired);if("array"===e.type){const t=xm(e.elementShape);return R.default.arrayOf(t.isRequired)}if("object"===e.type){const t=e.shape,n={};return Object.keys(t).forEach((e=>{n[e]=xm(t[e]).isRequired})),R.default.shape(n)}throw new he("unexpected shape type ".concat(e.type),pe.InvalidInput)}var Cm={MultiRenderer:bm,shapes:cm,buildPropTypeForShape:function(e){return R.default.oneOfType([R.default.shape({_multi:xm(e)}),R.default.oneOf([null,void 0])])},buildEmptyItemForShape:function(e){return{_multi:mm(e)}},findContentNodesInItem:function(e,t,n){const s=vm(e);um().setContentMapper(n).mapTree(s,t)},findHintNodesInItem:function(e,t,n){const s=vm(e);um().setHintMapper(n).mapTree(s,t)},inferItemShape:function(e){return gm(vm(e))}};const{findContentNodesInItem:wm,inferItemShape:km}=Cm,Sm=function(e,t){let n=!0;return rm(e,null,(function(e){n=n&&function(e,t){if(null==e||null==e.type)return!0;const n=yi(e);return function(e,t){if(null==t)return!1;const n=e.version||{major:0,minor:0};return t.major>n.major||!(t.major<n.major)&&t.minor>=n.minor}(n,t[n.type])}(e,t)})),n},{findContentNodesInItem:Em,inferItemShape:_m}=Cm;function Mm(e,t){rm(e,null,(function(e){e.type&&!bi(e)&&t.push(e.type)}))}const Tm={serialize:function(){return N.default.omit(this.props,cr)}},Im=j,Pm=Y;exports.ApiOptions=Qt,exports.ArrowPicker=Wf,exports.ArticleRenderer=If,exports.BaseRadio=Ka,exports.Categorizer=rl,exports.Changeable=mr,exports.ClassNames=en,exports.ColorPicker=Vf,exports.DashPicker=jf,exports.Dependencies=ce,exports.EditorJsonify=Tm,exports.ElementContainer=Yf,exports.Errors=pe,exports.Expression=br,exports.GrapherUtil=mc,exports.GrapherWidget=wc,exports.HintRenderer=Pf,exports.HintsRenderer=Nf,exports.InputNumber=Mr,exports.InteractiveGraphWidget=wp,exports.ItemRenderer=Df,exports.JiptParagraphs=ei,exports.KeypadContext=sm,exports.KhanColors=gn,exports.KhanMath=ue,exports.LoadingContext=Lf,exports.Log=de,exports.MatrixWidget=vd,exports.MultiItems=Cm,exports.NumericInput=Fr,exports.PerseusError=he,exports.PerseusMarkdown=Ke,exports.PlotterWidget=tu,exports.Radio=nl,exports.Renderer=Li,exports.ServerItemRenderer=Hf,exports.SizingUtils=ci,exports.TableWidget=Fu,exports.TransformerWidget=sf,exports.Util=Be,exports.WIDGET_PROP_BLACKLIST=cr,exports.WidgetJsonifyDeprecated=Dr,exports.Widgets=Ii,exports.apiVersion=Im,exports.buildEmptyItemTreeForShape=mm,exports.buildMapper=um,exports.components=tm,exports.constants=nm,exports.displaySigFigs=function(e,t,n,s){const o=""+e;let i,r,a,l=df(o),c=pf(o),p=cf(o),d=!1;if(0==e||""==c||"0"==c){c="";for(let e=0;e<t;e++)c+="0";l=t+n,n<0&&-n>=t&&(d=!0)}else{if(r=l-c.length-n,a=t-c.length,i=Math.min(a,r),i<0){let e=hf(c,-i);e.length>c.length+i&&(l++,r>a&&(e=hf(e,1))),c=e}else if(i>0)for(let e=0;e<i;e++)c+="0";""!=c&&"0"!=c||(c="0",p=!0,l=1+n,0!=l&&(d=!0))}let h="";if(p||(h+="-"),s||c.length>20||l>4||l<-2||l-c.length>0&&lf(c)>0||d)h+=c.charAt(0),c.length>1&&(h+="."+c.substring(1,c.length)),l-1!=0&&(h+=" x 10^"+(l-1));else{let e="",t="",n=!0;if(l>0)if(c.length>l)e=c.substring(0,l),t=c.substring(l,c.length);else{e=c,n=0!=lf(c);for(let t=0;t<l-c.length;t++)e+="0"}else{for(let e=0;e<-l;e++)t+="0";t+=c}h+=(""==e?"0":e)+(n?".":"")+t}return h},exports.globalConstants=ha,exports.globalStyles=va,exports.icons=As,exports.init=function(e){fi(sl),fi(Sf);return e.skipMathJax?Promise.resolve():new Promise(((e,t)=>{MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:"none","HTML-CSS":{availableFonts:["TeX"],imageFont:null,scale:100,showMathMenu:!1}}),MathJax.Hub.Configured(),MathJax.Hub.Queue(e)}))},exports.interactiveSizes=ne,exports.isItemRenderableByVersion=function(e,t){if(null==e||null==t)throw new he("missing parameter to Perseus.isRenderable.item",pe.InvalidInput);if(e._multi){const n=km(e);let s=!0;return wm(e,n,(e=>{Sm(e,t)||(s=!1)})),s}return Sm(e.question,t)},exports.itemDataVersion=Pm,exports.itemToTree=vm,exports.itemVersion=_f,exports.mediaQueries=jr,exports.preprocessTex=si,exports.registerAllWidgetsForTesting=()=>{fi(Ef)},exports.shapes=cm,exports.traverse=rm,exports.violatingWidgets=function(e){const t=[];if(e._multi){const n=_m(e);Em(e,n,(e=>Mm(e,t)))}else Mm(e.question,t);return N.default.uniq(t)},exports.widgets=Ef;
|
|
16
8
|
//# sourceMappingURL=index.js.map
|