/*
 Joel Espinosa Longi
 jlongi@im.unam.mx
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2026-04-23
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_ES6=!1;$jscomp.ASSUME_ES2020=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.INSTRUMENT_ASYNC_CONTEXT=!0;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(a,k,g){if(a==Array.prototype||a==Object.prototype)return a;a[k]=g.value;return a};$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var k=0;k<a.length;++k){var g=a[k];if(g&&g.Math==Math)return g}throw Error("Cannot find global object");};
$jscomp.global=$jscomp.ASSUME_ES2020?globalThis:$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE=typeof Symbol==="function"&&typeof Symbol("x")==="symbol";$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,k,g){if(!g||a!=null){g=$jscomp.propertyToPolyfillSymbol[k];if(g==null)return a[k];g=a[g];return g!==void 0?g:a[k]}};
$jscomp.TYPED_ARRAY_CLASSES=function(){var a="Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64".split(" ");$jscomp.global.BigInt64Array&&(a.push("BigInt64"),a.push("BigUint64"));return a}();$jscomp.polyfillTypedArrayMethod=function(a,k,g,d){if(k)for(var b=0;b<$jscomp.TYPED_ARRAY_CLASSES.length;b++){var e=$jscomp.TYPED_ARRAY_CLASSES[b]+"Array.prototype."+a;$jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(e,k,g,d):$jscomp.polyfillUnisolated(e,k,g,d)}};
$jscomp.polyfill=function(a,k,g,d){k&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,k,g,d):$jscomp.polyfillUnisolated(a,k,g,d))};$jscomp.polyfillUnisolated=function(a,k,g,d){g=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var b=a[d];if(!(b in g))return;g=g[b]}a=a[a.length-1];d=g[a];k=k(d);k!=d&&k!=null&&$jscomp.defineProperty(g,a,{configurable:!0,writable:!0,value:k})};
$jscomp.polyfillIsolated=function(a,k,g,d){var b=a.split(".");a=b.length===1;d=b[0];d=!a&&d in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var e=0;e<b.length-1;e++){var l=b[e];if(!(l in d))return;d=d[l]}b=b[b.length-1];g=$jscomp.IS_SYMBOL_NATIVE&&g==="es6"?d[b]:null;k=k(g);k!=null&&(a?$jscomp.defineProperty($jscomp.polyfills,b,{configurable:!0,writable:!0,value:k}):k!==g&&($jscomp.propertyToPolyfillSymbol[b]===void 0&&(g=Math.random()*1E9>>>0,$jscomp.propertyToPolyfillSymbol[b]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(b):$jscomp.POLYFILL_PREFIX+g+"$"+b),$jscomp.defineProperty(d,$jscomp.propertyToPolyfillSymbol[b],{configurable:!0,writable:!0,value:k})))};$jscomp.checkEs6ConformanceViaProxy=function(){try{var a={},k=Object.create(new $jscomp.global.Proxy(a,{get:function(g,d,b){return g==a&&d=="q"&&b==k}}));return k.q===!0}catch(g){return!1}};$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1;$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy();
$jscomp.arrayIteratorImpl=function(a){var k=0;return function(){return k<a.length?{done:!1,value:a[k++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.initSymbol=function(){};$jscomp.iteratorPrototype=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a};
$jscomp.makeIterator=function(a){var k=typeof Symbol!="undefined"&&Symbol.iterator&&a[Symbol.iterator];if(k)return k.call(a);if(typeof a.length=="number")return $jscomp.arrayIterator(a);throw Error(String(a)+" is not an iterable or ArrayLike");};$jscomp.owns=function(a,k){return Object.prototype.hasOwnProperty.call(a,k)};$jscomp.MapEntry=function(){};
$jscomp.polyfill("Set.prototype.intersection",function(a){return a?a:function(k){$jscomp.checkIsSetInstance(this);$jscomp.checkIsSetLike(k);var g=new Set,d=$jscomp.getSmallerAndLargerSets(this,k);k=d.smallerSetIterator;d=d.largerSet;for(var b=k.next();!b.done;)d.has(b.value)&&g.add(b.value),b=k.next();return g}},"es_next","es6");
$jscomp.checkIsSetLike=function(a){if(typeof a!=="object"||a===null||typeof a.size!=="number"||a.size<0||typeof a.keys!=="function"||typeof a.has!=="function")throw new TypeError("Argument must be set-like");};$jscomp.checkIsValidIterator=function(a){if(typeof a!=="object"||a===null||typeof a.next!=="function")throw new TypeError("Invalid iterator.");return a};
$jscomp.getSmallerAndLargerSets=function(a,k){return a.size<=k.size?{smallerSetIterator:a.keys(),largerSet:k}:{smallerSetIterator:$jscomp.checkIsValidIterator(k.keys()),largerSet:a}};$jscomp.checkIsSetInstance=function(a){if(!(a instanceof Set))throw new TypeError("Method must be called on an instance of Set.");};window.descartesJS=window.descartesJS||{};
window.babel=(a=>{a.no=a.ez=a.non=a["n\u00e3o"]=a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a.sim=a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto=a["#000000"]="#000000";a.maxenta=a.magenta=a["#ff00ff"]="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu=a["#0000ff"]="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise=a["#00ffff"]="#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert=
a["#00ff00"]="#00ff00";a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo=a["#ffff00"]="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa=a["#ffc800"]="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho=a["#ff0000"]="#ff0000";a.pink=a.rosa=a.arrosa=a.rose=a["#ffafaf"]="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro=a["#404040"]="#404040";a.gris=a.gray=a.grisa=a.cinza=a["#808080"]="#808080";a.grisClaro=a.lightGray=
a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro=a["#c0c0c0"]="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=a["#ffffff"]="#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=
a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]="sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=
a.sobre="about";a.config=a.konfig=a["configura\u00e7\u00e3o"]="config";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]=a.fillP="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=
a["plein-"]=a["recheo-"]=a["preencher-"]=a.fillM="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=a.external=a.kanpoalde=
a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=
a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte=a.testua="text";a.punto=a.point=a.punt=a.puntu=a.ponto=a.dot="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem=a.bg_image=a.irudia=a.imagem_de_fundo=a.irundia="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]=a.version=
"version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=a.language="language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=
a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer=a.doExpr="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto=a.whileExpr="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=a.algorithm=a.algorisme=
a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]=a.drawif="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]=a.x_axis="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=a["eixo-y"]=
a.y_axis="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]=a.exponentialif="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=
a.fim="end";a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]=a.onlyOnce="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]=a.colorInt="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=
a.animer="animate";a.auto="auto";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.alto=a.height=a.alt=a.altu=a.haut=a.altura=a["al\u00e7ada"]=a.hauteur=a.alto="height";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.profundidade=a.amplada=a.width=a.ample=a.large=a.largura="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.color_reverso=a.backcolor=a.color_revers=a["atzealde kolorea"]=
a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=
a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a.octahedron=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=
a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor=a.colour=a.kolorea="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir=
"split";a.despliegue=a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]=a.raytrace="raytrace";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]=
"bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.zentratu=a["centr\u00e9e"]=a.centrado=a.imgcenter="imgcenter";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=a.filas_norte=a.linhas_norte=a.files_nord=a.rowsNorth=
"rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud=a.rowsSouth="rowsSouth";a.ancho_este=a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est=a.widthEast="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest=a.widthWest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=a["Init Animation"]=
a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]=a.initAnimation="initAnimation";a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=
a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=
a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]=a.openURL="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]=a.openScene="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=
a.execution=a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.pos_mensajes=
a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra=a.x="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]=
"sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir=a.playAudio="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]=a.activeif="activeif";a.rotfin=a.finrot=a.bukrot=a.endrot="endrot";a.posfin=a.finpos=a.bukpos=a.endpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.R2="2D";a.R3="3D";a.vectores=a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=
a["font size"]=a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]=a.font_size="font_size";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte=a.onlyText="onlyText";a.respuesta=a.answer="answer";a.peso=a.weight=a.pes=
"weight";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.library="library";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text=a.border="border";a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay="autoplay";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=
a.align=a["ali\u00f1ar"]=a.aligner="align";a.anchor="anchor";a.a_left="left";a.a_center="center";a.a_right="right";a.a_justify="justify";a.a_top_left="top_left";a.a_top_center="top_center";a.a_top_right="top_right";a.a_center_left="center_left";a.a_center_center="center_center";a.a_center_right="center_right";a.a_bottom_left="bottom_left";a.a_bottom_center="bottom_center";a.a_bottom_right="bottom_right";a.malla=a.mesh="mesh";a.local=a.Local="local";a.rectangle=a["rect\u00e1ngulo"]="rectangle";a.lineDash=
"lineDash";a.solid="solid";a.dot="dot";a.dash="dash";a.dash_dot="dash_dot";a.offset_dist="offset_dist";a.offset_angle="offset_angle";a.flat="flat";a.borderColor="borderColor";a.text_align="text_align";a.image_align="image_align";a.checkbox="checkbox";a.torus=a.toro="torus";a.R="R";a.r="r";a.border_radius="border_radius";a.radio_group="radio_group";a.font_family="font_family";a.resizable="resizable";a.slider="slider";a.antialias="antialias";a.image_loader="image_loader";a.expand="expand";a.cover=a.cubrir=
"cover";a.fit=a.escalar="fit";a.code="code";a.doc="doc";a.image_dec="image_dec";a.image_inc="image_inc";a.btn_pos="btn_pos";a.border_width="border_width";a.border_color="border_color";a.v_left="v_left";a.v_right="v_right";a.h_left="h_left";a.h_right="h_right";a.h_left_right="h_left_right";a.label_color="label_color";a.label_text_color="label_text_color";a.shadowColor="shadowColor";a.shadowBlur="shadowBlur";a.shadowOffsetX="shadowOffsetX";a.shadowOffsetY="shadowOffsetY";a.border_size="border_size";
a.clip="clip";a.keyboard="keyboard";a.kblayout="kblayout";a.kbexp="kbexp";a.extra_style="extra_style";return a})({});(a=>{a.addSymbolFont=function(k){let g=[["normal","bold"],["italic","bold"],["italic","normal"],["normal","normal"]];for(let d of g)k.insertRule(`@font-face{font-family:'DJS_symbol';src:url('data:font/woff2;charset=utf-8;base64, ') format('woff2');font-style:${d[0]};font-weight:${d[1]};}`)}})(descartesJS);
(a=>{let k,g,d={bold:"Bold",italic:"Italic",italics:"Italic","bold+italic":"Italic Bold"};a.serif_font="descartesJS_serif,DJS_symbol,DJS_serif,Times,'Times New Roman','Liberation Serif','Nimbus Roman No9 L Regular',serif";a.sansserif_font="descartesJS_sansserif,DJS_symbol,DJS_sansserif,Helvetica,Arial,'Liberation Sans','Nimbus Sans L',sans-serif";a.monospace_font="descartesJS_monospace,DJS_symbol,DJS_monospace,'Courier New',Courier,'Liberation Mono','Nimbus Mono L',monospace";a.math_font="descartesJS_math,DJS_symbol,DJS_math,DJS_serif,Times,'Times New Roman','Liberation Serif','Nimbus Roman No9 L Regular',serif";
a.convertFont=function(b){if(b=="")return b;k=b.split(",");return a.getFontStyle(k[1])+" "+k[2]+"px "+a.getFontName(k[0].split(" ")[0])};a.getFontName=function(b){b=b.toLowerCase();g=a.monospace_font;/sansserif|arial|helvetica/.test(b)?g=a.sansserif_font:/serif|times/.test(b)&&(g=a.serif_font);return g};a.getFontStyle=function(b){return d[b.toLowerCase()]||""};a.getTextWidth=function(b,e){if(b=="")return 0;a.ctx.font!=e&&(a.ctx.font=e);return Math.round(a.ctx.measureText(b).width*100)/100};a.getFieldFontSize=
function(b){b=Math.min(50,b);return b>=24?Math.floor(2+b*.4375):b>=20?12:b>=17?11:b>=15?10:9}})(descartesJS);
(a=>{function k(){let b,e,l,w,q,n,p;Number.prototype.oToFixed||(Number.prototype.oToFixed=Number.prototype.toFixed,Number.prototype.toFixed=function(r=0){r=Math.max(0,Math.trunc(r));b=""+this;b.includes("e")&&(w=b.split("e"),n=w[0][0]=="-"?"-":"",q=n=="-"?parseFloat(w[0].slice(1)).oToFixed(11):parseFloat(w[0]).oToFixed(11),p=Math.trunc(w[1]),e=q.indexOf("."),q=q.replace(".",""),e+p<0?(e=e<0?1:e,b=n+"0."+"0".repeat(Math.abs(e+p))+q):b=n+q+"0".repeat(p-q.length+1));e=b.indexOf(".");e==-1?r>0&&(b+="."+
"0".repeat(r)):(l=b.length-e-1,b=l>=r?r<=11?parseFloat(b).oToFixed(r):b=b.slice(0,e+r+1):b+"0".repeat(r-l));return b})}const g=360/(Math.PI*2),d=Math.PI*2/360;a.rangeOK=a.cssScale=1;a.radToDeg=function(b){return b*g};a.degToRad=function(b){return b*d};a.getFeatures=function(){var b="";try{b=navigator.appVersion.toLowerCase()}catch(e){console.warn("navigator.appVersion is deprecated")}a.hasTouchSupport="ontouchstart"in window||/android/i.test(b);a.isIOS=/iPad|iPhone/i.test(navigator.userAgent);b=a.newHTML("canvas");
b.getContext&&(a.hasCanvas=b.getContext("2d"));if(a.hasCanvas){b.width=b.height=1;a.ctx=a.hasCanvas;a.ctx.textRendering="geometricPrecision";let e=window.devicePixelRatio||1;a._ratio=e==1?1.2:e;a.webpSupport=b.toDataURL("image/webp").indexOf("data:image/webp")==0}k()};a.whichBtn=function(b){return b.pointerType&&/touch|pen/.test(b.pointerType)||b.touches?"L":b.button==0?"L":b.button==1?"M":"R"};a.getCursorPosition=function(b,e){let l=b;b.touches&&b.touches.length>0&&(l=b.touches[0]);if(!l||typeof l.clientX==
"undefined")return null;b=e.getBoundingClientRect();return{x:(l.clientX-b.left)/a.cssScale,y:(l.clientY-b.top)/a.cssScale}};a.splitSeparator=function(b){let e=!1,l,w,q=[],n=0;for(let p=0,r=b.length;p<r;p++)if(l=b[p],l=="'"&&(e=!e),!e&&(w=+(l=="\\"&&b[p+1]=="n"),l==";"||w))q.push(b.slice(n,p)),n=p+1+w;q.push(b.slice(n));return q};a.preventDefault=b=>{b.stopPropagation();b.preventDefault();return!1};a.convertHTMLEntities=function(b){let e=a.newHTML("textarea");e.innerHTML=b;return e.value};a.newHTML=
function(b,e){b=document.createElement(b);for(let l in e)b.setAttribute(l,e[l]);return b};window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame;a.setInterval=function(b,e){function l(){Date.now()-w>=e&&(b.call(),w=Date.now());q.value=requestAnimationFrame(l)}if(!requestAnimationFrame)return setInterval(b,e);
let w=Date.now(),q={};q.value=requestAnimationFrame(l);return q};a.clearInterval=function(b){b&&(cancelAnimationFrame?cancelAnimationFrame(b.value):clearInterval(b))};a.setTimeout=function(b,e){function l(){Date.now()-w>=e?b.call():q.value=requestAnimationFrame(l)}if(!requestAnimationFrame)return setTimeout(b,e);let w=Date.now(),q={};q.value=requestAnimationFrame(l);return q};a.clearTimeout=function(b){b&&(cancelAnimationFrame?cancelAnimationFrame(b.value):clearTimeout(b))};a.showAbout=function(){window.open("https://arquimedes.matem.unam.mx/Descartes5/creditos/",
"cr\u00e9ditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0")}})(descartesJS);
(a=>{a.cacheFiles={};a.openFile=function(k){if(a.cacheFiles[k])return a.cacheFiles[k];let g=null,d=new XMLHttpRequest;d.open("GET",k,!1);try{d.send(null),g=d.status===404?"":d.responseText||"",g.match(String.fromCharCode(65533))&&(d.open("GET",k,!1),d.overrideMimeType("text/plain;charset=ISO-8859-1"),d.send(null),g=d.responseText)}catch(b){g=null}return g};a.addExternalFileContent=function(k,g){a.cacheFiles[k]=g}})(descartesJS);
(a=>{function k(q){q=q.replace(/[+*()]/g,"\\$&");b=q.trim();for(q={ignoreAccents:!1,ignoreCaps:!1,regExp:null};;)if(b.startsWith("'")&&b.endsWith("'"))q.ignoreCaps=!0,b=b.slice(1,-1);else if(b.startsWith("`")&&b.endsWith("\u00b4"))q.ignoreAccents=!0,b=b.slice(1,-1);else break;b.startsWith("\\*")&&!b.endsWith("\\*")?b=b.slice(2)+"$":!b.startsWith("\\*")&&b.endsWith("\\*")?b="^"+b.slice(0,-2):b.startsWith("\\*")||b.endsWith("\\*")?b.startsWith("\\*")&&b.endsWith("\\*")&&(b=b.slice(2,-2)):b="^"+b+"$";
q.regExp=b.replace(/\?/g,"[\\S\\s]{1}");return q}function g(q="",n){let p={},r=q.match(/^\s*(\(|\[)(.*)(\)|\])\s*$/);r?(p.type=r[1]+r[3],r=a.splitComa(r[2]),p.min=n.parser.parse(r[0]),p.max=n.parser.parse(r[1])):(p.type="[]",p.min=p.max=n.parser.parse(q));return p}function d(q=""){return q.toString().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}let b,e,l,w;a.answerRegEx=function(q="",n,p){p&&q.startsWith("(")&&q.endsWith(")")&&(q=q.slice(1,-1));q=q.replace(/&squot;|&amp;/g,r=>r==="&squot;"?"'":
"&").split("|");for(let r=0,t=q.length;r<t;r++){e=q[r].split("&");l=[];for(let c of e)p?l.push(k(c)):l.push(g(c,n));q[r]=l}return q};a.esCorrecto=function(q,n="",p){n=""+n;for(let c of q){w=!0;for(let f of c)if(b=f.regExp)f.ignoreAccents&&(n=d(n),b=d(b)),f.ignoreCaps&&(n=n.toLowerCase(),b=d(b).toLowerCase()),w=w&&!!n.match(b);else{if(q=w){q=f;var r=n,t=p;r=parseFloat(r);let m=t.eval(q.min);t=t.eval(q.max);t=q.type[1]==")"?r<t:r<t||Math.abs(t-r)<1E-8;q=(q.type[0]=="("?m<r:m<r||Math.abs(m-r)<1E-8)&&
t}w=q}if(w)return 1}return 0}})(descartesJS);
(a=>{a.loaderImg=new Image;a.loaderImg.src="data:image/svg+xml;base64,"+btoa('<svg xmlns=\'http://www.w3.org/2000/svg\' width="880" height="840" viewBox="0 0 880 840"><path d="M440 80c-132.5 0-240 107.5-240 240s107.5 240 240 240 240-107.5 240-240S572.5 80 440 80zm-11.1 462.2c-122.7 0-224.4-99.5-224.4-222.2S306.2 97.8 428.9 97.8 651.1 197.3 651.1 320s-99.5 222.2-222.2 222.2zm-11.1-426.6c-112.9 0-208.9 91.5-208.9 204.4s96 204.4 208.9 204.4S622.2 432.9 622.2 320s-91.5-204.4-204.4-204.4zm-11.1 391.1c-103.1 0-193.3-83.6-193.3-186.7s90.2-186.7 193.3-186.7S593.3 216.9 593.3 320s-83.5 186.7-186.6 186.7zm-11.1-355.6c-93.3 0-177.8 75.6-177.8 168.9s84.5 168.9 177.8 168.9S564.4 413.3 564.4 320c0-93.3-75.6-168.9-168.8-168.9zm-11.2 320c-83.5 0-162.2-67.7-162.2-151.1S301 168.9 384.4 168.9 535.6 236.5 535.6 320s-67.7 151.1-151.2 151.1zm-11.1-284.4c-73.6 0-146.7 59.7-146.7 133.3s73 133.3 146.7 133.3S506.7 393.6 506.7 320 447 186.7 373.3 186.7zm-11.1 248.9c-63.8 0-131.1-51.7-131.1-115.6s67.3-115.6 131.1-115.6S477.8 256.2 477.8 320 426 435.6 362.2 435.6zm-11.1-213.4c-54 0-115.6 43.8-115.6 97.8s61.6 97.8 115.6 97.8c54 0 97.8-43.8 97.8-97.8s-43.8-97.8-97.8-97.8zM340 400c-44.2 0-100-35.8-100-80s55.8-80 100-80 80 35.8 80 80-35.8 80-80 80z" fill="#2daae4"/><path d="M115.8 600.7c32.5 0 48.8 24.8 48.8 49.7 0 24.9-16.2 49.6-48.8 49.6H80.2v-99.3zm0 85c23 0 34.6-17.6 34.6-35.2s-11.6-35.4-34.6-35.4H94.5v70.6zm118.2 0V700h-60.6v-99.3h60.5V615h-46v28h45v14.5h-45l-.05 28.2zm42.2.9c10.6 0 22.3-6 22.3-16.2 0-1-.1-2.1-.4-3.4-1.7-7.5-11.9-8.8-21.9-9.8-15.5-1.6-33.7-5-35.2-25.65-.6-6.65 1.1-13.25 5.4-18.85 6.7-8.7 18.6-13.2 30.1-13.2 15.3 0 31.2 8 33.8 26.1l-14.3.7c-2-8.9-11.6-12.8-20.3-12.6-6.7.1-14.1 2.4-18 7.5-2 2.6-2.7 5.8-2.4 9.2.7 10.2 11.9 11.5 22.6 12.5 13.6 1.7 30.5 5.3 34.4 21.2.4 2.1.7 4.5.7 6.5 0 19.2-19 30.2-36.9 30.2-15.3 0-33.9-9.1-35.8-26.8l-.1-2.7 14.5-.3.1 1.8c1 8.9 12.2 13.8 21.4 13.8zm58-71.7c8.7-8.9 20.9-14.8 34.4-14.8 22.7 0 40.6 14.2 46.3 36.6h-14.2c-5.3-14.9-17.5-22.4-32.1-22.4-9.5 0-18.2 4.1-24.4 10.7-6.2 6.5-10.2 15.3-10.2 25.6 0 9.9 4 18.7 10.2 25.3 6.2 6.6 14.9 10.6 24.4 10.6 15.1 0 27.8-8.7 32.9-23.7h14.1c-5.7 22.6-23.9 37.9-47 37.9-13.5 0-25.7-5.7-34.4-14.8-8.5-9.1-14.2-21.6-14.2-35.4 0-14 5.7-26.5 14.2-35.6zm144.6 55.8h-35.6c-3.8 9.1-8.8 21-11.9 29.3h-15.5l39.9-100.7h10.5L506 700h-15.3zm-30.3-13.4h24.7L461 622.2zm96.9-7.7c12.1 0 18-8.7 18-17.3 0-8.5-6-17.2-18-17.2h-22V700h-14.2v-99.4h36.2c21.6 0 32.4 15.9 32.4 31.7 0 14.1-8.7 27.4-25.7 30.4l31.4 37.3h-18.6l-36.2-43.6-.05-6.8zm64.9 50.8v-85.3h-30.1v-14.5h74.4v14.5h-30v85.3zm112.2-14.7V700H662v-99.3h60.5V615h-46v28h45v14.5h-45l-.05 28.2zm42.3.9c10.6 0 22.3-6 22.3-16.2 0-1-.1-2.1-.4-3.4-1.7-7.5-11.9-8.8-21.9-9.8-15.5-1.6-33.7-5-35.2-25.65-.6-6.65 1.1-13.25 5.4-18.85 6.7-8.7 18.6-13.2 30.1-13.2 15.3 0 31.2 8 33.8 26.1l-14.3.7c-2-8.9-11.6-12.8-20.3-12.6-6.7.1-14.1 2.4-18 7.5-2 2.6-2.7 5.8-2.4 9.2.7 10.2 11.9 11.5 22.6 12.5 13.6 1.7 30.5 5.3 34.4 21.2.4 2.1.7 4.5.7 6.5 0 19.2-19 30.2-36.9 30.2-15.3 0-33.9-9.1-35.8-26.8l-.1-2.7 14.5-.3.1 1.8c1 8.9 12.2 13.8 21.4 13.8z" fill="#868686"/></svg>');a.getSvgGradient=
function(k=0){return"data:image/svg+xml;base64,"+btoa(`<svg xmlns='http://www.w3.org/2000/svg' width="100" height="100" viewBox="0 0 100 100"><defs><linearGradient id="a" x1="0%" y1="0%" x2="0%" y2="100%"><stop stop-color="#000" stop-opacity=".09566" offset="0"/><stop stop-color="#000" stop-opacity=".07558" offset=".04"/><stop stop-color="#000" stop-opacity=".05787" offset=".08"/><stop stop-color="#000" stop-opacity=".03905" offset=".13"/><stop stop-color="#000" stop-opacity=".0189" offset=".2"/><stop stop-color="#000" stop-opacity="0" offset=".36"/><stop stop-color="#000" stop-opacity=".01063" offset=".48"/><stop stop-color="#000" stop-opacity=".06643" offset=".66"/><stop stop-color="#000" stop-opacity=".1241" offset=".77"/><stop stop-color="#000" stop-opacity=".3023" offset="1"/></linearGradient></defs><rect transform="rotate(${k},50,50)" width="100" height="100" fill="url(#a)"/></svg>`)};
a.getSvgCheckbox=function(){return"data:image/svg+xml;base64,"+btoa('<svg xmlns=\'http://www.w3.org/2000/svg\' width="45" height="45"><path d="M37.095 6.284L15.473 27.905l-7.568-7.567L2.5 25.743l12.973 12.973L42.5 11.69z" fill="#1e272e"/></svg>')};a.getSvgRadio=function(){return"data:image/svg+xml;base64,"+btoa('<svg xmlns=\'http://www.w3.org/2000/svg\' width="45" height="45"><circle cx="22.5" cy="22.5" r="15" fill="#1e272e"/></svg>')}})(descartesJS);
(a=>{let k=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.webp)/gi,g,d,b,e,l,w,q,n,p,r,t,c;class f{constructor(m,v){this.r=this.g=this.b=0;this.a=1;this.evaluator=v;this.getColor=this.getColorStr;if(!m)this.colorStr="rgba(0,0,0,1)";else if(/^GradL/.test(m)){var h=a.splitComa(m.slice(6,-1));this.x1=v.parser.parse(h[0]);this.y1=v.parser.parse(h[1]);this.x2=v.parser.parse(h[2]);this.y2=v.parser.parse(h[3]);this.stops=[];for(let u=4;u<h.length;u++)h[u]!=""&&(m=h[u].split("|"),this.stops.push({percentage:v.parser.parse(m[1]),
color:`#${m[2]}`}));this.getColor=this.getLinearGradient}else if(/^Pattern/.test(m))this.img_src=m.slice(8,-1),this.img_src.match(k)&&(this.img_src=`'${this.img_src}'`),this.img_src=v.parser.parse(this.img_src),this.getColor=this.getPattern;else if(babel[m])babel[m]=="net"&&(m="rojo"),this.colorStr=m=babel[m],this.r=a.toHex(m.slice(1,3)),this.g=a.toHex(m.slice(3,5)),this.b=a.toHex(m.slice(5,7));else if(m.length==6)this.r=a.toHex(m.slice(0,2)),this.g=a.toHex(m.slice(2,4)),this.b=a.toHex(m.slice(4,
6)),this.colorStr=`#${m}`;else if(m.length==8)this.r=a.toHex(m.slice(2,4)),this.g=a.toHex(m.slice(4,6)),this.b=a.toHex(m.slice(6,8)),this.a=1-a.toHex(m.slice(0,2))/255,this.colorStr=`rgba(${this.r},${this.g},${this.b},${this.a})`;else if(m[0]=="("){v=[];m=a.splitComa(m.slice(1,-1));for(h of m)m=parseInt(h,16),h!==m.toString(16)&&h!==`0${m.toString(16)}`?(h.startsWith("[")&&h.endsWith("]")&&(h=h.slice(1,-1)),v.push(this.evaluator.parser.parse(h))):v.push(this.evaluator.parser.parse(""+m/255));[this.rExpr,
this.gExpr,this.bExpr,this.aExpr]=v;this.getColor=this.getColorExp}}getColorStr(){return this.colorStr}getColorExp(){g=this.evaluator;this.r=Math.floor(g.eval(this.rExpr)*255);this.g=Math.floor(g.eval(this.gExpr)*255);this.b=Math.floor(g.eval(this.bExpr)*255);this.a=1-g.eval(this.aExpr);return`rgba(${this.r},${this.g},${this.b},${this.a})`}getLinearGradient(){g=this.evaluator;t=a.ctx.createLinearGradient(g.eval(this.x1),g.eval(this.y1),g.eval(this.x2),g.eval(this.y2));for(const m of this.stops)t.addColorStop(Math.min(Math.max(g.eval(m.percentage),
0),1),m.color);return t}getPattern(){if(c=this.evaluator.parent.getImage(this.evaluator.eval(this.img_src)))try{return a.ctx.createPattern(c,"repeat")}catch(m){}return"ff00ff"}borderColor(){return this.r+this.g+this.b<380?"#ffffff":"#000000"}}a.toHex=function(m){return parseInt(`0x${m}`,16)};a.toHexStr=function(m){return parseInt(m).toString(16).padStart(2,"0")};a.RGBAToHexColor=function(m){m=m.slice(5,-1).split(",");q=a.toHexStr(m[0]);n=a.toHexStr(m[1]);p=a.toHexStr(m[2]);r=a.toHexStr(255-parseInt(parseFloat(m[3])*
255));return new f(r+q+n+p)};a.splitComa=function(m){d=[];b=e=l=0;for(let v=0,h=m.length;v<h;v++)w=m[v],w=="("?b++:w==")"?b--:w=="["?e++:w=="]"?e--:w==","&&b==0&&e==0&&(d.push(m.slice(l,v)),l=v+1);d.push(m.slice(l));return d};a.Color=f})(descartesJS);
(a=>{class k{constructor(g){this.parent=g;this.container=a.newHTML("div",{class:"DescartesKeyboardContainer"});this.display=this.container.appendChild(a.newHTML("textarea",{class:"DescartesKeyboardDisplay",spellcheck:"false",inputmode:"none"}));this.keyContainer=this.container.appendChild(a.newHTML("div",{style:"position:absolute;padding-bottom:5px",class:"DescartesKeysContainer"}));this.additionalKeys=this.container.appendChild(a.newHTML("div",{style:"position:absolute;padding:0 5px 5px 0;display:none",
class:"DescartesKeysContainer"}));this.newLine=this.container.appendChild(a.newHTML("div",{style:`position:absolute;background-color:white;margin:0;font-family:${a.sansserif_font};font-size:17px;font-weight:normal;line-height:38px`,class:"new_line_btn"}));this.newLine.textContent="\\n";this.newLine.addEventListener("pointerup",()=>{this.insert("\n")});this.display.addEventListener("keydown",l=>{this.key_pressed=!0;if(l.keyCode==27)this.close();else if(l.keyCode==13)this.onEnter()});this.key_pressed=
this.delete_pressed=!1;let d,b;this.keyContainer.addEventListener("pointerdown",l=>{if(/^(?:k_op|k_dot|k_a|k_e|k_i|k_o|k_u)$/.test(l.target.id)){l.target.onpointerleave=function(){clearTimeout(d)};let w=l.target.textContent.trim().toLowerCase();d=setTimeout(()=>{this.key_pressed=!0;this.showAdditionalKeys(w)},600)}else l.target.id=="k_del"&&(l.target.onpointerleave=function(){clearTimeout(b)},b=setInterval(()=>{this.delete_pressed=!0;this.delete()},200))});this.keyContainer.addEventListener("pointerup",
l=>{if(l.target!=this.keyContainer&&l.target!=this.container)if(a.preventDefault(l),l.target.id=="k_left")this.display.selectionStart=this.display.selectionEnd=Math.max(0,this.display.selectionStart-1);else if(l.target.id=="k_right")this.display.selectionStart=this.display.selectionEnd=Math.min(this.display.value.length,this.display.selectionStart+1);else if(l.target.id=="k_del")this.delete_pressed||this.delete(),clearTimeout(b),this.delete_pressed=!1;else if(l.target.id=="k_\u221a")this.insert("\u221a(");
else if(l.target.id=="k_space")this.insert(" ");else if(l.target.id=="k_esc")this.close();else if(l.target.id=="k_shift"){l=this.keyContainer.querySelectorAll("div");let w=this.additionalKeys.querySelectorAll("div");this.shift=!this.shift;for(const q of l)q.textContent.trim().length==1&&(q.textContent=q.textContent[this.shift?"toUpperCase":"toLowerCase"]()),q.id=="k_dot"&&(q.textContent=this.shift?",":".");for(const q of w)q.textContent=q.textContent[this.shift?"toUpperCase":"toLowerCase"]()}else if(l.target.id==
"k_num_layout")this["setLayout_"+this.layout_mode.replace("alfa","num")]();else if(l.target.id=="k_alfa_layout")this["setLayout_"+this.layout_mode.replace("num","alfa")]();else if(l.target.id=="k_clear")this.display.value="";else if(/^(?:k_op|k_dot|k_a|k_e|k_i|k_o|k_u)$/.test(l.target.id))clearTimeout(d),this.key_pressed||(this.insert(l.target.textContent.trim()),this.additionalKeys.style.display="none"),this.key_pressed=!1;else if(l.target.id=="k_return")this.onEnter();else this.insert(l.target.textContent.trim()),
this.additionalKeys.style.display="none";this.display.focus()});this.keyContainer.addEventListener("mouseup",l=>{a.preventDefault(l)});let e=!1;this.additionalKeys.addEventListener("pointerdown",()=>{e=!0});this.additionalKeys.addEventListener("pointerup",l=>{e&&(l.target!=this.keyContainer&&l.target!=this.container&&(a.preventDefault(l),this.insert(l.target.textContent.trim())),this.key_pressed=!1,this.additionalKeys.style.display="none");e=!1;this.display.focus()})}insert(g){this.display.setRangeText(g,
this.display.selectionStart,this.display.selectionEnd,"end");this.display.focus()}delete(){this.display.selectionStart==this.display.selectionEnd&&(this.display.selectionStart=Math.max(0,this.display.selectionStart-1));this.display.setRangeText("")}addKey(g,d,b){return`<div ${d?`id='${d}'`:""} ${b?`style='${b}'`:""}>${g}</div>`}addKeys(g){let d="";for(let b of g)d=typeof b=="object"?d+this.addKey(b.val,b.id,b.style):d+this.addKey(b);return d}showAdditionalKeys(g){let d=[];g=="."?d=",;:-_\u00bf?\u00a1!()".split(""):
g=="+"?d=["-","\u00d7","\u00f7","^"]:g=="a"?d=["\u00e1","\u00e0","\u00e4","\u00e2"]:g=="e"?d=["\u00e9","\u00e8","\u00eb","\u00ea"]:g=="i"?d=["\u00ed","\u00ec","\u00ef","\u00ee"]:g=="o"?d=["\u00f3","\u00f2","\u00f6","\u00f4"]:g=="u"&&(d=["\u00fa","\u00f9","\u00fc","\u00fb"]);this.additionalKeys.innerHTML=this.addKeys(d);this.shift&&(this.additionalKeys.innerHTML=this.additionalKeys.innerHTML.toUpperCase());this.additionalKeys.style.display="flex";this.additionalKeys.style.left=this.keyContainer.style.left;
this.additionalKeys.style.top=parseFloat(this.keyContainer.style.top)-50+"px"}setLayout_14x1(){this.keyContainer.innerHTML=this.addKeys([1,2,3,4,5,6,7,8,9,0,{val:this.parent.decimal_symbol},"-",{val:"\u232b",id:"k_del"},{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="635px"}setLayout_7x2(){this.keyContainer.innerHTML=this.addKeys([1,2,3,4,5,{val:this.parent.decimal_symbol},{val:"\u232b",id:"k_del"},6,7,8,9,0,"-",{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="320px"}setLayout_10x2(){this.keyContainer.innerHTML=
this.addKeys(["(",1,2,3,4,5,"\u00b2","/","\u00d7",{val:"\u232b",id:"k_del"},")",6,7,8,9,0,{val:this.parent.decimal_symbol},"-","+",{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="455px"}setLayout_4x4(){this.keyContainer.innerHTML=this.addKeys([7,8,9,{val:"\u232b",id:"k_del"},4,5,6,"+",1,2,3,"-",{val:0,style:"width:85px;"},{val:this.parent.decimal_symbol},{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="185px"}setLayout_5x4(){this.keyContainer.innerHTML=this.addKeys([7,8,
9,"\u00b2",{val:"\u232b",id:"k_del"},4,5,6,"/","\u00d7",1,2,3,"\u2212","+",{val:0,style:"width:85px;"},".",{val:"\u21b5",id:"k_return",style:"margin-left:50px;"}]);this.keyContainer.style.width="230px"}setLayout_11x3(){this.keyContainer.innerHTML=this.addKeys(["q","w",{val:"e",id:"k_e"},"r","t","y",{val:"u",id:"k_u"},{val:"i",id:"k_i"},{val:"o",id:"k_o"},"p",{val:"\u232b",id:"k_del"},{val:"a",id:"k_a"},"s","d","f","g","h","j","k","l","\u00f1",{val:".",id:"k_dot"},{val:"\u21c5",id:"k_shift"},"z","x",
"c","v","b","n","m",{val:"",id:"k_space",style:"width:85px;"},{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="500px";this.shift=!1}setLayout_11x4(){this.keyContainer.innerHTML=this.addKeys([1,2,3,4,5,6,7,8,9,0,{val:"\u232b",id:"k_del"},"q","w",{val:"e",id:"k_e"},"r","t","y",{val:"u",id:"k_u"},{val:"i",id:"k_i"},{val:"o",id:"k_o"},"p",{val:"+",id:"k_op"},{val:"a",id:"k_a"},"s","d","f","g","h","j","k","l","\u00f1",{val:".",id:"k_dot"},{val:"\u21c5",id:"k_shift"},"z","x","c","v","b","n",
"m",{val:"",id:"k_space",style:"width:85px;"},{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="500px"}setLayout_10x4_alfa(){this.keyContainer.innerHTML=this.addKeys(["q","w",{val:"e",id:"k_e"},"r","t","y",{val:"u",id:"k_u"},{val:"i",id:"k_i"},{val:"o",id:"k_o"},"p",{val:"a",id:"k_a"},"s","d","f","g","h","j","k","l","\u00f1",{val:"\u21c5",id:"k_shift",style:"width:62.5px;"},"z","x","c","v","b","n","m",{val:"\u232b",id:"k_del",style:"width:62.5px;"},{val:"123",id:"k_num_layout",style:"width:85px;"},
{val:"",id:"k_space",style:"width:220px;transform:none !important;"},{val:"/",id:"k_slash"},{val:".",id:"k_dot"},{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="455px"}setLayout_10x4_num(){this.keyContainer.innerHTML=this.addKeys(["1","2","3","4","5","6","7","8","9","0","@",'"',"$","_","-","+","(",")","/","*","&","|","\u00ba",":",";","\u00a1","!","\u00bf","?",{val:"\u232b",id:"k_del"},{val:"ABC",id:"k_alfa_layout",style:"width:85px;"},{val:"",id:"k_space",style:"width:220px;transform:none !important;"},
{val:",",id:"k_slash"},{val:".",id:"k_dot"},{val:"\u21b5",id:"k_return"}]);this.keyContainer.style.width="455px"}showCustomKB(g){var d=g.querySelectorAll("div");g=parseInt(g.getAttribute("cols")||d.length);let b=[];var e;for(let l of d){d={val:l.textContent};if(e=l.getAttribute("id"))d.id=e;if(e=l.getAttribute("size"))d.style=`width:${40*parseInt(e)+5*(parseInt(e)-1)}px;transform:none !important`;b.push(d)}this.keyContainer.innerHTML=this.addKeys(b);this.keyContainer.style.width=5+g*45+"px"}setLayout(g){this.layout_mode=
g;let d=document.getElementById("kb_"+g);d?this.showCustomKB(d):(g=this["setLayout_"+g],typeof g=="function"?g.call(this):this.setLayout_14x1())}show(g,d,b,e,l,w,q){this.ctr=g;this.var_id=l;this.onlyText=q;this.container.parentNode||this.parent.container.appendChild(this.container);this.container.style.display="block";this.setDisplay(w);this.setLayout(d);this.keyContainer.style.left=b+"px";this.keyContainer.style.top=e+"px";this.additionalKeys.style.display="none"}close(){this.container.style.display=
"none";this.parent.deactivateControls();this.parent.update()}setDisplay(g){let {x:d,y:b,w:e,h:l,fs:w}=g;if(g.type!="custom"){let q=this.container.getBoundingClientRect(),n=g.getBoundingClientRect();d=(n.left-q.left)/a.cssScale;b=(n.top-q.top)/a.cssScale;e=n.width/a.cssScale;l=n.height/a.cssScale;w=g.style.fontSize}g.tagName.toLowerCase()=="textarea"?(this.display.setAttribute("style",`left:${d}px;top:${b}px;width:${e}px;height:${l}px;font-size:${w};line-height:1.2em;font:${g.style.font};padding:5px`),
this.newLine.style.left=d+e-42+"px",this.newLine.style.top=b+l-42+"px",this.newLine.style.display="block"):(this.display.setAttribute("style",`left:${d}px;top:${b}px;width:${e}px;height:${l}px;font-size:${w};line-height:${l}px;white-space:nowrap`),this.newLine.style.display="none");this.display.value=g.value||"";this.display.focus();this.display.selectionStart=this.display.selectionEnd=this.display.value.length}onEnter(){let g=this.display.value;if(!this.onlyText){var d=this.parent.evaluator.parser.parse(g.replace(/\u221a/g,
"sqrt"));try{d&&(g=this.parent.evaluator.eval(d))}catch(b){g=0}}if(this.ctr)this.ctr.changeValue(g,!0);else if(this.var_id=(""+this.var_id).trim(),d=this.var_id.indexOf("["),d==-1)this.parent.evaluator.setVariable(this.var_id,g);else{let b=this.var_id.indexOf(","),e=this.var_id.slice(0,d);b==-1?this.parent.evaluator.setVector(e,parseInt(this.var_id.slice(d+1)),g):this.parent.evaluator.setMatrix(e,parseInt(this.var_id.slice(d+1)),parseInt(this.var_id.slice(b+1)),g)}this.close()}}a.Keyboard=k})(descartesJS);
(a=>{let k=document.head;var g=a.newHTML("meta",{name:"viewport",content:"width=device-width,initial-scale=1.0,user-scalable=yes"});k.querySelector("meta[name=viewport]")||k.appendChild(g);k.appendChild(a.newHTML("meta",{name:"mobile-web-app-capable",content:"yes"}));k.appendChild(a.newHTML("meta",{name:"apple-mobile-web-app-capable",content:"yes"}));k.appendChild(a.newHTML("meta",{name:"apple-mobile-web-app-status-bar-style",content:"black"}));(g=document.getElementById("StyleDescartesApps2"))&&
g.remove();g=a.newHTML("style",{rel:"stylesheet",type:"text/css",id:"StyleDescartesApps2"});k.insertBefore(g,k.firstChild);g.textContent="body{-webkit-font-smoothing:antialiased;touch-action:manipulation;}\n#descartesJS_north,#descartesJS_south,#descartesJS_east,#descartesJS_west{background:#c0c0c0;position:absolute;z-index:100}\n.PBL{position:absolute;background-color:#f2f2f2;border:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;color:#2daae4;border-radius:100vw}\n.PBL::-moz-progress-bar{background:#2daae4;border-radius:inherit}\n.PBL::-webkit-progress-bar{background:#f2f2f2;border-radius:100vw}\n.PBL::-webkit-progress-value{background:#2daae4;border-radius:inherit}\n.PBL::-ms-fill{background:#2daae4;border-radius:inherit}\n.DescartesAppContainer *,.DescartesAppContainer *:before,.DescartesAppContainer *:after{box-sizing:border-box;transform:translate3d(0,0,0)}\n.DescartesAppContainer{border:none;overflow:hidden;position:relative;top:0;left:0}\n.DescartesCatcher{position:absolute;background-color:transparent;cursor:pointer}\n.DescartesLoader{display:none;position:absolute;top:0;left:0;width:100%;height:100%;background-color:#fff;overflow:hidden;z-index:1000}\n.DescartesLoaderImage{position:absolute;top:0;left:0;width:100%;height:100%;background-repeat:no-repeat;background-position:center;overflow:hidden}\n.DescartesSpace2DCanvas,.DescartesSpace3DCanvas,.blocker{position:absolute;left:0;top:0;touch-action:none}\n.DescartesSpace2DContainer,.DescartesSpace3DContainer{position:absolute;overflow:hidden;line-height:0}\n.DescartesSpaceIframe{position:absolute;left:0;top:0;width:inherit;height:inherit}\n.DescartesSpaceIframeContainer{position:absolute;background-repeat:no-repeat;background-position:center}\n.DescartesCheckboxContainer input[type=checkbox],.DescartesCheckboxContainer input[type=radio]{display: none}\n.DescartesCheckboxContainer input[type=checkbox]+label::after{position:absolute;left:0px;content:'';padding:0;margin:0;width:100%;height:100%;background:#fff;border:1px solid gray}\n.DescartesCheckboxContainer input[type=checkbox]:checked+label::after{content:'';background:url("+
a.getSvgCheckbox()+") center center no-repeat;background-size:contain;background-color:#fff}\n.DescartesCheckboxContainer input[type=radio]+label::after{position:absolute;left:0px;content:'';padding:0;margin:0;width:100%;height:100%;background:#fff;border:1px solid gray;border-radius:50%}\n.DescartesCheckboxContainer input[type=radio]:checked+label::after{content:'';background:url("+a.getSvgRadio()+") center center no-repeat;background-size:contain;background-color:#fff}\n.DescartesCheckbox{position:absolute}\n.TextfieldCover{position:absolute;overflow:hidden;background-color:transparent;cursor:pointer}\ninput[type=text]{-webkit-appearance:none}\n.DescartesButton{position:absolute;cursor:pointer}\n.DescartesButtonContainer,.DescartesSpinnerContainer,.DescartesCheckboxContainer,.DescartesTextFieldContainer,.DescartesMenuContainer{position:absolute;overflow:hidden}\n.DescartesButtonContainer[grad]{background-image:url('"+
a.getSvgGradient()+"');background-size:auto 100%}\n.DescartesSpinnerContainer input,.DescartesCheckboxContainer,.DescartesTextFieldContainer input,.DescartesMenuContainer select{border-radius:0}\n.DescartesSpinnerField,.DescartesTextFieldField,.DescartesMenuField,.DescartesScrollbarField,.DescartesSliderField{font-family:"+a.sansserif_font+";padding:0 2px;border:solid #666 1px;position:absolute;outline:none}\n.DescartesSpinnerField:focus,.DescartesTextFieldField:focus,.DescartesMenuField:focus,.DescartesScrollbarField:focus,.DescartesSliderField:focus{border:2px solid #3f88fb}\ninput[type=text]:disabled,.DescartesMenuSelect:disabled{background-color:#e3e3e3;cursor:not-allowed;opacity:1}\n.DescartesSpinnerLabel,.DescartesCheckboxLabel,.DescartesMenuLabel,.DescartesScrollbarLabel,.DescartesSliderLabel,.DescartesTextFieldLabel{position:absolute;left:0;top:0;font-family:"+
a.sansserif_font+";font-weight:normal;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}\n.DescartesGraphicControl{cursor:pointer;background-color:transparent;touch-action:none;border-style:none;position:absolute}\n.DescartesTextAreaContainer{position:absolute;overflow:hidden;background:#F7F7F7;border:1px solid #666}\n.DescartesTextArea{position:absolute;padding:5px;left:2px;top:2px;background-color:white;text-align:left;border:none;outline:none;resize:none}\n.DescartesTextArea:focus{outline:3px solid #3f88fb}\n.DescartesMenuSelect{position:absolute;font-family:"+
a.sansserif_font+";padding-top:0;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;border:1px solid #7a8a99;background:#fff;padding:0 22px 0 5px;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;color:inherit}\n.DescartesMenuSelect option{background-color:white}\n.DescartesMenuSelect option:checked{font-weight:bold;background-color:rgba(0,0,100,0.1)}\n.DescartesMenuContainer:before{font-family:'DJS_symbol';font-size:28px;content:'\u02c5';position:absolute;right:var(--r);top:0;width:22px;height:100%;display:flex;justify-content:center;align-items:center;pointer-events:none;z-index:1;padding-bottom:6px}\n.DescartesMenuSelect::-ms-expand{display:none}\n.DescartesScrollbarContainer,.DescartesSliderContainer{touch-action:none;background:#eee;overflow:hidden;position:absolute}\n.DescartesSliderContainer{background:transparent;overflow:visible}\n.DescartesRange{position:absolute;margin:0;padding:0;-webkit-appearance:none;appearance:none;background:transparent;cursor:pointer}\n.DescartesRange[dir=V]{writing-mode:vertical-lr}\n.DescartesRange::-webkit-slider-runnable-track{background:var(--track_color);border-radius:var(--track_size)}\n.DescartesRange::-moz-range-track{background:var(--track_color);border-radius:var(--track_size)}\n.DescartesRange[dir=H]::-webkit-slider-runnable-track{height:var(--track_size)}\n.DescartesRange[dir=H]::-moz-range-track{height:var(--track_size)}\n.DescartesRange[dir=V]::-webkit-slider-runnable-track{width:var(--track_size)}\n.DescartesRange[dir=V]::-moz-range-track{width:var(--track_size)}\n.DescartesRange::-moz-range-thumb{border:none;border-radius:50%;background-color:var(--thumb_color);width:var(--thumb_size);height:var(--thumb_size)}\n.DescartesRange::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;border-radius:50%;background-color:var(--thumb_color);width:var(--thumb_size);height:var(--thumb_size)}\n.DescartesRange[dir=H]::-webkit-slider-thumb{margin-top:calc(var(--track_size) / 2 - var(--thumb_size) / 2)}\n.DescartesRange[dir=V]::-webkit-slider-thumb{margin-left:calc(var(--track_size) / 2 - var(--thumb_size) / 2)}\n.DescartesSliderContainer:has(.DescartesRange:active){z-index:10000 !important}\n.DescartesSliderContainer .range_output{background:#fff;border:1px solid #ccc;position:absolute;width:auto;height:25px;font-size:16px;font-family:"+
a.sansserif_font+";padding:5px;line-height:0.8;border-radius:4px;user-select:none;display:none}\n.DescartesRange:active + .range_output{display:block}\n.DJS_Up,.DJS_Down{cursor:pointer;position:absolute;border:1px outset #f0f8ff;background-color:#f0f8ff;background-size:cover;background-repeat:none;background-position:center}\n.DJS_Up:before,.DJS_Down:before{font-family:'DJS_symbol';font-size:calc(var(--w) * 1.1);text-align:center;line-height:65%;width:100%;height:100%;pointer-events:none}\n.DJS_Up[dir=V]:before,.DJS_Down[dir=V]:before{background-image:url('"+
a.getSvgGradient()+"');background-size:auto 200%}\n.DJS_Up[dir=V]:before{background-position:top center;content:'\u25b2';color:#24c}\n.DJS_Down[dir=V]:before{background-position:bottom center;content:'\u25bc';color:#d00018}\n.DJS_Up[dir=H]:before,.DJS_Down[dir=H]:before{background-size:200% auto}\n.DJS_Up[dir=H]:before{background-image:url('"+a.getSvgGradient(90)+"');background-position:right center;content:'\u25b6';left:0;color:#24c}\n.DJS_Down[dir=H]:before{background-image:url('"+a.getSvgGradient(-90)+
"');background-position:left center;content:'\u25c0';left:0;color:#d00018}\n.DJS_Up[push=true],.DJS_Down[push=true]{border:2px inset #f0f8ff;background-position:calc(50% + 1px) calc(50% + 1px)}\n.DJS_Up[active=false]::after,.DJS_Down[active=false]::after{cursor:not-allowed;content:'';position:absolute;left:0;top:0;width:100%;height:100%;background:rgba(255,255,255,0.3)}\n.DescartesKeyboardContainer{position:absolute;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,0.1);z-index:1000}\n.DescartesKeysContainer{display:flex;flex-direction:row;flex-wrap:wrap;background-color:#c0c0c0;border-radius:4px;border:1px solid rgba(0,0,0,0.3);box-shadow:0 0 8px 0 rgba(0,0,0,0.75);box-sizing: content-box}\n.DescartesKeysContainer > div, .new_line_btn{margin:5px 0 0 5px;display:inline-block;min-width:40px;min-height:40px;max-height:40px;line-height:35px;background-color:#ebeff3;font-family:"+
a.math_font+";font-size:18px;font-weight:bold;color:black;cursor:pointer;text-align:center;border-radius:4px;border:1px solid rgba(0,0,0,0.3);box-shadow:0 1px 2px 0 rgba(0,0,0,0.25);transform-origin:center;user-select:none}\n.DescartesKeysContainer > div:hover, .new_line_btn:hover{background-color:rgba(0,0,0,0.05);transform:scale(1.1)}\n.DescartesKeysContainer > div:active, .new_line_btn:active{transform:scale(0.95)}\n.DescartesKeyboardDisplay{font-family:"+a.sansserif_font+";padding:0 2px;text-align:left;background-color:white;position:absolute;overflow:hidden;resize:none;border:none;outline:solid #666 1px}\n.DescartesKeyboardDisplay:focus{outline:2px solid #3f88fb}.custom_keyboard{display:none}\n.DJS_Gradient{position:absolute;display:none}\n@media print{body{margin:0;padding:0}\n.DescartesAppContainer{transform:none !important;left:0 !important;top:0 !important}\ndiv:has(.DescartesAppContainer){overflow:unset !important;width:100% !important;height:100% !important;}}\n";
a.addSymbolFont(g.sheet);a.addFonts&&a.addFonts(g.sheet)})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t=String.fromCharCode;class c{constructor(f=0){this.key=""+f}getKey(f){k=[];for(let m=0;m<256;m++)k[m]=t(this.alfanum(Math.floor(Math.abs(7.5*(Math.sin(1*m-f)+Math.sin(1.4*m+f)+Math.sin(.6*m-f)+Math.sin(2.2*m+f))))));return k.join("")}encode(f){g=Math.floor(31*Math.random());this.key=this.getKey(g);d=[...f].map(m=>m.charCodeAt(0));e=[];for(let m=0,v=d.length;m<v;m++)q=(d[m]+128)*256+Math.round(Math.random()*255)+Math.round(Math.random()*255)*256*256,n=Math.floor((q<<
this.getShift(m))/256),e.push(this.alfanum(n%32)),e.push(this.alfanum(Math.floor(n/32)%32)),e.push(this.alfanum(Math.floor(n/1024)%32));return t(this.alfanum(g))+e.map(m=>t(m)).join("")}decode(f){if(!f)return"";g=this.numalfa(f.charCodeAt(0));this.key=this.getKey(g);l=[...f.slice(1)].map(m=>m.charCodeAt(0));w=[];for(let m=0,v=l.length/3;m<v;m++)n=this.numalfa(l[3*m])+this.numalfa(l[3*m+1])*32+this.numalfa(l[3*m+2])*1024,q=Math.floor(n*256>>this.getShift(m)),b=Math.floor(q/256)%256-128,b<0&&(b+=256),
w.push(b);return t(...w)}alfanum(f){return(f<10?48:87)+Math.floor(f)}numalfa(f){return f-(f<58?48:87)}getShift(f){p=this.numalfa(this.key.charCodeAt(f%this.key.length));r=Math.floor(p/2%8);return r===0?4:r}}a.Krypto=c})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t,c,f,m,v,h,u;class x{constructor(z=0,G=0){this.x=z;this.y=G}set(z=0,G=0){this.x=z;this.y=G;return this}copy(){return new x(this.x,this.y)}ix(){return Math.round(Math.max(Math.min(this.x,32E3),-32E3))}iy(){return Math.round(Math.max(Math.min(this.y,32E3),-32E3))}equals(z){return this.x==z.x&&this.y==z.y}norm2(){return this.x*this.x+this.y*this.y}norm(){return Math.sqrt(this.norm2())}distance(z){g=this.copy();g.sub(z);return g.norm()}dot(z){return this.x*z.x+this.y*z.y}det(z){return this.x*
z.y-this.y*z.x}mul(z){this.x*=z;this.y*=z}div(z){this.x/=z;this.y/=z}add(z){this.x+=z.x;this.y+=z.y}sub(z){this.x-=z.x;this.y-=z.y}normalize(){k=this.norm();k!=0&&this.div(k)}rotR90(){k=this.x;this.x=this.y;this.y=-k}rotL90(){k=this.x;this.x=-this.y;this.y=k}rot(z){d=this.copy();l=Math.cos(z);w=Math.sin(z);this.x=d.x*l-d.y*w;this.y=d.x*w+d.y*l}rot2(z){this.rot(z*Math.PI/180)}intersection(z,G,A,I){q=G.x-z.x;n=A.x-I.x;p=A.x-z.x;r=G.y-z.y;t=A.y-I.y;c=A.y-z.y;u=q*t-n*r;return Math.abs(u)>1E-6?(b=(p*t-
c*n)/u,e=(-p*r+c*q)/u,0<=b&&b<=1&&0<=e&&e<=1?new x(z.x+q*b,z.y+r*b):null):(G.x-A.x)*c!=(G.y-A.y)*p?null:z.x!=G.x?(f=Math.min(z.x,G.x),m=Math.max(z.x,G.x),f<=A.x&&A.x<=m?A:f<=I.x&&I.x<=m?I:null):A.x!=I.x?(v=Math.min(A.x,I.x),h=Math.max(A.x,I.x),v<=z.x&&z.x<=h?z:v<=G.x&&G.x<=h?G:null):z.y!=G.y?(f=Math.min(z.y,G.y),m=Math.max(z.y,G.y),f<=A.y&&A.y<=m?A:f<=I.y&&I.y<=m?I:null):A.y!=I.y?(v=Math.min(A.y,I.y),h=Math.max(A.y,I.y),v<=z.y&&z.y<=h?z:v<=G.y&&G.y<=h?G:null):z.x==A.x&&z.y==A.y?z:null}}a.R2=x})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n;class p{constructor(r,t){this.evaluator=r;this.constraint=t;/==|<|>|<=|>=/.test(this.constraint.value)&&(/</.test(this.constraint.value)?this.sign="<":/>/.test(this.constraint.value)?this.sign=">":this.sign="=",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0]);l=new a.R2(0,0);e=new a.R2(0,0);n=new a.R2(0,0)}getUnitNormal(){this.normal.normalize();return n.set(this.normal.x,this.normal.y)}gradient(r){k=this.evaluator;l.x=l.y=0;w=k.getVariable("x");
q=k.getVariable("y");k.setVariable("x",r.x);k.setVariable("y",r.y);this.f0=k.eval(this.constraint);k.setVariable("x",k.getVariable("x")+1E-6);g=k.eval(this.constraint);l.x=(g-this.f0)/1E-6;l.x=isNaN(l.x)?Infinity:l.x;k.setVariable("x",k.getVariable("x")-1E-6);k.setVariable("y",k.getVariable("y")+1E-6);g=k.eval(this.constraint);l.y=(g-this.f0)/1E-6;l.y=isNaN(l.y)?Infinity:l.y;k.setVariable("x",w);k.setVariable("y",q);return l}findZero(r,t,c){k=this.evaluator;e.x=r.x;e.y=r.y;w=k.getVariable("x");q=
k.getVariable("y");k.setVariable("x",r.x);k.setVariable("y",r.y);this.f0=k.eval(this.constraint);if(this.sign=="<"&&this.f0<=0||this.sign==">"&&this.f0>=0)return e;k.setVariable("x",w);k.setVariable("y",q);for(let f=0;f<16;f++)if(d=e.x,b=e.y,this.normal=this.gradient(e),this.normal.norm2()!=0&&this.normal.mul(-this.f0/this.normal.norm2()),e.x=d+this.normal.x,e.y=b+this.normal.y,this.normal.norm()<t)return this.normal.x==0&&this.normal.y==0&&(this.normal.x=e.x-r.x,this.normal.y=e.y-r.y),e;return c?
e:null}}a.R2Newton=p})(descartesJS);(a=>{class k{constructor(g,d){this.x=g;this.y=d}vLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}dotProduct(g){return this.x*g.x+this.y*g.y}angleBetweenVectors(g){return Math.acos(this.dotProduct(g)/(this.vLength()*g.vLength()))}}k.AXIS_X=new k(1,0);k.AXIS_Y=new k(0,1);a.Vector2D=k})(descartesJS);
(a=>{class k{constructor(g,d){const b=this;b.parent=g;let e=g.evaluator;g=e.parser;b.delay=g.parse(d.delay?d.delay:"60");b.loop=d.loop?d.loop:!1;b.auto=d.auto==void 0?!0:d.auto;b.controls=d.controls;a.parseExpr(b,d,g);b.animExec=function(){for(let l of b.doExpr)e.eval(l);b.parent.update();b.playing&&(e.eval(b.whileExpr)>0||b.loop)?b.timer=a.setTimeout(b.animExec,e.eval(b.delay)):(b.stop(),b.pause=!1,b.parent.update())};b.playing=!1;b.auto&&b.play()}play(){this.playing?(this.pause=!0,this.stop()):
(this.pause||this.reinit(),this.playing=!0,this.pause=!1,this.timer=a.setTimeout(this.animExec,Math.max(10,this.parent.evaluator.eval(this.delay))))}stop(){this.playing=!1;a.clearTimeout(this.timer)}reinit(){for(let g of this.init)this.parent.evaluator.eval(g)}}a.Animation=k})(descartesJS);(a=>{class k{constructor(g,d=""){this.parent=g;this.parameter=d.replace(/\\n/g,"\n").replace(/&squot;/g,"'")}execute(){alert(this.parameter)}}a.Message=k})(descartesJS);
(a=>{class k{constructor(g,d=""){this.parent=g;d=a.splitSeparator((d||"").replace(/&squot;/g,"'"));this.inst=d.map(b=>g.evaluator.parser.parse(b,!0)).filter(b=>b)}execute(){for(let g of this.inst)this.parent.evaluator.eval(g)}}a.Calculate=k})(descartesJS);
(a=>{class k{constructor(d,b=""){this.parent=d;this.param=b.trim();this.target="_blank"}execute(d=""){let b=this.param;var e=b.match(/^(.*)\s*target=(.*)/);e&&(b=e[1].trim(),this.target=e[2].trim());b.startsWith("[")&&b.endsWith("]")&&(b=this.parent.evaluator.eval(this.parent.evaluator.parser.parse(b.slice(1,-1))));if(b.startsWith("javascript:"))try{(new Function(b.slice(11)))()}catch(l){}else/^(http|www)/.test(b)||(e=window.__dirname||window.location.href,b=e.slice(0,e.lastIndexOf("/")+1)+b),b.startsWith("www.")&&
(b="https://"+b),window.open(b,this.target,d)}}class g extends k{constructor(d,b=""){super(d,b)}execute(){super.execute(`width=${this.parent.width},height=${this.parent.height},left=${(window.screen.width-this.parent.width)/2},top=${(window.screen.height-this.parent.height)/2},location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0`)}}a.OpenURL=k;a.OpenScene=g})(descartesJS);
(a=>{class k{constructor(g){this.parent=g}execute(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%;height:100%;'>"+this.parent.applet.outerHTML.replace(/applet>/g,"ajs>")+"</xmp>")}}a.Config=k})(descartesJS);(a=>{class k{constructor(g){this.parent=g}execute(){this.parent.init()}}a.Init=k})(descartesJS);(a=>{class k{constructor(g){this.parent=g}execute(){this.parent.clear()}}a.Clear=k})(descartesJS);
(a=>{class k{constructor(g){this.parent=g}execute(){this.parent.play()}}a.Animate=k})(descartesJS);(a=>{class k{constructor(g){this.parent=g}execute(){this.parent.reinitAnimation()}}a.InitAnimation=k})(descartesJS);
(a=>{class k{constructor(g,d=""){this.parent=g;(g=d.match(/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi))?this.filename=this.parent.evaluator.parser.parse(`'${g[0]}'`):(/^\[.*\]$/.test(d)&&(d=d.slice(1,-1)),this.filename=this.parent.evaluator.parser.parse(d))}execute(){const g=this.parent.getAudio(this.parent.evaluator.eval(this.filename));g.paused?g.play():(g.pause(),g.currentTime=0)}}a.PlayAudio=k})(descartesJS);
(a=>{let k,g;class d{constructor(b,e){this.parent=b;this.evaluator=b.evaluator;this.id=this.expresion=this.init=this.privateVars=this.doExpr=this.whileExpr="";this.evaluate="onlyOnce";Object.assign(this,e)}firstRun(){}update(){}}a.splitInstructions=function(b,e){e=e?a.splitSeparator(e):[""];k=[];for(let l=0,w=e.length;l<w;l++)a.DEBUG.lineCount=l,(g=b.parse(e[l],!0))&&k.push(g);return k};a.parseExpr=function(b,e,l){a.DEBUG.pName="inicio";b.init=a.splitInstructions(l,e.init);a.DEBUG.pName="local";b.privateVars=
a.getPrivateVariables(l,e.local);a.DEBUG.pName="hacer";b.doExpr=a.splitInstructions(l,e.doExpr);a.DEBUG.pName="mientras";b.whileExpr=l.parse(e.whileExpr)};a.getPrivateVariables=function(b,e){k=[];e=e?e.split(/;|,/):[""];for(let l of e)(g=b.parse(l,!0))&&k.push(g);for(let l=0,w=k.length;l<w;l++)k[l]=k[l].type=="assign"?k[l].childs[0].value:k[l].type=="identifier"?k[l].value:"";return k};a.Auxiliary=d})(descartesJS);
(a=>{class k extends a.Auxiliary{constructor(g,d){super(g,d);d=this.evaluator;this.expresionString=this.expresion;(this.expresion=d.parser.parse(this.expresionString))&&d.setVariable(this.id,this.expresion);this.editable&&(this.registerTextField(),g.editableRegionVisible=!0)}registerTextField(){const g=this;let d=g.evaluator,b=a.newHTML("div"),e=a.newHTML("label");e.appendChild(document.createTextNode(`___${g.id}=___`));let l=a.newHTML("input");l.value=g.expresionString;l.disabled=!g.editable;b.appendChild(e);
b.appendChild(l);l.onkeydown=function(w){w.keyCode==13&&(g.expresion=parser.parse(this.value),d.setVariable(g.id,g.expresion),g.parent.update())};g.parent.editableRegion.textFields.push({container:b,type:"div"})}}a.Variable=k})(descartesJS);(a=>{class k extends a.Auxiliary{constructor(g,d){super(g,d);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()}update(){this.evaluator.setVariable(this.id,this.evaluator.eval(this.expresion))}}a.Constant=k})(descartesJS);
(a=>{let k,g,d,b;class e extends a.Auxiliary{constructor(l,w){super(l,w);g=l.evaluator.parser;this.size=this.size||g.parse("3");this.expresion=this.expresion.split(";");this.parseFile=g.parse(this.file);this.update()}update(){var l=this.expresion,w;k=this.evaluator;g=k.parser;this.oldFile=this.file;if(d=k.eval(this.parseFile))this.file=d;this.file&&(b=(w=document.getElementById(this.file))&&w.type=="descartes/vectorFile"?w.text:a.openFile(this.file),b!=null&&(b=b.replace(/\r/g,"").split("\n").filter(r=>
r.trim()!=="")),b==null||b.length==1&&b[0]==""?(b=[],this.size=g.parse("0")):(l=b,this.size=null),this.size==null&&(this.size=g.parse(""+l.length)));let q,n,p=this.parent.decimal_symbol==",";l=l.map((r,t)=>{(n=g.parse(r,!0))&&n.type!="assign"&&(q=NaN,p&&(q=parseFloat(r.replace(",","."))),n=g.parse(`${this.id}[${t}]=${isNaN(q)?r:q}`,!0));return n});w=Array(parseInt(Math.abs(k.eval(this.size)))).fill(0);w._size_=w.length;k.vectors[this.id]=w;k.setVariable(this.id+".long",w._size_);for(let r of l)k.eval(r)}}
a.Vector=e})(descartesJS);
(a=>{let k,g,d,b,e,l;const w=/'[^']*'|"[^"]*"|[^,']+/g,q=/'[^']*'|"[^"]*"|[^;']+/g;class n extends a.Auxiliary{constructor(p,r){super(p,r);k=p.evaluator;g=k.parser;this.rows=this.rows||g.parse("3");this.columns=this.columns||g.parse("3");if(this.file){l=(r=document.getElementById(this.file))&&r.type=="descartes/matrixFile"?r.text:a.openFile(this.file);let t,c=p.decimal_symbol==".";if(l!=null){b=0;d=null;l=l.replace(/\r/g,"").split("\n");this.expresion=[];for(let f of l)f&&(p=f.trim().match(c?w:q)||
[],d==null&&(d=p.length),p.forEach((m,v)=>{m=m.trim();t=c?parseFloat(m):parseFloat(m.replace(",","."));isNaN(t)&&!/^'.*'$/.test(m)?(t=m.replace(/^"(.*)"$/,"$1"),t=`'${t}'`):(c||(m=m.replace(",",".")),t=m);this.expresion.push(g.parse(`${this.id}[${b},${v}]:=${t}`))}),b++);this.rows=g.parse(""+d);this.columns=g.parse(""+b)}if(l==null||l.length==1&&l[0]=="")this.expresion=[],this.rows=this.columns=g.parse("0")}else this.expresion=a.splitInstructions(g,this.expresion),d=k.eval(this.rows),b=k.eval(this.columns);
e=[];e.type="matrix";for(let t=0,c=b;t<c;t++)e[t]=Array(d).fill(0);k.matrices[this.id]=e;this.update()}update(){k=this.evaluator;e=k.matrices[this.id];e.rows=k.eval(this.rows);e.cols=k.eval(this.columns);k.setVariable(this.id+".filas",e.rows);k.setVariable(this.id+".columnas",e.cols);for(let p of this.expresion)k.eval(p)}}a.Matrix=n})(descartesJS);
(a=>{class k extends a.Auxiliary{constructor(g,d){super(g,d);const b=this;let e=b.evaluator;g=e.parser;d=b.id.indexOf("(");b.name=b.id.slice(0,d);b.params=b.id.slice(d+1,b.id.indexOf(")"));b.domain=b.range?g.parse(b.range):g.parse("1");b.params=b.params==""?[]:b.params.split(",");b.numParams=b.params.length;b.algorithm||(b.init=b.doExpr=b.whileExpr="");a.parseExpr(b,b,g);b.expresion=g.parse(b.expresion);let l;b.functionExec=function(){var w=0;if(b.numParams<=arguments.length){let q=[];for(let p of b.privateVars)q.push(e.getVariable(p)),
e.setVariable(p,0);let n=[];b.params.forEach((p,r)=>{n.push(e.getVariable(p));e.setVariable(p,arguments[r])});for(let p of b.init)e.eval(p);l=e.getVariable("_NUM_MAX_ITE_ALG_")||1E5;do{for(let p of b.doExpr)e.eval(p);if(++w>l)return console.warn(`se ha excedido el l\u00edmite de ${l} repeticiones en la funci\u00f3n \u00ab${b.name}\u00bb`),0}while(e.eval(b.whileExpr)>0);w=e.eval(b.expresion);a.rangeOK=e.eval(b.domain);b.params.forEach((p,r)=>{e.setVariable(p,n[r])});b.privateVars.forEach((p,r)=>{e.setVariable(p,
q[r])});return w}return 0};e.setFunction(b.name,b.functionExec)}}a.Function=k})(descartesJS);
(a=>{let k,g;class d extends a.Auxiliary{constructor(b,e){super(b,e);a.parseExpr(this,this,this.evaluator.parser)}algorithmExec(){let b=0;g=this.evaluator;k=g.getVariable("_NUM_MAX_ITE_ALG_")||1E5;for(let e of this.init)g.eval(e);do{for(let e of this.doExpr)g.eval(e);if(++b>k)return console.warn(`se ha excedido el l\u00edmite de ${k} repeticiones en el algoritmo \u00ab${this.name}\u00bb`),0}while(g.eval(this.whileExpr)>0)}update(){this.algorithmExec();this.evaluate=="onlyOnce"&&(this.update=()=>{})}}
a.Algorithm=d})(descartesJS);
(a=>{class k extends a.Auxiliary{constructor(g,d){super(g,d);const b=this;g=b.evaluator;delete b.evaluate;b.condition=g.parser.parse(b.condition);b.lastEval=!1;b.action=b.parent.lessonParser.parseAction(b);b.execution=="onlyOnce"?b.eventExec=function(){!b.lastEval&&b.evaluator.eval(b.condition)>0&&(b.lastEval=!0,b.action.execute())}:b.execution=="alternate"?b.eventExec=function(){const e=b.evaluator.eval(b.condition)>0;e&&!b.lastEval?(b.action.execute(),b.lastEval=!0):!e&&b.lastEval&&(b.lastEval=
!1)}:b.execution=="always"&&(b.eventExec=function(){b.evaluator.eval(b.condition)>0&&b.action.execute()})}update(){this.eventExec()}}a.Event=k})(descartesJS);(a=>{class k extends a.Auxiliary{constructor(g,d){super(g,d);d=d.file;var b=null;d&&(b=(b=document.getElementById(d))&&b.type=="descartes/library"?b.text:a.openFile(d));if(b){b=a.convertHTMLEntities(b).replace(/\r/g,"").split("\n");for(let e of b)e.trim()!=""&&g.lessonParser.parseAuxiliar(e)}}}a.Library=k})(descartesJS);
(a=>{let k,g,d,b,e;class l{constructor(w,q){this.parent=w;this.evaluator=w.evaluator;let n=this.evaluator.parser;this.spaceID=this.type=this.trace=this.family=this.text="";this.background=this.visible=this.editable=!1;this.drawif=n.parse("1");this.abs_coord=q&&q.type&&q.type.toLowerCase()=="text";this.color=new a.Color("20303a");this.expresion=n.parse("(0,0)");this.family_interval=n.parse("[0,1]");this.family_steps=n.parse("8");this.font="SansSerif,PLAIN,"+(this.parent.version>=5?"18":"12");this.fixed=
!0;this.decimals=n.parse("2");Object.assign(this,q);this.space=this.getSpace();this.canvas=this.background?this.space.backCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backCtx);this.font_str=this.font;this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/([\d\.]+)px/))?parseFloat(this.fontSize[1]):10;this.font_style=a.getFontStyle(this.font_str.split(",")[1]);if(typeof this.bold=="boolean"||typeof this.italics=="boolean")this.font_style=
(this.italics?"Italic ":"")+(this.bold?"Bold ":"");this.font_family||(this.font_family=this.font_str.split(",")[0]);this.font_family=a.getFontName(this.font_family);typeof this.font_size=="undefined"&&(this.font_size=w.evaluator.parser.parse(""+this.fontSize))}getSpace(){for(const w of this.parent.spaces)if(w.id==this.spaceID)return w;return this.parent.spaces[0]}getFamilyValues(){k=this.evaluator;[this.fInf,this.fSup]=k.eval(this.family_interval)[0];this.fSteps=Math.round(k.eval(this.family_steps));
this.fSep=this.fSteps>0?(this.fSup-this.fInf)/this.fSteps:0}drawFamilyAux(w,q,n){k=this.evaluator;this.getFamilyValues();g=k.getVariable(this.family);if(this.fSteps>=0)for(let p=0,r=this.fSteps;p<=r;p++)k.setVariable(this.family,this.fInf+p*this.fSep),k.eval(this.drawif)>0&&(this.update(),this.drawAux(w,q,n));k.setVariable(this.family,g)}draw(w,q){this._helperDraw(w,q)}drawTrace(w,q){this._helperDraw(w,q,!0)}_helperDraw(w,q,n){d=n?this.traceCtx:this.ctx;this.family!=""?this.drawFamilyAux(d,w,q):this.evaluator.eval(this.drawif)>
0&&(this.update(),this.drawAux(d,w,q));d.setLineDash([])}rotate(w,q,n){b=Math.cos(n);e=Math.sin(n);return{x:w*b-q*e,y:w*e+q*b}}dashStyle(){d=this.ctx;d.lineCap="butt";switch(this.lineDash){case "dot":d.setLineDash([d.lineWidth,d.lineWidth]);break;case "dash":d.setLineDash([d.lineWidth*4,d.lineWidth*3]);break;case "dash_dot":d.setLineDash([d.lineWidth*4,d.lineWidth*2,d.lineWidth,d.lineWidth*2]);break;default:d.lineCap="round",d.setLineDash([])}}}a.Graphic=l})(descartesJS);
(a=>{function k(l,w,q=[]){for(let n of l)if(n.type=="identifier"&&!q.includes(n.value)&&!a.reservedIds.includes(n.value)||/^(R|G|B)$/.test(n.value))n.value=`${w}.${n.value}`;return l}function g(l,w,q,n){w=k(q.tokenize(w.replace(/&squot;/g,"'")),n);return(l.startsWith("\\expr")?"\\expr ":"\\decimals ")+q.flatTokens(w)}function d(l){let w=[],q=0,n=0,p=-1,r,t;for(;q<l.length;)r=l[q],t=l[q-1],t!="\\"||r!="["&&r!="]"?r=="["?(p==-1&&(w.push(`'${l.slice(n,q)}'`),n=q),p++):r=="]"&&p==0?(w.push(`[${l.slice(n,
q+1)}]`),n=q+1,p--):r=="]"&&p>=0&&p--:(w.push(`'${l.slice(n,q-1)}${r}'`),n=q+1),q++;w.push(`'${l.slice(n,q)}'`);return w}const b=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.webp)/gi;class e extends a.Graphic{constructor(l,w,q,n){super(l,w);this.hasExpresion=this.hasExpresion||!1;this.graphics=[];Object.assign(this,w);if(this.hasExpresion=this.expresion!==void 0){this.expresion[0]!="'"&&(this.expresion=`'${this.expresion}'`);this.expresion=this.evaluator.parser.parse(this.expresion);w=this.evaluator.eval(this.expresion);
if(w)var p=(p=document.getElementById(w))&&p.type=="descartes/macro"?p.text:a.openFile(w);if(p){w=a.convertHTMLEntities(p).replace(/\r/g,"").split("\n");p=[];l=l.lessonParser;let v=new a.Tokenizer;for(var r of w)if(r.includes("=")){w=l.split(r);for(var t of w)if(t&&t.length>1&&["id","type"].includes(babel[t[0]])){p.push(w);break}}for(let h=0,u=p.length;h<u;h++){t=(r=p[h]||[],r[0])&&r[0][0]=="id";w=!1;for(let x=0,z=r.length;x<z;x++){var c=r[x][0];var f=r[x][1];var m=c.indexOf(".");m==-1||t?m=babel[c]:
(m=babel[c.slice(m+1)],r[x][0]=`${this.name}.${c}`);m=="type"&&babel[f]=="surface"&&(w=!0);if(q.includes("3D")){if((m=="font"||m=="font_family"||(m=="fill"||m=="color"||m=="backcolor"||m=="arrow")&&r[x][1].charAt(0)!="("||m=="file"&&r[x][1].match(b)||m!="id"&&babel[r[x][1]]!==void 0)&&m!="width"&&m!="height"&&m!="length")continue}else if((m=="font"||m=="font_family"||(m=="fill"||m=="color"||m=="border"||m=="arrow")&&r[x][1].charAt(0)!="("||m=="file"&&r[x][1].match(b)||m!="id"&&babel[r[x][1]]!==void 0)&&
m!="radius")continue;if(w&&m=="expresion"){f=r[x][1].split(" ");m="";for(let G=0,A=f.length;G<A;G++){let I=f[G].replace(/&squot;/g,"'").split(";");for(let S=0,F=I.length;S<F;S++)c=v.tokenize(I[S].replace(/\\n/g,";")),c=k(c,this.name,q.includes("3D")?["x","y","z","u","v"]:[]),I[S]=v.flatTokens(c);m+=I.join(";")+" "}r[x][1]=m}else{if(m=="text")if(f.includes("{\\rtf1"))f=f.replace(/\\expr\s*([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,(G,A)=>g(G,A,v,this.name)).replace(/\\decimals\s*([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,
(G,A)=>g(G,A,v,this.name));else{f=d(f);for(let G=0,A=f.length;G<A;G++)c=v.tokenize(f[G].replace(/&squot;/g,"'")),c=k(c,this.name),f[G]=v.flatTokens(c).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]"),f[G]=f[G].slice(1,-1);f=f.join("")}else{f=f.replace(/&squot;/g,"'").split(";");for(let G=0,A=f.length;G<A;G++)c=v.tokenize(f[G].replace(/\\n/g,";")),c=k(c,this.name,q.includes("3D")?["Euler"]:[]),f[G]=v.flatTokens(c);f=f.join(";")}r[x][1]=f}}}for(let h=0,u=p.length;h<u;h++)if(p[h][0]){r=
"";t=!1;for(let x=0,z=p[h].length;x<z;x++)!t&&babel[p[h][x][0]]=="type"&&n.includes(`-${babel[p[h][x][1]]}-`)&&(t=!0),r+=`${p[h][x][0]}='${p[h][x][1]}' `;p[h]=r+(t?` space='${this.spaceID}'`:"");t?this.graphics.push(l[q](p[h],this.abs_coord,this.background,this.inirot)):l.parseAuxiliar(p[h])}}}}}a.BaseMacro=e})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t,c,f,m,v,h,u,x,z,G,A,I,S,F,y,H,C,D,J,N,Z,ba,ca;class aa extends a.Graphic{constructor(L,P){super(L,P);this.width=this.width||L.evaluator.parser.parse("1");this.fillP=this.fillP||"";this.fillM=this.fillM||"";this.parseExpression();(this.visible=this.parent.version==2&&this.visible==void 0?!0:this.visible)&&this.registerTextField();t=new a.R2;c=new a.R2;f=new a.R2;m=new a.R2;h=new a.R2;this.cInd=0}parseExpression(){if(this.expresion.type=="compOperator"){let L=this.expresion.childs[0],
P=this.expresion.childs[1];L.type!="identifier"||L.value!="y"||P.contains("y")?P.type!="identifier"||P.value!="y"||L.contains("y")?L.type!="identifier"||L.value!="x"||P.contains("x")?P.type!="identifier"||P.value!="x"||L.contains("x")||(this.funExpr=P,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=P,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=L,this.of_y=!1,this.drawAux=this.drawAuxFun):(this.funExpr=P,this.of_y=!1,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,
this.expresion)}update(){}draw(){this.family!=""?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))}drawFamilyAux(L,P,U){d=this.evaluator;this.getFamilyValues();g=d.getVariable(this.family);if(this.fSteps>=0)for(let W=0,M=this.fSteps;W<=M;W++)d.setVariable(this.family,this.fInf+W*this.fSep),this.update(),this.drawAux(L,P,U);d.setVariable(this.family,g)}drawTrace(){super.drawTrace(this.fill,this.trace)}drawAux(L,P,U){if(!(this.evaluator.eval(this.drawif)<=
0)){this.cInd=0;d=this.evaluator;b=this.space;e=d.eval(this.width);L.strokeStyle=this.color.getColor();L.lineWidth=e;l=d.getVariable("x");w=d.getVariable("y");q=b.w+24;n=b.h+24;U=n/q;P=Math.round(Math.sqrt(64/U));U=Math.round(Math.sqrt(64*U));P=Math.max(2,P);U=Math.max(2,U);p=q/P;r=n/U;p<3&&(p=3);r<3&&(r=3);this.cInd==0?(k=[],this.cInd++):this.cInd=(this.cInd+1)%1E7;t.set(0,0);c.set(0,0);f.set(0,0);ba=.25;ca=8;this.abs_coord||(ba/=b.scale,ca/=b.scale);L.beginPath();for(H=parseInt(r/2);H<n;H+=r)for(y=
parseInt(p/2);y<q;y+=p){if(this.abs_coord){h.set(y,H);v=this.newt.findZero(h,ba);if(v==null)continue;d.setVariable("x",v.x);d.setVariable("y",v.y);m.set(v.x,v.y)}else{h.set(b.getRelativeX(y),b.getRelativeY(H));v=this.newt.findZero(h,ba);if(v==null)continue;d.setVariable("x",v.x);d.setVariable("y",v.y);m.set(b.getAbsoluteX(v.x),b.getAbsoluteY(v.y))}u=m.ix();x=m.iy();if(u>=-12&&u<q+24&&x>=-12&&x<n+24){if(k[u+12+(x+12)*b.w]==this.cInd)continue;k[u+12+(x+12)*b.w]=this.cInd}a.rangeOK&&(L.moveTo(u,x),L.lineTo(u,
x));t.x=v.x;t.y=v.y;c.x=v.x;c.y=v.y;z=this.newt.getUnitNormal();if(z.x!=0||z.y!=0)for(z.rotL90(),f.x=z.x,f.y=z.y,A=G=0,I=!1;A<2;)if(I&&(f.x=-z.x,f.y=-z.y,v.x=t.x,v.y=t.y,c.x=v.x,c.y=v.y,this.abs_coord?m.set(v.x,v.y):m.set(b.getAbsoluteX(v.x),b.getAbsoluteY(v.y)),u=m.ix(),x=m.iy(),I=!1,G=0),v.x+=ca*f.x,v.y+=ca*f.y,v=this.newt.findZero(v,ba),v!=null){d.setVariable("x",v.x);d.setVariable("y",v.y);f.x=v.x-c.x;f.y=v.y-c.y;f.normalize();if(f.x==0&&f.y==0)break;c.x=v.x;c.y=v.y;this.abs_coord?m.set(v.x,v.y):
m.set(b.getAbsoluteX(v.x),b.getAbsoluteY(v.y));S=parseInt(m.ix());F=parseInt(m.iy());if(S!=u||F!=x)if(C=u,D=x,u=S,x=F,u>=-12&&u<q+24&&x>=-12&&x<n+24){G=0;J=k[u+12+(x+12)*b.w];k[u+12+(x+12)*b.w]=this.cInd;for(P=1;P<8;P++)N=C+Math.round((u-C)*P/8),Z=D+Math.round((x-D)*P/8),0<=N&&N<q&&0<=Z&&Z<n&&(k[N+12+(Z+12)*b.w]=this.cInd);a.rangeOK&&(L.moveTo(C,D),L.lineTo(u,x));if(J==this.cInd)break}else I=!0,A++;else++G>4&&(I=!0,A++)}}L.stroke();d.setVariable("x",l);d.setVariable("y",w)}}X(L,P,U){U||(P=this.space.w/
2+this.space.Ox+this.space.scale*P);P<-L&&(P=-L);P>this.space.w+L&&(P=this.space.w+L);return P}Y(L,P,U){U||(P=this.space.h/2+this.space.Oy-this.space.scale*P);P<-L&&(P=-L);P>this.space.h+L&&(P=this.space.h+L);return P}XX(L,P,U){return Math.round(this.X(L,P,U))}YY(L,P,U){return Math.round(this.Y(L,P,U))}extrapolate(L,P,U,W,M,E){d=this.evaluator;let O=d.getVariable(P),Q=E/2,X=0,T,B,K,R,V,Y;for(;Math.abs(Q)>1E-15;){T=d.getVariable(P);B=d.getVariable(P)+Q;d.setVariable(P,B);K=!0;try{R=M,M=d.eval(this.funExpr),
d.setVariable(U,M),d.eval(L)>0?(V=new a.R2(Math.min(R,M),Math.max(R,M)),Y=0,Y=E>0?this.Singularity(Math.abs(Q),P,W,T,R,B,M,V):this.Singularity(Math.abs(Q),P,W,B,M,T,R,V),Y>0&&(K=!1)):K=!1}catch(fa){K=!1}K?X+=Q:d.setVariable(P,T);Q/=2}d.setVariable(P,O);return new a.R2(X/Math.abs(E),M)}extrapolateOnSingularity(L,P,U,W,M,E){d=this.evaluator;W=d.getVariable(P);let O=E/2,Q=0,X=M,T;for(;Math.abs(O)>1E-15;){d.setVariable(P,d.getVariable(P)+O);T=!0;if(d.eval(L)>0)try{X=d.eval(this.funExpr),d.setVariable(U,
X),d.eval(L)<=0&&(T=!1)}catch(B){T=!1}else T=!1;T?Q+=O:d.setVariable(P,d.getVariable(P)-O);O/=2}if(Q==0)for(O=E/2,Q=E,X=M;Math.abs(O)>1E-15;){d.setVariable(P,d.getVariable(P)-O);U=!0;if(d.eval(L)>0)try{X=d.eval(this.funExpr)}catch(B){U=!1}else U=!1;U?Q+=-O:d.setVariable(P,d.getVariable(P)+O);O/=2}d.setVariable(P,W);return new a.R2(Q/Math.abs(E),X)}Singularity(L,P,U,W,M,E,O,Q){d=this.evaluator;if(isNaN(O)||isNaN(M)||isNaN(Q.y)||isNaN(Q.x)||W>=E)return 2;let X=d.getVariable(P),T=0;try{if(Math.abs(E-
W)<1E-15||Math.abs(E-W)<1E-12&&Math.abs(O-M)>Math.abs(L))return d.setVariable(P,X),1;let K=(W+E)/2;d.setVariable(P,K);let R=NaN;try{R=d.eval(this.funExpr)}catch(V){return 2}if(isNaN(R))return 5;if(Math.abs(O-M)>L){d.setVariable(P,W-1E-12);var B=d.eval(this.funExpr);B=(M-B)/1E-12;d.setVariable(P,E+1E-12);let V=(d.eval(this.funExpr)-O)/1E-12;if((Math.abs(V)<10||Math.abs(B)<10)&&(V>=0&&B>=0||V<=0&&B<=0)&&4*Math.abs(V)<Math.abs((O-M)/(E-W)))return d.setVariable(P,X),2}if(isNaN(Q.x)||isNaN(Q.y)||isNaN(R))return 2;
if(!(Q.x<=R&&R<=Q.y)){d.setVariable(P,K);Q.x=Math.min(M,R);Q.y=Math.max(M,R);let V=this.Singularity(L/2,P,U,W,M,K,R,Q);d.setVariable(P,E);Q.x=Math.min(O,R);Q.y=Math.max(O,R);let Y=this.Singularity(L/2,P,U,K,R,E,O,Q);T=Math.max(V,Y)}}catch(K){T=1}d.setVariable(P,X);return T}drawAuxFun(L,P,U){d=this.evaluator;l=d.getVariable("x");w=d.getVariable("y");a.rangeOK=1;P="x";let W="y";this.of_y&&(P="y",W="x");let M=this.drawif,E=d.eval(this.width),O=!1;var Q=new a.R2(this.space.w/2+this.space.Ox,this.space.h/
2+this.space.Oy);let X=this.of_y?Q.ix():Q.iy(),T=0,B=0,K=0,R=0,V=1/this.space.scale;Q=V*(this.of_y?-this.space.h+Q.y:-Q.x);let Y=0;this.abs_coord&&(Q=0,V=1);let fa,ea,da,la,ma,ja,ka,ha,ia,na=this.of_y?this.space.h+2:this.space.w+2;for(;K<=na;){fa=!0;ea=0;d.setVariable(P,Q);try{da=d.eval(this.funExpr),isNaN(da)||(d.setVariable(W,da),d.eval(this.drawif)>0&&a.rangeOK?(O?(la=Math.min(Y,da),ma=Math.max(Y,da),ja=new a.R2(la,ma),ea=this.Singularity(V,P,0,Q-V,Y,Q,da,ja),ea==0?(Y<=da?(Y=ja.x,da=ja.y):(da=
ja.x,Y=ja.y),ka=parseInt(this.of_y?this.XX(E,Y,this.abs_coord):this.YY(E,Y,this.abs_coord)),T=this.abs_coord?Math.round(da):parseInt(this.of_y?this.XX(E,da,this.abs_coord):this.YY(E,da,this.abs_coord)),this.fillM&&T>X&&(L.lineWidth=1,L.strokeStyle=this.fillM.getColor(),L.beginPath(),this.of_y?(L.moveTo(X+1,this.space.h-K+.5),L.lineTo(T,this.space.h-K+.5)):(L.moveTo(K+.5,X+1),L.lineTo(K+.5,T)),L.stroke()),this.fillP&&T<X&&(L.lineWidth=1,L.strokeStyle=this.fillP.getColor(),L.beginPath(),this.of_y?(L.moveTo(X-
1,this.space.h-K+.5),L.lineTo(T,this.space.h-K+.5)):(L.moveTo(K+.5,X-1),L.lineTo(K+.5,T)),L.stroke()),L.lineWidth=E,L.strokeStyle=U.getColor(),L.beginPath(),this.of_y?(L.moveTo(ka+.5,this.space.h-R),L.lineTo(T+.5,this.space.h-K)):(L.moveTo(R+.5,ka),L.lineTo(K+.5,T)),L.stroke()):ea==1?(d.setVariable(P,Q-V),ha=this.extrapolate(M,P,W,0,Y,V),T=this.of_y?this.XX(E,ha.y,this.abs_coord):this.YY(E,ha.y,this.abs_coord),L.lineWidth=E,L.strokeStyle=U.getColor(),L.beginPath(),this.of_y?(L.moveTo(B+.5,this.space.h-
R),L.lineTo(T+.5,this.space.h-R+Math.round(ha.x))):(L.moveTo(R+.5,B),L.lineTo(R+Math.round(ha.x)+.5,T)),d.setVariable(P,Q),ia=this.extrapolate(M,P,W,0,da,-V),B=this.of_y?this.XX(E,ia.y,this.abs_coord):this.YY(E,ia.y,this.abs_coord),T=this.of_y?this.XX(E,da,this.abs_coord):this.YY(E,da,this.abs_coord),L.lineWidth=E,L.strokeStyle=U.getColor(),L.beginPath(),this.of_y?(L.moveTo(B+.5,this.space.h-K),L.lineTo(T+.5,this.space.h-K)):(L.moveTo(K+.5,B),L.lineTo(K+.5,T)),L.stroke()):ea==2&&(T=this.of_y?this.XX(E,
da,this.abs_coord):this.YY(E,da,this.abs_coord),L.lineWidth=E,L.strokeStyle=U.getColor(),L.beginPath(),this.of_y?(L.moveTo(B+.5,this.space.h-K),L.lineTo(T+.5,this.space.h-K)):(L.moveTo(K+.5,B),L.lineTo(K+.5,T)))):(ia=this.extrapolateOnSingularity(M,P,W,0,da,-V),B=this.of_y?this.XX(E,ia.y,this.abs_coord):this.YY(E,ia.y,this.abs_coord),T=this.of_y?this.XX(E,da,this.abs_coord):this.YY(E,da,this.abs_coord),L.lineWidth=E,L.strokeStyle=U.getColor(),L.beginPath(),this.of_y?(L.moveTo(B,this.space.h-(K+Math.round(ia.x))+
.5),L.lineTo(T,this.space.h-K+.5)):(L.moveTo(K+Math.round(ia.x),B),L.lineTo(K,T)),L.stroke()),Y=da):fa=!1)}catch(oa){fa=!1}O&&!fa&&(d.setVariable(P,Q-V),d.setVariable(W,Y),ha=this.extrapolate(M,P,W,0,Y,V),T=parseInt(this.of_y?this.XX(E,ha.y,this.abs_coord):this.YY(E,ha.y,this.abs_coord)),d.eval(this.drawif)>0&&a.rangeOK&&(L.lineWidth=E,L.strokeStyle=U.getColor(),L.beginPath(),this.of_y?(L.moveTo(B,this.space.h-(R+Math.round(ha.x))+.5),L.lineTo(T,this.space.h-(R+Math.round(ha.x))+.5)):(L.moveTo(R+
Math.round(ha.x)+.5,B),L.lineTo(R+Math.round(ha.x)+.5,T)),L.stroke()),d.setVariable(P,Q));O=fa;Q+=V;B=T;R=K++}d.setVariable("x",l);d.setVariable("y",w)}registerTextField(){const L=this;let P=a.newHTML("input");P.value=L.expresionString;P.disabled=!L.editable;P.onkeydown=function(U){U.keyCode==13&&(L.expresion=L.evaluator.parser.parse(this.value),L.parseExpression(),L.parent.update())};L.parent.editableRegion.textFields.push(P)}}a.Equation=aa})(descartesJS);
(a=>{let k,g,d,b,e,l,w;class q extends a.Graphic{constructor(n,p){super(n,p);this.parameter=this.parameter||"t";this.parameter_interval=this.parameter_interval||n.evaluator.parser.parse("[0,1]");this.parameter_steps=this.parameter_steps||n.evaluator.parser.parse("8");this.width=this.width||n.evaluator.parser.parse("1");this.fill=this.fill||"";(this.visible=this.parent.version==2&&this.visible==void 0?!0:this.visible)&&this.registerTextField()}update(){k=this.evaluator;[this.paraInf,this.paraSup]=
k.eval(this.parameter_interval)[0];this.pSteps=k.eval(this.parameter_steps);this.paraSep=this.pSteps>0?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0}draw(){super.draw(this.fill,this.color)}drawTrace(){super.drawTrace(this.fill,this.trace)}drawAux(n,p,r){k=this.evaluator;g=this.space;w=Math.round(k.eval(this.width));n.lineCap=n.lineJoin="round";n.strokeStyle=r.getColor();d=k.getVariable(this.parameter);n.beginPath();k.setVariable(this.parameter,this.paraInf);b=k.eval(this.expresion)[0];this.X=
Math.round(this.abs_coord?b[0]:g.getAbsoluteX(b[0]));this.Y=Math.round(this.abs_coord?b[1]:g.getAbsoluteY(b[1]));this.rotateExp&&(e=a.degToRad(k.eval(this.rotateExp)),l=this.rotate(b[0],b[1],e),this.X=Math.round(this.abs_coord?l.x:g.getAbsoluteX(l.x)),this.Y=Math.round(this.abs_coord?l.y:g.getAbsoluteY(l.y)));n.moveTo(this.X+.5,this.Y+.5);for(r=1;r<=this.pSteps;r++)k.setVariable(this.parameter,this.paraInf+r*this.paraSep),b=k.eval(this.expresion)[0],this.rotateExp&&(l=this.rotate(b[0],b[1],e),b[0]=
l.x,b[1]=l.y),this.X=Math.round(this.abs_coord?b[0]:g.getAbsoluteX(b[0])),this.Y=Math.round(this.abs_coord?b[1]:g.getAbsoluteY(b[1])),!isNaN(this.X)&&!isNaN(this.Y)&&this.X>-1E6&&this.X<1E6&&this.Y>-1E6&&this.Y<1E6&&n.lineTo(this.X+.5,this.Y+.5);this.fill&&(n.fillStyle=p.getColor(),n.fill("evenodd"));w>0&&(n.lineWidth=w,this.dashStyle(),n.stroke());n.setLineDash([]);k.setVariable(this.parameter,d)}registerTextField(){const n=this;let p=a.newHTML("input");p.value=n.expresionString;p.disabled=!n.editable;
p.onkeydown=function(r){r.keyCode==13&&(n.expresion=n.evaluator.parser.parse(this.value),n.parent.update())};n.parent.editableRegion.textFields.push(p)}}a.Curve=q})(descartesJS);
(a=>{let k=Math.PI*2,g,d,b,e,l,w,q;class n extends a.Graphic{constructor(p,r){super(p,r);this.size=this.size||p.evaluator.parser.parse("2");this.range=this.range||p.evaluator.parser.parse("[1, 100]");(this.visible=this.parent.version==2&&this.visible==void 0?!0:this.visible)&&this.registerTextField()}update(){g=this.evaluator;[this.X,this.Y]=g.eval(this.expresion)[0];this.rotateExp&&(b=this.rotate(this.X,this.Y,a.degToRad(g.eval(this.rotateExp))),this.X=b.x,this.Y=b.y);[this.rangeInf,this.rangeMax]=
g.eval(this.range)[0]}draw(){super.draw(this.color,this.color)}drawTrace(){super.drawTrace(this.trace,this.trace)}drawAux(p,r){g=this.evaluator;d=this.space;q=Math.ceil(g.eval(this.size)-.4);p.fillStyle=r.getColor();p.beginPath();this.rangeInf>this.rangeMax&&([this.rangeInf,this.rangeMax]=[this.rangeMax,this.rangeInf]);w=g.getVariable("n");for(let t=this.rangeInf,c=this.rangeMax;t<=c;t++)g.setVariable("n",t),[this.X,this.Y]=g.eval(this.expresion)[0],e=Math.round(this.abs_coord?this.X:d.getAbsoluteX(this.X)),
l=Math.round(this.abs_coord?this.Y:d.getAbsoluteY(this.Y)),q>0&&(p.beginPath(),p.arc(e,l,q,0,k),p.fill());p.fill();g.setVariable("n",w)}registerTextField(){const p=this;let r=a.newHTML("input");r.value=p.expresionString;r.disabled=!p.editable;r.onkeydown=function(t){t.keyCode==13&&(p.expresion=p.evaluator.parser.parse(this.value),p.parent.update())};p.parent.editableRegion.textFields.push(r)}}a.Sequence=n})(descartesJS);
(a=>{let k=Math.PI*2,g,d,b,e,l,w;class q extends a.Graphic{constructor(n,p){super(n,p);this.size=this.size||n.evaluator.parser.parse("2");this.text=new a.TextObject(this,this.text)}update(){g=this.evaluator;[this.X,this.Y]=g.eval(this.expresion)[0];this.rotateExp&&(b=this.rotate(this.X,this.Y,a.degToRad(g.eval(this.rotateExp))),this.X=b.x,this.Y=b.y)}draw(){super.draw(this.color,this.color)}drawTrace(){super.drawTrace(this.trace,this.trace)}drawAux(n,p){d=this.space;n.fillStyle=p.getColor();e=Math.round(this.abs_coord?
this.X:d.getAbsoluteX(this.X));l=Math.round(this.abs_coord?this.Y:d.getAbsoluteY(this.Y));w=Math.round(this.evaluator.eval(this.size));w>0&&(n.beginPath(),n.arc(e,l,w,0,k),n.fill());this.text.hasContent&&this.text.draw(n,p,e,l)}}a.Point=q})(descartesJS);
(a=>{let k=Math.PI*2,g,d,b,e,l,w,q,n,p,r,t;class c extends a.Graphic{constructor(f,m){super(f,m);this.width=this.width||f.evaluator.parser.parse("1");this.size=this.size||f.evaluator.parser.parse("2");this.text=new a.TextObject(this,this.text)}update(){g=this.evaluator;b=g.eval(this.expresion);this.points=[];for(let f=0,m=b.length;f<m;f++)this.points[f]={x:b[f][0],y:b[f][1]};if(this.rotateExp){e=a.degToRad(g.eval(this.rotateExp));for(let f=0,m=this.points.length;f<m;f++)this.points[f]=this.rotate(this.points[f].x,
this.points[f].y,e)}}draw(){super.draw(this.color,this.color)}drawTrace(){super.drawTrace(this.trace,this.trace)}drawAux(f,m,v){g=this.evaluator;d=this.space;t=Math.round(g.eval(this.width));l=g.eval(this.size);f.fillStyle=m.getColor();f.strokeStyle=v.getColor();f.lineCap="round";w=t%2==0?0:.5;this.abs_coord?(q=Math.round(this.points[0].x),n=Math.round(this.points[0].y),p=Math.round(this.points[1].x),r=Math.round(this.points[1].y)):(q=Math.round(d.getAbsoluteX(this.points[0].x)),n=Math.round(d.getAbsoluteY(this.points[0].y)),
p=Math.round(d.getAbsoluteX(this.points[1].x)),r=Math.round(d.getAbsoluteY(this.points[1].y)));q+=w;n+=w;p+=w;r+=w;f.beginPath();f.moveTo(q,n);f.lineTo(p,r);t>0&&(f.lineWidth=t,this.dashStyle(),f.stroke());l>0&&(f.beginPath(),f.arc(q,n,l,0,k),f.arc(p,r,l,0,k),f.fill());f.setLineDash([]);this.text.hasContent&&this.text.draw(f,v,parseInt((q+p)/2)-3,parseInt((n+r)/2)+3)}}a.Segment=c})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t;class c extends a.Graphic{constructor(f,m){super(f,m);this.width=this.width||f.evaluator.parser.parse("5");this.size=this.size||f.evaluator.parser.parse("2");this.spear=this.spear||f.evaluator.parser.parse("8");this.arrow=this.arrow||new a.Color("ee0022");this.text=new a.TextObject(this,this.text);this.V=new a.Vector2D(0,0);this.points=[]}update(){k=this.evaluator;g=k.eval(this.expresion);for(let f=0,m=g.length;f<m;f++)this.points[f]={x:g[f][0],y:g[f][1]};if(this.rotateExp){d=
a.degToRad(k.eval(this.rotateExp));for(let f=0,m=this.points.length;f<m;f++)this.points[f]=this.rotate(this.points[f].x,this.points[f].y,d)}}draw(){super.draw(this.arrow,this.color)}drawTrace(){super.drawTrace(this.arrow,this.trace)}drawAux(f,m,v){k=this.evaluator;b=this.space;g=this.points;e=Math.max(0,k.eval(this.width));l=Math.ceil(e/2);this.V.x=g[1].x-g[0].x;this.V.y=g[1].y-g[0].y;w=this.V.vLength();this.angle=Math.atan2(this.V.y,this.V.x);f.fillStyle=m.getColor();f.strokeStyle=v.getColor();f.lineWidth=
2;this.abs_coord?(q=Math.round(g[0].x),n=Math.round(g[0].y),p=Math.round(g[1].x),r=Math.round(g[1].y)):(q=Math.round(b.getAbsoluteX(g[0].x)),n=Math.round(b.getAbsoluteY(g[0].y)),p=Math.round(b.getAbsoluteX(g[1].x)),r=Math.round(b.getAbsoluteY(g[1].y)));t=Math.max(0,k.eval(this.spear));f.save();f.translate(q,n);this.abs_coord?f.rotate(this.angle):(w*=b.scale,f.rotate(-this.angle));f.beginPath();f.moveTo(-l,Math.floor(-l));f.lineTo(Math.floor(w-t-e),Math.floor(-l));f.lineTo(Math.floor(w-2*t),Math.floor(-t-
l));f.lineTo(Math.floor(w),0);f.lineTo(Math.floor(w-2*t),Math.floor(t+l));f.lineTo(Math.floor(w-t-e),Math.floor(l));f.lineTo(-l,Math.floor(l));f.closePath();f.stroke();f.fill();f.restore();this.text.hasContent&&this.text.draw(f,v,parseInt((q+p)/2)-3,parseInt((n+r)/2)+3)}}a.Arrow=c})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q;class n extends a.Graphic{constructor(p,r){super(p,r);this.width=this.width||p.evaluator.parser.parse("1");this.fill=this.fill||"";this.points=[]}update(){k=this.evaluator;d=k.eval(this.expresion);for(let p=0,r=d.length;p<r;p++)this.points[p]={x:d[p][0],y:d[p][1]};if(this.rotateExp){b=a.degToRad(k.eval(this.rotateExp));for(let p=0,r=this.points.length;p<r;p++)this.points[p]=this.rotate(this.points[p].x,this.points[p].y,b)}}draw(){super.draw(this.fill,this.color)}drawTrace(){super.drawTrace(this.trace,
this.trace)}drawAux(p,r,t){k=this.evaluator;g=this.space;q=Math.round(k.eval(this.width));p.strokeStyle=t.getColor();p.lineCap=p.lineJoin="round";e=q>0?.5:0;l=Math.round(this.abs_coord?this.points[0].x:g.getAbsoluteX(this.points[0].x));w=Math.round(this.abs_coord?this.points[0].y:g.getAbsoluteY(this.points[0].y));p.beginPath();p.moveTo(l+e,w+e);for(let c=1,f=this.points.length;c<f;c++)l=Math.round(this.abs_coord?this.points[c].x:g.getAbsoluteX(this.points[c].x)),w=Math.round(this.abs_coord?this.points[c].y:
g.getAbsoluteY(this.points[c].y)),p.lineTo(l+e,w+e);this.fill&&(p.fillStyle=r.getColor(),p.fill());q>0&&(p.lineWidth=q,this.dashStyle(),p.stroke());p.setLineDash([])}}a.Polygon=n})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t;class c extends a.Graphic{constructor(f,m){super(f,m);this.width=this.width||f.evaluator.parser.parse("1");this.fill=this.fill||"";this.border_radius=this.border_radius||f.evaluator.parser.parse("0")}update(){k=this.evaluator;e=k.eval(this.expresion);this.X=e[0][0];this.Y=e[0][1];this.w=150;this.h=100;this.rotateExp&&(d=this.rotate(this.X,this.Y,a.degToRad(k.eval(this.rotateExp))),this.X=d.x,this.Y=d.y);e[0].length>=4&&(this.w=e[0][2],this.h=e[0][3]);e[1]&&e[1].length==
2&&(this.w=e[1][0],this.h=e[1][1]);this.w=Math.max(0,this.w);this.h=Math.max(0,this.h)}draw(){super.draw(this.fill,this.color)}drawTrace(){super.drawTrace(this.fill,this.trace,"trace")}drawAux(f,m,v,h){k=this.evaluator;g=this.space;t=Math.round(k.eval(this.width));f.strokeStyle=v.getColor();f.lineCap="round";f.lineJoin="miter";b=t>0?.5:0;l=Math.round(this.abs_coord?this.X:g.getAbsoluteX(this.X))+b;w=Math.round(this.abs_coord?this.Y:g.getAbsoluteY(this.Y))+b;q=this.abs_coord?this.w:this.w*g.scale;
n=this.abs_coord?this.h:-this.h*g.scale;p=Math.min(Math.max(0,k.eval(this.border_radius)),Math.abs(q)*.5,Math.abs(n)*.5);r=this.abs_coord?1:-1;f.beginPath();f.roundRect?f.roundRect(l,w,q,n,p):(f.moveTo(l+p,w),f.arcTo(l+q,w,l+q,w+r*p,p),f.arcTo(l+q,w+n,l+q-p,w+n,p),f.arcTo(l,w+n,l,w+n-r*p,p),f.arcTo(l,w,l+p,w,p));f.closePath();this.fill&&(f.fillStyle=m.getColor(),f.fill());t>0&&(f.lineWidth=t,this.dashStyle(),f.stroke());f.setLineDash([])}}a.Rectangle=c})(descartesJS);
(a=>{const k=Math.PI/2,g=2*Math.PI;let d,b,e,l,w,q,n,p,r,t,c,f,m,v,h,u=/^(\(.*\)|\[.*\])$/;class x extends a.Graphic{constructor(z,G){super(z,G);this.width=this.width||z.evaluator.parser.parse("1");this.fill=this.fill||"";this.center=this.center||z.evaluator.parser.parse("(0,0)");this.radius=this.radius||z.evaluator.parser.parse("1");this.init=this.init||"0";this.end=this.end||"90";this.init.startsWith("_(")&&(this.iFlag=!0,this.init=this.init.slice(1));this.end.startsWith("_(")&&(this.eFlag=!0,this.end=
this.end.slice(1));this.initExpr=z.evaluator.parser.parse(this.init);this.endExpr=z.evaluator.parser.parse(this.end);this.text=new a.TextObject(this,this.text)}update(){d=this.evaluator;[this.X,this.Y]=d.eval(this.center)[0];b=0;this.rotateExp&&(b=a.degToRad(d.eval(this.rotateExp)),e=Math.cos(b),l=Math.sin(b),[this.X,this.Y]=[this.X*e-this.Y*l,this.X*l+this.Y*e]);let z=d.eval(this.initExpr),G=d.eval(this.endExpr);if(u.test(this.initExpr.type)&&u.test(this.endExpr.type)){[w,q]=z[0];[n,p]=G[0];this.vectors?
this.abs_coord&&(q=-q,p=-p):(w-=this.X,q=-q+this.Y,n-=this.X,p=-p+this.Y,this.abs_coord||(q=-q,p=-p));r=w==0?q<0?3*k:k:Math.acos(w*1/Math.sqrt(w*w+q*q));t=n==0?p<0?3*k:k:Math.acos(n*1/Math.sqrt(n*n+p*p));r+=b;t+=b;if(this.abs_coord&&w!=0&&q>0||!this.abs_coord&&w!=0&&q<0)r=g-r;if(this.abs_coord&&n!=0&&p>0||!this.abs_coord&&n!=0&&p<0)t=g-t;if(this.iFlag)[r,t]=[t,r];else if([r,t]=[Math.min(r,t),Math.max(r,t)],t-r>Math.PI&&this.abs_coord||t-r<=Math.PI&&!this.abs_coord)[r,t]=[t,r];this.iniAng=r;this.endAng=
t;this.drawPoints=!0}else this.iniAng=a.degToRad(z)+b,this.endAng=a.degToRad(G)+b,this.drawAngle=!0}draw(){super.draw(this.fill,this.color)}drawTrace(){super.drawTrace(this.fill,this.trace)}drawAux(z,G,A){d=this.evaluator;c=this.space;v=Math.max(0,d.eval(this.radius));h=Math.round(d.eval(this.width));z.lineCap="round";z.strokeStyle=A.getColor();this.abs_coord?(f=Math.round(this.X),m=Math.round(this.Y)):(f=Math.round(c.getAbsoluteX(this.X)),m=Math.round(c.getAbsoluteY(this.Y)),v*=c.scale,this.iniAng=
-this.iniAng,this.endAng=-this.endAng);this.drawAngle&&this.iniAng>this.endAng&&([this.iniAng,this.endAng]=[this.endAng,this.iniAng]);this.fill&&(z.fillStyle=G.getColor(),z.beginPath(),z.moveTo(f,m),z.arc(f,m,v,this.iniAng,this.endAng,void 0),z.fill());h>0&&(z.lineWidth=h,z.beginPath(),z.arc(f,m,v,this.iniAng,this.endAng,void 0),this.dashStyle(),z.stroke());this.text.hasContent&&this.text.draw(z,this.color,f,m)}}a.Arc=x})(descartesJS);
(a=>{let k,g;class d extends a.Graphic{constructor(b,e){super(b,e);this.width=this.width||b.evaluator.parser.parse("0");this.align||(this.align="left");this.anchor||(this.anchor="top_left");this.shadowColor=this.shadowColor?this.shadowColor.getColor():"transparent";this.text=new a.TextObject(this,this.text)}update(){k=this.evaluator;[this.X,this.Y]=k.eval(this.expresion)[0];this.rotateExp&&(g=this.rotate(this.X,this.Y,a.degToRad(k.eval(this.rotateExp))),this.X=g.x,this.Y=g.y)}draw(){super.draw(this.color)}drawTrace(){super.drawTrace(this.trace)}drawAux(b,
e){this.text.draw(b,e,parseInt(this.abs_coord?this.X:this.space.getAbsoluteX(this.X)),parseInt(this.abs_coord?this.Y:this.space.getAbsoluteY(this.Y)))}}a.Text=d})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p;class r extends a.Graphic{constructor(t,c){super(t,c);this.file=this.file||"";this.inirot=this.inirot||t.evaluator.parser.parse("0");this.img=new Image;this.scaleX=this.scaleY=1;this.ratio=t.ratio;t=this.expresion.getChildren();this.x_e=t[0];this.y_e=t[1];t.length>2&&(this.centered=!0,this.s_x_e=t[2],this.s_y_e=t.length>3?t[3]:t[2]);this.evaluator.eval(this.clip)&&(this.clip=this.clip.getChildren());this.update()}update(){k=this.evaluator;this.X=k.eval(this.x_e);this.Y=
k.eval(this.y_e);this.rotateExp&&(g=this.rotate(this.X,this.Y,a.degToRad(k.eval(this.rotateExp))),this.X=g.x,this.Y=g.y);this.centered&&(this.scaleX=k.eval(this.s_x_e),this.scaleY=k.eval(this.s_y_e),this.scaleX==0&&(this.scaleX=1E-5),this.scaleY==0&&(this.scaleY=1E-5));if((d=k.eval(this.file))||d=="")this.img=this.parent.getImage(d),this.img.hasUpdate||(this.img.hasUpdate=!0,this.img.addEventListener("load",()=>{this.space.update(!0)}))}draw(){super.draw()}drawTrace(){super.drawTrace()}drawAux(t){k=
this.evaluator;this.img&&this.img.ready&&this.img.complete&&(this.clip?(n=k.eval(this.clip[2]),p=k.eval(this.clip[3])):(n=this.img.width,p=this.img.height,this.img.canvas&&(n=Math.round(n/this.img.ratio),p=Math.round(p/this.img.ratio))),b=e=0,this.centered||(b=Math.round(n/2),e=Math.round(p/2)),l=Math.round(this.abs_coord?this.X:this.space.getAbsoluteX(this.X)),w=Math.round(this.abs_coord?this.Y:this.space.getAbsoluteY(this.Y)),q=a.degToRad(-k.eval(this.inirot)),t.save(),t.translate(l+b,w+e),t.rotate(q),
this.opacity&&(t.globalAlpha=k.eval(this.opacity)),t.scale(this.scaleX,this.scaleY),this.clip?this.img.canvas?t.drawImage(this.img,k.eval(this.clip[0])*this.img.ratio,k.eval(this.clip[1])*this.img.ratio,n*this.img.ratio,p*this.img.ratio,-n/2,-p/2,n,p):t.drawImage(this.img,k.eval(this.clip[0]),k.eval(this.clip[1]),n,p,-n/2,-p/2,n,p):t.drawImage(this.img,-n/2,-p/2,n,p),t.restore())}}a.Image=r})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q=document.createElement("canvas").getContext("2d");q.canvas.width=q.canvas.height=1;class n extends a.Graphic{constructor(p,r){super(p,r)}update(){[this.X,this.Y]=this.evaluator.eval(this.expresion)[0]}draw(){super.draw(this.color,this.color)}drawTrace(){super.drawTrace(this.trace,this.trace)}drawAux(p,r){r=r.getColor();q.clearRect(0,0,1,1);q.fillStyle=r;q.fillRect(0,0,1,1);r=(new Uint32Array(q.getImageData(0,0,1,1).data.buffer))[0];l=p.getImageData(0,0,this.space.w,this.space.h);
w=new Uint32Array(l.data.buffer);k=parseInt(this.abs_coord?this.X:this.space.getAbsoluteX(this.X));g=parseInt(this.abs_coord?this.Y:this.space.getAbsoluteY(this.Y));var t=w,c=l.width;b=k<0||g<0||k>=c||g>=l.height?-1:t[k+g*c];if(b!=-1&&r!=b){d=[k,g];for(e=0;d.length>0&&!(g=d.pop(),k=d.pop(),t=w,c=l.width,b==(k<0||g<0||k>=c||g>=l.height?-1:t[k+g*c])&&(e++,w[k+g*l.width]=r,k>0&&d.push(k-1,g),k<l.width-1&&d.push(k+1,g),g>0&&d.push(k,g-1),g<l.height-1&&d.push(k,g+1)),e>=this.space.w*this.space.h););p.putImageData(l,
0,0)}}}a.Fill=n})(descartesJS);
(a=>{class k extends a.BaseMacro{constructor(g,d){super(g,d,"parseGraphic","-text-image-point-polygon-arc-segment-arrow-macro-curve-equation-sequence-rectangle-fill-");this.inirot=this.inirot||g.evaluator.parser.parse("0");this.inipos=this.inipos||g.evaluator.parser.parse("(0,0)");Object.assign(this,d)}update(){[this.iniPosX,this.iniPosY]=this.evaluator.eval(this.inipos)[0]}drawAux(g){for(let d of this.graphics)d&&(g.save(),d.abs_coord?g.translate(this.iniPosX,this.iniPosY):g.translate(this.iniPosX*
this.space.scale,-this.iniPosY*this.space.scale),d.draw(),g.restore())}}a.Macro=k})(descartesJS);
(a=>{class k{constructor(d=0,b=0,e=0,l=1){this.D=new Float32Array(4);this.set(d,b,e,l)}set(d,b,e,l){this.D[0]=d;this.D[1]=b;this.D[2]=e;this.D[3]=l;return this}get x(){return this.D[0]}set x(d){this.D[0]=d}get y(){return this.D[1]}set y(d){this.D[1]=d}get z(){return this.D[2]}set z(d){this.D[2]=d}get w(){return this.D[3]}set w(d){this.D[3]=d}norm3D(){let d=this.D[0],b=this.D[1],e=this.D[2];return Math.sqrt(d*d+b*b+e*e)}normalize3D(d=new k){var b=this.norm3D();if(b==0)return d.set(0,0,0,this.w);b=
1/b;return d.set(this.D[0]*b,this.D[1]*b,this.D[2]*b,this.w)}dotProduct3D(d){return this.D[0]*d.D[0]+this.D[1]*d.D[1]+this.D[2]*d.D[2]}crossProduct3D(d,b=new k){let [e,l,w]=this.D,[q,n,p]=d.D;return b.set(l*p-w*n,w*q-e*p,e*n-l*q,b.w)}scalarProd3D(d,b=new k){return b.set(this.D[0]*d,this.D[1]*d,this.D[2]*d,this.w)}subtract3D(d,b=new k){return b.set(this.D[0]-d.D[0],this.D[1]-d.D[1],this.D[2]-d.D[2],this.w)}add3D(d,b=new k){return b.set(this.D[0]+d.D[0],this.D[1]+d.D[1],this.D[2]+d.D[2],this.w)}equals3D(d,
b){return Math.abs(this.D[0]-d.D[0])<=b&&Math.abs(this.D[1]-d.D[1])<=b&&Math.abs(this.D[2]-d.D[2])<=b}clone(){return new k(this.D[0],this.D[1],this.D[2],this.D[3])}}class g{constructor(d=0,b=0,e=0,l=0,w=0,q=0,n=0,p=0,r=0,t=0,c=0,f=0,m=0,v=0,h=0,u=0){this.D=new Float32Array(16);this.set(d,b,e,l,w,q,n,p,r,t,c,f,m,v,h,u)}set(d,b,e,l,w,q,n,p,r,t,c,f,m,v,h,u){let x=this.D;x[0]=d;x[1]=b;x[2]=e;x[3]=l;x[4]=w;x[5]=q;x[6]=n;x[7]=p;x[8]=r;x[9]=t;x[10]=c;x[11]=f;x[12]=m;x[13]=v;x[14]=h;x[15]=u;return this}setIdentity(){let d=
this.D;d[0]=1;d[1]=0;d[2]=0;d[3]=0;d[4]=0;d[5]=1;d[6]=0;d[7]=0;d[8]=0;d[9]=0;d[10]=1;d[11]=0;d[12]=0;d[13]=0;d[14]=0;d[15]=1;return this}mulV4(d,b=new k){let e=this.D;var l=d.D;d=b.D;let w=l[0],q=l[1],n=l[2];l=l[3];d[0]=w*e[0]+q*e[4]+n*e[8]+l*e[12];d[1]=w*e[1]+q*e[5]+n*e[9]+l*e[13];d[2]=w*e[2]+q*e[6]+n*e[10]+l*e[14];d[3]=w*e[3]+q*e[7]+n*e[11]+l*e[15];return b}translate(d,b=(new g).setIdentity()){let e=this.D,l=b.D;d instanceof k||(d=new k(d.x,d.y,d.z,d.w));let w=d.D[0],q=d.D[1];d=d.D[2];l[0]=e[0];
l[1]=e[1];l[2]=e[2];l[3]=e[3];l[4]=e[4];l[5]=e[5];l[6]=e[6];l[7]=e[7];l[8]=e[8];l[9]=e[9];l[10]=e[10];l[11]=e[11];l[12]=e[0]*w+e[4]*q+e[8]*d+e[12];l[13]=e[1]*w+e[5]*q+e[9]*d+e[13];l[14]=e[2]*w+e[6]*q+e[10]*d+e[14];l[15]=e[3]*w+e[7]*q+e[11]*d+e[15];return b}rotateX(d,b=(new g).setIdentity()){let e=this.D,l=b.D,w=Math.sin(d);d=Math.cos(d);l[0]=e[0];l[1]=e[1];l[2]=e[2];l[3]=e[3];l[4]=e[4]*d+e[8]*w;l[5]=e[5]*d+e[9]*w;l[6]=e[6]*d+e[10]*w;l[7]=e[7]*d+e[11]*w;l[8]=e[4]*-w+e[8]*d;l[9]=e[5]*-w+e[9]*d;l[10]=
e[6]*-w+e[10]*d;l[11]=e[7]*-w+e[11]*d;l[12]=e[12];l[13]=e[13];l[14]=e[14];l[15]=e[15];return b}rotateY(d,b=(new g).setIdentity()){let e=this.D,l=b.D,w=Math.sin(d);d=Math.cos(d);l[0]=e[0]*d+e[8]*-w;l[1]=e[1]*d+e[9]*-w;l[2]=e[2]*d+e[10]*-w;l[3]=e[3]*d+e[11]*-w;l[4]=e[4];l[5]=e[5];l[6]=e[6];l[7]=e[7];l[8]=e[0]*w+e[8]*d;l[9]=e[1]*w+e[9]*d;l[10]=e[2]*w+e[10]*d;l[11]=e[3]*w+e[11]*d;l[12]=e[12];l[13]=e[13];l[14]=e[14];l[15]=e[15];return b}rotateZ(d,b=(new g).setIdentity()){let e=this.D,l=b.D,w=Math.sin(d);
d=Math.cos(d);l[0]=e[0]*d+e[4]*w;l[1]=e[1]*d+e[5]*w;l[2]=e[2]*d+e[6]*w;l[3]=e[3]*d+e[7]*w;l[4]=e[0]*-w+e[4]*d;l[5]=e[1]*-w+e[5]*d;l[6]=e[2]*-w+e[6]*d;l[7]=e[3]*-w+e[7]*d;l[8]=e[8];l[9]=e[9];l[10]=e[10];l[11]=e[11];l[12]=e[12];l[13]=e[13];l[14]=e[14];l[15]=e[15];return b}clone(){let d=new g;d.D.set(this.D);return d}}a.norm3D=function(d){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));return d.norm3D()};a.normalize3D=function(d){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));return d.normalize3D().clone()};
a.dotProduct3D=function(d,b){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));b instanceof k||(b=new k(b.x,b.y,b.z,b.w));return d.dotProduct3D(b)};a.crossProduct3D=function(d,b){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));b instanceof k||(b=new k(b.x,b.y,b.z,b.w));return d.crossProduct3D(b).clone()};a.scalarProd3D=function(d,b){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));return d.scalarProd3D(b).clone()};a.subtract3D=function(d,b){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));b instanceof k||(b=new k(b.x,b.y,
b.z,b.w));return d.subtract3D(b).clone()};a.add3D=function(d,b){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));b instanceof k||(b=new k(b.x,b.y,b.z,b.w));return d.add3D(b).clone()};a.equals3D=function(d,b,e){d instanceof k||(d=new k(d.x,d.y,d.z,d.w));b instanceof k||(b=new k(b.x,b.y,b.z,b.w));return d.equals3D(b,e)};a.Vec4D=k;a.Mat4=g})(descartesJS);
(a=>{function k(q){q.textNode=null;parseInt(this.size)!==0&&(q.lineWidth=1,q.fillStyle=this.backColor,q.strokeStyle=this.frontColor,q.beginPath(),q.arc(this.projV[0].x,this.projV[0].y,this.size,0,l),q.fill(),q.stroke())}function g(q,n){q.textNode=null;q.lineCap=q.lineJoin="round";q.lineWidth=.4;q.beginPath();q.moveTo(this.projV[0].x,this.projV[0].y);for(let p=1,r=this.projV.length;p<r;p++)q.lineTo(this.projV[p].x,this.projV[p].y);q.closePath();this.model=="color"?(q.fillStyle=this.direction<0?this.backColor:
this.frontColor,q.strokeStyle=q.fillStyle,q.stroke(),q.fill()):this.model=="light"||this.model=="metal"?(q.fillStyle=n.computeColor(this.direction<0?this.backColor:this.frontColor,this,this.model=="metal"),q.strokeStyle=q.fillStyle,q.stroke(),q.fill()):this.model=="wire"&&(q.lineWidth=1.25,q.strokeStyle=this.frontColor,q.stroke());this.edges&&this.model!=="wire"&&(q.lineWidth=1,q.strokeStyle=this.edges,q.stroke())}function d(q){q.textNode=null;let n=this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,
this.fVal);this.fontSize=Math.max(5,this.evaluator.eval(this.font_size));this.font=`${this.font_style} ${this.fontSize}px ${this.font_family}`;this.drawText(q,this.text,this.projV[0].x,this.projV[0].y,this.frontColor,this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,n)}function b(q){q.textNode=null;q.lineCap="butt";q.lineJoin="round";q.lineWidth=this.lineWidth;q.strokeStyle=this.frontColor;q.beginPath();q.moveTo(this.projV[0].x,this.projV[0].y);q.lineTo(this.projV[1].x,
this.projV[1].y);this.lineDash=="dot"?q.setLineDash([q.lineWidth,q.lineWidth]):this.lineDash=="dash"?q.setLineDash([q.lineWidth*4,q.lineWidth*3]):this.lineDash=="dash_dot"?q.setLineDash([q.lineWidth*4,q.lineWidth*2,q.lineWidth,q.lineWidth*2]):(q.lineCap="round",q.setLineDash([]));q.stroke()}function e(q,n,p){return a.normalize3D(a.crossProduct3D(a.subtract3D(q,n),a.subtract3D(q,p)))}const l=2*Math.PI;class w{constructor(q,n){Object.assign(this,q);this.space=n;this.projV=[];this.spaceV=[];this.newProjV=
[];this.newSpaceV=[];this.type=="vertex"?this.draw=k:this.type=="face"?(this.normal=e(this.V[0],this.V[1],this.V[2]),this.draw=g):this.type=="text"?this.draw=d:this.type=="edge"&&(this.draw=b);this.isText&&(this.computeDepth=function(){this.normal={x:0,y:0,z:0};this.projV=this.V;this.depth=this.V[0].z;this.avg=this.V[0]})}computeDepth(q){this.space=q;this.avg={x:0,y:0,z:0};this.removeDoubles();this.normal={x:0,y:1,z:0};this.direction={x:1,y:0,z:0};var n=this.V.length;for(let p=0;p<n;p++)this.spaceV[p]=
q.rotateVertex(this.V[p]),this.avg.x+=this.spaceV[p].x,this.avg.y+=this.spaceV[p].y,this.avg.z+=this.spaceV[p].z;this.avg=a.scalarProd3D(this.avg,1/n);this.avg_proy=q.project(this.avg);this.depth=a.norm3D(a.subtract3D(q.eye,this.avg));this.V.length>2&&(this.normal=e(this.spaceV[0],this.spaceV[1],this.spaceV[2]));for(let p=0,r=this.V.length;p<r;p++)this.newSpaceV[p]=this.spaceV[p],this.projV[p]=this.newProjV[p]=q.project(this.spaceV[p]);this.V.length>2&&(this.direction=e(this.projV[0],this.projV[1],
this.projV[2]).z);this.minDistToEye=Infinity;this.maxDistToEye=-Infinity;this.minX=Infinity;this.maxX=-Infinity;this.minY=Infinity;this.maxY=-Infinity;for(let p=0,r=this.V.length;p<r;p++)n=a.norm3D(a.subtract3D(this.spaceV[p],q.eye)),this.minDistToEye=Math.min(this.minDistToEye,n),this.maxDistToEye=Math.max(this.maxDistToEye,n);for(let p=0,r=this.V.length;p<r;p++)this.minX>this.projV[p].x&&(this.minX=this.projV[p].x),this.maxX<this.projV[p].x&&(this.maxX=this.projV[p].x),this.minY>this.projV[p].y&&
(this.minY=this.projV[p].y),this.maxY<this.projV[p].y&&(this.maxY=this.projV[p].y)}removeDoubles(){if(this.type!=="edge"){let q=[];for(let n=0,p=this.V.length;n<p;n++)(Math.abs(this.V[n].x-this.V[(n+1)%p].x)>1E-8||Math.abs(this.V[n].y-this.V[(n+1)%p].y)>1E-8||Math.abs(this.V[n].z-this.V[(n+1)%p].z)>1E-8||Math.abs(this.V[n].w-this.V[(n+1)%p].w)>1E-8)&&q.push(this.V[n]);q.length==0&&q.push(this.V[0]);this.V=q}}drawText(q,n,p,r,t,c,f,m,v,h,u){q.textNode=n;c=this.evaluator.eval(this.offset_dist);f=-a.degToRad(this.evaluator.eval(this.offset_angle));
p+=c*Math.cos(f);r+=c*Math.sin(f);q.textNode.pos={x:p,y:r};n.hasContent&&(n.draw(q,t,p,r,!0),n.draw(q,t,p-(this.fromPoint?n.textNodes.metrics.w/2:0),r-(this.fromPoint?n.textNodes.metrics.h/2:0)))}splitFace(q){if(this.intersects(q)){var n=null;let m=null,v=0,h=0;var p,r=this.V;let u=q.V;for(let x=0,z=u.length;x<z;x++){var t=this.intersection(u[x],u[(x+1)%z]);if(t!==null)if(n===null){if(n=t,v=x,u.length==2){m=n;break}}else if(!a.equals3D(t,n,1E-8)){m=t;h=x;break}}if(n!==null&&m!==null){var c=this.isInterior(n)||
this.isInterior(m);var f=p=null;if(!c&&u.length>=3)for(let x=0,z=r.length;x<z;x++)if(t=q.intersection(this.V[x],this.V[(x+1)%z]),t!==null)if(p==null)p=t;else if(!a.equals3D(t,p,1E-8)){f=t;break}if(c||p!==null&&f!==null&&q.isInterior(p)&&q.isInterior(f)){r=!0;p=c=null;if(u.length==2)a.equals3D(n,u[0],1E-8)||a.equals3D(n,u[1],1E-8)?r=!1:(c=[],c[0]=u[0],c[1]=n,p=[],p[0]=n,p[1]=u[1]);else{c=[];p=[];t=f=0;for(let x=0;x<u.length;x++)x<v?c[f++]=u[x]:x==v?(c[f++]=u[x],c[f++]=n,p[t++]=n):x<h?p[t++]=u[x]:x==
h?(p[t++]=u[x],p[t++]=m,c[f++]=m):c[f++]=u[x]}if(r){n=[];n[0]=new w({V:c,type:"face",frontColor:q.frontColor,backColor:q.backColor,edges:q.edges,model:q.model},this.space);n[0].removeDoubles();n[0].normal=q.normal;n[1]=new w({V:p,type:"face",frontColor:q.frontColor,backColor:q.backColor,edges:q.edges,model:q.model},this.space);n[1].removeDoubles();n[1].normal=q.normal;if(n[0].V.length>2)return n[1].V.length>2?n:[n[0]];if(n[1].V.length>2)return[n[1]]}}}}return[q]}intersects(q){return this.intersectsPlane(q)&&
q.intersectsPlane(this)}intersectsPlane(q){let n,p,r=this.V;var t=q.V;if(r.length>0){n=a.dotProduct3D(t[0],q.normal);p=a.dotProduct3D(r[0],q.normal);if(Math.abs(n-p)<1E-8)return!0;for(let c=1,f=r.length;c<f;c++)if(t=a.dotProduct3D(r[c],q.normal),Math.abs(n-t)<1E-8||t>n&&p<n||t<n&&p>n)return!0}return!1}intersection(q,n){var p=this.V;if(p.length>0){n=a.subtract3D(n,q);let r=a.dotProduct3D(n,this.normal);if(r!==0&&(p=a.dotProduct3D(a.subtract3D(p[0],q),this.normal)/r,-1E-8<p&&p<1.00000001))return a.add3D(q,
a.scalarProd3D(n,p))}return null}isInterior(q){let n=this.V;if(n.length>0){let p=0,r=a.subtract3D(n[0],q);for(let t=0,c=n.length;t<c;t++){let f=a.subtract3D(n[(t+1)%c],q),m=a.dotProduct3D(a.crossProduct3D(r,f),this.normal);if(Math.abs(m)<1E-8){if(a.dotProduct3D(r,f)<0)break}else{if(p<0&&m>0||p>0&&m<0)return!1;r=f;p=m}}}return!0}inFrontOf(q,n,p){if(this.minDistToEye>=n.maxDistToEye||this.maxX<=n.minX||this.minX>=n.maxX||this.maxY<=n.minY||this.minY>=n.maxY)return!1;let r;let t;for(r=0;r<3;r++){var c=
r==0?this.intersections(n):r==1?n.verticesContainedIn(this):this.verticesContainedIn(n);if(c!=null&&c.length>0){for(let f of c)q.push(f);for(let f of c){c=this.space.rayFromEye(f.x,f.y);try{t=this.distanceToEyeAlong(c)-n.distanceToEyeAlong(c);if(t<=-p)return!0;if(t>=p)return!1}catch(m){}}}}return!1}intersections(q){let n=[],p;let r,t=new a.R2,c=this.newSpaceV,f=q.newSpaceV,m=this.newProjV,v=q.newProjV;for(let u=0,x=c.length;u<x;u++){q=c[u];p=c[(u+1)%x];for(let z=0,G=f.length;z<G;z++){var h=f[z];r=
f[(z+1)%G];q!=h&&q!=r&&p!=h&&p!=r&&(h=t.intersection(m[u],m[(u+1)%x],v[z],v[(z+1)%G]),h!=null&&n.push(h))}}return n}distanceToEyeAlong(q){q=a.dotProduct3D(this.normal,q);if(Math.abs(q)>1E-6)return a.dotProduct3D(a.subtract3D(this.avg,this.space.eye),this.normal)/q;throw new Exception("Face is invisible");}verticesContainedIn(q){let n=[],p=this.newSpaceV,r=this.newProjV;for(let t=0,c=p.length;t<c;t++)!q.isVertex(p[t])&&q.appearsToContain(r[t])&&n.push(r[t]);return n}appearsToContain(q){let n=0;var p=
this.newSpaceV;let r=this.newProjV;for(let t=0,c=p.length;t<c;t++){p=(r[t].x-q.x)*(r[(t+1)%c].y-q.y)-(r[(t+1)%c].x-q.x)*(r[t].y-q.y);if(n!=0)if(Math.abs(p)<1E-8){if(Math.abs(r[t].x-r[(t+1)%c].x)>1E-8)return Math.min(r[t].x,r[(t+1)%c].x)<=q.x+1E-8&&q.x<=Math.max(r[t].x,r[(t+1)%c].x)+1E-8;if(Math.abs(r[t].y-r[(t+1)%c].y)>1E-8)return Math.min(r[t].y,r[(t+1)%c].y)<=q.y+1E-8&&q.y<=Math.max(r[t].y,r[(t+1)%c].y)+1E-8}else if(n>0&&p<0||n<0&&p>0)return!1;n=p}return!0}isVertex(q){let n=this.newSpaceV;for(let p of n)if(a.equals3D(q,
p,1E-8))return!0;return!1}}a.Primitive3D=w})(descartesJS);
(a=>{const k=a.degToRad;let g,d,b,e,l,w;class q{constructor(n,p){this.parent=n;this.evaluator=n.evaluator;let r=n.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.Nv=this.evaluator.parser.parse("7");this.drawif=r.parse("1");this.abs_coord=!1;this.family="";this.family_interval=r.parse("[0,1]");this.family_steps=r.parse("8");this.font="SansSerif,PLAIN,18";this.fixed=!0;this.text="";this.decimals=r.parse("2");
this.inirot=this.endrot="(0,0,0)";this.inirotEuler=this.endrotEuler=!1;this.inipos=this.endpos=r.parse("(0,0,0)");this.model="color";Object.assign(this,p);this.expresion==void 0&&this.type!=="macro"&&(this.expresion=r.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font_str=this.font;this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/([\d\.]+)px/))?parseFloat(this.fontSize[1]):10;this.font_style=a.getFontStyle(this.font_str.split(",")[1]);
if(typeof this.bold=="boolean"||typeof this.italics=="boolean")this.font_style=(this.italics?"Italic ":"")+(this.bold?"Bold ":"");this.font_family||(this.font_family=this.font_str.split(",")[0]);this.font_family=a.getFontName(this.font_family);typeof this.font_size=="undefined"&&(this.font_size=n.evaluator.parser.parse(""+this.fontSize));this.inirot.includes("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.includes("Euler")&&(this.endrot=this.endrot.replace("Euler",
""),this.endrotEuler=!0);this.inirot=r.parse(this.inirot);this.endrot=r.parse(this.endrot);this.inirotM=new a.Mat4;this.inirotM_X=new a.Mat4;this.inirotM_Y=new a.Mat4;this.inirotM_Z=new a.Mat4;this.iniposM=new a.Mat4;this.endrotM=new a.Mat4;this.endrotM_X=new a.Mat4;this.endrotM_Y=new a.Mat4;this.endrotM_Z=new a.Mat4;this.endposM=new a.Mat4;w=new a.Mat4}getSpace(){return this.parent.spaces.find(n=>n.id==this.spaceID)||this.parent.spaces[0]}getFamilyValues(){g=this.evaluator;[this.fInf,this.fSup]=
g.eval(this.family_interval)[0];this.fSteps=Math.round(g.eval(this.family_steps));this.fSep=this.fSteps>0?(this.fSup-this.fInf)/this.fSteps:0}buildFamilyPrimitives(){g=this.evaluator;this.getFamilyValues();d=g.getVariable(this.family);if(this.fSteps>=0)for(let n=0,p=this.fSteps;n<=p;n++)this.fVal=this.fInf+n*this.fSep,g.setVariable(this.family,this.fVal),g.eval(this.drawif)&&this.buildPrimitives();g.setVariable(this.family,d)}update(){this.primitives=[];this.evaluator.eval(this.drawif)&&(this.family||
this.buildPrimitives());this.family&&this.buildFamilyPrimitives()}updateMVMatrix(){b=this.evaluator.eval(this.inirot)[0];this.inirotEuler?(this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(k(b[0])),this.inirotM=this.inirotM.rotateX(k(b[1])),this.inirotM=this.inirotM.rotateZ(k(b[2]))):(w.setIdentity(),w.rotateX(k(b[0]),this.inirotM_X),w.rotateY(k(b[1]),this.inirotM_Y),w.rotateZ(k(b[2]),this.inirotM_Z));b=this.evaluator.eval(this.inipos)[0];this.iniposM=this.iniposM.setIdentity().translate({x:b[0],
y:b[1],z:b[2]});b=this.evaluator.eval(this.endrot)[0];this.endrotEuler?(this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(k(b[0])),this.endrotM=this.endrotM.rotateX(k(b[1])),this.endrotM=this.endrotM.rotateZ(k(b[2]))):(w.setIdentity(),w.rotateX(k(b[0]),this.endrotM_X),w.rotateY(k(b[1]),this.endrotM_Y),w.rotateZ(k(b[2]),this.endrotM_Z));b=this.evaluator.eval(this.endpos)[0];this.endposM=this.endposM.setIdentity().translate({x:b[0],y:b[1],z:b[2]})}transformVertex(n){e=this.inirotEuler?this.inirotM.mulV4(n):
this.inirotM_Z.mulV4(this.inirotM_Y.mulV4(this.inirotM_X.mulV4(n)));e=this.iniposM.mulV4(e);e=this.endrotEuler?this.endrotM.mulV4(e):this.endrotM_Z.mulV4(this.endrotM_Y.mulV4(this.endrotM_X.mulV4(e)));e=this.endposM.mulV4(e);this.macroChildren&&(e=this.applyMacroTransform(e));return e}applyMacroTransform(n){e=this.macro_inirotEuler?this.macro_inirotM.mulV4(n):this.macro_inirotM_Z.mulV4(this.macro_inirotM_Y.mulV4(this.macro_inirotM_X.mulV4(n)));e=this.macro_iniposM.mulV4(e);e=this.macro_endrotEuler?
this.macro_endrotM.mulV4(e):this.macro_endrotM_Z.mulV4(this.macro_endrotM_Y.mulV4(this.macro_endrotM_X.mulV4(e)));return e=this.macro_endposM.mulV4(e)}parseExpression(){let n=[];for(let c of this.expresion.split(";"))if(c.trim()!==""){var p=n,r=p.push;let f;var t=c;let m=[],v=0,h=t.length;for(let u=t.length-1;u>-1;u--)f=t.charAt(u),v==0?f=="="&&(v=1):v==1?f!=" "&&(v=f=="<"||f==">"?0:2):v==2&&f==" "&&(m.unshift(t.slice(u+1,h)),h=u,v=0);m.unshift(t.slice(0,h));r.call(p,...m)}for(let c=0,f=n.length;c<
f;c++)n[c]=this.evaluator.parser.parse(n[c],!0);return n}splitFace(n){for(let p of this.primitives)if(l=[],p.type=="face"){for(let r of n.primitives)r.type=="face"?l.push(...p.splitFace(r)):l.push(r);n.primitives=l}}}a.Graphic3D=q})(descartesJS);
(a=>{let k,g,d,b,e;class l extends a.Graphic3D{constructor(w,q){super(w,q)}buildPrimitives(){k=this.evaluator;this.updateMVMatrix();g=k.eval(this.expresion)[0];d=g[0];b=g[1];e=g[2];this.primitives.push(new a.Primitive3D({V:[this.transformVertex(new a.Vec4D(d,b,e))],type:"vertex",backColor:this.backcolor.getColor(),frontColor:this.color.getColor(),size:k.eval(this.width)}));this.text!==""&&(this.offset_dist=this.offset_dist||k.parser.parse("10"),this.offset_angle=this.offset_angle||k.parser.parse("270"),
this.primitives.push(new a.Primitive3D({V:[this.transformVertex(new a.Vec4D(d,b,e))],type:"text",fromPoint:!0,frontColor:this.color.getColor(),font_size:this.font_size,font_style:this.font_style,font_family:this.font_family,decimals:k.eval(this.decimals),fixed:this.fixed,evaluator:k,text:new a.TextObject(this,this.text),family:this.family,fVal:this.fVal,offset_dist:this.offset_dist,offset_angle:this.offset_angle},this.space)))}}a.Point3D=l})(descartesJS);
(a=>{let k,g,d;class b extends a.Graphic3D{constructor(e,l){super(e,l);this.width=this.width||e.evaluator.parser.parse("1")}buildPrimitives(){g=this.evaluator;this.updateMVMatrix();k=g.getVariable("u");g.setVariable("u",this.Nu);d=g.eval(this.expresion);this.primitives.push(new a.Primitive3D({V:[this.transformVertex(new a.Vec4D(d[0][0],d[0][1],d[0][2])),this.transformVertex(new a.Vec4D(d[1][0],d[1][1],d[1][2]))],type:"edge",lineDash:this.lineDash,frontColor:this.color.getColor(),lineWidth:g.eval(this.width)},
this.space));g.setVariable("u",k)}}a.Segment3D=b})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p;class r extends a.Graphic3D{constructor(t,c){super(t,c);this.param=this.param||"t";this.parameter_interval=this.parameter_interval||t.evaluator.parser.parse("[0,1]");this.parameter_steps=this.parameter_steps||t.evaluator.parser.parse("8");this.expresion=this.parseExpression()}buildPrimitives(){k=this.evaluator;this.updateMVMatrix();b=k.getVariable("x");e=k.getVariable("y");l=k.getVariable("z");g=k.getVariable("u");d=k.getVariable("v");k.setVariable("u",0);k.setVariable("v",
0);w=parseInt(k.eval(this.Nu));q=parseInt(k.eval(this.Nv));n=[];for(var t=0;t<=w;t++){k.setVariable("u",t/w);for(var c=0;c<=q;c++){k.setVariable("v",c/q);for(var f of this.expresion)k.eval(f);n.push(this.transformVertex(new a.Vec4D(k.getVariable("x"),k.getVariable("y"),k.getVariable("z"))))}}t=this.color.getColor();c=this.backcolor.getColor();f=this.edges?this.edges.getColor():"";for(let m=0;m<w;m++)for(let v=0;v<q;v++)p=[],p.push(n[v+m*q+m]),p.push(n[v+1+m*q+m]),p.push(n[v+2+(m+1)*q+m]),p.push(n[v+
1+(m+1)*q+m]),this.primitives.push(new a.Primitive3D({V:p,type:"face",frontColor:t,backColor:c,edges:f,model:this.model},this.space));k.setVariable("x",b);k.setVariable("y",e);k.setVariable("z",l);k.setVariable("u",g);k.setVariable("v",d)}}a.Surface3D=r})(descartesJS);
(a=>{let k,g,d;class b extends a.Graphic3D{constructor(e,l){super(e,l);this.width=this.width||e.evaluator.parser.parse("1")}buildPrimitives(){k=this.evaluator;this.updateMVMatrix();g=k.eval(this.expresion);d=this.color.getColor();for(let e=0,l=g.length-1;e<l;e++)this.primitives.push(new a.Primitive3D({V:[this.transformVertex(new a.Vec4D(g[e][0],g[e][1],g[e][2])),this.transformVertex(new a.Vec4D(g[e+1][0],g[e+1][1],g[e+1][2]))],type:"edge",frontColor:d,lineWidth:k.eval(this.width)},this.space))}}a.Polygon3D=
b})(descartesJS);
(a=>{let k,g,d,b,e,l,w;class q extends a.Graphic3D{constructor(n,p){super(n,p);this.width=this.width||n.evaluator.parser.parse("1");this.expresion=this.parseExpression()}buildPrimitives(){w=this.evaluator;this.updateMVMatrix();b=w.getVariable("x");e=w.getVariable("y");l=w.getVariable("z");d=w.getVariable("u");w.setVariable("u",0);g=w.eval(this.Nu);k=[];for(let n=0;n<=g;n++){w.setVariable("u",n/g);for(let p of this.expresion)w.eval(p);k.push(this.transformVertex(new a.Vec4D(w.getVariable("x"),w.getVariable("y"),
w.getVariable("z"))))}for(let n=0,p=k.length-1;n<p;n++)this.primitives.push(new a.Primitive3D({V:[k[n],k[n+1]],type:"edge",frontColor:this.color.getColor(),lineWidth:w.eval(this.width)},this.space));this.fill&&k.length>2&&this.primitives.push(new a.Primitive3D({V:k,type:"face",frontColor:this.fill.getColor(),backColor:this.fill.getColor(),edges:"",model:this.model},this.space));w.setVariable("x",b);w.setVariable("y",e);w.setVariable("z",l);w.setVariable("u",d)}}a.Curve3D=q})(descartesJS);
(a=>{let k,g;class d extends a.Graphic3D{constructor(b,e){super(b,e)}buildPrimitives(){k=this.evaluator;this.updateMVMatrix();g=k.eval(this.expresion);this.primitives.push(new a.Primitive3D({V:[this.transformVertex(new a.Vec4D(g[0][0],g[0][1],g[0][2])),this.transformVertex(new a.Vec4D(g[2][0],g[2][1],g[2][2])),this.transformVertex(new a.Vec4D(g[1][0],g[1][1],g[1][2]))],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges?this.edges.getColor():"",model:this.model},
this.space))}}a.Triangle3D=d})(descartesJS);
(a=>{let k,g,d;class b extends a.Graphic3D{constructor(e,l){super(e,l)}buildPrimitives(){g=this.evaluator;this.updateMVMatrix();d=g.eval(this.expresion);k=[];for(let e=d.length-1;e>=0;e--)k.push(this.transformVertex(new a.Vec4D(d[e][0],d[e][1],d[e][2])));this.primitives.push(new a.Primitive3D({V:k,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges?this.edges.getColor():"",model:this.model},this.space))}}a.Face3D=b})(descartesJS);
(a=>{let k,g,d,b,e,l;class w extends a.Graphic3D{constructor(q,n){super(q,n);this.width=this.width||q.evaluator.parser.parse("2");this.length=this.length||q.evaluator.parser.parse("2")}buildPrimitives(){l=this.evaluator;this.updateMVMatrix();k=l.eval(this.Nu);g=[this.transformVertex(new a.Vec4D)];d=l.eval(this.width)/2;b=l.eval(this.length)/2;e=2*Math.PI/k;for(var q=0;q<k;q++)g.push(this.transformVertex(new a.Vec4D(d*Math.cos(e*q),b*Math.sin(e*q),0)));q=this.color.getColor();let n=this.backcolor.getColor(),
p=this.edges?this.edges.getColor():"";for(let r=0;r<k;r++)this.primitives.push(new a.Primitive3D({V:[g[0],r+2<=k?g[r+2]:g[1],g[r+1]],type:"face",frontColor:q,backColor:n,edges:p,model:this.model},this.space))}}a.Polireg3D=w})(descartesJS);
(a=>{let k,g;class d extends a.Graphic3D{constructor(b,e){super(b,e);this.shadowColor=this.shadowColor?this.shadowColor.getColor():"transparent"}buildPrimitives(){k=this.evaluator;g=k.eval(this.expresion)[0];this.primitives.push(new a.Primitive3D({V:[new a.Vec4D(g[0],g[1],0)],type:"text",frontColor:this.color.getColor(),font_size:this.font_size,font_style:this.font_style,font_family:this.font_family,decimals:k.eval(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:k,text:new a.TextObject(this,
this.text),family:this.family,fVal:this.fVal},this.space))}}a.Text3D=d})(descartesJS);
(a=>{let k,g,d;const b=a.degToRad;let e=0;class l extends a.BaseMacro{constructor(w,q){super(w,q,"parse3DGraphic","-point-segment-polygon-curve-triangle-face-polireg-surface-text-cube-box-tetrahedron-octahedron-sphere-dodecahedron-icosahedron-ellipsoid-cone-cylinder-torus-mesh-macro-");this.inirot=this.inirot||"(0,0,0)";this.inirotEuler=this.inirotEuler||!1;this.inipos=this.inipos||w.evaluator.parser.parse("(0,0,0)");this.endrot=this.endrot||"(0,0,0)";this.endrotEuler=this.endrotEuler||!1;this.endpos=
this.endpos||w.evaluator.parser.parse("(0,0,0)");this.name=this.name||`_M_${e++}`;Object.assign(this,q);typeof this.inirot=="string"&&this.inirot.includes("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);typeof this.endrot=="string"&&this.endrot.includes("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=this.evaluator.parser.parse(this.inirot);this.endrot=this.evaluator.parser.parse(this.endrot);this.inirotM=new a.Mat4;this.inirotM_X=
new a.Mat4;this.inirotM_Y=new a.Mat4;this.inirotM_Z=new a.Mat4;this.iniposM=new a.Mat4;this.endrotM=new a.Mat4;this.endrotM_X=new a.Mat4;this.endrotM_Y=new a.Mat4;this.endrotM_Z=new a.Mat4;this.endposM=new a.Mat4;g=new a.Mat4;for(let n of this.graphics)n.macroChildren=!0}buildFamilyPrimitives(){k=this.evaluator;this.getFamilyValues();let w=k.getVariable(this.family);if(this.fSteps>=0)for(let q=0,n=this.fSteps;q<=n;q++)this.fVal=this.fInf+q*this.fSep,k.setVariable(this.family,this.fVal),k.eval(this.drawif)&&
this.updateMacro();k.setVariable(this.family,w)}update(){this.primitives=[];this.evaluator.eval(this.drawif)&&(this.family||this.updateMacro());this.family&&this.buildFamilyPrimitives()}updateMacro(){this.updateTransformation();if(this.inipos){var w=this.evaluator.eval(this.inipos)[0];this.iniPosX=w[0];this.iniPosY=w[1]}for(var q of this.graphics)q.macro_inirotEuler=this.inirotEuler,q.macro_inirotM=this.inirotM,q.macro_inirotM_X=this.inirotM_X,q.macro_inirotM_Y=this.inirotM_Y,q.macro_inirotM_Z=this.inirotM_Z,
q.macro_iniposM=this.iniposM,q.macro_endrotEuler=this.endrotEuler,q.macro_endrotM=this.endrotM,q.macro_endrotM_X=this.endrotM_X,q.macro_endrotM_Y=this.endrotM_Y,q.macro_endrotM_Z=this.endrotM_Z,q.macro_endposM=this.endposM,q.update();for(let n=0,p=this.graphics.length;n<p;n++){w=this.graphics[n];if(w.split||this.split)for(q=n+1;q<p;q++){let r=this.graphics[q];(r.split||this.split)&&w.splitFace(r)}this.primitives=this.primitives.concat(w.primitives||[])}}updateTransformation(){d=this.evaluator.eval(this.inirot)[0];
this.inirotEuler?(this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(b(d[0])),this.inirotM=this.inirotM.rotateX(b(d[1])),this.inirotM=this.inirotM.rotateZ(b(d[2]))):(g.setIdentity(),g.rotateX(b(d[0]),this.inirotM_X),g.rotateY(b(d[1]),this.inirotM_Y),g.rotateZ(b(d[2]),this.inirotM_Z));d=this.evaluator.eval(this.inipos)[0];this.iniposM=this.iniposM.setIdentity().translate({x:d[0],y:d[1],z:d[2]});d=this.evaluator.eval(this.endrot)[0];this.endrotEuler?(this.endrotM.setIdentity(),this.endrotM=
this.endrotM.rotateZ(b(d[0])),this.endrotM=this.endrotM.rotateX(b(d[1])),this.endrotM=this.endrotM.rotateZ(b(d[2]))):(g.setIdentity(),g.rotateX(b(d[0]),this.endrotM_X),g.rotateY(b(d[1]),this.endrotM_Y),g.rotateZ(b(d[2]),this.endrotM_Z));d=this.evaluator.eval(this.endpos)[0];this.endposM=this.endposM.setIdentity().translate({x:d[0],y:d[1],z:d[2]})}drawAux(w){}}a.Macro3D=l})(descartesJS);
(a=>{const k=2*Math.PI,g=Math.sqrt(3);let d,b,e,l,w,q,n,p,r,t;class c extends a.Graphic3D{constructor(F,y){super(F,y);this.width=this.width||F.evaluator.parser.parse("2");this.height=this.height||F.evaluator.parser.parse("2");this.length=this.length||F.evaluator.parser.parse("2");this.R=this.R||F.evaluator.parser.parse("2");this.r=this.r||F.evaluator.parser.parse("1");d=a.Vec4D}buildPrimitives(){b=this.evaluator;this.updateMVMatrix();this.buildGeometry(b.eval(this.width),b.eval(this.height),b.eval(this.length),
b.eval(this.Nu),b.eval(this.Nv));let F=this.color.getColor(),y=this.backcolor.getColor(),H=this.edges?this.edges.getColor():"";for(let C of this.faces){e=[];for(let D of C)e.push(this.transformVertex(this.V[D]));this.primitives.push(new a.Primitive3D({V:e,type:"face",frontColor:F,backColor:y,edges:H,model:this.model},this.space))}}changeGeometry(F,y,H,C,D){return this.oldW==F&&this.oldH==y&&this.oldL==H&&this.oldNu==C&&this.oldNv==D}updateValues(F,y,H,C,D){this.oldW=F;this.oldH=y;this.oldL=H;this.oldNv=
D;this.oldNu=C}}class f extends c{constructor(F,y){super(F,y);this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]]}buildGeometry(F,y,H,C,D){F/=2;y/=2;H/=2;this.changeGeometry(F,y,H,C,D)||(this.V=[new d(F,H,y),new d(F,-H,y),new d(F,H,-y),new d(F,-H,-y),new d(-F,H,y),new d(-F,-H,y),new d(-F,H,-y),new d(-F,-H,-y)],this.updateValues(F,y,H,C,D))}}class m extends f{constructor(F,y){super(F,y)}buildGeometry(F,y,H,C,D){y=F/g;super.buildGeometry(y,y,y,C,D)}}class v extends c{constructor(F,
y){super(F,y);this.faces=[[1,3,2],[0,1,2],[0,2,3],[0,3,1]]}buildGeometry(F,y,H,C,D){F/=2;if(!this.changeGeometry(F,y,H,C,D)){var J=k/3,N=Math.cos(J),Z=Math.sin(J);J=F*2*Math.sqrt(2)/3;var ba=-F/3,ca=J*N+0*Z;N=-J*Z+0*N;this.V=[new d(0,0,F),new d(ca,N,ba),new d(ca,-N,ba),new d(J,0,ba)];this.updateValues(F,y,H,C,D)}}}class h extends c{constructor(F,y){super(F,y);this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]]}buildGeometry(F,y,H,C,D){F/=2;this.changeGeometry(F,y,H,C,D)||
(this.V=[new d(0,0,F),new d(F,0,0),new d(-F,0,0),new d(0,F,0),new d(0,-F,0),new d(0,0,-F)],this.updateValues(F,y,H,C,D))}}class u extends c{constructor(F,y){super(F,y)}buildGeometry(F,y,H,C,D){F/=2;y/=2;H/=2;if(!this.changeGeometry(F,y,H,C,D)){this.V=[new d(0,0,y)];for(var J=1;J<C;J++){w=J*Math.PI/C;for(var N=0;N<D;N++)l=N*k/D,this.V.push(new d(F*Math.sin(w)*Math.cos(l),H*Math.sin(w)*Math.sin(l),y*Math.cos(w)))}this.V.push(new d(0,0,-y));this.faces=[];for(J=0;J<D;J++)this.faces.push([0,(J+1)%D+1,
J%D+1]);for(J=1;J<C-1;J++)for(N=0;N<D;N++)this.faces.push([N+1+(J-1)*D,(N+1)%D+1+(J-1)*D,(N+1)%D+1+J*D,N+1+J*D]);for(J=0;J<D;J++)this.faces.push([this.V.length-1,this.V.length-1-D+J,this.V.length-1-D+(J+1)%D]);this.updateValues(F,y,H,C,D)}}}class x extends u{constructor(F,y){super(F,y)}buildGeometry(F,y,H,C,D){super.buildGeometry(F,F,F,C,D)}}class z extends c{constructor(F,y){super(F,y);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,4,14,12,0],[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],
[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]]}buildGeometry(F,y,H,C,D){F/=Math.PI;if(!this.changeGeometry(F,y,H,C,D)){p=F/1.6180339887;r=F*1.6180339887;this.V=[new d(F,F,F),new d(F,F,-F),new d(F,-F,F),new d(F,-F,-F),new d(-F,F,F),new d(-F,F,-F),new d(-F,-F,F),new d(-F,-F,-F),new d(0,p,r),new d(0,p,-r),new d(0,-p,r),new d(0,-p,-r),new d(p,r,0),new d(p,-r,0),new d(-p,r,0),new d(-p,-r,0),new d(r,0,p),new d(r,0,-p),new d(-r,0,p),new d(-r,0,-p)];t=(new a.Mat4).setIdentity().rotateY(-Math.PI/
6);for(let J=0,N=this.V.length;J<N;J++)this.V[J]=t.mulV4(this.V[J]);this.updateValues(F,y,H,C,D)}}}class G extends c{constructor(F,y){super(F,y);this.faces=[[10,0,2],[0,8,2],[8,5,2],[5,7,2],[7,10,2],[6,0,10],[11,6,10],[7,11,10],[7,3,11],[5,3,7],[9,3,5],[8,9,5],[4,9,8],[0,4,8],[6,4,0],[11,3,1],[6,11,1],[4,6,1],[9,4,1],[3,9,1]]}buildGeometry(F,y,H,C,D){F/=3.8;if(!this.changeGeometry(F,y,H,C,D)){r=F*1.6180339887;this.V=[new d(0,F,r),new d(0,F,-r),new d(0,-F,r),new d(0,-F,-r),new d(F,r,0),new d(F,-r,
0),new d(-F,r,0),new d(-F,-r,0),new d(r,0,F),new d(r,0,-F),new d(-r,0,F),new d(-r,0,-F)];t=(new a.Mat4).setIdentity().rotateY(-1.0285);for(let J=0,N=this.V.length;J<N;J++)this.V[J]=t.mulV4(this.V[J]);this.updateValues(F,y,H,C,D)}}}class A extends c{constructor(F,y){super(F,y)}buildGeometry(F,y,H,C,D){F/=2;y/=2;H/=2;if(!this.changeGeometry(F,y,H,C,D)){this.V=[];for(var J=0;J<D;J++)for(var N=0;N<C;N++)this.V.push(new d(F*(D-J)/D*Math.cos(N*k/C),H*(D-J)/D*Math.sin(N*k/C),y-J*2*y/D));this.V.push(new d(0,
0,-y));this.faces=[];for(J=0;J<D-1;J++)for(N=0;N<C;N++)this.faces.push([N+J*C,(N+1)%C+J*C,(N+1)%C+(J+1)*C,N+(J+1)*C]);for(J=0;J<C;J++)this.faces.push([this.V.length-1,this.V.length-1-C+J,this.V.length-1-C+(J+1)%C]);this.updateValues(F,y,H,C,D)}}}class I extends c{constructor(F,y){super(F,y)}buildGeometry(F,y,H,C,D){F/=2;y/=2;H/=2;if(!this.changeGeometry(F,y,H,C,D)){this.V=[];for(var J=0;J<D+1;J++)for(var N=0;N<C;N++)this.V.push(new d(F*Math.cos(N*k/C),H*Math.sin(N*k/C),y-J*2*y/D));this.faces=[];for(J=
0;J<D;J++)for(N=0;N<C;N++)this.faces.push([N+J*C,(N+1)%C+J*C,(N+1)%C+(J+1)*C,N+(J+1)*C]);this.updateValues(F,y,H,C,D)}}}class S extends c{constructor(F,y){super(F,y)}buildGeometry(F,y,H,C,D){F/=2;y/=2;H/=2;q=b.eval(this.R);n=b.eval(this.r);if(!this.changeGeometry(F,y,H,C,D)){this.V=[];for(var J=0;J<D+1;J++)for(var N=0;N<C;N++)this.V.push(new d(-(q+n*Math.sin(k*N/C))*Math.sin(k*J/D),(q+n*Math.sin(k*N/C))*Math.cos(k*J/D),n*Math.cos(k*N/C)));this.faces=[];for(J=0;J<D;J++)for(N=0;N<C;N++)this.faces.push([N+
J*C,N+(J+1)*C,(N+1)%C+(J+1)*C,(N+1)%C+J*C]);this.updateValues(F,y,H,C,D)}}}a.OtherGeometry3D=c;a.Cube3D=m;a.Box3D=f;a.Tetrahedron3D=v;a.Octahedron3D=h;a.Sphere3D=x;a.Ellipsoid3D=u;a.Dodecahedron3D=z;a.Icosahedron3D=G;a.Cone3D=A;a.Cylinder3D=I;a.Torus3D=S})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r;class t{constructor(c,f){this.parent=c;this.evaluator=c.evaluator;let m=this.parser=c.evaluator.parser;this.id=f.type!=="GraphicControl"?"C":"G";this.region="south";this.x=this.y=0;this.w=f.type!=="Video"?100:350;this.h=f.type!=="Video"?23:120;this.keyboard=!1;this.kblayout="1x16";f.type!=="GraphicControl"&&f.type!=="Audio"&&f.type!=="Video"?f.type!=="TextArea"?this.expresion=m.parse("(0,0,100,23)"):(this.expresion=m.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=
m.parse("(0,0)");this.fixed=this.visible=!0;this.color="222222";this.colorInt="cc0022";f.gui=="Scrollbar"?(this.colorInt="182C61",this.color="e0e4e8"):f.type!=="GraphicControl"&&(this.colorInt="f0f8ff");this.color=new a.Color(this.color);this.colorInt=new a.Color(this.colorInt);f.gui=="Menu"&&(this.color=new a.Color("ffffff"),this.colorInt=new a.Color("000000"));this.font_size=m.parse("0");this.type=this.gui=this.bold=this.italics=this.underlined=this.action=this.param=this.tooltip=this.Explanation=
this.msg_pos=this.cID="";this.paramFont=this.tooltipFont=this.ExplanationFont="Monospace 12px";this.drawif=this.activeif=m.parse("1");this.valueExpr=m.parse("0");this.decimals=m.parse("2");this.min=m.parse("-Infinity");this.max=m.parse("Infinity");this.incr=m.parse("0.1");this.discrete=this.exponentialif=!1;this.zIndex=-1;Object.assign(this,f);/Video|Audio/.test(this.type)&&(this.region="interior");this.name==void 0&&(this.name=this.parent.version==2?this.id:"_nada_");this.name=["_._","_nada_","_void_"].includes(this.name.trim())?
"":this.name;f=this.evaluator.eval(this.expresion)[0];this.x=Math.round(f[0]);this.y=Math.round(f[1]);f.length==4&&(this.w=Math.round(f[2]),this.h=Math.round(f[3]));this.actionExec=c.lessonParser.parseAction(this)}init(){}update(){}draw(){}getContainer(){let c=this.parent.spaces;if(this.region=="interior")for(let f of c){if(f.id==this.spaceID)return f.addCtr(this),this.zIndex=f.zIndex,this.space=f,f.numCtrContainer}else{if(this.region=="external")return this.parent.externalSpace.addCtr(this),this.parent.externalSpace.container;
if(this.region=="scenario")return this.cID?(this.expresion=this.evaluator.parser.parse(`(0,-1000,${this.w},${this.h})`),this.parent.stage.stageSpace.addCtr(this),this.zIndex=this.parent.stage.stageSpace.zIndex,this.parent.stage.stageSpace.numCtrContainer):this.parent.externalSpace.container;if(["north","south","east","west"].includes(this.region))return this.parent[this.region+"Space"].controls.push(this),this.parent[this.region+"Space"].container}c[0].addCtr(this);this.zIndex=c[0].zIndex;return c[0].numCtrContainer}addControlContainer(c){this.getContainer().appendChild(c)}updatePositionAndSize(){k=
g=d=b=!1;e=this.evaluator.eval(this.expresion)[0];l=Math.round(e[0]);k=Math.round(this.x)!==l;this.x=l;l=Math.round(e[1]);g=Math.round(this.y)!==l;this.y=l;e.length==4&&(l=Math.round(e[2]),d=Math.round(this.w)!==l,this.w=l,l=Math.round(e[3]),b=Math.round(this.h)!==l,this.h=l);if(d||b||k||g)this.init(!0,!0),this.draw()}formatValue(c){r=this.parent;w=""+c;q=this.evaluator.eval(this.decimals);n=w.indexOf(".");n!=-1&&(p=w.slice(n+1),p.length>q&&(w=parseFloat(w).toFixed(q)));this.fixed&&(r.version!==2||
r.version==2&&!this.exponentialif)&&(w=parseFloat(c).toFixed(q));this.exponentialif&&parseFloat(w)!=0&&(w=parseFloat(w).toExponential(this.fixed&&r.version!=2?q:void 0),w=w.toUpperCase().replace("+",""));return w.replace(".",r.decimal_symbol)}updateAndExecAction(){r=this.parent;r.updateControls();this.action=="init"&&(this.click=!1);this.actionExec.execute();r.updateControls();this.action!=="animate"&&r.update();r.updateControls()}}a.Control=t})(descartesJS);
(a=>{let k,g,d,b,e,l,w;class q extends a.Control{constructor(n,p){super(n,p);this.label_color=this.label_color||new a.Color("e0e4e8",n.evaluator);this.label_text_color=this.label_text_color||new a.Color("000000",n.evaluator);this.orientation=this.w>=this.h?"h":"v";this.ratio=n.ratio;this.container=a.newHTML("div",{id:this.id});this.field=a.newHTML("input",{type:"text"});this.label=a.newHTML("canvas",{});this.label_ctx=this.label.getContext("2d");this.cover=a.newHTML("div",{class:"TextfieldCover"});
this._addInteractiveElements();this.container.appendChild(this.label);this.container.appendChild(this.field);this.keyboard&&this.visible&&this.container.appendChild(this.cover);this.addControlContainer(this.container);this.addEvents()}init(){k=this.evaluator;this.value=this.validateValue(k.eval(this.valueExpr));d=this.formatValue(this.value);g=this.evaluator.eval(this.expresion)[0];this.x=g[0];this.y=g[1];g.length==4&&(this.w=g[2],this.h=g[3]);this.orientation=this.w>=this.h?"h":"v";this.initializeLayout(d);
this.updateControlPosition();this.prePos=this.pos;k.setVariable(this.id,this.value)}initializeLayout(n){k=this.evaluator;var p=this.orientation=="v"?parseInt(19+5*(this.h-100)/100):this.h;this.fieldFontSize=k.eval(this.font_size)>0?k.eval(this.font_size):this.orientation=="v"?p-parseInt(this.h/20)-1:a.getFieldFontSize(p);this.text_object=new a.TextObject({parent:{decimal_symbol:this.parent.decimal_symbol},evaluator:this.evaluator,decimals:this.decimals,fixed:!1,align:"left",anchor:"center_center",
width:this.parser.parse("0"),font_size:this.parser.parse(""+this.fieldFontSize),font_family:this.font_family,italics:this.italics,bold:this.bold},this.name);let r=this.text_object.getTextMetrics(this.label_ctx).w;n=a.getTextWidth(n+"_",this.fieldFontSize+"px "+a.sansserif_font);this.labelHeight=r==0?0:p;this.fieldHeight=this.visible==""?0:p;if(this.orientation=="v")p=this.parent.getSpaceById(this.spaceID).h,this.canvasWidth=this.w,this.canvasHeight=this.h-this.labelHeight-this.fieldHeight,this.canvasHeight+
this.y-p>=18&&(this.canvasHeight=p),p=this.fieldHeight+this.canvasHeight,this.canvasX=0,this.canvasY=this.fieldHeight,this.labelWidth=this.w,this.labelY=p,this.fieldWidth=this.w,this.fieldX=0;else{this.labelWidth=r+parseInt(this.fieldFontSize);this.fieldWidth=n;r==0&&(this.labelWidth=0);this.visible||(this.fieldWidth=0);for(p=this.w-this.fieldWidth-this.labelWidth;p<58&&this.labelWidth>0;)this.labelWidth--,p++;for(;p<58&&this.fieldWidth>0;)this.fieldWidth--,p++;this.fieldWidth=this.w-(this.labelWidth+
p);this.canvasWidth=p;this.canvasHeight=this.h;this.canvasX=this.labelWidth;this.canvasY=0;this.fieldX=this.canvasWidth+this.labelWidth;this.labelHeight=this.h;this.labelY=0}this.container.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};`);this.field.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${this.fieldWidth}px;height:${this.fieldHeight}px;left:${this.fieldX}px;top:0;`);this.cover.setAttribute("style",`width:${this.fieldWidth}px;height:${this.fieldHeight}px;left:${this.fieldX}px;top:0;`);
this.fieldHeight==0&&(this.field.style.display="none");this.label.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${this.labelWidth}px;height:${this.labelHeight}px;line-height:${this.labelHeight}px;left:0;top:${this.labelY}px;background-color:${this.label_color.getColor()};color:${this.label_text_color.getColor()};`);this.label.width=this.labelWidth*this.ratio;this.label.height=this.labelHeight*this.ratio;this.field.id=this.id+"field"}update(){k=this.evaluator;this.activeIfValue=k.eval(this.activeif)>
0;this.drawIfValue=k.eval(this.drawif)>0;this.field.disabled=!this.activeIfValue;if(this.drawIfValue){this.container.style.display="block";this.draw();this.updatePositionAndSize();var n=this.validateValue(k.getVariable(this.id));n==this.value||Math.abs(n-this.value)>0&&Math.abs(n-this.value)<1E-9||(this.value=n,this.updateControlPosition(),this.prePos=this.pos);this.value=n;this.field.value=this.formatValue(this.value);k.setVariable(this.id,this.value);this.label_ctx.setTransform(this.ratio,0,0,this.ratio,
0,0);this.label_ctx.clearRect(0,0,this.label.width,this.label.height);(w=this.label_color.getColor())&&/CanvasGradient|CanvasPattern/.test(w.constructor.name)&&(this.label_ctx.fillStyle=w,this.label_ctx.fillRect(0,0,this.label_ctx.canvas.width,this.label_ctx.canvas.height));this.text_object.getTextMetrics(this.label_ctx).w>this.label.width/this.ratio?(this.text_object.anchor="center_left",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),5,this.label.height/this.ratio/2)):(this.text_object.anchor=
"center_center",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),this.label.width/this.ratio/2,this.label.height/this.ratio/2));this.label_ctx.setTransform(1,0,0,1,0,0)}else this.container.style.display="none"}validateValue(n){k=this.evaluator;b=parseFloat((""+n).replace(this.parent.decimal_symbol,"."));isNaN(b)&&(b=0);this.minimo=k.eval(this.min);b<this.minimo&&(this.value=null,b=this.minimo);this.maximo=k.eval(this.max);b>this.maximo&&(this.value=null,b=this.maximo);e=this.incr;
e!=0&&(b=Math.round(b/e)*e);this.fixed&&(b=parseFloat(parseFloat(b).toFixed(k.eval(this.decimals))));return b}changeValue(n){this.activeIfValue&&(l=this.validateValue(n),l!=this.value&&(this.value=l,this.field.value=this.formatValue(l),this.updateControlPosition(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value)),this.updateAndExecAction())}addEvents(){this.field.addEventListener("keydown",n=>{n.keyCode==13&&this.changeValue(this.field.value)});this.field.addEventListener("blur",
()=>{this.drawIfValue&&this.changeValue(this.field.value,!0)});this.cover.addEventListener("click",()=>{if(this.activeIfValue){let n=this.evaluator.eval(this.kbexp);this.parent.keyboard.show(this,this.kblayout,n[0][0]||0,n[0][1]||0,this.id,this.field,this.onlyText)}});this._addEvents()}_addInteractiveElements(){}_addEvents(){}draw(){}updateControlPosition(){}}a.ScrollbarSliderBase=q})(descartesJS);
(a=>{let k=/[\w\.\-//]*(\.gif)/gi,g=/CanvasGradient|CanvasPattern/;class d extends a.Control{constructor(b,e){super(b,e);this.isPointerDown=this.isPointerOver=!1;this.ratio=b.ratio;this.flat=e.flat||!1;this.text_align=(e.text_align||"center_center").split("_");this.image_align=(e.image_align||"center_center").split("_");this.font_family=a.getFontName(e.font_family||"arial");b=(e.imageSrc||"").trim();b.startsWith("_STYLE_")&&(this.extra_style=b.slice(8),b="vacio.gif");b.startsWith("_COLORES_")&&(b=
b.split("_"),this.colorInt=new a.Color(b[2]),this.color=new a.Color(b[3]),this.font_size=this.parser.parse(b[5]),b="");/^\[.*\]$/.test(b)?this.imageSrc=this.parser.parse(b.slice(1,-1)):this.imageSrc=this.parser.parse(`'${b}'`);if(this.extra_style=e.extra_style||""){this.customStyle=!0;this.btnStyle=[];this.conStyleArray=[];this.conStyle={textBorder:3};let l;for(let w of this.extra_style.split("|"))if(b=w.split("="),b.length==2)switch(e=b[0].trim(),b=b[1].trim(),l=b.includes("rgb")?"":"#",e){case "class":this.cssClass=
` ${b}`;break;case "border":this.btnStyle.push({type:"border-style",value:"solid"});this.btnStyle.push({type:"border-width",value:`${b}px`});break;case "borderRadius":this.btnStyle.push({type:"border-radius",value:`${b}px`});this.conStyleArray.push({type:"border-radius",value:`${b}px`});break;case "borderColor":this.btnStyle.push({type:"border-color",value:l+b});break;case "overColor":case "downColor":case "inactiveColor":case "inactiveColorBorder":case "shadowTextColor":case "shadowBoxColor":case "shadowInsetBoxColor":this.conStyle[e]=
l+b;break;case "font":this.conStyle[e]=b.toLowerCase();break;case "shadowTextBlur":case "shadowTextOffsetX":case "shadowTextOffsetY":case "shadowBoxBlur":case "shadowBoxOffsetX":case "shadowBoxOffsetY":case "shadowInsetBoxBlur":case "shadowInsetBoxOffsetX":case "shadowInsetBoxOffsetY":case "textBorder":case "imgSizeW":case "imgSizeH":this.conStyle[e]=parseFloat(b)||0;break;case "flat":this.flat=parseInt(b)==1}}else this.conStyle={};this.borderColor&&(this.borderColor=new a.Color(this.borderColor));
this.font_size==-1&&(this.noFSize=!0);this.container=a.newHTML("div",{class:"DescartesButtonContainer"+(this.cssClass?` ${this.cssClass} `:""),id:this.id,style:`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};`});this.btn=a.newHTML("canvas",{width:this.w*this.ratio,height:this.h*this.ratio,class:"DescartesButton",style:`left:0;top:0;width:${this.w}px;height:${this.h}px;touch-action:none;`});this.ctx=this.btn.getContext("2d");this.ctx.imageSmoothingEnabled=
!1;this.tooltip&&(this.btn.title=this.tooltip);this.container.appendChild(this.btn);this.addControlContainer(this.container);this._loadImages();this.addEvents();this.previousState={};this.init()}_loadImages(){var b=(""+this.evaluator.eval(this.imageSrc)).trim();if(b)if(this.image=this.imageOver=this.imageDown=null,/vacio.gif$/i.test(b))this.image={ready:!0,isVacio:!0};else{this.image=this.parent.getImage(b);let e=b.lastIndexOf("."),l=b.slice(0,e);b=b.slice(e);l&&(this.imageOver=this.parent.getImage(`${l}_over${b}`),
this.imageDown=this.parent.getImage(`${l}_down${b}`))}}init(b){let e=this.evaluator.eval(this.expresion)[0];this.x=e[0];this.y=e[1];e.length==4&&(this.w=parseInt(e[2]),this.h=parseInt(e[3]));this.noFSize&&(this.font_size=this.parser.parse(""+a.getFieldFontSize(this.h)));this.fs_evaluated=this.evaluator.eval(this.font_size);this.text_object=new a.TextObject({parent:{decimal_symbol:this.parent.decimal_symbol},evaluator:this.evaluator,decimals:this.decimals,fixed:!1,align:"left",anchor:"center_center",
width:this.parser.parse("0"),font_size:this.font_size,font_family:this.font_family,italics:this.italics,bold:this.bold,border:this.borderColor,border_size:this.conStyle?this.conStyle.textBorder:void 0,shadowBlur:this.conStyle&&this.conStyle.shadowTextColor?this.conStyle.shadowTextBlur||1:void 0,shadowOffsetX:this.conStyle&&this.conStyle.shadowTextColor?this.conStyle.shadowTextOffsetX||0:void 0,shadowOffsetY:this.conStyle&&this.conStyle.shadowTextColor?this.conStyle.shadowTextOffsetY||2:void 0,shadowColor:this.conStyle&&
this.conStyle.shadowTextColor?this.conStyle.shadowTextColor:void 0},this.name);this.btn.width=this.w*this.ratio;this.btn.height=this.h*this.ratio;this.btn.setAttribute("style",`position:absolute;left:0;top:0;width:${this.w}px;height:${this.h}px;box-sizing:border-box;touch-action:none;`);this.container.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};`);if(this.btnStyle)for(let {type:l,value:w}of this.btnStyle)this.btn.style[l]=w;if(this.conStyleArray)for(let {type:l,
value:w}of this.conStyleArray)this.container.style[l]=w;this.conStyle&&(this.conStyle.shadowBoxColor&&(this.container.style.boxShadow=`${this.conStyle.shadowBoxOffsetX||0}px ${this.conStyle.shadowBoxOffsetY||2}px ${this.conStyle.shadowBoxBlur||2}px 1px ${this.conStyle.shadowBoxColor}`),this.conStyle.shadowInsetBoxColor&&(this.btn.style.boxShadow=`${this.conStyle.shadowInsetBoxOffsetX||0}px ${this.conStyle.shadowInsetBoxOffsetY||-2}px ${this.conStyle.shadowInsetBoxBlur||1}px 1px ${this.conStyle.shadowInsetBoxColor} inset`));
this.draw(b)}update(){this.activeIfValue=this.evaluator.eval(this.activeif)>0;this.drawIfValue=this.evaluator.eval(this.drawif)>0;let b=(this.space?this.space.drawIfValue:!0)&&this.drawIfValue;this.container.style.display=b?"block":"none";b?(this.draw(),this.container.style.cursor=this.btn.style.cursor=this.activeIfValue?"pointer":"not-allowed",this.container.setAttribute("active",this.activeIfValue),this.updatePositionAndSize()):this.isPointerDown=!1}_isRedrawRequired(b){let e=this.previousState;
for(let l in b)if(b[l]!==e[l])return!0;return!1}draw(b){var e=this.colorInt.getColor(),l=this.color.getColor(),w=(""+this.evaluator.eval(this.imageSrc)).trim();e={name:this.text_object.updateTextStr(),imageSrc:w,backColor:e,textColor:l,isPointerOver:this.isPointerOver,isPointerDown:this.isPointerDown,activeIfValue:this.activeIfValue,imageReady:this.image?this.image.ready:!1};var q=this._isRedrawRequired(e);this.previousState=e;if(b||q){this._loadImages();this.ctx.clearRect(0,0,this.btn.width,this.btn.height);
this.ctx.save();this.ctx.setTransform(this.ratio,0,0,this.ratio,0,0);this.container.removeAttribute("grad");var n=this.isPointerDown?1:0;b=this.text_object.getTextMetrics(a.ctx);var p,r;this.text_align[1]=="center"?p=Math.floor(this.w/2+n)-.5:this.text_align[1]=="left"?p=b.w/2+5+n:this.text_align[1]=="right"&&(p=this.w-b.w/2-5+n);this.text_align[0]=="center"?r=Math.floor(this.h/2+n)-.5:this.text_align[0]=="top"?r=b.h/2+4+n:this.text_align[0]=="bottom"&&(r=this.h-b.h/2-3+n);var t,c;e=this.conStyle&&
this.conStyle.imgSizeW||(this.image?this.image.width:0);q=this.conStyle&&this.conStyle.imgSizeH||(this.image?this.image.height:0);this.image_align[1]=="center"?t=Math.floor((this.w-e)/2)+n:this.image_align[1]=="left"?t=n:this.image_align[1]=="right"&&(t=this.w-e+n);this.image_align[0]=="center"?c=Math.floor((this.h-q)/2)+n:this.image_align[0]=="top"?c=n:this.image_align[0]=="bottom"&&(c=this.h-q+n);n=this.image&&this.image.ready;var f=this.colorInt.getColor();if(!n||this.image_align[0]!=="center"||
this.image_align[1]!=="center"||this.customStyle&&this.image.isVacio)f&&g.test(f.constructor.name)?(this.ctx.fillStyle=f,this.ctx.fillRect(0,0,this.w,this.h)):this.container.style.backgroundColor=f;n?this.image.complete?w.match(k)?(this.btn.style.backgroundRepeat="no-repeat",this.btn.style.backgroundImage=`url('${w}')`,this.btn.style.backgroundPosition=`${t}px ${c}px`):this.ctx.drawImage(this.image,0,0,this.image.width,this.image.height,t,c,e,q):this.image.isVacio&&(this.container.style.backgroundColor=
"transparent"):n||this.flat||this.isPointerDown||(this.drawLine(this.ctx,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,0.5)"),this.drawLine(this.ctx,0,0,0,this.h,"rgba(0,0,0,0.09)"),this.drawLine(this.ctx,1,0,1,this.h,"rgba(0,0,0,0.03)"),this.container.setAttribute("grad","true"));this.activeIfValue&&(this.isPointerOver&&(this.imageOver&&this.imageOver.ready&&this.imageOver.complete?(e=w.replace(/(\.\w+)$/,"_over$1"),e.match(k)?this.btn.style.backgroundImage=`url('${e}')`:this.ctx.drawImage(this.imageOver,
t,c)):this.customStyle&&this.conStyle.overColor&&(this.container.style.backgroundColor=this.conStyle.overColor)),this.isPointerDown&&(this.imageDown&&this.imageDown.ready&&this.imageDown.complete?(w=w.replace(/(\.\w+)$/,"_down$1"),w.match(k)?this.btn.style.backgroundImage=`url('${w}')`:this.ctx.drawImage(this.imageDown,t,c)):this.customStyle&&this.conStyle.downColor?this.container.style.backgroundColor=this.conStyle.downColor:this.image||this.flat||(this.container.setAttribute("grad","true"),this.ctx.fillStyle=
"rgba(0,0,0,0.09)",this.ctx.fillRect(0,0,this.w,this.h))));this.ctx.font=`${this.italics} ${this.bold} ${this.fs_evaluated}px ${this.font_family}`;this.ctx.fillStyle=l;this.customStyle&&this.conStyle.shadowTextColor&&this.conStyle.textBorder>0?(this.ctx.lineWidth=this.conStyle.textBorder,this.ctx.strokeStyle=this.conStyle.shadowTextColor):this.borderColor&&(this.ctx.lineWidth=parseInt(this.fs_evaluated/6),this.ctx.strokeStyle=this.borderColor.getColor());this.text_object.draw(this.ctx,l,p,r);this.underlined&&
(this.ctx.strokeStyle=l,this.ctx.lineWidth=Math.floor(this.fs_evaluated*.1)||2,this.ctx.lineCap="round",l=this.isPointerDown?1:0,r=r+Math.floor(this.fs_evaluated/2)+Math.floor(this.fs_evaluated/5)-1.5,this.ctx.beginPath(),this.ctx.moveTo(p-b.w/2+l,r),this.ctx.lineTo(p+b.w/2+l,r),this.ctx.stroke());this.activeIfValue||(this.customStyle&&this.conStyle.inactiveColor?this.container.style.backgroundColor=this.conStyle.inactiveColor:(this.ctx.fillStyle="rgba(240,240,240,0.6)",this.ctx.fillRect(0,0,this.w,
this.h)));this.ctx.restore()}}drawLine(b,e,l,w,q,n="#000",p=1){b.lineWidth=p;b.strokeStyle=n;n=b.lineWidth%2*.5;b.beginPath();b.moveTo(Math.floor(e)+n,Math.floor(l)+n);b.lineTo(Math.floor(w)+n,Math.floor(q)+n);b.stroke()}addEvents(){let b=null,e=w=>{a.clearTimeout(b);this.isPointerDown&&this.drawIfValue&&this.activeIfValue&&(this.updateAndExecAction(),b=a.setTimeout(()=>{e(!1)},w?1E3:100))};this.btn.addEventListener("pointerdown",w=>{this.parent.deactivateControls();this.btn.focus();this.btn.setPointerCapture(w.pointerId);
a.preventDefault(w);document.activeElement!=document.body&&document.activeElement.blur();this.whichBtn=a.whichBtn(w);this.whichBtn=="L"&&this.activeIfValue&&(this.isPointerDown=!0,this.draw(),this.action=="calculate"&&(this.evaluator.setVariable(this.id,this.evaluator.eval(this.valueExpr)),e(!0)))});let l=w=>{a.newBlobContent=null;this.btn.focus();this.btn.releasePointerCapture(w.pointerId);a.preventDefault(w);this.isPointerDown&&this.action!=="calculate"&&(this.evaluator.setVariable(this.id,this.evaluator.eval(this.valueExpr)),
this.updateAndExecAction());this.isPointerDown=!1;a.clearTimeout(b);this.draw()};this.btn.addEventListener("pointerup",l);this.btn.addEventListener("pointerleave",w=>{this.isPointerOver=!1;l(w)});this.btn.addEventListener("pointerenter",w=>{a.preventDefault(w);this.isPointerOver=!0;this.draw()});document.addEventListener("visibilitychange",()=>{a.newBlobContent=null;this.isPointerDown=!1;a.clearTimeout(b)})}}a.Button=d})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t,c;class f extends a.Control{constructor(m,v){super(m,v);this.flat=this.image_dec_src&&this.image_inc_src;this.btn_pos=this.btn_pos||"v_left";this.horizontal=this.btn_pos=="h_left"||this.btn_pos=="h_right"||this.btn_pos=="h_left_right";this.label_color=this.label_color||new a.Color("e0e4e8",m.evaluator);this.label_text_color=this.label_text_color||new a.Color("000000",m.evaluator);this.tabindex=++m.tabindex;this.initial_value=0;try{this.initial_value=this.evaluator.eval(this.parser.parse(this.valueExprString))}catch(h){console.log(h)}this.container=
a.newHTML("div",{class:"DescartesSpinnerContainer",id:this.id});this.divUp=a.newHTML("div",{class:"DJS_Up"});this.divDown=a.newHTML("div",{class:"DJS_Down"});this.field=a.newHTML("input",{type:"text",id:this.id+"_spinner",class:"DescartesSpinnerField",tabindex:this.tabindex});this.label=a.newHTML("canvas",{class:"DescartesSpinnerLabel"});this.label_ctx=this.label.getContext("2d");this.ratio=m.ratio;this.container.appendChild(this.label);this.container.appendChild(this.field);this.container.appendChild(this.divUp);
this.container.appendChild(this.divDown);this.cover=a.newHTML("div",{class:"TextfieldCover"});this.keyboard&&this.visible&&this.container.appendChild(this.cover);this.addControlContainer(this.container);p=this.evaluator.parser.parse("1");this.originalIncr=this.incr;if(this.evaluator.eval(this.decimals)<0||this.evaluator.eval(this.incr)==0)m=this.evaluator.eval(this.incr),m>0?this.originalIncr=this.incr=this.evaluator.parser.parse(""+parseInt(m)):this.incr=p;this.image_dec_src&&(/^\[.*\]$/.test(this.image_dec_src)?
this.image_dec_src=this.parser.parse(this.image_dec_src.slice(1,-1)):this.image_dec_src=this.parser.parse(`'${this.image_dec_src}'`),this.old_image_dec_src=(""+this.evaluator.eval(this.image_dec_src)).trim(),this.image_dec=this.parent.getImage(this.old_image_dec_src));this.image_inc_src&&(/^\[.*\]$/.test(this.image_inc_src)?this.image_inc_src=this.parser.parse(this.image_inc_src.slice(1,-1)):this.image_inc_src=this.parser.parse(`'${this.image_inc_src}'`),this.old_image_inc_src=(""+this.evaluator.eval(this.image_inc_src)).trim(),
this.image_inc=this.parent.getImage(this.old_image_inc_src));this.addEvents();this.init()}init(m,v){k=this.evaluator;v||(this.value=this.validateValue(k.eval(this.valueExpr)));m=this.formatValue(this.value);this.fieldFontSize=k.eval(this.font_size)>0?k.eval(this.font_size):a.getFieldFontSize(this.h);this.text_object=new a.TextObject({parent:{decimal_symbol:this.parent.decimal_symbol},evaluator:k,decimals:this.decimals,fixed:!1,align:"left",anchor:"center_center",width:this.parser.parse("0"),font_size:this.parser.parse(""+
this.fieldFontSize),font_family:this.font_family,italics:this.italics,bold:this.bold},this.name);v=this.text_object.getTextMetrics(this.label_ctx).w;var h=a.getTextWidth(m+"_",`${this.fieldFontSize}px ${a.sansserif_font}`);if(this.horizontal){var u=parseInt(this.h),x=parseInt(this.w/2-u),z=v+parseInt(this.fieldFontSize);this.visible||(x=this.w-2*u,h=0);x<z&&(x=z);v==0&&(x=0);this.w-x-u<h&&(x=this.w-u-h);x<0&&(x=0);v=this.w-(x+2*u);this.container.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};background-color:transparent;`);
this.divUp.setAttribute("style",`width:${u}px;height:${u}px;${this.btn_pos=="h_left"?"left:"+(x+u):"right:0"}px;top:0;${this.flat?"border-width:0;":""}`);this.divDown.setAttribute("style",`width:${u}px;height:${u}px;left:${x+(this.btn_pos=="h_right"?v:0)}px;top:0;${this.flat?"border-width:0;":""}`);this.field.setAttribute("style",`font-family:${a.sansserif_font};font-size:${this.fieldFontSize}px;width:${v}px;height:${this.h}px;left:${u+x+(this.btn_pos=="h_left"?u:this.btn_pos=="h_right"?-u:0)}px;text-align:center;`);
this.cover.setAttribute("style",`width:${v}px;height:${this.h}px;left:${u+x+(this.btn_pos=="h_left"?u:this.btn_pos=="h_right"?-u:0)}px;text-align:center;`);this.field.value=m;this.visible||(this.field.style.display="none");this.label.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${x}px;height:${this.h}px;line-height:${this.h}px;background-color:${this.label_color.getColor()};color:${this.label_text_color.getColor()};`);this.label.width=x*this.ratio}else u=2+parseInt(this.h/2),x=parseInt(this.w/
2-u/2),z=v+parseInt(this.fieldFontSize),this.visible||(x=this.w-u,h=0),x<z&&(x=z),v==0&&(x=0),this.w-x-u<h&&(x=this.w-u-h),x<0&&(x=0),v=this.w-(x+u),this.container.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};background-color:transparent;`),h=`width:${u}px;left:${x+(this.btn_pos=="v_right"?v:0)}px;`,this.divUp.setAttribute("style",`${h};height:${this.h/2+1}px;top:0;${this.flat?"border-width:0;":""}`),this.divDown.setAttribute("style",
`${h};height:${this.h/2-1}px;top:${this.h/2+1}px;${this.flat?"border-width:0;":""}`),this.field.setAttribute("style",`font-family:${a.sansserif_font};font-size:${this.fieldFontSize}px;width:${v}px;height:${this.h}px;left:${(this.btn_pos=="v_left"?u:0)+x}px;`),this.cover.setAttribute("style",`width:${v}px;height:${this.h}px;left:${(this.btn_pos=="v_left"?u:0)+x}px;`),this.field.value=m,this.visible||(this.field.style.display="none"),this.label.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${x}px;height:${this.h}px;line-height:${this.h}px;background-color:${this.label_color.getColor()};color:${this.label_text_color.getColor()};`),
this.label.width=x*this.ratio;this.label.height=this.h*this.ratio;this.horizontal?(this.divUp.setAttribute("dir","H"),this.divDown.setAttribute("dir","H")):(this.divUp.setAttribute("dir","V"),this.divDown.setAttribute("dir","V"));this.image_dec&&this.image_dec.ready&&(this.divDown.style["background-image"]=`url(${this.image_dec.src})`,this.divDown.removeAttribute("dir"));this.image_inc&&this.image_inc.ready&&(this.divUp.style["background-image"]=`url(${this.image_inc.src})`,this.divUp.removeAttribute("dir"));
k.setVariable(this.id,this.value)}update(){k=this.evaluator;k.eval(this.decimals)<0?(g=k.eval(this.incr),g>0?this.originalIncr=this.incr=k.parser.parse(""+parseInt(g)):this.incr=p):this.incr=k.eval(this.originalIncr)!==0?this.originalIncr:p;this.activeIfValue=k.eval(this.activeif)>0;this.drawIfValue=k.eval(this.drawif)>0;this.field.disabled=!this.activeIfValue;this.divUp.setAttribute("active",!this.field.disabled);this.divDown.setAttribute("active",!this.field.disabled);this.drawIfValue?(this.updateStyle(),
this.container.style.display="block"):(this.click=!1,this.container.style.display="none");this.image_dec&&(r=(""+this.evaluator.eval(this.image_dec_src)).trim(),this.old_image_dec_src!==r&&(this.divDown.style["background-image"]=`url(${r})`,this.divDown.removeAttribute("dir"),this.old_image_dec_src=r));this.image_inc&&(t=(""+this.evaluator.eval(this.image_inc_src)).trim(),this.old_image_inc_src!==t&&(this.divUp.style["background-image"]=`url(${t})`,this.divUp.removeAttribute("dir"),this.image_inc_src=
t));this.updatePositionAndSize();this.divUp.style.setProperty("--w",this.divUp.style.getPropertyValue("width"));this.divDown.style.setProperty("--w",this.divDown.style.getPropertyValue("width"));this.parent.animation.playing&&document.activeElement==this.field||(d=this.field.value,b=this.value,this.value=this.validateValue(k.getVariable(this.id)),this.field.value=this.formatValue(this.value),this.value==b&&this.field.value!=d&&(this.value=this.validateValue(d),this.field.value=this.formatValue(this.value)),
k.setVariable(this.id,this.value));this.label_ctx.setTransform(this.ratio,0,0,this.ratio,0,0);this.label_ctx.clearRect(0,0,this.label.width,this.label.height);(c=this.label_color.getColor())&&/CanvasGradient|CanvasPattern/.test(c.constructor.name)&&(this.label_ctx.fillStyle=c,this.label_ctx.fillRect(0,0,this.label_ctx.canvas.width,this.label_ctx.canvas.height));this.text_object.getTextMetrics(this.label_ctx).w>this.label.width/this.ratio?(this.text_object.anchor="center_left",this.text_object.draw(this.label_ctx,
this.label_text_color.getColor(),5,this.label.height/this.ratio/2)):(this.text_object.anchor="center_center",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),this.label.width/this.ratio/2,this.label.height/this.ratio/2));this.label_ctx.setTransform(1,0,0,1,0,0)}updateStyle(){this.divUp.style.backgroundColor=this.flat?"transparent":this.up?"#bfbfbf":"";this.divUp.setAttribute("push",this.up);this.divDown.style.backgroundColor=this.flat?"transparent":this.down?"#bfbfbf":"";this.divDown.setAttribute("push",
this.down)}validateValue(m){k=this.evaluator;isNaN(parseFloat(m))||(""+m).includes("e")&&(m=parseFloat(m).toFixed(20));m=(m!=void 0?""+m:"0").replace(this.parent.decimal_symbol,".");e=m==parseFloat(m)?parseFloat(m):parseFloat(k.eval(k.parser.parse(m)));isNaN(e)&&(e=0);q=k.eval(this.min);n=k.eval(this.max);q===""&&(q=-Infinity);n===""&&(n=Infinity);e=Math.min(Math.max(e,q),n);this.discrete&&(l=k.eval(this.incr),e=l==0?0:this.initial_value+l*Math.round((e-this.initial_value)/l));w=k.eval(this.decimals);
w<=0&&(w=0);return e=parseFloat(parseFloat(e).toFixed(w))}increase(){this.changeValue(parseFloat(this.value)+this.evaluator.eval(this.incr))}decrease(){this.changeValue(parseFloat(this.value)-this.evaluator.eval(this.incr))}changeValue(m){this.activeIfValue&&(this.value=this.validateValue(m),this.field.value=this.formatValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())}addEvents(){function m(x,z,G){a.clearTimeout(u);if(h.up||h.down)z.call(h),x=G?x:Math.max(x-
50,25),u=a.setTimeout(function(){m(x,z)},x)}function v(){if(h.up||h.down)h.up=!1,h.down=!1,a.clearTimeout(u),h.updateStyle()}const h=this;let u;h.label.style.touchAction=h.divUp.style.touchAction=h.divDown.style.touchAction="none";h.label.addEventListener("pointerdown",a.preventDefault);h.field.addEventListener("keydown",x=>{x.keyCode==13&&h.changeValue(h.field.value)});h.divUp.addEventListener("pointerdown",function(x){a.preventDefault(x);h.whichBtn=a.whichBtn(x);h.whichBtn=="L"&&h.activeIfValue&&
(h.up=!0,m(400,h.increase,!0))});h.divDown.addEventListener("pointerdown",function(x){a.preventDefault(x);h.whichBtn=a.whichBtn(x);h.whichBtn=="L"&&h.activeIfValue&&(h.down=!0,m(400,h.decrease,!0))});h.divUp.addEventListener("pointerleave",function(x){h.up=!1;a.clearTimeout(u);a.preventDefault(x);h.updateStyle()});h.divDown.addEventListener("pointerleave",function(x){h.down=!1;a.clearTimeout(u);a.preventDefault(x);h.updateStyle()});window.addEventListener("pointerup",v);h.divUp.addEventListener("pointerup",
x=>{a.preventDefault(x);v()});h.divDown.addEventListener("pointerup",x=>{a.preventDefault(x);v()});document.addEventListener("visibilitychange",()=>{h.up=h.down=!1;a.clearTimeout(u);h.updateStyle()});h.field.addEventListener("blur",()=>{h.drawIfValue&&h.changeValue(h.field.value,!0)});h.field.addEventListener("click",x=>{x.target.focus()});h.cover.addEventListener("click",()=>{let x=h.evaluator.eval(h.kbexp);h.activeIfValue&&h.parent.keyboard.show(h,h.kblayout,x[0][0]||0,x[0][1]||0,h.id,h.field,h.onlyText)})}}
a.Spinner=f})(descartesJS);
(a=>{let k,g;class d extends a.Control{constructor(b,e){super(b,e);this.label_color=this.label_color||new a.Color("e0e4e8",b.evaluator);this.label_text_color=this.label_text_color||new a.Color("000000",b.evaluator);this.typeCtr="checkbox";this.pressed=e.pressed||!1;this.radio_group=(e.radio_group||"").trim();this.radio_group!==""&&(this.typeCtr="radio");this.tabindex=++b.tabindex;this.containerControl=a.newHTML("div",{class:"DescartesCheckboxContainer",id:this.id});this.checkbox=a.newHTML("input",
{type:this.typeCtr,id:this.id+this.typeCtr,class:"DescartesCheckbox",tabindex:this.tabindex});this.radio_group!==""&&this.checkbox.setAttribute("name",this.radio_group);this.checkbox.internalID=this.id;this.label=a.newHTML("canvas",{class:"DescartesCheckboxLabel"});this.label_ctx=this.label.getContext("2d");this.ratio=b.ratio;this.dummyLabel=a.newHTML("label",{"for":this.id+this.typeCtr});this.value=this.evaluator.eval(this.valueExpr);this.evaluator.setVariable(this.id,this.value);this.containerControl.appendChild(this.label);
this.containerControl.appendChild(this.checkbox);this.containerControl.appendChild(this.dummyLabel);this.addControlContainer(this.containerControl);this.addEvents();this.init()}init(b){k=this.evaluator;this.labelFontSize=k.eval(this.font_size)>0?k.eval(this.font_size):a.getFieldFontSize(this.h);b=Math.max(this.w-this.h,0);this.text_object=new a.TextObject({parent:{decimal_symbol:this.parent.decimal_symbol},evaluator:k,decimals:this.decimals,fixed:!1,align:"left",anchor:"center_center",width:this.parser.parse("0"),
font_size:this.parser.parse(""+this.labelFontSize),font_family:this.font_family,italics:this.italics,bold:this.bold},this.name);this.containerControl.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};`);this.position=="right"?(this.dummyLabel.setAttribute("style",`position:absolute;width:${this.h}px;height:${this.h}px;left:${b}px;`),this.checkbox.setAttribute("style",`width:${this.h}px;height:${this.h}px;left:${b}px;`),this.label.setAttribute("style",
`font-size:${this.labelFontSize}px;width:${b}px;height:${this.h}px;line-height:${this.h}px;background-color:${this.label_color.getColor()};color:${this.label_text_color.getColor()};`)):(this.dummyLabel.setAttribute("style",`position:absolute;width:${this.h}px;height:${this.h}px;left:0;`),this.checkbox.setAttribute("style",`width:${this.h}px;height:${this.h}px;left:0;`),this.label.setAttribute("style",`font-size:${this.labelFontSize}px;width:${b}px;height:${this.h}px;line-height:${this.h}px;background-color:${this.label_color.getColor()};color:${this.label_text_color.getColor()};left:${this.h}px`));
this.checkbox.checked=k.getVariable(this.id)!=0;this.label.width=b*this.ratio;this.label.height=this.h*this.ratio;this.update()}update(){k=this.evaluator;this.activeIfValue=k.eval(this.activeif)>0;this.drawIfValue=k.eval(this.drawif)>0;this.checkbox.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";if(!this.parent.animation.playing||document.activeElement!=this.checkbox){var b=k.getVariable(this.id)!==0?1:0;if(this.radio_group=="")this.pressed?(this.value=
this.checkbox.checked?1:0,this.pressed=!1):(this.value=b,this.checkbox.checked=this.value!==0),k.setVariable(this.id,this.value);else{this.value=k.getVariable(this.id);k.setVariable(this.radio_group,0);b=document.querySelectorAll(`[name=${this.radio_group}]`);var e=-1;if(this.pressed){for(e=b.length-1;e>=0;e--)k.setVariable(b[e].internalID,0),b[e].checked=!1;k.setVariable(this.id,1);this.checkbox.checked=!0;this.value=1;k.setVariable(this.radio_group,this.id);this.pressed=0}else{for(let l=b.length-
1;l>=0;l--)e=k.getVariable(b[l].internalID)!=0?l:e,k.setVariable(b[l].internalID,0),b[l].checked=!1;e>=0&&(k.setVariable(b[e].internalID,1),b[e].checked=!0,k.setVariable(this.radio_group,b[e].internalID));this.value=this.checkbox.checked?1:0}}}this.updatePositionAndSize();this.label_ctx.setTransform(this.ratio,0,0,this.ratio,0,0);this.label_ctx.clearRect(0,0,this.label.width,this.label.height);(g=this.label_color.getColor())&&/CanvasGradient|CanvasPattern/.test(g.constructor.name)&&(this.label_ctx.fillStyle=
g,this.label_ctx.fillRect(0,0,this.label_ctx.canvas.width,this.label_ctx.canvas.height));this.text_object.getTextMetrics(this.label_ctx).w>this.label.width/this.ratio?(this.text_object.anchor="center_left",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),5,this.label.height/this.ratio/2)):(this.text_object.anchor="center_center",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),this.label.width/this.ratio/2,this.label.height/this.ratio/2));this.label_ctx.setTransform(1,
0,0,1,0,0)}addEvents(){this.label.ontouchstart=this.label.onmousedown=this.dummyLabel.onmousedown=a.preventDefault;this.checkbox.addEventListener("click",()=>{this.pressed=!0;this.updateAndExecAction()})}}a.Checkbox=d})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q;class n extends a.Control{constructor(p,r){super(p,r);this.label_color=this.label_color||new a.Color("e0e4e8",p.evaluator);this.label_text_color=this.label_text_color||new a.Color("000000",p.evaluator);this.valueExprString===void 0&&(this.valueExprString=this.onlyText?"0":"");this.ok=0;this.tabindex=++p.tabindex;if(this.evaluate)if(this.answer){if(q=this.answer.match(/^krypto_(.*)$/))this.answer=(new a.Krypto).decode(q[1]);this.answer=a.answerRegEx(this.answer,this.evaluator,
this.onlyText)}else this.evaluate=!1;this.onlyText&&(/^'.*'$/.test(this.valueExprString)||(this.valueExpr=this.evaluator.parser.parse(`'${this.valueExprString}'`)),this.validateValue=function(t){t=""+t;return t=="''"||t=="'"?"":t&&/^'.*'$/.test(t)?t.slice(1,-1):t},this.formatValue=function(t){return""+t});this.containerControl=a.newHTML("div",{class:"DescartesTextFieldContainer",id:this.id});this.field=a.newHTML("input",{type:"text",id:this.id+"TextField",class:"DescartesTextFieldField",tabindex:this.tabindex});
this.label=a.newHTML("canvas",{class:"DescartesTextFieldLabel"});this.label_ctx=this.label.getContext("2d");this.ratio=p.ratio;this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.cover=a.newHTML("div",{class:"TextfieldCover"});this.keyboard&&this.containerControl.appendChild(this.cover);this.activoStr=this.id+".activo";this.activeStr=this.id+".active";this.addControlContainer(this.containerControl);this.addEvents();this.init()}init(p){k=this.evaluator;
p||(this.value=this.validateValue(k.eval(this.valueExpr)));p=this.formatValue(this.value);this.fieldFontSize=k.eval(this.font_size)>0?k.eval(this.font_size):a.getFieldFontSize(this.h);this.text_object=new a.TextObject({parent:{decimal_symbol:this.parent.decimal_symbol},evaluator:k,decimals:this.decimals,fixed:!1,align:"left",anchor:"center_center",width:this.parser.parse("0"),font_size:this.parser.parse(""+this.fieldFontSize),font_family:this.font_family,italics:this.italics,bold:this.bold},this.name);
var r=this.text_object.getTextMetrics(this.label_ctx).w,t=a.getTextWidth(p+"_",`${this.fieldFontSize}px ${a.sansserif_font}`);let c=parseInt(this.w/2),f=r+parseInt(this.fieldFontSize);this.visible||(c=this.w,t=0);c<f&&(c=f);r==0&&(c=0);this.w-c<t&&(c=this.w-t);c<0&&(c=0);r=this.w-c;this.containerControl.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};`);this.field.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${r}px;height:${this.h}px;left:${c}px; font-family:${this.font_family==
"Serif"?a.serif_font:this.font_family=="Monospaced"?a.monospace_font:a.sansserif_font};`);this.field.value=p;this.cover.setAttribute("style",`;width:${r}px;height:${this.h}px;left:${c}px;`);this.label.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${c}px;height:${this.h}px;line-height:${this.h}px;background-color:${this.label_color.getColor()};color:${this.label_text_color.getColor()};`);this.label.width=c*this.ratio;this.label.height=this.h*this.ratio;this.evaluate&&(this.ok=this.evalAnswer());
this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()}update(){k=this.evaluator;this.activeIfValue=k.eval(this.activeif)>0;this.drawIfValue=k.eval(this.drawif)>0;this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.parent.animation.playing&&document.activeElement==this.field||(g=this.field.value,d=this.value,this.value=this.validateValue(k.getVariable(this.id)),
this.field.value=this.formatValue(this.value),this.value===d&&this.field.value!=g&&(this.value=this.validateValue(g),this.field.value=this.formatValue(this.value)),k.setVariable(this.id,this.value));this.updatePositionAndSize();this.label_ctx.setTransform(this.ratio,0,0,this.ratio,0,0);this.label_ctx.clearRect(0,0,this.label.width,this.label.height);(w=this.label_color.getColor())&&/CanvasGradient|CanvasPattern/.test(w.constructor.name)&&(this.label_ctx.fillStyle=w,this.label_ctx.fillRect(0,0,this.label_ctx.canvas.width,
this.label_ctx.canvas.height));this.text_object.getTextMetrics(this.label_ctx).w>this.label.width/this.ratio?(this.text_object.anchor="center_left",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),5,this.label.height/this.ratio/2)):(this.text_object.anchor="center_center",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),this.label.width/this.ratio/2,this.label.height/this.ratio/2));this.label_ctx.setTransform(1,0,0,1,0,0)}validateValue(p){if(p===""||p=="''")return"";
k=this.evaluator;p=(""+p).replace(this.parent.decimal_symbol_regexp,".");b=p==parseFloat(p)?parseFloat(p):parseFloat(k.eval(k.parser.parse(p)));isNaN(b)&&(b=0);e=k.eval(this.min);l=k.eval(this.max);e===""&&(e=-Infinity);l===""&&(l=Infinity);b<e&&(b=e);b>l&&(b=l);this.discrete&&(p=k.eval(this.incr),b=p===0?0:p*Math.round(b/p));return b=parseFloat(parseFloat(b).toFixed(k.eval(this.decimals)))}formatValue(p){return p===""?p:super.formatValue(p)}changeValue(p){this.activeIfValue&&(this.value=this.validateValue(p),
this.field.value=this.formatValue(this.value),this.evaluate&&(this.ok=this.evalAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())}evalAnswer(){return a.esCorrecto(this.answer,this.value,this.evaluator)}deactivate(){this.evaluator.setVariable(this.activoStr,0);this.evaluator.setVariable(this.activeStr,0)}addEvents(){this.label.addEventListener("touchstart",a.preventDefault);this.label.addEventListener("mousedown",a.preventDefault);
this.field.addEventListener("mousedown",()=>{this.parent.deactivateControls();this.evaluator.setVariable(this.activoStr,1);this.evaluator.setVariable(this.activeStr,1);this.parent.update()});this.field.addEventListener("blur",()=>{this.drawIfValue&&this.changeValue(this.field.value,!0)});this.field.addEventListener("keydown",p=>{this.activeIfValue&&p.keyCode==13&&this.changeValue(this.field.value,!0)});this.field.addEventListener("click",p=>{p.target.focus()});this.cover.addEventListener("click",
()=>{this.parent.deactivateControls();this.evaluator.setVariable(this.activoStr,1);this.evaluator.setVariable(this.activeStr,1);this.parent.update();let p=this.evaluator.eval(this.kbexp);this.activeIfValue&&this.parent.keyboard.show(this,this.kblayout,p[0][0]||0,p[0][1]||0,this.id,this.field,this.onlyText)})}}a.TextField=n})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r;class t extends a.Control{constructor(c,f){function m(h){v.options=h.replace(/\\,/g,"&comma;").split(",");v.menuOptions=[];v.strVal=[];for(let u=0,x=v.options.length;u<x;u++)h=v.customSplit(v.options[u]),h.length==1?(v.menuOptions.push(h[0]),v.strVal.push(""+u)):h.length==2&&(v.menuOptions.push(h[0]),h[1]==""?v.strVal.push(""+u):v.strVal.push(h[1]));for(let u=0,x=v.menuOptions.length;u<x;u++)/^\[.*\]$/.test(v.menuOptions[u])?v.menuOptions[u]=k.parse(v.menuOptions[u].slice(1,
-1)):v.menuOptions[u]=k.parse(`'${v.menuOptions[u]}'`);for(let u=0,x=v.strVal.length;u<x;u++)/^\[.*\]$/.test(v.strVal[u])?v.strVal[u]=k.parse(v.strVal[u].slice(1,-1)):v.strVal[u]=k.parse(v.strVal[u]);v.select.innerHTML="";for(let u of v.menuOptions)h=v.select.appendChild(a.newHTML("option")),h.innerHTML=g.eval(u);return 0}super(c,f);k=this.parser;g=this.evaluator;this.label_color=this.label_color||new a.Color("e0e4e8",g);this.label_text_color=this.label_text_color||new a.Color("000000",g);this.options=
f.options||"";this.ok=0;this.tabindex=++c.tabindex;this.answer&&(/^krypto_/.test(this.answer)&&(this.answer=(new a.Krypto).decode(this.answer.slice(7))),this.answer=parseInt(this.answer.split(",")[0].replace("[",""))||0);this.evaluator.setFunction(this.id+".setOptions",m);const v=this;this.containerControl=a.newHTML("div",{class:"DescartesMenuContainer",id:this.id});this.label=a.newHTML("canvas",{class:"DescartesMenuLabel"});this.label_ctx=this.label.getContext("2d");this.ratio=c.ratio;this.select=
a.newHTML("select",{id:this.id+"_menuSelect",class:"DescartesMenuSelect",tabindex:this.tabindex});this.field=a.newHTML("input",{type:"text",id:this.id+"_menuField",class:"DescartesMenuField",tabindex:this.tabindex});m(this.options);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.cover=a.newHTML("div",{class:"TextfieldCover"});this.keyboard&&this.visible&&this.containerControl.appendChild(this.cover);
this.addControlContainer(this.containerControl);this.addEvents();this.init()}init(c){g=this.evaluator;this.fieldFontSize=g.eval(this.font_size)>0?g.eval(this.font_size):a.getFieldFontSize(this.h);this.text_object=new a.TextObject({parent:{decimal_symbol:this.parent.decimal_symbol},evaluator:g,decimals:this.decimals,fixed:!1,align:"left",anchor:"center_center",width:this.parser.parse("0"),font_size:this.parser.parse(""+this.fieldFontSize),font_family:this.font_family,italics:this.italics,bold:this.bold},
this.name);var f=0,m=0;this.value=c?this.value:g.eval(this.valueExpr);this.idxVal=this.getIndex(this.value);for(let u=0,x=this.menuOptions.length;u<x;u++)c=parseInt(a.getTextWidth(""+g.eval(this.menuOptions[u]),`${this.fieldFontSize}px ${a.sansserif_font}`)),c>f&&(f=c,m=u);f+=25;c=parseInt(a.getTextWidth(this.formatValue(g.eval(this.strVal[m])),`${this.fieldFontSize}px ${a.sansserif_font}`))+7;m=this.text_object.getTextMetrics(this.label_ctx).w;m>0&&(m=parseInt(m)+parseInt(this.fieldFontSize));this.visible||
(c=0);let v=this.w-c-m;for(;v<f&&m>0;)m--,v++;for(;v<f&&c>0;)c--,v++;for(;m+v+c+1<this.w;)v++,c++;f=m+v;c=this.w-f;let h=this.formatValue(g.eval(this.strVal[this.idxVal]));this.containerControl.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};color:${this.colorInt.getColor()};--r:${c}px;`);this.label.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${m}px;height:${this.h}px;line-height:${this.h}px;background-color:${this.label_color.getColor()};color:${this.label_text_color.getColor()};`);
this.label.width=m*this.ratio;this.label.height=this.h*this.ratio;this.field.value=h;this.field.setAttribute("style",`font-size:${this.fieldFontSize}px;width:${c}px;height:${this.h}px;left:${f}px;`);this.cover.setAttribute("style",`width:${c}px;height:${this.h}px;left:${f}px;`);this.select.setAttribute("style",`text-align:left;font-size:${this.fieldFontSize}px;width:${v}px;height:${this.h}px;left:${m}px;`);this.select.selectedIndex=this.idxVal;g.setVariable(this.id,parseFloat(h.replace(this.parent.decimal_symbol,
".")));this.update()}update(){g=this.evaluator;this.activeIfValue=g.eval(this.activeif)>0;this.drawIfValue=g.eval(this.drawif)>0;this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");if(!this.parent.animation.playing||document.activeElement!=this.select){for(let c=0,f=this.menuOptions.length;c<f;c++)this.select.options[c].innerHTML=(""+(g.eval(this.menuOptions[c])||
"")).replace(/\\u002C/g,",");this.value=g.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatValue(this.value);g.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))}this.ok=this.value==this.answer?1:0;this.evaluator.setVariable(this.id+".ok",this.ok);this.updatePositionAndSize();this.label_ctx.setTransform(this.ratio,0,0,this.ratio,0,0);this.label_ctx.clearRect(0,0,this.label.width,this.label.height);(r=this.label_color.getColor())&&
/CanvasGradient|CanvasPattern/.test(r.constructor.name)&&(this.label_ctx.fillStyle=r,this.label_ctx.fillRect(0,0,this.label_ctx.canvas.width,this.label_ctx.canvas.height));this.text_object.getTextMetrics(this.label_ctx).w>this.label.width/this.ratio?(this.text_object.anchor="center_left",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),5,this.label.height/this.ratio/2)):(this.text_object.anchor="center_center",this.text_object.draw(this.label_ctx,this.label_text_color.getColor(),
this.label.width/this.ratio/2,this.label.height/this.ratio/2));this.label_ctx.setTransform(1,0,0,1,0,0)}customSplit(c){l=!1;w="";q=0;for(n=-1;q<c.length;)p=c[q],p=="["?(n!=-1||!l&&w==""||(w+="\u00a6"),n++):p=="]"&&(n==0?(l=!0,n--):n>0&&n--),w+=p,q++;return w.split("\u00a6")}getIndex(c){c=parseFloat((""+c).replace(this.parent.decimal_symbol,"."));d=-1;b=Infinity;for(let f=0,m=this.strVal.length;f<m;f++)e=Math.abs(c-parseFloat(this.evaluator.eval(this.strVal[f]))),e<=b&&(b=e,d=f);this.select.options[this.select.selectedIndex]&&
this.evaluator.setVariable(this.id+".txt",this.select.options[this.select.selectedIndex].text);return d}changeValue(c,f){this.activeIfValue&&(f&&(this.idxVal=this.getIndex(c),this.value=this.evaluator.eval(this.strVal[this.idxVal]),this.field.value=this.formatValue(this.idxVal),this.select.selectedIndex=this.idxVal),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())}addEvents(){const c=this;c.label.addEventListener("touchstart",a.preventDefault);c.label.addEventListener("mousedown",
a.preventDefault);c.select.addEventListener("change",function(f){c.value=c.evaluator.eval(c.strVal[this.selectedIndex]);c.field.value=c.formatValue(c.value);c.evaluator.setVariable(c.id,c.field.value);c.changeValue();a.preventDefault(f)});c.field.addEventListener("keydown",f=>{f.keyCode==13&&(c.idxVal=c.getIndex(c.field.value),c.value=c.evaluator.eval(c.strVal[c.idxVal]),c.field.value=c.formatValue(c.idxVal),c.select.selectedIndex=c.idxVal,c.changeValue())});c.field.addEventListener("blur",()=>{c.drawIfValue&&
c.changeValue(c.field.value,!0)});c.field.addEventListener("click",()=>{c.field.focus()});c.cover.addEventListener("click",()=>{let f=c.evaluator.eval(c.kbexp);c.activeIfValue&&c.parent.keyboard.show(c,c.kblayout,f[0][0]||0,f[0][1]||0,c.id,c.field,c.onlyText)})}}a.Menu=t})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r;class t extends a.ScrollbarSliderBase{constructor(c,f){super(c,f);this.container.className="DescartesScrollbarContainer";this.field.className="DescartesScrollbarField";this.label.className="DescartesScrollbarLabel";this.incr_exp=typeof this.incr=="object"?this.incr:c.evaluator.parse(this.incr);this.init()}_addInteractiveElements(){this.canvas=a.newHTML("canvas");this.divUp=a.newHTML("div",{class:"DescartesCatcher up"});this.divDown=a.newHTML("div",{class:"DescartesCatcher down"});
this.handler=a.newHTML("div",{class:"DescartesCatcher manipulator"});this.container.appendChild(this.canvas);this.container.appendChild(this.divUp);this.container.appendChild(this.divDown);this.container.appendChild(this.handler)}init(){k=this.evaluator;k.eval(this.decimals)==0?this.incr=1:this.incr=(k.eval(this.max)-k.eval(this.min))/100;super.init()}update(){k=this.evaluator;k.eval(this.decimals)==0?this.incr=1:this.incr=(k.eval(this.max)-k.eval(this.min))/100;super.update()}initializeLayout(c){super.initializeLayout(c);
this.orientation=="v"?(this.upHeight=this.downH=this.upWidth=this.downW=this.w,this.upX=0,this.upY=this.canvasY,this.downX=0,this.downY=this.canvasY+this.canvasHeight-this.downH,this.handlerW=this.w,this.handlerH=Math.max(15,this.canvasHeight-this.upHeight-this.downH>this.w*2?this.w:parseInt((this.canvasHeight-this.upHeight-this.downH)/10)),this.limInf=this.canvasY+this.canvasHeight-this.downH-this.handlerH,this.limSup=this.canvasY+this.upHeight):(this.upHeight=this.downH=this.upWidth=this.downW=
this.h,this.upX=this.canvasX+this.canvasWidth-this.upWidth,this.upY=0,this.downX=this.canvasX,this.downY=0,this.handlerW=Math.max(15,this.canvasWidth-this.upWidth-this.downW>this.h*2?this.h:parseInt((this.canvasWidth-this.upWidth-this.downW)/10)),this.handlerH=this.h,this.limInf=this.canvasX+this.downW,this.limSup=this.canvasX+this.canvasWidth-this.upWidth-this.handlerW);this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position:absolute;left:0;top:0;");
this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.divUp.setAttribute("style",`width:${this.upWidth}px;height:${this.upHeight}px;left:${this.upX}px;top:${this.upY}px;`);this.divDown.setAttribute("style",`width:${this.downW}px;height:${this.downH}px;left:${this.downX}px;top:${this.downY}px;`);this.handler.setAttribute("style",`width:${this.handlerW}px;height:${this.handlerH}px;left:${this.orientation=="v"?0:this.limInf}px;top:${this.orientation=="v"?this.limInf:0}px;`)}draw(){g=
this.ctx;b=Math.floor(this.w);d=Math.floor(this.h);g.clearRect(0,0,b,d);g.fillStyle=this.color.getColor();g.fillRect(0,0,b,d);g.fillStyle="black";g.beginPath();this.orientation=="h"?(g.lineWidth=1,g.strokeStyle="rgba(0,0,0,0.3)",g.strokeRect(this.canvasX+.5,.5,this.canvasWidth-1,this.h-1),g.lineWidth=Math.ceil(12*this.upWidth/100)||1,g.strokeStyle=this.colorInt.getColor(),g.moveTo(this.downX+62.215*this.upWidth/100,20*this.downH/100),g.lineTo(this.downX+32.449*this.upWidth/100,this.downH/2),g.lineTo(this.downX+
62.215*this.upWidth/100,80*this.downH/100),g.moveTo(this.upX+32.449*this.upWidth/100,20*this.downH/100),g.lineTo(this.upX+62.215*this.upWidth/100,this.downH/2),g.lineTo(this.upX+32.449*this.upWidth/100,80*this.downH/100),g.stroke(),l=Math.floor(this.pos),e=Math.ceil(d/10)||1,g.fillStyle=this.colorInt.getColor(),g.fillRect(l+.5,e,Math.floor(this.handlerW),d-e*2)):(g.lineWidth=1,g.strokeStyle="rgba(0,0,0,0.3)",g.strokeRect(.5,this.canvasY+.5,this.w-1,this.canvasHeight-1),g.lineWidth=Math.ceil(12*this.upWidth/
100)||1,g.strokeStyle=this.colorInt.getColor(),g.moveTo(20*this.upWidth/100,this.h-this.labelHeight-70*this.downH/100),g.lineTo(50*this.upWidth/100,this.h-this.labelHeight-40.237*this.downH/100),g.lineTo(80*this.upWidth/100,this.h-this.labelHeight-70*this.downH/100),g.moveTo(20*this.upWidth/100,this.upY+70*this.downH/100),g.lineTo(50*this.upWidth/100,this.upY+40.237*this.downH/100),g.lineTo(80*this.upWidth/100,this.upY+70*this.downH/100),g.stroke(),l=Math.floor(this.pos),e=Math.ceil(b/10)||1,g.fillStyle=
this.colorInt.getColor(),g.fillRect(e,l+.5,b-e*2,Math.floor(this.handlerH)));this.activeIfValue||(g.fillStyle="rgba(255,255,255,0.5)",g.fillRect(0,0,g.canvas.width,g.canvas.height))}updateControlPosition(){k=this.evaluator;q=this.limInf;n=this.limSup;p=k.eval(this.min);r=k.eval(this.max);this.pos=r-p==0?q:(this.value-p)*(n-q)/(r-p)+q;this.handler.style[this.orientation=="h"?"left":"top"]=this.pos+"px"}_addEvents(){function c(u,x,z,G){a.clearTimeout(h);(v.up||v.down||v.canvasClick)&&Math.abs(v.value-
G)>1E-7&&(x.call(v),u=z?u:30,h=a.setTimeout(function(){c(u,x,!1,G)},u))}function f(u){v.scrollClick&&(a.preventDefault(u),u=a.getCursorPosition(u,v.container),v.orientation=="h"?(v.pos=v.prePos-(v.initPos.x-u.x),v.pos<v.limInf&&(v.pos=v.limInf),v.pos>v.limSup&&(v.pos=v.limSup),v.handler.style.left=v.pos+"px"):(v.pos=v.prePos-(v.initPos.y-u.y),v.pos>v.limInf&&(v.pos=v.limInf),v.pos<v.limSup&&(v.pos=v.limSup),v.handler.style.top=v.pos+"px"),v.changeValueMovement())}function m(u){a.preventDefault(u);
v.scrollClick=!1;v.prePos=v.pos;v.handler.releasePointerCapture(u.pointerId);v.handler.removeEventListener("pointermove",f);v.handler.removeEventListener("pointerup",m);v.handler.removeEventListener("pointercancel",m)}const v=this;let h;v.canvas.addEventListener("pointerdown",function(u){a.preventDefault(u);v.whichBtn=a.whichBtn(u);v.whichBtn=="L"&&v.activeIfValue&&(v.clickPos=a.getCursorPosition(u,v.container),v.canvasClick=!0,v.orientation=="h"?v.clickPos.x<v.prePos?c(350,v.decrease10,!0,v.minimo):
c(350,v.increase10,!0,v.maximo):v.clickPos.y>v.prePos?c(350,v.decrease10,!0,v.minimo):c(350,v.increase10,!0,v.maximo))});v.canvas.addEventListener("pointerout",function(u){v.canvasClick&&(v.canvasClick=!1,a.clearTimeout(h),a.preventDefault(u))});window.addEventListener("pointerup",function(u){v.canvasClick&&(v.canvasClick=!1,a.clearTimeout(h))});v.handler.addEventListener("pointerdown",function(u){v.activeIfValue&&u.isPrimary&&(a.preventDefault(u),v.scrollClick=!0,v.initPos=a.getCursorPosition(u,
v.container),v.handler.setPointerCapture(u.pointerId),v.handler.addEventListener("pointermove",f),v.handler.addEventListener("pointerup",m),v.handler.addEventListener("pointercancel",m))});v.divUp.addEventListener("pointerdown",function(u){u.isPrimary&&v.activeIfValue&&(a.preventDefault(u),v.up=!0,v.orientation=="v"?c(350,v.decrease,!0,v.minimo):c(350,v.increase,!0,v.maximo))});v.divDown.addEventListener("pointerdown",function(u){u.isPrimary&&v.activeIfValue&&(a.preventDefault(u),v.down=!0,v.orientation==
"v"?c(350,v.increase,!0,v.maximo):c(350,v.decrease,!0,v.minimo))});v.divUp.addEventListener("pointerout",function(u){v.up&&(v.up=!1,a.clearTimeout(h),a.preventDefault(u))});v.divDown.addEventListener("pointerout",function(u){v.down&&(v.down=!1,a.clearTimeout(h),a.preventDefault(u))});window.addEventListener("pointerup",function(u){if(v.up||v.down)v.up=!1,v.down=!1,a.clearTimeout(h),v.draw()})}increase(){this.changeValue(parseFloat(this.value)+this.incr)}decrease(){this.changeValue(parseFloat(this.value)-
this.incr)}increase10(){this.changeValue(parseFloat(this.value)+(this.evaluator.eval(this.max)-this.evaluator.eval(this.min))/10)}decrease10(){this.changeValue(parseFloat(this.value)-(this.evaluator.eval(this.max)-this.evaluator.eval(this.min))/10)}changeValueMovement(){k=this.evaluator;q=this.limInf;n=this.limSup;p=k.eval(this.min);r=k.eval(this.max);w=n-q==0?p:(this.pos-q)*(r-p)/(n-q)+p;w=this.validateValue(w);w!=this.value&&(this.value=w,this.field.value=this.formatValue(w),k.setVariable(this.id,
this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())}}a.Scrollbar=t})(descartesJS);
(a=>{let k,g,d,b,e;class l extends a.ScrollbarSliderBase{constructor(w,q){super(w,q);this.displayValue=this.visible;this.visible=!1;this.container.className="DescartesSliderContainer";this.field.className="DescartesSliderField";this.label.className="DescartesSliderLabel";this.incr_exp=typeof this.incr=="object"?this.incr:w.evaluator.parse(this.incr);this.init()}_addInteractiveElements(){this.sliderCtr=a.newHTML("input",{type:"range",id:this.id+"_range",min:0,max:100,step:"any",class:"DescartesRange"});
this.valueOutput=a.newHTML("div",{class:"range_output"});this.container.appendChild(this.sliderCtr);this.container.appendChild(this.valueOutput)}init(){this.incr=this.evaluator.eval(this.incr_exp);super.init()}update(){this.incr=this.evaluator.eval(this.incr_exp);this.sliderCtr.disabled=!this.activeIfValue;this.sliderCtr.style.filter=this.activeIfValue?"":"grayscale(60%)";super.update();this.valueOutput.textContent=this.field.value;e=this.sliderCtr.value;d=this.sliderCtr.min?this.sliderCtr.min:0;
b=this.sliderCtr.max?this.sliderCtr.max:100;g=Number((e-d)*100/(b-d));this.valueOutput.style=this.displayValue?this.orientation=="v"?`top:${this.fieldHeight+this.canvasWidth/2+g/100*(this.canvasHeight-this.canvasWidth)}px;${this.x<this.parent.width/2?"left":"right"}:${this.w+4}px;transform:translate(0,-50%)`:`left:${this.labelWidth+this.canvasHeight/2+g/100*(this.canvasWidth-this.canvasHeight)}px;${this.y<this.parent.height/2?"top":"bottom"}:${this.canvasHeight+4}px;transform:translate(-50%,0)`:"display:none;"}initializeLayout(w){super.initializeLayout(w);
this.orientation=="v"?(this.sliderCtr.setAttribute("dir","V"),this.valueOutput.setAttribute("dir","V"),this.sliderCtr.style=`left:0;top:${this.canvasY}px;width:${this.canvasWidth}px;height:${this.canvasHeight}px;;--thumb_size:${this.canvasWidth}px;--track_size:${parseInt(this.canvasWidth/3)}px;`):(this.sliderCtr.setAttribute("dir","H"),this.valueOutput.setAttribute("dir","H"),this.sliderCtr.style=`left:${this.canvasX}px;top:0;width:${this.canvasWidth}px;height:${this.canvasHeight}px;--thumb_size:${this.canvasHeight}px;--track_size:${parseInt(this.canvasHeight/
3)}px;`)}draw(){this.sliderCtr.style.setProperty("--track_color",this.color.getColor());this.sliderCtr.style.setProperty("--thumb_color",this.colorInt.getColor());this.sliderCtr.value=this.pos}updateControlPosition(){k=this.evaluator;d=k.eval(this.min);b=k.eval(this.max);this.pos=b-d==0?0:(this.value-d)*100/(b-d)}_addEvents(){this.sliderCtr.addEventListener("input",w=>{this.activeIfValue&&(this.pos=w.target.value,this.changeValueForSliderMovement())})}changeValueForSliderMovement(){k=this.evaluator;
d=k.eval(this.min);b=k.eval(this.max);g=this.pos/100*(b-d)+d;g=this.validateValue(g);g!=this.value&&(this.value=g,this.field.value=this.formatValue(g),k.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())}}a.Slider=l})(descartesJS);
(a=>{let k,g,d;class b extends a.Control{constructor(e,l){super(e,l);this.controls=l.controls||!0;this.file=l.file||"";this.oldDrawIf=0;e=this.evaluator.eval(this.expresion);this.w=(l=e[0].length==4)?e[0][2]:200;this.h=l?e[0][3]:28;this.audio=this.parent.getAudio(this.file);this.oldFile=this.file;/^\[.*\]$/.test(this.file)&&(this.file=this.evaluator.parser.parse(this.file.slice(1,-1)));this.autoplay&&(this.audio.setAttribute("autoplay","autoplay"),this.audio.play());this.loop&&this.audio.setAttribute("loop",
"loop");this.controls&&this.audio.setAttribute("controls","controls");this.audio.setAttribute("style",`position:absolute;width:${this.w}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};`);this.addControlContainer(this.audio);const w=this;w.evaluator.setFunction(w.id+".play",function(){try{w.audio.play()}catch(q){}return 0});w.evaluator.setFunction(w.id+".pause",function(){try{w.audio.pause()}catch(q){}return 0});w.evaluator.setFunction(w.id+".stop",function(){try{w.audio.pause(),w.audio.currentTime=
0}catch(q){}return 0});w.evaluator.setFunction(w.id+".currentTime",function(q){try{w.audio.currentTime=parseFloat(q)}catch(n){}return 0});w.audio.addEventListener("timeupdate",function(){w.evaluator.setVariable(w.id+".currentTime",w.audio.currentTime);w.evaluator.setVariable(w.id+".playing",w.audio.paused?0:1);w.evaluator.setVariable(w.id+".duration",w.audio.duration)})}init(){this.audio.style.left=`${this.x}px`;this.audio.style.top=`${this.y}px`;this.update()}update(){k=this.evaluator;typeof this.file!==
"string"&&(g=k.eval(this.file),this.old!==g&&(this.audio.src=this.old=g));d=k.eval(this.drawif)>0;this.audio.style.display=d?"block":"none";d||d===this.oldDIF||this.audio.pause();this.oldDIF=d;this.updatePositionAndSize()}}a.Audio=b})(descartesJS);
(a=>{let k,g;class d extends a.Control{constructor(b,e){super(b,e);this.controls=e.controls||!0;this.file=e.file||"";this.oldDrawIf=0;k=this.evaluator;b=k.eval(this.expresion)[0];b.length==4?(this.w=b[2],this.h=b[3]):this.h=this.w=null;b=this.file;e=b.lastIndexOf(".");e!=-1&&(b=this.file.slice(0,e));this.video=a.newHTML("video",{poster:b+".png",style:`position:absolute;overflow:hidden;left:${this.x}px;top:${this.y}px;outline:none;background:rgba(0,0,0,0);`});this.autoplay&&this.video.setAttribute("autoplay",
"autoplay");this.loop&&this.video.setAttribute("loop","loop");this.controls&&this.video.setAttribute("controls","controls");this.w&&(this.video.setAttribute("width",this.w),this.video.setAttribute("height",this.h));this.video.canPlayType("video/mp4")&&(e=a.newHTML("source",{src:b+".mp4",type:"video/mp4"}),this.video.appendChild(e));this.video.canPlayType("video/ogg")&&(e=a.newHTML("source",{src:b+".ogg",type:"video/ogg"}),this.video.appendChild(e),e=a.newHTML("source",{src:b+".ogv",type:"video/ogg"}),
this.video.appendChild(e));this.video.canPlayType("video/webm")&&(e=a.newHTML("source",{src:b+".webm",type:"video/webm"}),this.video.appendChild(e));this.addControlContainer(this.video);k.setFunction(this.id+".play",()=>{try{this.video.play()}catch(l){}return 0});k.setFunction(this.id+".pause",()=>{try{this.video.pause()}catch(l){}return 0});k.setFunction(this.id+".stop",()=>{try{this.video.pause(),this.video.currentTime=0}catch(l){}return 0});k.setFunction(this.id+".currentTime",l=>{try{this.video.currentTime=
parseFloat(l)}catch(w){}return 0});this.video.addEventListener("timeupdate",()=>{k.setVariable(this.id+".currentTime",this.video.currentTime)})}init(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()}update(){k=this.evaluator;(g=k.eval(this.drawif)>0)?this.video.style.display="block":(this.video.style.display="none",g!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=g;this.updatePositionAndSize()}}a.Video=d})(descartesJS);
(a=>{let k,g,d;class b extends a.Control{constructor(e,l){super(e,l);this.font_family=l.font_family||"sansserif";this.style=l.style||",PLAIN,";this.font_size=l.font_size||12;typeof(this.font_size!=="number")&&(this.font_size=this.evaluator.eval(this.font_size));this.font=this.font_family+this.style+this.font_size;this.evaluator.setVariable(this.id+"._scroll_x",0);this.evaluator.setVariable(this.id+"._scroll_y",0);this.region="interior";this.tabindex=++e.tabindex;this.answer&&/^krypto_/.test(this.answer)&&
(this.answer=(new a.Krypto).decode(this.answer.slice(7)));this.containerControl=a.newHTML("div",{class:"DescartesTextAreaContainer",id:this.id,spellcheck:"false"});this.textArea=a.newHTML("textarea",{class:"DescartesTextArea",spellcheck:"false"});this.textAreaAnswer=a.newHTML("div",{class:"DescartesTextArea"});this.showButton=a.newHTML("div",{class:"DJS_Gradient"});this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);
this.cover=a.newHTML("div",{class:"TextfieldCover"});this.keyboard&&this.containerControl.appendChild(this.cover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=this.text||"";this.evaluator.setVariable(this.id,this.text);let w;const q=this;this.evaluator.setFunction(this.id+".insertAtCursor",function(n){w=q.textArea.selectionStart+n.length;q.textArea.value=q.textArea.value.slice(0,q.textArea.selectionStart)+n+q.textArea.value.slice(q.textArea.selectionEnd);q.textArea.selectionStart=
q.textArea.selectionEnd=w;q.textArea.focus();return 0});this.evaluator.setFunction(this.id+".update",()=>{this.update()});this.evaluator.setFunction(this.id+".scrollTo",n=>{this.textArea.scrollTop=n});this.addEvents();this.init()}init(){g=this.answer?30:7;k=this.evaluator;let e=this.text.replace(/\\n/g,"\n");this.containerControl.setAttribute("style",`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};`);let l=`width:${this.w-6}px;height:${this.h-g}px;font:${a.convertFont(this.font)};line-height:${this.font_size}px;`;
this.textArea.setAttribute("style",l);this.textArea.value=e;this.textAreaAnswer.setAttribute("style",`${l}display:${this.showAnswer?"block":"none"};`);this.textAreaAnswer.innerHTML=`<span>${this.answer}</span>`;this.showButton.setAttribute("style",`text-align:center;width:20px;height:16px;position:absolute;bottom:4px;right:4px;cursor:pointer;border:1px outset #c0c0c0;display:${this.answer?"block":"none"};`);this.showButton.innerHTML=`<span style="position:relative;top:1px;text-align:center;font:11px ${a.sansserif_font};">S</span>`;
this.cover.setAttribute("style",`position:absolute;width:${this.w}px;height:${this.h}px;left:0px;top:0px;`);this.update()}update(){k=this.evaluator;this.activeIfValue=k.eval(this.activeif)>0;this.drawIfValue=k.eval(this.drawif)>0;k.getVariable(this.id)!==this.oldValue&&(this.textArea.value=(k.getVariable(this.id)||"").replace(/\\n/g,"\n"));d=this.textArea.value||"";d=d.charAt(d.length-1)=="\n"?d.slice(0,-1):d;d=d.replace(/\n/g,"\\n").replace(/\s/g," ");k.setVariable(this.id,d);this.oldFieldValue=
d;this.oldValue=k.getVariable(this.id);this.activeIfValue?this.textArea.removeAttribute("disabled"):this.textArea.setAttribute("disabled",!0);this.containerControl.style.display=this.drawIfValue?"block":"none";this.textArea.style["overflow-x"]=k.getVariable(this.id+"._scroll_x")>0?"auto":"unset";this.textArea.style["overflow-y"]=k.getVariable(this.id+"._scroll_y")>0?"auto":"unset";this.updatePositionAndSize()}changeValue(e){this.textArea.value=e;this.update()}addEvents(){this.showButton.addEventListener("click",
e=>{a.preventDefault(e);this.showAnswer=!this.showAnswer;this.textAreaAnswer.style.display=this.showAnswer?"block":"none";this.showButton.childNodes[0].childNodes[0].textContent=this.showAnswer?"T":"S";this.textArea.blur()});this.showButton.onmouseup=this.showButton.onmouseout=e=>{a.preventDefault(e)};this.textArea.addEventListener("blur",()=>{this.cursorInd=window.getSelection().focusOffset});this.textArea.addEventListener("paste",e=>{a.preventDefault(e);document.execCommand("insertHTML",!1,e.clipboardData.getData("text/plain").replace(/\n/g,
"<br>"))});this.textArea.addEventListener("keydown",e=>{e.key!="PageDown"&&e.key!="PageUp"||a.preventDefault(e)});this.cover.addEventListener("pointerdown",()=>{let e=this.evaluator.eval(this.kbexp);this.activeIfValue&&this.parent.keyboard.show(this,this.kblayout,e[0][0]||0,e[0][1]||0,this.id,this.textArea,!0)})}}a.TextArea=b})(descartesJS);
(a=>{const k=Math.PI*2;let g,d,b,e,l,w,q,n,p,r,t,c;class f extends a.Control{constructor(m,v){super(m,v);d=m.evaluator.parser;this.spaceID=v.spaceID||"";this.size=v.size||d.parse("4");this.font=v.font||"Serif,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc=v.imageSrc||"";/^\[.*\]$/.test(this.imageSrc)?this.imageSrc=this.parser.parse(this.imageSrc.slice(1,-1)):this.imageSrc=this.parser.parse(`'${this.imageSrc}'`);this.font=a.convertFont(this.font);if(this.constraintExpr){this.constraint=
d.parse(this.constraintExpr);this.constraint.type=="(expr)"&&(this.constraint=d.parse(this.constraintExpr.slice(1,-1)));if(this.constraint.type=="compOperator"){v=this.constraint.childs[0];let h=this.constraint.childs[1];v.type!="identifier"||v.value!="y"||h.contains("y")?v.type!="identifier"||v.value!="x"||h.contains("x")?this.newt=new a.R2Newton(this.evaluator,this.constraint):(this.constVar="y",this.noConstVar="x",this.evalConst=this.evalConstXoY,this.constraint=h):(this.constVar="x",this.noConstVar=
"y",this.evalConst=this.evalConstXoY,this.constraint=h)}else this.constraint=null;r=new a.R2(0,0)}this.container=this.getContainer();this.mouseCatcher=a.newHTML("div",{class:"DescartesGraphicControl",id:this.id,dragged:!0,tabindex:"-1",style:`z-index:${this.zIndex};touch-action:none;`});this.ctx=this.space.ctx;this.container.appendChild(this.mouseCatcher);this.addEvents();this.xStr=this.id+".x";this.yStr=this.id+".y";this.activoStr=this.id+".activo";this.activeStr=this.id+".active";m=this.space.id!==
""&&m.version!==2?this.space.id+".":"";this.mX=m+"mouse_x";this.mY=m+"mouse_y";this.mClicked=m+"mouse_clicked";this.mClicIzq=m+"clic_izquierdo";this.init()}init(m){g=this.evaluator;t=a.hasTouchSupport;m||(m=g.eval(this.expresion)[0],this.x=m[0],this.y=m[1],g.setVariable(this.xStr,this.x),g.setVariable(this.yStr,this.y));this.img_src_eval=(""+g.eval(this.imageSrc)).trim();this.img_src_eval==""||/vacio.gif$/i.test(this.img_src_eval)?(this.width=g.eval(this.size)*2,this.height=g.eval(this.size)*2,this._w=
t&&this.width<48?48:this.width,this._h=t&&this.height<48?48:this.height,this.mouseCatcher.style.borderRadius=parseInt(Math.min(this._w,this._h)/2)+"px"):(this.image=this.parent.getImage(this.img_src_eval),this.width=this.image.width,this.height=this.image.height,this._w=Math.max(this.width,32),this._h=Math.max(this.height,32));this.mouseCatcher.style.width=this._w+"px";this.mouseCatcher.style.height=this._h+"px";this.mouseCatcher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";
this.mouseCatcher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";g.setVariable(this.activoStr,0);g.setVariable(this.activeStr,0);this.setImage=!1;this.update()}update(){g=this.evaluator;(""+g.eval(this.imageSrc)).trim()!==this.img_src_eval&&this.init(!0);this.activeIfValue=g.eval(this.activeif)>0;this.drawIfValue=g.eval(this.drawif)>0;this.x=g.getVariable(this.xStr);this.y=g.getVariable(this.yStr);this.mouseCatcher.style.display=this.activeIfValue?"block":"none";this.mouseCatcher.style.left=
parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCatcher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";this.constraint&&this.evalConst();this.draw()}draw(){g=this.evaluator;this.drawIfValue&&(n=this.ctx,p=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+.5,e=parseInt(this.space.getAbsoluteY(this.y))+.5,this.image.ready?(l=this.image.width/2,w=this.image.height/2,this.image.complete&&!this.setImage&&n.drawImage(this.image,parseInt(b-l),parseInt(e-
w)),this.trace&&(p.save(),p.translate(b,e),p.scale(parseInt(l),parseInt(w)),p.beginPath(),p.arc(0,0,1,0,k),p.restore(),p.lineWidth=1,p.strokeStyle=this.trace.getColor(),p.stroke())):(l=parseInt(this.width/2),n.beginPath(),n.arc(b,e,l,0,k),n.fillStyle=this.colorInt.getColor(),n.fill(),n.lineWidth=1,n.strokeStyle=this.color.getColor(),n.stroke(),this.active&&(n.strokeStyle=this.colorInt.borderColor(),n.beginPath(),n.arc(b,e,l-2,0,k),n.stroke()),this.trace&&(p.strokeStyle=this.trace.getColor(),p.beginPath(),
p.arc(b,e,l,0,k),p.stroke())))}evalConst(){r.set(this.x,this.y);q=this.newt.findZero(r,1/this.space.scale,!0);this.x=q.x;this.y=q.y;this.evaluator.setVariable(this.xStr,this.x);this.evaluator.setVariable(this.yStr,this.y)}evalConstXoY(){g=this.evaluator;c=g.getVariable(this.constVar);g.setVariable(this.constVar,this[this.constVar]);this[this.noConstVar]=g.eval(this.constraint);g.setVariable(this.xStr,this.x);g.setVariable(this.yStr,this.y);g.setVariable(this.constVar,c)}getContainer(){let m=this.parent.spaces;
for(let v of m)if(v.id==this.spaceID)return v.addCtr(this),this.zIndex=v.zIndex,this.space=v,v.graphicControlContainer;m[0].addCtr(this);this.zIndex=m[0].zIndex;this.space=m[0];return m[0].graphicControlContainer}deactivate(){this.active=!1;this.evaluator.setVariable(this.activoStr,0);this.evaluator.setVariable(this.activeStr,0);this.evaluator.setVariable(this.mClicIzq,0)}addEvents(){function m(z){a.preventDefault(z);x.mouseCatcher.releasePointerCapture(z.pointerId);z.type=="pointerup"&&(x.evaluator.setVariable(x.mClicked,
1),x.evaluator.setVariable(x.mClicIzq,1));if(x.activeIfValue||x.active)x.click=!1,x.mouseCatcher.removeEventListener("pointermove",v),x.mouseCatcher.removeEventListener("pointerup",m),x.mouseCatcher.removeEventListener("pointercancel",m),u=a.getCursorPosition(z,x.container)||x.posAnte,x.posX=x.prePos.x-(x.posAnte.x-u.x),x.posY=x.prePos.y-(x.posAnte.y-u.y),x.evaluator.setVariable(x.xStr,x.space.getRelativeX(x.posX)),x.evaluator.setVariable(x.yStr,x.space.getRelativeY(x.posY)),x.evaluator.setVariable(x.mX,
x.space.getRelativeX(u.x)),x.evaluator.setVariable(x.mY,x.space.getRelativeY(u.y)),x.parent.updateControls(),x.parent.update(),x.mouseCatcher.style.left=x.space.getAbsoluteX(x.x)-x._w/2+"px",x.mouseCatcher.style.top=x.space.getAbsoluteY(x.y)-x._h/2+"px";z=x.evaluator.getVariable(x.activeStr);x.parent.deactivateControls();x.parent.updateControls();x.evaluator.setVariable(x.activoStr,z);x.evaluator.setVariable(x.activeStr,z);x.parent.update()}function v(z){a.preventDefault(z);x.evaluator.setVariable(x.mClicked,
0);x.evaluator.setVariable(x.mClicIzq,0);u=a.getCursorPosition(z,x.container);x.posX=x.prePos.x-(x.posAnte.x-u.x);x.posY=x.prePos.y-(x.posAnte.y-u.y);x.evaluator.setVariable(x.xStr,x.space.getRelativeX(x.posX));x.evaluator.setVariable(x.yStr,x.space.getRelativeY(x.posY));x.evaluator.setVariable(x.mX,x.space.getRelativeX(u.x));x.evaluator.setVariable(x.mY,x.space.getRelativeY(u.y));Date.now()-h>80&&(x.parent.updateControls(),x.parent.update(),h=Date.now())}let h=0,u;const x=this;x.click=x.over=x.active=
!1;x.mouseCatcher.addEventListener("pointerdown",function(z){document.body.focus();a.preventDefault(z);x.whichBtn=a.whichBtn(z);x.whichBtn=="L"&&x.activeIfValue&&(x.parent.deactivateControls(),x.click=x.active=!0,x.mouseCatcher.setPointerCapture(z.pointerId),x.evaluator.setVariable(x.activoStr,1),x.evaluator.setVariable(x.activeStr,1),x.evaluator.setVariable(x.mClicked,0),x.evaluator.setVariable(x.mClicIzq,0),x.posAnte=a.getCursorPosition(z,x.container),x.prePos={x:x.space.getAbsoluteX(x.x),y:x.space.getAbsoluteY(x.y)},
x.evaluator.setVariable(x.mX,x.space.getRelativeX(x.posAnte.x)),x.evaluator.setVariable(x.mY,x.space.getRelativeY(x.posAnte.y)),x.parent.update(),x.mouseCatcher.addEventListener("pointermove",v),x.mouseCatcher.addEventListener("pointerup",m),x.mouseCatcher.addEventListener("pointercancel",m))});x.mouseCatcher.addEventListener("pointerover",function(z){x.over=!0});x.mouseCatcher.addEventListener("pointerout",function(z){x.over=!1})}}a.GraphicControl=f})(descartesJS);
((a,k)=>{function g(t){return t?t[0].toUpperCase()+t.slice(1):""}const d=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.webp)/i,b=/interval|steps/;let e,l,w,q,n,p;class r{constructor(t){this.parent=t;this.parser=t.evaluator.parser}parseButtonsConfig(t){let c={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};for(let [f,m]of this.split(t))switch(l=k[f],l){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":c[l]=parseInt(m);break;case "about":case "config":case "init":case "clear":c[l]=
k[m]=="true";break;default:console.warn(`Propiedad de botones no identificada: <${f}> valor: <${m}>`)}return c}parseSpace(t){w={};for(let [c,f]of this.split(t))switch(l=k[c],a.DEBUG.pName=c,a.DEBUG.objectName="Space",l){case "info":break;case "type":if(f=="R2"||f=="R3")f=k[f];w[l]=f;break;case "id":a.DEBUG.idName=f;case "x_axis":case "y_axis":case "cID":case "file":case "border_width":case "border_radius":w[l]=f;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "3D":case "split":case "resizable":w[l]=
k[f]=="true";break;case "bg_display":case "render":w[l]=k[f];break;case "border_color":case "net":case "net10":case "axes":case "text":w[l]="";f!=""&&(w[l]=k[f]=="false"?"":new a.Color(f,this.parent.evaluator));break;case "O.x":w.OxExpr=f;break;case "O.y":w.OyExpr=f;break;case "image":w.imageSrc=f;break;case "x":case "y":e=f.trim();t=l=="x"?this.parent.container.width:this.parent.container.height;e.endsWith("%")&&(w[l+"PercentExpr"]=e,e=""+t*parseFloat(e)/100);w[l+"Expr"]=this.parser.parse(e);break;
case "width":case "height":e=f.trim();w[l[0]+"ModExpr"]=e;e.endsWith("%")?(w[l[0]+"Expr"]=e,e=this.parent.container[l]*parseFloat(e)/100):(e=parseFloat(f),e!=f&&(e=this.parent.container[l],w[`_${l[0]}_`]=f.trim()));w[l[0]]=e;break;case "drawif":f!=""&&(w[l]=this.parser.parse(f));break;case "scale":e=parseFloat(f);isNaN(e)&&(e=48);w[l]=e;break;case "background":w[l]=new a.Color(f,this.parent.evaluator);break;default:console.warn(`Propiedad del espacio no identificada: <${c}> valor: <${f}>`)}return new a["Space"+
w.type](this.parent,w)}parseControl(t){q={type:"Numeric",gui:"Spinner"};for(let [c,f]of this.split(t))switch(l=k[c],a.DEBUG.pName=c,a.DEBUG.objectName="Control",l){case "info":break;case "type":e=k[f.trim()];e=="graphic"?e="GraphicControl":e=="text"&&(e="TextArea");q[l]=g(e);break;case "gui":e=k[f];e=="textfield"&&(e="TextField");q[l]=g(e);break;case "id":a.DEBUG.idName=f;case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "font_family":case "file":case "answer":case "cssClass":case "radio_group":case "extra_style":case "kblayout":q[l]=
f;break;case "region":case "position":case "action":case "msg_pos":case "poster":case "text_align":case "image_align":case "btn_pos":q[l]=k[f];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":case "flat":case "keyboard":q[l]=k[f]=="true";break;case "color":case "colorInt":case "label_color":case "label_text_color":case "trace":q[l]=new a.Color(f,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":f!==
""&&(q[l]=this.parser.parse(f));break;case "constraint":q.constraintExpr=f;break;case "image":q.imageSrc=f;break;case "image_dec":q.image_dec_src=f;break;case "image_inc":q.image_inc_src=f;break;case "space":q.spaceID=f;break;case "expresion":case "kbexp":q[l]=this.parser.parse(f.replace(")(",","));break;case "borderColor":q[l]=k[f]=="false"?"":f;break;case "bold":case "italics":k[f]!="false"&&(q[l]=l);break;case "underlined":k[f]!="false"&&(q[l]=!0);break;case "value":t=f.replace(/&squot;/g,"'").replace(/^\|(.*)\|$/,
"'$1'");q.valueExpr=this.parser.parse(t);q.valueExprString=t;break;case "incr":f!=0&&(q[l]=this.parser.parse(f));break;case "exponentialif":q[l]=parseFloat(f);break;case "text":q[l]=f;break;default:t=c.indexOf(".");let m=k[c.slice(0,t)];k[c.slice(t+1)]=="font"&&/parameter|Explanation|tooltip/.test(m)?q[m+"Font"]=f:console.warn(`Propiedad de control no identificada: <${c}> valor: <${f}>`)}return new a[q.type=="Numeric"?q.gui:q.type](this.parent,q)}parseGraphic(t,c,f,m){n={rotateExp:m,parameter:"t"};
for(let [v,h]of this.split(t))if(l=k[v],a.DEBUG.pName=v,a.DEBUG.objectName="Graphic",h!="")switch(l){case "info":break;case "type":a.DEBUG.idName=h;n[l]=g(k[h]);break;case "align":case "anchor":case "lineDash":n[l]=k[h];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":case "bold":case "italics":case "underlined":n[l]=k[h]=="true";break;case "shadowColor":case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":n[l]=k[h]=="false"?
"":new a.Color(h,this.parent.evaluator);break;case "border_size":case "shadowBlur":case "shadowOffsetX":case "shadowOffsetY":case "family":case "parameter":case "font":case "font_family":case "name":case "init":case "end":n[l]=h;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "border_radius":case "opacity":case "inirot":case "inipos":case "range":case "clip":h!==""&&(n[l]=this.parser.parse(h));break;case "font_size":h=h.trim();h.startsWith("[")&&
h.endsWith("]")&&(h=h.slice(1,-1));h!==""&&(n[l]=this.parser.parse(h));break;case "space":n[l+"ID"]=h;break;case "expresion":h!==""&&(n.type!="Macro"?(n[l]=this.parser.parse(h),n[l+"String"]=h):n[l]=h);break;case "text":n[l]=h;break;case "file":t=h.replace(/&squot;/g,"'").trim();t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,-1));d.test(t)&&(t=`'${t}'`);t.startsWith("data:image/")?n[l]=this.parser.parse(`'${t}'`):n[l]=this.parser.parse(t);break;case "border":h!=""&&k[h]!="false"&&(n[l]=new a.Color(h,
this.parent.evaluator));break;default:if(n.family!=void 0&&(t=n.family.length+1,v.slice(0,t)==n.family+".")){t=k[v.slice(t)];b.test(t)&&h!=""&&(n["family_"+t]=this.parser.parse(h));break}n.parameter!=void 0&&v.match(n.parameter+".")?(t=v.slice(0,v.indexOf(n.parameter)+n.parameter.length),n.parameter!==t&&(n.parameter=t),t=k[v.slice(n.parameter.length+1)],b.test(t)&&h!=""&&(n["parameter_"+t]=this.parser.parse(h))):console.warn(`Propiedad del gr\u00e1fico no identificada: <${v}> valor: <${h}>`)}c&&
(n.abs_coord=c);f&&(n.background=f);return new a[n.type](this.parent,n)}parse3DGraphic(t,c,f,m){n={rotateExp:m,parameter:"t"};for(let [v,h]of this.split(t))switch(l=k[v],a.DEBUG.pName=v,a.DEBUG.objectName="Graphic3D",l){case "info":break;case "type":a.DEBUG.idName=h;n[l]=g(k[h]);break;case "model":case "align":case "anchor":case "lineDash":n[l]=k[h];break;case "shadowColor":case "fill":n[l]=k[h]=="false"?"":new a.Color(h,this.parent.evaluator);break;case "background":case "fixed":case "split":case "bold":case "italics":case "underlined":n[l]=
k[h]=="true";break;case "edges":k[h]=="false"?n[l]="":(k[h]=="true"&&(h="808080"),n[l]=new a.Color(h,this.parent.evaluator));break;case "border":h!=""&&k[h]!="false"&&(n.border=new a.Color(h,this.parent.evaluator));break;case "color":case "backcolor":n[l]=new a.Color(h,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "R":case "r":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":case "offset_angle":case "offset_dist":case "font_size":h!=""&&(n[l]=
this.parser.parse(h));break;case "border_size":case "shadowBlur":case "shadowOffsetX":case "shadowOffsetY":case "family":case "parameter":case "font":case "font_family":case "name":case "inirot":case "endrot":n[l]=h;break;case "space":n[l+"ID"]=h;break;case "expresion":/Macro|Curve|Surface/.test(n.type)?n[l]=h.replace(/\\n/g,";"):(n[l]=this.parser.parse(h),n.expresionString=h);break;case "text":n.text=h;break;case "file":t=h.replace(/&squot;/g,"'").trim();t.startsWith("[")&&t.endsWith("]")&&(t=t.slice(1,
-1));/./.test(t)&&(t=`'${t}'`);n[l]=this.parser.parse(t);break;default:if(n.family!=void 0&&(t=n.family.length+1,v.slice(0,t)==n.family+".")){t=k[v.slice(t)];b.test(t)&&h!=""&&(n["family_"+t]=this.parser.parse(h));break}console.warn(`Propiedad del gr\u00e1fico 3D no identificada: <${v}> valor: <${h}>`)}return new a[n.type+"3D"](this.parent,n)}parseAuxiliar(t){p={};t=this.split(t);for(let f=0,m=t.length;f<m;f++)t[f][1]=t[f][1].replace(/&squot;/g,"'");for(let [f,m]of t)switch(l=k[f],a.DEBUG.pName=f,
a.DEBUG.objectName="Auxiliar",l){case "info":case "code":case "doc":break;case "id":a.DEBUG.idName=m;case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":p[l]=m.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":p[l]=k[m]=="true";break;case "size":case "rows":case "columns":case "x":case "y":case "width":case "height":p[l]=this.parser.parse(m);
break;case "evaluate":case "execution":case "msg_pos":case "action":case "type":p[l]=k[m];break;default:var c=f.indexOf(".");t=k[f.slice(0,c)];c=k[f.slice(c+1)];t=="parameter"&&c=="font"?p[t+"Font"]=m:console.warn(`Propiedad del auxiliar no identificada: <${f}> valor: <${m}>`)}p.sequence?p.type="sequence":p.constant?p.type="constant":p.algorithm&&p.evaluate?p.type="algorithm":p.array&&!p.matrix&&p.id.charAt(p.id.length-1)!=")"?p.type="vector":p.matrix&&p.id.charAt(p.id.length-1)!=")"?p.type="matrix":
p.event&&p.id.charAt(p.id.length-1)!=")"?p.type="event":p.type=="library"?p.type="library":p.id.charAt(p.id.length-1)==")"?p.type="function":p.type="variable";a.DEBUG.typeName=p.type;switch(p.type){case "sequence":new a.Function(this.parent,p);break;case "algorithm":this.parent.auxiliaries.push(new a.Algorithm(this.parent,p));break;case "constant":case "vector":case "matrix":t=p.type=="constant"?new a.Constant(this.parent,p):p.type=="vector"?new a.Vector(this.parent,p):new a.Matrix(this.parent,p);
p.evaluate&&p.evaluate=="always"&&this.parent.auxiliaries.push(t);break;case "event":this.parent.events.push(new a.Event(this.parent,p));break;case "library":new a.Library(this.parent,p);break;case "variable":new a.Variable(this.parent,p);break;default:new a.Function(this.parent,p)}}parseAction(t){return t.action?new (a[g(t.action)])(t.parent,t.parameter):{execute:()=>{}}}parseAnimation(t){let c={};for(let [f,m]of this.split(t))switch(l=k[f],a.DEBUG.pName=f,a.DEBUG.objectName="Animation",l){case "info":break;
case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[l]=m.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[l]=k[m]=="true";break;default:console.warn(`Propiedad de la animaci\u00f3n no identificada: <${f}> valor: <${m}>`)}return new a.Animation(this.parent,c)}split(t){if(typeof t!="string")return[];t=(t||"").trim();let c=0,f=[],m=0,v=0,h=-1,u=-1,x,z;for(;m<t.length;)if(c==0)for(;m<t.length&&c==0;)t[m]=="="&&(h=m,c=1,t[m+1]=="'"&&
(c=2,m++),u=m+1),m++;else for(;m<t.length&&c!=0;)z=c==1?t[m]==" ":t[m]=="'"&&t[m-1]!="\\",x=m,z&&(c=0,f.push([t.slice(v,h).trim(),t.slice(u,x)]),v=m+1,h=u=-1),m++;u!=-1&&f.push([t.slice(v,h).trim(),t.slice(u)]);return f}}a.LessonParser=r})(descartesJS,babel);
(a=>{function k(){return parseFloat(this.value)}function g(){return this.value.replace(/\\u0027/g,"'")}function d(B,K){let R=B.variables[this.value];if(typeof R=="object"&&R.length==void 0)return R.evaluate(B);R==void 0&&(K||B.matrices[this.value]?R=B.matrices[this.value]:B.vectors[this.value]&&(R=B.vectors[this.value]));return R!==void 0?R:0}function b(B){try{let K=B.getVector(this.value,this.childs[0].childs[0].evaluate(B));return K!==void 0?K:0}catch(K){return 0}}function e(B){try{let K=B.getMatrix(this.value,
this.childs[0].childs[0].evaluate(B),this.childs[0].childs[1].evaluate(B));return K!==void 0?K:0}catch(K){return 0}}function l(B){return B.functions[this.value].apply(B,this.childs[0].childs.map(K=>K.evaluate(B)))}function w(B){var K=this.childs[0].evaluate(B,!0);B=this.childs[1].evaluate(B,!0);if(K.type!="matrix"||B.type!="matrix")return typeof K=="number"&&typeof B=="string"?K+="":typeof K=="string"&&typeof B=="number"&&(B+=""),K+B;W=K.rows;M=K.cols;E=N(W,M);for(Q=0;Q<W;Q++)for(O=0;O<M;O++)E[O][Q]=
K[O][Q]+B[O][Q];return E}function q(B){let K=this.childs[0].evaluate(B,!0);B=this.childs[1].evaluate(B,!0);if(K.type!=="matrix"||B.type!=="matrix")return K-B;W=K.rows;M=K.cols;E=N(W,M);for(Q=0;Q<W;Q++)for(O=0;O<M;O++)E[O][Q]=K[O][Q]-B[O][Q];return E}function n(B){let K=this.childs[0].evaluate(B,!0);B=this.childs[1].evaluate(B,!0);return K.type!=="matrix"||B.type!=="matrix"?K*B:Z(K,B)}function p(B){var K=this.childs[0].evaluate(B,!0);B=this.childs[1].evaluate(B,!0);if(K.type!=="matrix"||B.type!=="matrix")return K/
B;{let Y=N(B.length,B.length);var R=ca(B);if(R==0)B=0;else{R=1/R;if(B.length>1)for(let fa=0,ea=B.length;fa<ea;fa++){var V=R;for(let da=0;da<ea;da++)Y[da][fa]=V*ca(ba(fa,da,B)),V=-V;R=-R}else Y[0][0]=R;B=Y}}K=B==0?N(K.rows,K.cols):Z(K,B);return K}function r(B){let K=this.childs[0].evaluate(B);B=this.childs[1].evaluate(B);return K-Math.floor(K/B)*B}function t(B){let K=this.childs[0].evaluate(B);B=this.childs[1].evaluate(B);return B>=0?J(K,B):1/J(K,-B)}function c(B){return+(this.childs[0].evaluate(B)<
this.childs[1].evaluate(B))}function f(B){return+(this.childs[0].evaluate(B)<=this.childs[1].evaluate(B))}function m(B){return+(this.childs[0].evaluate(B)>this.childs[1].evaluate(B))}function v(B){return+(this.childs[0].evaluate(B)>=this.childs[1].evaluate(B))}function h(B){let K=this.childs[0].evaluate(B);B=this.childs[1].evaluate(B);return typeof K=="number"&&typeof B=="number"?+(Math.abs(K-B)<1E-8):+(K===B)}function u(B){let K=this.childs[0].evaluate(B);B=this.childs[1].evaluate(B);return typeof K==
"number"&&typeof B=="number"?+(Math.abs(K-B)>=1E-8):+(K!==B)}function x(B){return this.childs[0].evaluate(B)?this.childs[1].evaluate(B)?1:0:0}function z(B){return this.childs[0].evaluate(B)?1:this.childs[1].evaluate(B)?1:0}function G(B){return+!this.childs[0].evaluate(B)}function A(B){return this.childs[0].evaluate(B)>0?this.childs[1].evaluate(B):this.childs[2]?this.childs[2].evaluate(B):0}function I(B){return this.childs[0].evaluate(B)}function S(B){return-this.childs[0].evaluate(B)}function F(B,
K){return this.childs[0].evaluate(B,K)}function y(B){return this.childs.length==1&&this.childs[0].childs.length==1&&this.type=="(expr)"?this.childs[0].childs[0].evaluate(B):this.childs.map(K=>K.childs.map(R=>R.evaluate(B)))}function H(B){let K=this.childs[0],R=K.childs[0]?K.childs[0].childs:null,V=this.childs[1].evaluate(B);B.setVector(K.value,R[0].evaluate(B),V);return V}function C(B){let K=this.childs[0],R=K.childs[0]?K.childs[0].childs:null,V=this.childs[1].evaluate(B);B.setMatrix(K.value,R[0].evaluate(B),
R[1].evaluate(B),V);return V}function D(B){let K=this.childs[0],R=this.childs[1].evaluate(B);return R.type?B.matrices[K.value]=R:typeof B.variables[K.value]!="object"?B.variables[K.value]=R:0}function J(B,K){if(K==0)return 1;if(K<0)return NaN;if(B>=0||Math.floor(K)===K)return Math.pow(B,K);if(B<0){let R=1/K,V=Math.floor(R);if(V===R&&V%2===1)return-Math.pow(-B,K)}return NaN}function N(B,K){E=[];E.type="matrix";E.rows=B;E.cols=K;Q=0;for(X=K;Q<X;Q++)E[Q]=Array(B).fill(0);return E}function Z(B,K){W=B.rows;
M=B.cols;E=N(W,M);let R;for(Q=0;Q<W;Q++)for(O=0;O<M;O++){for(X=R=0;X<M;X++)R+=B[X][Q]*K[O][X];E[O][Q]=R}return E}function ba(B,K,R){let V=N(R.length-1,R.length-1);for(let Y=0,fa=V.length;Y<fa;Y++)for(let ea=0;ea<fa;ea++)V[Y][ea]=Y<B?ea<K?R[Y][ea]:R[Y][ea+1]:Y<K?R[Y+1][ea]:R[Y+1][ea+1];return V}function ca(B){if(B.cols>1){let K=0,R=1;for(let V=0,Y=B.cols;V<Y;V++)K+=R*B[0][V]*ca(ba(0,V,B)),R=-R;return K}return B[0][0]}let aa,L,P,U,W,M,E,O,Q,X;class T{constructor(B,K){this.sep="";this.type=B;this.value=
K;this.parent=null;this.childs=[]}getRoot(){return this.parent===null?this:this.parent.getRoot()}addChild(B){B.parent=this;this.childs.push(B)}replaceLastChild(B){L=this.childs.length-1;aa=this.childs[L];aa.parent=null;this.childs[L]=B;B.parent=this;return B}contains(B){if(this.value===B)return!0;for(let K of this.childs)if(K.contains(B))return!0;return!1}equalToMinus(){return this.type=="compOperator"?(this.type="operator",this.value="-",U=new T("compOperator","=="),U.addChild(this),U.addChild(new T("number",
"0")),P=this.getRoot(),P.setAllEvalFun(),P):this}getChildren(){if(this.type=="(expr)"||this.type=="[expr]"){if(this.childArray)return this.childArray;this.childArray=[];for(let B of this.childs)/square_bracket|parentheses/.test(B.type)&&this.childArray.push(...B.childs);return this.childArray}return null}setAllEvalFun(){this.setEvalFun();for(let B of this.childs)B.setAllEvalFun()}setEvalFun(){if(this.type=="number")this.evaluate=k;else if(this.type=="string")this.evaluate=g;else if(this.type=="identifier")this.childs.length==
0?this.evaluate=d:this.childs[0].type=="square_bracket"?this.childs[0].childs.length==1?this.evaluate=b:this.childs[0].childs.length>1&&(this.evaluate=e):this.childs[0].type=="parentheses"&&(this.evaluate=l);else if(this.type=="operator")this.value=="+"?this.evaluate=w:this.value=="-"?this.evaluate=q:this.value=="*"?this.evaluate=n:this.value=="/"?this.evaluate=p:this.value=="%"?this.evaluate=r:this.value=="^"&&(this.evaluate=t);else if(this.type=="compOperator")this.value=="<"?this.evaluate=c:this.value==
"<="?this.evaluate=f:this.value==">"?this.evaluate=m:this.value==">="?this.evaluate=v:this.value=="=="?this.evaluate=h:this.value=="!="&&(this.evaluate=u);else if(this.type=="boolOperator")this.value=="&"?this.evaluate=x:this.value=="|"?this.evaluate=z:this.value=="!"&&(this.evaluate=G);else if(this.type=="conditional")this.evaluate=A;else if(this.type=="sign")this.evaluate=this.value=="sign+"?I:S;else if(this.type=="parentheses")this.evaluate=F;else if(this.type=="(expr)"||this.type=="[expr]")this.evaluate=
y;else if(this.type=="assign"){let B=this.childs[0],K=B.childs[0]?B.childs[0].childs:null;B.childs.length==1&&B.childs[0].type=="square_bracket"?K.length==1?this.evaluate=H:K.length==2&&(this.evaluate=C):this.evaluate=D}}}a.Node=T})(descartesJS);
(a=>{let k,g,d=/\|/g,b=/\|\*/g,e=/\*\|/g;const l=n=>n>="0"&&n<="9",w=n=>n=="_"||n.toLowerCase()!==n.toUpperCase();class q{constructor(){}tokenize(n=""){n=n.trim();if(n=="")return[];n&&(n=n.replace(/\\u(\S+) /g,(c,f)=>f.startsWith("{")||parseInt(f,16)===39?c:String.fromCharCode(parseInt(f,16))).replace(/&sup(.+?);/g,"^$1 ").replace(/&squot;/g,"'").replace(/&squot/g,"'"),n.includes("=|*")&&(n=n.replace(b,"'").replace(e,"'")),n.includes("=|")&&(n=n.replace(d,"'")),n.startsWith("|")&&n.endsWith("|")&&
(n=n.slice(1,-1)));k=[];let p=0;for(var r,t;p<n.length;)if(r=n[p],t=n[p+1],r=="["||r=="]")k.push({type:"square_bracket",value:r}),p++;else if(r=="("||r==")")t=k[k.length-1],r=="("&&t&&t.type=="number"&&k.push({type:"operator",value:"*"}),k.push({type:"parentheses",value:r}),p++;else if(r==",")k.push({type:"separator",value:r}),p++;else{if(r=="/"&&t==r)break;if("%^+-*/\u00f7\u2212\u00b7\u00d7".includes(r))k.push({type:"operator",value:r.replace(/\u00f7/g,"/").replace(/\u2212/g,"-").replace(/\u00b7|\u00d7/g,
"*")}),p++;else if(r=="\u00b2"||r=="\u00b3")k.push({type:"operator",value:"^"}),k.push({type:"number",value:r=="\u00b2"?"2":"3"}),p++;else if(r=="'"){t="";for(p++;p<n.length&&n[p]!=r;)t+=n[p],p++;p++;k.push({type:"string",value:t})}else if(t=="="&&"=!<>".includes(r))k.push({type:"compOperator",value:`${r}=`}),p+=2;else if(r=="<"||r==">"||r=="#")k.push({type:"compOperator",value:r=="#"?"!=":r}),p++;else if(r==="="&&t!="=")k.push({type:"assign",value:r}),p++;else if(r==":"&&t=="=")k.push({type:"assign",
value:":="}),p+=2;else if(r=="&"&&t==r||r=="|"&&t==r)k.push({type:"boolOperator",value:r}),p+=2;else if("&|!~".includes(r))k.push({type:"boolOperator",value:r=="~"?"!":r}),p++;else if(r=="?"||r==":")k.push({type:"conditional",value:r}),p++;else if(r>="0"&&r<="9"||r=="."&&t>="0"&&t<="9"){r="";t=!1;let c;for(;p<n.length;){c=n[p];if(c>="0"&&c<="9")r+=c;else if(c!="."||t)break;else t=!0,r+=c;p++}k.push({type:"number",value:r})}else if(r==";")p++;else if(w(r)){t=k[k.length-1];for(r="";p<n.length&&(w(n[p])||
l(n[p])||n[p]==".");)r+=n[p],p++;t&&t.type=="number"&&k.push({type:"operator",value:"*"});r!="rnd"?k.push({type:"identifier",value:r}):(k.push({type:"identifier",value:"random"}),k.push({type:"parentheses",value:"("}),k.push({type:"parentheses",value:")"}))}else r.trim().length!=0&&a.DEBUG.setError(a.DEBUG.EXPRESSION,n),p++}return k}flatTokens(n=[],p=""){g="";for(let r of n)g=r.type=="string"?g+`&squot;${r.value}&squot;`:r.type!="identifier"||a.reservedIds.includes(r.value)?g+r.value:g+(p+r.value);
return g}}a.Tokenizer=q})(descartesJS);
(a=>{function k(v){v=String(v).trim().replace(/^'|'$/g,"");let h=parseFloat(v);return isNaN(h)||String(h)!=v?v:h}function g(v,h,u,x){console.info(`Error${v}: en la expresi\u00f3n \u300a${h}\u300b, en el token {valor: ${u}, tipo: ${x}}`)}a.reservedIds="_ _NUM_MAX_ITE_ALG_ rnd pi \u03c0 e Infinity isTouch esT\u00e1ctil device dispositivo screenOrientation screenWidth screenHeight sqr sqrt ra\u00edz exp log log10 abs ent sgn ind sin sen cos tan cot sec csc sinh senh cosh tanh coth sech csch asin asen acos atan atan2 floor piso ceil techo round redondeo trunc truncamiento min max _Trace_ _Print_ _Num_ isNumber esN\u00famero random aleatorio _Stop_Audios_ parent.set parent.update parent.exec toFixed _NumToStr_ _NumACadena_ charAt _charAt_ _letraEn_ substring _substring_ _subcadena_ strLength _length_ _longitud_ indexOf _indexOf_ \u00edndiceDe lastIndexOf replace _replace_ _reemplazar_ toLowerCase toUpperCase trim _Load_ _GetValues_ _GetMatrix_ _MatrixToStr_ _StrToMatrix_ _GetVector_ _VectorToStr_ _StrToVector_ _ExecStr_ _ExecBlock_ _Save_ _SaveSpace_ _Open_ _SaveState_ _OpenState_ _AnchoDeCadena_ _strWidth_ R G B _Rojo_ _Red_ _Verde_ _Green_ _Azul_ _Blue_ HSV2RGB DJS.typeof DJS.squote DJS.comma DJS.w DJS.h".split(" ");const d=
String.fromCharCode("166");let b,e,l,w,q,n,p,r,t,c;class f{constructor(v){this.evaluator=v;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.definitions={};this.registerDefaultValues();this.registerExternalValues&&this.registerExternalValues()}parse(v="",h){b=this.tokenizer.tokenize(v);if(b.length==0)return null;e=null;h=!h||!1;w=q=n=0;for(let u=0,x=b.length;u<x;u++){p=b[u];r=p.value;t=p.type;if(t=="identifier")if(b[u+1]&&b[u+1].type=="parentheses"&&
b[u+1].value=="(")this.functions.hasOwnProperty(r)||(this.functions[r]=()=>0);else if(b[u+1]&&b[u+1].type=="square_bracket"&&b[u+1].value=="[")b[u+3]&&b[u+3].type=="square_bracket"&&b[u+3].value=="]"?this.vectors.hasOwnProperty(r)||(this.vectors[r]=[0,0,0]):this.matrices.hasOwnProperty(r)||(this.matrices[r]=[[0,0,0],[0,0,0],[0,0,0]]);else{let z=r.match(/(\w*)(?:\.mouse_x|\.mouse_y|\.mouse_pressed|\.mouse_clicked|\.clic_izquierdo)$/);z&&(this.variables[z[1]+".DJS_NO_FIXED"]=1)}t=="assign"&&h&&r!=":="&&
(t="compOperator",r="==");if(t=="assign")if(l=new a.Node(t,r),e!=null){h=!0;if(e.type=="identifier")e.parent&&e.parent.replaceLastChild(l),l.addChild(e);else if(e.type=="square_bracket")l.addChild(e.parent);else{l.type="compOperator";for(l.value="==";e.parent&&(m[e.parent.value]||9)>=(m[l.value]||9);)e=e.parent;e.parent&&e.parent.replaceLastChild(l);l.addChild(e)}e=l}else{g(1,v,r,t);break}else if(t=="parentheses"&&r=="("||t=="square_bracket"&&r=="[")if(l=new a.Node(t,r),r=="("&&w++,r=="["&&q++,e==
null)r=="("&&(new a.Node("(expr)","(expr)")).addChild(l),r=="["&&(new a.Node("[expr]","[expr]")).addChild(l),e=l;else if(e.type=="operator"||e.type=="boolOperator"||e.type=="compOperator"||e.type=="conditional"||e.type=="assign"||e.type=="sign"||e.type=="parentheses"&&e.value=="("||e.type=="square_bracket"&&e.value=="["||e.type=="identifier")e.addChild(l),e=l;else if(e.type=="parentheses"&&e.value=="()"||e.type=="square_bracket"&&e.value=="[]")e.parent.addChild(l),e=l;else{g(2,v,r,t);break}else if(t==
"parentheses"&&r==")")if(w--,e==null)g(3,v,r,t);else{for(;e&&e.parent&&(e.value!="("||e.value=="("&&e.type!="parentheses");)e=e.parent;if(e&&e.value=="(")e.value="()";else{g(4,v,r,t);break}}else if(t=="square_bracket"&&r=="]")if(q--,e==null)g(5,v,r,t);else{for(;e&&e.parent&&(e.value!="["||e.value=="["&&e.type!="square_bracket");)e=e.parent;if(e&&e.value=="[")e.value="[]";else{g(6,v,r,t);break}}else if(t=="number"||t=="string"||t=="identifier")if(l=new a.Node(t,r),e==null)e=l;else if(e.type=="operator"||
e.type=="compOperator"||e.type=="boolOperator"||e.type=="parentheses"&&e.value=="("||e.type=="square_bracket"&&e.value=="["||e.type=="sign"||e.type=="conditional"||e.type=="assign")e.addChild(l),e=l;else break;else if(t=="operator"||t=="compOperator"||t=="boolOperator")if(l=new a.Node(t,r),e==null)if(r=="-"||r=="+")l.type="sign",l.value="sign"+r,e=l;else if(r=="!")e=l;else{g(8,v,r,t);break}else if(e.type=="operator"||e.type=="compOperator"||e.type=="boolOperator"||e.type=="assign"||e.type=="conditional"||
e.type=="square_bracket"&&e.value=="["&&(r=="-"||r=="+"||r=="!")||e.type=="parentheses"&&e.value=="("&&(r=="-"||r=="+"||r=="!")){if(r=="-"||r=="+")l.type="sign",l.value="sign"+r;e.addChild(l);e=l}else if(e.type=="number"||e.type=="parentheses"&&e.value=="()"||e.type=="square_bracket"&&e.value=="[]"||e.type=="string"||e.type=="identifier"||e.type=="conditional"||e.type=="assign"){for(;e.parent&&(m[e.parent.value]||9)>=(m[l.value]||9);)e=e.parent;e.parent&&e.parent.replaceLastChild(l);l.addChild(e);
e=l}else{g(9,v,r,t);break}else if(t=="conditional")if(l=new a.Node(t,r),e!=null)if(l.value=="?"){for(n++;e.parent&&(m[e.parent.value]||9)>(m[l.value]||9);)e=e.parent;e.parent&&e.parent.replaceLastChild(l);l.addChild(e);e=l}else{for(n--;e&&e.parent&&(e.value!="?"||e.value=="?"&&e.type!="conditional");)e=e.parent;if(e&&e.value=="?")e.value="?:";else{g(10,v,r,t);break}}else{g(11,v,r,t);break}else if(t=="separator")if(e!=null)for(;e.parent&&e.value!="("&&e.value!="[";)e=e.parent;else{g(12,v,r,t);break}else{g(13,
v,r,t);break}}w>0&&a.DEBUG.setError(a.DEBUG.PARENTHESIS_CLOSING,v);w<0&&a.DEBUG.setError(a.DEBUG.PARENTHESIS_OPENING,v);q>0&&a.DEBUG.setError(a.DEBUG.BRACKET_CLOSING,v);q<0&&a.DEBUG.setError(a.DEBUG.BRACKET_OPENING,v);n!=0&&a.DEBUG.setError(a.DEBUG.INCOMPLETE_IF,v);(c=e?e.getRoot():null)&&c.setAllEvalFun();return c}registerDefaultValues(){let v=Date.now();const h=this;h.variables._NUM_MAX_ITE_ALG_=1E5;h.variables.pi=h.variables["\u03c0"]=Math.PI;h.variables.e=Math.E;h.variables.Infinity=Infinity;
h.variables["-Infinity"]=-Infinity;h.variables.isTouch=h.variables["esT\u00e1ctil"]=+a.hasTouchSupport;h.variables.device=h.variables.dispositivo=(()=>{const y=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(y)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(y)?"mobile":"desktop"})();Object.defineProperties(h.variables,{screenOrientation:{get:()=>window.matchMedia("(orientation: landscape)").matches?
"landscape":"portrait"},screenWidth:{get:()=>window.innerWidth},screenHeight:{get:()=>window.innerHeight}});h.variables["DJS.squote"]="\\u0027";h.variables["DJS.comma"]="\\u002C";let u={};h.functions._Eval_=function(y=""){if(y=="")return 0;if(typeof y!="number"){var H=y.replace(",",".");y.includes(",")&&parseFloat(H)==H&&(y=H);if(u[y]==void 0)if(H=y.includes(":="),y.includes(";")){let C=!1,D,J=[],N=0;for(let Z=0,ba=y.length;Z<ba;Z++)D=y[Z],D=="'"&&(C=!C),C||D!=";"||(J.push(y.slice(N,Z)),N=Z+1);J.push(y.slice(N));
u[y]=h.parse(`(${J.join(")(")})`,H)}else u[y]=h.parse(y,H);y=h.evaluator.eval(u[y]);return y!=void 0?y:"NaN"}return"NaN"};h.functions.sqr=y=>y*y;h.functions.sqrt=h.functions["ra\u00edz"]=Math.sqrt;h.functions.exp=Math.exp;h.functions.log=Math.log;h.functions.log10=Math.log10?Math.log10:y=>Math.log(y)/Math.log(10);h.functions.abs=Math.abs;h.functions.ent=y=>Math.trunc(parseFloat(y)+Math.sign(y)*1E-16);h.functions.sgn=Math.sign;h.functions.ind=y=>y?1:0;h.functions.sin=h.functions.sen=Math.sin;h.functions.cos=
Math.cos;h.functions.tan=Math.tan;h.functions.cot=y=>1/Math.tan(y);h.functions.sec=y=>1/Math.cos(y);h.functions.csc=y=>1/Math.sin(y);h.functions.sinh=h.functions.senh=Math.sinh?Math.sinh:y=>(Math.exp(y)-Math.exp(-y))/2;h.functions.cosh=Math.cosh?Math.cosh:y=>(Math.exp(y)+Math.exp(-y))/2;h.functions.tanh=Math.tanh?Math.tanh:y=>(Math.exp(y)-Math.exp(-y))/(Math.exp(y)+Math.exp(-y));h.functions.coth=y=>1/h.functions.tanh(y);h.functions.sech=y=>1/h.functions.cosh(y);h.functions.csch=y=>1/h.functions.sinh(y);
h.functions.asin=h.functions.asen=Math.asin;h.functions.acos=Math.acos;h.functions.atan=Math.atan;h.functions.atan2=Math.atan2;h.functions.floor=h.functions.piso=Math.floor;h.functions.ceil=h.functions.techo=Math.ceil;h.functions.round=h.functions.redondeo=Math.round;h.functions.trunc=h.functions.truncamiento=Math.trunc;h.functions.min=Math.min;h.functions.max=Math.max;h.functions.clamp=h.functions.acotar=(y,H,C)=>H<C?Math.max(Math.min(y,C),H):Math.max(Math.min(y,H),C);h.functions._Trace_=h.functions._Print_=
function(){console.info.apply(console,arguments);return 0};h.functions._Num_=y=>{if(typeof y=="number")return"NaN";y=y.replace(",",".");return parseFloat(y)==y?parseFloat(y):"NaN"};h.functions.isNumber=h.functions["esN\u00famero"]=y=>+Number.isFinite(y);h.functions.random=h.functions.aleatorio=(y,H)=>{y=isNaN(parseFloat(y))?0:parseFloat(y);H=isNaN(parseFloat(H))?1:parseFloat(H);y>H&&([y,H]=[H,y]);return y+Math.random()*(H-y)};h.functions._Stop_Audios_=()=>{h.evaluator.parent.stopAudios()};window.parent!==
window&&(h.functions["parent.set"]=(y,H)=>{window.parent.postMessage({type:"set",name:y,value:H},"*");return 0},h.functions["parent.update"]=()=>{window.parent.postMessage({type:"update"},"*");return 0},h.functions["parent.exec"]=(y,H)=>{window.parent.postMessage({type:"exec",name:y,value:H},"*");return 0});h.functions.toFixed=h.functions._NumToStr_=h.functions._NumACadena_=(y,H)=>{y=isNaN(parseFloat(y))?0:parseFloat(y);return y.toFixed(parseInt(H||0)).replace(".",h.evaluator.parent.decimal_symbol)};
h.functions.charAt=h.functions._charAt_=h.functions._letraEn_=(y,H)=>{y=""+(y||"");H=isNaN(parseInt(H))?0:parseInt(H);return y.charAt(H)};h.functions.substring=h.functions._substring_=h.functions._subcadena_=(y,H,C)=>{y=""+(y||"");H=parseInt(H)||0;C=parseInt(C)||0;return H<0&&C<0?"":H<0?y.substring(C):C<0?y.substring(H):y.substring(H,C)};h.functions.strLength=h.functions._length_=h.functions._longitud_=y=>(""+(y||"")).length;h.functions.indexOf=h.functions._indexOf_=h.functions["_\u00edndiceDe_"]=
(y,H)=>(""+(y||"")).indexOf(""+(H||""));h.functions.lastIndexOf=(y,H)=>(""+(y||"")).lastIndexOf(""+(H||""));h.functions.replace=h.functions._replace_=h.functions._reemplazar_=(y,H,C)=>{y=""+(y||"");C=""+(C||"");H=(""+(H||"")).replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return y.replace(new RegExp(H,"g"),C)};h.functions.toLowerCase=y=>(""+(y||"")).toLowerCase();h.functions.toUpperCase=y=>(""+(y||"")).toUpperCase();h.functions.trim=y=>(""+(y||"")).trim();h.functions._Load_=y=>{if(y)var H=(H=document.getElementById(y))&&
H.type=="descartes/archivo"?H.text:a.openFile(y);return H||""};h.functions._GetValues_=function(y,H){return h.functions._ExecBlock_(h.functions._Load_(y).replace(/&brvbar;/g,d),H)};h.functions._GetMatrix_=function(y,H){return h.functions._StrToMatrix_(h.functions._Load_(y).replace(/&brvbar;/g,d),H)};h.functions._MatrixToStr_=function(y){let H=h.matrices[y];if(H){let C=`<${y}>\\n`,D=h.evaluator.getVariable(y+".columnas_usadas")||H.cols||0,J=h.evaluator.getVariable(y+".filas_usadas")||H.rows||0,N;for(let Z=
0;Z<D;Z++){for(let ba=0;ba<J;ba++)N=H[Z][ba],N!==void 0&&(typeof N=="string"?N=`'${N}'`:typeof N=="number"&&(N=String(Number(N.toFixed(6)))),C+=N+(ba<J-1?" \u00a6 ":""));C=C.replace(/(\u00A6 )$/g,"")+"\\n"}return C+`</${y}>`}return""};h.functions._StrToMatrix_=function(y,H){let C=[];var D=!1;let J=!1;C.type="matrix";if(y){y=y.replace(/\r|\\r/g,"").split(/\n|\\n/);for(let N=0,Z=y.length;N<Z;N++)y[N].includes(`<${H}>`)?(J=!0,D=y[N].trim().split(`<${H}>`),D.length==2&&D[1]!=""&&C.push(D[1].split(d).map(k)),
D=!0):(y[N].includes(`</${H}>`)&&(D=y[N].trim().split(`</${H}>`),D.length==2&&D[0]!=""&&C.push(D[0].split(d).map(k)),D=!1,N=y.length),D&&C.push(y[N].split(d).map(k)));h.matrices[H]=C;h.matrices[H].rows=C&&C[0]&&C[0].length?C[0].length:0;h.matrices[H].cols=C&&C.length?C.length:0;h.evaluator.setVariable(H+".filas",h.matrices[H].rows);h.evaluator.setVariable(H+".columnas",h.matrices[H].cols)}return J?"OK":"ERROR"};h.functions._GetVector_=function(y,H){return h.functions._StrToVector_(h.functions._Load_(y),
H)};h.functions._VectorToStr_=function(y){let H=h.vectors[y];if(H){let C=`<${y}>\\n`,D=h.evaluator.getVariable(`${y}.long_usada`)||H._size_||0,J;for(let N=0;N<D;N++)J=H[N],J!==void 0?(typeof J=="number"&&(J=parseFloat(J)),C+=J+"\\n"):C+="0\\n";return C+`</${y}>`}return""};h.functions._StrToVector_=function(y,H){let C=[],D=!1,J=!1;C.type="vector";if(y){y=y.replace(/\r|\\r/g,"").split(/\n|\\n/);for(let N=0,Z=y.length;N<Z;N++)y[N].includes(`<${H}>`)?D=J=!0:(y[N].includes(`</${H}>`)&&(D=!1,N=y.length),
D&&C.push(k(y[N])));C._size_=C.length;h.vectors[H]=C;h.evaluator.setVariable(`${H}.long`,C.length);h.evaluator.setVariable(`${H}.long_usada`,C.length)}return J?"OK":"ERROR"};h.functions._ExecStr_=function(y){return h.functions._ExecBlock_(y,"")};h.functions._ExecBlock_=function(y,H){let C=[];var D=H=="";if(y){y=y.replace(/\r|\\r/g,"").split(/\n|\\n/);for(let J=0,N=y.length;J<N;J++)y[J].includes(`<${H}>`)?(D=y[J].trim().split(`<${H}>`),D.length==2&&D[1]!=""&&(C=C.concat(D[1].split(d))),D=!0):y[J].includes(`</${H}>`)?
(D=y[J].trim().split(`</${H}>`),D.length==2&&D[0]!=""&&(C=C.concat(D[0].split(d))),D=!1):D&&(C=C.concat(y[J].split(d)));for(let J=0,N=C.length;J<N;J++)D=C[J].split("="),D[0]=D[0].trim(),D.length==2&&D[0]!=""&&(isNaN(parseFloat(D[1]))?h.evaluator.setVariable(D[0],D[1].trim().replace(/^'|'$/g,"")):h.evaluator.setVariable(D[0],parseFloat(D[1])))}return 0};let x=a.newHTML("a",{target:"_blank"}),z,G=null;a.newBlobContent=null;h.functions._Save_=function(y,H){h.evaluator.parent.removeButtonClick();Date.now()-
v>1500&&(v=Date.now(),document.body.appendChild(x),G=H.replace(/\\r/g,"").replace(/\\n/g,"\r\n").replace(/\\q/g,"'").replace(/\\_/g,"\\").replace(/\\br/g,"\\n"),z=new Blob(["\ufeff",G],{type:"text/plain;charset=utf-8"}),x.setAttribute("href",window.URL.createObjectURL(z)),x.setAttribute("download",y),G!=a.newBlobContent&&(x.click(),a.newBlobContent=G),x.remove());return 0};let A=a.newHTML("a",{target:"_blank"});h.functions._SaveSpace_=function(y,H){h.evaluator.parent.removeButtonClick();Date.now()-
v>1500&&(v=Date.now(),document.body.appendChild(A),G=H,A.setAttribute("href",G),A.setAttribute("download",y),G!=a.newBlobContent&&(A.click(),a.newBlobContent=G),A.remove());return 0};let I,S,F=a.newHTML("input",{type:"file"});F.addEventListener("change",function(y){I=y.target.files;S=new FileReader;S.onload=function(H){a.addExternalFileContent(I[0].name,H.target.result);h.evaluator.setVariable("DJS.fileName",I[0].name);h.evaluator.setVariable("DJS.fileContent",H.target.result);if(H=h.evaluator.getFunction(h._callback))H.apply(h.evaluator,
[]),h.evaluator.parent.update();F.value=""};I.length>0&&S.readAsText(I[0])});h.functions._Open_=function(y){h.evaluator.parent.removeButtonClick();Date.now()-v>1500&&(h._callback=y,F.click(),v=Date.now());return 0};h.functions._AnchoDeCadena_=h.functions._strWidth_=(y,H,C,D)=>a.getTextWidth(y,a.convertFont(`${H},${C},${D}`));h.functions.R=h.functions._Rojo_=h.functions._Red_=(y="")=>a.toHex((""+y).slice(0,2))/255;h.functions.G=h.functions._Verde_=h.functions._Green_=(y="")=>a.toHex((""+y).slice(2,
4))/255;h.functions.B=h.functions._Azul_=h.functions._Blue_=(y="")=>a.toHex((""+y).slice(4,6))/255;h.functions.HSV2RGB=function(y,H,C){y<0&&(y+=360);y%=360;H*=C;let D=H*(1-Math.abs(y/60%2-1));C-=H;let J;0<=y&&y<60?(y=H,J=D,H=0):60<=y&&y<120?(y=D,J=H,H=0):120<=y&&y<180?(y=0,J=H,H=D):180<=y&&y<240?(y=0,J=D):240<=y&&y<300?(y=D,J=0):300<=y&&y<360?(y=H,J=0,H=D):y=J=H=0;y=Math.round((y+C)*255);J=Math.round((J+C)*255);H=Math.round((H+C)*255);return`${y.toString(16).padStart(2,"0")}${J.toString(16).padStart(2,
"0")}${H.toString(16).padStart(2,"0")}`};h.functions["DJS.typeof"]=function(y){return y.rows?"matrix":y._size_?"vector":typeof y}}}const m={"=":1,":=":1,"(":2,"[":2,"?":2,":":3,"?:":3,"<":5,"<=":5,">":5,">=":5,"==":5,"!=":5,"|":6,"+":6,"-":6,"&":7,"/":7,"*":7,"sign-":7,"sign+":7,"!":8,"%":8,"^":9};a.Parser=f})(descartesJS);
(a=>{class k{constructor(g){this.parent=g;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices;this.definitions=this.parser.definitions}setDefinition(g,d){this.definitions[g]=d}getDefinition(g){return this.definitions[g]}setVariable(g,d){this.variables[g]=d}getVariable(g){return this.variables[g]}setVector(g,d,b){d=d<0?0:Math.floor(d);this.vectors[g][d]=b}getVector(g,d){d=d<0?0:
Math.floor(d);return this.vectors[g][d]}setMatrix(g,d,b,e){d=d<0?0:Math.floor(d);b=b<0?0:Math.floor(b);this.matrices[g][d]==void 0&&(this.matrices[g][d]=[]);this.matrices[g][d][b]=e}getMatrix(g,d,b){d=d<0?0:Math.floor(d);b=b<0?0:Math.floor(b);return this.matrices[g][d][b]}setFunction(g,d){this.functions[g]=d}getFunction(g){return this.functions[g]}eval(g){return g?g.evaluate(this):0}}a.externalEvaluator=new k;a.Evaluator=k})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t,c,f;const m={"\\{":"\\curlyBracketOpen ","\\}":"\\curlyBracketClose ","\\[":"\\squareBracketOpen ","\\]":"\\squareBracketClose ","\\BIG(":"\\BIGbracketOpen ","\\BIG)":"\\BIGbracketClose ","\\BIG{":"\\BIGcurlyBracketOpen ","\\BIG}":"\\BIGcurlyBracketClose ","\\BIG[":"\\BIGsquareBracketOpen ","\\BIG]":"\\BIGsquareBracketClose ","\\BIG|":"\\BIGbar ","\\Big(":"\\BigbracketOpen ","\\Big)":"\\BigbracketClose ","\\Big{":"\\BigcurlyBracketOpen ","\\Big}":"\\BigcurlyBracketClose ",
"\\Big[":"\\BigsquareBracketOpen ","\\Big]":"\\BigsquareBracketClose ","\\Big|":"\\Bigbar ","\\big(":"\\bigbracketOpen ","\\big)":"\\bigbracketClose ","\\big{":"\\bigcurlyBracketOpen ","\\big}":"\\bigcurlyBracketClose ","\\big[":"\\bigsquareBracketOpen ","\\big]":"\\bigsquareBracketClose ","\\big|":"\\bigbar "},v=/(?:\\BIG|\\Big|\\big)(?:\(|\)|\{|\}|\[|\]|\|)|\\\{|\\\}|\\\[|\\\]/g;class h{constructor(u,x){this.parent=u;this.evaluator=u.evaluator;this.decimals=u.decimals;this.fixed=u.fixed;this.align=
u.align||"left";this.anchor=u.anchor||"a_top_left";this.decimal_symbol=u.parent.decimal_symbol;this.w=this.h=100;this.hasContent=x!=="";this.oldTextStr=this.oldWidth=this.oldSize=this.oldColor=this.oldPosX=this.oldPosY=this.style=null;x.startsWith("{\\rtf")?(this.type="rtfNode",this.text=x,this.textNodes=a.RTFParser.parse(x.slice(10),u.evaluator),this.draw=this.drawRTF):(this.text=this.parseSimpleText((x||"").replace(v,z=>m[z])),this.textNodes=null,this.draw=this.drawText)}drawText(u,x,z,G,A){k=this.evaluator.eval(this.decimals);
g=this.evaluator.eval(this.parent.width);d=this.evaluator.eval(this.parent.font_size);b=x&&x.getColor?x.getColor():x;e=this.updateTextStr();if(this.oldTextStr!=e||this.oldWidth!=g||this.oldColor!=b||this.oldSize!=d||A){this.style==null&&(this.style=new a.TextStyle({size:d,family:this.parent.font_family||"arial",italic:this.parent.italics||!1,bold:this.parent.bold||!1,color:b,align:this.align,border:this.parent.border,border_size:this.parent.border_size,shadowBlur:this.parent.shadowBlur,shadowOffsetX:this.parent.shadowOffsetX,
shadowOffsetY:this.parent.shadowOffsetY,shadowColor:this.parent.shadowColor||"transparent"}));if(this.oldColor!=b||this.oldSize!=d)this.style.color=b,this.style.size=d;this.textNodes=a.DescarTeXParser.parse(e,this.evaluator,this.style);this.textNodes.update(z,G,k,this.fixed,this.align,this.anchor,b,g)}else this.oldPosX==z&&this.oldPosY==G||this.textNodes.update(z,G,k,this.fixed,this.align,this.anchor,b,g);A||this.textNodes.draw(u);this.oldTextStr=e;this.oldWidth=g;this.oldSize=d;this.oldColor=b;this.oldPosX=
z;this.oldPosY=G}updateTextStr(){e=this.textToString(this.text,k,this.fixed).replace(v,u=>m[u]);e.includes("[")&&(e=this.textToString(this.parseSimpleText(e),k,this.fixed));return e}getTextMetrics(u){this.textNodes==null&&this.drawText(u,this.oldColor,this.oldPosX,this.oldPosY,!0);return this.textNodes.metrics}drawRTF(u,x,z,G,A){x=x.getColor?x.getColor():x;u.fillStyle=u.strokeStyle=x;u.textBaseline="alphabetic";this.textNodes.style.align!==this.align&&this.textNodes.propagateStyle("align",this.align);
this.textNodes.update(z,G,this.evaluator.eval(this.decimals),this.fixed,this.align,this.anchor,x,this.evaluator.eval(this.parent.width));A||this.textNodes.draw(u)}parseSimpleText(u){u=u.replace("&#x2013","\u2013").replace(/&squot;/g,"'");l=[];w="'";q=n=0;p=-1;for(c=u.length;q<c;)r=u[q],t=u[q-1],t!="\\"||r!="["&&r!="]"?r=="["?(p==-1&&(l.push(u.slice(n,q)),n=q),p++):r=="]"?p==0?(l.push(this.evaluator.parser.parse(u.slice(n,q+1))),n=q+1,p--):(p>=0&&p--,w+=r):w+=r:(l.push(u.slice(n,q-1)+r),n=q+1),q++;
l.push(u.slice(n,q));return l}textToString(u,x=0,z){w="";for(let G=0,A=u.length;G<A;G++)typeof u[G]=="string"?w+=u[G]:(f=this.evaluator.eval(u[G])[0][0],f!==""&&(typeof f=="string"?w+=f:Math.abs(f)==Infinity||isNaN(f)?w+=""+f:(f=parseFloat(f).toFixed(x),z||(f=String(Number(f))),w+=(""+f).replace(".",this.decimal_symbol))));return w}}a.TextObject=h})(descartesJS);
(a=>{class k{static tokenize(g){g=g.replace(/\\n/g,"\\newline ").replace(/\\u0027/g,"'");let d=[],b=null,e,l,w=!1,q=!1,n=0,p="";for(let r=0,t=g.length;r<t;r++)e=g[r],l=g[r+1],e=="\\"&&l=="$"&&(q=!0),e=="{"?n++:e=="}"&&(n--,q&&n==0&&(q=!1)),!q||e!="_"&&e!="^"?p+=e:(p+=e=="_"?"\\sub":"\\sup",l!="{"&&(p+="{"+l+"}",r++));g=p;l=g[0];for(let r=0,t=g.length;r<t;r++)e=l,l=g[r+1],w&&(["{","[","\\"," "].includes(e)?(w=!1,e==" "&&(b={type:"ignore"},d.push(b))):b.value+=e),w||(e=="\\"?(w=!0,b={type:"command",
value:""},d.push(b)):"{}[]".includes(e)?(b={type:e=="{"||e=="["?"open":"close",value:e},d.push(b)):b&&b.type=="text"?b.value+=e:b&&b.type=="ignore"?(d.pop(),b=d[d.length-1]):(b={type:"text",value:e},d.push(b)));return d}}a.DescarTeXTokenizer=k})(descartesJS);
(a=>{const k={curlyBracketOpen:"{",curlyBracketClose:"}",squareBracketOpen:"[",squareBracketClose:"]",bracketOpen:"(",bracketClose:")",bar:"|"},g={b:"bold",i:"italic",o:"overline",u:"underline",c:"center",l:"left",r:"right",j:"justify",ts:"text_size",color:"color",sum:"sum",prod:"prod","int":"integral",lim:"limit",sqrt:"radical",sub:"subIndex",sup:"superIndex",frac:"numerator",plain:"plain"},d=["center","left","right","justify"],b=["bold","italic","overline","underline"],e=["sansserif","serif","monospace"],
l=["sum","integral","limit","prod"],w=b.concat(e).concat(["plain","color_text","color","text_size_text","text_size"]);class q{static parse(n,p,r){let t=a.DescarTeXTokenizer.tokenize(n);n=new a.TextNode("","textBlock",r,null);let c=new a.TextNode("","textLineBlock",r.clone(),null);n.addChild(c);let f=[],m=void 0,v=r,h=[r];let u,x=!1;for(let I=0,S=t.length;I<S;I++)if(t[I].type=="text")if(m=="color_parameter")var z=new a.Color(t[I].value,p);else if(m=="text_size_parameter")var G=parseFloat(t[I].value);
else if(m=="hspace_size")u=parseFloat(t[I].value);else if(c.nodeType=="textLineBlock"){var A=t[I].value.split(" ");for(let F=0,y=A.length;F<y;F++)A[F]!=""&&c.addChild(new a.TextNode(A[F],"text",v.clone(),null)),F+1<y&&c.addChild(new a.TextNode(" ","space",v.clone(),null))}else c.addChild(new a.TextNode(t[I].value,"text",v.clone(),null));else t[I].type=="command"?k[t[I].value]?c.addChild(new a.TextNode(k[t[I].value],"text",v.clone(),null)):t[I].value=="newline"?(c.children.length==0&&c.addChild(new a.TextNode("",
"text",v.clone(),null)),c=new a.TextNode("","textLineBlock",r.clone(),null),n.addChild(c)):t[I].value=="bslash"?c.addChild(new a.TextNode("\\","text",v.clone(),null)):t[I].value=="hspace"?m="hspace":t[I].value.toLowerCase().startsWith("big")&&k[t[I].value.slice(3)]?c.addChild(new a.TextNode(k[t[I].value.slice(3)],t[I].value.slice(0,3),v.clone(),null)):g[t[I].value]?(m=g[t[I].value],f.push(m)):e.includes(t[I].value.toLowerCase())?(m=t[I].value.toLowerCase(),f.push(m)):t[I].value=="$"&&(m="formula",
f.push(m),x=!0):t[I].type=="open"&&t[I].value=="{"&&m?b.includes(m)?(A=v.clone(),A[m]=!0,h.push(A),v=A):m=="hspace"?(m="hspace_size",A=v.clone(),h.push(A),v=A):m=="plain"?(A=v.clone(),A.bold=A.italic=A.overline=A.underline=!1,h.push(A),v=A):e.includes(m)?(A=v.clone(),A.family=m,h.push(A),v=A):m=="text_size"?m="text_size_parameter":m=="text_size_text"?(A=v.clone(),A.size=G,h.push(A),v=A):m=="color"?m="color_parameter":m=="color_text"?(A=v.clone(),A.color=z,h.push(A),v=A):d.includes(m)?(A=v.clone(),
A.align=m,h.push(A),v=A,c=new a.TextNode("","textLineBlock",v.clone(),null),n.addChild(c)):m=="formula"?(A=v.clone(),h.push(A),v=A,A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A):m=="subIndex"||m=="superIndex"?x?(A=v.clone(),h.push(A),v=A,A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A):c.addChild(new a.TextNode(m=="subIndex"?"_":"^","text",v.clone(),null)):x&&(m=="radical"?(A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A,A=v.clone(),h.push(A),v=A,m="index",A=new a.TextNode("",
m,v.clone(),null),c.addChild(A),c=A):m=="index"?(h.pop(),v=h[h.length-1],m="radicand",A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A):l.includes(m)?(A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A,A=v.clone(),h.push(A),v=A,m="from",A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A,f[f.length-1]=m):m=="from"?(m="to",A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A,f[f.length-1]=m):m=="to"?(h.pop(),v=h[h.length-1],m="what",A=new a.TextNode("",m,v.clone(),null),c.addChild(A),
c=A,f[f.length-1]=m):m=="numerator"?(A=new a.TextNode("","fraction",v.clone(),null),c.addChild(A),c=A,A=v.clone(),h.push(A),v=A,A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A):m=="denominator"&&(A=new a.TextNode("",m,v.clone(),null),c.addChild(A),c=A)):t[I].type=="close"&&t[I].value=="}"&&m&&(w.includes(m)?(h.pop(),v=h[h.length-1],f.pop(),m=f[f.length-1]):m=="hspace_size"?(h.pop(),c.addChild(new a.TextNode(u,"space",v.clone(),null)),m=f[f.length-1]):m=="color_parameter"?m="color_text":m==
"text_size_parameter"?m="text_size_text":d.includes(m)?(h.pop(),v=h[h.length-1],f.pop(),m=f[f.length-1],t[I+1]&&t[I+1].type=="command"&&t[I+1].value=="newline"?c=n:(c=new a.TextNode("","textLineBlock",v.clone(),null),n.addChild(c))):c.nodeType=="formula"?(x=!1,h.pop(),v=h[h.length-1],f.pop(),m=f[f.length-1],c=c.parent):c.nodeType!="subIndex"&&c.nodeType!="superIndex"||!x?c.nodeType=="from"||c.nodeType=="to"||c.nodeType=="index"?c=c.parent:c.nodeType=="what"||c.nodeType=="radicand"?(f.pop(),m=f[f.length-
1],c=c.parent.parent):c.nodeType=="numerator"?(m="denominator",c=c.parent):c.nodeType=="denominator"&&(h.pop(),v=h[h.length-1],f.pop(),m=f[f.length-1],c=c.parent.parent):(h.pop(),v=h[h.length-1],f.pop(),m=f[f.length-1],c=c.parent));r=null;z=[];for(let I of n.children)for(let S=0,F=I.children.length;S<F-1;S++)G=I.children[S],p=I.children[S+1],G.nodeType=="text"&&p.nodeType=="text"&&G.style.equals(p.style)?(r===null&&(r=G,A=G.clone(),r.changeNodeType("word"),r.value="___"+A.value,r.addChild(A)),A=p.clone(),
r.addChild(A),z.push(p),r.value+=A.value):r=null;for(let I of z)I.parent.removeChild(I);n.normalize();n.adjustFontSize();return n}}a.DescarTeXParser=q})(descartesJS);
(a=>{let k;class g{constructor(d){this.size=20;this.family="Arial";this.italic=this.bold=this.underline=this.overline=!1;this.color=this.border=null;this.align="left";d=d||{};this.set(d)}clone(){return new g(Object.assign({},this))}set(d){Object.assign(this,d);this.math_str=this.str=null}equals(d){let b=!0;for(let e in this)this.hasOwnProperty(e)&&(b=b&&this[e]==d[e]);return b}toString(d){if(d)return this.math_str||(this.math_str=this.toStringAux(d)),this.math_str;this.str||(this.str=this.toStringAux(d));
return this.str}toStringAux(d){k=a.monospace_font;/arial|sansserif/i.test(this.family)?k=a.sansserif_font:/times|serif/i.test(this.family)&&(k=d?a.math_font:a.serif_font);return(this.bold?"bold ":"")+(this.italic?"italic ":"")+this.size+"px "+k}}a.TextStyle=g})(descartesJS);
(a=>{function k(c,f){let m=0;for(let v=0;v<f;v++)m+=c[v];return m}function g(c){let f={ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,marginX:0,marginY:0,paddingX:0,paddingY:0};if(c.trim()=="")return f;var m=parseInt(c.match(/[\d\.]+px/)[0]);c=c.includes("sansserif")?"sansserif":c.includes("serif")?"serif":"monospace";m/=t[c].unitsPerEm;f.ascent=Math.ceil((t[c].ascent+25)*m);f.descent=Math.ceil(Math.abs((t[c].descent-25)*m));f.h=f.ascent+f.descent;return f}let d=!1,b="#000000",e=2,l=!1,w;
const q="textLineBlock formula numerator denominator superIndex subIndex index radicand from to what element".split(" "),n="formula fraction superIndex subIndex radical sum integral prod limit matrix defparts dynamicText componentNumCtrl componentSpace".split(" "),p={textBlock:"drawTextBlock",textLineBlock:"drawTextLineBlock",formula:"drawFormula",dynamicText:"drawDynamicText",fraction:"drawFraction",numerator:"drawGenericBlock",denominator:"drawGenericBlock",superIndex:"drawGenericBlock",subIndex:"drawGenericBlock",
radical:"drawRadical",limit:"drawLimit",integral:"drawIntegral",prod:"drawProd",sum:"drawSum",matrix:"drawMatrix",defparts:"drawDefparts",text:"drawText",newLine:"drawText",mathSymbol:"drawText",space:"drawSpace",word:"drawWord",hyperlink:"drawHyperlink",index:"drawGenericBlock",radicand:"drawGenericBlock",from:"drawGenericBlock",to:"drawGenericBlock",what:"drawGenericBlock",element:"drawGenericBlock",componentNumCtrl:"drawComponentNumCtrl",componentSpace:"drawComponentSpace",big:"drawBig",Big:"drawBig",
BIG:"drawBig"};class r{constructor(c,f,m,v){this.type="rtfNode";this.evaluator=v;this.parent=null;this.children=[];this.metrics={ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,marginX:0,marginY:0,paddingX:0,paddingY:0};this.value=c;this.style=m;this.changeNodeType(f)}changeNodeType(c){this.nodeType=c;this.draw=this[p[c]||"drawText"];this.nodeType==="dynamicText"&&(this.decimal_symbol=this.evaluator.parent.decimal_symbol)}clone(){let c=new r(this.value,this.nodeType,this.style.clone());for(let f of this.children)c.addChild(f.clone());
return c}toStr(){let c=this.value;for(let f of this.children)c+=" "+f.toStr();return c}stringify(){let c=`{"NT":"${this.nodeType}", "V":"${this.value||""}", "C":[`;for(let f=0,m=this.children.length;f<m;f++)c+=this.children[f].stringify()+(f==m-1?"":",");return c+`], "S":${JSON.stringify(this.style)}}`}addChild(c,f){f&&c.parent!==null&&c.parent.removeChild(c);c.parent=this;this.children.push(c)}removeChild(c){let f=this.children.indexOf(c);f!=-1&&(c.parent=null,this.children.splice(f,1))}getFirstTextNode(){let c=
this;for(;c.children.length>0;)c=c.children[0];return c}getLastTextNode(){let c=this;for(;c.children.length>0;)c=c.children[c.children.length-1];return c}nextSibling(){if(!this.parent)return null;const c=this.parent.children.indexOf(this);return c!==-1&&c<this.parent.children.length-1?this.parent.children[c+1]:null}prevSibling(){if(!this.parent)return null;const c=this.parent.children.indexOf(this);return c>0?this.parent.children[c-1]:null}queryAll(c){let f=[];for(let m of this.children)f.push(...m.queryAll(c));
c.includes(this.nodeType)&&f.push(this);return f}insertBefore(c,f){c=this.children.indexOf(c);c!=-1&&(f.parent=this,this.children.splice(c,0,f))}insertAfter(c,f){c=this.children.indexOf(c);c!=-1&&(f.parent=this,this.children.splice(c+1,0,f))}normalize(){var c=this.queryAll(q);for(let f of c)f.children.length==0&&f.addChild(new r("","text",f.style));for(let f of this.queryAll(n))c=f.prevSibling(),(c===null||c!==null&&c.nodeType!="text"&&f.nodeType!="superIndex"&&f.nodeType!="subIndex"||c!==null&&c.nodeType.toLowerCase()!=
"big"&&(f.nodeType=="superIndex"||f.nodeType=="subIndex"))&&f.parent.insertBefore(f,new r("","text",f.parent.style)),c=f.nextSibling(),(c===null||c!==null&&c.nodeType!="text"&&f.nodeType!="superIndex"&&f.nodeType!="subIndex"||c!==null&&c.nodeType.toLowerCase()!="big"&&(f.nodeType=="superIndex"||f.nodeType=="subIndex"))&&f.parent.insertAfter(f,new r("","text",f.parent.style));return this}removeEmptyText(){for(let c of this.queryAll(["text"]))c.value==""&&c.parent&&c.parent.removeChild(c)}adjustFontSize(c){let f=
this.style.size;this.nodeType=="formula"&&(c=!0);for(let m of this.children)if(m.nodeType=="text"&&c)m.style.size=f,m.styleString=m.style.toString();else if("index to from numerator denominator subIndex superIndex".split(" ").includes(m.nodeType)){if(m.nodeType=="index")m.style.size=Math.max(parseInt(f-f*.5),8);else if(m.nodeType=="to"||m.nodeType=="from")m.style.size=Math.max(parseInt(f-f*.2),8);else if(m.nodeType=="numerator"||m.nodeType=="denominator")m.style.size=Math.max(parseInt(f-f*.1),8);
else if(m.nodeType==="subIndex"||m.nodeType==="superIndex")m.style.size=Math.max(parseInt(f-f*.33),8);m.styleString=m.style.toString();m.adjustFontSize(!0)}else c&&(m.style.size=f,m.styleString=m.style.toString()),m.adjustFontSize(c)}propagateStyle(c,f){this.style[c]=f;this.styleString=this.style.toString();for(let m of this.children)m.propagateStyle(c,f)}update(c,f,m,v,h,u,x,z){e=m;l=v;b=x;this.metrics.w=this.metrics.h=0;m=f;if(z>=20)for(v=0;v<this.children.length;v++)this.children[v].breakLines(z);
for(var G of this.children)G.updateLine(),G.metrics.offsetX=c,G.metrics.y=f,f+=parseInt(G.metrics.ascent+.5),G.metrics.offsetY=f,f+=parseInt(G.metrics.descent+.5)+parseInt(1.5+G.style.size*.05),this.metrics.h+=G.metrics.h,this.metrics.w=Math.max(this.metrics.w,G.metrics.w),this.style.align=="justify"&&(this.metrics.w=Math.max(this.metrics.w,z));f=m;u=u||"";u.includes("right")?c-=this.metrics.w:u.includes("_center")&&(c-=this.metrics.w/2);u.includes("bottom")?f-=this.metrics.h:u.includes("center_")&&
(f-=this.metrics.h/2);u=this.children;for(let A=0,I=u.length;A<I;A++)u[A].style.align=="left"?u[A].metrics.offsetX=c:u[A].style.align=="right"?u[A].metrics.offsetX=c+this.metrics.w-u[A].metrics.w:u[A].style.align=="center"?u[A].metrics.offsetX=c+(this.metrics.w-u[A].metrics.w)/2:u[A].style.align=="justify"&&z>=20&&(G=A<I-1?u[A+1].value:null,u[A].metrics.offsetX=c,G=="wrap"&&u[A].justifyAux(z)),u[A].metrics.y=f,f+=parseInt(u[A].metrics.ascent+.5),u[A].metrics.offsetY=f,f+=parseInt(u[A].metrics.descent+
.5)+parseInt(1.5+u[A].style.size*.05)}breakLines(c){let f,m=0,v=!1,h=[],u=this.style.align=="justify"?this.style.size/5:0;for(let x=0,z=this.children.length;x<z;x++)f=this.children[x],v?h.push(f):(f.nodeType=="text"?f.metrics.w=a.getTextWidth(f.value,f.style.toString()):f.nodeType=="space"?f.metrics.w=typeof f.value=="number"?f.value:a.getTextWidth(f.value,f.style.toString()):f.nodeType=="word"?f.updateLine():f.nodeType=="formula"&&f.updateFormula(),m+=f.metrics.w,m>c+u&&f.nodeType!="space"&&x>0&&
(v=!0,h.push(f)));if(h.length>0){c=new r("wrap","textLineBlock",this.style.clone(),null);this.parent.insertAfter(this,c);for(let x of h)x.parent&&x.parent.removeChild(x),c.addChild(x)}}updateLine(c){let f=this;if(f.nodeType=="textLineBlock"||f.nodeType=="word"){let v=f.metrics.w=f.metrics.ascent=f.metrics.descent=0,h=f.children,u;for(let x=0,z=h.length;x<z;x++){u=h[x];if(u.nodeType=="text"){w=u.style.toString();var m=u.value!==""?u.value:a.in_editor?"\u200a":"";u.metrics=g(w);u.metrics.w=a.getTextWidth(m,
w);u.metrics.offsetX=v;Object.defineProperties(u.metrics,{x:{get:function(){return f.metrics.offsetX+this.offsetX}},y:{get:function(){return f.metrics.offsetY+this.offsetY}}})}u.nodeType=="space"?(w=u.style.toString(),u.metrics=g(w),u.metrics.w=x==z-1?0:typeof u.value=="number"?u.value:c?c:a.getTextWidth(" ",w),u.metrics.offsetX=v,Object.defineProperties(u.metrics,{x:{get:function(){return f.metrics.offsetX+this.offsetX}},y:{get:function(){return f.metrics.offsetY+this.offsetY}}})):u.nodeType=="word"&&
(u.updateLine(),u.metrics.offsetX_aux=v,Object.defineProperties(u.metrics,{offsetX:{get:function(){return f.metrics.offsetX+this.offsetX_aux}},offsetY:{get:function(){return f.metrics.offsetY}}}));u.nodeType=="hyperlink"&&(w=u.styleString,m=u.value!==""?u.value:a.in_editor?"\u200a":"",u.metrics=g(w),u.metrics.w=a.getTextWidth(m,w),u.metrics.offsetX=v,Object.defineProperties(u.metrics,{x:{get:function(){return f.metrics.offsetX+this.offsetX}},y:{get:function(){return f.metrics.offsetY}}}),u.clickCatcher||
(u.clickCatcher=a.newHTML("div",{style:`position:absolute;width:${u.metrics.w}px;height:${u.metrics.h}px;cursor:pointer;`}),u.clickCatcher.rtfNode=u,u.clickCatcher.action=new a.OpenURL(f.evaluator.parent,u.URL),u.clickCatcher.addEventListener("click",function(){f.rtfNode.click=!0;f.action.execute();f.rtfNode.draw(f.rtfNode.ctx)})));u.nodeType=="componentNumCtrl"&&(u.componentNumCtrl=f.evaluator.parent.getControlByCId(u.value),u.metrics=g(u.styleString),u.metrics.w=u.componentNumCtrl.w,u.metrics.h=
u.componentNumCtrl.h,u.metrics.offsetX=v,Object.defineProperties(u.metrics,{x:{get:function(){return f.metrics.offsetX+this.offsetX}},y:{get:function(){return f.metrics.offsetY}}}));u.nodeType=="componentSpace"?(u.componentSpace=f.evaluator.parent.getSpaceByCId(u.value),u.metrics=g(u.styleString),u.metrics.w=u.componentSpace.w,u.metrics.h=u.componentSpace.h,u.metrics.offsetX=v,Object.defineProperties(u.metrics,{x:{get:function(){return f.metrics.offsetX+this.offsetX}},y:{get:function(){return f.metrics.offsetY}}})):
u.nodeType=="formula"&&(u.updateFormula(),u.metrics.marginX=u.metrics.marginY=u.metrics.paddingX=u.metrics.paddingY=0,u.metrics.offsetX_aux=v,Object.defineProperties(u.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return f.metrics.offsetX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return f.metrics.offsetY}}}),u.metrics.w+=2*u.metrics.paddingX,u.metrics.ascent+=u.metrics.paddingY,u.metrics.descent+=u.metrics.paddingY,u.metrics.h+=
2*u.metrics.paddingY,v+=2*u.metrics.marginX);f.metrics.w+=u.metrics.w+2*u.metrics.marginX;f.metrics.ascent=Math.max(f.metrics.ascent,u.metrics.ascent);f.metrics.descent=Math.max(f.metrics.descent,u.metrics.descent);v+=u.metrics.w}f.metrics.h=f.metrics.ascent+f.metrics.descent}}updateFormula(){let c=this;c.metrics={ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,marginX:0,marginY:0,paddingX:0,paddingY:0};let f=c.children,m,v=0;var h={metrics:{ascent:0,descent:0,h:0,w:0,x:0,y:0,offsetX:0,offsetY:0,
marginX:0,marginY:0,paddingX:0,paddingY:0}};for(let H=0,C=f.length;H<C;H++){m=f[H];if(m.nodeType=="text"){w=m.style.toString(!0);var u=m.value!==""?m.value:a.in_editor?"\u200a":"";m.metrics=g(w);m.metrics.w=a.getTextWidth(u,w);m.metrics.offsetX=v;Object.defineProperties(m.metrics,{x:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX}},y:{get:function(){return c.metrics.offsetY}}});v+=c.metrics.marginX}if(m.nodeType.toLowerCase()=="big")w=m.style.toString(!0),m.metrics=g(w),m.nodeType==
"big"?(m.scaleY=1.5,m.metrics.adjust=14):m.nodeType=="Big"?(m.scaleY=2,m.metrics.adjust=10.5):m.nodeType=="BIG"&&(m.scaleY=2.5,m.metrics.adjust=8.5),m.scaleX=1+m.scaleY/6,m.value=="|"&&(m.scaleX=1,m.nodeType=="big"?m.metrics.adjust=10:m.nodeType=="Big"?m.metrics.adjust=8:m.nodeType=="BIG"&&(m.metrics.adjust=6)),m.metrics.h*=m.scaleY,m.metrics.ascent=.6*m.metrics.h,m.metrics.descent=.4*m.metrics.h,m.metrics.w=a.getTextWidth(m.value,w)*m.scaleX,m.metrics.offsetX=v,Object.defineProperties(m.metrics,
{x:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX}},y:{get:function(){return c.metrics.offsetY}}}),v+=c.metrics.marginX;else if(m.nodeType=="dynamicText"){u=m.decimals===void 0?e:m.evaluator.eval(m.decimals);var x=m.fixed===void 0?l:m.fixed,z=m.evaluator.eval(m.value),G=parseFloat(z);""+G===""+z&&(z=x?G.toFixed(u):String(Number(G.toFixed(u))),z=(""+z).replace(".",m.decimal_symbol));m.evalValue=z;w=m.style.toString(!0);m.metrics=g(w);m.metrics.marginX=m.metrics.paddingX=0;
m.metrics.w=a.getTextWidth(z,w)+2*m.metrics.paddingX;m.metrics.offsetX_aux=v;Object.defineProperties(m.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX_aux+this.marginX}},offsetY:{get:function(){return c.metrics.offsetY}}});v+=2*m.metrics.marginX}if(m.nodeType=="superIndex")u=m,u.updateFormula(),u.metrics.marginX=u.metrics.paddingX=u.metrics.paddingY=0,u.metrics.offsetX_aux=v,u.metrics.prevChild=
h,Object.defineProperties(u.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX_aux+this.marginX}}}),h.nodeType=="text"?Object.defineProperties(u.metrics,{offsetY:{get:function(){return c.metrics.offsetY+this.ascent+(this.prevChild.metrics.descent-this.prevChild.metrics.ascent)/2-this.h}}}):Object.defineProperties(u.metrics,{offsetY:{get:function(){return c.metrics.offsetY-this.prevChild.metrics.ascent-
this.descent+this.h*.8}}}),u.metrics.w+=2*u.metrics.paddingX,u.metrics.ascent+=u.metrics.paddingY,u.metrics.descent+=u.metrics.paddingY,u.metrics.h+=2*u.metrics.paddingY,u.metrics.tmp_ascent=u.metrics.h+(u.metrics.prevChild.metrics.ascent-u.metrics.prevChild.metrics.descent)/2,v+=2*u.metrics.marginX;else if(m.nodeType=="subIndex")u=m,u.updateFormula(),u.metrics.marginX=u.metrics.paddingX=u.metrics.paddingY=0,u.metrics.offsetX_aux=v,u.metrics.prevChild=h,Object.defineProperties(u.metrics,{x:{get:function(){return this.offsetX}},
y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.offsetX_aux}}}),h.nodeType=="text"?Object.defineProperties(u.metrics,{offsetY:{get:function(){return c.metrics.offsetY+this.ascent+(this.prevChild.metrics.descent-this.prevChild.metrics.ascent)*.5}}}):Object.defineProperties(u.metrics,{offsetY:{get:function(){return c.metrics.offsetY+this.prevChild.metrics.descent-this.descent}}}),u.metrics.w+=u.metrics.paddingX,u.metrics.ascent+=u.metrics.paddingY,
u.metrics.descent+=u.metrics.paddingY,u.metrics.h+=2*u.metrics.paddingY,c.metrics.descent=u.metrics.ascent+(u.metrics.prevChild.metrics.descent-u.metrics.prevChild.metrics.ascent)/2+u.metrics.descent,v+=u.metrics.marginX;else if(m.nodeType=="fraction"){u=m;u.updateFormula();z=u.children;x=z[0];z=z[1];u.metrics.marginX=parseInt(.5+c.style.size*.075);u.metrics.paddingX=u.metrics.paddingY=0;G=Math.max(x.metrics.w,z.metrics.w)+2*u.metrics.paddingX;u.metrics.prevChild=h;u.metrics.offsetX_aux=v;let D=parseInt(-h.metrics.descent+
4*h.metrics.h/9);Object.defineProperties(u.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY+D}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY-D}}});Object.defineProperties(x.metrics,{parent:{value:u},maxWidth:{value:G},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+parseInt((this.maxWidth-
this.w)/2)}},offsetY:{get:function(){return this.parent.metrics.offsetY-this.descent-this.parent.metrics.paddingY}}});Object.defineProperties(z.metrics,{parent:{value:u},maxWidth:{value:G},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+parseInt((this.maxWidth-this.w)/2)}},offsetY:{get:function(){return this.parent.metrics.offsetY+this.ascent+this.parent.metrics.paddingY}}});u.metrics.w=G;u.metrics.ascent=x.metrics.h+
D+2*u.metrics.paddingY;u.metrics.descent=z.metrics.h-D+2*u.metrics.paddingY;u.metrics.h=x.metrics.h+z.metrics.h+4*u.metrics.paddingY;v+=2*u.metrics.marginX}else if(m.nodeType=="radical"){h=m;h.updateFormula();x=h.children;u=x[0];let D=x[1];h.metrics.marginX=parseInt(1.5+c.style.size*.075);h.metrics.paddingX=parseInt(1.5+c.style.size*.075);h.metrics.paddingY=parseInt(1.5+c.style.size*.05);h.metrics.offsetX_aux=v;Object.defineProperties(h.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});x=h.style.size;h.radicalSign={w:x,scaleX:x/722,scaleY:D.metrics.h/1E3};z=parseInt(u.metrics.w-2*h.radicalSign.w/3);Object.defineProperties(h.radicalSign,{parent:{value:h},displaceIndex:{value:z},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+Math.max(this.displaceIndex,0)}},y:{get:function(){return c.metrics.offsetY-
D.metrics.ascent}}});Object.defineProperties(u.metrics,{parent:{value:h},displaceIndex:{value:z},fontSize:{value:x},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+Math.max(this.displaceIndex,0)-this.displaceIndex}},offsetY:{get:function(){return c.metrics.offsetY-this.descent-2*this.fontSize/5}}});Object.defineProperties(D.metrics,{parent:{value:h},displaceIndex:{value:z},x:{get:function(){return this.offsetX}},
y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+this.parent.radicalSign.w+Math.max(this.displaceIndex,0)}},offsetY:{get:function(){return c.metrics.offsetY}}});z=u.metrics.w<2*h.radicalSign.w/3?h.radicalSign.w:parseInt(u.metrics.w+h.radicalSign.w/3);h.metrics.w=z+2*h.metrics.paddingX+D.metrics.w;h.metrics.ascent=Math.max(D.metrics.ascent,u.metrics.h+2*x/5)+h.metrics.paddingY;h.metrics.descent=D.metrics.descent+h.metrics.paddingY;
h.metrics.h=h.metrics.ascent+h.metrics.descent;v+=2*h.metrics.marginX}else if(m.nodeType=="sum"){h=m;h.updateFormula();z=h.children;u=z[0];x=z[1];z=z[2];h.metrics.marginX=parseInt(1.5+c.style.size*.075);h.metrics.paddingX=parseInt(1.5+c.style.size*.075);h.metrics.paddingY=parseInt(1.5+c.style.size*.05);h.metrics.offsetX_aux=v;Object.defineProperties(h.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+
this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});let D=g(m.style.toString());G=parseInt(D.h*1.2);var A=parseInt(.5+G*780/1E3);h.sigmaSign={w:A,h:G,scale:G/1E3};A=Math.max(x.metrics.w,u.metrics.w,h.sigmaSign.w);h.sigmaSign.parent=h;Object.defineProperties(h.sigmaSign,{sumWidth:{value:A},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.sumWidth-this.w)/2)}},y:{get:function(){return c.metrics.offsetY+D.descent-(this.h+
D.h)/2}}});var I=D.descent-x.metrics.descent-(G+D.h)/2-h.metrics.paddingY;Object.defineProperties(x.metrics,{parent:{value:h},sumWidth:{value:A},newBaselineTo:{value:I},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.sumWidth-this.w)/2)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineTo}}});G=u.metrics.ascent+D.descent+(G-D.h)/2+h.metrics.paddingY;
Object.defineProperties(u.metrics,{parent:{value:h},sumWidth:{value:A},newBaselineFrom:{value:G},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.sumWidth-this.w)/2)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineFrom}}});Object.defineProperties(z.metrics,{parent:{value:h},sumWidth:{value:A},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return this.parent.metrics.offsetX+2*this.parent.metrics.paddingX+this.sumWidth}},offsetY:{get:function(){return c.metrics.offsetY}}});h.metrics.w=A+z.metrics.w+3*h.metrics.paddingX;h.metrics.ascent=Math.max(z.metrics.ascent,-I+x.metrics.ascent)+h.metrics.paddingY;h.metrics.descent=Math.max(z.metrics.descent,G+u.metrics.descent)+h.metrics.paddingY;h.metrics.h=h.metrics.ascent+h.metrics.descent;v+=2*h.metrics.marginX}else if(m.nodeType=="integral"){h=m;h.updateFormula();z=h.children;
u=z[0];x=z[1];z=z[2];h.metrics.marginX=parseInt(1.5+c.style.size*.075);h.metrics.paddingX=parseInt(1.5+c.style.size*.075);h.metrics.paddingY=parseInt(1.5+c.style.size*.05);h.metrics.offsetX_aux=v;Object.defineProperties(h.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});let D=g(m.style.toString());G=parseInt(D.h*
1.2);var S=parseInt(10.5+G*529/1E3);h.sign={w:S,h:G,scale:G/1E3};h.sign.parent=h;Object.defineProperties(h.sign,{x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX}},y:{get:function(){return c.metrics.offsetY+D.descent-(this.h+D.h)/2}}});A=D.descent-(G+D.h)/2-x.metrics.descent+G/3;Object.defineProperties(x.metrics,{parent:{value:h},integralWidth:{value:S},newBaselineTo:{value:A},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+
this.parent.metrics.paddingX+parseInt(4*this.integralWidth/5)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineTo}}});I=D.descent+u.metrics.ascent/2;Object.defineProperties(u.metrics,{parent:{value:h},integralWidth:{value:S},newBaselineFrom:{value:I},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt(2*this.integralWidth/5)}},offsetY:{get:function(){return c.metrics.offsetY+
this.newBaselineFrom}}});S=Math.max(parseInt(3*S/5)+x.metrics.w,parseInt(2*S/5+u.metrics.w))+h.metrics.paddingX;Object.defineProperties(z.metrics,{parent:{value:h},whatDisplace:{value:S},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+this.whatDisplace}},offsetY:{get:function(){return c.metrics.offsetY}}});h.metrics.w=S+z.metrics.w+2*h.metrics.paddingX;h.metrics.ascent=Math.max(z.metrics.ascent,
-A+x.metrics.ascent)+h.metrics.paddingY;h.metrics.descent=Math.max(z.metrics.descent,I+u.metrics.descent,G-h.metrics.ascent)+h.metrics.paddingY;h.metrics.h=Math.max(h.metrics.ascent+h.metrics.descent,G);v+=2*h.metrics.marginX}else if(m.nodeType=="prod"){h=m;h.updateFormula();z=h.children;u=z[0];x=z[1];z=z[2];h.metrics.marginX=parseInt(1.5+c.style.size*.075);h.metrics.paddingX=parseInt(1.5+c.style.size*.075);h.metrics.paddingY=parseInt(1.5+c.style.size*.05);h.metrics.offsetX_aux=v;Object.defineProperties(h.metrics,
{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});let D=g(m.style.toString());G=parseInt(D.h*1.2);A=parseInt(.5+G*876/1E3);h.piSign={w:A,h:G,scale:G/1E3};A=Math.max(x.metrics.w,u.metrics.w,h.piSign.w);h.piSign.parent=h;Object.defineProperties(h.piSign,{prodWidth:{value:A},x:{get:function(){return this.parent.metrics.offsetX+
this.parent.metrics.paddingX+parseInt((this.prodWidth-this.w)/2)}},y:{get:function(){return c.metrics.offsetY+D.descent-(this.h+D.h)/2}}});I=D.descent-x.metrics.descent-(G+D.h)/2-h.metrics.paddingY;Object.defineProperties(x.metrics,{parent:{value:h},prodWidth:{value:A},newBaselineTo:{value:I},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.prodWidth-this.w)/2)}},offsetY:{get:function(){return c.metrics.offsetY+
this.newBaselineTo}}});G=u.metrics.ascent+D.descent+(G-D.h)/2+h.metrics.paddingY;Object.defineProperties(u.metrics,{parent:{value:h},prodWidth:{value:A},newBaselineFrom:{value:G},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+parseInt((this.prodWidth-this.w)/2)}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaselineFrom}}});Object.defineProperties(z.metrics,{parent:{value:h},
prodWidth:{value:A},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+2*this.parent.metrics.paddingX+this.prodWidth}},offsetY:{get:function(){return c.metrics.offsetY}}});h.metrics.w=A+z.metrics.w+3*h.metrics.paddingX;h.metrics.ascent=Math.max(z.metrics.ascent,-I+x.metrics.ascent)+h.metrics.paddingY;h.metrics.descent=Math.max(z.metrics.descent,G+u.metrics.descent)+h.metrics.paddingY;h.metrics.h=h.metrics.ascent+
h.metrics.descent;v+=2*h.metrics.marginX}else if(m.nodeType=="limit"){h=m;h.updateFormula();x=h.children;let D=x[0];u=x[1];x=x[2];h.metrics.marginX=parseInt(1.5+c.style.size*.075);h.metrics.paddingX=parseInt(1.5+c.style.size*.075);h.metrics.paddingY=parseInt(1.5+c.style.size*.05);h.metrics.offsetX_aux=v;Object.defineProperties(h.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+this.marginX+
this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});w=m.style.toString();G=g(w);z=parseInt(.5+a.getTextWidth("l\u00edm",w));A=parseInt(.5+a.getTextWidth("\u2192",w));I=Math.max(z,D.metrics.w+A+u.metrics.w);h.limitText={parent:h};Object.defineProperties(h.limitText,{limitWidth:{value:I},limitTextWidth:{value:z},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+(this.limitWidth-this.limitTextWidth)/2}}});z=G.descent+Math.max(D.metrics.ascent,u.metrics.ascent,
2*G.ascent/3)+h.metrics.paddingY;h.limitArrow={parent:h};Object.defineProperties(h.limitArrow,{newBaseline:{value:z},x:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+D.metrics.w}},y:{get:function(){return c.metrics.offsetY+this.newBaseline}}});Object.defineProperties(D.metrics,{parent:{value:h},newBaseline:{value:z},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX}},
offsetY:{get:function(){return c.metrics.offsetY+this.newBaseline}}});Object.defineProperties(u.metrics,{parent:{value:h},arrowWidth:{value:A},newBaseline:{value:z},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+D.metrics.w+this.arrowWidth}},offsetY:{get:function(){return c.metrics.offsetY+this.newBaseline}}});Object.defineProperties(x.metrics,{parent:{value:h},limitWidth:{value:I},
x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+2*this.parent.metrics.paddingX+this.limitWidth}},offsetY:{get:function(){return c.metrics.offsetY}}});h.metrics.w=I+x.metrics.w+3*h.metrics.paddingX;h.metrics.ascent=Math.max(x.metrics.ascent,G.ascent)+h.metrics.paddingY;G=0;x=Math.max(D.metrics.descent,u.metrics.descent,x.metrics.descent);if(D.metrics.h!=0||u.metrics.h!=0)G=z,x=Math.max(D.metrics.descent,u.metrics.descent,
x-G);h.metrics.descent=G+x+h.metrics.paddingY;h.metrics.h=h.metrics.ascent+h.metrics.descent;v+=2*h.metrics.marginX}else if(m.nodeType=="matrix"){h=m;h.updateFormula();u=h.children;x=h.rows;z=h.columns;h.metrics.marginX=parseInt(1.5+c.style.size*.075);h.metrics.paddingX=parseInt(5+c.style.size*.075);h.metrics.paddingY=parseInt(1.5+c.style.size*.05);h.metrics.offsetX_aux=v;Object.defineProperties(h.metrics,{x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return c.metrics.offsetX+
c.metrics.paddingX+this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});S=g(m.style.toString());G=[];A=[];var F=void 0;let D;for(let J=0,N=x*z;J<N;J++)F=parseInt(J/z),D=J%z,G[F]=Math.max(G[F]||0,u[J].metrics.h),A[D]=Math.max(A[D]||0,u[J].metrics.w);I=(1+z)*h.metrics.paddingX;for(var y=0;y<z;y++)I+=A[y];y=(1+x)*h.metrics.paddingY;for(F=0;F<x;F++)y+=G[F];S=S.descent-S.h/2;for(let J=0,N=x*z;J<N;J++)F=parseInt(J/z),D=J%z,u[J].metrics.offsetX_aux=k(A,D)+(A[D]-u[J].metrics.w)/
2+D*h.metrics.paddingX,u[J].metrics.offsetY_aux=k(G,F)+(G[F]-u[J].metrics.h)/2+(1+F)*h.metrics.paddingY,Object.defineProperties(u[J].metrics,{parent:{value:h},matrixH:{value:y},dispY:{value:S},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+this.parent.metrics.paddingX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY-this.matrixH/2+this.ascent+this.offsetY_aux+this.dispY}}});h.metrics.w=I;
h.metrics.ascent=y/2-S;h.metrics.descent=y/2+S;h.metrics.h=h.metrics.ascent+h.metrics.descent;v+=2*h.metrics.marginX}else if(m.nodeType=="defparts"){h=m;h.updateFormula();u=m.children;x=m.parts;h.metrics.marginX=parseInt(1.5+c.style.size*.075);h.metrics.paddingX=parseInt(1.5+c.style.size*.075);h.metrics.paddingY=parseInt(1.5+c.style.size*.05);h.metrics.offsetX_aux=v;Object.defineProperties(h.metrics,{parent:{value:c},x:{get:function(){return this.offsetX-2*this.marginX}},y:{get:function(){return this.offsetY}},
offsetX:{get:function(){return c.metrics.offsetX+c.metrics.paddingX+3*this.marginX+this.offsetX_aux}},offsetY:{get:function(){return c.metrics.offsetY}}});A=g(m.style.toString());z=0;G=h.metrics.paddingY;A=A.descent-A.h/2;for(I=0;I<x;I++)u[I].metrics.offsetY_aux=G,z=Math.max(z,u[I].metrics.w),G+=u[I].metrics.h+h.metrics.paddingY,Object.defineProperties(u[I].metrics,{parent:{value:h},dispY:{value:A},x:{get:function(){return this.offsetX}},y:{get:function(){return this.offsetY}},offsetX:{get:function(){return this.parent.metrics.offsetX+
this.parent.metrics.paddingX}},offsetY:{get:function(){return c.metrics.offsetY-this.parent.metrics.defpartsH/2+this.ascent+this.offsetY_aux+this.dispY}}});h.metrics.defpartsH=G;h.metrics.w=z+4*h.metrics.paddingX;h.metrics.ascent=G/2-A;h.metrics.descent=G/2+A;h.metrics.h=h.metrics.ascent+h.metrics.descent;v+=2*h.metrics.marginX}else"numerator denominator index radicand from to what element".split(" ").includes(m.nodeType)&&(m.updateFormula(),m.metrics.paddingX=parseInt(1.5+c.style.size*.075),m.metrics.paddingY=
parseInt(1.5+c.style.size*.05),m.metrics.ascent+=m.metrics.paddingY,m.metrics.descent+=m.metrics.paddingY,m.metrics.h=m.metrics.ascent+m.metrics.descent,m.children.length==1&&m.children[0].nodeType=="text"&&m.children[0].value==""?(m.metrics.w=0,a.in_editor||(m.metrics.ascent=m.metrics.descent=m.metrics.h=0)):m.metrics.w+=2*m.metrics.paddingX);h=m;c.metrics.ascent=Math.max(c.metrics.ascent,m.metrics.tmp_ascent||m.metrics.ascent);c.metrics.descent=Math.max(c.metrics.descent,m.metrics.descent);c.metrics.w+=
m.metrics.w+2*m.metrics.marginX;c.metrics.h=c.metrics.ascent+c.metrics.descent;v+=m.metrics.w}}justifyAux(c){var f=this.children[this.children.length-1];f=f.nodeType=="text"&&f.value==""?1:0;let m=0;for(var v=this.children.length-1-f;v>=0&&this.children[v].nodeType=="space";v--)m++;let h=v=0;for(let u=0,x=this.children.length-m-f;u<x;u++)this.children[u].nodeType=="space"?v++:h+=this.children[u].metrics.w;this.updateLine((c-h)/v)}drawTextBlock(c){c.fillStyle=b;c.shadowBlur=this.style.shadowBlur;c.shadowOffsetX=
this.style.shadowOffsetX;c.shadowOffsetY=this.style.shadowOffsetY;c.shadowColor=this.style.shadowColor;for(let f of this.children)f.draw(c);c.shadowColor="transparent"}drawTextLineBlock(c){for(let f of this.children)d=!1,f.draw(c)}drawText(c){if(this.value!==""){var {x:f,y:m}=this.metrics;c.fillStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;c.font=this.style.toString(d);c.beginPath();this.style.overline&&(c.rect(f,m-this.metrics.ascent+parseInt(1+
this.style.size/25),this.metrics.w,parseInt(1+this.style.size/25)),c.fill());this.style.underline&&(c.rect(f,m+parseInt(1+this.style.size/10),this.metrics.w,parseInt(1+this.style.size/25)),c.fill());if(this.style.border){let v=c.strokeStyle;c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8);c.lineJoin="round";c.miterLimit=2;c.strokeStyle=this.style.border.getColor();c.strokeText(this.value,f,m);c.strokeStyle=v}c.fillText(this.value,
f,m)}}drawBig(c){const {x:f,y:m}=this.metrics;this.style.border&&(c.save(),c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8),c.lineJoin="round",c.miterLimit=2,c.strokeStyle=this.style.border.getColor(),c.font=this.style.toString(d),c.translate(f,m+this.metrics.h/this.metrics.adjust),c.scale(this.scaleX,this.scaleY),c.strokeText(this.value,0,0),c.restore());c.fillStyle=this.style.color!==null?this.style.color.getColor?
this.style.color.getColor():this.style.color:b;c.save();c.font=this.style.toString(d);c.translate(f,m+this.metrics.h/this.metrics.adjust);c.scale(this.scaleX,this.scaleY);c.fillText(this.value,0,0);c.restore()}drawWord(c){for(let f of this.children)f.draw(c)}drawSpace(c){const {x:f,y:m}=this.metrics;this.style.overline&&(c.rect(f,m-this.metrics.ascent+parseInt(1+this.style.size/25),this.metrics.w,parseInt(1+this.style.size/25)),c.fill());this.style.underline&&(c.rect(f,m+parseInt(1+this.style.size/
10),this.metrics.w,parseInt(1+this.style.size/25)),c.fill())}drawDynamicText(c){let f=this.metrics.x+this.metrics.paddingX,m=this.metrics.y;c.fillStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;c.font=this.style.toString(d);c.beginPath();this.style.overline&&(c.rect(f,m-this.metrics.ascent+parseInt(1+this.style.size/25),this.metrics.w,parseInt(1+this.style.size/25)),c.fill());this.style.underline&&(c.rect(f,m+parseInt(1+this.style.size/10),this.metrics.w,
parseInt(1+this.style.size/25)),c.fill());c.fillText(this.evalValue,f,m)}drawHyperlink(c){const {x:f,y:m}=this.metrics;this.ctx=c;this.clickCatcher.parentNode||(c.canvas.nextSibling.className?c.canvas.parentNode.insertBefore(this.clickCatcher,c.canvas.nextSibling.nextSibling):c.canvas.parentNode.insertBefore(this.clickCatcher,c.canvas.nextSibling));this.clickCatcher.style.left=f+"px";this.clickCatcher.style.top=m-this.metrics.ascent+"px";c.fillStyle="blue";this.click&&(c.fillStyle="white",c.fillRect(f,
m-this.metrics.ascent,this.metrics.w,this.metrics.h),c.fillStyle="red");c.font=this.style.toString(d);c.beginPath();c.rect(f,m+parseInt(1+this.style.size/10),this.metrics.w,parseInt(1+this.style.size/25));c.fill();c.fillText(this.value,f,m)}drawFormula(c){for(let f of this.children)d=!0,f.draw(c)}drawFraction(c){c.lineWidth=5;c.fillStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;var f=parseInt(1+this.style.size/24);c.beginPath();c.rect(this.metrics.x,
this.metrics.offsetY-parseInt(f/2),this.metrics.w,f);this.style.border&&(f=c.strokeStyle,c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8),c.lineJoin="round",c.miterLimit=2,c.strokeStyle=this.style.border.getColor(),c.stroke(),c.strokeStyle=f);c.fill();this.children[0].draw(c);this.children[1].draw(c)}drawRadical(c){c.fillStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:
b;this.style.border&&(c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8),c.lineJoin="round",c.miterLimit=2,c.strokeStyle=this.style.border.getColor(),c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8));c.beginPath();c.rect(Math.floor(this.children[1].metrics.x+2)-.5,this.radicalSign.y-.5,this.children[1].metrics.w-1.5,parseInt(1+this.style.size/
18));this.style.border&&c.stroke();c.save();c.lineWidth/=Math.max(this.radicalSign.scaleX,this.radicalSign.scaleY);c.font="1000px DJS_symbol";c.translate(this.radicalSign.x,this.radicalSign.y);c.scale(this.radicalSign.scaleX,this.radicalSign.scaleY);this.style.border&&c.strokeText("\u221a",-70,800);c.fillText("\u221a",-70,800);c.restore();c.fill();for(let f of this.children)f.draw(c)}drawSum(c){c.fillStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:
b;c.font=`${this.sigmaSign.w*1.9}px DJS_symbol`;this.style.border&&(c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8),c.lineJoin="round",c.miterLimit=2,c.strokeStyle=this.style.border.getColor(),c.strokeText("\u03a3",this.sigmaSign.x,this.sigmaSign.y+this.sigmaSign.h));c.fillText("\u03a3",this.sigmaSign.x,this.sigmaSign.y+this.sigmaSign.h);for(let f of this.children)f.draw(c)}drawIntegral(c){c.fillStyle=this.style.color!==
null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;c.font=`${this.sign.w*1.5}px DJS_symbol`;this.style.border&&(c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8),c.lineJoin="round",c.miterLimit=2,c.strokeStyle=this.style.border.getColor(),c.strokeText("\u222b",this.sign.x,this.sign.y+this.sign.h*3/4));c.fillText("\u222b",this.sign.x,this.sign.y+this.sign.h*3/4);for(let f of this.children)f.draw(c)}drawProd(c){c.fillStyle=
this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;c.font=`${this.piSign.w*1.5}px DJS_symbol`;this.style.border&&(c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8),c.lineJoin="round",c.miterLimit=2,c.strokeStyle=this.style.border.getColor(),c.strokeText("\u03a0",this.piSign.x,this.piSign.y+this.piSign.h));c.fillText("\u03a0",this.piSign.x,this.piSign.y+this.piSign.h);for(let f of this.children)f.draw(c)}drawLimit(c){for(let f of this.children)f.draw(c);
c.fillStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;this.style.border&&(c.lineWidth=this.style.border_size&&parseInt(this.style.border_size)>0?parseInt(this.style.border_size):1+parseInt(this.style.size/8),c.lineJoin="round",c.miterLimit=2,c.strokeStyle=this.style.border.getColor());c.font=this.style.toString();this.style.border&&c.strokeText("l\u00edm",this.limitText.x,this.metrics.y);c.fillText("l\u00edm",this.limitText.x,this.metrics.y);
this.children[1].metrics.h!=0&&(this.style.border&&c.strokeText("\u2192",this.limitArrow.x,this.limitArrow.y),c.fillText("\u2192",this.limitArrow.x,this.limitArrow.y))}drawMatrix(c){for(var f of this.children)f.draw(c);var m=parseInt(1.5+this.style.size/25);f=m/2;c.lineWidth=m;c.strokeStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;c.beginPath();if(this.matrix_type==0)c.moveTo(this.metrics.x+f+1.5*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent),
c.lineTo(this.metrics.x+f,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+f,this.metrics.y+f-this.metrics.ascent+this.metrics.h),c.lineTo(this.metrics.x+f+1.5*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent+this.metrics.h),c.moveTo(this.metrics.x+this.metrics.w-f-1.5*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+this.metrics.w-f,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+this.metrics.w-f,this.metrics.y+f-this.metrics.ascent+
this.metrics.h),c.lineTo(this.metrics.x+this.metrics.w-f-1.5*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent+this.metrics.h);else if(this.matrix_type==1)c.moveTo(this.metrics.x+f+2*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent),c.bezierCurveTo(this.metrics.x-f,this.metrics.y+f-this.metrics.ascent,this.metrics.x-f,this.metrics.y+f-this.metrics.ascent+this.metrics.h,this.metrics.x+f+2*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent+this.metrics.h),c.moveTo(this.metrics.x+
this.metrics.w-f-2*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent),c.bezierCurveTo(this.metrics.x+this.metrics.w+f,this.metrics.y+f-this.metrics.ascent,this.metrics.x+this.metrics.w+f,this.metrics.y+f-this.metrics.ascent+this.metrics.h,this.metrics.x+this.metrics.w-f-2*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent+this.metrics.h);else if(this.matrix_type==2){m=3*this.metrics.marginX;let v=m/2;c.moveTo(this.metrics.x+f+m,this.metrics.y+f-this.metrics.ascent);c.bezierCurveTo(this.metrics.x+
f+v,this.metrics.y+f-this.metrics.ascent,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+2*this.metrics.marginX);c.lineTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2-5*this.metrics.marginX);c.bezierCurveTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+f,this.metrics.y+f-this.metrics.ascent+this.metrics.h/
2);c.bezierCurveTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2+5*this.metrics.marginX);c.lineTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h-2*this.metrics.marginX);c.bezierCurveTo(this.metrics.x+f+v,this.metrics.y-f-this.metrics.ascent+this.metrics.h,this.metrics.x+f+v,this.metrics.y-f-this.metrics.ascent+
this.metrics.h,this.metrics.x+f+m,this.metrics.y-f-this.metrics.ascent+this.metrics.h);c.moveTo(this.metrics.x+this.metrics.w+f-m,this.metrics.y+f-this.metrics.ascent);c.bezierCurveTo(this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent,this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent,this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+2*this.metrics.marginX);c.lineTo(this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+
this.metrics.h/2-5*this.metrics.marginX);c.bezierCurveTo(this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+this.metrics.w+f,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2);c.bezierCurveTo(this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/
2,this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2+5*this.metrics.marginX);c.lineTo(this.metrics.x+this.metrics.w+f-v,this.metrics.y+f-this.metrics.ascent+this.metrics.h-2*this.metrics.marginX);c.bezierCurveTo(this.metrics.x+this.metrics.w+f-v,this.metrics.y-f-this.metrics.ascent+this.metrics.h,this.metrics.x+this.metrics.w+f-v,this.metrics.y-f-this.metrics.ascent+this.metrics.h,this.metrics.x+this.metrics.w+f-m,this.metrics.y-f-this.metrics.ascent+this.metrics.h)}else this.matrix_type==
3?(c.moveTo(this.metrics.x+f,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+f,this.metrics.y+f-this.metrics.ascent+this.metrics.h),c.moveTo(this.metrics.x+this.metrics.w-f,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+this.metrics.w-f,this.metrics.y+f-this.metrics.ascent+this.metrics.h)):this.matrix_type==4&&(c.moveTo(this.metrics.x+f,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+f,this.metrics.y+f-this.metrics.ascent+this.metrics.h),c.moveTo(this.metrics.x+
f+1.25*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+f+1.25*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent+this.metrics.h),c.moveTo(this.metrics.x+this.metrics.w-f,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+this.metrics.w-f,this.metrics.y+f-this.metrics.ascent+this.metrics.h),c.moveTo(this.metrics.x+this.metrics.w-f-1.25*this.metrics.marginX,this.metrics.y+f-this.metrics.ascent),c.lineTo(this.metrics.x+this.metrics.w-f-1.25*this.metrics.marginX,
this.metrics.y+f-this.metrics.ascent+this.metrics.h));c.stroke()}drawDefparts(c){for(var f of this.children)f.draw(c);var m=parseInt(1.5+this.style.size/25);f=m/2;c.lineWidth=m;c.strokeStyle=this.style.color!==null?this.style.color.getColor?this.style.color.getColor():this.style.color:b;c.beginPath();m=3*this.metrics.marginX;let v=m/2;c.moveTo(this.metrics.x+f+m,this.metrics.y+f-this.metrics.ascent);c.bezierCurveTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent,this.metrics.x+f+v,this.metrics.y+
f-this.metrics.ascent,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+2*this.metrics.marginX);c.lineTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2-5*this.metrics.marginX);c.bezierCurveTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+f,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2);c.bezierCurveTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+
this.metrics.h/2,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2,this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h/2+5*this.metrics.marginX);c.lineTo(this.metrics.x+f+v,this.metrics.y+f-this.metrics.ascent+this.metrics.h-2*this.metrics.marginX);c.bezierCurveTo(this.metrics.x+f+v,this.metrics.y-f-this.metrics.ascent+this.metrics.h,this.metrics.x+f+v,this.metrics.y-f-this.metrics.ascent+this.metrics.h,this.metrics.x+f+m,this.metrics.y-f-this.metrics.ascent+
this.metrics.h);c.stroke()}drawGenericBlock(c){for(let f of this.children)f.draw(c)}drawComponentNumCtrl(c){this.componentNumCtrl.expresion=this.evaluator.parser.parse(`(${this.metrics.x},${this.metrics.y-this.metrics.ascent},${this.componentNumCtrl.w},${this.componentNumCtrl.h})`);this.componentNumCtrl&&this.componentNumCtrl.parent&&this.componentNumCtrl.parent.readyApp&&this.componentNumCtrl.update(!0)}drawComponentSpace(c){this.componentSpace.xExpr=this.evaluator.parser.parse(""+this.metrics.x);
this.componentSpace.yExpr=this.evaluator.parser.parse(""+(this.metrics.y-this.metrics.ascent));this.componentSpace&&this.componentSpace.parent&&this.componentSpace.parent.readyApp&&this.componentSpace.update(!0)}drawBorderSpecial(c,f){c.beginPath();c.setLineDash([1,2]);c.strokeStyle=f;c.lineWidth=1;c.rect(parseInt(this.metrics.x)+.5,parseInt(this.metrics.y-this.metrics.ascent)+.5,this.metrics.w,this.metrics.h);c.stroke();c.setLineDash([])}toRTF(){var c=[];let f=[];let m="";this.mergeTextNodes();for(let h=
0,u=this.children.length;h<u;h++){var v=this.children[h];v.nodeType=="textLineBlock"&&(m+=v.toRTFAux(c,f)+(u>1&&h<u-1?"\\par":""))}v="{\\fonttbl";for(let h=0,u=c.length;h<u;h++)v+="\\f"+h+"\\fcharset0 "+c[h]+";";c="";if(f.length>0){c="{\\colortbl";for(let h=0,u=f.length;h<u;h++)c+=f[h];c+="}"}return"{\\rtf1\\uc0"+(v+"}")+c+m+"}"}toRTFAux(c,f){let m,v,h=null,u="";let x,z,G,A;for(let S of this.children){var I=x="";z=this.addToFontTable(S.style.family,c);G=S.style.size;A=this.addToColorTable(S.style.color,
f);A===null&&f.length>0&&(A=this.addToColorTable(b,f));A!==h&&(I+="\\cf"+A,h=A);z!==m&&(I+="\\f"+z,m=z);G!==v&&(I+="\\fs"+G*2,v=G);S.style.italic&&(I+="\\i",x="\\i0"+x);S.style.bold&&(I+="\\b",x="\\b0"+x);S.style.underline&&(I+="\\ul",x="\\ulnone"+x);S.style.overline&&(I+="\\ol",x="\\olnone"+x);S.nodeType=="text"?(S.value=S.value.replace(/\\?([{}])/g,"\\$1"),I=I!==""?I+" "+S.value+x:u!==""&&u.charAt(u.length-1)!=="}"?" "+S.value:S.value,u+=I):S.nodeType=="formula"?u+="{\\*\\mjaformula"+S.formulaToRTF(m,
v,h,c,f)+"}":S.nodeType=="componentSpace"?u+="{\\*\\component\\Space "+S.value+"}":S.nodeType=="componentNumCtrl"&&(u+="{\\*\\component\\NumCtrl "+S.value+"}")}return u}formulaToRTF(c,f,m,v,h){let u="",x,z,G,A;for(let I of this.children)x=z="",G=this.addToFontTable(I.style.family,v),A=this.addToColorTable(I.style.color,h),A===null&&h.length>0&&(A=this.addToColorTable(b,h)),G!==c&&(x+="\\f"+G,c=G),A!==m&&(x+="\\cf"+A,I.nodeType!=="text"||I.nodeType==="text"&&I.value!=="")&&(m=A),I.style.italic&&(x+=
"\\i",z="\\i0"+z),I.style.bold&&(x+="\\b",z="\\b0"+z),I.style.underline&&(x+="\\ul",z="\\ulnone"+z),I.style.overline&&(x+="\\ol",z="\\olnone"+z),I.nodeType=="text"&&I.value!==""?(I.value=I.value.replace(/\\?([{}])/g,"\\$1"),tmpRTF=x!==""?x+" "+I.value+z:u.charAt(u.length-1)!=="}"?" "+I.value:I.value,u+=tmpRTF):I.nodeType=="dynamicText"?(I.value=I.value===""?" ":I.value,u+=x+"{\\expr "+I.value+"\\decimals "+(I.decimals||2)+"\\fixed"+(I.fixed?1:0)+"}"+z):"fraction radical index radicand sum integral prod limit from to what element".split(" ").includes(I.nodeType)?
u+="{\\"+I.nodeType+I.formulaToRTF(c,f,m,v,h)+"}":I.nodeType=="numerator"?u+="{\\num"+I.formulaToRTF(c,f,m,v,h)+"}":I.nodeType=="denominator"?u+="{\\den"+I.formulaToRTF(c,f,m,v,h)+"}":I.nodeType=="superIndex"?u+="{\\supix"+I.formulaToRTF(c,f,m,v,h)+"}":I.nodeType=="subIndex"?u+="{\\subix"+I.formulaToRTF(c,f,m,v,h)+"}":I.nodeType=="matrix"?u+="{\\matrix\\rows "+(I.rows||2)+"\\columns "+(I.columns||2)+I.formulaToRTF(c,f,m,v,h)+"}":I.nodeType=="defparts"&&(u+="{\\defparts\\parts "+(I.parts||2)+I.formulaToRTF(c,
f,m,v,h)+"}");return u}addToFontTable(c,f){let m;/times/i.test(c)?m="Times New Roman":/courier/i.test(c)?m="Courier New":/arial/i.test(c)&&(m="Arial");c=f.indexOf(m);c===-1&&(c=f.length,f.push(m));return c}addToColorTable(c,f){if(c){c="\\red"+parseInt(c.slice(1,3),16)+"\\green"+parseInt(c.slice(3,5),16)+"\\blue"+parseInt(c.slice(5,7),16)+";";let m=f.indexOf(c);m==-1&&(m=f.length,f.push(c));return m}return null}mergeTextNodes(){let c=[],f=null;for(let m of this.children)m.nodeType=="text"?f!==null&&
f.nodeType=="text"&&f.style.equals(m.style)&&(m.value=f.value+m.value,c.push(f)):m.mergeTextNodes(),f=m;for(let m of c)this.removeChild(m)}}let t={sansserif:{ascent:1854,descent:-434,lineGap:67,capHeight:1409,xHeight:1082,unitsPerEm:2048},serif:{ascent:1825,descent:-443,lineGap:87,capHeight:1341,xHeight:940,unitsPerEm:2048},monospace:{ascent:1705,descent:-615,lineGap:0,capHeight:1349,xHeight:1082,unitsPerEm:2048}};a.TextNode=r})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r;const t={"&gt;":">","&lt;":"<","&quote;":"''","&squot;":"'","\\rquote ":"'","\\endash ":"-","\n":" ","\r":""},c=/&gt;|&lt;|&quote;|&squot;|\\rquote |\\endash |\n|\r|\\uc\d+ ?/g;class f{constructor(){}tokenize(m){if(m)m=m.replace(c,v=>t[v]||"");else return[];k=[];g="";d=b=0;l=m[0];w=!1;for(q="text";d<m.length;){e=l;l=m[d+1];if(w)if(["\\","{","}"," ",";"].includes(l)){w=!1;g+=e;if(r=l==" ")d++,l=m[d+1];(n=g.match(/^'([0-9a-f]{2})/))?(p="",q=="text"&&(p=k.pop().value),
g=p+=String.fromCharCode(parseInt(n[1],16))+g.slice(3)):(n=g.match(/^u[0-9]+/))?(p="",q=="text"&&(p=k.pop().value),g=p+=String.fromCharCode(n[0].slice(1))):(g=="{"||g=="}"||e=="\\"?(q="text",k.push({type:q,value:g+(r?" ":"")})):(q="controlWord",k.push({type:q,value:g})),g="")}else["{","}","\\"].includes(e)?(w=!1,q="text",k.push({type:q,value:e})):g+=e;else e=="\\"?(w=!0,g!=""&&(q="text",k.push({type:q,value:g}),g="")):e=="{"||e=="}"?(e=="{"&&b++,g!=""&&(k.push({type:"text",value:g}),g=""),q=e=="{"?
"openBlock":"closeBlock",k.push({type:q,value:b}),e=="}"&&b--):g+=e;d++}g!==""&&k.push({type:"text",value:g});return k}}a.RTFTokenizer=f})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p,r,t,c,f,m,v,h,u,x,z,G,A,I,S,F,y,H,C,D,J,N,Z,ba,ca,aa;const L="fraction radicand radical what sum integral limit index to from".split(" "),P=["num","den","subix","supix"],U="b b0 i i0 ul ulnone ol olnone".split(" ");class W{constructor(){this.tokenizer=new a.RTFTokenizer}parse(M,E){k=this.tokenizer.tokenize(M);b={};l=2;if(k[0].type=="openBlock"&&k[1].value=="fonttbl"){for(e=k[0].value;k[l].type!="closeBlock"&&k[l].value!=e;)b[k[l].value]=k[l+2].value.slice(0,-1),l+=3;l++}w=
{};q=0;if(k[l].type=="openBlock"&&k[l+1].value=="colortbl"){e=k[l++].value;for(l++;k[l].type!="closeBlock"&&k[l].value!=e;)n=a.toHexStr(k[l++].value.slice(3)),p=a.toHexStr(k[l++].value.slice(5)),r=a.toHexStr(k[l++].value.slice(4)),k[l].value==";"&&l++,w[q++]=`#${n}${p}${r}`;l++}f=m=v=null;h=u=x=z=G=A=I=D=J=N=!1;S=[new a.TextStyle];F=S[0];y=H=-1;C=[];t=Z=new a.TextNode("","textBlock",F,E);c=new a.TextNode("","textLineBlock",F,E);t.addChild(c);Z.stableWidth=!0;Z.hasFormula=!1;for(let O=l,Q=k.length;O<
Q;O++){g=k[O].value;d=k[O].type;if(d=="controlWord")if(b[g])F.set({family:b[g]});else if(g.startsWith("fs"))F.set({size:parseInt(g.slice(2)/2)});else if(U.includes(g))g.startsWith("b")?ca={bold:g=="b"}:g.startsWith("i")?ca={italic:g=="i"}:g.startsWith("ul")?ca={underline:g=="ul"}:g.startsWith("ol")&&(ca={overline:g=="ol"}),F.set(ca),C.length>0&&C[C.length-1].style.set(ca);else if(g.startsWith("cf"))F.set({color:w[parseInt(g.slice(2))]}),C.length>0&&(C[C.length-1].style.color=F.color);else if(g=="par"){t=
new a.TextNode("","textLineBlock",F.clone(),E);if(c.nodeType!="textBlock")for(c=c.parent;c.nodeType!="textBlock";)c=c.parent;c.addChild(t);c=t}else if(g=="mjaformula")Z.hasFormula=h=!0,H=y,t=new a.TextNode("","formula",F.clone(),E),c.addChild(t),c=t,C[C.length-1]=t;else if(L.includes(g)){aa=C[C.length-2].style.clone();if(g=="index")aa.size=Math.max(parseInt(aa.size-aa.size*.5),8);else if(g=="to"||g=="from")aa.size=Math.max(parseInt(aa.size-aa.size*.2),8);t=new a.TextNode("",g,aa,E);C[C.length-2].addChild(t);
C[C.length-1]=t}else P.includes(g)?(aa=C[C.length-2].style.clone(),g=="num"||g=="den"?(aa.size=Math.max(Math.round(aa.size-aa.size*.1),8),ca=g=="num"?"numerator":"denominator",t=new a.TextNode("",ca,aa,E)):(aa.size=Math.max(Math.floor(aa.size-aa.size*.33),8),ca=g=="subix"?"subIndex":"superIndex",t=new a.TextNode("",ca,aa,E),t.originalStyle=C[C.length-2].style.clone()),C[C.length-2].addChild(t),C[C.length-1]=t):g=="defparts"||g=="matrix"||g=="element"?(aa=C[C.length-2].style.clone(),t=new a.TextNode("",
g,aa,E),C[C.length-2].addChild(t),C[C.length-1]=t,g=="defparts"?v=t:g=="matrix"&&(m=t,m.matrix_type=0)):g=="parts"?I=!0:g=="type"?z=!0:g=="rows"?G=!0:g=="columns"?A=!0:g=="expr"?(Z.stableWidth=!1,u=!0):g=="decimals"?x=!0:g.startsWith("fixed")?f.fixed=g=="fixed1":g!="component"&&(g=="NumCtrl"?D=!0:g=="Space"?J=!0:g=="hyperlink"&&(N=!0));if(d=="text")if(I)v.parts=parseInt(g),I=!1;else if(z)m.matrix_type=parseInt(g),z=!1;else if(G)m.rows=parseInt(g),G=!1;else if(A)m.columns=parseInt(g),A=!1;else if(x)f.decimals=
E.parser.parse(""+g),x=!1;else if(N){ba=g.split("|")[0];aa=F.clone();t=new a.TextNode(ba,"hyperlink",aa,E);t.URL=g.split("|")[1];if(c.nodeType!="textLineBlock")for(c=c.parent;c.nodeType!="textLineBlock";)c=c.parent;c.addChild(t);N=!1}else if(D)t=new a.TextNode(g,"componentNumCtrl",F.clone(),E),c.addChild(t),D=!1;else if(J)t=new a.TextNode(g,"componentSpace",F.clone(),E),c.addChild(t),J=!1;else if(u)aa=C[C.length-2].style.clone(),ba=E.parser.parse(g),t=new a.TextNode(ba,"dynamicText",aa,E),C[C.length-
2].addChild(t),f=C[C.length-1]=t,u=!1;else if(u||h)!u&&h&&(ba=g,t=new a.TextNode(ba,"text",C[C.length-1].style.clone(),E),C[C.length-1].addChild(t));else{ba=g;t=new a.TextNode(ba,"text",F.clone(),E);if(c.nodeType!="textLineBlock")for(c=c.parent;c.nodeType!="textLineBlock";)c=c.parent;c.addChild(t)}else d=="openBlock"?(y=g,F=F.clone(),S.push(F),C.push(null)):d=="closeBlock"&&(g==H&&(H=-1,h=!1,c=c.parent),S.pop(),F=S[S.length-1],C.pop())}return Z.normalize()}}a.RTFParser=new W})(descartesJS);
(a=>{let k,g,d,b,e,l,w,q,n,p;class r{constructor(t,c){this.parent=t;g=this.evaluator=t.evaluator;d=g.parser;this.id=this.imageSrc=this.x_axis=this.y_axis=this.cID="";this.type="2D";this.xExpr=this.yExpr=d.parse("0");this.w=parseInt(t.container.width);this.h=parseInt(t.container.height);this.drawif=d.parse("1");this.fixed=this.text=this.numbers=this.sensitive_to_mouse_movements=!1;this.scale=48;this.Ox=this.Oy=this.mouse_x=this.mouse_y=this.border_width=this.border_radius=0;this.image=new Image;this.image.onload=
function(){this.ready=1};this.bg_display="topleft";this.background=new a.Color("ffffff");this.net=new a.Color("b8c4c8");this.net10=new a.Color("889498");this.axes=new a.Color("405860");this.border_color=new a.Color("000000");this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backGraphics=[];this.zIndex=t.zIndex;this.plecaHeight=t.plecaHeight||0;this.displaceRegionNorth=t.displaceRegionNorth||0;this.displaceRegionWest=t.displaceRegionWest||0;Object.assign(this,c);this.initSpace()}initSpace(){({evaluator:g,
parent:k}=this);this.resizable||(this.displaceRegionNorth=k.displaceRegionNorth||0,this.displaceRegionSouth=k.displaceRegionSouth||0,this.displaceRegionEast=k.displaceRegionEast||0,this.displaceRegionWest=k.displaceRegionWest||0,w=parseInt(k.container.width),l=parseInt(k.container.height),this.wExpr!=void 0&&(this.w=parseInt(w-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.wExpr)/100),this.hExpr!=void 0&&(this.h=parseInt(l-this.displaceRegionNorth-this.displaceRegionSouth)*parseFloat(this.hExpr)/
100),this.xPercentExpr!=void 0&&(this.xExpr=g.parser.parse(""+parseInt(w-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.xPercentExpr)/100)),this.yPercentExpr!=void 0&&(this.yExpr=g.parser.parse(""+parseInt(l-this.displaceRegionNorth-this.displaceRegionSouth)*parseFloat(this.yPercentExpr)/100)),this.x=g.eval(this.xExpr)+this.displaceRegionWest,this.y=g.eval(this.yExpr)+this.plecaHeight+this.displaceRegionNorth,this.container&&(this.container.style.left=this.x+"px",this.container.style.top=
this.y+"px"),this.y>=0?(b=l-this.y,this.h=Math.min(this.h,b)):(b=this.h+this.y,this.h=b>=l?l:b),this.x>=0?(e=w-this.x,this.w=Math.min(this.w,e)):(e=this.w+this.x,this.w=e>=w?w:e));this.imageSrc==""&&/vacio.gif$/i.test(this.imageSrc.trim())||(this.image=k.getImage(this.imageSrc));this.OxExpr&&(n=this.OxExpr,n.endsWith("%")?this.Ox=this.w*parseFloat(n)/100:(q=parseFloat(n),q!=n&&(q=0),this.Ox=q));this.OyExpr&&(p=this.OyExpr,p.endsWith("%")?this.Oy=this.h*parseFloat(p)/100:(q=parseFloat(p),q!=p&&(q=
0),this.Oy=q));let t=this.id+".";g.setVariable(t+"_w",this.w);g.setVariable(t+"_h",this.h);g.setVariable(t+"escala",g.getVariable(t+"escala")||this.scale);g.setVariable(t+"Ox",g.getVariable(t+"Ox")||this.Ox);g.setVariable(t+"Oy",g.getVariable(t+"Oy")||this.Oy);g.setVariable(t+"mouse_x",0);g.setVariable(t+"mouse_y",0);g.setVariable(t+"mouse_pressed",0);g.setVariable(t+"mouse_clicked",0);g.setVariable(t+"clic_izquierdo",0);this.w_2=this.w/2;this.h_2=this.h/2;g.setFunction(t+"download_image",c=>{g.functions._SaveSpace_(c,
this.canvas.toDataURL("image/png"))})}addCtr(t){t.type=="GraphicControl"?this.graphicsCtr.push(t):this.ctrs.push(t)}addGraph(t,c){this.type=="2D"&&c||this.type=="3D"&&!c||(t.background&&this.type!="3D"?this.backGraphics.push(t):this.graphics.push(t))}getRelativeX(t){return(Math.trunc(t)-this.w_2-this.Ox)/this.scale}getRelativeY(t){return(-Math.trunc(t)+this.h_2+this.Oy)/this.scale}getAbsoluteX(t){return t*this.scale+this.w_2+this.Ox}getAbsoluteY(t){return-t*this.scale+this.h_2+this.Oy}getDistance(t,
c){let f=t.clientX-c.clientX;t=t.clientY-c.clientY;return Math.sqrt(f*f+t*t)}clearClick(){this.evaluator.setVariable(this.mclickedStr,0);this.evaluator.setVariable(this.mclickIzqStr,0)}addEvents(){function t(){h.click!=0&&(h.click=0,h.evaluator.setVariable(h.mpressedStr,0),h.evaluator.setVariable(h.mclickedStr,1),h.evaluator.setVariable(h.mclickIzqStr,1),h.activePointers.clear(),h.initialPinchDistance=h.whichBtn=h.posZoom=h.posZoomNew=null,window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",
f),window.removeEventListener("pointercancel",f),h.parent.update())}function c(u){a.preventDefault(u);h.activePointers.has(u.pointerId)&&h.activePointers.set(u.pointerId,u);h.activePointers.size==1?h.whichBtn!="R"||h.fixed?h.whichBtn=="L"&&(h.fixed||h._dragMove(u),m(u)):(h.posZoomNew=a.getCursorPosition(u,h.container).y,h.evaluator.setVariable(h.scaleStr,h.tempScale+h.tempScale/45*((h.posZoom-h.posZoomNew)/10)),h.parent.update()):h.activePointers.size!=2||h.fixed||(u=Array.from(h.activePointers.values()),
h.initialPinchDistance>0&&(h.evaluator.setVariable(h.scaleStr,h.tempScale*(h.getDistance(u[0],u[1])/h.initialPinchDistance)),h.parent.update()))}function f(u){a.preventDefault(u);h.click=0;h.evaluator.setVariable(h.mpressedStr,0);h.evaluator.setVariable(h.mclickedStr,1);h.evaluator.setVariable(h.mclickIzqStr,1);h.whichBtn=="R"&&h.posZoom==h.posZoomNew&&a.showConfig&&h.parent.externalSpace.show();h.activePointers.delete(u.pointerId);h.activePointers.size==0?(window.removeEventListener("pointermove",
c),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),h.whichBtn=null):h.activePointers.size<2&&(h.initialPinchDistance=null);h.parent.update()}function m(u){h.posAnte=a.getCursorPosition(u,h.container);h.mouse_x=h.getRelativeX(h.posAnte.x);h.mouse_y=h.getRelativeY(h.posAnte.y);h.evaluator.setVariable(h.mxStr,h.mouse_x);h.evaluator.setVariable(h.myStr,h.mouse_y);h.clearClick();h.parent.update()}function v(u){h.click==0&&m(u)}const h=this;h.activePointers=new Map;
h.initialPinchDistance=h.whichBtn=null;h.disp={x:0,y:0};h.canvas.addEventListener("pointerdown",function(u){a.preventDefault(u);window.focus();document.activeElement.blur();h.parent.clearClick();h.parent.deactivateControls();h.activePointers.set(u.pointerId,u);window.addEventListener("pointermove",c);window.addEventListener("pointerup",f);window.addEventListener("pointercancel",f);h.activePointers.size==1?(h.click=1,h.whichBtn=a.whichBtn(u),h.whichBtn=="R"?(h.posZoom=a.getCursorPosition(u,h.container).y,
h.posZoomNew=h.posZoom,h.fixed||(h.tempScale=h.scale)):h.whichBtn=="L"&&(h.evaluator.setVariable(h.mpressedStr,1),h.evaluator.setVariable(h.mclickedStr,0),h.evaluator.setVariable(h.mclickIzqStr,0),h._dragStart(u),m(u))):h.activePointers.size==2&&(u=Array.from(h.activePointers.values()),h.initialPinchDistance=h.getDistance(u[0],u[1]),h.tempScale=h.scale)});h.sensitive_to_mouse_movements&&h.canvas.addEventListener("pointermove",v);window.addEventListener("blur",t);document.body.addEventListener("mouseleave",
t)}}a.Space=r})(descartesJS);
(a=>{class k{constructor(g){this.parent=g;this.width=228;this.vSpace=25;this.container=a.newHTML("div",{style:`box-sizing:border-box;border-style:ridge;border-width:5px;border-color:gray;box-shadow:#000 0 0 25px 5px;overflow-y:scroll;overflow-x:hidden;position:fixed;left:0;top:0;z-index:10000;background-color:#63b4fb;width:${this.width+27}px;height:460px;`});this.movable=a.newHTML("div",{style:`position:absolute;left:0;top:0;width:${this.width+27}px;height:${this.vSpace}px;line-height:${this.vSpace}px;background-color:#ddd;cursor:move;padding-left:75px;font-family:${a.sansserif_font};font-size:18px;touch-action:none;`});this.movable.innerHTML=
"DescartesJS";this.container.appendChild(this.movable);this.ctrs=[]}init(){function g(n){q.newPos=a.getCursorPosition(n,document.body);q.container.style.left=q.initialPosition.x+(q.newPos.x-q.oldPos.x)*a.cssScale+"px";q.container.style.top=q.initialPosition.y+(q.newPos.y-q.oldPos.y)*a.cssScale+"px"}function d(n){a.preventDefault(n);q.movable.releasePointerCapture(n.pointerId);q.movable.removeEventListener("pointermove",g);q.movable.removeEventListener("pointerup",d)}document.body.appendChild(this.container);
let b=this.parent.evaluator.parser;var e=b.parse("15");let l=this.language=="english";this.numCtr=this.ctrs.length;this.ctrs.forEach((n,p)=>{n.expresion=b.parse(`(0,${this.vSpace+23+p*35},${this.width},35)`);n.update()});let w=new a.Button(this.parent,{region:"external",name:l?"about":"cr\u00e9ditos",font_size:e,expresion:b.parse(`(0,${this.vSpace},${this.width/2},25)`)});w.actionExec={execute:a.showAbout};w.update();(new a.Button(this.parent,{region:"external",name:"config",font_size:e,action:"config",
expresion:b.parse(`(${this.width/2},${this.vSpace},${this.width/2},25)`)})).update();(new a.Button(this.parent,{region:"external",name:l?"init":"inicio",font_size:e,action:"init",expresion:b.parse(`(0,${this.vSpace+23+this.numCtr*35},${this.width/2},25)`)})).update();(new a.Button(this.parent,{region:"external",name:l?"clear":"limpiar",font_size:e,action:"clear",expresion:b.parse(`(${this.width/2},${this.vSpace+23+this.numCtr*35},${this.width/2},25)`)})).update();e=new a.Button(this.parent,{region:"external",
name:l?"close":"cerrar",font_size:e,expresion:b.parse(`(${this.width/4},${this.vSpace+46+this.numCtr*35},${this.width/2},25)`)});e.update();e.btn.addEventListener("click",()=>{this.hide()});this.setPositionAndSize();const q=this;q.movable.addEventListener("pointerdown",function(n){a.preventDefault(n);q.oldPos=a.getCursorPosition(n,document.body);q.initialPosition={x:q.container.offsetLeft,y:q.container.offsetTop};q.movable.setPointerCapture(n.pointerId);q.movable.addEventListener("pointermove",g);
q.movable.addEventListener("pointerup",d)});q.hide()}addCtr(g){this.ctrs.push(g)}show(){this.setPositionAndSize();this.container.style.display="block"}hide(){this.container.style.display="none"}setPositionAndSize(){let g=this.vSpace+this.numCtr*35+81,d=g;this.container.style.left=Math.max(parseInt(window.innerWidth-this.width)/2,0)+"px";this.container.style.top="5px";window.innerHeight<this.vSpace+75?d=this.vSpace+75:g>window.innerHeight-10&&(d=window.innerHeight-10);this.container.style.height=d+
"px"}}a.SpaceExternal=k})(descartesJS);
(a=>{const k=Math.PI*2,g="Italic 16px "+a.math_font,d="12px "+a.monospace_font;let b,e,l,w,q,n,p,r,t,c,f,m,v,h,u,x,z,G,A,I,S,F,y,H,C,D,J,N,Z,ba,ca,aa,L,P,U,W;class M extends a.Space{constructor(E,O){super(E,O);this.ratio=E.ratio;O=`${this.border_width>0?"border:"+this.border_width+"px solid "+this.border_color.getColor()+";":""}${this.border_radius?"border-radius:"+this.border_radius+"px;":""}`;this.canvas=a.newHTML("canvas",{id:this.id+"_canvas",class:"DescartesSpace2DCanvas",width:this.w*this.ratio+
"px",height:this.h*this.ratio+"px",style:O});this.backCanvas=a.newHTML("canvas",{id:this.id+"_background",width:this.w*this.ratio+"px",height:this.h*this.ratio+"px",style:O});this.canvas.style.zIndex=this.zIndex;this.ctx=this.canvas.getContext("2d");this.backCtx=this.backCanvas.getContext("2d");this.ctx.imageSmoothingEnabled=this.backCtx.imageSmoothingEnabled=!1;this.ctx.textRendering=this.backCtx.textRendering="optimizeSpeed";this.canvas.ratio=this.backCanvas.ratio=this.ratio;O=`position:absolute;left:0;top:0;z-index:${this.zIndex};`;
this.graphicControlContainer=a.newHTML("div",{id:this.id+"_graphicControls",style:O});this.numCtrContainer=a.newHTML("div",{id:this.id+"_numericalControls",style:O});this.container=a.newHTML("div",{id:this.id,class:"DescartesSpace2DContainer",style:`z-index:${this.zIndex};${this.border_radius?"border-radius:"+this.border_radius+"px;":""}`});this.container.appendChild(this.backCanvas);this.container.appendChild(this.canvas);this.container.appendChild(this.graphicControlContainer);this.container.appendChild(this.numCtrContainer);
E.container.insertBefore(this.container,E.loader);O=this.id+".image";E.images[O]=this.canvas;E.images[O].ready=1;E.images[O].complete=E.images[O].canvas=!0;E.evaluator.setVariable(O,O);O=this.id+".back";E.images[O]=this.backCanvas;E.images[O].ready=1;E.images[O].complete=E.images[O].canvas=!0;E.evaluator.setVariable(O,O);O=this.id+".";this.OxStr=O+"Ox";this.OyStr=O+"Oy";this.scaleStr=O+"escala";this.wStr=O+"_w";this.hStr=O+"_h";this.mxStr=O+"mouse_x";this.myStr=O+"mouse_y";this.mpressedStr=O+"mouse_pressed";
this.mclickedStr=O+"mouse_clicked";this.mclickIzqStr=O+"clic_izquierdo";this.refreshStr=O+"_refresh_back_";this.click=0;this.resizable&&(this.wModExpr=E.evaluator.parser.parse(this.wModExpr),this.hModExpr=E.evaluator.parser.parse(this.hModExpr));this.id!="descartesJS_stage"&&this.addEvents();E.evaluator.setVariable(this.refreshStr,1)}init(){this.initSpace();this.canvas&&(this.old_w=this.w,this.old_h=this.h,this.canvas.width=this.backCanvas.width=this.w*this.ratio,this.canvas.height=this.backCanvas.height=
this.h*this.ratio,this.canvas.style.width=this.backCanvas.style.width=this.container.style.width=this.w+"px",this.canvas.style.height=this.backCanvas.style.height=this.container.style.height=this.h+"px")}update(E){b=this.evaluator;if(this.resizable){if(U=b.eval(this.wModExpr),W=b.eval(this.hModExpr),this.old_w!=U||this.old_h!=W)this.w=U,this.h=W,this.w_2=this.w/2,this.h_2=this.h/2,b.setVariable(this.wStr,this.w),b.setVariable(this.hStr,this.h),this.old_w=this.w,this.old_h=this.h,this.canvas.width=
this.backCanvas.width=this.w*this.ratio,this.canvas.height=this.backCanvas.height=this.h*this.ratio,this.canvas.style.width=this.backCanvas.style.width=this.container.style.width=this.w+"px",this.canvas.style.height=this.backCanvas.style.height=this.container.style.height=this.h+"px",E=!0,this.backCtx.setTransform(this.ratio,0,0,this.ratio,0,0),this.drawBackground()}else b.setVariable(this.wStr,this.w),b.setVariable(this.hStr,this.h);if(this.drawIfValue=b.eval(this.drawif)>0){n=b.eval(this.xExpr)+
this.displaceRegionWest;p=b.eval(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;l=this.x!==n;w=this.y!==p;q=b.getVariable(this.scaleStr);r=b.getVariable(this.OxStr);t=b.getVariable(this.OyStr);this.spaceChange=E||l||w||this.drawBefore!==this.drawIfValue||this.Ox!==r||this.Oy!==t||this.scale!==q||this.backColor!==this.background.getColor();l&&(this.x=n);w&&(this.y=p);this.Ox=Number.isFinite(r)?r:0;this.Oy=Number.isFinite(t)?t:0;this.scale=Math.max(1E-6,Math.min(1E6,q));b.setVariable(this.scaleStr,
this.scale);this.drawBefore=this.drawIfValue;if(l||w)this.container.style.left=this.x+"px",this.container.style.top=this.y+"px";this.container.style.display="block";this.drawTrace=!this.spaceChange&&(!this.fixed&&!this.click||this.fixed);this.spaceChange&&(this.backCtx.setTransform(this.ratio,0,0,this.ratio,0,0),this.drawBackground());this.ctx.setTransform(this.ratio,0,0,this.ratio,0,0);this.draw()}else this.container.style.display="none"}drawBackground(){e=this.backCtx;e.clearRect(0,0,this.backCanvas.width,
this.backCanvas.height);e.fillStyle=this.backColor=this.background.getColor();e.fillRect(0,0,this.backCanvas.width,this.backCanvas.height);this.image&&this.image.src&&this.image.ready&&this.image.complete&&(this.bg_display=="topleft"?e.drawImage(this.image,0,0):this.bg_display=="stretch"?e.drawImage(this.image,0,0,this.w,this.h):this.bg_display=="patch"?(e.fillStyle=e.createPattern(this.image,"repeat"),e.fillRect(0,0,this.w,this.h)):this.bg_display=="imgcenter"&&e.drawImage(this.image,(this.w-this.image.width)/
2,(this.h-this.image.height)/2));c=this.scale;f=0;for(m=Math.max(0,this.w+this.h);c>m;)c/=10,f++;for(;c<m/10;)c*=10;e.lineWidth=1;this.net!==""&&(e.strokeStyle=this.net.getColor(),this.drawMarks(e,c/10,-1));this.net10&&(e.strokeStyle=this.net10.getColor(),this.drawMarks(e,c,-1));this.axes&&(e.strokeStyle=this.axes.getColor(),e.beginPath(),this.x_axis!="no"&&(H=Math.floor(this.h/2+this.Oy)+.5,e.moveTo(0,H),e.lineTo(this.w,H)),this.y_axis!="no"&&(y=Math.floor(this.w/2+this.Ox)+.5,e.moveTo(y,0),e.lineTo(y,
this.h)),e.lineWidth=1.2,e.stroke(),e.lineWidth=1,this.drawMarks(e,c,4,this.x_axis=="no",this.y_axis=="no"),this.drawMarks(e,c/2,2,this.x_axis=="no",this.y_axis=="no"),this.drawMarks(e,c/10,1,this.x_axis=="no",this.y_axis=="no"));if(this.x_axis!==""||this.y_axis!=="")e.fillStyle=this.axes!==""?this.axes.getColor():"#000",e.font=g,e.textAlign="right",e.textBaseline="alphabetic",this.x_axis!="no"&&e.fillText(this.x_axis,Math.floor(this.w)-2,Math.floor(this.h/2+this.Oy)+12),this.y_axis!="no"&&e.fillText(this.y_axis,
Math.floor(this.w/2+this.Ox)-2,12);this.numbers&&this.axes!=""&&(e.fillStyle=this.axes.getColor(),e.font=g,c>(this.w+this.h)/2?this.drawNumbers(e,c/5,c<=this.scale?f+1:f):c>(this.w+this.h)/4?this.drawNumbers(e,c/2,c<=this.scale?f+1:f):this.drawNumbers(e,c,f));for(let E of this.backGraphics)E.draw()}draw(){e=this.ctx;b.getVariable(this.refreshStr)&&e.clearRect(0,0,this.canvas.width,this.canvas.height);for(let E of this.graphics)E.trace&&this.drawTrace&&E.drawTrace(),E.draw();for(let E of this.graphicsCtr)E.draw();
this.text&&this.click&&this.whichBtn=="L"&&(e.save(),e.strokeStyle=e.fillStyle=this.text.getColor(),e.lineWidth=1,e.font=d,e.textAlign="center",e.textBaseline="alphabetic",C=this.scale<=1?0:Math.floor(Math.log10(this.scale))+1,D=this.mouse_x.oToFixed(C),J=this.mouse_y.oToFixed(C),N=`(${D},${J})`,Z=Math.floor(e.measureText(N).width/2),ba=this.getAbsoluteX(this.mouse_x),ca=this.getAbsoluteY(this.mouse_y),aa=Math.floor(ba),L=Math.floor(ca-10),aa=Math.max(Z,Math.min(this.w-Z,aa)),L=Math.max(15,Math.min(this.h,
L)),e.fillText(N,aa,L),e.beginPath(),e.arc(ba,ca,2.5,0,k),e.stroke(),e.restore())}drawMarks(E,O,Q,X=!1,T=!1){v=this.w;h=this.h;z=Math.floor(v/2+this.Ox);G=Math.floor(h/2+this.Oy);A=S=.5;I=v+.5;F=h+.5;Q>=0&&(A=z-Q+.5,I=z+Q+.5,S=G-Q+.5,F=G+Q+.5);E.beginPath();if(!X)for(Q=-Math.round(z/O);;Q++){u=z+Math.round(Q*O);if(u>=v)break;E.moveTo(u+.5,S);E.lineTo(u+.5,F)}if(!T)for(T=-Math.round(G/O);;T++){x=G+Math.round(T*O);if(x>=h)break;E.moveTo(A,x+.5);E.lineTo(I,x+.5)}E.stroke()}drawNumbers(E,O){v=this.w;
h=this.h;z=Math.floor(v/2+this.Ox);G=Math.floor(h/2+this.Oy);E.textAlign="center";E.textBaseline="bottom";for(var Q=-Math.round(z/O);;Q++){u=z+Math.round(Q*O);if(u>=v)break;E.fillText(parseFloat((Q*O/this.scale).oToFixed(4)),u+1,G-2)}E.textAlign="start";E.textBaseline="middle";for(Q=-Math.round(G/O);;Q++){x=G+Math.round(Q*O);if(x>=h)break;parseFloat(-Q*O/this.scale)!==0&&E.fillText(parseFloat((-Q*O/this.scale).oToFixed(4)),z+5,x)}}_dragStart(E){this.posAnte=a.getCursorPosition(E,this.container)}_dragMove(E){P=
a.getCursorPosition(E,this.container);this.evaluator.setVariable(this.OxStr,this.Ox-this.posAnte.x+P.x);this.evaluator.setVariable(this.OyStr,this.Oy-this.posAnte.y+P.y);this.posAnte=P}}a.Space2D=M})(descartesJS);
(a=>{var k,g,d;function b(M,E){return E.depth-M.depth}let e,l,w,q,n,p,r,t,c,f,m,v,h,u,x,z,G,A,I,S,F,y,H,C=[],D,J,N,Z,ba,ca,aa,L,P,U;class W extends a.Space{constructor(M,E){super(M,E);this.ratio=M.ratio;this.canvas=a.newHTML("canvas",{id:this.id+"_canvas",width:this.w*this.ratio+"px",height:this.h*this.ratio+"px",class:"DescartesSpace3DCanvas",style:`${this.border_width>0?"border:"+this.border_width+"px solid "+this.border_color.getColor()+";":""}${this.border_radius?"border-radius:"+this.border_radius+
"px;":""}`});this.canvas.style.zIndex=this.zIndex;this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.canvas.ratio=this.ratio;E=this.id+".image";M.images[E]=this.canvas;M.images[E].ready=1;M.images[E].complete=M.images[E].canvas=!0;M.evaluator.setVariable(E,E);E=`position:absolute;left:0;top:0;z-index:${this.zIndex};`;this.graphicControlContainer=a.newHTML("div",{id:this.id+"_graphicControls",style:E});this.numCtrContainer=a.newHTML("div",{id:this.id+"_numericalControls",
style:E});this.container=a.newHTML("div",{id:this.id,class:"DescartesSpace3DContainer",style:`z-index:${this.zIndex};${this.border_radius?"border-radius:"+this.border_radius+"px;":""}`});this.container.appendChild(this.canvas);this.container.appendChild(this.graphicControlContainer);this.container.appendChild(this.numCtrContainer);M.container.insertBefore(this.container,M.loader);this.eye={x:0,y:0,z:0};this.lights=[{x:50,y:50,z:70},{x:50,y:-50,z:30},{x:20,y:0,z:-80},{x:0,y:0,z:0}];for(let Q=0,X=this.lights.length;Q<
X;Q++)this.lights[Q]=a.normalize3D(this.lights[Q]);this.light3={x:0,y:0,z:0};this.intensity=[.4,.5,.3,0];this.userIntensity=0;this.dim=1;this.tmpIntensity=[];E=this.id+".";this.OxStr=E+"Ox";this.OyStr=E+"Oy";this.scaleStr=E+"escala";this.wStr=E+"_w";this.hStr=E+"_h";this.mxStr=E+"mouse_x";this.myStr=E+"mouse_y";this.mpressedStr=E+"mouse_pressed";this.mclickedStr=E+"mouse_clicked";this.mclickIzqStr=E+"clic_izquierdo";this.obsStr=E+"observador";this.ojoXStr=E+"Ojo.x";this.ojoYStr=E+"Ojo.y";this.ojoZStr=
E+"Ojo.z";this.rotZStr=E+"rot.z";this.rotYStr=E+"rot.y";this.userIDimStr=E+"userIlum.dim";this.userIIStr=E+"userIlum.I";this.userIxStr=E+"userIlum.x";this.userIyStr=E+"userIlum.y";this.userIzStr=E+"userIlum.z";M.evaluator.setVariable(this.rotZStr,0);M.evaluator.setVariable(this.rotYStr,0);M.evaluator.setVariable(this.userIDimStr,this.dim);M.evaluator.setVariable(this.userIIStr,this.userIntensity);M.evaluator.setVariable(this.userIxStr,0);M.evaluator.setVariable(this.userIyStr,0);M.evaluator.setVariable(this.userIzStr,
0);U=new a.Primitive3D({V:[new a.Vec4D],type:"vertex"},this);const O=this;M.evaluator.setFunction(this.id+"._X3D2D_",function(Q,X,T){U.V[0].x=Q;U.V[0].y=X;U.V[0].z=T;U.computeDepth(O);return U.projV[0].x});M.evaluator.setFunction(this.id+"._Y3D2D_",function(Q,X,T){U.V[0].x=Q;U.V[0].y=X;U.V[0].z=T;U.computeDepth(O);return U.projV[0].y});this.resizable&&(this.wModExpr=M.evaluator.parser.parse(this.wModExpr),this.hModExpr=M.evaluator.parser.parse(this.hModExpr));this.addEvents()}init(M){this.initSpace();
this.canvas&&(this.old_w=this.w,this.old_h=this.h,this.canvas.width=this.w*this.ratio,this.canvas.height=this.h*this.ratio,this.canvas.style.width=this.container.style.width=this.w+"px",this.canvas.style.height=this.container.style.height=this.h+"px");this.w_2=this.w/2;this.h_2=this.h/2;this.w_plus_h=this.w+this.h;this.oldMouse={x:0,y:0};this.S={x:this.h/1080*(40/this.scale)*-20.6,y:0,z:0};this.Ojo={x:3*this.w_2,y:0,z:0};this.evaluator.setVariable(this.ojoXStr,this.Ojo.x);this.evaluator.setVariable(this.ojoYStr,
this.Ojo.y);this.evaluator.setVariable(this.ojoZStr,this.Ojo.z)}update(M){({evaluator:e,parent:l}=this);e.setVariable(this.wStr,this.w);e.setVariable(this.hStr,this.h);if(this.drawIfValue=e.eval(this.drawif)>0){this.resizable&&(wModExpr=this.evaluator.eval(this.wModExpr),hModExpr=this.evaluator.eval(this.hModExpr),this.old_w!=wModExpr||this.old_h!=hModExpr)&&(this.old_w=this.w=wModExpr,this.old_h=this.h=hModExpr,this.w_2=this.w/2,this.h_2=this.h/2,e.setVariable(this.wStr,this.w),e.setVariable(this.hStr,
this.h),this.canvas.width=this.w*this.ratio,this.canvas.height=this.h*this.ratio,this.canvas.style.width=this.container.style.width=this.w+"px",this.canvas.style.height=this.container.style.height=this.h+"px",M=!0,this.S={x:this.h/1080*(40/this.scale)*-20.6,y:0,z:0},this.Ojo={x:3*this.w_2,y:0,z:0},this.evaluator.setVariable(this.ojoXStr,this.Ojo.x),this.evaluator.setVariable(this.ojoYStr,this.Ojo.y),this.evaluator.setVariable(this.ojoZStr,this.Ojo.z));c=e.eval(this.xExpr)+this.displaceRegionWest;
f=e.eval(this.yExpr)+l.plecaHeight+this.displaceRegionNorth;n=this.x!==c;p=this.y!==f;m=e.getVariable(this.OxStr);v=e.getVariable(this.OyStr);h=e.getVariable(this.ojoXStr);u=e.getVariable(this.ojoYStr);x=e.getVariable(this.ojoZStr);z=e.getVariable(this.scaleStr);this.spaceChange=M||n||p||this.drawBefore!==this.drawIfValue||this.Ox!==m||this.Oy!==v||this.Ojo.x!==h||this.Ojo.y!==u||this.Ojo.z!==x||this.scale!==z;n&&(this.x=c);p&&(this.y=f);this.Ojo.x=h;this.Ojo.y=u;this.Ojo.z=x;this.Ox=Number.isFinite(m)?
m:0;this.Oy=Number.isFinite(v)?v:0;this.drawBefore=this.drawIfValue;if(M||this.observer==void 0){for(let E of this.parent.controls)E.id==this.obsStr&&(P=!0);this.observer=P?e.getVariable(this.obsStr)||this.w_plus_h*2.5:this.w_plus_h*2.5;this.observer=Math.max(this.observer,.25*this.w_plus_h);e.setVariable(this.obsStr,this.observer)}this.scale=Math.max(1E-6,Math.min(1E6,z));e.setVariable(this.scaleStr,this.scale);if(n||p)this.container.style.left=this.x+"px",this.container.style.top=this.y+"px";this.container.style.display=
"block";this.dim=e.getVariable(this.userIDimStr);this.userIntensity=e.getVariable(this.userIIStr);this.light3={x:Math.trunc(e.getVariable(this.userIxStr)),y:Math.trunc(e.getVariable(this.userIyStr)),z:Math.trunc(e.getVariable(this.userIzStr))};this.updateCamera();this.ctx.setTransform(this.ratio,0,0,this.ratio,0,0);this.draw()}else this.container.style.display="none"}updateCamera(){this.eye=a.scalarProd3D(this.Ojo,1/this.scale)}rotateVertex(M){G=a.degToRad(this.evaluator.getVariable(this.rotZStr));
A=Math.cos(G);I=Math.sin(G);k=M.x*A-M.y*I;g=M.x*I+M.y*A;d=M.z;G=a.degToRad(this.evaluator.getVariable(this.rotYStr));A=Math.cos(G);I=Math.sin(G);return{x:d*I+k*A,y:g,z:d*A-k*I}}project(M){let E=this.eye.x/(M.x-this.eye.x);return{x:this.getAbsoluteX(E*(this.eye.y-M.y)),y:this.getAbsoluteY(E*(this.eye.z-M.z)),z:this.eye.x-M.x}}computeColor(M,E,O){typeof M!="object"&&(M.includes("rgba")?M=a.RGBAToHexColor(M):M.includes("#")&&(M=new a.Color(M.slice(1))));Z=a.subtract3D(this.eye,E.avg);ba=a.norm3D(Z);
ca=a.scalarProd3D(Z,1/ba);this.lights[3]=a.subtract3D(this.light3,E.avg);H=a.norm3D(this.lights[3]);for(let K=0,R=this.intensity.length-1;K<R;K++)C[K]=this.intensity[K]*this.dim;C[3]=this.userIntensity*this.userIntensity/H||0;D=O?this.dim/2:this.dim/4;J=0;N=E.direction<0?E.normal:a.scalarProd3D(E.normal,-1);for(let K=0,R=this.lights.length;K<R;K++){if(O){E=Math;var Q=E.max,X=a,T=X.dotProduct3D;var B=this.lights[K];aa=a.add3D(B,a.scalarProd3D(a.subtract3D(B,a.scalarProd3D(N,a.dotProduct3D(B,N))),-2));
L=a.norm3D(aa);B=L!==0?a.scalarProd3D(aa,1/L):a.scalarProd3D(B,-1);J=Q.call(E,0,T.call(X,B,ca));J*=J*J}else J=Math.max(0,a.dotProduct3D(this.lights[K],N));D+=C[K]*J}D=Math.min(D,1);S=Math.round(M.r*D);F=Math.round(M.g*D);y=Math.round(M.b*D);return`rgba(${S},${F},${y},${M.a})`}draw(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);this.image&&this.image.src!=""&&this.image.ready&&
this.image.complete&&(this.bg_display=="topleft"?this.ctx.drawImage(this.image,0,0):this.bg_display=="stretch"?this.ctx.drawImage(this.image,0,0,this.w,this.h):this.bg_display=="patch"?(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):this.bg_display=="center"&&this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));if(!this.click){for(var M of this.graphics)M.update();this.primitives=[];if(this.split)for(let E=
0,O=this.graphics.length;E<O;E++){w=this.graphics[E];for(M=E+1;M<O;M++)q=this.graphics[M],w.splitFace(q),q.splitFace(w);this.primitives=this.primitives.concat(w.primitives||[])}else for(let E=0,O=this.graphics.length;E<O;E++){w=this.graphics[E];if(w.split)for(M=E+1;M<O;M++)q=this.graphics[M],q.split&&w.splitFace(q);this.primitives=this.primitives.concat(w.primitives||[])}}for(let E of this.primitives)E.computeDepth(this);this.primitives=this.primitives.sort(b);if(this.render=="painter")this.drawPainter(this.primitives);
else for(let E of this.primitives)E.draw(this.ctx,this);for(let E of this.graphicsCtr)E.draw()}drawPainter(M){let E=M.length;for(var O=0;O<E;O++)M[O].drawn=!1,M[O].draw(this.ctx,this);var Q=[];O=[];let X=0,T=M.length,B=.001,K,R;for(;;){K=T;for(let V=0;V<E;V++)if(!M[V].drawn){R=!0;for(let Y=0;Y<E;Y++)if(Y!=V&&!M[Y].drawn&&M[V].inFrontOf(Q,M[Y],B)){R=!1;break}R&&(T--,O[X++]=M[V],M[V].drawn=!0)}if(T==0)break;else if(T==K){if(B*=10,B>.1){for(Q=0;Q<E;Q++)M[Q].drawn||(O[X++]=M[Q],M[Q].drawn=!0);break}}else B=
.001}for(M=0;M<E;M++)O[M].draw(this.ctx,this)}rayFromEye(M,E){return{x:-this.eye.x,y:(M-(this.w_2+this.Ox))/this.scale-this.eye.y,z:(this.h_2+this.Oy-E)/this.scale-this.eye.z}}_dragStart(M){this.posAnte=a.getCursorPosition(M,this.container);this.oldMouse.x=this.getRelativeX(this.posAnte.x);this.oldMouse.y=this.getRelativeY(this.posAnte.y)}_dragMove(M){r=(this.getAbsoluteX(this.oldMouse.x)-this.getAbsoluteX(this.mouse_x))/4;t=(-this.getAbsoluteY(this.oldMouse.y)+this.getAbsoluteY(this.mouse_y))/4;
if(r!==this.disp.x||t!==this.disp.y)this.alpha=this.evaluator.getVariable(this.rotZStr)-r,this.beta=-this.evaluator.getVariable(this.rotYStr)-t,this.evaluator.setVariable(this.rotZStr,this.alpha),this.evaluator.setVariable(this.rotYStr,-this.beta),this.disp.x=r,this.disp.y=t,this.oldMouse.x=this.mouse_x,this.oldMouse.y=this.mouse_y}}a.Space3D=W})(descartesJS);
(a=>{let k,g,d,b,e,l,w;class q extends a.Space{constructor(n,p){super(n,p);k=this.parent.evaluator;this._w_!=void 0&&(n=k.parser.parse(this._w_),this._w_=n.type!="number"?n:void 0);this._h_!=void 0&&(n=k.parser.parse(this._h_),this._h_=n.type!="number"?n:void 0);this.isFirefox=/firefox/i.test(window.navigator.userAgent);this.file=this.file?this.file.trim():"";/^\[.*\]$/.test(this.file)?this.file=k.parser.parse(this.file.slice(1,-1)):/^'.*'$/.test(this.file)?this.file=k.parser.parse(this.file):this.file=
k.parser.parse(`'${this.file}'`);this.oldFile=k.eval(this.file);this.MyIFrame=a.newHTML("iframe",{marginheight:0,marginwidth:0,frameborder:0,scrolling:"auto",class:"DescartesSpaceIframe"});this.oldFile!=0&&this.MyIFrame.setAttribute("src",this.oldFile);this.container=a.newHTML("div",{id:this.id,class:"DescartesSpaceIframeContainer",style:`width:${this.w}px;height:${this.h}px;left:${this.x}px;top:${this.y}px;z-index:${this.zIndex};${a.isIOS?"overflow:scroll;-webkit-overflow-scrolling:touch;overflow-scrolling:touch;":
""}`});this.container.appendChild(this.MyIFrame);this.parent.container.insertBefore(this.container,this.parent.loader);const r=this;this.MyIFrame.onload=function(t){let c=this;r.evaluator.setFunction(r.id+".set",function(f,m){c.contentWindow.postMessage({type:"set",name:f,value:m},"*");return 0});r.evaluator.setFunction(r.id+".update",function(){c.contentWindow.postMessage({type:"update"},"*");return 0});r.evaluator.setFunction(r.id+".exec",function(f,m){c.contentWindow.postMessage({type:"exec",name:f,
value:m},"*");return 0});r.evaluator.setFunction(r.id+".changeConf",function(f){if(f){if(a.cacheFiles[f])var m=a.cacheFiles[f];else m=(m=document.getElementById(f))&&m.type=="descartes/embed"?m.textContent:a.openFile(f),m=(m=(new DOMParser).parseFromString(m,"text/html").querySelector("ajs"))?m.innerHTML:"",a.cacheFiles[f]=m;c.contentWindow.postMessage({type:"change_config",filename:f,content:m},"*")}return 0});r.evaluator.setFunction(r.id+".changeContent",function(f){f&&(f=(f=(new DOMParser).parseFromString(f.replace(/&sq;/g,
"'"),"text/html").querySelector("ajs"))?f.innerHTML:"",c.contentWindow.postMessage({type:"change_content",content:f},"*"))});r.ImReady=!r.isFirefox;r.isFirefox||(r.container.style.visibility="visible",r.container.style.opacity="1",r.container.style.zIndex=r.zIndex,r.container.style.display=r.drawIfValue?"block":"none");r.MyIFrame.style.visibility="visible";r.container.style.backgroundImage=""};this.update();this.evaluator.setVariable(this.id+"._scroll",0)}init(){this.initSpace()}update(n){g=this.container;
k=this.evaluator;this.drawIfValue=k.eval(this.drawif)>0;this.ImReady?g.style.display=this.drawIfValue?"block":"none":(g.style.visibility=this.drawIfValue?"visible":"hidden",g.style.opacity=this.drawIfValue?"1":"0",g.style.zIndex=this.drawIfValue?this.zIndex:-1E3);if(this.drawIfValue){n&&(this.x=this.y=Infinity);e=k.eval(this.xExpr)+this.displaceRegionWest;if(d=this.x!==e)this.x=e;e=k.eval(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;if(b=this.y!==e)this.y=e;this._w_!=void 0&&(e=k.eval(this._w_),
this.w!==e&&(g.style.width=e+"px",this.w=e));this._h_!=void 0&&(e=k.eval(this._h_),this.h!==e&&(g.style.height=e+"px",this.h=e));if(d||b)g.style.left=this.x+"px",g.style.top=this.y+"px";l=k.eval(this.file);l!==this.oldFile&&(this.ImReady=!1,this.isFirefox||(g.style.display="block",g.style.visibility=this.drawIfValue?"visible":"hidden",g.style.opacity=this.drawIfValue?"1":"0",g.style.zIndex=this.drawIfValue?this.zIndex:-1E3),this.MyIFrame.style.visibility="hidden",this.oldFile=l,this.MyIFrame.contentWindow.location.replace(l));
w=k.getVariable(this.id+"._scroll");w==1?(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=""):w==-1?(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}else this.MyIFrame.contentWindow.blur()}}a.SpaceHTMLIFrame=q})(descartesJS);
(a=>{class k{constructor(g){this.children=g.children;this.lessonParser=g.lessonParser;this.images=g.images;this.audios=g.audios;this.parent=g;for(let b of document.querySelectorAll('script[type="descartes/imagen"]')){g.images[b.id]=new Image;g.images[b.id].onload=function(){this.ready=1};var d=b.innerText.trim();d.startsWith("data:image/svg+xml,")&&(d=encodeURIComponent(d).replace(encodeURIComponent("data:image/svg+xml,"),"data:image/svg+xml,"));g.images[b.id].src=d}this.imgLoader=a.newHTML("div",
{class:"DescartesLoaderImage"});g.loader.appendChild(this.imgLoader);this.progress=a.newHTML("progress",{class:"PBL",value:0,max:100});g.imgLoader?(g.loader.style.backgroundColor="transparent",this.imgLoader.setAttribute("style",`background-image:url(${g.imgLoader});background-size:contain;`)):(d=Math.min(2.5,g.width<g.height?g.width/1144:g.height/1092),this.imgLoader.setAttribute("style",`background-image:url(${a.loaderImg.src});background-position:50% 33.5%;background-size:${880*d}px;`),this.progress.setAttribute("style",
`left:${(g.width-726*d)/2}px;top:${g.height*33.5/100+940*d/2}px;width:${726*d}px;height:${14*d}px;`),g.loader.appendChild(this.progress));this.initPreloader()}initPreloader(){let {images:g,audios:d}=this,b=/[\w\.\-//]*(?:\.png|\.jpg|\.gif|\.svg|\.webp)/gi,e=/[\w\.\-//]*(?:\.ogg|\.oga|\.mp3|\.wav)/gi,l=/'macro'|'makro'/;var w;for(let t of this.children){if(l.test(t.value)){var q=w=null;for(let c of this.lessonParser.split(t.value))if(babel[c[0]]=="expresion"){q=c[1];break}q&&(w=(w=document.getElementById(q))&&
w.type=="descartes/macro"?w.text:a.openFile(q));if(w&&(q=w.match(b)))for(let c of q)!c.toLowerCase().endsWith("vacio.gif")&&c.length>4&&!g[c]&&(g[c]=this.parent.getImageAux(c))}if(q=t.value.match(b))for(let c of q)!c.toLowerCase().endsWith("vacio.gif")&&c.length>4&&!g[c]&&(g[c]=this.parent.getImageAux(c));if(q=t.value.match(e))for(let c of q)d[c]||(d[c]=this.parent.getAudioAux(c))}let n=Object.keys(g).length+Object.keys(d).length;if(n==0)this.parent.initBuildApp();else{var p,r=()=>{p=0;for(let t of Object.values(g))(t.ready||
t.errorload)&&p++;for(let t of Object.values(d))(t.ready||t.errorload)&&p++;this.progress.setAttribute("value",p);p<n?this.timer=a.setTimeout(r,0):this.parent.initBuildApp()};this.progress.setAttribute("max",n);r()}}}a.DescartesLoader=k})(descartesJS);
(a=>{function k(){a.cssScale=Math.min(window.innerWidth/this.width,window.innerHeight/this.height);this.container.parentNode.style.width=window.innerWidth+"px";this.container.parentNode.style.height=window.innerHeight+"px";this.container.style.transform=`translate(-50%, -50%) scale(${a.cssScale})`}class g{constructor(d){this.animation={playing:!1,play:()=>{},stop:()=>{},reinit:()=>{}};this.ratio=a._ratio;this.URL=window.location.href;this.applet=d;this.parentC=d.parentNode;this.width=parseFloat(d.getAttribute("width"));
this.height=parseFloat(d.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=RegExp("\\.","g");this.language="espa\u00f1ol";this.children=d.getElementsByTagName("param");this.code=d.getAttribute("code");this.images={};this.audios={};this.firstRun=!0;this.keyboard=new a.Keyboard(this);this.scaleToFit=()=>{};this.init()}init(){this.stop();this.evaluator=new a.Evaluator(this);this.evaluator.setVariable("DJS.w",this.width);this.evaluator.setVariable("DJS.h",this.height);this.getURLParameters();
this.lessonParser=new a.LessonParser(this);for(let {name:b,value:e}of this.children)if(babel[b]=="Buttons")this.buttonsConfig=this.lessonParser.parseButtonsConfig(e);else if(b=="image_loader")this.imgLoader=e;else if(b=="expand")this.expand=e;else if(b=="docBase")document.head.appendChild(a.newHTML("base",{id:"descartesJS_base",href:e}));else if(b.startsWith("E_"))break;this.externalSpace&&this.externalSpace.container.parentNode&&this.externalSpace.container.remove();this.externalSpace=new a.SpaceExternal(this);
this.northSpace={container:a.newHTML("div"),controls:[]};this.southSpace={container:a.newHTML("div"),controls:[]};this.eastSpace={container:a.newHTML("div"),controls:[]};this.westSpace={container:a.newHTML("div"),controls:[]};this.editableRegion={container:a.newHTML("div"),textFields:[]};this.spaces=[];this.controls=[];this.auxiliaries=[];this.events=[];this.zIndex=this.tabindex=this.plecaHeight=this.nIframes=0;this.container!=void 0&&(this.cleanCanvasImages(),this.container.remove(),delete this.container,
delete this.loader);this.container=a.newHTML("div");this.container.addEventListener("contextmenu",a.preventDefault);this.loader=a.newHTML("div",{class:"DescartesLoader"});this.container.appendChild(this.loader);this.parentC.insertBefore(this.container,this.parentC.firstChild);this.container.width=this.loader.width=this.width;this.container.height=this.loader.height=this.height;this.container.className="DescartesAppContainer";this.container.setAttribute("style",`width:${this.width}px;height:${this.height}px;`);
if(this.expand=="fit"){var d=a.newHTML("style",{rel:"stylesheet",type:"text/css",id:"StyleDescartesAppsPrint"});document.head.insertBefore(d,document.head.firstChild);d.innerHTML=`@page{margin:0;size:${this.width}px ${this.height}px;}`;(d=document.querySelector("meta[name=viewport"))&&window.parent==window&&d.setAttribute("content","width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover");document.body.style.margin=document.body.style.padding=0;document.body.style.width=
"100vw";document.body.style.height="100dvh";document.body.style.overflow="hidden";this.container.parentNode.removeAttribute("align");this.container.parentNode.style.overflow="hidden";this.container.style.left=this.container.style.top="50%";this.container.style.transformOrigin="50% 50%";this.scaleToFit=k;this.scaleToFit()}this.expand=="cover"&&(this.scaleToFit=function(){this.container.width=this.width=window.innerWidth;this.container.height=this.height=window.innerHeight;this.container.setAttribute("style",
`width:${this.width}px;height:${this.height}px;`);try{this.update()}catch(b){}if(this.spaces)for(let b of this.spaces)b.initSpace(),b.init(),b.update(!0)},this.scaleToFit());this.firstRun?(this.loader.style.display="block",new a.DescartesLoader(this),this.firstRun=!1):this.initBuildApp()}initBuildApp(){a.showConfig=!0;let d=/type='fill'|tipo='relleno'|tipus='ple'|mota='betea'|type='plein'|tipo='recheo'|tipo='curva_piena'|tipo='preencher'|tipus='ple'/,b=this.lessonParser,e=[],l=[],w=[],q=[],n=[],p=
[];for(let {name:r,value:t}of this.children)babel[r]=="editable"?a.showConfig=babel[t]!="false":babel[r]=="language"?this.language=t:babel[r]=="Buttons"?this.buttonsConfig=b.parseButtonsConfig(t):babel[r]=="decimal_symbol"?(this.decimal_symbol=t,this.decimal_symbol_regexp=new RegExp("\\"+this.decimal_symbol,"g")):babel[r]=="version"?this.version=parseInt(t):r.startsWith("E_")?(t.includes("='HTMLIFrame'")&&this.nIframes++,e.push(t)):r.startsWith("C_")?l.push(t):r.startsWith("A_")?w.push(t):r.startsWith("G_")?
(d.test(t)&&(this.ratio=1),q.push(t)):r.startsWith("S_")?n.push(t):babel[r]=="Animation"&&p.push(t);for(let r of e)this.spaces.push(b.parseSpace(r)),this.zIndex++;q.forEach((r,t)=>{a.DEBUG.elemIndex=t;if(r=b.parseGraphic(r))this.editableRegionVisible=this.editableRegionVisible||r.visible,r.space.addGraph(r)});n.forEach((r,t)=>{a.DEBUG.elemIndex=t;(r=b.parse3DGraphic(r))&&r.space.addGraph(r,!0)});for(let r of l)this.controls.push(b.parseControl(r));for(let r of w)b.parseAuxiliar(r);for(let r of p)this.animation=
b.parseAnimation(r);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();for(let r of this.controls)r.init();this.updateControls();this.updateSpaces(!0);a.setTimeout(()=>{this.finishInit()},10*this.nIframes);document.addEventListener("keydown",r=>{(r.ctrlKey||r.commandKey)&&r.shiftKey&&r.key=="C"&&(navigator.clipboard.writeText(this.applet.outerHTML),a.preventDefault(r))})}finishInit(){this.evaluator.setVariable("decimalSymbol",this.decimal_symbol);this.update();this.loader.remove();
window.parent!==window&&(this.parentC.style.margin=this.parentC.style.padding="0",this.expand=="fit"&&window.addEventListener("touchmove",d=>{a.preventDefault(d)}),window.parent.postMessage({type:"reportSize",href:this.URL,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready",value:this.URL},"*"),a.onResize());window.opener&&window.opener.postMessage({type:"isResizeNeeded",href:this.URL},"*");a.showConfig&&this.externalSpace.init();window.dispatchEvent(new CustomEvent("descartesReady",
{detail:this}));this.evaluator.setFunction("openKB",(d,b,e,l,w,q,n,p,r,t,c)=>{this.keyboard.show(null,d,b,e,l,{x:w,y:q,w:n,h:p,fs:r+"px",value:t+"",type:"custom",tagName:"textfield"},c)});this.readyApp=!0}adjustSize(){document.body.style.margin=document.body.style.padding=this.parentC.style.margin=this.parentC.style.padding="0";let d=parseInt(this.width+30),b=parseInt(this.height+90);window.moveTo(parseInt(screen.width-d)/2,parseInt(screen.height-b)/2);window.resizeTo(d,b);a.onResize()}configRegions(){var d=
this.buttonsConfig||{};let b=this.container;var e=this.evaluator.parser;let l=this._configHorizontalRegion(d,b,e,"north",this.northSpace,d.rowsNorth,[{show:d.about,width:100,name:this.language=="english"?"about":"cr\u00e9ditos",action:{execute:a.showAbout},position:"left"},{show:d.config,width:100,name:"config",action:"config",position:"right"}]),w=this._configHorizontalRegion(d,b,e,"south",this.southSpace,d.rowsSouth,[{show:d.init,width:100,name:this.language=="english"?"init":"inicio",action:"init",
position:"left"},{show:d.clear,width:100,name:this.language=="english"?"clear":"limpiar",action:"clear",position:"right"}]),q=this._configVerticalRegion(d,b,e,"west",this.westSpace,d.widthWest,l,w);e=this._configVerticalRegion(d,b,e,"east",this.eastSpace,d.widthEast,l,w);d=this.editableRegionVisible?this._configEditableRegion(d,b,w):0;this.displaceRegionNorth=l;this.displaceRegionSouth=w+d;this.displaceRegionWest=q;this.displaceRegionEast=e;for(let n of this.spaces)n.init()}_configHorizontalRegion(d,
b,e,l,w,q,n){var p=w.controls;n=n.filter(f=>f.show);if(q<=0&&p.length==0&&n.length==0)return 0;var r=q>0?q:1;q=d.height*r;w=w.container;w.id=`descartesJS_${l}`;w.setAttribute("style",`width:${b.width}px;height:${q}px;left:0;${l=="north"?`top:${this.plecaHeight}px;`:"bottom:0;"}`);b.insertBefore(w,this.loader);let t=b.width;w=0;for(var c of n)t-=c.width,c.position=="left"&&(w+=c.width);if(p.length>0){c=Math.ceil(p.length/r);r=t/c;for(let f=0,m=p.length;f<m;f++)p[f].expresion=e.parse(`(${w+f%c*r},${d.height*
Math.floor(f/c)},${r},${d.height})`),p[f].init()}d=0;for(let f of n)f.position=="left"?p=w-f.width:(p=b.width-d-f.width,d+=f.width),p={region:l,name:f.name,font_size:e.parse("15"),expresion:e.parse(`(${p},0,${f.width},${q})`)},typeof f.action=="string"&&(p.action=f.action),p=new a.Button(this,p),typeof f.action=="object"&&(p.actionExec=f.action),p.update();return q}_configVerticalRegion(d,b,e,l,w,q,n,p){let r=w.controls;if(r.length==0||!q)return 0;p=b.height-n-p;w=w.container;w.id=`descartesJS_${l}`;
w.setAttribute("style",`width:${q}px;height:${p}px;${l=="west"?"left":"right"}:0;top:${n}px;`);b.insertBefore(w,this.loader);for(let t=0,c=r.length;t<c;t++)r[t].expresion=e.parse(`(0,${d.height*t},${q},${d.height})`),r[t].init();return q}_configEditableRegion(d,b,e){d=d.height;let l=this.editableRegion.container;l.id="descartesJS_editableRegion";l.setAttribute("style",`position:absolute;width:${b.width}px;height:${d}px;left:0;top:${b.height-e-d}px;`);b.insertBefore(l,this.loader);e=this.editableRegion.textFields;
b=b.width/e.length;let w=a.getFieldFontSize(d);for(let q=0,n=e.length;q<n;q++){let p=e[q];if(p.type=="div"){l.appendChild(p.container);p.container.setAttribute("style",`font-family:${a.sansserif_font};width:${b-4}px;height:${d}px;position:absolute;left:${q*b}px;top:0;`);let r=p.container.firstChild;r.firstChild.textContent=r.firstChild.textContent.slice(3,-3);r.setAttribute("style",`font-family:${a.sansserif_font};font-size:${w}px;padding-top:0;background-color:#e0e4e8;position:absolute;left:0;top:0;height:${d}px;text-align:center;line-height:${d}px;`);
let t=r.offsetWidth;r.style.width=`${t}px`;p.container.lastChild.setAttribute("style",`font-family:${a.monospace_font};font-size:${w}px;width:${b-t}px;height:${d}px;position:absolute;left:${t}px;top:0;border:2px groove white;`)}else l.appendChild(p),p.setAttribute("style",`font-family:${a.monospace_font};font-size:${w}px;width:${b}px;height:${d}px;position:absolute;left:${q*b}px;top:0;border:2px groove white;`)}return d}update(){this.updateAuxiliaries();this.updateControls();this.updateEvents();this.updateControls();
this.updateSpaces()}clearClick(){for(let d of this.spaces)d.clearClick()}removeButtonClick(){a.newBlobContent=null;for(let d of this.controls)d.buttonClick=d.isPointerDown=!1}deactivateControls(){for(let d of this.controls)d.deactivate&&d.deactivate()}updateAuxiliaries(){for(let d of this.auxiliaries)d.update()}updateEvents(){for(let d of this.events)d.update()}updateControls(){for(let d of this.controls)d.update()}updateSpaces(d){for(let b of this.spaces)b.update(d)}clear(){for(let d of this.spaces)d.spaceChange=
!0,d.drawBackground&&d.drawBackground()}play(){this.animation.play()}stop(){this.animation.stop()}reinitAnimation(){this.animation.reinit()}stopAudios(){this.stop();for(let d of Object.values(this.audios))d&&typeof d.pause=="function"&&(d.pause(),d.currentTime=0)}getImage(d){return d?(this.images[d]||(this.images[d]=this.getImageAux(d)),this.images[d]):new Image}getImageAux(d){const b=new Image;d.startsWith("http")&&(b.crossOrigin="Anonymous");b.onload=function(){this.ready=1};b.onerror=function(){this.errorload=
1};b.src=d;return b}getAudio(d){return d?(this.audios[d]||(this.audios[d]=this.getAudioAux(d)),this.audios[d]):new Audio}getAudioAux(d){let b=new Audio(d);b.filename=d;let e=function(){this.ready=1},l=function(){this.canPlayType("audio/"+this.filename.slice(-3))||this.filename.slice(-3)!="mp3"?(console.warn(`El archivo ${d} no puede ser reproducido`),this.errorload=1):(b=new Audio(this.filename.replace("mp3","ogg")),b.filename=this.filename.replace("mp3","ogg"),b.addEventListener("canplaythrough",
e),b.addEventListener("load",e),b.addEventListener("error",l),b.load())};b.addEventListener("canplaythrough",e);b.addEventListener("load",e);b.addEventListener("error",l);a.hasTouchSupport?(b.load(),b.play(),a.setTimeout(()=>{b.pause()},20),b.ready=1):b.load();return b}getControlByCId(d){return this.getControlById(d,!0)}getControlById(d,b){b=b?"cID":"id";for(let e of this.controls)if(e[b]==d)return e;return{update:()=>{},w:0,h:0}}getSpaceByCId(d){return this.getSpaceById(d,!0)}getSpaceById(d,b){b=
b?"cID":"id";for(let e of this.spaces)if(e[b]==d)return e;return{update:()=>{},w:0,h:0}}getURLParameters(){for(const [d,b]of(new URLSearchParams(window.location.search)).entries())this.evaluator.setVariable(`URL.${d}`,+b==+b?parseFloat(b):b)}cleanCanvasImages(){for(let d of this.container.querySelectorAll("canvas"))d.width=d.height=1,d.style.width=d.style.height="1px";for(let d of this.spaces)d.canvas=d.ctx=d.backCanvas=d.backCtx=null;for(let [d,b]of Object.entries(this.images))b.nodeName&&b.nodeName.toLowerCase()==
"canvas"&&delete this.images[d]}}a.DescartesApp=g})(descartesJS);
(a=>{a.DEBUG={PARENTHESIS_CLOSING:"Faltan par\u00e9ntesis por cerrar",PARENTHESIS_OPENING:"Faltan par\u00e9ntesis por abrir",BRACKET_CLOSING:"Faltan corchetes por cerrar",BRACKET_OPENING:"Faltan corchetes por abrir",INCOMPLETE_IF:"Condicional incompleta",EXPRESSION:"En la expresi\u00f3n",setError:function(k,g){k=`Error: ${k} en\u300a ${g} \u300b`;let d=/doExpr|init/.test(babel[this.pName])?" en la l\u00ednea "+(this.lineCount+1):"";switch(this.objectName){case "Graphic":k+=`En el gr\u00e1fico #${this.elemIndex+
1} de tipo \u300c${this.idName}\u300d, en el par\u00e1metro \u300c${this.pName}\u300d.`;break;case "Auxiliar":g=/event|algorithm|constant/.test(this.typeName)?"En el programa ":"En la definici\u00f3n ";k+=`${g}\u300c${this.idName}\u300d, en el par\u00e1metro \u300c${this.pName}\u300d${d}.`;break;case "Animation":k+=`. En la Animaci\u00f3n, en el par\u00e1metro \u300c${this.pName}\u300d${d}.`}console.info(k)}}})(descartesJS);
(a=>{async function k(){for(let b of"descartesJS_serif descartesJS_sansserif descartesJS_monospace descartesJS_math DJS_serif DJS_sansserif DJS_monospace".split(" "))document.fonts.load(`9px ${b}`),document.fonts.load(`bold 9px ${b}`),document.fonts.load(`italic 9px ${b}`),document.fonts.load(`bold italic 9px ${b}`);await document.fonts.ready;a.getFeatures();if(a.hasCanvas){for(let b of document.querySelectorAll(".DescartesAppContainer"))b.remove();for(let b of document.querySelectorAll("applet,ajs"))/descartes/i.test(b.getAttribute("code"))&&
(a.apps.push(new a.DescartesApp(b)),b.className="DescartesJS");window.addEventListener("resize",a.onResize)}else d.remove()}var g={};a.apps=[];let d=document.getElementById("StyleDescartesApps");d&&d.remove();d=a.newHTML("style",{id:"StyleDescartesApps",type:"text/css",rel:"stylesheet"});d.innerHTML="applet.DescartesJS,applet,ajs.DescartesJS,ajs{display:none;}";document.head.appendChild(d);a.onResize=function(){a.apps.length>0&&a.apps[0].scaleToFit()};a.onMessage=function(b){if(a.apps.length>0){let l=
b.data;if(l){var e=a.apps[0].evaluator;switch(l.type){case "set":typeof l.value=="string"||typeof l.value=="number"?e.setVariable(l.name,l.value):l.value&&l.value.rows!=void 0?e.matrices[l.name]=l.value:e.vectors[l.name]=l.value;break;case "update":a.apps[0].update();break;case "exec":(b=e.getFunction(l.name))&&b.apply(e,(""+l.value).split(","));break;case "isResizeNeeded":b.source.postMessage({type:"doResize"},"*");break;case "doResize":a.apps[0].adjustSize();break;case "change_config":g[l.filename]?
e=g[l.filename]:(e=(new DOMParser).parseFromString(l.content,"text/html").getElementsByTagName("param"),g[l.filename]=e);a.apps[0].children=e;a.apps[0].init();break;case "change_content":a.apps[0].children=(new DOMParser).parseFromString(l.content,"text/html").getElementsByTagName("param"),a.apps[0].init()}}}};if(a.loadLib==void 0){a.loadLib=!0;window.addEventListener("load",k);window.addEventListener("message",a.onMessage);for(let b of["webkitTransitionEnd","transitionend","oTransitionEnd","MSTransitionEnd"])window.addEventListener(b,
a.onResize)}})(descartesJS);
