From 243ba5f585716dd45073a42821de5212db2ae737 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 7 Mar 2024 00:11:43 +0000 Subject: [PATCH] chore: build and documentation for release --- dist/maidr.js | 88 +++++++++++++++-- dist/maidr.min.js | 2 +- dist/maidr_style.css | 31 +++++- dist/maidr_style.min.css | 2 +- docs/Audio.html | 4 +- docs/BarChart.html | 4 +- docs/BoxPlot.html | 4 +- docs/BoxplotRect.html | 4 +- docs/ChatLLM.html | 22 ++--- docs/Constants.html | 4 +- docs/Constants_ConvertHexToRGBString.html | 4 +- docs/Constants_ConvertRGBStringToHex.html | 4 +- docs/Constants_GetStyleArrayFromString.html | 4 +- docs/Constants_GetStyleStringFromArray.html | 4 +- docs/Control.html | 4 +- docs/Description.html | 14 +-- docs/Display.html | 4 +- docs/HeatMap.html | 4 +- docs/HeatMapRect.html | 4 +- docs/Helper.html | 8 +- docs/Histogram.html | 4 +- docs/Layer0Point.html | 4 +- docs/Layer1Point.html | 4 +- docs/LinePlot.html | 4 +- docs/LogError.html | 16 ++-- docs/Menu.html | 101 ++++++++++++++++++-- docs/Point.html | 4 +- docs/Position.html | 6 +- docs/Resources.html | 6 +- docs/Review.html | 8 +- docs/ScatterPlot.html | 4 +- docs/Segmented.html | 4 +- docs/Tracker.html | 20 ++-- docs/audio.js.html | 4 +- docs/barplot.js.html | 4 +- docs/boxplot.js.html | 4 +- docs/constants.js.html | 92 ++++++++++++++++-- docs/controls.js.html | 4 +- docs/display.js.html | 4 +- docs/global.html | 4 +- docs/heatmap.js.html | 4 +- docs/histogram.js.html | 4 +- docs/index.html | 4 +- docs/init.js.html | 4 +- docs/lineplot.js.html | 4 +- docs/scatterplot.js.html | 4 +- docs/segmented.js.html | 4 +- 47 files changed, 403 insertions(+), 145 deletions(-) diff --git a/dist/maidr.js b/dist/maidr.js index bb10e960..0e33917f 100644 --- a/dist/maidr.js +++ b/dist/maidr.js @@ -273,6 +273,7 @@ class Resources { openai: 'OpenAI Vision', gemini: 'Gemini Pro Vision', multi: 'Multiple AI', + processing: 'Processing Chart...', }, }, }; @@ -443,7 +444,7 @@ class Menu { @@ -579,6 +580,16 @@ class Menu { } }, ]); + + // trigger notification that LLM will be reset + // this is done on change of LLM model, multi settings, or skill level + constants.events.push([ + document.getElementById('LLM_model'), + 'change', + function (e) { + menu.NotifyOfLLMReset(); + }, + ]); } /** @@ -720,6 +731,9 @@ class Menu { document.getElementById('LLM_preferences').value = constants.LLMPreferences; } + if (document.getElementById('LLM_reset_notification')) { + document.getElementById('LLM_reset_notification').remove(); + } } /** @@ -777,6 +791,24 @@ class Menu { .setAttribute('aria-live', constants.ariaMode); } + /** + * Notifies the user that the LLM will be reset. + */ + NotifyOfLLMReset() { + let html = + '

Note: Changes in LLM settings will reset any existing conversation.

'; + document + .getElementById('save_and_close_menu') + .insertAdjacentHTML('beforebegin', html); + + // add to aria button text + document + .getElementById('save_and_close_menu') + .setAttribute( + 'aria-labelledby', + 'save_and_close_text LLM_reset_notification' + ); + } /** * Handles changes to the LLM model and multi-modal settings. * We reset if we change the LLM model, multi settings, or skill level. @@ -895,8 +927,11 @@ class ChatLLM { \n \n `;document.querySelector("body").insertAdjacentHTML("beforeend",t)}SetEvents(){let t=document.querySelectorAll("#close_chatLLM, #chatLLM .close");for(let e=0;e p > button").focus(),document.getElementById("more_suggestions").remove()}]);let e=document.querySelectorAll("#chatLLM .LLM_suggestions button:not(#more_suggestions)");for(let t=0;t2?{id:"chatcmpl-8Y44iRCRrohYbAqm8rfBbJqTUADC7",object:"chat.completion",created:1703129508,model:"gpt-4-1106-vision-preview",usage:{prompt_tokens:451,completion_tokens:16,total_tokens:467},choices:[{message:{role:"assistant",content:"A fake response from the LLM. Nice."},finish_reason:"length",index:0}]}:{id:"chatcmpl-8Y44iRCRrohYbAqm8rfBbJqTUADC7",object:"chat.completion",created:1703129508,model:"gpt-4-1106-vision-preview",usage:{prompt_tokens:451,completion_tokens:16,total_tokens:467},choices:[{message:{role:"assistant",content:"The chart you're referring to is a bar graph titled \"The Number of Diamonds"},finish_reason:"length",index:0}]},t}OpenAIPrompt(t,e=null){let n=constants.openAIAuthKey,s=chatLLM.OpenAIJson(t,e);console.log("LLM request: ",s),fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+n},body:JSON.stringify(s)}).then((t=>t.json())).then((t=>{chatLLM.ProcessLLMResponse(t,"openai")})).catch((t=>{chatLLM.WaitingSound(!1),console.error("Error:",t),chatLLM.DisplayChatMessage(LLMName,"Error processing request.",!0)}))}OpenAIJson(t,e=null){let n=constants.LLMSystemMessage;singleMaidr.type;this.requestJson||(this.requestJson={},this.requestJson.model="gpt-4-vision-preview",this.requestJson.max_tokens=constants.LLMmaxResponseTokens,this.requestJson.messages=[],this.requestJson.messages[0]={},this.requestJson.messages[0].role="system",this.requestJson.messages[0].content=n,constants.LLMPreferences&&(this.requestJson.messages[1]={},this.requestJson.messages[1].role="system",this.requestJson.messages[1].content=constants.LLMPreferences));let s=this.requestJson.messages.length;return this.requestJson.messages[s]={},this.requestJson.messages[s].role="user",this.requestJson.messages[s].content=e?[{type:"text",text:t},{type:"image_url",image_url:{url:e}}]:t,this.requestJson}async GeminiPrompt(t,e=null){try{null==e?e=constants.LLMImage:constants.LLMImage=e,constants.LLMImage=e;const{GoogleGenerativeAI:n}=await import("https://esm.run/@google/generative-ai"),s=constants.geminiAuthKey,o=new n(s).getGenerativeModel({model:"gemini-pro-vision"});let i=constants.LLMSystemMessage;constants.LLMPreferences&&(i+=constants.LLMPreferences),i+="\n\n"+t;const a={inlineData:{data:e,mimeType:"image/png"}};console.log("LLM request: ",i,a);const l=await o.generateContent([i,a]);console.log(l.response.text()),chatLLM.ProcessLLMResponse(l.response,"gemini")}catch(t){throw console.error("Error in GeminiPrompt:",t),t}}DisplayChatMessage(t="User",e="",n=!1){let s="h3";if(!n&&"multi"==constants.LLMModel&&"User"!=t){if(this.firstMulti){let t=`\n
\n

${resources.GetString("multi")} Responses

\n
\n `;this.RenderChatMessage(t),this.firstMulti=!1}s="h4"}let o=`\n
\n <${s} class="chatLLM_message_user">${t}\n

${e}

\n
\n `;this.RenderChatMessage(o)}RenderChatMessage(t){document.getElementById("chatLLM_chat_history").insertAdjacentHTML("beforeend",t),document.getElementById("chatLLM_input").value="",document.getElementById("chatLLM_chat_history").scrollTop=document.getElementById("chatLLM_chat_history").scrollHeight}ResetChatHistory(){document.getElementById("chatLLM_chat_history").innerHTML="",document.getElementById("more_suggestions_container").classList.add("hidden"),document.getElementById("more_suggestions").classList.remove("hidden"),this.requestJson=null,this.firstTime=!0}Destroy(){let t=document.getElementById("chatLLM");t&&t.remove();let e=document.getElementById("chatLLM_modal_backdrop");e&&e.remove()}Toggle(t){if(void 0===t&&(t=!!document.getElementById("chatLLM").classList.contains("hidden")),t){if(this.whereWasMyFocus=document.activeElement,constants.tabMovement=0,document.getElementById("chatLLM").classList.remove("hidden"),document.getElementById("chatLLM_modal_backdrop").classList.remove("hidden"),document.querySelector("#chatLLM .close").focus(),this.firstTime){let t=resources.GetString(constants.LLMModel);this.firstTime=!1,this.DisplayChatMessage(t,"Processing Chart...",!0);let e=this.GetDefaultPrompt();this.Submit(e,!0)}}else document.getElementById("chatLLM").classList.add("hidden"),document.getElementById("chatLLM_modal_backdrop").classList.add("hidden"),this.whereWasMyFocus.focus(),this.whereWasMyFocus=null}async ConvertSVGtoJPG(t,e){let n=document.getElementById(t);return new Promise(((t,s)=>{var o=document.createElement("canvas"),i=o.getContext("2d"),a=(new XMLSerializer).serializeToString(n);a.startsWith("\n \n \n\n ');let t=document.querySelectorAll("#close_desc, #description .close");for(let e=0;eType: ${e}

`),null!=plot.title&&(t+=`

Title: ${plot.title}

`),null!=plot.subtitle&&(t+=`

Subtitle: ${plot.subtitle}

`),null!=plot.caption&&(t+=`

Caption: ${plot.caption}

`);let n="",s=null,o=null,i=null,a=null,l=0,r=0,c=0,p=0;if("bar"==constants.chartType&&(null!=plot.plotLegend.x&&(s=plot.plotLegend.x,r+=1),null!=plot.plotLegend.y&&(o=plot.plotLegend.y,p+=1),null!=plot.columnLabels&&(i=plot.columnLabels,p+=1),null!=plot.plotData&&(a=[],a[0]=plot.plotData,l=plot.plotData.length,c=1,r+=l,p+=c)),null!=a){if(n+="",null!=s||null!=i){if(n+="",null!=s&&(n+="",null!=o&&(n+=""),n+=``,n+=""),null!=i){n+="",null!=o&&(n+="");for(let t=0;t${i[t]}`;n+=""}n+=""}if(c>0){n+="";for(let t=0;t",null!=o&&0==t&&(n+=``);for(let e=0;e${a[t][e]}`;n+=""}n+=""}n+="
${s}
${o}
"}document.getElementById("desc_title").innerHTML=e+" description",document.getElementById("desc_content").innerHTML=t,document.getElementById("desc_table").innerHTML=n}}class Position{constructor(t=0,e=0,n=-1){this.x=t,this.y=e,this.z=n}}class Helper{static containsObject(t,e){for(let n=0;n0&&console.log("tracking data cleared"),this.DataSetup()}LogEvent(t){let e={};if(e.timestamp=Object.assign(t.timeStamp),e.time=Date().toString(),e.key=Object.assign(t.key),e.altKey=Object.assign(t.altKey),e.ctrlKey=Object.assign(t.ctrlKey),e.shiftKey=Object.assign(t.shiftKey),t.path&&(e.focus=Object.assign(t.path[0].tagName)),this.isUndefinedOrNull(constants.position)||(e.position=Object.assign(constants.position)),this.isUndefinedOrNull(constants.minX)||(e.min_x=Object.assign(constants.minX)),this.isUndefinedOrNull(constants.maxX)||(e.max_x=Object.assign(constants.maxX)),this.isUndefinedOrNull(constants.minY)||(e.min_y=Object.assign(constants.minY)),this.isUndefinedOrNull(constants.MAX_FREQUENCY)||(e.max_frequency=Object.assign(constants.MAX_FREQUENCY)),this.isUndefinedOrNull(constants.MIN_FREQUENCY)||(e.min_frequency=Object.assign(constants.MIN_FREQUENCY)),this.isUndefinedOrNull(constants.NULL_FREQUENCY)||(e.null_frequency=Object.assign(constants.NULL_FREQUENCY)),this.isUndefinedOrNull(constants.MAX_SPEED)||(e.max_speed=Object.assign(constants.MAX_SPEED)),this.isUndefinedOrNull(constants.MIN_SPEED)||(e.min_speed=Object.assign(constants.MIN_SPEED)),this.isUndefinedOrNull(constants.INTERVAL)||(e.interval=Object.assign(constants.INTERVAL)),this.isUndefinedOrNull(constants.vol)||(e.volume=Object.assign(constants.vol)),this.isUndefinedOrNull(constants.autoPlayRate)||(e.autoplay_rate=Object.assign(constants.autoPlayRate)),this.isUndefinedOrNull(constants.colorSelected)||(e.color=Object.assign(constants.colorSelected)),this.isUndefinedOrNull(constants.brailleDisplayLength)||(e.braille_display_length=Object.assign(constants.brailleDisplayLength)),this.isUndefinedOrNull(constants.duration)||(e.tone_duration=Object.assign(constants.duration)),this.isUndefinedOrNull(constants.autoPlayOutlierRate)||(e.autoplay_outlier_rate=Object.assign(constants.autoPlayOutlierRate)),this.isUndefinedOrNull(constants.autoPlayPointsRate)||(e.autoplay_points_rate=Object.assign(constants.autoPlayPointsRate)),this.isUndefinedOrNull(constants.textMode)||(e.text_mode=Object.assign(constants.textMode)),this.isUndefinedOrNull(constants.sonifMode)||(e.sonification_mode=Object.assign(constants.sonifMode)),this.isUndefinedOrNull(constants.brailleMode)||(e.braille_mode=Object.assign(constants.brailleMode)),this.isUndefinedOrNull(constants.chartType)||(e.chart_type=Object.assign(constants.chartType)),!this.isUndefinedOrNull(constants.infoDiv.innerHTML)){let t=Object.assign(constants.infoDiv.innerHTML);t=t.replaceAll(/<[^>]*>?/gm,""),e.text_display=t}this.isUndefinedOrNull(location.href)||(e.location=Object.assign(location.href));let n="",s="",o="",i="",a="",l="";if("bar"==constants.chartType)this.isUndefinedOrNull(plot.columnLabels[position.x])||(n=plot.columnLabels[position.x]),this.isUndefinedOrNull(plot.plotLegend.x)||(o=plot.plotLegend.x),this.isUndefinedOrNull(plot.plotLegend.y)||(i=plot.plotLegend.y),this.isUndefinedOrNull(plot.plotData[position.x])||(a=plot.plotData[position.x]);else if("heat"==constants.chartType)this.isUndefinedOrNull(plot.x_labels[position.x])||(n=plot.x_labels[position.x].trim()),this.isUndefinedOrNull(plot.y_labels[position.y])||(s=plot.y_labels[position.y].trim()),this.isUndefinedOrNull(plot.x_group_label)||(o=plot.x_group_label),this.isUndefinedOrNull(plot.y_group_label)||(i=plot.y_group_label),this.isUndefinedOrNull(plot.values)||this.isUndefinedOrNull(plot.values[position.x][position.y])||(a=plot.values[position.x][position.y]),this.isUndefinedOrNull(plot.group_labels[2])||(l=plot.group_labels[2]);else if("box"==constants.chartType){let t="vert"==constants.plotOrientation?position.x:position.y,e="vert"==constants.plotOrientation?position.y:position.x;this.isUndefinedOrNull(plot.x_group_label)||(o=plot.x_group_label),this.isUndefinedOrNull(plot.y_group_label)||(i=plot.y_group_label),"vert"==constants.plotOrientation?t>-1&&e>-1&&(this.isUndefinedOrNull(plot.plotData[t][e].label)||(s=plot.plotData[t][e].label),this.isUndefinedOrNull(plot.x_labels[position.x])||(n=plot.x_labels[position.x]),this.isUndefinedOrNull(plot.plotData[t][e].values)?this.isUndefinedOrNull(plot.plotData[t][e].y)||(a=plot.plotData[t][e].y):a=plot.plotData[t][e].values):t>-1&&e>-1&&(this.isUndefinedOrNull(plot.plotData[t][e].label)||(n=plot.plotData[t][e].label),this.isUndefinedOrNull(plot.y_labels[position.y])||(s=plot.y_labels[position.y]),this.isUndefinedOrNull(plot.plotData[t][e].values)?this.isUndefinedOrNull(plot.plotData[t][e].x)||(a=plot.plotData[t][e].x):a=plot.plotData[t][e].values)}else"point"==constants.chartType&&(this.isUndefinedOrNull(plot.x_group_label)||(o=plot.x_group_label),this.isUndefinedOrNull(plot.y_group_label)||(i=plot.y_group_label),this.isUndefinedOrNull(plot.x[position.x])||(n=plot.x[position.x]),this.isUndefinedOrNull(plot.y[position.x])||(s=plot.y[position.x]),a=[n,s]);e.x_tickmark=Object.assign(n),e.y_tickmark=Object.assign(s),e.x_label=Object.assign(o),e.y_label=Object.assign(i),e.value=Object.assign(a),e.fill_value=Object.assign(l);let r=this.GetTrackerData();r.events.push(e),this.SaveTrackerData(r)}isUndefinedOrNull(t){try{return null==t}catch{return!0}}}class Review{constructor(){}ToggleReviewMode(t=!0){t?(constants.reviewSaveSpot=document.activeElement,constants.review_container.classList.remove("hidden"),constants.reviewSaveBrailleMode=constants.brailleMode,constants.review.focus(),display.announceText("Review on")):(constants.review_container.classList.add("hidden"),"on"==constants.reviewSaveBrailleMode?display.toggleBrailleMode("on"):constants.reviewSaveSpot.focus(),display.announceText("Review off"))}}class LogError{constructor(){}LogAbsentElement(t){console.log(t,"not found. Visual highlighting is turned off.")}LogCriticalElement(t){consolelog(t,"is critical. MAIDR unable to run")}LogDifferentLengths(t,e){console.log(t,"and",e,"do not have the same length. Visual highlighting is turned off.")}LogTooManyElements(t,e){console.log("Too many",t,"elements. Only the first",e,"will be highlighted.")}LogNotArray(t){console.log(t,"is not an array. Visual highlighting is turned off.")}}class Audio{constructor(){this.AudioContext=window.AudioContext||window.webkitAudioContext,this.audioContext=new AudioContext,this.compressor=this.compressorSetup(this.audioContext)}compressorSetup(){let t=this.audioContext.createDynamicsCompressor();t.threshold.value=-50,t.knee.value=40,t.ratio.value=12,t.attack.value=0,t.release.value=.25;let e=this.audioContext.createGain();return e.gain.value=constants.vol,t.connect(e),e.connect(this.audioContext.destination),t}playTone(t=null){let e=constants.duration,n=constants.vol;null!=t&&null!=t.volScale&&(n=t.volScale*constants.vol);let s=0,o=0,i=0,a=0,l="sine";if("bar"==constants.chartType)o=plot.plotData[position.x],s=position.x,i=this.SlideBetween(o,constants.minY,constants.maxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(s,constants.minX,constants.maxX,-1,1);else if("box"==constants.chartType){let t="vert"==constants.plotOrientation?position.x:position.y,e=plot.GetSectionKey("vert"==constants.plotOrientation?position.y:position.x);o=Array.isArray(plot.plotData[t][e])?plot.plotData[t][e][position.z]:plot.plotData[t][e],null!=plot.plotData[t][e]?"vert"==constants.plotOrientation?(i=this.SlideBetween(o,constants.minY,constants.maxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(o,constants.minY,constants.maxY,-1,1)):(i=this.SlideBetween(o,constants.minX,constants.maxX,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(o,constants.minX,constants.maxX,-1,1)):(i=constants.MIN_FREQUENCY,a=0)}else if("heat"==constants.chartType)o=plot.data[position.y][position.x],s=position.x,i=this.SlideBetween(o,constants.minY,constants.maxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(s,constants.minX,constants.maxX,-1,1);else if("point"==constants.chartType||"smooth"==constants.chartType){constants.globalMinMax=!0;let t=constants.minY,e=constants.maxY;"smooth"==constants.chartType&&(t=plot.curveMinY,e=plot.curveMaxY),constants.globalMinMax&&(t=Math.min(constants.minY,plot.curveMinY),e=Math.max(constants.maxY,plot.curveMaxY)),"point"==constants.chartType?(o=plot.y[position.x][position.z],n=1==plot.max_count?constants.vol:this.SlideBetween(plot.points_count[position.x][position.z],1,plot.max_count,constants.vol,constants.MAX_VOL),s=position.x,i=this.SlideBetween(o,t,e,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(s,t,e,-1,1)):"smooth"==constants.chartType&&(o=plot.curvePoints[positionL1.x],s=positionL1.x,i=this.SlideBetween(o,t,e,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(s,t,e,-1,1))}else if("hist"==constants.chartType)o=plot.plotData[position.x].y,s=plot.plotData[position.x].x,i=this.SlideBetween(o,constants.minY,constants.maxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(s,constants.minX,constants.maxX,-1,1);else if("line"==constants.chartType)o=plot.pointValuesY[position.x],s=position.x,i=this.SlideBetween(o,constants.minY,constants.maxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(s,constants.minX,constants.maxX,-1,1);else if("stacked_bar"==constants.chartType||"stacked_normalized_bar"==constants.chartType||"dodged_bar"==constants.chartType){if(o=plot.plotData[position.x][position.y],0==o)return void this.PlayNull();Array.isArray(o)&&(o=o[position.z]),s=position.x,i=this.SlideBetween(o,constants.minY,constants.maxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY),a=this.SlideBetween(s,constants.minX,constants.maxX,-1,1),l=["triangle","square","sawtooth","sine"][position.y]}if(constants.debugLevel>5&&(console.log("will play tone at freq",i),"box"==constants.chartType?console.log("based on",constants.minY,"<",o,"<",constants.maxY," | freq min",constants.MIN_FREQUENCY,"max",constants.MAX_FREQUENCY):console.log("based on",constants.minX,"<",o,"<",constants.maxX," | freq min",constants.MIN_FREQUENCY,"max",constants.MAX_FREQUENCY)),"box"==constants.chartType){let t=plot.GetSectionKey("vert"==constants.plotOrientation?position.y:position.x);"lower_outlier"!=t&&"upper_outlier"!=t||(e=constants.outlierDuration)}if(this.playOscillator(i,e,a,n,l),"box"==constants.chartType){let t=plot.GetSectionKey("vert"==constants.plotOrientation?position.y:position.x);if("q1"==t||"q2"==t||"q3"==t){let t=i/2;this.playOscillator(t,e,a,constants.vol/4,"triangle")}}else"heat"==constants.chartType&&0==o&&this.PlayNull()}playOscillator(t,e,n,s=1,o="sine"){const i=this.audioContext.currentTime,a=this.audioContext.createOscillator();a.type=o,a.frequency.value=parseFloat(t),a.start();const l=this.audioContext.createGain();l.gain.setValueCurveAtTime([.5*s,1*s,.5*s,.5*s,.5*s,.1*s,1e-4*s],i,e);const r=new PannerNode(this.audioContext,{panningModel:"HRTF",distanceModel:"linear",positionX:position.x,positionY:position.y,positionZ:1,plotOrientationX:0,plotOrientationY:0,plotOrientationZ:-1,refDistance:1,maxDistance:1e4,rolloffFactor:10,coneInnerAngle:40,coneOuterAngle:50,coneOuterGain:.4}),c=this.audioContext.createStereoPanner();c.pan.value=n,a.connect(l),l.connect(c),c.connect(r),r.connect(this.compressor),setTimeout((()=>{r.disconnect(),l.disconnect(),a.stop(),a.disconnect()}),1e3*e*2)}playSmooth(t=[600,500,400,300],e=2,n=[-1,0,1],s=1,o="sine"){let i=new Array(3*t.length).fill(.5*s);i.push(1e-4*s);const a=this.audioContext.currentTime,l=this.audioContext.createOscillator();l.type=o,l.frequency.setValueCurveAtTime(t,a,e),l.start(),constants.isSmoothAutoplay=!0,this.smoothGain=this.audioContext.createGain(),this.smoothGain.gain.setValueCurveAtTime(i,a,e);const r=new PannerNode(this.audioContext,{panningModel:"HRTF",distanceModel:"linear",positionX:position.x,positionY:position.y,positionZ:1,plotOrientationX:0,plotOrientationY:0,plotOrientationZ:-1,refDistance:1,maxDistance:1e4,rolloffFactor:10,coneInnerAngle:40,coneOuterAngle:50,coneOuterGain:.4}),c=this.audioContext.createStereoPanner();c.pan.setValueCurveAtTime(n,a,e),l.connect(this.smoothGain),this.smoothGain.connect(c),c.connect(r),r.connect(this.compressor),constants.smoothId=setTimeout((()=>{r.disconnect(),this.smoothGain.disconnect(),l.stop(),l.disconnect(),constants.isSmoothAutoplay=!1}),1e3*e*2)}PlayNull(){let t=constants.NULL_FREQUENCY,e=constants.duration,n=constants.vol,s="triangle";this.playOscillator(t,e,0,n,s),setTimeout((function(o){o.playOscillator(23*t/24,e,0,n,s)}),Math.round(e/5*1e3),this)}playEnd(){if(constants.canPlayEndChime){let t=constants.endChime.cloneNode(!0);t.play(),t=null}}KillSmooth(){constants.smoothId&&(this.smoothGain.gain.cancelScheduledValues(0),this.smoothGain.gain.exponentialRampToValueAtTime(1e-4,this.audioContext.currentTime+.03),clearTimeout(constants.smoothId),constants.isSmoothAutoplay=!1)}SlideBetween(t,e,n,s,o){t=Number(t),e=Number(e),n=Number(n),s=Number(s);let i=(t-e)/(n-e)*((o=Number(o))-s)+s;return 0==e&&0==n&&(i=0),i}}class Display{constructor(){this.infoDiv=constants.infoDiv,this.x={},this.x.id="x",this.x.textBase="x-value: ",this.y={},this.y.id="y",this.y.textBase="y-value: ",this.boxplotGridPlaceholders=[resources.GetString("lower_outlier"),resources.GetString("min"),resources.GetString("25"),resources.GetString("50"),resources.GetString("75"),resources.GetString("max"),resources.GetString("upper_outlier")]}toggleTextMode(){"off"==constants.textMode?constants.textMode="terse":"terse"==constants.textMode?constants.textMode="verbose":"verbose"==constants.textMode&&(constants.textMode="off"),this.announceText(' '+constants.textMode)}toggleBrailleMode(t){if(position.x<0&&(position.x=0),position.y<0&&(position.y=0),"point"!=constants.chartType){if(void 0===t&&(void 0===constants.brailleMode?(constants.brailleMode="off",t="on"==constants.brailleMode):(t="on"==constants.brailleMode?"off":"on",constants.brailleMode=t)),"on"==t){if("box"==constants.chartType&&("vert"!=constants.plotOrientation&&-1==position.x&&position.y==plot.plotData.length?(position.x+=1,position.y-=1):"vert"==constants.plotOrientation&&0==position.x&&(position.y,plot.plotData[0].length)),constants.brailleMode="on",document.getElementById(constants.braille_container_id).classList.remove("hidden"),constants.brailleInput.focus(),constants.brailleInput.setSelectionRange(position.x,position.x),this.SetBraille(),"heat"==constants.chartType){let t=position.y*(plot.num_cols+1)+position.x;constants.brailleInput.setSelectionRange(t,t)}-1==position.x&&-1==position.y&&constants.brailleInput.setSelectionRange(0,0)}else constants.brailleMode="off",document.getElementById(constants.braille_container_id).classList.add("hidden"),constants.review_container?constants.review_container.classList.contains("hidden")?constants.chart.focus():constants.review.focus():constants.chart.focus();this.announceText("Braille "+constants.brailleMode)}else this.announceText("Braille is not supported in point layer.")}toggleSonificationMode(){"point"==constants.chartType||"stacked_bar"==constants.chartType||"stacked_normalized_bar"==constants.chartType||"dodged_bar"==constants.chartType?"off"==constants.sonifMode?(constants.sonifMode="on",this.announceText(resources.GetString("son_sep"))):"on"==constants.sonifMode?(constants.sonifMode="same",this.announceText(resources.GetString("son_same"))):"same"==constants.sonifMode&&(constants.sonifMode="off",this.announceText(resources.GetString("son_off"))):"off"==constants.sonifMode?(constants.sonifMode="on",this.announceText(resources.GetString("son_on"))):(constants.sonifMode="off",this.announceText(resources.GetString("son_off")))}changeChartLayer(t="down"){let e=maidr.type;if(Array.isArray(e)){let n=e.indexOf(constants.chartType);"down"==t?0==n||(constants.chartType=e[n-1],this.announceText("Switched to "+constants.chartType)):n==e.length-1||(constants.chartType=e[n+1],this.announceText("Switched to "+constants.chartType))}"point"==constants.chartType?position.x=Math.round((plot.x.length-1)*positionL1.x/(plot.curvePoints.length-1)):"smooth"==constants.chartType&&(positionL1.x=Math.round((plot.curvePoints.length-1)*position.x/(plot.x.length-1)))}announceText(t){this.displayInfo("announce",t,constants.announceContainer)}UpdateBraillePos(){if("bar"==constants.chartType||"hist"==constants.chartType||"line"==constants.chartType)constants.brailleInput.setSelectionRange(position.x,position.x);else if("stacked_bar"==constants.chartType||"stacked_normalized_bar"==constants.chartType||"dodged_bar"==constants.chartType){let t=null;t=position.y0&&(e+=plot.plotLegend.x+" is "),e+=plot.columnLabels[position.x]+", "),plot.plotData[position.x]&&(plot.plotLegend&&(e+=plot.plotLegend.y+" is "),e+=plot.plotData[position.x]),"off"==constants.textMode||("terse"==constants.textMode?t+="

"+plot.columnLabels[position.x]+" "+plot.plotData[position.x]+"

\n":"verbose"==constants.textMode&&(t+="

"+e+"

\n"));else if("heat"==constants.chartType)1==constants.navigation?(e+=plot.x_group_label+" "+plot.x_labels[position.x]+", "+plot.y_group_label+" "+plot.y_labels[position.y]+", "+plot.fill+" is ",e+=plot.data[position.y][position.x]):(e+=plot.y_group_label+" "+plot.y_labels[position.y]+", "+plot.x_group_label+" "+plot.x_labels[position.x]+", "+plot.fill+" is ",e+=plot.data[position.y][position.x]),"off"==constants.textMode||("terse"==constants.textMode?1==constants.navigation?t+="

"+plot.x_labels[position.x]+", "+plot.data[position.y][position.x]+"

\n":t+="

"+plot.y_labels[position.y]+", "+plot.data[position.y][position.x]+"

\n":"verbose"==constants.textMode&&(t+="

"+e+"

\n"));else if("box"==constants.chartType){let n=0,s=1,o=!1,i="vert"==constants.plotOrientation?position.x:position.y,a=plot.GetSectionKey("vert"==constants.plotOrientation?position.y:position.x),l="",r="";"lower_outlier"!=a&&"upper_outlier"!=a||(o=!0),null==plot.plotData[i][a]?(n="",o&&(s=0)):o?(n=plot.plotData[i][a].join(", "),s=plot.plotData[i][a].length):n=plot.plotData[i][a],constants.navigation?plot.x_group_label&&(r+=plot.x_group_label):constants.navigation||plot.y_group_label&&(r+=plot.y_group_label),constants.navigation?plot.x_labels[i]?(r+=" is ",l+=plot.x_labels[i]+", ",r+=plot.x_labels[i]+", "):r+=", ":constants.navigation||(plot.y_labels[i]?(r+=" is ",l+=plot.y_labels[i]+", ",r+=plot.y_labels[i]+", "):r+=", "),o&&(l+=s+" ",r+=s+" "),r+=resources.GetString(a),1==s?r+=" is ":(r+="s ",s>1&&(r+=" are ")),(o||constants.navigation&&"horz"==constants.plotOrientation||!constants.navigation&&"vert"==constants.plotOrientation)&&(l+=resources.GetString(a),1!=s&&(l+="s"),l+=" "),null!=plot.plotData[i][a]||o?(l+=n,r+=n):(l+="empty",r+="empty"),e=r,"verbose"==constants.textMode?t="

"+r+"

\n":"terse"==constants.textMode&&(t="

"+l+"

\n")}else[].concat(singleMaidr.type).includes("point")||[].concat(singleMaidr.type).includes("smooth")?("point"==constants.chartType?(e+=plot.x_group_label+" "+plot.x[position.x]+", "+plot.y_group_label+" ["+plot.y[position.x].join(", ")+"]","off"==constants.textMode||("terse"==constants.textMode?t+="

"+plot.x[position.x]+", ["+plot.y[position.x].join(", ")+"]

\n":constants.textMode)):"smooth"==constants.chartType&&(e+=plot.x_group_label+" "+plot.curveX[positionL1.x]+", "+plot.y_group_label+" "+plot.curvePoints[positionL1.x],"off"==constants.textMode||("terse"==constants.textMode?t+="

"+plot.curvePoints[positionL1.x]+"

\n":constants.textMode)),"verbose"==constants.textMode&&(t="

"+e+"

\n")):"hist"==constants.chartType?"terse"==constants.textMode?t="

"+plot.plotData[position.x].x+", "+plot.plotData[position.x].y+"

\n":"verbose"==constants.textMode&&(t="

",plot.legendX&&(t=plot.legendX+" is "),t+=plot.plotData[position.x].xmin,t+=" through "+plot.plotData[position.x].xmax+", ",plot.legendY&&(t+=plot.legendY+" is "),t+=plot.plotData[position.x].y):"line"==constants.chartType?(plot.plotLegend&&(e+=plot.plotLegend.x+" is "),e+=plot.pointValuesX[position.x]+", ",plot.plotLegend&&plot.plotLegend.y,e+=plot.pointValuesY[position.x],"off"==constants.textMode||("terse"==constants.textMode?t+="

"+plot.pointValuesX[position.x]+", "+plot.pointValuesY[position.x]+"

\n":"verbose"==constants.textMode&&(t+="

"+e+"

\n"))):"stacked_bar"!=constants.chartType&&"stacked_normalized_bar"!=constants.chartType&&"dodged_bar"!=constants.chartType||(plot.plotLegend&&(e+=plot.plotLegend.x+" is "),e+=plot.level[position.x]+", ",plot.plotLegend&&(e+=plot.plotLegend.y+" is "),e+=plot.fill[position.y]+", ",e+="value is "+plot.plotData[position.x][position.y],"off"==constants.textMode||("terse"==constants.textMode?1==constants.navigation?t+="

"+plot.level[position.x]+" is "+plot.plotData[position.x][position.y]+"

\n":t+="

"+plot.fill[position.y]+" is "+plot.plotData[position.x][position.y]+"

\n":t+="

"+e+"

\n"));constants.infoDiv&&(constants.infoDiv.innerHTML=t),constants.review&&(t.length>0?constants.review.value=t.replace(/<[^>]*>?/gm,""):constants.review.value=e)}displayInfo(t,e,n=constants.infoDiv){let s="";if("announce"==t)e&&(s=e);else if(t)if(e){if("terse"==constants.textMode)s=e;else if("verbose"==constants.textMode){s=t.charAt(0).toUpperCase()+t.slice(1)+" is "+e}}else{s="Plot does not have "+(["a","e","i","o","u"].includes(t.charAt(0))?"an":"a")+" "+t}if(s.length>0){n.innerHTML=null;let t=document.createElement("p");t.innerHTML=s,n.appendChild(t)}}SetBraille(){let t=[];if("heat"==constants.chartType){let e=(constants.maxY-constants.minY)/3,n=constants.minY+e,s=n+e;for(let e=0;en&&(n=plot.plotData[t][position.y]));let s=(n-e)/4,o=e+s,i=o+s,a=i+s;for(let e=0;e-1){let e,n,s,o=plot.sections.length;"vert"==constants.plotOrientation?(e=position.x,n=constants.minY,s=constants.maxY):(e=position.y,n=constants.minX,s=constants.maxX);let i=[];i.push({type:"global_min",value:n});for(let t=0;t0||"lower_outlier"==a[t].type||"upper_outlier"==a[t].type)?(a[t].numChars=1,h++):a[t].numChars=0,"min"==a[t].type&&a[t].length>0&&(r=t),"max"==a[t].type&&a[t].length>0&&(d=t),"q1"==a[t].type&&(c=t),"q3"==a[t].type&&(p=t),"q2"==a[t].type&&(a[t].numChars=2,h++);r>-1&&d>-1&&a[r].length!=a[d].length&&(a[r].length>a[d].length?(a[r].numChars++,h++):(a[d].numChars++,h++)),a[c].length!=a[p].length&&(a[c].length>a[p].length?(a[c].numChars++,h++):(a[p].numChars++,h++));let u=constants.brailleDisplayLength-h,y=this.AllocateCharacters(a,u),g=a;for(let t=0;t5&&(console.log("plotData[i]",plot.plotData[e]),console.log("valData",i),console.log("lenData",a),console.log("brailleData",g));for(let e=0;e=0&&plot.pointValuesY[e-1]>n?plot.pointValuesY[e-1]<=s?t.push("⢄"):plot.pointValuesY[e-1]<=o?t.push("⢆"):plot.pointValuesY[e-1]>o&&t.push("⢇"):plot.pointValuesY[e]<=n?t.push("⣀"):e-1>=0&&plot.pointValuesY[e-1]<=n?plot.pointValuesY[e]<=s?t.push("⡠"):plot.pointValuesY[e]<=o?t.push("⡰"):plot.pointValuesY[e]>o&&t.push("⡸"):plot.pointValuesY[e]<=s&&e-1>=0&&plot.pointValuesY[e-1]>s?plot.pointValuesY[e-1]<=o?t.push("⠢"):plot.pointValuesY[e-1]>o&&t.push("⠣"):plot.pointValuesY[e]<=s?t.push("⠤"):e-1>=0&&plot.pointValuesY[e-1]<=s?plot.pointValuesY[e]<=o?t.push("⠔"):plot.pointValuesY[e]>o&&t.push("⠜"):plot.pointValuesY[e]<=o&&e-1>=0&&plot.pointValuesY[e-1]>o?t.push("⠑"):plot.pointValuesY[e]<=o?t.push("⠒"):e-1>=0&&plot.pointValuesY[e-1]<=o?t.push("⠊"):plot.pointValuesY[e]<=i&&t.push("⠉")}constants.brailleInput.value=t.join(""),constants.brailleInput.value=t.join(""),constants.debugLevel>5&&console.log("braille:",constants.brailleInput.value),this.UpdateBraillePos()}CharLenImpact(t){return t.length/t.numChars}AllocateCharacters(t,e){let n=[],s=0;for(let e=0;et+e),0),a=e-i,l=t.length;for(;0!==a&&l>0;){for(let e=0;et+e),0),a=e-i,l--}if(0!==a){let e=[];for(let n=0;nn[t]-n[e]));let s=-1;a>0&&(s=1);let o=0,i=3*e.length;for(;a>0&&i>0;)n[e[o]]+=s,a+=-s,o+=1,o>=e.length&&(o=0),i+=-1}return n}}class BarChart{constructor(){let t=null;"axes"in singleMaidr&&singleMaidr.axes.x&&singleMaidr.axes.x.level&&(t=singleMaidr.axes.x.level);let e=null;"data"in singleMaidr&&(e=singleMaidr.data);let n=null;"selector"in singleMaidr?n=document.querySelectorAll(singleMaidr.selector):"elements"in singleMaidr&&(n=singleMaidr.elements),t&&e&&n?n.length!=e.length?(constants.hasRect=0,logError.LogDifferentLengths("elements","data")):t.length!=n.length?(constants.hasRect=0,logError.LogDifferentLengths("x level","elements")):e.length!=t.length?(constants.hasRect=0,logError.LogDifferentLengths("x level","data")):(this.bars=n,constants.hasRect=1):e&&n?e.length!=n.length?(constants.hasRect=0,logError.LogDifferentLengths("data","elements")):(this.bars=n,constants.hasRect=1):t&&e?(t.length!=e.length&&(constants.hasRect=0,logError.LogDifferentLengths("x level","data")),logError.LogAbsentElement("elements")):e&&(logError.LogAbsentElement("x level"),logError.LogAbsentElement("elements")),this.columnLabels=[];let s="",o="";"labels"in singleMaidr&&("x"in singleMaidr.labels&&(s=singleMaidr.labels.x),"y"in singleMaidr.labels&&(o=singleMaidr.labels.y)),"axes"in singleMaidr&&(singleMaidr.axes.x&&singleMaidr.axes.x.label&&""==s&&(s=singleMaidr.axes.x.label),singleMaidr.axes.y&&singleMaidr.axes.y.label&&""==o&&(o=singleMaidr.axes.y.label),singleMaidr.axes.x&&singleMaidr.axes.x.level&&(this.columnLabels=singleMaidr.axes.x.level),singleMaidr.axes.y&&singleMaidr.axes.y.level&&(this.columnLabels=singleMaidr.axes.y.level)),this.plotLegend={x:s,y:o},this.title="","labels"in singleMaidr&&"title"in singleMaidr.labels&&(this.title=singleMaidr.labels.title),""==this.title&&"title"in singleMaidr&&(this.title=singleMaidr.title),"labels"in singleMaidr&&"subtitle"in singleMaidr.labels&&(this.subtitle=singleMaidr.labels.subtitle),"labels"in singleMaidr&&"caption"in singleMaidr.labels&&(this.caption=singleMaidr.labels.caption),Array.isArray(singleMaidr)?this.plotData=singleMaidr:"data"in singleMaidr&&(this.plotData=singleMaidr.data),this.SetMaxMin(),this.autoplay=null}SetMaxMin(){for(let t=0;tconstants.maxY&&(constants.maxY=this.plotData[t]),this.plotData[t]e)&&(e=o)}if(this.plotData[n].min&&((null==t||this.plotData[n].mine)&&(e=this.plotData[n].max)),this.plotData[n].q1&&((null==t||this.plotData[n].q1e)&&(e=this.plotData[n].q1)),this.plotData[n].q2&&((null==t||this.plotData[n].q2e)&&(e=this.plotData[n].q2)),this.plotData[n].q3&&((null==t||this.plotData[n].q3e)&&(e=this.plotData[n].q3)),this.plotData[n].max&&((null==t||this.plotData[n].maxe)&&(e=this.plotData[n].max)),this.plotData[n].upper_outlier){let s=Math.min(...this.plotData[n].upper_outlier),o=Math.max(...this.plotData[n].upper_outlier);(null==t||se)&&(e=o)}}"vert"==constants.plotOrientation?(constants.minY=t,constants.maxY=e,constants.minX=0,constants.maxX=this.plotData.length-1):(constants.minX=t,constants.maxX=e,constants.minY=0,constants.maxY=this.plotData.length-1),constants.autoPlayRate=Math.min(Math.ceil(constants.AUTOPLAY_DURATION/this.plotData.length),constants.MAX_SPEED),constants.DEFAULT_SPEED=constants.autoPlayRate,constants.autoPlayRatea.bottom&&(s=!0),e.topa.right&&(l=!0)),s?(i[1]=this.convertBoundingClientRectToObj(e),i[1].label=n[1],i[1].type="whisker","vert"==constants.plotOrientation?(i[1].top=i[2].bottom,i[1].y=i[1].top,i[1].height=i[1].bottom-i[1].top):i[1].width=i[2].left-i[1].left):(i[1]={},i[1].label=n[1],i[1].type="blank"),l?(i[5]=this.convertBoundingClientRectToObj(e),i[5].label=n[5],i[5].type="whisker","vert"==constants.plotOrientation?(i[5].bottom=i[4].top,i[5].height=i[5].bottom-i[5].top):(i[5].left=i[4].right,i[5].x=i[4].right,i[5].width=i[5].right-i[5].left)):(i[5]={},i[5].label=n[5],i[5].type="blank")}if(Object.hasOwn(o[t],"outlier")){let e=o[t].outlier.children,s=null,l=null;for(let t=0;ts.bottom&&(s.bottom=n.bottom)):s=this.convertBoundingClientRectToObj(n):l?(n.yl.bottom&&(l.bottom=n.bottom)):l=this.convertBoundingClientRectToObj(n):n.x>a.x?s?(n.xs.right&&(s.right=n.right)):s=this.convertBoundingClientRectToObj(n):l?(n.xl.right&&(l.right=n.right)):l=this.convertBoundingClientRectToObj(n)}l?(l.height=l.bottom-l.top,l.width=l.right-l.left,i[0]=this.convertBoundingClientRectToObj(l),i[0].label=n[0],i[0].type="outlier"):(i[0]={},i[0].label=n[0],i[0].type="blank"),s?(s.height=s.bottom-s.top,s.width=s.right-s.left,i[6]=this.convertBoundingClientRectToObj(s),i[6].label=n[6],i[6].type="outlier"):(i[6]={},i[6].label=n[6],i[6].type="blank")}else i[0]={},i[0].label=n[0],i[0].type="blank",i[6]={},i[6].label=n[6],i[6].type="blank";e.push(i)}return constants.debugLevel>5&&console.log("plotBounds",e),e}GetAllSegmentTypes(){let t=[];for(let e=0;eplot.plotData[t][e].length)&&(clearInterval(constants.outlierInterval),position.z=-1)}),constants.autoPlayOutlierRate))}GetSectionKey(t){return this.sections[t]}}class BoxplotRect{rectPadding=15;rectStrokeWidth=4;constructor(){this.x1=0,this.width=0,this.y1=0,this.height=0,this.chartOffsetLeft=constants.chart.getBoundingClientRect().left,this.chartOffsetTop=constants.chart.getBoundingClientRect().top}UpdateRect(){document.getElementById("highlight_rect")&&document.getElementById("highlight_rect").remove();let t=position.x,e=position.y,n=plot.GetSectionKey(position.y);if("vert"==constants.plotOrientation||(t=position.y,e=position.x,n=plot.GetSectionKey(position.x)),"vert"==constants.plotOrientation&&position.y>-1||"horz"==constants.plotOrientation&&position.x>-1){let s=plot.plotBounds[t][e];"blank"!=s.type&&(this.x1=s.left-this.rectPadding-this.chartOffsetLeft,this.width=s.width+2*this.rectPadding,this.y1=s.top-this.rectPadding-this.chartOffsetTop,this.height=s.height+2*this.rectPadding,constants.debugLevel>5&&(console.log("Point",n,"bottom:",s.bottom,"top:",s.top),console.log("x1:",this.x1,"y1:",this.y1,"width:",this.width,"height:",this.height)),this.CreateRectDisplay())}}CreateRectDisplay(){let t=document.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("id","highlight_rect"),t.setAttribute("x",this.x1),t.setAttribute("y",this.y1),t.setAttribute("width",this.width),t.setAttribute("height",this.height),t.setAttribute("stroke",constants.colorSelected),t.setAttribute("stroke-width",this.rectStrokeWidth),t.setAttribute("fill","none"),constants.chart.appendChild(t)}}class HeatMap{constructor(){let t=null,e=null;"axes"in singleMaidr&&(singleMaidr.axes.x&&singleMaidr.axes.x.level&&(t=singleMaidr.axes.x.level),singleMaidr.axes.y&&singleMaidr.axes.y.level&&(e=singleMaidr.axes.y.level)),"data"in singleMaidr?(this.data=singleMaidr.data,this.num_rows=this.data.length,this.num_cols=this.data[0].length):console.error("No data found in singleMaidr object"),"selector"in singleMaidr?(this.elements=document.querySelectorAll(singleMaidr.selector),constants.hasRect=1):"elements"in singleMaidr?(this.elements=singleMaidr.elements,constants.hasRect=1):(this.elements=null,constants.hasRect=0),this.group_labels=this.getGroupLabels(),this.x_labels=t,this.y_labels=e,this.title=this.getTitle(),this.fill=this.getFill(),constants.hasRect&&this.SetHeatmapRectData(),this.updateConstants(),this.x_group_label=this.group_labels[0].trim(),this.y_group_label=this.group_labels[1].trim()}SetHeatmapRectData(){let t=[],e=[],n=[],s=[];for(let n=0;nMath.min(...t)))),constants.maxY=Math.max(...this.data.map((t=>Math.max(...t)))),constants.autoPlayRate=Math.min(Math.ceil(constants.AUTOPLAY_DURATION/(constants.maxX+1)),constants.MAX_SPEED),constants.DEFAULT_SPEED=constants.autoPlayRate,constants.autoPlayRate0?(this.curveMinY=Math.min(...this.curvePoints),this.curveMaxY=Math.max(...this.curvePoints)):(this.curveMinY=Number.MAX_VALUE,this.curveMaxY=Number.MIN_VALUE),this.gradient=this.GetGradient()}GetSvgPointCoords(){let t=new Map;if(this.plotPoints)for(let e=0;e-1?singleMaidr.data[n]:singleMaidr.data;let o=[],i=[];if("array"==s)"x"in e&&(o=e.x),"y"in e&&(i=e.y);else if("object"==s)for(let t=0;t-1?singleMaidr.data[t]:singleMaidr.data,n=Array.isArray(e)?"object":"array",n}GetSVGScaler(){let t=1,e=1,n=!1;if(this.plotPoints){let s=this.plotPoints[0];for(;s&&"body"!=s.tagName.toLowerCase();)s.tagName&&"svg"===s.tagName.toLowerCase()&&(n=!0),s=s.parentNode;if(n){let n=this.plotPoints[0];for(;n&&"body"!=n.tagName.toLowerCase();){if(n.getAttribute("transform")){let s=n.getAttribute("transform").match(/scale\((-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)\)/);s&&(isNaN(s[1])||(t*=parseFloat(s[1])),isNaN(s[3])||(e*=parseFloat(s[3])))}n=n.parentNode}}}return[t,e]}GetPrefix(){let t=this.GetElementIndex("point"),e=null;-1!=t?"selector"in singleMaidr?e=document.querySelectorAll(singleMaidr.selector[t])[0]:"elements"in singleMaidr&&(e=singleMaidr.elements[t][0]):"point"==singleMaidr.type&&("selector"in singleMaidr?e=document.querySelectorAll(singleMaidr.selector)[0]:"elements"in singleMaidr&&(e=singleMaidr.elements[0]));let n="";return e&&"circle"===e.tagName.toLowerCase()&&(n="c"),n}GetPointValues(){let t,e,n=new Map,s=[],o=[],i=[],a=this.GetElementIndex("point"),l=this.GetDataXYFormat(a);if(a>-1?e=singleMaidr.data[a]:"point"==singleMaidr.type&&(e=singleMaidr.data),void 0!==e){let a=[],r=[];if("array"==l)"x"in e&&(a=e.x),"y"in e&&(r=e.y);else if("object"==l)for(let t=0;tMath.max(...t))))}return[s,o,i,t]}PlayTones(){constants.sepPlayId&&constants.KillSepPlay(),"point"==constants.chartType?(position.z=0,constants.sepPlayId=setInterval((function(){audio.playTone(),position.z+=1,position.z+1>plot.y[position.x].length&&(constants.KillSepPlay(),position.z=-1)}),"on"==constants.sonifMode?constants.autoPlayPointsRate:0)):"smooth"==constants.chartType&&audio.playTone()}GetSvgLineCoords(){let t=[],e=[];if(this.plotLine){if(this.plotLine instanceof SVGPathElement){const n=this.plotLine.getAttribute("d"),s=/[ML]\s*(-?\d+(\.\d+)?)\s+(-?\d+(\.\d+)?)/g;let o;for(;null!==(o=s.exec(n));)t.push(o[1]),e.push(o[3])}else if(this.plotLine instanceof SVGPolylineElement){let n=this.plotLine.getAttribute("points").split(" ");for(let s=0;s-1?singleMaidr.data[s]:singleMaidr.data,"object"==o)for(let s=0;s-1?t=singleMaidr.data[s]:"smooth"==singleMaidr.type&&(t=singleMaidr.data),void 0!==t)if("object"==o)for(let s=0;s-1){if("selector"in singleMaidr)return!!singleMaidr.selector[e];if("elements"in singleMaidr)return!!singleMaidr.elements[e]}else{if("selector"in singleMaidr)return!!singleMaidr.selector;if("elements"in singleMaidr)return!!singleMaidr.elements}}}class Layer0Point{constructor(){[].concat(singleMaidr.type).includes("point")&&(this.x=plot.chartPointsX[0],this.y=plot.chartPointsY[0],this.strokeWidth=1.35,this.hasRect=plot.GetRectStatus("point"),this.circleIndex=[])}async UpdatePoints(){await this.ClearPoints(),this.x=plot.chartPointsX[position.x],this.y=plot.chartPointsY[position.x],this.circleIndex=[];for(let t=0;tconstants.maxY&&(constants.maxY=this.plotData[t].y),this.plotData[t].yconstants.maxX&&(constants.maxX=this.plotData[t].xmax),this.plotData[t].xmine.ye.y>t?e.y:t),singleMaidr.data[0].y),constants.autoPlayRate=Math.min(Math.ceil(constants.AUTOPLAY_DURATION/(constants.maxX+1)),constants.MAX_SPEED),constants.DEFAULT_SPEED=constants.autoPlayRate,constants.autoPlayRateplot.plotData[position.x][position.y].length&&(constants.KillSepPlay(),position.z=-1):(constants.KillSepPlay(),position.z=-1)}),"on"==constants.sonifMode?constants.autoPlayPointsRate:0);else{let t=Math.min(...this.plotData[position.x][position.y]),e=Math.max(...this.plotData[position.x][position.y]);for(let n=0;nconstants.maxY&&(constants.maxY=singleMaidr.data[t].y),singleMaidr.data[t].yt.target.value.length-2||((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x-=1,u("right",position.x,plot.plotData.length)):(position.x=plot.bars.length-1,e=!0,n=c()):t.altKey&&t.shiftKey&&position.x!=plot.bars.length-1?(constants.lastx=position.x,u("reverse-right",plot.bars.length,position.x)):(position.x+=1,e=!0,n=c()))):"ArrowLeft"==t.key?(t.preventDefault(),(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x+=1,u("left",position.x,-1)):(position.x=0,e=!0,n=c()):t.altKey&&t.shiftKey&&0!=position.x?(constants.lastx=position.x,u("reverse-left",-1,position.x)):(position.x+=-1,e=!0,n=c())):"Tab"==t.key||t.preventDefault(),e&&!n&&h(),n&&audio.playEnd()}]);let a=[constants.chart,constants.brailleInput],l=0;for(let y=0;yplot.plotData.length-1&&(position.x=plot.plotData.length-1,t=!0),t}function p(){constants.showDisplay&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones()}function d(){constants.showDisplayInAutoplay&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones(),"off"!=constants.brailleMode&&display.UpdateBraillePos()}function h(){constants.showDisplayInBraille&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones(),display.UpdateBraillePos()}function u(t,e,n){i=t;let s=1;"left"!=t&&"reverse-right"!=t||(s=-1),null!=constants.autoplayId&&constants.KillAutoplay(),"reverse-right"!=t&&"reverse-left"!=t||(position.x=e),constants.autoplayId=setInterval((function(){position.x+=s,position.x<0||plot.plotData.length-10?("vert"==constants.plotOrientation?lastY=position.y:constants.lastx=position.x,w("reverse-left",0,position.x)):(position.x+=-1,e=!0,n=L()),constants.navigation=1),"ArrowUp"==t.key){position.y;(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?"vert"==constants.plotOrientation?w("up",position.y,plot.sections.length):w("up",position.y,plot.plotData.length):("vert"==constants.plotOrientation?position.y=plot.sections.length-1:position.y=plot.plotData.length-1,e=!0,n=L()):"vert"==constants.plotOrientation?t.altKey&&t.shiftKey&&position.y!=plot.sections.length-1?(lastY=position.y,w("reverse-up",plot.sections.length-1,position.y)):(position.y+=1,e=!0,n=L()):t.altKey&&t.shiftKey&&position.y!=plot.sections.length-1?(constants.lastx=position.x,w("reverse-up",plot.plotData.length-1,position.y)):(position.y+=1,e=!0,n=L()),constants.navigation=0}if("ArrowDown"==t.key){position.y;(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?w("down",position.y,-1):(position.y=0,e=!0,n=L()):t.altKey&&t.shiftKey&&0!=position.y?("vert"==constants.plotOrientation?lastY=position.y:constants.lastx=position.x,w("reverse-down",0,position.y)):("vert"==constants.plotOrientation?-1==position.x&&position.y==plot.sections.length&&(position.x+=1):-1==position.x&&position.y==plot.plotData.length&&(position.x+=1),position.y+=-1,e=!0,n=L()),constants.navigation=0}e&&!n&&M(),n&&audio.playEnd()}]),constants.events.push([constants.brailleInput,"keydown",function(t){let e=!1,n=!1,s=!1;if("ArrowRight"==t.key)t.preventDefault(),(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?"vert"==constants.plotOrientation?w("right",position.x,plot.plotData.length-1):w("right",position.x,plot.sections.length):("vert"==constants.plotOrientation?position.x=plot.plotData.length-1:position.x=plot.sections.length-1,e=!0,s=L()):"vert"==constants.plotOrientation?t.altKey&&t.shiftKey&&plot.plotData.length-1!=position.x?(lastY=position.y,w("reverse-right",plot.plotData.length-1,position.x)):(-1==position.x&&position.y==plot.plotData[position.x].length&&(position.y-=1),position.x+=1,e=!0,s=L()):t.altKey&&t.shiftKey&&plot.sections.length-1!=position.x?(constants.lastx=position.x,w("reverse-right",plot.sections.length-1,position.x)):(-1==position.x&&position.y==plot.plotData.length&&(position.y-=1),position.x+=1,e=!0,s=L()),n=!0,constants.navigation=1;else if("ArrowLeft"==t.key)t.preventDefault(),(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?w("left",position.x,-1):(position.x=0,e=!0,s=L()):t.altKey&&t.shiftKey&&position.x>0?("vert"==constants.plotOrientation?lastY=position.y:constants.lastx=position.x,w("reverse-left",0,position.x)):(position.x+=-1,e=!0,s=L()),n=!0,constants.navigation=1;else if("ArrowUp"==t.key){position.y;(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?"vert"==constants.plotOrientation?(position.x<0&&(position.x=0),w("up",position.y,plot.sections.length)):w("up",position.y,plot.plotData.length):"vert"==constants.plotOrientation?(position.y=plot.sections.length-1,e=!0):(position.y=plot.plotData.length-1,e=!0):"vert"==constants.plotOrientation?t.altKey&&t.shiftKey&&position.y!=plot.sections.length-1?(lasY=position.y,w("reverse-up",plot.sections.length-1,position.y)):(position.y+=1,e=!0,s=L()):t.altKey&&t.shiftKey&&position.y!=plot.plotData.length-1?(constants.lastx=position.x,w("reverse-up",plot.plotData.length-1,position.y)):(position.y+=1,e=!0,s=L()),"vert"==constants.plotOrientation||(n=!0),constants.navigation=0}else if("ArrowDown"==t.key){position.y;(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?w("down",position.y,-1):(position.y=0,e=!0,s=L()):t.altKey&&t.shiftKey&&0!=position.y?("vert"==constants.plotOrientation?lastY=position.y:constants.lastx=position.x,w("reverse-down",0,position.y)):("vert"==constants.plotOrientation?-1==position.x&&position.y==plot.sections.length&&(position.x+=1):-1==position.x&&position.y==plot.plotData.length&&(position.x+=1),position.y+=-1,e=!0,s=L()),constants.navigation=0,"vert"==constants.plotOrientation||(n=!0),constants.navigation=0}else"Tab"==t.key||t.preventDefault();e&&!s&&(n&&display.SetBraille(plot),setTimeout(_,50)),s&&audio.playEnd()}]);let f=[constants.chart,constants.brailleInput],x=0;for(let E=0;Eplot.plotData.length-1&&(position.x=plot.plotData.length-1,t=!0),position.y>plot.sections.length-1&&(position.y=plot.sections.length-1,t=!0)):(position.y>plot.plotData.length-1&&(position.y=plot.plotData.length-1,t=!0),position.x>plot.sections.length-1&&(position.x=plot.sections.length-1,t=!0)),t}function w(t,e,n){m=t;let s=1;"left"!=t&&"down"!=t&&"reverse-right"!=t&&"reverse-up"!=t||(s=-1),null!=constants.autoplayId&&constants.KillAutoplay(),"reverse-left"==t||"reverse-right"==t?position.x=e:"reverse-up"!=t&&"reverse-down"!=t||(position.y=e),constants.debugLevel>0&&console.log("starting autoplay",t,e,n),b(),constants.autoplayId=setInterval((function(){let e=!1;"left"==t||"right"==t||"up"==t||"down"==t?(position.x<1&&"left"==t||"vert"==constants.plotOrientation&&"up"==t&&position.y>plot.sections.length-2||"horz"==constants.plotOrientation&&"up"==t&&position.y>plot.plotData.length-2||"horz"==constants.plotOrientation&&"right"==t&&position.x>plot.sections.length-2||"vert"==constants.plotOrientation&&"right"==t&&position.x>plot.plotData.length-2||"horz"==constants.plotOrientation&&"down"==t&&position.y<1||"vert"==constants.plotOrientation&&"down"==t&&position.y<1)&&(e=!0):("reverse-left"==t&&position.x>=n||"reverse-right"==t&&position.x<=n||"reverse-up"==t&&position.y<=n||"reverse-down"==t&&position.y>=n)&&(e=!0),e?constants.KillAutoplay():("left"==t||"right"==t||"reverse-left"==t||"reverse-right"==t?position.x+=s:position.y+=s,b()),constants.debugLevel>5&&console.log("autoplay pos",position)}),constants.autoPlayRate)}}else if([].concat(singleMaidr.type).includes("heat")){constants.plotId="geom_rect.rect.2.1",window.position=new Position(-1,-1),window.plot=new HeatMap;let D=new HeatMapRect,S="";constants.lastx=0,constants.events.push([constants.chart,"keydown",function(t){let e=!1,n=!1;"ArrowRight"==t.key&&((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x-=1,C("right",position.x,plot.num_cols)):(position.x=plot.num_cols-1,e=!0):t.altKey&&t.shiftKey&&position.x!=plot.num_cols-1?(constants.lastx=position.x,C("reverse-right",plot.num_cols,position.x)):(-1==position.x&&-1==position.y&&(position.y+=1),position.x+=1,e=!0,n=k()),constants.navigation=1),"ArrowLeft"==t.key&&((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x+=1,C("left",position.x,-1)):(position.x=0,e=!0):t.altKey&&t.shiftKey&&0!=position.x?(constants.lastx=position.x,C("reverse-left",-1,position.x)):(position.x-=1,e=!0,n=k()),constants.navigation=1),"ArrowUp"==t.key&&((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.y+=1,C("up",position.y,-1)):(position.y=0,e=!0):t.altKey&&t.shiftKey&&0!=position.y?(constants.lastx=position.x,C("reverse-up",-1,position.y)):(position.y-=1,e=!0,n=k()),constants.navigation=0),"ArrowDown"==t.key&&((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.y-=1,C("down",position.y,plot.num_rows)):(position.y=plot.num_rows-1,e=!0):t.altKey&&t.shiftKey&&position.y!=plot.num_rows-1?(constants.lastx=position.x,C("reverse-down",plot.num_rows,position.y)):(-1==position.x&&-1==position.y&&(position.x+=1),position.y+=1,e=!0,n=k()),constants.navigation=0),e&&!n&&T(),n&&audio.playEnd()}]);let A=[constants.chart,constants.brailleInput],I=0;for(let B=0;Bplot.num_cols-1&&(position.x=plot.num_cols-1,t=!0),position.y<0&&(position.y=0,t=!0),position.y>plot.num_rows-1&&(position.y=plot.num_rows-1,t=!0),t}function T(){constants.showDisplay&&display.displayValues(),constants.showRect&&constants.hasRect&&D.UpdateRectDisplay(),"off"!=constants.sonifMode&&plot.PlayTones()}function K(){constants.showDisplayInAutoplay&&display.displayValues(),constants.showRect&&constants.hasRect&&D.UpdateRectDisplay(),"off"!=constants.sonifMode&&plot.PlayTones(),"off"!=constants.brailleMode&&display.UpdateBraillePos()}function R(){constants.showDisplayInBraille&&display.displayValues(),constants.showRect&&constants.hasRect&&D.UpdateRectDisplay(),"off"!=constants.sonifMode&&plot.PlayTones(),display.UpdateBraillePos()}function C(t,e,n){S=t;let s=1;"left"!=t&&"up"!=t&&"reverse-right"!=t&&"reverse-down"!=t||(s=-1),null!=constants.autoplayId&&constants.KillAutoplay(),"reverse-left"==t||"reverse-right"==t?position.x=e:"reverse-up"!=t&&"reverse-down"!=t||(position.y=e),constants.autoplayId=setInterval((function(){"left"==t||"right"==t||"reverse-left"==t||"reverse-right"==t?(position.x+=s,position.x<0||plot.num_cols-1t.target.value.length-3||"⠳"==t.target.value.substring(t.target.selectionStart+1,t.target.selectionStart+2))t.preventDefault();else{(constants.isMac?t.metaKey:t.ctrlKey)?(-1==position.x&&-1==position.y&&(position.x+=1,position.y+=1),t.shiftKey?(position.x-=1,C("right",position.x,plot.num_cols)):(position.x=plot.num_cols-1,e=!0)):t.altKey&&t.shiftKey&&position.x!=plot.num_cols-1?(constants.lastx=position.x,C("reverse-right",plot.num_cols,position.x)):(-1==position.x&&-1==position.y&&(position.y+=1),position.x+=1,e=!0,n=k());let s=position.y*(plot.num_cols+1)+position.x;t.target.setSelectionRange(s,s),t.preventDefault(),constants.navigation=1}else if("ArrowLeft"==t.key)if(0==t.target.selectionStart||"⠳"==t.target.value.substring(t.target.selectionStart-1,t.target.selectionStart))t.preventDefault();else{(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x+=1,C("left",position.x,-1)):(position.x=0,e=!0):t.altKey&&t.shiftKey&&0!=position.x?(constants.lastx=position.x,C("reverse-left",-1,position.x)):(position.x+=-1,e=!0,n=k());let s=position.y*(plot.num_cols+1)+position.x;t.target.setSelectionRange(s,s),t.preventDefault(),constants.navigation=1}else if("ArrowDown"==t.key)if(position.y+1==plot.num_rows)t.preventDefault();else{(constants.isMac?t.metaKey:t.ctrlKey)?(-1==position.x&&-1==position.y&&(position.x+=1,position.y+=1),t.shiftKey?(position.y-=1,C("down",position.y,plot.num_rows)):(position.y=plot.num_rows-1,e=!0)):t.altKey&&t.shiftKey&&position.y!=plot.num_rows-1?(constants.lastx=position.x,C("reverse-down",plot.num_rows,position.y)):(-1==position.x&&-1==position.y&&(position.x+=1),position.y+=1,e=!0,n=k());let s=position.y*(plot.num_cols+1)+position.x;t.target.setSelectionRange(s,s),t.preventDefault(),constants.navigation=0}else if("ArrowUp"==t.key)if(t.target.selectionStart-plot.num_cols-1<0)t.preventDefault();else{(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.y+=1,C("up",position.y,-1)):(position.y=0,e=!0):t.altKey&&t.shiftKey&&0!=position.y?(constants.lastx=position.x,C("reverse-up",-1,position.y)):(position.y+=-1,e=!0,n=k());let s=position.y*(plot.num_cols+1)+position.x;t.target.setSelectionRange(s,s),t.preventDefault(),constants.navigation=0}else"Tab"==t.key||t.preventDefault();e&&!n&&R(),n&&audio.playEnd()}])}else if([].concat(singleMaidr.type).includes("point")||[].concat(singleMaidr.type).includes("smooth")){constants.plotId="geom_point.points.12.1",window.position=new Position(-1,-1),window.plot=new ScatterPlot;let O=new Layer0Point,N=new Layer1Point,U="";constants.lastx=0;let Y=0;window.positionL1=new Position(Y,Y),constants.events.push([[constants.chart,constants.brailleInput],"keydown",function(t){let e=!1,n=!1;"point"==constants.chartType?("ArrowRight"==t.key&&((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x-=1,Q("right",position.x,plot.x.length)):(position.x=plot.x.length-1,e=!0,n=X()):t.altKey&&t.shiftKey&&position.x!=plot.x.length-1?(constants.lastx=position.x,Q("reverse-right",plot.x.length,position.x)):(position.x+=1,e=!0,n=X())),"ArrowLeft"==t.key&&((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x+=1,Q("left",position.x,-1)):(position.x=0,e=!0,n=X()):t.altKey&&t.shiftKey&&0!=position.x?(constants.lastx=position.x,Q("reverse-left",-1,position.x)):(position.x-=1,e=!0,n=X()))):"smooth"==constants.chartType&&(positionL1.x||(positionL1.x=Y),"ArrowRight"==t.key&&t.shiftKey&&((constants.isMac?t.metaKey:t.ctrlKey)&&"off"!=constants.sonifMode?z("right"):t.altKey&&"off"!=constants.sonifMode&&z("reverse-right")),"ArrowLeft"==t.key&&t.shiftKey&&((constants.isMac?t.metaKey:t.ctrlKey)&&"off"!=constants.sonifMode?z("left"):t.altKey&&"off"!=constants.sonifMode&&z("reverse-left"))),e&&"point"==constants.chartType&&!n&&q(),n&&audio.playEnd()}]);let G=[constants.chart,constants.brailleInput],F=0;for(let J=0;Jplot.x.length-1&&(position.x=plot.x.length-1,t=!0)):"smooth"==constants.chartType&&(positionL1.x<0&&(positionL1.x=0,t=!0),positionL1.x>plot.curvePoints.length-1&&(positionL1.x=plot.curvePoints.length-1,t=!0)),t}function q(){constants.showDisplay&&display.displayValues(),O.hasRect&&O.UpdatePointDisplay(),"off"!=constants.sonifMode&&plot.PlayTones()}function j(){constants.showDisplayInAutoplay&&display.displayValues(),constants.showRect&&("point"==constants.chartType&&O.hasRect?O.UpdatePointDisplay():"smooth"==constants.chartType&&N.hasRect&&N.UpdatePointDisplay()),"off"!=constants.sonifMode&&plot.PlayTones(),"off"!=constants.brailleMode&&display.UpdateBraillePos()}function H(){constants.showDisplayInBraille&&display.displayValues(),N.hasRect&&N.UpdatePointDisplay(),"off"!=constants.sonifMode&&plot.PlayTones(),display.UpdateBraillePos()}function Q(t,e,n){U=t;let s=1;"left"!=t&&"reverse-right"!=t||(s=-1),constants.autoplayId&&constants.KillAutoplay(),constants.isSmoothAutoplay&&audio.KillSmooth(),"reverse-left"!=t&&"reverse-right"!=t||(position.x=e,position.L1x=e),"point"==constants.chartType?constants.autoplayId=setInterval((function(){position.x+=s,position.x<0||position.x>plot.y.length-1?(constants.KillAutoplay(),X()):position.x==n?(constants.KillAutoplay(),j()):j()}),constants.autoPlayRate):"smooth"==constants.chartType&&(constants.autoplayId=setInterval((function(){positionL1.x+=s,positionL1.x<0||positionL1.x>plot.curvePoints.length-1?(constants.KillAutoplay(),X()):positionL1.x==n?(constants.KillAutoplay(),j()):j()}),constants.autoPlayRate))}function z(t){U=t;let e=[],n=[],s=audio.SlideBetween(positionL1.x,0,plot.curvePoints.length-1,-1,1),o=positionL1.x<0?0:positionL1.x,i=0;if("right"==t){for(let t=o;t=0;t--)e.push(audio.SlideBetween(plot.curvePoints[t],plot.curveMinY,plot.curveMaxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY));n=[s,-1],i=Math.abs(o)/plot.curvePoints.length*3}else if("reverse-right"==t){for(let t=plot.curvePoints.length-1;t>=o;t--)e.push(audio.SlideBetween(plot.curvePoints[t],plot.curveMinY,plot.curveMaxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY));n=[1,s],i=Math.abs(plot.curvePoints.length-o)/plot.curvePoints.length*3}else if("reverse-left"==t){for(let t=0;t<=o;t++)e.push(audio.SlideBetween(plot.curvePoints[t],plot.curveMinY,plot.curveMaxY,constants.MIN_FREQUENCY,constants.MAX_FREQUENCY));n=[-1,s],i=Math.abs(o)/plot.curvePoints.length*3}constants.isSmoothAutoplay&&audio.KillSmooth(),audio.playSmooth(e,i,n,constants.vol,"sine")}constants.events.push([constants.brailleInput,"keydown",function(t){let e=!1,n=!1;"smooth"==constants.chartType?(X(),"ArrowRight"==t.key?(t.preventDefault(),constants.brailleInput.setSelectionRange(positionL1.x,positionL1.x),t.target.selectionStart>t.target.value.length-2?t.preventDefault():(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(positionL1.x-=1,Q("right",positionL1.x,plot.curvePoints.length)):(positionL1.x=plot.curvePoints.length-1,e=!0,n=X()):t.altKey&&t.shiftKey&&positionL1.x!=plot.curvePoints.length-1?(Y=positionL1.x,Q("reverse-right",plot.curvePoints.length,positionL1.x)):(positionL1.x+=1,e=!0,n=X())):"ArrowLeft"==t.key?(t.preventDefault(),(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(positionL1.x+=1,Q("left",positionL1.x,-1)):(positionL1.x=0,e=!0,n=X()):t.altKey&&t.shiftKey&&0!=positionL1.x?Q("reverse-left",-1,positionL1.x):(positionL1.x-=1,e=!0,n=X())):t.preventDefault()):"Tab"==t.key||t.preventDefault(),Y=positionL1.x,e&&!n&&H(),n&&audio.playEnd()}])}else if([].concat(singleMaidr.type).includes("hist")){window.position=new Position(-1,-1),window.plot=new Histogram;let W="";constants.lastx=0,constants.events.push([[constants.chart,constants.brailleInput],"keydown",function(t){let e=!1,n=!1;"ArrowRight"!=t.key||(constants.isMac?t.metaKey:t.ctrlKey)||t.shiftKey?"ArrowRight"==t.key&&(constants.isMac?t.metaKey:t.ctrlKey)&&t.shiftKey?(t.preventDefault(),position.x-=1,it("right",position.x,plot.plotData.length)):"ArrowRight"==t.key&&!(constants.isMac?t.metaKey:t.ctrlKey)&&t.altKey&&t.shiftKey?(t.preventDefault(),constants.lastx=position.x,it("reverse-right",plot.bars.length,position.x)):"ArrowRight"==t.key&&(constants.isMac?t.metaKey:t.ctrlKey)&&!t.shiftKey&&(t.preventDefault(),position.x=plot.plotData.length-1,e=!0,n=et()):(t.preventDefault(),position.x+=1,e=!0,n=et()),"ArrowLeft"!=t.key||(constants.isMac?t.metaKey:t.ctrlKey)||t.shiftKey?"ArrowLeft"==t.key&&(constants.isMac?t.metaKey:t.ctrlKey)&&t.shiftKey?(t.preventDefault(),position.x+=1,it("left",position.x,-1)):"ArrowLeft"==t.key&&!(constants.isMac?t.metaKey:t.ctrlKey)&&t.altKey&&t.shiftKey?(t.preventDefault(),constants.lastx=position.x,it("reverse-left",-1,position.x)):"ArrowLeft"==t.key&&(constants.isMac?t.metaKey:t.ctrlKey)&&!t.shiftKey&&(t.preventDefault(),position.x=0,e=!0,n=et()):(t.preventDefault(),position.x+=-1,e=!0,n=et()),e&&!n&&("off"==constants.brailleMode?nt():ot()),n&&audio.playEnd()}]);let $=[constants.chart,constants.brailleInput],Z=0;for(let at=0;at<$.length;at++)constants.events.push([$[at],"keydown",function(t){"."==t.key&&(t.preventDefault(),constants.SpeedUp(),tt(),display.announceText("Speed up")),","==t.key&&(t.preventDefault(),constants.SpeedDown(),tt(),display.announceText("Speed down")),"/"==t.key&&(t.preventDefault(),constants.SpeedReset(),tt(),display.announceText("Speed reset"))}]);function tt(){null!=constants.autoplayId&&(constants.KillAutoplay(),it("reverse-left"==W?"right":"reverse-right"==W?"left":W,position.x,Z))}function et(){let t=!1;return position.x<0&&(position.x=0,t=!0),position.x>plot.plotData.length-1&&(position.x=plot.plotData.length-1,t=!0),t}function nt(){constants.showDisplay&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones()}function st(){constants.showDisplayInAutoplay&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones(),"off"!=constants.brailleMode&&display.UpdateBraillePos()}function ot(){constants.showDisplayInBraille&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones(),display.UpdateBraillePos()}function it(t,e,n){W=t;let s=1;"left"!=t&&"reverse-right"!=t||(s=-1),null!=constants.autoplayId&&constants.KillAutoplay(),"reverse-right"!=t&&"reverse-left"!=t||(position.x=e),constants.autoplayId=setInterval((function(){position.x+=s,position.x<0||plot.plotData.length-1plot.level.length-1&&(position.x=plot.plotData.length-1,t=!0),position.y<0&&(position.y=0,t=!0),position.y>plot.fill.length-1&&(position.y=plot.fill.length-1,t=!0),t}function ht(){constants.showDisplay&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones()}function ut(){constants.showDisplayInAutoplay&&display.displayValues(),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones(),"off"!=constants.brailleMode&&display.UpdateBraillePos()}function yt(){constants.showDisplayInBraille&&(display.SetBraille(),display.displayValues()),constants.showRect&&constants.hasRect&&plot.Select(),"off"!=constants.sonifMode&&plot.PlayTones(),display.UpdateBraillePos()}function gt(t,e,n){lt=t;let s=1;"left"!=t&&"down"!=t&&"reverse-right"!=t&&"reverse-up"!=t||(s=-1),null!=constants.autoplayId&&constants.KillAutoplay(),"reverse-left"==t||"reverse-right"==t?position.x=e:"reverse-up"!=t&&"reverse-down"!=t||(position.y=e),constants.autoplayId=setInterval((function(){"left"==t||"right"==t||"reverse-left"==t||"reverse-right"==t?(position.x+=s,position.x<0||plot.plotData.length-1t.target.value.length-2||((constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x-=1,Dt("right",position.x,plot.pointValuesY.length)):(position.x=plot.pointValuesY.length-1,e=!0,n=_t()):t.altKey&&t.shiftKey&&position.x!=plot.pointValues.length-1?(constants.lastx=position.x,Dt("reverse-right",plot.pointValuesY.length,position.x)):(position.x+=1,e=!0,n=_t()))):"ArrowLeft"==t.key?(t.preventDefault(),(constants.isMac?t.metaKey:t.ctrlKey)?t.shiftKey?(position.x+=1,Dt("left",position.x,-1)):(position.x=0,e=!0,n=_t()):t.altKey&&t.shiftKey&&0!=position.x?(constants.lastx=position.x,Dt("reverse-left",-1,position.x)):(position.x+=-1,e=!0,n=_t())):"Tab"==t.key||t.preventDefault(),e&&!n&&Et(),n&&audio.playEnd()}]);let vt=[constants.chart,constants.brailleInput],Mt=0;for(let St=0;Stplot.pointValuesY.length-1&&(position.x=plot.pointValuesY.length-1,t=!0),t}function Lt(){constants.showDisplay&&display.displayValues(),constants.showRect&&ft.UpdatePointDisplay(),"off"!=constants.sonifMode&&plot.PlayTones()}function wt(){constants.showDisplayInAutoplay&&display.displayValues(),constants.showRect&&ft.UpdatePointDisplay(),"off"!=constants.sonifMode&&plot.PlayTones(),"off"!=constants.brailleMode&&display.UpdateBraillePos()}function Et(){constants.showDisplayInBraille&&display.displayValues(),constants.showRect&&ft.UpdatePointDisplay(),"off"!=constants.sonifMode&&plot.PlayTones(),display.UpdateBraillePos()}function Dt(t,e,n){xt=t;let s=1;"left"!=t&&"reverse-right"!=t||(s=-1),null!=constants.autoplayId&&constants.KillAutoplay(),"reverse-right"!=t&&"reverse-left"!=t||(position.x=e),constants.autoplayId=setInterval((function(){position.x+=s,position.x<0||plot.pointValuesY.length-1-1&&constants.focusables.splice(e,1),n>e&&n--}}}function InitMaidr(t){if("undefined"!=typeof constants){window.singleMaidr=t,constants.chartId=singleMaidr.id,Array.isArray(singleMaidr.type)?constants.chartType=singleMaidr.type[0]:constants.chartType=singleMaidr.type,CreateChartComponents(singleMaidr),window.control=new Control,window.review=new Review,window.display=new Display,window.audio=new Audio;let e=[constants.chart,constants.brailleInput,constants.review];for(let t=0;t{0==constants.tabMovement?constants.tabMovement=null:(1!=constants.tabMovement&&-1!=constants.tabMovement||FocusBeforeOrAfter(),DestroyMaidr())}),0)}function FocusBeforeOrAfter(){if(1==constants.tabMovement){let t=document.createElement("div");t.setAttribute("tabindex","0"),constants.main_container.after(t),t.focus(),t.remove()}else if(-1==constants.tabMovement){let t=document.createElement("div");t.setAttribute("tabindex","0"),constants.main_container.before(t),t.focus(),t.remove()}}function DestroyMaidr(){"bar"!=constants.chartType&&"hist"!=constants.chartType||("function"==typeof plot.DeselectAll&&plot.DeselectAll(),"function"==typeof plot.UnSelectPrevious&&plot.UnSelectPrevious());for(let t=0;t