"use strict";(self.webpackChunkdatawhys_experimental_control=self.webpackChunkdatawhys_experimental_control||[]).push([[509],{509:(e,t,n)=>{n.r(t),n.d(t,{default:()=>g});var l=n(88),o=n(765),a=n.n(o),i=n(424);const s="Click here to see examples from your first notebook",r=new URLSearchParams(window.location.search),c=function(){let e=window.location.pathname.split("/"),t=0;return e.forEach(((e,n)=>{"user"===e&&(t=n+1)})),e[t]}(),d=r.get("hub")+"/"+c+"/"+r.get("index")+"/"+r.get("condition"),u=r.get("qualtrics"),p=r.get("rb");function h(){if("1"===p){let e=document.getElementById("main");e&&(e.style.display="none"),window.alert("You cannot reload this tab.\n\nPlease return to the experiment tab to continue.\n\nYou may close this tab now.")}this.collapseLeft();let e=document.getElementById("jp-top-panel");e&&(e.style.display="none");let t=document.getElementById("jp-left-stack");t&&(t.style.display="none");let n=document.getElementById("jp-main-statusbar");n&&(n.style.display="none");let l=document.getElementById("jp-main-content-panel");l&&l.children.length>0&&(l.children[0].style.display="none")}const m=(e,t)=>{const n=e.currentWidget;let l="";n&&(l=n.title.label);let o=null;n&&(o=n.model);let i="",c=!1;if(o)try{c=o.cells.get(0).toJSON().source.includes(s)}catch(e){console.log(e)}if(l.includes("ps-near1")&&!c){if(e.forEach((e=>{e.title.label.includes("we-")&&(e=>{const t=e.model;t&&t.cells.get(t.cells.length-1).id.includes("external")&&console.log("Clearing unused worked example external link.")})(e)})),l.includes("-gl")){let e=r.get("bl");i=e&&1===Number.parseInt(e)?`<span style="font-size:16pt;">[${s}](we-bl-gl.ipynb)</span>`:`<span style="font-size:16pt;">[${s}](we-co-gl.ipynb)</span>`}if(l.includes("-na")){let e=r.get("bl");i=e&&1===Number.parseInt(e)?`<span style="font-size:16pt;">[${s}](we-bl-na.ipynb)</span>`:`<span style="font-size:16pt;">[${s}](we-co-na.ipynb)</span>`}n&&n.context.model.sharedModel.insertCell(0,{cell_type:"markdown",source:[i],metadata:{deletable:!1,editable:!1},id:"internal-we"})}if(!a()("#external-link").length){const n=a()("<a>",{id:"external-link",css:{color:"#64b5f6",fontSize:"16pt"}});n.text("Click here after you've finished to move to the next assignment"),n.on("click",(function(){let n=[];e.forEach((e=>{let l=t.contextForWidget(e);if(l){let e=l.save();n.push(e)}})),"1"===u?Promise.all(n).then((()=>{let e=document.getElementById("main");e&&(e.style.display="none"),r.set("rb","1");var t=window.location.pathname+"?"+r.toString();history.replaceState(null,"",t);let n=["rain","insure","silk","contest","polish"],o="";l.includes("we-")?o=n[0]:l.includes("ps-near1")?o=n[1]:l.includes("ps-near2")?o=n[2]:l.includes("ps-far-")?o=n[3]:l.includes("ps-farplus")&&(o=n[4]),window.alert("The keyword is:\n\n"+o+"\n\nPlease enter the keyword in the experiment tab to continue.\n\nClose this window *after* you enter the keyword in the experiment tab.")})):Promise.all(n).then((()=>window.location.replace(d)))})),a()(".jp-WindowedPanel-outer").append(n)}},f={id:"datawhys_experimental_control:plugin",description:"A JupyterLab extension that locks down the user interface and provides additional controls for running experiments using the JupyterLab platform. It is not configurable but may serve as an example for other projects.",autoStart:!0,requires:[l.INotebookTracker,i.IDocumentManager],activate:(e,t,n)=>{const l=new URLSearchParams(window.location.search),o=l.get("lock"),i=l.get("personalagent");"1"===o&&(console.log("JupyterLab extension datawhys_experimental_control is activated!"),t.currentChanged.connect((()=>{let e=t.currentWidget;e&&e.context.ready.then((()=>{m(t,n)}))})),e.restored.then((()=>{e.shell.collapseLeft(),setInterval((function(){var e;a()(".p-TabBar-tabCloseIcon").hide();let n=!0;a()(".p-TabBar-tab").each((function(e){let t=a()(this)[0].innerText;(t.includes("near2")||t.includes("far"))&&(n=!1)})),a()(".p-TabBar-tab").each((function(e){let t=a()(this),l=t[0].innerText;(l.includes("we-")||l.includes("near1"))&&n||t.hide()}));let l=t.currentWidget;if(l&&l.content.widgets.forEach(((e,t)=>{"markdown"===e.model.type&&(e.rendered=!0,e.inputHidden=!1)})),n){a()("#external-link").hide();let n=0,l=null===(e=null==t?void 0:t.currentWidget)||void 0===e?void 0:e.model;if(l)for(let e=0;e<l.cells.length;e++){let t=l.cells.get(e);if("code"===t.type&&""!==t.sharedModel.source){let e=t;e.executionCount&&e.executionCount>0&&n++}}let o=!1,i=t.currentWidget;(i&&i.title.label.includes("we-")&&n>=9||i&&i.title.label.includes("near1")&&n>=5)&&(o=!0),o&&a()("#external-link").show()}if(null!=i)for(let e=1;e<=5;e++){let t=document.getElementById(`agent-img-${e}`);if(t){let n=t;""==n.src&&(n.src="https://ffarzan.com/wp-content/uploads/2025/03/jup-"+i+`-${e}.jpg`)}}}),1e3)})),t.currentChanged.connect(h,e.shell))}},g=f}}]);