Files
Probability-and-Statistics-…/_static/prefix-runestone.5555907f139e2014.bundle.js
2026-08-01 15:00:14 +00:00

2 lines
54 KiB
JavaScript

(self.webpackChunkWebComponents=self.webpackChunkWebComponents||[]).push([[222],{19695:()=>{var e=[],t=!1;function n(){return[...document.querySelectorAll("section *")].filter((e=>!e.matches("h1, .presentation-title, .btn-presenter, .runestone, .runestone *, section, .pre, code")))}function o(){t||(function(){for(const e of document.querySelectorAll("[data-childcomponent]")){e.classList.add("runestone");const t=e.parentElement?.closest("div");t&&!t.matches("section")&&(t.classList.add("runestone"),t.style.maxWidth="none");const n=e.querySelectorAll(".ac_code_div, .ac_output");if(n.length){const e=document.createElement("div");e.className="ac-block",e.style.width="100%",n[0].before(e);for(const t of n)e.appendChild(t)}}for(const e of document.querySelectorAll("section img")){const t=document.createElement("div");t.className="runestone",e.replaceWith(t),t.appendChild(e)}e=[...document.querySelectorAll(".runestone")].filter((e=>!e.parentElement.closest(".runestone")));for(const e of document.querySelectorAll("h1"))e.insertAdjacentHTML("beforebegin","<div class='presentation-title'> <button class='prev-exercise btn-presenter btn-grey-outline' onclick='prevExercise()'>Back</button> <button class='next-exercise btn-presenter btn-grey-solid' onclick='nextExercise()'>Next</button> </div>")}(),t=!0);let o=document.body,s="present",r="full-height",a="bottom";if(o.classList.contains(s)){for(const e of n())e.classList.remove("hidden");document.getElementById("completionButton")?.classList.remove("hidden"),o.classList.remove(s);for(const e of document.querySelectorAll("."+r))e.classList.remove(r);for(const e of document.querySelectorAll("."+a))e.classList.remove(a);localStorage.setItem("presentMode","text");for(const t of e)t.classList.remove("hidden")}else{for(const e of n())e.classList.add("hidden");document.getElementById("completionButton")?.classList.add("hidden"),o.classList.add(s),o.classList.add(r),document.documentElement.classList.add(r);for(const e of document.querySelectorAll("section .runestone"))e.classList.add(r);for(const e of document.querySelectorAll(".ac-caption"))e.classList.add(a);localStorage.setItem("presentMode",s),i()}}function s(){return e.filter((e=>e.classList.contains("active")))}function i(t){if(void 0===t&&(t=0),e.length){for(const e of s())e.classList.remove("active");const n=e[t];n.classList.add("active"),n.classList.remove("hidden");for(const t of e)t!==n&&t.classList.add("hidden")}}window.nextExercise=function(){let t=s()[0],n=e.indexOf(t)+1;n<e.length&&i(n)},window.prevExercise=function(){let t=s()[0],n=e.indexOf(t)-1;n>=0&&i(n)},document.addEventListener("runestone:login-complete",(function(){eBookConfig.isInstructor&&function(){let e=document.querySelector(".navbar-right");e&&(e.insertAdjacentHTML("afterbegin","<li class='dropdown view-toggle'> <label>View: <select class='mode-select'> <option value='text'>Textbook</option> <option value='present'>Code Presenter</option> </select> </label> </li>"),document.querySelector(".mode-select").addEventListener("change",o))}()}))},34089:(e,t,n)=>{"use strict";n.d(t,{BM:()=>i,DK:()=>l,Gq:()=>a,Qt:()=>s,i0:()=>m});const o=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/;function s(e,t){const n=e.getAttribute(`data-${t}`);if(null!==n){if("true"===n)return!0;if("false"===n)return!1;if("null"===n)return null;if(n===+n+"")return+n;if(o.test(n))try{return JSON.parse(n)}catch(e){return n}return n}}function i(e){e&&(r(e)?(e.style.display="",r(e)&&(e.style.display="block")):e.style.display="none")}function r(e){return"none"===e.style.display||"none"===e.ownerDocument.defaultView.getComputedStyle(e).display}function a(e){const t=getComputedStyle(e);return e.getBoundingClientRect().width+(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0)}function l(e){const t=getComputedStyle(e);return e.getBoundingClientRect().height+(parseFloat(t.marginTop)||0)+(parseFloat(t.marginBottom)||0)}const c=new Set(["opacity","zIndex","fontWeight"]),d=/-([a-z])/g,u=e=>e.replace(d,((e,t)=>t.toUpperCase()));function p(e){if(!e)return null;let t=e.match(/^#([0-9a-f]{3})$/i);return t?[...t[1]].map((e=>parseInt(e+e,16))):(t=e.match(/^#([0-9a-f]{6})$/i),t?[0,2,4].map((e=>parseInt(t[1].slice(e,e+2),16))):(t=e.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)/),t?[+t[1],+t[2],+t[3]]:null))}function m(e,t,n={}){const o=n.duration??400,s=getComputedStyle(e),i=[];for(const[n,o]of Object.entries(t)){const t=u(n);if("number"==typeof o){const n=parseFloat(s[t])||0,r=c.has(t)?"":"px";i.push((s=>{e.style[t]=n+(o-n)*s+r}))}else{const n=p(s[t]),r=p(o);n&&r?i.push((o=>{const s=n.map(((e,t)=>Math.round(e+(r[t]-e)*o)));e.style[t]=`rgb(${s.join(", ")})`})):i.push((n=>{1===n&&(e.style[t]=o)}))}}n.start&&n.start();const r=performance.now();requestAnimationFrame((function e(t){const s=Math.min(1,(t-r)/o);for(const e of i)e(s);n.progress&&n.progress(null,s,null),s<1?requestAnimationFrame(e):n.complete&&n.complete()}))}},41669:e=>{"use strict";e.exports=jQuery},58942:(e,t,n)=>{"use strict";n.d(t,{w:()=>b}),n(67375);var o=n(83057),s=n(34089);async function i(e,t){let n=t?`${e}?${new URLSearchParams(t)}`:e;try{let e=await fetch(n);if(!e.ok)return console.log("Request Failed for "+n),null;let t=await e.text();return"None"==t||""===t?null:JSON.parse(t)}catch(e){return console.log("Request Failed for "+n),console.log(e),null}}function r(e,t,n,o){e.classList.add(t);let s=document.createElement("span");s.className=n,s.textContent=o,e.appendChild(s);let i=e.children[0];i&&i!==s&&(i.addEventListener("mouseenter",(function(){s.style.display=""})),i.addEventListener("mouseleave",(function(){s.style.display="none"})))}function a(){return!!document.querySelector("body.pretext")}async function l(e,t,n,o){var s=window.location.pathname;-1!==s.indexOf("?")&&(s=s.substring(0,s.lastIndexOf("?")));let i=a();var r={lastPageUrl:s,lastPageScrollLocation:Math.round(window.scrollY),completionFlag:e,pageLoad:t,markingComplete:n,markingIncomplete:o,course:eBookConfig.course,isPtxBook:i};let l=`${eBookConfig.new_server_prefix}/logger/updatelastpage`;try{await fetch(l,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(r)})}catch(e){console.log("Request Failed for "+l),console.log(e)}}document.addEventListener("runestone:login",(async function(){var e;await async function(){if(!(0,o.ex)()){var e=window.location.pathname;-1!==e.indexOf("?")&&(e=e.substring(0,e.lastIndexOf("?")));var t=await i(`${eBookConfig.new_server_prefix}/logger/getCompletionStatus`,{lastPageUrl:e,isPtxBook:a()});if(t){var n,s;1==t.detail[0].completionStatus?(n="buttonConfirmCompletion",s="<i class='glyphicon glyphicon-ok'></i> Completed. Well Done!"):(n="buttonAskCompletion",s="Mark as Completed");let e=document.querySelector("#scprogresscontainer");e&&(e.classList.add("ptx-runestone-container"),e.insertAdjacentHTML("beforeend",'<div style="text-align:center"><button class="btn btn-lg '+n+'" id="completionButton">'+s+"</button></div>"))}}}(),null!==(e=new URLSearchParams(window.location.search).get("lastPosition"))&&(document.body.insertAdjacentHTML("beforeend",'<img src="../_static/last-point.png" style="position:absolute; padding-top:55px; left: 10px; top: '+parseInt(e)+'px;"/>'),window.scrollTo({top:parseInt(e),behavior:"smooth"})),function(){if(!(0,o.ex)()){var e,t=document.getElementById("completionButton"),n=document.getElementById("navLinkBgRight"),i=document.getElementById("navLinkBgLeft"),r=document.getElementById("relations-next"),a=n?-(0,s.Gq)(n)-5:-5;t?.classList.contains("buttonAskCompletion")?e=a+70:t?.classList.contains("buttonConfirmCompletion")&&(e=0);var c=r?getComputedStyle(r).right:"0px",d=-(a+35);if(n){n.style.right=a+"px",n.style.display="";var u=!1;window.addEventListener("scroll",(function(){window.scrollY+window.innerHeight>=document.documentElement.scrollHeight?((0,s.i0)(n,{right:e},{duration:200}),i&&(0,s.i0)(i,{left:0},{duration:200}),r&&t?.classList.contains("buttonConfirmCompletion")&&(0,s.i0)(r,{right:d},{duration:200}),u=!0):u&&((0,s.i0)(n,{right:a},{duration:200}),i&&(0,s.i0)(i,{left:-65},{duration:200}),r&&(0,s.i0)(r,{right:c}),u=!1)}))}var p=0;l(p=t?.classList.contains("buttonAskCompletion")?0:1,!0,!1,!1),t?.addEventListener("click",(function(){var o=!1,i=!1;t.classList.contains("buttonAskCompletion")?(t.classList.remove("buttonAskCompletion"),t.classList.add("buttonConfirmCompletion"),t.innerHTML="<i class='glyphicon glyphicon-ok'></i> Completed. Well Done!",n&&(0,s.i0)(n,{right:0}),r&&(0,s.i0)(r,{right:d}),e=0,p=1,o=!0):t.classList.contains("buttonConfirmCompletion")&&(t.classList.remove("buttonConfirmCompletion"),t.classList.add("buttonAskCompletion"),t.innerHTML="Mark as Completed",e=a+70,n&&(0,s.i0)(n,{right:e}),r&&(0,s.i0)(r,{right:c}),p=0,i=!0),l(p,!1,o,i)}))}}(),await async function(){if(-1!=window.location.href.toLowerCase().indexOf("toc.html")||-1!=window.location.href.toLowerCase().indexOf("index.html")||-1!=window.location.href.toLowerCase().indexOf("frontmatter")){if(!a()){let t=await i(`${eBookConfig.new_server_prefix}/logger/getAllCompletionStatus`);if(t){let n=t.detail,o=document.querySelectorAll("#main-content div li a");for(let t of n)for(var e=0;e<o.length;e++)-1!=o[e].href.indexOf(t.chapterName+"/"+t.subChapterName)&&(1==t.completionStatus?r(o[e].parentElement,"completed","infoTextCompleted","- Completed this topic on "+t.endDate):0==t.completionStatus&&r(o[e].parentElement,"active","infoTextActive","Last read this topic on "+t.endDate))}}let t=await i(`${eBookConfig.new_server_prefix}/logger/getlastpage`,{course:eBookConfig.course});if(t){let e=t.detail;if(null!=e.lastPageChapter){let t=document.getElementById("continue-reading");t&&(t.style.display="",t.innerHTML='<div id="jump-to-chapter" class="alert alert-info" ><strong>You were Last Reading:</strong> '+e.lastPageChapter+(e.lastPageSubchapter?" &gt; "+e.lastPageSubchapter:"")+' <a href="'+e.lastPageUrl+"?lastPosition="+e.lastPageScrollLocation+'">Continue Reading</a></div>')}}}}()}));var c=n(78673);window.addEventListener("load",(function(){console.log("setting up pretext"),function(){let e=new c.A;document.querySelectorAll("[data-knowl]").forEach((t=>{t.addEventListener("click",(function(){let n=t.getAttribute("data-knowl");e.logBookEvent({event:"knowl",act:"click",div_id:n})}))})),document.querySelectorAll("details.born-hidden-knowl").forEach((t=>{t.addEventListener("toggle",(function(){if(t.open){let n=t.id;e.logBookEvent({event:"knowl",act:"open",div_id:n})}}))})),document.querySelectorAll(".sagecell_evalButton").forEach((t=>{t.addEventListener("click",(function(){let n=t.closest(".ptx-sagecell"),o=n?n.querySelector(".sagecell_input"):null,s=(o&&o.textContent,n?n.id:null);s?e.logBookEvent({event:"sage",act:"run",div_id:s}):console.warn("Could not find container or div_id for sagecell button")}))})),"undefined"==typeof eBookConfig||eBookConfig.isInstructor||document.querySelectorAll(".commentary").forEach((e=>{e.style.display="none"}))}();let e=document.getElementById("primary-navbar-sticky-wrapper");e&&(e.style.overflow="visible")})),n(19695);var d=n(98098);class u extends c.A{constructor(){super(),this.graderFrames=new Map,this.initSplice()}registerGraderFrame(e,t){this.graderFrames.set(e,t)}unregisterGraderFrame(e){this.graderFrames.delete(e)}handleGraderFrameMessage(e,t){"SPLICE.getState"==e.data.subject&&e.source.postMessage({message_id:e.data.message_id,subject:"SPLICE.getState.response",state:t},"*")}initSplice(){window.addEventListener("message",(async e=>{var t,n,o=this.sendingIframe(e);if(console.log(`SpliceWrapper: received message subject: ${e.data.subject} from iframe: ${o?o.id:"unknown"}`),o&&this.graderFrames.has(o))this.handleGraderFrameMessage(e,this.graderFrames.get(o));else if("SPLICE.reportScoreAndState"==e.data.subject)this.handleScoreAndState(e,o);else if("SPLICE.sendEvent"==e.data.subject)this.handleSpliceEvent(e,o);else if("SPLICE.getState"==e.data.subject)await this.handleGetState(e,o);else if("https://www.myopenmath.com"===e.origin&&"string"==typeof e.data&&-1!=e.data.indexOf("lti.ext.imathas.result")){let o=JSON.parse(e.data),s=(t=o.jwt.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(window.atob(t).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join("")),JSON.parse(n));console.log("Result received from frame "+o.frame_id+" with score "+s.score)}}))}getUniqueID(e,t){if(t){let e=t.closest("[data-component]");if(e)return e.id}let n=e.data.activity_id;return n||(t?n=t.src:(n="unknown",console.error("Could not find iframe that sent the SPLICE event"))),n}handleScoreAndState(e,t){console.log("Got SPLICE.reportScoreAndState"),console.log(e.data.activity_id),console.log(e.data.score),console.log(e.data.state);let n=this.getUniqueID(e,t);this.logBookEvent({event:e.data.subject,div_id:n,act:`score: ${e.data.score}`,score:e.data.score,percent:e.data.score,correct:1==e.data.score,answer:JSON.stringify(e.data.state)})}sendingIframe(e){for(const t of document.getElementsByTagName("iframe"))if(t.contentWindow===e.source)return t}async getSavedState(e){try{const t=await fetch("/ns/assessment/results",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({div_id:e,course:eBookConfig.course,event:"SPLICE.getState"})});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}catch(e){return console.error("Error fetching SPLICE state:",e),null}}async handleGetState(e,t){console.log("Got SPLICE.getState"),console.log(e.data.activity_id),console.log(e.data.state);let n=this.getUniqueID(e,t),o=await this.getSavedState(n),s=null==o?void 0:o.detail.answer;e.source.postMessage({message_id:e.data.message_id,subject:"SPLICE.getState.response",state:s},"*")}handleSpliceEvent(e,t){console.log("Got SPLICE.sendEvent"),console.log(e.data.activity_id),console.log(e.data.name);let n=this.getUniqueID(e,t);this.logBookEvent({event:e.data.subject,div_id:n,act:e.data.name||"unknown"})}checkLocalStorage(){}setLocalStorage(){}restoreAnswers(){}disableInteraction(){}}const p={activecode:()=>Promise.all([n.e(249),n.e(428),n.e(764),n.e(877)]).then(n.bind(n,73565)),clickablearea:()=>Promise.all([n.e(529),n.e(817)]).then(n.bind(n,58529)),codelens:()=>Promise.all([n.e(764),n.e(412)]).then(n.bind(n,76412)),datafile:()=>n.e(580).then(n.bind(n,33580)),dragndrop:()=>Promise.all([n.e(349),n.e(114)]).then(n.bind(n,83349)),fillintheblank:()=>Promise.all([n.e(139),n.e(497)]).then(n.bind(n,98139)),groupsub:()=>n.e(616).then(n.bind(n,24616)),matching:()=>Promise.all([n.e(566),n.e(964)]).then(n.bind(n,14566)),multiplechoice:()=>Promise.all([n.e(919),n.e(350)]).then(n.bind(n,9919)),hparsons:()=>Promise.all([n.e(249),n.e(583),n.e(49)]).then(n.bind(n,97401)),parsons:()=>Promise.all([n.e(420),n.e(250)]).then(n.bind(n,52420)),poll:()=>n.e(168).then(n.bind(n,11168)),selectquestion:()=>Promise.all([n.e(662),n.e(380)]).then(n.bind(n,10662)),shortanswer:()=>Promise.all([n.e(819),n.e(850)]).then(n.bind(n,48819)),showeval:()=>n.e(824).then(n.bind(n,8824)),tabbedStuff:()=>n.e(442).then(n.bind(n,76442)),timedAssessment:()=>Promise.all([n.e(249),n.e(428),n.e(764),n.e(877),n.e(420),n.e(139),n.e(349),n.e(919),n.e(566),n.e(662),n.e(529),n.e(819),n.e(506)]).then(n.bind(n,46424)),webwork:()=>n.e(680).then(n.bind(n,84680)),youtube:()=>n.e(915).then(n.bind(n,86915)),doenet:()=>Promise.resolve()},m={},g=10,h=[];let f=0;async function y(){if(0===h.length)return;if(Date.now()-f<g)return void window.setTimeout(y,g+1);f=Date.now();const e=[...h];h.length=0,console.log("Webpack is starting the loading process for the following Runestone modules",e.map((e=>e.component_name)));const t=e.map((async e=>{try{return await p[e.component_name](),console.log(`Runestone component ${e.component_name} has been loaded`),e}catch(t){e.reject(t)}})),n=await Promise.all(t);try{n.forEach((function(e){e&&e.resolve()}))}catch(e){console.error(e)}}let v=new Promise((e=>document.addEventListener("runestone:pre-login-complete",e)));function w(){const e=new Set([...document.querySelectorAll("[data-component]")].map((e=>e.getAttribute("data-component"))));document.querySelector(".webwork-button")&&e.add("webwork");const t=[...e].map((e=>{let t;console.log(`Loading Runestone component: ${e}`);try{t=(p[e]||(()=>Promise.resolve()))()}catch(t){console.error(`Error loading ${e}:`,t)}return t.error=t=>console.error(`Error in ${e}:`,t),t}));Promise.all([v,...t]).then((function(){document.body.dataset.reactInUse||document.dispatchEvent(new CustomEvent("runestone:login-complete"))}))}async function b(e){if(m[e])return m[e];console.log(`Runestone component ${e} is being queued for import`);const t=function(e){let t=null,n=null;const o=new Promise(((e,o)=>{t=e,n=o})),s={component_name:e,resolve:t,reject:n};return h.push(s),window.setTimeout(y,g+1),o}(e);return m[e]=t,t}v.then((()=>{console.log("Runestone pre-login complete")})),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",w):w();const C=document.currentScript.src;n.p=C.substring(0,C.lastIndexOf("/")+1);var S=new u;window.spliceWrapper=S;const k={};k.runestone_import=b,k.runestone_auto_import=w,k.getSwitch=function(){const e=document.querySelector('.theme-switch input[type="checkbox"]'),t=localStorage.getItem("theme")?localStorage.getItem("theme"):null;t&&(document.documentElement.setAttribute("data-theme",t),"dark"===t&&(e.checked=!0))},k.switchTheme=function(){1==document.getElementById("checkbox").checked?(document.documentElement.setAttribute("data-theme","dark"),localStorage.setItem("theme","dark")):(document.documentElement.setAttribute("data-theme","light"),localStorage.setItem("theme","light"))},k.popupScratchAC=async function(){if(await b("activecode"),!eBookConfig.scratchDiv){window.ACFactory.createScratchActivecode();let e=eBookConfig.scratchDiv;window.componentMap[e]=ACFactory.createActiveCode(document.getElementById(e),eBookConfig.acDefaultLanguage),eBookConfig.isLoggedIn&&window.componentMap[e].enableSaveLoad()}setTimeout((()=>{window.ACFactory.toggleScratchActivecode()}),100)},k.renderOneComponent=d.yT,window.componentMap={},window.runestoneComponents=k},78673:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var o=n(83057),s=n(34089),i=["parsonsMove","showeval","video","poll","view_toggle","dashboard","selectquestion","codelens","peer"];class r{constructor(e){this.component_ready_promise=new Promise((e=>this._component_ready_resolve_fn=e)),this.optional=!1,void 0===window.allComponents&&(window.allComponents=[]),window.allComponents.push(this),e&&(this.sid=e.sid,this.graderactive=e.graderactive,this.showfeedback=!0,e.timed&&(this.isTimed=!0),e.enforceDeadline&&(this.deadline=e.deadline),this.optional=this.parseBooleanAttribute(e.orig,"data-optional"),e.selector_id&&(this.selector_id=e.selector_id),void 0!==e.assessmentTaken?this.assessmentTaken=e.assessmentTaken:this.assessmentTaken=!0,void 0!==e.timedWrapper?this.timedWrapper=e.timedWrapper:location.href.indexOf("doAssignment")>=0?this.timedWrapper=document.querySelector("h1#assignment_name")?.textContent||"":this.timedWrapper=null,e.orig&&(0,s.Qt)(e.orig,"question_label")&&(this.question_label=(0,s.Qt)(e.orig,"question_label")),this.is_toggle=e.is_toggle,this.is_select=e.is_select),this.mjelements=[];let t=this;if(this.mjReady=new Promise((function(e,n){t.mjresolver=e})),this.aQueue=new l,e&&void 0!==e.preamble){this.preamble=e.preamble;let t=document.createElement("div");t.classList.add("hidden-content"),t.classList.add("process-math"),t.innerHTML="\\("+this.preamble+"\\)",e.orig.appendChild(t),t.id="ltx_preamble",t.style.display="none",this.aQueue.preamble=t}this.jsonHeaders=new Headers({"Content-type":"application/json; charset=utf-8",Accept:"application/json"})}parseBooleanAttribute(e,t){const n=e.getAttribute(t);if(null===n)return!1;const o=n.toLowerCase();return"false"!==o&&"no"!==o}async logBookEvent(e){if(this.graderactive)return;let t;if(e.course_name=eBookConfig.course,e.clientLoginStatus=eBookConfig.isLoggedIn,e.timezoneoffset=(new Date).getTimezoneOffset()/60,this.selector_id&&(e.selector_id=this.selector_id),"number"==typeof this.percent&&(e.percent=this.percent),window.assignmentId&&(e.assignment_id=window.assignmentId),eBookConfig.isLoggedIn&&eBookConfig.useRunestoneServices&&eBookConfig.logLevel>0&&(t=this.postLogMessage(e)),!this.isTimed||eBookConfig.debug){let t=eBookConfig.isLoggedIn?"Save":"Not";console.log(`${t} logging event `+JSON.stringify(e))}return this.selector_id&&(e.div_id=this.selector_id.replace("-toggleSelectedQuestion",""),e.event="selectquestion",e.act="interaction",this.postLogMessage(e)),"function"==typeof o.Xw.updateProgress&&"edit"!=e.act&&0==this.optional&&o.Xw.updateProgress(e.div_id),-1===i.indexOf(e.event)&&this.decorateStatus(),t}async postLogMessage(e){var t;let n=new Request(`${eBookConfig.new_server_prefix}/logger/bookevent`,{method:"POST",headers:this.jsonHeaders,body:JSON.stringify(e)});try{var o=await fetch(n);if(!o.ok){if(422===o.status)throw t=await o.json(),console.log(JSON.stringify(t.detail,null,4)),new Error("Unprocessable Request");if(401==o.status)throw t=await o.json(),console.log(`Missing authentication token ${t.detail}`),new Error("Missing authentication token");throw new Error(`Failed to save the log entry\n Status: ${o.status}`)}let e=(t=await o.json()).detail,s=null;if(this.selector_id){let e=this.selector_id.replace("-toggleSelectedQuestion","");s=document.getElementById(`${e}_score`)}else s=document.getElementById(`${this.divid}_score`);s&&!this.isTimed&&e&&this.updateScores(s,e)}catch(e){let n="none";t&&t.detail&&(n=t.detail),eBookConfig.useRunestoneServices&&alert(`Error: Your action was not saved!\n The error was ${e}\n Status Code: ${o.status}\n Detail: ${JSON.stringify(n,null,4)}.\n Please report this error!`),console.log(`Error: ${e} Detail: ${n} Status Code: ${o.status}`)}return t}updateScores(e,t){if(!t.assigned||null===t.score)return void(document.getElementById(`${this.divid}_message`).innerHTML="Score not updated. Submissions are closed.");let n=e.getElementsByClassName("qscore")[0];n&&(n.innerHTML=t.score.toFixed(1));let o=document.getElementsByClassName("qscore"),s=document.getElementsByClassName("qmaxscore"),i=0,r=0;for(let e=0;e<o.length;e++)i+=parseFloat(o[e].innerHTML),r+=parseFloat(s[e].innerHTML);let a=document.getElementById("total_score");a&&(a.innerHTML=i.toFixed(1));let l=document.getElementById("total_max");l&&(l.innerHTML=r);let c=document.getElementById("total_percent");c&&(c.innerHTML=(i/r*100).toFixed(2))}async logRunEvent(e){let t="done";if(!this.graderactive){if(e.course=eBookConfig.course,e.clientLoginStatus=eBookConfig.isLoggedIn,e.timezoneoffset=(new Date).getTimezoneOffset()/60,(this.forceSave||"to_save"in e==0)&&(e.save_code="True"),void 0!==e.errinfo&&(e.errinfo=e.errinfo.toString()),eBookConfig.isLoggedIn&&eBookConfig.useRunestoneServices&&eBookConfig.logLevel>0){let n=new Request(`${eBookConfig.new_server_prefix}/logger/runlog`,{method:"POST",headers:this.jsonHeaders,body:JSON.stringify(e)}),o=await fetch(n);o.ok?t=await o.json():(t=await o.json(),eBookConfig.useRunestoneServices?alert(`Failed to save your code\n Status is ${o.status}\n Detail: ${JSON.stringify(t.detail,null,4)}`):console.log(`Did not save the code.\n Status: ${o.status}\n Detail: ${JSON.stringify(t.detail,null,4)}`))}return this.isTimed&&!eBookConfig.debug||console.log("running "+JSON.stringify(e)),"function"==typeof o.Xw.updateProgress&&0==this.optional&&o.Xw.updateProgress(e.div_id),t}}async checkServer(e,t=!1){let n=this;if(this.checkServerComplete=new Promise((function(e,t){n.csresolver=e})),eBookConfig.isLoggedIn&&(this.useRunestoneServices||this.graderactive)){let t={};if(t.div_id=this.divid,t.course=eBookConfig.course,t.event=e,this.graderactive&&this.deadline&&(t.deadline=this.deadline,t.rawdeadline=this.rawdeadline,t.tzoff=this.tzoff),this.sid&&(t.sid=this.sid),t.div_id&&t.course&&t.event||console.log(`A required field is missing data ${t.div_id}:${t.course}:${t.event}`),eBookConfig.practice_mode||eBookConfig.peer||!this.assessmentTaken)this.loadData({}),console.log("resolving checkServer no answer given"),this.csresolver("not taken");else{let e=new Request(`${eBookConfig.new_server_prefix}/assessment/results`,{method:"POST",body:JSON.stringify(t),headers:this.jsonHeaders});try{let n=await fetch(e);console.log(`Response from server: ${n.status}`),n.ok?(t=await n.json(),t=t.detail,console.log(`Data from server: ${JSON.stringify(t)} calling repopulateFromStorage`),this.repopulateFromStorage(t),this.attempted=!0,void 0!==t.correct?this.correct=t.correct:this.correct=null,console.log("resolving checkServer with server data"),this.csresolver("server")):(console.log(`HTTP Error getting results: ${n.statusText}`),this.checkLocalStorage(),console.log("resolving checkServer with local data"),this.csresolver("local"))}catch(e){console.log(`Error getting results: ${e}`);try{this.checkLocalStorage()}catch(e){console.log(e)}}}}else this.checkLocalStorage(),console.log("resolving checkServer with local data"),this.csresolver("local");t&&this.indicate_component_ready()}indicate_component_ready(){this.containerDiv.classList.add("runestone-component-ready"),this._component_ready_resolve_fn()}loadData(e){return null}repopulateFromStorage(e){null!==e&&"no data"!==e&&this.shouldUseServer(e)?(this.restoreAnswers(e),this.setLocalStorage(e)):this.checkLocalStorage(),this.decorateStatus()}shouldUseServer(e){if("T"===e.correct||!0===e.correct||0===localStorage.length||!0===this.graderactive||this.isTimed)return!0;let t,n=localStorage.getItem(this.localStorageKey());if(null===n)return!0;try{t=JSON.parse(n)}catch(e){return console.log(e.message),localStorage.removeItem(this.localStorageKey()),!0}if(e.answer==t.answer)return!0;let o=new Date(t.timestamp);return new Date(e.timestamp)>=o}localStorageKey(){return eBookConfig.email+":"+eBookConfig.course+":"+this.divid+"-given"}addCaption(e){if(!this.isTimed){var t=document.createElement("p");this.question_label?(this.caption=eBookConfig.useRunestoneServices?`Activity: ${this.question_label} ${this.caption} <span class="runestone_caption_divid">(${this.divid})</span>`:`Activity: ${this.question_label} ${this.caption}`,t.innerHTML=this.caption,t.classList.add(`${e}_caption`)):(t.innerHTML=eBookConfig.useRunestoneServices?this.caption+" ("+this.divid+")":this.caption,t.classList.add(`${e}_caption`),t.classList.add(`${e}_caption_text`)),this.capDiv=t,this.containerDiv.appendChild(t)}}hasUserActivity(){return this.isAnswered}checkCurrentAnswer(){console.log("Each component should provide an implementation of checkCurrentAnswer")}async logCurrentAnswer(){console.log("Each component should provide an implementation of logCurrentAnswer")}renderFeedback(){console.log("Each component should provide an implementation of renderFeedback")}disableInteraction(){console.log("Each component should provide an implementation of disableInteraction")}toString(){return`${this.constructor.name}: ${this.divid}`}queueMathJax(e){return"undefined"==typeof MathJax?(console.log("Error -- MathJax is not loaded"),Promise.resolve(null)):MathJax.typesetPromise?void 0!==window.runestoneMathReady?window.runestoneMathReady.then((()=>this.mjresolver(this.aQueue.enqueue(e)))):this.mjresolver(this.aQueue.enqueue(e)):(console.log(`Waiting on MathJax!! ${MathJax.typesetPromise}`),setTimeout((()=>this.queueMathJax(e)),200),console.log(`Returning mjready promise: ${this.mjReady}`),this.mjReady)}decorateStatus(){if(this.isTimed||eBookConfig.peer)return;let e=this.containerDiv?this.containerDiv.closest("div.runestone"):null;if(!e)return;e.classList.remove("notAnswered"),e.classList.remove("isInCorrect"),e.classList.remove("isCorrect");let t=localStorage.getItem(`currentAssignmentInfo_${eBookConfig.course}`),n=[];t&&(n=JSON.parse(t).questions),n.indexOf(this.divid)>=0&&e.classList.add("isAssigned"),this.correct?e.classList.add("isCorrect"):null===this.correct||void 0===this.correct?e.classList.add("notAnswered"):e.classList.add("isInCorrect")}}class a{constructor(){this._items=[]}enqueue(e){this._items.push(e)}dequeue(){return this._items.shift()}get size(){return this._items.length}}class l extends a{constructor(){super(),this._pendingPromise=!1}enqueue(e){return new Promise(((t,n)=>{super.enqueue({component:e,resolve:t,reject:n}),this.dequeue()}))}async dequeue(){if(this._pendingPromise)return!1;let e=super.dequeue();if(!e)return!1;let t=this;try{this._pendingPromise=!0;let n=await window.runestoneMathReady.then((async function(){return console.log(`MathJax Ready -- dequeing a typesetting run for ${e.component.id} ${t.preamble?.innerHTML}`),t.preamble&&(await MathJax.typesetPromise([t.preamble]),console.log(`MathJax typeset the preamble for ${e.component.id}`)),await MathJax.typesetPromise([e.component])}));this._pendingPromise=!1,e.resolve(n)}catch(t){this._pendingPromise=!1,e.reject(t)}finally{this.dequeue()}return!0}}window.RunestoneBase=r},83057:(e,t,n)=>{"use strict";n.d(t,{Xw:()=>p,ex:()=>d,uD:()=>h});var o=n(78673),s=n(60023),i=new o.A;const r=[];function a(e){if("string"==typeof e)return e;if(e instanceof Error)return`${e.name}: ${e.message}`;try{return JSON.stringify(e)}catch(t){return String(e)}}function l(e,t){try{const n=`[${e}] ${Array.from(t).map(a).join(" ")}`;r.push(n),r.length>200&&r.shift()}catch(e){}}!function(){if(!window.__rsConsoleCaptureInstalled){window.__rsConsoleCaptureInstalled=!0;for(const e of["log","info","warn","error"]){const t=console[e]?console[e].bind(console):null;console[e]=function(...n){l(e,n),t&&t(...n)}}window.addEventListener("error",(e=>{e.message&&l("uncaught",[`${e.message} @ ${e.filename||"?"}:${e.lineno||"?"}`])})),window.addEventListener("unhandledrejection",(e=>{l("promise",[a(e.reason)])}))}}();const c=["index.html","genindex.html","toctree.html","toc.html","navhelp.html","assignments.html","Exercises.html","search.html"];function d(e=window.location.pathname){let t=e.split("/").pop().toLowerCase();return c.some((e=>e.toLowerCase()===t))}class u{constructor(e){if(this.possible=0,this.total=1,e&&"assignment_spec"in e&&(this.assignment_spec=e.assignment_spec,delete e.assignment_spec),e&&Object.keys(e).length>0?this.activities=e:this.activities=function(e=document){let t={page:0};return e.querySelectorAll(".runestone").forEach((function(e,n){let o=e.matches("[data-component]")?e:e.querySelector("[data-component]"),s=o?.id||e.firstElementChild?.id;t[s||`unidentified-activity-${n}`]=0})),t}(),"page"in this.activities||(this.activities.page=0),this.calculateProgress(),d()){const e=document.getElementById("scprogresscontainer");e&&(e.style.display="none")}this.renderProgress()}calculateProgress(){for(let e in this.activities)void 0!==e&&(this.possible++,this.activities[e]>0&&this.total++)}get activitiesAttempted(){return Math.max(this.total-1,0)}get activitiesPossible(){return Math.max(this.possible-1,0)}renderProgress(){let e=0;const t=document.getElementById("scprogresstotal");t&&(t.textContent=this.activitiesAttempted);const n=document.getElementById("scprogressposs");n&&(n.textContent=this.activitiesPossible);try{e=100*this.total/this.possible}catch(t){e=0}let o=document.getElementById("subchapterprogress");if(o&&"PROGRESS"!==o.tagName){const t=document.createElement("progress");t.id="subchapterprogress",t.max=100,t.value=e,t.className=o.className,o.replaceWith(t),o=t}else o&&(o.max=100,o.value=e);if(this.assignment_spec){let e=this.activitiesAttempted,t=this.assignment_spec.activities_required;null==t&&(t=0,this.assignment_spec.activities_required=this.activitiesPossible),e>=t&&this.sendCompletedReadingScore().then((()=>{console.log("Reading score sent for page"),setTimeout((()=>{let e=document.getElementById("completionButton");e&&"mark as completed"===e.textContent.toLowerCase()&&e.click()}),500)}))}if(!eBookConfig.isLoggedIn){const e=document.getElementById("subchapterprogress");e&&e.classList.add("loggedout")}}updateProgress(e){if(this.activities[e]++,1===this.activities[e]){this.total++;let e=100*this.total/this.possible;const t=document.getElementById("scprogresstotal");t&&(t.textContent=this.activitiesAttempted);const n=document.getElementById("scprogressposs");n&&(n.textContent=this.activitiesPossible);let o=document.getElementById("subchapterprogress");if(o&&"PROGRESS"===o.tagName&&(o.value=e),this.assignment_spec&&null!==this.assignment_spec.activities_required&&this.activitiesAttempted>=this.assignment_spec.activities_required&&(console.log("Required activities completed"),this.sendCompletedReadingScore().then((()=>{console.log("Reading score sent")}))),100==e&&function(){const e=document.getElementById("completionButton");return e&&e.textContent&&"mark as completed"===e.textContent.toLowerCase()}()){const e=document.getElementById("completionButton");e&&"function"==typeof e.click&&e.click()}}}async sendCompletedReadingScore(){let e=new Headers({"Content-type":"application/json; charset=utf-8",Accept:"application/json"}),t={...this.assignment_spec},n=new Request(`${eBookConfig.new_server_prefix}/logger/update_reading_score`,{method:"POST",body:JSON.stringify(t),headers:e});try{let e=await fetch(n);e.ok||console.error(`Failed to send reading score! ${e.statusText}`),t=await e.json()}catch(e){console.error(`Error sending reading score ${e}`)}}}var p={};let m=-1;function g(e,t,n,o=!1){const s=document.createElement("div");s.className=`studyclues-message ${t}`,o?s.innerHTML=n:s.textContent=n,e.appendChild(s),e.scrollTop=e.scrollHeight}function h(e){return"string"==typeof e&&([/\$\$[\s\S]+?\$\$/,/\$[^$\n]+?\$/,/\\\[[\s\S]+?\\\]/,/\\\([\s\S]+?\\\)/].some((t=>t.test(e)))||/\\(frac|sqrt|sum|prod|int|lim|sin|cos|tan|log|ln|alpha|beta|gamma|pi|theta|sigma|Delta|cdot|times|leq|geq|neq)\b/.test(e)||/[a-zA-Z0-9]\s*[\^_]\s*\{?.+?\}?/.test(e))}document.addEventListener("runestone:login",(function(){const e=document.getElementById("profilelink");e&&e.style.removeProperty("display");const t=document.getElementById("passwordlink");t&&t.style.removeProperty("display");const n=document.getElementById("registerlink");n&&(n.style.display="none"),document.querySelectorAll("li.loginout").forEach((e=>{e.innerHTML='<a href="/admin/auth/logout">Log Out</a>'}))})),document.addEventListener("runestone:logout",(function(){if(eBookConfig.useRunestoneServices){console.log("setup navbar for logged out");const e=document.getElementById("registerlink");e&&e.style.removeProperty("display");const t=document.getElementById("profilelink");t&&(t.style.display="none");const n=document.getElementById("passwordlink");n&&(n.style.display="none");const o=document.getElementById("ip_dropdown_link");o&&(o.style.display="none");const s=document.getElementById("inst_peer_link");s&&(s.style.display="none"),document.querySelectorAll("li.loginout").forEach((e=>{e.innerHTML='<a href="'+eBookConfig.app+'/default/user/login">Login</a>'})),document.querySelectorAll(".footer").forEach((e=>{e.innerHTML="user not logged in"}))}})),document.addEventListener("DOMContentLoaded",(function(){eBookConfig?(async function(){var e;if(eBookConfig.useRunestoneServices){let e=new Headers({"Content-type":"application/json; charset=utf-8",Accept:"application/json"}),n={timezoneoffset:(new Date).getTimezoneOffset()/60,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},o=function(){const e=`; ${document.cookie}`.split("; RS_info=");if(2===e.length)return e.pop().split(";").shift()}();var t=!1;if(o)try{let e=o.replace(/\\054/g,","),s=JSON.parse(decodeURIComponent(e));s=JSON.parse(decodeURIComponent(s)),s.timezone===n.timezone&&s.tz_offset===n.timezoneoffset&&(console.log("Timezone cookie matches, not sending timezone to server"),t=!0)}catch(e){console.error("Error parsing RS_info cookie, sending timezone to server")}if(!1===t){let t=new Request(`${eBookConfig.new_server_prefix}/logger/set_tz_offset`,{method:"POST",body:JSON.stringify(n),headers:e});try{let e=await fetch(t);e.ok||console.error(`Failed to set timezone! ${e.statusText}`),n=await e.json()}catch(e){console.error(`Error setting timezone ${e}`)}}}if(console.log(`This page served by ${eBookConfig.served_by}`),eBookConfig.isLoggedIn){if(e=`username: ${eBookConfig.username}`,!eBookConfig.isInstructor){const e=document.getElementById("ip_dropdown_link");e&&"function"==typeof e.remove&&e.remove();const t=document.getElementById("inst_peer_link");t&&"function"==typeof t.remove&&t.remove()}document.dispatchEvent(new Event("runestone:login")),function(){let e=localStorage.getItem(`currentAssignmentInfo_${eBookConfig.course}`);if(e&&eBookConfig.readings){var t,n,o,s,i,r,a,l,c,d,u=JSON.parse(e);let g=u.id,h=u.name,f=u.readingNames;(o=document.createElement("div")).textContent="Active assignment: ",(s=document.createElement("a")).textContent=h,s.href=`/assignment/student/doAssignment?assignment_id=${g}`,o.append(s),(i=document.createElement("a")).textContent=" Exit Assignment",i.href=window.location.pathname,i.addEventListener("click",(function(e){localStorage.removeItem(`currentAssignmentInfo_${eBookConfig.course}`)}));let y=window.location.pathname.split("/"),v=y[y.length-2]+"/"+y[y.length-1],w=!1,b=2;document.getElementsByTagName("body")[0].classList.contains("pretext")&&(w=!0,eBookConfig.readings=eBookConfig.readings.map((e=>e.split("/").pop())),v=v.split("/").pop(),b=1);let C=eBookConfig.readings.indexOf(v),S=eBookConfig.readings.length;if(C>0){l=eBookConfig.readings[C-1],(c=y.slice(0,y.length-b)).push(l),d=c.join("/"),r=o.cloneNode(!0);let e=document.createElement("p");e.textContent=`Page ${C+1} of ${S}, `;var p=document.createElement("a");p.href=d,p.textContent=`Back to page ${C} of ${S}: ${f[C-1]}.`,e.append(p),r.append(e)}else if(0==C){r=o.cloneNode(!0);let e=document.createElement("p");e.textContent=`Page 1 of ${S}.`,r.append(e)}else{let e=!1,t=Object.keys(componentMap);0==t.length&&(t=document.querySelectorAll("[data-component]"),t=Array.from(t).map((function(e){return e.id})));for(let n of t)if(u.questions.includes(n)){e=!0;break}l=eBookConfig.readings[0],(c=y.slice(0,y.length-b)).push(l),d=c.join("/"),r=o.cloneNode(!0);let n=document.createElement("p");n.textContent=e?"This page has activities assigned to the current assignment.":"Notice: this page is not part of the assignment.",n.append(i),r.append(n)}if(C==eBookConfig.readings.length-1){a=o;let e=document.createElement("p");e.textContent=`Page ${S} of ${S}: ${f[C]}`,a.append(e)}else if(C>=0){l=eBookConfig.readings[C+1],(c=y.slice(0,y.length-b)).push(l),d=c.join("/"),a=o;var m=document.createElement("a");m.href=d,m.textContent=`Continue to page ${C+2} of ${S}: ${f[C+1]}`;let e=document.createElement("p");e.append(m),a.append(e)}else{a=o.cloneNode(!0);let e=document.createElement("p");e.textContent="Notice: this page is not part of the assignment. To remove this warning click ";let t=i.cloneNode(!0);t.addEventListener("click",(function(e){localStorage.removeItem(`currentAssignmentInfo_${eBookConfig.course}`)})),e.append(t),a.append(e)}if((t=document.createElement("div")).className="ptx-runestone-container",r.className="runestone assignment-nav top-assignment-nav",t.append(r),(n=document.createElement("div")).className="ptx-runestone-container",a.className="runestone assignment-nav bottom-assignment-nav",n.append(a),w){let e=document.getElementById("ptx-content");e&&e.insertBefore(t,e.firstChild);let o=document.getElementById("scprogresscontainer");return void(o&&(o.style.marginBottom="20px",o.appendChild(n)))}const k=document.getElementById("main-content");k&&a&&(k.insertBefore(t,k.firstChild),k.appendChild(n))}}(),function(){if(!location.pathname.includes("/ns/books/")&&!location.pathname.includes("doAssignment"))return!1;const e=window.location.hostname;return"localhost"===e?["csawesome2","py4e-int","thinkcspy","httlacs","PTXSB","cppds2"].includes(eBookConfig.basecourse):"runestone.academy"===e&&["SI201-W26-MW","SI201-W26-TTh","DukeCS101SP26","mcd-csa-schoology","mcd-csa-canvas","csawesome2-MOOC","test_py4e-int_api","bc_cppds_s26","bc_cppds2_f26","Test-py4e-int","virginiatech_py4e-int_spring26","umsi101_fall26","csawesome2_studyclues_test","httlacs_studyclues_test","py4e_studyclues_test"].includes(eBookConfig.course)}()&&function(){if(document.getElementById("studyclues-fab"))return;const e=document.createElement("style");e.textContent='\n #studyclues-fab {\n position: fixed;\n right: 24px;\n bottom: 24px;\n z-index: 9999;\n border: none;\n border-radius: 9999px;\n padding: 12px 18px;\n font-size: 14px;\n font-weight: 600;\n cursor: pointer;\n color: #fff;\n background: #2563eb;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);\n }\n\n #studyclues-chat {\n position: fixed;\n right: 24px;\n bottom: 78px;\n z-index: 9999;\n width: min(420px, calc(100vw - 32px));\n height: min(520px, calc(100vh - 120px));\n background: #fff;\n border: 1px solid #d1d5db;\n border-radius: 12px;\n box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25);\n display: none;\n flex-direction: column;\n overflow: hidden;\n }\n\n #studyclues-chat.open {\n display: flex;\n }\n\n .studyclues-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 12px;\n border-bottom: 1px solid #e5e7eb;\n font-weight: 600;\n background: #f9fafb;\n }\n\n .studyclues-close {\n border: none;\n background: transparent;\n cursor: pointer;\n font-size: 16px;\n line-height: 1;\n }\n\n .studyclues-coach-toggle {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n font-weight: 500;\n color: #4b5563;\n }\n\n .studyclues-coach-toggle input[type="checkbox"] {\n appearance: none;\n -webkit-appearance: none;\n width: 32px;\n height: 18px;\n border-radius: 9999px;\n background: #d1d5db;\n cursor: pointer;\n position: relative;\n transition: background 0.2s;\n flex-shrink: 0;\n }\n\n .studyclues-coach-toggle input[type="checkbox"]::after {\n content: "";\n position: absolute;\n top: 2px;\n left: 2px;\n width: 14px;\n height: 14px;\n border-radius: 50%;\n background: #fff;\n transition: transform 0.2s;\n }\n\n .studyclues-coach-toggle input[type="checkbox"]:checked {\n background: #2563eb;\n }\n\n .studyclues-coach-toggle input[type="checkbox"]:checked::after {\n transform: translateX(14px);\n }\n\n .studyclues-messages {\n flex: 1;\n overflow-y: auto;\n padding: 12px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n background: var(--background);\n color: var(--bodyFont);\n }\n\n .studyclues-message {\n max-width: 85%;\n padding: 10px 12px;\n border-radius: 10px;\n white-space: pre-wrap;\n word-break: break-word;\n font-size: 14px;\n line-height: 1.4;\n }\n\n .studyclues-message.user {\n margin-left: auto;\n background: var(--componentBgColor);\n border: 1px solid #bfdbfe;\n color: var(--bodyFont);\n }\n\n .studyclues-message.assistant {\n margin-right: auto;\n background: var(--background);\n border: 1px solid var(--grayToWhite);\n color: var(--bodyFont);\n }\n\n .studyclues-message.studyclues-loading {\n color: var(--bodyFont);\n font-style: italic;\n }\n\n .studyclues-spinner {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n }\n\n .studyclues-spinner-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: #6b7280;\n opacity: 0.35;\n animation: studyclues-dot-pulse 1s infinite ease-in-out;\n }\n\n .studyclues-spinner-dot:nth-child(2) {\n animation-delay: 0.15s;\n }\n\n .studyclues-spinner-dot:nth-child(3) {\n animation-delay: 0.3s;\n }\n\n @keyframes studyclues-dot-pulse {\n 0%,\n 80%,\n 100% {\n opacity: 0.35;\n transform: scale(1);\n }\n 40% {\n opacity: 1;\n transform: scale(1.2);\n }\n }\n\n .studyclues-inputbar {\n display: flex;\n gap: 8px;\n padding: 10px;\n border-top: 1px solid #e5e7eb;\n background: #fff;\n }\n\n .studyclues-inputbar input {\n flex: 1;\n min-width: 0;\n border: 1px solid #d1d5db;\n border-radius: 8px;\n padding: 8px 10px;\n font-size: 14px;\n }\n\n .studyclues-inputbar button {\n border: none;\n border-radius: 8px;\n padding: 8px 12px;\n cursor: pointer;\n color: #fff;\n background: #2563eb;\n font-weight: 600;\n }\n ',document.head.appendChild(e);const t=document.createElement("button");t.id="studyclues-fab",t.textContent="StudyClues Chat";const n=document.createElement("div");n.id="studyclues-chat",n.innerHTML='\n <div class="studyclues-header">\n <span>StudyClues</span>\n <label class="studyclues-coach-toggle">\n <input type="checkbox" id="studyclues-coach-mode" checked />\n Coach Mode\n </label>\n <button class="studyclues-close" aria-label="Close chat">✕</button>\n </div>\n <div class="studyclues-messages"></div>\n <div class="studyclues-inputbar">\n <input type="text" placeholder="Ask a question about this course..." />\n <button type="button">Send</button>\n </div>\n ',document.body.appendChild(t),document.body.appendChild(n);const o=n.querySelector(".studyclues-close"),r=n.querySelector(".studyclues-messages"),a=n.querySelector(".studyclues-inputbar input"),l=n.querySelector(".studyclues-inputbar button"),c=n.querySelector("#studyclues-coach-mode");let d=c.checked;c.addEventListener("change",(()=>{d=c.checked}));const u=()=>{n.classList.toggle("open"),n.classList.contains("open")&&a.focus()},p=async()=>{let e=a.value.trim();if(!e)return;var t="";if(document.querySelector("body.pretext")&&document.querySelector("section.section")){let e=document.querySelector("section.section"),n=e.querySelector("span.title").innerText;t=`${e.querySelector("span.codenumber").innerText} ${n}`}else{let e=document.querySelector("span.section-number");e&&(t=e.parentElement.innerText.trim())}-1===m&&t&&(e=`Regarding section "${t}": ${e}`),i.logBookEvent({event:"studyclues_query",act:`query: ${e}`,div_id:`${t}`}),g(r,"user",e),a.value="",l.disabled=!0;const n=document.createElement("div");n.className="studyclues-message assistant studyclues-loading",n.innerHTML='Thinking <span class="studyclues-spinner"><span class="studyclues-spinner-dot"></span><span class="studyclues-spinner-dot"></span><span class="studyclues-spinner-dot"></span></span>',r.appendChild(n),r.scrollTop=r.scrollHeight;try{const t=await fetch("/assignment/student/studyclues_query",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({query:e,conversation_id:m,coachMode:d})});if(!t.ok)throw new Error(`Request failed with status ${t.status}`);const n=await t.json(),o=n?.detail||{},i=o?.response||{},a=i?.llm_response,l=i?.references||{};"number"==typeof o.conversation_id&&(m=o.conversation_id);const c=(a||"No response available from StudyClues.").replace(/\[([^\]]+)\]\(([^)]+)\)/g,((e,t,n)=>{const o=l[n]?.content_url;return o?`[${t}](${o})`:e})),u=s.xI.parse(c);g(r,"assistant",u,!0)}catch(e){g(r,"assistant","Sorry, StudyClues is unavailable right now. Please try again."),console.error("StudyClues chat error:",e)}finally{n.remove(),l.disabled=!1,a.focus()}};t.addEventListener("click",u),o.addEventListener("click",u),l.addEventListener("click",p),a.addEventListener("keydown",(e=>{"Enter"===e.key&&(e.preventDefault(),p())}))}()}else{e="Not logged in",document.dispatchEvent(new Event("runestone:logout"));let t=document.getElementById("browsing_warning");t&&(t.innerHTML="<p class='navbar_message'>Saving and Logging are Disabled</p>");let n=document.getElementById("ad_warning");n&&(n.innerHTML="<p class='navbar_message'>🚫 Log-in to Remove <a href='/admin/legal/ads'>Ads!</a> 🚫 &nbsp;</p>")}document.querySelectorAll(".loggedinuser").forEach((t=>{t.innerHTML=e})),p=new u(eBookConfig.activities),console.log("triggering runestone:pre-login-complete"),document.dispatchEvent(new Event("runestone:pre-login-complete"))}(),function(){if("undefined"!=typeof showAd&&showAd){let e=Math.floor(2*Math.random())+1,t=document.getElementById(`adcopy_${e}`),n=document.querySelectorAll(".runestone");n.length>0&&(n[Math.floor(Math.random()*n.length)].after(t),t.style.display="block")}}()):"undefined"==typeof eBookConfig&&console.log("eBookConfig is not defined. This page must not be set up for Runestone")})),window.addEventListener("load",(function(){if(document.querySelectorAll(".video-play-overlay").forEach((function(e){e.style.backgroundImage="url('{{pathto('_static/play_overlay_icon.png', 1)}}')"})),document.querySelectorAll(".dropdown input, .dropdown label").forEach((function(e){e.addEventListener("click",(function(e){e.stopPropagation()}))})),location.href.includes("mode=browsing")){let e="?mode=browsing";document.querySelectorAll("a").forEach((t=>{let n="";if(t.href.includes("books/published")&&!t.href.includes("?mode=browsing")){if(t.href.includes("#")){let e=t.href.indexOf("#");n=t.href.substring(e),t.href=t.href.substring(0,e)}t.href=t.href.includes("?")?t.href+e.replace("?","&")+n:t.href+e+n}}))}})),window.addEventListener("DOMContentLoaded",(function(e){const t=this.document.querySelector(".dropdown-content[data-deprecated]");t&&t.remove();const n=this.document.getElementById("ptx-user-dropdown-content_item-template"),o=this.document.getElementById("ptx-user-dropdown-content_separator-template"),s=this.document.getElementById("ptx-user-dropdown_rs-content");if(!n||!o||!s)return void console.warn("Missing template or content area for user dropdown");function i(e,t,o=null,s=null){const i=n.content.cloneNode(!0),r=i.querySelector("a");r.href=e,r.innerText="";const a=document.createElement("span");a.style.display="inline-flex",a.style.alignItems="center",a.style.gap="0.35rem";const l=document.createElement("span");l.setAttribute("aria-hidden","true"),l.className="material-symbols-outlined",l.style.display="inline-flex",l.style.alignItems="center",l.style.justifyContent="center",l.style.width="1.25em",l.style.minWidth="1.25em",o?l.innerText=o:(l.style.visibility="hidden",l.innerText="home"),a.appendChild(l);let c=document.createElement("span");return c.innerText=t,a.appendChild(c),r.appendChild(a),s&&(r.ariaLabel=s),i}if(s.appendChild(i("/ns/course/index","Course Home","home")),s.appendChild(i("/assignment/student/chooseAssignment","Assignments","edit")),s.appendChild(i("/assignment/peer/student","Peer Instruction (Student)","groups_3")),s.appendChild(i("/assignment/student/studentreport","Progress")),eBookConfig.isInstructor){s.appendChild(o.content.cloneNode(!0)),s.appendChild(i("/admin/instructor/menu","Instructor Dashboard","settings")),s.appendChild(i("/assignment/peer/instructor","Peer Instruction (Instructor)","groups_3"));let e=(eBookConfig.authorServerUrl||"https://author.runestone.academy/author")+"/";eBookConfig.isAuthor&&s.appendChild(i(e,"Author Dashboard")),eBookConfig.isEditor&&s.appendChild(i(e,"Editor Dashboard")),s.appendChild(i("/assignment/instructor/invoice_request","Request Invoice"))}s.appendChild(o.content.cloneNode(!0)),s.appendChild(i("/admin/auth/my_courses","Change Course","newsstand")),s.appendChild(i("/admin/auth/profile","Profile")),s.appendChild(i("/admin/auth/logout","Log Out")),s.appendChild(o.content.cloneNode(!0));const a=i("/admin/problem/report","Problem Report","bug_report"),l=a.querySelector("a");l&&l.addEventListener("click",(()=>{try{sessionStorage.setItem("rs_console_log",r.join("\n"))}catch(e){}})),s.appendChild(a)}))},98098:(e,t,n)=>{"use strict";n.d(t,{$y:()=>r,JK:()=>i,yT:()=>a});var o=n(58942),s=n(34089);async function i(e,t,n){let i=document.getElementById(t);if(!i)return;if(!e)return void(i.innerHTML="<p>Sorry, no source is available for preview.</p>");e=e.replace(/..\/_images/g,`${eBookConfig.app}/books/published/${eBookConfig.basecourse}/_images`),i.innerHTML=e,void 0===window.componentMap&&(window.componentMap={});let r=i.querySelector("[data-component]"),a=r?.dataset.component;await(0,o.w)(a);let l={};if(l.orig=r,l.orig&&(l.lang=(0,s.Qt)(l.orig,"lang"),l.useRunestoneServices=!0,l.graderactive=!1,l.python3=!0,void 0!==n))for(let e in n)l[e]=n[e];if("undefined"==typeof component_factory)alert("Error: Missing the component factory!");else if(window.component_factory[a]||i.innerHTML){let e=window.component_factory[a](l);"activecode"===a&&(n.multiGrader?window.componentMap[`${n.gradingContainer} ${e.divid}`]=e:window.componentMap[e.divid]=e)}else i.innerHTML=`<p>Preview not available for ${a}</p>`}function r(e,t){e=e.replace(/..\/_images/g,`${eBookConfig.app}/books/published/${eBookConfig.basecourse}/_images`);let n=document.createElement("div");n.innerHTML=e;let o,s=n.querySelector("[data-component]"),i=s?.dataset.component,r=s?.getAttribute("id");if(!document.getElementById(r)){let t=document.createElement("div");t.style.display="none",t.innerHTML=e,document.body.appendChild(t)}let a={orig:document.getElementById(r),timed:!0};if(void 0!==t)for(let e in t)a[e]=t[e];i in window.component_factory&&(o=window.component_factory[i](a));let l={};return l.question=o,l}async function a(e){let t=e.querySelector("[data-component]");if(null==t)return void console.log("Render was called for a component, but now [data-component] attribute is present. This may mean the component has already been rendered.");let n=t.dataset.component;if(await(0,o.w)(n),!e.closest("[data-component=timedAssessment]"))try{let e=t.id;window.componentMap[e]=window.component_factory[n]({orig:t,useRunestoneServices:eBookConfig.useRunestoneServices})}catch(e){console.log(`Error rendering ${n} Problem ${t.id}\n Details: ${e}`)}}}},e=>{e.O(0,[926],(()=>e(e.s=58942))),e.O()}]);
//# sourceMappingURL=prefix-runestone.5555907f139e2014.bundle.js.map