!function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=35)}({35:function(e,t){window.PennController._AddElementType("Selector",(function(e){async function t(t,...n){let s=[];if(n.length)for(let t in n){if(!(n[t]._element&&n[t]._element.jQueryElement instanceof jQuery)){e.debug.error("Invalid element #"+t+" in shuffling selector "+this.id);continue}let i=this.elements.map(e=>e[0]).indexOf(n[t]._element);i<0?e.debug.error("Cannot shuffle element "+n[t]._element.id+" for it has not been added to selector "+this.id):s.push(i)}else s=[...new Array(this.elements.length)].map((e,t)=>t);let i=[...s];fisherYates(i);const l=[],r=s.map(e=>{const t=this.elements[e][0],n=t._lastPrint;if(void 0===n[0]){const n=t.jQueryContainer;if(n instanceof jQuery&&n.parent().length){const t=$("");n.before(t),l[e]=t}}else if(n[0]instanceof jQuery&&(n[0].hasClass("PennController-after")||n[0].hasClass("PennController-before"))){const e={};let l=n[0][0].className.replace(/^.*PennController-(after|before).*$/,"$1");l=l.replace(/^[ab]/,e=>e.toUpperCase());for(let n=0;ne._element!=t),r["jQuery"+l].length{const t=this.elements[e][0];await window.PennController.Elements["get"+t.type](t.id).remove()._runPromises()}),i.forEach(async(e,t)=>{let n=this.elements[e][0],i=r[t];if(void 0===i)return;const o=window.PennController.Elements["get"+n.type](n.id);i.hasOwnProperty("After")?await window.PennController.Elements["get"+i.After.type](i.After.id).after(o)._runPromises():i.hasOwnProperty("Before")?await window.PennController.Elements["get"+i.Before.type](i.Before.id).after(o)._runPromises():await o.print(...i)._runPromises();const a=l[s[t]];a instanceof jQuery&&(n.jQueryContainer.css("position","unset"),a.before(n.jQueryContainer),a.remove())});const o=[...this.elements];s.forEach((e,t)=>this.elements[e]=o[i[t]]),t()}this.immediate=function(e){void 0!==e&&"string"==typeof e&&0!=e.length||(e="Selector"),this.id=e},this.uponCreation=function(t){this.elements=[],this.selections=[],this.disabled=!1,this.frame=$("
").css({position:"absolute",display:"inline-block",margin:"auto",outline:"dotted 1px grey","z-index":100}).addClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selectionFrame"),this.noClick=!1,this.select=t=>{if(!this.disabled){if(this.elements.map(e=>e[0]).indexOf(t)<0)return e.debug.error("Tried to select an element not part of Selector "+this.id);this.selections.push(["Selection",t.id,Date.now(),this.elements.map(e=>e[0].id).join(";")]),this.frame.css({width:t.jQueryElement.outerWidth(),height:t.jQueryElement.outerHeight(),"pointer-events":"none"}),"absolute"==t.jQueryElement.css("position")&&this.frame.css({left:t.jQueryElement.css("left"),top:t.jQueryElement.css("top")}),t.jQueryElement.before(this.frame),this.elements.map(e=>e[0].jQueryElement.removeClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selected")),t.jQueryElement.addClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selected")}},e.events.keypress(e=>{if(!this.disabled)for(let t=0;t1&&(n=this.elements[t][1]);let s=e.key.isSpecialKey(),i=e.key.toUpperCase(),l={0:"",1:"LEFT",2:"RIGHT"};if(s===n.replace(/^(Left|Right)/i,"").isSpecialKey()&&(n.toUpperCase()==i||n.toUpperCase()==l[e.location]+i))return this.select(this.elements[t][0])}}),t()},this.end=function(){if(this.select=()=>{},this.frame&&this.frame instanceof jQuery&&this.frame.remove(),this.log&&this.log instanceof Array)if(this.selections.length)if(1==this.selections.length)e.controllers.running.save(this.type,this.id,...this.selections[0]);else if(this.log.indexOf("all")>-1)for(let t in this.selections)e.controllers.running.save(this.type,this.id,...this.selections[t]);else this.log.indexOf("first")>-1&&e.controllers.running.save(this.type,this.id,...this.selections[0]),this.log.indexOf("last")>-1&&e.controllers.running.save(this.type,this.id,...this.selections[this.selections.length-1]);else e.controllers.running.save(this.type,this.id,"Selection","NA","Never",this.elements.map(e=>e[0].id).join(";")+";No selection happened");this.elements=[]},this.value=function(){if(this.selections.length){let e=this.selections[this.selections.length-1][1],t=this.elements.filter(t=>t[0].id==e);return t.length?(t=t[0][0],window.PennController.Elements["get"+t.type](t.id)):null}return null},this.actions={select:function(t,n){if(!isNaN(Number(n))&&Number(n)>=0&&Number(n)e[0].id).join(";")+";From script"]),this.frame.detach(),this.elements.map(e=>e[0].jQueryElement.removeClass("PennController-"+this.type+"-selected")),e()},wait:function(e,t){if("first"==t&&this.selections.length)e();else{let n=!1,s=this.select;this.select=i=>{let l=s.apply(this,[i]);if(!(n||this.disabled&&!l))if(t instanceof Object&&t._runPromises&&t.success){let s=this.disabled;this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=s)})}else n=!0,e()}}}},this.settings={add:function(t,...n){for(w in n){let t=n[w]._element;if(null==t||null==t.id)e.debug.error("Invalid element added to selector "+this.id);else if(this.elements.map(e=>e[0]).indexOf(t)>-1)e.debug.error("Element "+t.id+" already part of selector "+this.id);else if(null!=t.jQueryElement&&t.jQueryElement instanceof jQuery){this.elements.push([t]);let e=()=>{this.noClick||t.jQueryElement.css("cursor","pointer");let e=t.jQueryElement[0].onclick;t.jQueryElement[0].onclick=(...n)=>{e instanceof Function&&e.apply(t.jQueryElement[0],n),this.noClick||this.select(t)}};t.jQueryElement.parent().length?e():t._printCallback.push(e)}else e.debug.error("Element "+t.id+" has no visble element to be chosen in selector "+this.id)}t()},callback:function(e,...t){let n=this.select;this.select=async function(e){let s=this.disabled;if(n.apply(this,[e]),!s)for(let e in t)await t[e]._runPromises()},e()},disable:function(e){this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),this.jQueryContainer.addClass("PennController-disabled"),this.jQueryElement.addClass("PennController-disabled"),e()},disableClicks:function(e){this.noClick=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),e()},enable:function(e){this.disabled=!1,this.noClick||this.elements.map(e=>e[0].jQueryElement.css("cursor","pointer")),this.jQueryContainer.removeClass("PennController-disabled"),this.jQueryElement.removeClass("PennController-disabled"),e()},enableClicks:function(e){this.noClick=!1,this.elements.map(e=>e[0].jQueryElement.css("cursor","pointer")),e()},frame:function(e,t){this.frame.css.apply(this.frame,["outline",t]),e()},keys:function(e,...t){for(let e=0;e=this.elements.length)break;"string"!=typeof n&&Number(n)>0&&(n=String.fromCharCode(n)),this.elements[e]=[this.elements[e][0],n]}e()},log:function(e,...t){t.length?this.log=t:this.log=["last"],e()},once:function(e){if(this.selections.length)this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor",""));else{let e=this.select;this.select=t=>{if(e.apply(this,[t]),!this.disabled)return this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),"once"}}e()},shuffle:function(e,...n){t.apply(this,[e].concat(n))}},this.test={selected:function(t){if(0===this.selections.length)return!1;let n=this.selections[this.selections.length-1][1];return null==t?this.selections.length>0:"string"==typeof t?t==n:t._element?t._element.id==n:(e.debug.error("Invalid element tested for Selector "+this.id,t._element.id),!1)},index:function(t,n){return null==t||null==t._element?e.debug.error("Invalid element tested for selector "+this.id,t._element.id):Number(n)>=0?this.elements.map(e=>e[0]).indexOf(t._element)==Number(n):this.elements.map(e=>e[0]).indexOf(t._element)>=0}}})),window.PennController._AddStandardCommands((function(e){this.settings={selector:async function(t,n){var s;if("string"==typeof n){let t=e.controllers.running.options.elements;if(!t.hasOwnProperty("Selector")||!t.Selector.hasOwnProperty(n))return e.debug.error("No selector found named "+n);s=t.Selector[n]}else n._element&&n._runPromises&&("Selector"==n._element.type?(await n._runPromises(),s=n._element):e.debug.error("Tried to add "+this.name+" to an invalid Selector"));if(s.elements.map(e=>e[0]).indexOf(this)>-1)e.debug.error("Element "+this.id+" already part of Selector "+s.id);else if(null!=this.jQueryElement&&this.jQueryElement instanceof jQuery){s.elements.push([this]),this.noClick||this.jQueryElement.css("cursor","pointer");let e=this.jQueryElement[0].onclick;this.jQueryElement[0].onclick=(...t)=>{e instanceof Function&&e.apply(this.jQueryElement[0],t),s.noClick||s.select(this)}}else e.debug.error("Element "+this.id+" has no visble element to be chosen in Selector "+s.id);t()}}}))}});