jspsych 8.1.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
- var jsPsychModule=function(E){"use strict";var we=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function O(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}const ve=r=>{const e=new Set;do for(const t of Reflect.ownKeys(r))e.add([r,t]);while((r=Reflect.getPrototypeOf(r))&&r!==Object.prototype);return e};var Pe=(r,{include:e,exclude:t}={})=>{const i=s=>{const l=o=>typeof o=="string"?s===o:o.test(s);return e?e.some(l):t?!t.some(l):!0};for(const[s,l]of ve(r.constructor.prototype)){if(l==="constructor"||!i(l))continue;const o=Reflect.getOwnPropertyDescriptor(s,l);o&&typeof o.value=="function"&&(r[l]=r[l].bind(r))}return r},A=O(Pe),Ee={name:"jspsych",version:"8.1.0",description:"Behavioral experiments in a browser",type:"module",main:"dist/index.cjs",exports:{".":{import:"./dist/index.js",require:"./dist/index.cjs"},"./css/*":"./css/*"},typings:"dist/index.d.ts",unpkg:"dist/index.browser.min.js",files:["src","dist","css"],source:"src/index.ts",scripts:{test:"jest","test:watch":"npm test -- --watch",tsc:"tsc","build:js":"rollup --config","build:styles":"webpack-cli",build:"run-p build:js build:styles","build:watch":'run-p "build:js -- --watch" "build:styles watch"',prepack:"cp ../../README.md ."},repository:{type:"git",url:"git+https://github.com/jspsych/jsPsych.git",directory:"packages/jspsych"},author:"Josh de Leeuw",license:"MIT",bugs:{url:"https://github.com/jspsych/jsPsych/issues"},homepage:"https://www.jspsych.org",dependencies:{"auto-bind":"^4.0.0","random-words":"^1.1.1",seedrandom:"^3.0.5","type-fest":"^2.9.0"},devDependencies:{"@fontsource/open-sans":"4.5.3","@jspsych/config":"^3.0.1","@types/dom-mediacapture-record":"^1.0.11","base64-inline-loader":"^2.0.1","css-loader":"^6.6.0","mini-css-extract-plugin":"^2.5.3","npm-run-all":"^4.1.5","replace-in-file-webpack-plugin":"^1.0.6",sass:"^1.43.5","sass-loader":"^12.4.0",webpack:"^5.76.0","webpack-cli":"^4.9.2","webpack-remove-empty-scripts":"^0.7.2"}},K=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class _{constructor(e,t){this.dependencies=e,this.extensionsConfiguration=t,this.extensions=Object.fromEntries(t.map(i=>[_.getExtensionNameByClass(i.type),this.dependencies.instantiateExtension(i.type)]))}static getExtensionNameByClass(e){return e.info.name}getExtensionInstanceByClass(e){return this.extensions[_.getExtensionNameByClass(e)]}initializeExtensions(){return K(this,null,function*(){yield Promise.all(this.extensionsConfiguration.map(({type:e,params:t={}})=>{this.getExtensionInstanceByClass(e).initialize(t);const i=e.info;!("version"in i)&&!("data"in i)?console.warn(i.name,"is missing the 'version' and 'data' fields. Please update extension as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."):"version"in i?"data"in i||console.warn(i.name,"is missing the 'data' field. Please update extension as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."):console.warn(i.name,"is missing the 'version' field. Please update extension as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details.")}))})}onStart(e=[]){var t;for(const{type:i,params:s}of e)(t=this.getExtensionInstanceByClass(i))==null||t.on_start(s)}onLoad(e=[]){var t;for(const{type:i,params:s}of e)(t=this.getExtensionInstanceByClass(i))==null||t.on_load(s)}onFinish(){return K(this,arguments,function*(e=[]){const t=yield Promise.all(e.map(({type:s,params:l})=>{var o;return Promise.resolve((o=this.getExtensionInstanceByClass(s))==null?void 0:o.on_finish(l))})),i=e.length?{extension_type:e.map(({type:s})=>s.info.name),extension_version:e.map(({type:s})=>s.info.version)}:{};return t.unshift(i),Object.assign({},...t)})}}function x(r){return[...new Set(r)]}function f(r){if(!r)return r;let e;if(Array.isArray(r)){e=[];for(const t of r)e.push(f(t));return e}else if(typeof r=="object"&&r!==null){e={};for(const t in r)r.hasOwnProperty(t)&&(e[t]=f(r[t]));return e}else return r}function k(r,e){let t={};for(const i in r)r.hasOwnProperty(i)&&(typeof r[i]=="object"&&e.hasOwnProperty(i)?t[i]=k(r[i],e[i]):t[i]=r[i]);for(const i in e)e.hasOwnProperty(i)&&(t.hasOwnProperty(i)&&typeof e[i]=="object"?t[i]=k(t[i],e[i]):t[i]=e[i]);return t}var _e=Object.freeze({__proto__:null,unique:x,deepCopy:f,deepMerge:k});class I{constructor(e=[]){this.values=e}sum(){let e=0;for(const t of this.values)e+=t;return e}mean(){let e=0,t=0;for(const i of this.values)typeof i!="undefined"&&i!==null&&(e+=i,t++);if(t!==0)return e/t}median(){if(this.values.length===0)return;const e=this.values.slice(0).sort(function(i,s){return i-s}),t=Math.floor(e.length/2);return e.length%2===0?(e[t]+e[t-1])/2:e[t]}min(){return Math.min.apply(null,this.values)}max(){return Math.max.apply(null,this.values)}count(){return this.values.length}variance(){const e=this.mean();let t=0;for(const i of this.values)t+=Math.pow(i-e,2);return t/(this.values.length-1)}sd(){const e=this.variance();return Math.sqrt(e)}frequencies(){const e={};for(const t of this.values)typeof e[t]=="undefined"?e[t]=1:e[t]++;return e}all(e){for(const t of this.values)if(!e(t))return!1;return!0}subset(e){const t=[];for(const i of this.values)e(i)&&t.push(i);return new I(t)}}function xe(r,e){const t=new Blob([r],{type:"text/plain"});let i="";typeof window.webkitURL!="undefined"?i=window.webkitURL.createObjectURL(t):i=window.URL.createObjectURL(t);const s=document.createElement("a");s.id="jspsych-download-as-text-link",s.style.display="none",s.download=e,s.href=i,s.click()}function ke(r){const e=typeof r!="object"?JSON.parse(r):r;let t="",i="";const s=[];for(const l of e)for(const o in l){let a=o+"";a='"'+a.replace(/"/g,'""')+'",',s.includes(o)||(s.push(o),t+=a)}t=t.slice(0,-1),i+=t+`\r
2
- `;for(const l of e){t="";for(const o of s){let a=typeof l[o]=="undefined"?"":l[o];typeof a=="object"&&(a=JSON.stringify(a));const n=a+"";t+='"'+n.replace(/"/g,'""')+'",'}t=t.slice(0,-1),i+=t+`\r
3
- `}return i}function je(){const r=window.location.search.substr(1).split("&"),e={};for(let t=0;t<r.length;++t){const i=r[t].split("=",2);i.length==1?e[i[0]]="":e[i[0]]=decodeURIComponent(i[1].replace(/\+/g," "))}return e}class p{constructor(e=[]){this.trials=e}push(e){return this.trials.push(e),this}join(e){return this.trials=this.trials.concat(e.values()),this}top(){return this.trials.length<=1?this:new p([this.trials[this.trials.length-1]])}first(e=1){if(e<1)throw`You must query with a positive nonzero integer. Please use a
4
- different value for n.`;return this.trials.length===0?new p:(e>this.trials.length&&(e=this.trials.length),new p(this.trials.slice(0,e)))}last(e=1){if(e<1)throw`You must query with a positive nonzero integer. Please use a
5
- different value for n.`;return this.trials.length===0?new p:(e>this.trials.length&&(e=this.trials.length),new p(this.trials.slice(this.trials.length-e,this.trials.length)))}values(){return this.trials}count(){return this.trials.length}readOnly(){return new p(f(this.trials))}addToAll(e){for(const t of this.trials)Object.assign(t,e);return this}addToLast(e){return this.trials.length>0&&Object.assign(this.trials[this.trials.length-1],e),this}filter(e){let t;Array.isArray(e)?t=f(e):t=f([e]);const i=[];for(const s of this.trials){let l=!1;for(const o of t){let a=!0;for(const n of Object.keys(o))typeof s[n]!="undefined"&&s[n]===o[n]||(a=!1);if(a){l=!0;break}}l&&i.push(s)}return new p(i)}filterCustom(e){return new p(this.trials.filter(e))}filterColumns(e){return new p(this.trials.map(t=>Object.fromEntries(e.filter(i=>i in t).map(i=>[i,t[i]]))))}select(e){const t=[];for(const i of this.trials)typeof i[e]!="undefined"&&t.push(i[e]);return new I(t)}ignore(e){Array.isArray(e)||(e=[e]);const t=f(this.trials);for(const i of t)for(const s of e)delete i[s];return new p(t)}uniqueNames(){const e=[];for(const t of this.trials)for(const i of Object.keys(t))e.includes(i)||e.push(i);return e}csv(){return ke(this.trials)}json(e=!1){return e?JSON.stringify(this.trials,null," "):JSON.stringify(this.trials)}localSave(e,t){e=e.toLowerCase();let i;if(e==="json")i=this.json();else if(e==="csv")i=this.csv();else throw new Error('Invalid format specified for localSave. Must be "json" or "csv".');xe(i,t)}}var Te=Object.defineProperty,U=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,F=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ie=(r,e)=>{for(var t in e||(e={}))Oe.call(e,t)&&F(r,t,e[t]);if(U)for(var t of U(e))Ae.call(e,t)&&F(r,t,e[t]);return r};class Le{constructor(e){this.dependencies=e,this.dataProperties={},this.interactionListeners={blur:()=>{this.addInteractionRecord("blur")},focus:()=>{this.addInteractionRecord("focus")},fullscreenchange:()=>{this.addInteractionRecord(document.isFullScreen||document.webkitIsFullScreen||document.mozIsFullScreen||document.fullscreenElement?"fullscreenenter":"fullscreenexit")}},this.reset()}reset(){this.results=new p,this.resultToTrialMap=new WeakMap,this.interactionRecords=new p}get(){return this.results}getInteractionData(){return this.interactionRecords}write(e){const t=e.getResult();Object.assign(t,this.dataProperties),this.results.push(t),this.resultToTrialMap.set(t,e)}addProperties(e){this.results.addToAll(e),this.dataProperties=Object.assign({},this.dataProperties,e)}addDataToLastTrial(e){this.results.addToLast(e)}getLastTrialData(){return this.results.top()}getLastTimelineData(){const e=this.getLastTrialData().values()[0];return new p(e?this.resultToTrialMap.get(e).parent.getResults():[])}displayData(e="json"){e=e.toLowerCase(),e!=="json"&&e!=="csv"&&(console.log("Invalid format declared for displayData function. Using json as default."),e="json");const t=document.createElement("pre");t.id="jspsych-data-display",t.textContent=e==="json"?this.results.json(!0):this.results.csv(),this.dependencies.getDisplayElement().replaceChildren(t)}urlVariables(){return typeof this.query_string=="undefined"&&(this.query_string=je()),this.query_string}getURLVariable(e){return this.urlVariables()[e]}addInteractionRecord(e){const t=Ie({event:e},this.dependencies.getProgress());this.interactionRecords.push(t),this.dependencies.onInteractionRecordAdded(t)}createInteractionListeners(){window.addEventListener("blur",this.interactionListeners.blur),window.addEventListener("focus",this.interactionListeners.focus),document.addEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}removeInteractionListeners(){window.removeEventListener("blur",this.interactionListeners.blur),window.removeEventListener("focus",this.interactionListeners.focus),document.removeEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}}class Se{constructor(e,t=!1,i=0){this.getRootElement=e,this.areResponsesCaseSensitive=t,this.minimumValidRt=i,this.listeners=new Set,this.heldKeys=new Set,this.areRootListenersRegistered=!1,A(this),this.registerRootListeners()}registerRootListeners(){if(!this.areRootListenersRegistered){const e=this.getRootElement();e&&(e.addEventListener("keydown",this.rootKeydownListener),e.addEventListener("keyup",this.rootKeyupListener),this.areRootListenersRegistered=!0)}}rootKeydownListener(e){for(const t of[...this.listeners])t(e);this.heldKeys.add(this.toLowerCaseIfInsensitive(e.key))}toLowerCaseIfInsensitive(e){return this.areResponsesCaseSensitive?e:e.toLowerCase()}rootKeyupListener(e){this.heldKeys.delete(this.toLowerCaseIfInsensitive(e.key))}isResponseValid(e,t,i){return!t&&this.heldKeys.has(i)?!1:e==="ALL_KEYS"?!0:e==="NO_KEYS"?!1:e.includes(i)}getKeyboardResponse({callback_function:e,valid_responses:t="ALL_KEYS",rt_method:i="performance",persist:s,audio_context:l,audio_context_start_time:o,allow_held_key:a=!1,minimum_valid_rt:n=this.minimumValidRt}){i!=="performance"&&i!=="audio"&&(console.log('Invalid RT method specified in getKeyboardResponse. Defaulting to "performance" method.'),i="performance");const u=i==="performance"?performance.now():o*1e3;this.registerRootListeners(),!this.areResponsesCaseSensitive&&typeof t!="string"&&(t=t.map(h=>h.toLowerCase()));const c=h=>{const d=Math.round((i=="performance"?performance.now():l.currentTime*1e3)-u);if(d<n)return;const y=this.toLowerCaseIfInsensitive(h.key);this.isResponseValid(t,a,y)&&(h.preventDefault(),s||this.cancelKeyboardResponse(c),e({key:h.key,rt:d}))};return this.listeners.add(c),c}cancelKeyboardResponse(e){this.listeners.delete(e)}cancelAllKeyboardResponses(){this.listeners.clear()}compareKeys(e,t){if(typeof e!="string"&&e!==null||typeof t!="string"&&t!==null){console.error("Error in jsPsych.pluginAPI.compareKeys: arguments must be key strings or null.");return}return typeof e=="string"&&typeof t=="string"?this.areResponsesCaseSensitive?e===t:e.toLowerCase()===t.toLowerCase():e===null&&t===null}}var g=(r=>(r[r.BOOL=0]="BOOL",r[r.STRING=1]="STRING",r[r.INT=2]="INT",r[r.FLOAT=3]="FLOAT",r[r.FUNCTION=4]="FUNCTION",r[r.KEY=5]="KEY",r[r.KEYS=6]="KEYS",r[r.SELECT=7]="SELECT",r[r.HTML_STRING=8]="HTML_STRING",r[r.IMAGE=9]="IMAGE",r[r.AUDIO=10]="AUDIO",r[r.VIDEO=11]="VIDEO",r[r.OBJECT=12]="OBJECT",r[r.COMPLEX=13]="COMPLEX",r[r.TIMELINE=14]="TIMELINE",r))(g||{}),L=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class j{constructor(e,t={useWebAudio:!1}){this.src=e,this.useWebAudio=t.useWebAudio,this.audioContext=t.audioContext||null}load(){return L(this,null,function*(){this.useWebAudio?this.webAudioBuffer=yield this.preloadWebAudio(this.src):this.audio=yield this.preloadHTMLAudio(this.src)})}play(){this.audio instanceof HTMLAudioElement?this.audio.play():(this.audio||(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.start())}stop(){this.audio instanceof HTMLAudioElement?(this.audio.pause(),this.audio.currentTime=0):(this.audio.stop(),this.audio=this.getAudioSourceNode(this.webAudioBuffer))}addEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.addEventListener(e,t)}removeEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.removeEventListener(e,t)}getAudioSourceNode(e){const t=this.audioContext.createBufferSource();return t.buffer=e,t.connect(this.audioContext.destination),t}preloadWebAudio(e){return L(this,null,function*(){const t=yield(yield fetch(e)).arrayBuffer(),i=yield this.audioContext.decodeAudioData(t),s=this.audioContext.createBufferSource();return s.buffer=i,s.connect(this.audioContext.destination),i})}preloadHTMLAudio(e){return L(this,null,function*(){return new Promise((t,i)=>{const s=new Audio(e);s.addEventListener("canplaythrough",()=>{t(s)}),s.addEventListener("error",l=>{i(l)}),s.addEventListener("abort",l=>{i(l)})})})}}var Ce=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});const G=[g.AUDIO,g.IMAGE,g.VIDEO];class Me{constructor(e){this.useWebaudio=e,this.video_buffers={},this.context=null,this.audio_buffers=[],this.preload_requests=[],this.img_cache={},this.preloadMap=new Map,this.microphone_recorder=null,this.camera_stream=null,this.camera_recorder=null,this.useWebaudio&&typeof window!="undefined"&&typeof window.AudioContext!="undefined"&&(this.context=new AudioContext)}getVideoBuffer(e){return e.startsWith("blob:")&&(this.video_buffers[e]=e),this.video_buffers[e]}audioContext(){return this.context&&this.context.state!=="running"&&this.context.resume(),this.context}getAudioPlayer(e){return Ce(this,null,function*(){return this.audio_buffers[e]instanceof j?this.audio_buffers[e]:(this.audio_buffers[e]=new j(e,{useWebAudio:this.useWebaudio,audioContext:this.context}),yield this.audio_buffers[e].load(),this.audio_buffers[e])})}preloadAudio(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());let l=0;if(e.length==0){t();return}for(const o of e)this.audio_buffers[o]instanceof j?(l++,i(o),l==e.length&&t()):(this.audio_buffers[o]=new j(o,{useWebAudio:this.useWebaudio,audioContext:this.context}),this.audio_buffers[o].load().then(()=>{l++,i(o),l==e.length&&t()}).catch(a=>{s(a)}))}preloadImages(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());var l=0;if(e.length===0){t();return}for(let o=0;o<e.length;o++){const a=new Image,n=e[o];a.onload=()=>{l++,i(n),l===e.length&&t()},a.onerror=u=>{s({source:n,error:u})},a.src=n,this.img_cache[n]=a,this.preload_requests.push(a)}}preloadVideo(e,t=()=>{},i=l=>{},s=l=>{}){e=x(e.flat());let l=0;if(e.length===0){t();return}for(const o of e){const a=this.video_buffers,n=new XMLHttpRequest;n.open("GET",o,!0),n.responseType="blob",n.onload=()=>{if(n.status===200||n.status===0){const u=n.response;a[o]=URL.createObjectURL(u),l++,i(o),l===e.length&&t()}},n.onerror=u=>{let c=u;n.status==404&&(c="404"),s({source:o,error:c})},n.onloadend=u=>{n.status==404&&s({source:o,error:"404"})},n.send(),this.preload_requests.push(n)}}getAutoPreloadList(e){const t=Object.fromEntries(G.map(s=>[s,new Set])),i=(s,l)=>{var o,a,n,u;if(typeof s.timeline!="undefined")for(const c of s.timeline)i(c,(o=s.type)!=null?o:l);else if((n=(a=s.type)!=null?a:l)!=null&&n.info){const{name:c,parameters:h}=((u=s.type)!=null?u:l).info;this.preloadMap.has(c)||this.preloadMap.set(c,Object.fromEntries(Object.entries(h).filter(([d,{type:y,preload:P}])=>G.includes(y)&&(P!=null?P:!0)).map(([d,{type:y}])=>[d,y])));for(const[d,y]of Object.entries(this.preloadMap.get(c))){const P=s[d],ye=t[y];if(typeof P=="string")ye.add(P);else if(Array.isArray(P))for(const be of P.flat())typeof be=="string"&&ye.add(be)}}};return i({timeline:e}),{images:[...t[g.IMAGE]],audio:[...t[g.AUDIO]],video:[...t[g.VIDEO]]}}cancelPreloads(){for(const e of this.preload_requests)e.onload=()=>{},e.onerror=()=>{},e.oncanplaythrough=()=>{},e.onabort=()=>{};this.preload_requests=[]}initializeMicrophoneRecorder(e){const t=new MediaRecorder(e);this.microphone_recorder=t}getMicrophoneRecorder(){return this.microphone_recorder}initializeCameraRecorder(e,t){this.camera_stream=e;const i=new MediaRecorder(e,t);this.camera_recorder=i}getCameraStream(){return this.camera_stream}getCameraRecorder(){return this.camera_recorder}}var Ne=Object.defineProperty,W=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,Y=(r,e,t)=>e in r?Ne(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,J=(r,e)=>{for(var t in e||(e={}))Re.call(e,t)&&Y(r,t,e[t]);if(W)for(var t of W(e))De.call(e,t)&&Y(r,t,e[t]);return r};class Ve{constructor(e,t){this.getDisplayContainerElement=e,this.setJsPsychTimeout=t}dispatchEvent(e){this.getDisplayContainerElement().dispatchEvent(e)}keyDown(e){this.dispatchEvent(new KeyboardEvent("keydown",{key:e}))}keyUp(e){this.dispatchEvent(new KeyboardEvent("keyup",{key:e}))}pressKey(e,t=0){t>0?this.setJsPsychTimeout(()=>{this.keyDown(e),this.keyUp(e)},t):(this.keyDown(e),this.keyUp(e))}clickTarget(e,t=0){t>0?this.setJsPsychTimeout(()=>{e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))},t):(e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0})))}fillTextInput(e,t,i=0){i>0?this.setJsPsychTimeout(()=>{e.value=t},i):e.value=t}getValidKey(e){const t=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"," "];let i;if(e=="NO_KEYS")i=null;else if(e=="ALL_KEYS")i=t[Math.floor(Math.random()*t.length)];else{const s=e.flat();i=s[Math.floor(Math.random()*s.length)]}return i}mergeSimulationData(e,t){return J(J({},e),t==null?void 0:t.data)}ensureSimulationDataConsistency(e,t){if(t.rt&&(t.rt=Math.round(t.rt)),e.trial_duration&&t.rt&&t.rt>e.trial_duration&&(t.rt=null,t.response&&(t.response=null),t.correct&&(t.correct=!1)),e.choices&&e.choices=="NO_KEYS"&&(t.rt&&(t.rt=null),t.response&&(t.response=null)),e.allow_response_before_complete&&e.sequence_reps&&e.frame_time){const i=e.sequence_reps*e.frame_time*e.stimuli.length;t.rt<i&&(t.rt=null,t.response=null)}}}class qe{constructor(){this.timeout_handlers=[]}setTimeout(e,t){const i=window.setTimeout(e,t);return this.timeout_handlers.push(i),i}clearAllTimeouts(){for(const e of this.timeout_handlers)clearTimeout(e);this.timeout_handlers=[]}}function ze(r){const e=r.getInitSettings(),t=new Se(r.getDisplayContainerElement,e.case_sensitive_responses,e.minimum_valid_rt),i=new qe,s=new Me(e.use_webaudio),l=new Ve(r.getDisplayContainerElement,i.setTimeout.bind(i));return Object.assign({},...[t,i,s,l].map(o=>A(o)))}var S=["ability","able","aboard","about","above","accept","accident","according","account","accurate","acres","across","act","action","active","activity","actual","actually","add","addition","additional","adjective","adult","adventure","advice","affect","afraid","after","afternoon","again","against","age","ago","agree","ahead","aid","air","airplane","alike","alive","all","allow","almost","alone","along","aloud","alphabet","already","also","although","am","among","amount","ancient","angle","angry","animal","announced","another","answer","ants","any","anybody","anyone","anything","anyway","anywhere","apart","apartment","appearance","apple","applied","appropriate","are","area","arm","army","around","arrange","arrangement","arrive","arrow","art","article","as","aside","ask","asleep","at","ate","atmosphere","atom","atomic","attached","attack","attempt","attention","audience","author","automobile","available","average","avoid","aware","away","baby","back","bad","badly","bag","balance","ball","balloon","band","bank","bar","bare","bark","barn","base","baseball","basic","basis","basket","bat","battle","be","bean","bear","beat","beautiful","beauty","became","because","become","becoming","bee","been","before","began","beginning","begun","behavior","behind","being","believed","bell","belong","below","belt","bend","beneath","bent","beside","best","bet","better","between","beyond","bicycle","bigger","biggest","bill","birds","birth","birthday","bit","bite","black","blank","blanket","blew","blind","block","blood","blow","blue","board","boat","body","bone","book","border","born","both","bottle","bottom","bound","bow","bowl","box","boy","brain","branch","brass","brave","bread","break","breakfast","breath","breathe","breathing","breeze","brick","bridge","brief","bright","bring","broad","broke","broken","brother","brought","brown","brush","buffalo","build","building","built","buried","burn","burst","bus","bush","business","busy","but","butter","buy","by","cabin","cage","cake","call","calm","came","camera","camp","can","canal","cannot","cap","capital","captain","captured","car","carbon","card","care","careful","carefully","carried","carry","case","cast","castle","cat","catch","cattle","caught","cause","cave","cell","cent","center","central","century","certain","certainly","chain","chair","chamber","chance","change","changing","chapter","character","characteristic","charge","chart","check","cheese","chemical","chest","chicken","chief","child","children","choice","choose","chose","chosen","church","circle","circus","citizen","city","class","classroom","claws","clay","clean","clear","clearly","climate","climb","clock","close","closely","closer","cloth","clothes","clothing","cloud","club","coach","coal","coast","coat","coffee","cold","collect","college","colony","color","column","combination","combine","come","comfortable","coming","command","common","community","company","compare","compass","complete","completely","complex","composed","composition","compound","concerned","condition","congress","connected","consider","consist","consonant","constantly","construction","contain","continent","continued","contrast","control","conversation","cook","cookies","cool","copper","copy","corn","corner","correct","correctly","cost","cotton","could","count","country","couple","courage","course","court","cover","cow","cowboy","crack","cream","create","creature","crew","crop","cross","crowd","cry","cup","curious","current","curve","customs","cut","cutting","daily","damage","dance","danger","dangerous","dark","darkness","date","daughter","dawn","day","dead","deal","dear","death","decide","declared","deep","deeply","deer","definition","degree","depend","depth","describe","desert","design","desk","detail","determine","develop","development","diagram","diameter","did","die","differ","difference","different","difficult","difficulty","dig","dinner","direct","direction","directly","dirt","dirty","disappear","discover","discovery","discuss","discussion","disease","dish","distance","distant","divide","division","do","doctor","does","dog","doing","doll","dollar","done","donkey","door","dot","double","doubt","down","dozen","draw","drawn","dream","dress","drew","dried","drink","drive","driven","driver","driving","drop","dropped","drove","dry","duck","due","dug","dull","during","dust","duty","each","eager","ear","earlier","early","earn","earth","easier","easily","east","easy","eat","eaten","edge","education","effect","effort","egg","eight","either","electric","electricity","element","elephant","eleven","else","empty","end","enemy","energy","engine","engineer","enjoy","enough","enter","entire","entirely","environment","equal","equally","equator","equipment","escape","especially","essential","establish","even","evening","event","eventually","ever","every","everybody","everyone","everything","everywhere","evidence","exact","exactly","examine","example","excellent","except","exchange","excited","excitement","exciting","exclaimed","exercise","exist","expect","experience","experiment","explain","explanation","explore","express","expression","extra","eye","face","facing","fact","factor","factory","failed","fair","fairly","fall","fallen","familiar","family","famous","far","farm","farmer","farther","fast","fastened","faster","fat","father","favorite","fear","feathers","feature","fed","feed","feel","feet","fell","fellow","felt","fence","few","fewer","field","fierce","fifteen","fifth","fifty","fight","fighting","figure","fill","film","final","finally","find","fine","finest","finger","finish","fire","fireplace","firm","first","fish","five","fix","flag","flame","flat","flew","flies","flight","floating","floor","flow","flower","fly","fog","folks","follow","food","foot","football","for","force","foreign","forest","forget","forgot","forgotten","form","former","fort","forth","forty","forward","fought","found","four","fourth","fox","frame","free","freedom","frequently","fresh","friend","friendly","frighten","frog","from","front","frozen","fruit","fuel","full","fully","fun","function","funny","fur","furniture","further","future","gain","game","garage","garden","gas","gasoline","gate","gather","gave","general","generally","gentle","gently","get","getting","giant","gift","girl","give","given","giving","glad","glass","globe","go","goes","gold","golden","gone","good","goose","got","government","grabbed","grade","gradually","grain","grandfather","grandmother","graph","grass","gravity","gray","great","greater","greatest","greatly","green","grew","ground","group","grow","grown","growth","guard","guess","guide","gulf","gun","habit","had","hair","half","halfway","hall","hand","handle","handsome","hang","happen","happened","happily","happy","harbor","hard","harder","hardly","has","hat","have","having","hay","he","headed","heading","health","heard","hearing","heart","heat","heavy","height","held","hello","help","helpful","her","herd","here","herself","hidden","hide","high","higher","highest","highway","hill","him","himself","his","history","hit","hold","hole","hollow","home","honor","hope","horn","horse","hospital","hot","hour","house","how","however","huge","human","hundred","hung","hungry","hunt","hunter","hurried","hurry","hurt","husband","ice","idea","identity","if","ill","image","imagine","immediately","importance","important","impossible","improve","in","inch","include","including","income","increase","indeed","independent","indicate","individual","industrial","industry","influence","information","inside","instance","instant","instead","instrument","interest","interior","into","introduced","invented","involved","iron","is","island","it","its","itself","jack","jar","jet","job","join","joined","journey","joy","judge","jump","jungle","just","keep","kept","key","kids","kill","kind","kitchen","knew","knife","know","knowledge","known","label","labor","lack","lady","laid","lake","lamp","land","language","large","larger","largest","last","late","later","laugh","law","lay","layers","lead","leader","leaf","learn","least","leather","leave","leaving","led","left","leg","length","lesson","let","letter","level","library","lie","life","lift","light","like","likely","limited","line","lion","lips","liquid","list","listen","little","live","living","load","local","locate","location","log","lonely","long","longer","look","loose","lose","loss","lost","lot","loud","love","lovely","low","lower","luck","lucky","lunch","lungs","lying","machine","machinery","mad","made","magic","magnet","mail","main","mainly","major","make","making","man","managed","manner","manufacturing","many","map","mark","market","married","mass","massage","master","material","mathematics","matter","may","maybe","me","meal","mean","means","meant","measure","meat","medicine","meet","melted","member","memory","men","mental","merely","met","metal","method","mice","middle","might","mighty","mile","military","milk","mill","mind","mine","minerals","minute","mirror","missing","mission","mistake","mix","mixture","model","modern","molecular","moment","money","monkey","month","mood","moon","more","morning","most","mostly","mother","motion","motor","mountain","mouse","mouth","move","movement","movie","moving","mud","muscle","music","musical","must","my","myself","mysterious","nails","name","nation","national","native","natural","naturally","nature","near","nearby","nearer","nearest","nearly","necessary","neck","needed","needle","needs","negative","neighbor","neighborhood","nervous","nest","never","new","news","newspaper","next","nice","night","nine","no","nobody","nodded","noise","none","noon","nor","north","nose","not","note","noted","nothing","notice","noun","now","number","numeral","nuts","object","observe","obtain","occasionally","occur","ocean","of","off","offer","office","officer","official","oil","old","older","oldest","on","once","one","only","onto","open","operation","opinion","opportunity","opposite","or","orange","orbit","order","ordinary","organization","organized","origin","original","other","ought","our","ourselves","out","outer","outline","outside","over","own","owner","oxygen","pack","package","page","paid","pain","paint","pair","palace","pale","pan","paper","paragraph","parallel","parent","park","part","particles","particular","particularly","partly","parts","party","pass","passage","past","path","pattern","pay","peace","pen","pencil","people","per","percent","perfect","perfectly","perhaps","period","person","personal","pet","phrase","physical","piano","pick","picture","pictured","pie","piece","pig","pile","pilot","pine","pink","pipe","pitch","place","plain","plan","plane","planet","planned","planning","plant","plastic","plate","plates","play","pleasant","please","pleasure","plenty","plural","plus","pocket","poem","poet","poetry","point","pole","police","policeman","political","pond","pony","pool","poor","popular","population","porch","port","position","positive","possible","possibly","post","pot","potatoes","pound","pour","powder","power","powerful","practical","practice","prepare","present","president","press","pressure","pretty","prevent","previous","price","pride","primitive","principal","principle","printed","private","prize","probably","problem","process","produce","product","production","program","progress","promised","proper","properly","property","protection","proud","prove","provide","public","pull","pupil","pure","purple","purpose","push","put","putting","quarter","queen","question","quick","quickly","quiet","quietly","quite","rabbit","race","radio","railroad","rain","raise","ran","ranch","range","rapidly","rate","rather","raw","rays","reach","read","reader","ready","real","realize","rear","reason","recall","receive","recent","recently","recognize","record","red","refer","refused","region","regular","related","relationship","religious","remain","remarkable","remember","remove","repeat","replace","replied","report","represent","require","research","respect","rest","result","return","review","rhyme","rhythm","rice","rich","ride","riding","right","ring","rise","rising","river","road","roar","rock","rocket","rocky","rod","roll","roof","room","root","rope","rose","rough","round","route","row","rubbed","rubber","rule","ruler","run","running","rush","sad","saddle","safe","safety","said","sail","sale","salmon","salt","same","sand","sang","sat","satellites","satisfied","save","saved","saw","say","scale","scared","scene","school","science","scientific","scientist","score","screen","sea","search","season","seat","second","secret","section","see","seed","seeing","seems","seen","seldom","select","selection","sell","send","sense","sent","sentence","separate","series","serious","serve","service","sets","setting","settle","settlers","seven","several","shade","shadow","shake","shaking","shall","shallow","shape","share","sharp","she","sheep","sheet","shelf","shells","shelter","shine","shinning","ship","shirt","shoe","shoot","shop","shore","short","shorter","shot","should","shoulder","shout","show","shown","shut","sick","sides","sight","sign","signal","silence","silent","silk","silly","silver","similar","simple","simplest","simply","since","sing","single","sink","sister","sit","sitting","situation","six","size","skill","skin","sky","slabs","slave","sleep","slept","slide","slight","slightly","slip","slipped","slope","slow","slowly","small","smaller","smallest","smell","smile","smoke","smooth","snake","snow","so","soap","social","society","soft","softly","soil","solar","sold","soldier","solid","solution","solve","some","somebody","somehow","someone","something","sometime","somewhere","son","song","soon","sort","sound","source","south","southern","space","speak","special","species","specific","speech","speed","spell","spend","spent","spider","spin","spirit","spite","split","spoken","sport","spread","spring","square","stage","stairs","stand","standard","star","stared","start","state","statement","station","stay","steady","steam","steel","steep","stems","step","stepped","stick","stiff","still","stock","stomach","stone","stood","stop","stopped","store","storm","story","stove","straight","strange","stranger","straw","stream","street","strength","stretch","strike","string","strip","strong","stronger","struck","structure","struggle","stuck","student","studied","studying","subject","substance","success","successful","such","sudden","suddenly","sugar","suggest","suit","sum","summer","sun","sunlight","supper","supply","support","suppose","sure","surface","surprise","surrounded","swam","sweet","swept","swim","swimming","swing","swung","syllable","symbol","system","table","tail","take","taken","tales","talk","tall","tank","tape","task","taste","taught","tax","tea","teach","teacher","team","tears","teeth","telephone","television","tell","temperature","ten","tent","term","terrible","test","than","thank","that","thee","them","themselves","then","theory","there","therefore","these","they","thick","thin","thing","think","third","thirty","this","those","thou","though","thought","thousand","thread","three","threw","throat","through","throughout","throw","thrown","thumb","thus","thy","tide","tie","tight","tightly","till","time","tin","tiny","tip","tired","title","to","tobacco","today","together","told","tomorrow","tone","tongue","tonight","too","took","tool","top","topic","torn","total","touch","toward","tower","town","toy","trace","track","trade","traffic","trail","train","transportation","trap","travel","treated","tree","triangle","tribe","trick","tried","trip","troops","tropical","trouble","truck","trunk","truth","try","tube","tune","turn","twelve","twenty","twice","two","type","typical","uncle","under","underline","understanding","unhappy","union","unit","universe","unknown","unless","until","unusual","up","upon","upper","upward","us","use","useful","using","usual","usually","valley","valuable","value","vapor","variety","various","vast","vegetable","verb","vertical","very","vessels","victory","view","village","visit","visitor","voice","volume","vote","vowel","voyage","wagon","wait","walk","wall","want","war","warm","warn","was","wash","waste","watch","water","wave","way","we","weak","wealth","wear","weather","week","weigh","weight","welcome","well","went","were","west","western","wet","whale","what","whatever","wheat","wheel","when","whenever","where","wherever","whether","which","while","whispered","whistle","white","who","whole","whom","whose","why","wide","widely","wife","wild","will","willing","win","wind","window","wing","winter","wire","wise","wish","with","within","without","wolf","women","won","wonder","wonderful","wood","wooden","wool","word","wore","work","worker","world","worried","worry","worse","worth","would","wrapped","write","writer","writing","written","wrong","wrote","yard","year","yellow","yes","yesterday","yet","you","young","younger","your","yourself","youth","zero","zebra","zipper","zoo","zulu"];function H(r){function e(){return r&&r.maxLength>1?t():i()}function t(){for(var c=!1,h;!c;)h=i(),h.length<=r.maxLength&&(c=!0);return h}function i(){return S[s(S.length)]}function s(c){return Math.floor(Math.random()*c)}if(typeof r=="undefined")return e();typeof r=="number"&&(r={exactly:r}),r.exactly&&(r.min=r.exactly,r.max=r.exactly),typeof r.wordsPerString!="number"&&(r.wordsPerString=1),typeof r.formatter!="function"&&(r.formatter=c=>c),typeof r.separator!="string"&&(r.separator=" ");for(var l=r.min+s(r.max+1-r.min),o=[],a="",n=0,u=0;u<l*r.wordsPerString;u++)n===r.wordsPerString-1?a+=r.formatter(e(),n):a+=r.formatter(e(),n)+r.separator,n++,(u+1)%r.wordsPerString===0&&(o.push(a),a="",n=0);return typeof r.join=="string"&&(o=o.join(r.join)),o}var Be=H;H.wordList=S;var $e=O(Be),C={exports:{}};C.exports,function(r){(function(e,t,i){function s(n){var u=this,c=a();u.next=function(){var h=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=h-(u.c=h|0)},u.c=1,u.s0=c(" "),u.s1=c(" "),u.s2=c(" "),u.s0-=c(n),u.s0<0&&(u.s0+=1),u.s1-=c(n),u.s1<0&&(u.s1+=1),u.s2-=c(n),u.s2<0&&(u.s2+=1),c=null}function l(n,u){return u.c=n.c,u.s0=n.s0,u.s1=n.s1,u.s2=n.s2,u}function o(n,u){var c=new s(n),h=u&&u.state,d=c.next;return d.int32=function(){return c.next()*4294967296|0},d.double=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.quick=d,h&&(typeof h=="object"&&l(h,c),d.state=function(){return l(c,{})}),d}function a(){var n=4022871197,u=function(c){c=String(c);for(var h=0;h<c.length;h++){n+=c.charCodeAt(h);var d=.02519603282416938*n;n=d>>>0,d-=n,d*=n,n=d>>>0,d-=n,n+=d*4294967296}return(n>>>0)*23283064365386963e-26};return u}t&&t.exports?t.exports=o:i&&i.amd?i(function(){return o}):this.alea=o})(we,r,!1)}(C);var Ke=C.exports,Ue=O(Ke),Fe=Object.defineProperty,Ge=Object.defineProperties,We=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Q=(r,e,t)=>e in r?Fe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,He=(r,e)=>{for(var t in e||(e={}))Ye.call(e,t)&&Q(r,t,e[t]);if(X)for(var t of X(e))Je.call(e,t)&&Q(r,t,e[t]);return r},Xe=(r,e)=>Ge(r,We(e));function Qe(r=Math.random().toString()){return Math.random=Ue(r),r}function M(r,e,t=!1){const i=Array.isArray(r),s=Array.isArray(e);if(!i)s?(e=[e[0]],console.log("Unclear parameters given to randomization.repeat. Multiple set sizes specified, but only one item exists to sample. Proceeding using the first set size.")):(r=[r],e=[e]);else if(s){if(r.length!=e.length)if(console.warn("Unclear parameters given to randomization.repeat. Items and repetitions are unequal lengths. Behavior may not be as expected."),e.length<r.length){let a=[];for(let n=0;n<r.length;n++)a.push(e);e=a}else e=e.slice(0,r.length)}else{let a=[];for(let n=0;n<r.length;n++)a.push(e);e=a}let l=[];for(let a=0;a<r.length;a++)for(let n=0;n<e[a];n++)r[a]==null||typeof r[a]!="object"?l.push(r[a]):l.push(Object.assign({},r[a]));let o=b(l);return t&&(o=ot(o)),o}function b(r){Array.isArray(r)||console.error("Argument to shuffle() must be an array.");const e=r.slice(0);let t=e.length,i,s;for(;t;)s=Math.floor(Math.random()*t--),i=e[t],e[t]=e[s],e[s]=i;return e}function Ze(r,e){Array.isArray(r)||console.error("First argument to shuffleNoRepeats() must be an array."),typeof e!="undefined"&&typeof e!="function"&&console.error("Second argument to shuffleNoRepeats() must be a function."),typeof e=="undefined"&&(e=function(i,s){return i===s});const t=b(r);for(let i=0;i<t.length-1;i++)if(e(t[i],t[i+1])){let s=Math.floor(Math.random()*(t.length-2))+1;for(;e(t[i+1],t[s])||e(t[i+1],t[s+1])||e(t[i+1],t[s-1])||e(t[i],t[s]);)s=Math.floor(Math.random()*(t.length-2))+1;const l=t[s];t[s]=t[i+1],t[i+1]=l}return t}function Z(r,e=!1){const t=r.length;if(t==1)return console.warn("shuffleAlternateGroups() was called with only one group. Defaulting to simple shuffle."),b(r[0]);let i=[];for(let a=0;a<t;a++)i.push(a);e&&(i=b(i));const s=[];let l=null;for(let a=0;a<t;a++)l=l===null?r[a].length:Math.min(l,r[a].length),s.push(b(r[a]));const o=[];for(let a=0;a<l;a++)for(let n=0;n<i.length;n++)o.push(s[i[n]][a]);return o}function ee(r,e){return Array.isArray(r)||console.error("First argument to sampleWithoutReplacement() must be an array"),e>r.length&&console.error("Cannot take a sample larger than the size of the set of items to sample."),b(r).slice(0,e)}function te(r,e,t){Array.isArray(r)||console.error("First argument to sampleWithReplacement() must be an array");const i=[];if(typeof t!="undefined"){t.length!==r.length&&console.error("The length of the weights array must equal the length of the array to be sampled from.");let o=0;for(const a of t)o+=a;for(const a of t)i.push(a/o)}else for(let o=0;o<r.length;o++)i.push(1/r.length);const s=[i[0]];for(let o=1;o<i.length;o++)s.push(i[o]+s[o-1]);const l=[];for(let o=0;o<e;o++){const a=Math.random();let n=0;for(;a>s[n];)n++;l.push(r[n])}return l}function et(r,e=1,t=!1){let i=[{}];for(const[s,l]of Object.entries(r)){const o=[];for(const a of l)for(const n of i)o.push(Xe(He({},n),{[s]:a}));i=o}return M(i,e,t)}function tt(r=32){let e="";const t="0123456789abcdefghjklmnopqrstuvwxyz";for(let i=0;i<r;i++)e+=t[Math.floor(Math.random()*t.length)];return e}function rt(r,e){if(e<r)throw new Error("Upper boundary must be greater than or equal to lower boundary");return r+Math.floor(Math.random()*(e-r+1))}function it(r){return Math.random()<=r?1:0}function N(r,e){return at()*e+r}function R(r){return-Math.log(Math.random())/r}function st(r,e,t,i=!1){let s=N(r,e)+R(t);if(i)for(;s<=0;)s=N(r,e)+R(t);return s}function nt(r){return $e(r)}function at(){for(var r=0,e=0;r===0;)r=Math.random();for(;e===0;)e=Math.random();return Math.sqrt(-2*Math.log(r))*Math.cos(2*Math.PI*e)}function ot(r){const e={};for(const t of r)for(const i of Object.keys(t))typeof e[i]=="undefined"&&(e[i]=[]),e[i].push(t[i]);return e}var lt=Object.freeze({__proto__:null,setSeed:Qe,repeat:M,shuffle:b,shuffleNoRepeats:Ze,shuffleAlternateGroups:Z,sampleWithoutReplacement:ee,sampleWithReplacement:te,factorial:et,randomID:tt,randomInt:rt,sampleBernoulli:it,sampleNormal:N,sampleExponential:R,sampleExGaussian:st,randomWords:nt});function re(){const r={previewMode:!1,outsideTurk:!1,hitId:"INVALID_URL_PARAMETER",assignmentId:"INVALID_URL_PARAMETER",workerId:"INVALID_URL_PARAMETER",turkSubmitTo:"INVALID_URL_PARAMETER"},e=function(i,s){s=s.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");const l="[\\?&]"+s+"=([^&#]*)",o=new RegExp(l).exec(i);return o==null?"":o[1]},t=e(window.location.href,"assignmentId")?window.location.href:document.referrer;return["assignmentId","hitId","workerId","turkSubmitTo"].map(function(i){r[i]=unescape(e(t,i))}),r.previewMode=r.assignmentId=="ASSIGNMENT_ID_NOT_AVAILABLE",r.outsideTurk=!r.previewMode&&r.hitId===""&&r.assignmentId==""&&r.workerId=="",r}function ut(r){const e=re(),t=e.assignmentId,i=e.turkSubmitTo;if(!t||!i)return;const s=document.createElement("form");s.method="POST",s.action=i+"/mturk/externalSubmit?assignmentId="+t;for(const l in r)if(r.hasOwnProperty(l)){const o=document.createElement("input");o.type="hidden",o.name=l,o.id=l,o.value=r[l],s.appendChild(o)}document.body.appendChild(s),s.submit()}var ct=Object.freeze({__proto__:null,turkInfo:re,submitToTurk:ut});class ht{constructor(e,t){this.containerElement=e,this.message=t,this._progress=0,this.setupElements()}setupElements(){this.messageSpan=document.createElement("span"),this.innerDiv=document.createElement("div"),this.innerDiv.id="jspsych-progressbar-inner",this.update();const e=document.createElement("div");e.id="jspsych-progressbar-outer",e.appendChild(this.innerDiv),this.containerElement.appendChild(this.messageSpan),this.containerElement.appendChild(e)}update(){this.innerDiv.style.width=this._progress*100+"%",typeof this.message=="function"?this.messageSpan.innerHTML=this.message(this._progress):this.messageSpan.innerHTML=this.message}set progress(e){if(typeof e!="number"||e<0||e>1)throw new Error("jsPsych.progressBar.progress must be a number between 0 and 1");this._progress=e,this.update()}get progress(){return this._progress}}class D{constructor(e){this.name=e}}const dt=["timeline","timeline_variables","name","repetitions","loop_function","conditional_function","randomize_order","sample","on_timeline_start","on_timeline_finish"];function pt(r){return!V(r)}function V(r){return Boolean(r.timeline)||Array.isArray(r)}var m=(r=>(r[r.PENDING=0]="PENDING",r[r.RUNNING=1]="RUNNING",r[r.PAUSED=2]="PAUSED",r[r.COMPLETED=3]="COMPLETED",r[r.ABORTED=4]="ABORTED",r))(m||{});class ie{constructor(){this.reset()}reset(){this.promise=new Promise(e=>{this.resolvePromise=e})}get(){return this.promise}resolve(e){this.resolvePromise(e),this.reset()}}function mt(r){return r&&typeof r.then=="function"}function ft(r){return new Promise(e=>setTimeout(e,r))}function se([r,...e]){let t=r!=null?r:"";for(const i of e)t+=Number.isNaN(Number.parseInt(i))?`.${i}`:`[${i}]`;return t}function gt(r){return typeof r=="object"&&r!==null}class q{constructor(){this.cache=new Map}static lookupChild(e,t){let i=!1,s;return Number.isNaN(Number.parseInt(t))?Object.hasOwn(e,t)&&(i=!0,s=e[t]):Number.parseInt(t)<e.length&&(i=!0,s=e[t]),{doesPathExist:i,value:s}}get(e){return this.cache.get(e.join("."))}has(e){return this.cache.has(e.join("."))}initialize(e){this.rootObject=e,this.cache.set("",e)}reset(){this.cache.clear(),this.cache.set("",this.rootObject)}set(e,t){this.cache.set(e.join("."),t)}lookup(e){if(this.has(e))return{doesPathExist:!0,value:this.get(e)};const t=i=>{const s=i.slice(0,-1),l=i[i.length-1];if(!this.has(s)&&s.length>0&&!t(s).doesPathExist)return{doesPathExist:!1};const o=this.get(s);if(!gt(o))return{doesPathExist:!1};const a=q.lookupChild(o,l);return a.doesPathExist&&this.set(i,a.value),a};return t(e)}}var yt=Object.defineProperty,ne=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,ae=(r,e,t)=>e in r?yt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,oe=(r,e)=>{for(var t in e||(e={}))bt.call(e,t)&&ae(r,t,e[t]);if(ne)for(var t of ne(e))wt.call(e,t)&&ae(r,t,e[t]);return r};class le{constructor(e){this.dependencies=e,this.status=m.PENDING,this.parameterValueCache=new q}getStatus(){return this.status}initializeParameterValueCache(){this.parameterValueCache.initialize(this.description)}resetParameterValueCache(){var e;this.parameterValueCache.reset(),(e=this.parent)==null||e.resetParameterValueCache()}getParameterValue(e,t={}){const{evaluateFunctions:i=!0,recursive:s=!0,cacheResult:l=!0,replaceResult:o}=t;typeof e=="string"&&(e=[e]);let{doesPathExist:a,value:n}=this.parameterValueCache.lookup(e);return!a&&s&&this.parent&&(n=this.parent.getParameterValue(e,t)),typeof n=="function"&&i&&(n=n()),n instanceof D&&(n=this.evaluateTimelineVariable(n)),typeof o=="function"&&(n=o(n)),l&&this.parameterValueCache.set(e,n),n}getDataParameter(){var e;const t=this.getParameterValue("data",{recursive:!1});return oe(oe({},Object.fromEntries(typeof t=="object"?Object.keys(t).map(i=>[i,this.getParameterValue(["data",i])]):[])),(e=this.parent)==null?void 0:e.getDataParameter())}}var vt=Object.defineProperty,Pt=Object.defineProperties,Et=Object.getOwnPropertyDescriptors,ue=Object.getOwnPropertySymbols,_t=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,ce=(r,e,t)=>e in r?vt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,z=(r,e)=>{for(var t in e||(e={}))_t.call(e,t)&&ce(r,t,e[t]);if(ue)for(var t of ue(e))xt.call(e,t)&&ce(r,t,e[t]);return r},kt=(r,e)=>Pt(r,Et(e)),B=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class T extends le{constructor(e,t,i){super(e),this.description=t,this.parent=i,this.onLoad=()=>{this.runParameterCallback("on_load"),this.dependencies.runOnLoadExtensionCallbacks(this.getParameterValue("extensions"))},this.initializeParameterValueCache(),this.trialObject=f(t),this.pluginClass=this.getParameterValue("type",{evaluateFunctions:!1}),this.pluginInfo=this.pluginClass.info,!("version"in this.pluginInfo)&&!("data"in this.pluginInfo)?console.warn(this.pluginInfo.name,"is missing the 'version' and 'data' fields. Please update plugin as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):"version"in this.pluginInfo?"data"in this.pluginInfo||console.warn(this.pluginInfo.name,"is missing the 'data' field. Please update plugin as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):console.warn(this.pluginInfo.name,"is missing the 'version' field. Please update plugin as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details.")}run(){return B(this,null,function*(){var e;this.status=m.RUNNING,this.processParameters(),this.onStart(),this.addCssClasses(),this.pluginInstance=this.dependencies.instantiatePlugin(this.pluginClass),this.result=this.processResult(yield this.executeTrial()),this.dependencies.onTrialResultAvailable(this),this.status=m.COMPLETED,yield this.onFinish(),this.removeCssClasses();const t=(e=this.getParameterValue("post_trial_gap"))!=null?e:this.dependencies.getDefaultIti();t!==0&&this.dependencies.getSimulationMode()!=="data-only"&&(yield ft(t)),this.resetParameterValueCache()})}executeTrial(){return B(this,null,function*(){const e=this.dependencies.finishTrialPromise.get();let t=!1;e.then(()=>{t=!0});const{trialReturnValue:i,hasTrialBeenSimulated:s}=this.invokeTrialMethod();let l;return mt(i)?(l=yield Promise.race([i,e]),t&&(l=yield e)):(s||this.onLoad(),l=yield e),this.cleanupTrial(),l})}invokeTrialMethod(){var e;const t=this.dependencies.getSimulationMode();if(t&&typeof this.pluginInstance.simulate=="function"){const i=this.getSimulationOptions();if(i.simulate!==!1)return{hasTrialBeenSimulated:!0,trialReturnValue:this.pluginInstance.simulate(this.trialObject,(e=i.mode)!=null?e:t,i,this.onLoad)}}return{hasTrialBeenSimulated:!1,trialReturnValue:this.pluginInstance.trial(this.dependencies.getDisplayElement(),this.trialObject,this.onLoad)}}cleanupTrial(){this.dependencies.clearAllTimeouts(),this.dependencies.getDisplayElement().innerHTML=""}addCssClasses(){const e=this.getParameterValue("css_classes"),t=this.dependencies.getDisplayElement().classList;typeof e=="string"?t.add(e):Array.isArray(e)&&t.add(...e)}removeCssClasses(){const e=this.getParameterValue("css_classes");e&&this.dependencies.getDisplayElement().classList.remove(...typeof e=="string"?[e]:e)}processResult(e){var t;e||(e={});for(const[s,l]of Object.entries((t=this.getParameterValue("save_trial_parameters"))!=null?t:{}))if(this.pluginInfo.parameters[s])if(l&&!Object.hasOwn(e,s)){let o=this.trialObject[s];typeof o=="function"&&(o=o.toString()),e[s]=o}else!l&&Object.hasOwn(e,s)&&delete e[s];else console.warn(`Non-existent parameter "${s}" specified in save_trial_parameters.`);e=kt(z(z({},this.getDataParameter()),e),{trial_type:this.pluginInfo.name,trial_index:this.index,plugin_version:this.pluginInfo.version?this.pluginInfo.version:null});const i=this.getParameterValue("save_timeline_variables");return i===!0?e.timeline_variables=z({},this.parent.getAllTimelineVariables()):Array.isArray(i)&&(e.timeline_variables=Object.fromEntries(Object.entries(this.parent.getAllTimelineVariables()).filter(([s,l])=>i.includes(s)))),e}runParameterCallback(e,...t){const i=this.getParameterValue(e,{evaluateFunctions:!1});if(i)return i(...t)}onStart(){this.dependencies.onTrialStart(this),this.runParameterCallback("on_start",this.trialObject),this.dependencies.runOnStartExtensionCallbacks(this.getParameterValue("extensions"))}onFinish(){return B(this,null,function*(){const e=yield this.dependencies.runOnFinishExtensionCallbacks(this.getParameterValue("extensions"));Object.assign(this.result,e),yield Promise.resolve(this.runParameterCallback("on_finish",this.getResult())),this.dependencies.onTrialFinished(this)})}evaluateTimelineVariable(e){var t;return(t=this.parent)==null?void 0:t.evaluateTimelineVariable(e)}getParameterValue(e,t={}){return dt.includes(typeof e=="string"?e:e[0])&&(t.recursive=!1),super.getParameterValue(e,t)}getSimulationOptions(){const e=this.getParameterValue("simulation_options",{replaceResult:(t={})=>{var i,s;if(typeof t=="string"){const l=this.dependencies.getGlobalSimulationOptions();t=(s=(i=l[t])!=null?i:l.default)!=null?s:{}}return k(f(this.dependencies.getGlobalSimulationOptions().default),f(t))}});return typeof e=="undefined"?{}:(e.mode=this.getParameterValue(["simulation_options","mode"]),e.simulate=this.getParameterValue(["simulation_options","simulate"]),e.data=this.getParameterValue(["simulation_options","data"]),typeof e.data=="object"&&(e.data=Object.fromEntries(Object.keys(e.data).map(t=>[t,this.getParameterValue(["simulation_options","data",t])]))),e)}getResult(){return this.getParameterValue("record_data")===!1?void 0:this.result}getResults(){const e=this.getResult();return e?[e]:[]}processParameters(){const e=(i,s,l=[])=>{for(const[o,a]of Object.entries(s)){const n=[...l,o];let u=this.getParameterValue(n,{evaluateFunctions:a.type!==g.FUNCTION,replaceResult:c=>{if(typeof c=="undefined"){if(typeof a.default=="undefined")throw new Error(`You must specify a value for the "${se(n)}" parameter in the "${this.pluginInfo.name}" plugin.`);return a.default}else return c}});if(a.array&&!Array.isArray(u)){const c=se(n);throw new Error(`A non-array value (\`${u}\`) was provided for the array parameter "${c}" in the "${this.pluginInfo.name}" plugin. Please make sure that "${c}" is an array.`)}a.type===g.COMPLEX&&a.nested&&(a.array?u=u.map((c,h)=>{const d=[...n,h.toString()],y=this.getParameterValue(d);return e(y,a.nested,d),y}):e(u,a.nested,n)),i[o]=u}},t=f(this.description);e(t,this.pluginInfo.parameters),this.trialObject=t}getLatestNode(){return this}getActiveTimelineByName(e){}}var jt=Object.defineProperty,he=Object.getOwnPropertySymbols,Tt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable,de=(r,e,t)=>e in r?jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pe=(r,e)=>{for(var t in e||(e={}))Tt.call(e,t)&&de(r,t,e[t]);if(he)for(var t of he(e))Ot.call(e,t)&&de(r,t,e[t]);return r},At=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class w extends le{constructor(e,t,i){super(e),this.parent=i,this.children=[],this.shouldAbort=!1,this.resumePromise=new ie,this.description=Array.isArray(t)?{timeline:t}:t,this.initializeParameterValueCache()}run(){return At(this,null,function*(){typeof this.index=="undefined"&&(this.index=0),this.status=m.RUNNING;const{conditional_function:e,loop_function:t,repetitions:i=1}=this.description;let s=this.generateTimelineVariableOrder();this.setCurrentTimelineVariablesByIndex(s[0]);let l=!0,o;if(!e||e()){this.onStart();for(let a=0;a<i;a++)do{o=[],l?l=!1:s=this.generateTimelineVariableOrder();for(const n of s){this.setCurrentTimelineVariablesByIndex(n);for(const u of this.description.timeline){const c=this.instantiateChildNode(u),h=this.currentChild;if(this.currentChild=c,c.index=h?h.getLatestNode().index+1:this.index,yield c.run(),this.status===m.PAUSED&&(yield this.resumePromise.get()),this.shouldAbort){this.status=m.ABORTED;return}o.push(...this.currentChild.getResults())}}}while(t&&t(new p(o)));this.onFinish()}this.status=m.COMPLETED})}onStart(){this.description.on_timeline_start&&this.description.on_timeline_start()}onFinish(){this.description.on_timeline_finish&&this.description.on_timeline_finish()}pause(){this.currentChild instanceof w&&this.currentChild.pause(),this.status=m.PAUSED}resume(){this.status==m.PAUSED&&(this.currentChild instanceof w&&this.currentChild.resume(),this.status=m.RUNNING,this.resumePromise.resolve())}abort(){(this.status===m.RUNNING||this.status===m.PAUSED)&&(this.currentChild instanceof w&&this.currentChild.abort(),this.shouldAbort=!0,this.status===m.PAUSED&&this.resume())}instantiateChildNode(e){const t=V(e)?new w(this.dependencies,e,this):new T(this.dependencies,e,this);return this.children.push(t),t}setCurrentTimelineVariablesByIndex(e){var t;this.currentTimelineVariables=pe(pe({},(t=this.parent)==null?void 0:t.getAllTimelineVariables()),e===null?void 0:this.description.timeline_variables[e])}generateTimelineVariableOrder(){var e;const t=(e=this.description.timeline_variables)==null?void 0:e.length;if(!t)return[null];let i=[...Array(t).keys()];const s=this.description.sample;if(s)switch(s.type){case"custom":i=s.fn(i);break;case"with-replacement":i=te(i,s.size,s.weights);break;case"without-replacement":i=ee(i,s.size);break;case"fixed-repetitions":i=M(i,s.size);break;case"alternate-groups":i=Z(s.groups,s.randomize_group_order);break;default:throw new Error(`Invalid type "${s.type}" in timeline sample parameters. Valid options for type are "custom", "with-replacement", "without-replacement", "fixed-repetitions", and "alternate-groups"`)}return this.description.randomize_order&&(i=b(i)),i}getAllTimelineVariables(){return this.currentTimelineVariables}evaluateTimelineVariable(e){var t;if((t=this.currentTimelineVariables)!=null&&t.hasOwnProperty(e.name))return this.currentTimelineVariables[e.name];throw new Error(`Timeline variable ${e.name} not found.`)}getResults(){const e=[];for(const t of this.children)if(t instanceof T){const i=t.getResult();i&&e.push(i)}else t instanceof w&&e.push(...t.getResults());return e}getNaiveProgress(){if(this.status===m.PENDING)return 0;const e=this.getLatestNode();if(!e)return 1;let t=e.index;return e.getStatus()===m.COMPLETED&&t++,Math.min(t/this.getNaiveTrialCount(),1)}getNaiveTrialCount(){const e=t=>{var i,s,l;const o=a=>a.map(n=>e(n)).reduce((n,u)=>n+u);if(Array.isArray(t))return o(t);if(pt(t))return 1;if(V(t)){let a=((i=t.timeline_variables)==null?void 0:i.length)||1;switch((s=t.sample)==null?void 0:s.type){case"with-replacement":case"without-replacement":a=t.sample.size;break;case"fixed-repetitions":a*=t.sample.size;break;case"alternate-groups":a=t.sample.groups.map(n=>n.length).reduce((n,u)=>n+u,0);break}return o(t.timeline)*((l=t.repetitions)!=null?l:1)*a}return 0};return e(this.description)}getLatestNode(){var e,t;return(t=(e=this.currentChild)==null?void 0:e.getLatestNode())!=null?t:this}getActiveTimelineByName(e){var t;return this.description.name===e?this:(t=this.currentChild)==null?void 0:t.getActiveTimelineByName(e)}}var It=Object.defineProperty,me=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,fe=(r,e,t)=>e in r?It(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ct=(r,e)=>{for(var t in e||(e={}))Lt.call(e,t)&&fe(r,t,e[t]);if(me)for(var t of me(e))St.call(e,t)&&fe(r,t,e[t]);return r},$=(r,e,t)=>new Promise((i,s)=>{var l=n=>{try{a(t.next(n))}catch(u){s(u)}},o=n=>{try{a(t.throw(n))}catch(u){s(u)}},a=n=>n.done?i(n.value):Promise.resolve(n.value).then(l,o);a((t=t.apply(r,e)).next())});class ge{constructor(e){this.turk=ct,this.randomization=lt,this.utils=_e,this.options={},this.isFileProtocolUsed=!1,this.finishTrialPromise=new ie,this.timelineDependencies={onTrialStart:t=>{this.options.on_trial_start(t.trialObject),this.getDisplayContainerElement().focus(),this.getDisplayElement().scrollTop=0},onTrialResultAvailable:t=>{const i=t.getResult();i&&(i.time_elapsed=this.getTotalTime(),this.data.write(t))},onTrialFinished:t=>{const i=t.getResult();this.options.on_trial_finish(i),i&&this.options.on_data_update(i),this.progressBar&&this.options.auto_update_progress_bar&&(this.progressBar.progress=this.timeline.getNaiveProgress())},runOnStartExtensionCallbacks:t=>this.extensionManager.onStart(t),runOnLoadExtensionCallbacks:t=>this.extensionManager.onLoad(t),runOnFinishExtensionCallbacks:t=>this.extensionManager.onFinish(t),getSimulationMode:()=>this.simulationMode,getGlobalSimulationOptions:()=>this.simulationOptions,instantiatePlugin:t=>new t(this),getDisplayElement:()=>this.getDisplayElement(),getDefaultIti:()=>this.getInitSettings().default_iti,finishTrialPromise:this.finishTrialPromise,clearAllTimeouts:()=>this.pluginAPI.clearAllTimeouts()},this.extensionManagerDependencies={instantiateExtension:t=>new t(this)},this.dataDependencies={getProgress:()=>{var t,i;return{time:this.getTotalTime(),trial:(i=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?i:0}},onInteractionRecordAdded:t=>{this.options.on_interaction_data_update(t)},getDisplayElement:()=>this.getDisplayElement()},e=Ct({display_element:void 0,on_finish:()=>{},on_trial_start:()=>{},on_trial_finish:()=>{},on_data_update:()=>{},on_interaction_data_update:()=>{},on_close:()=>{},use_webaudio:!0,show_progress_bar:!1,message_progress_bar:"Completion Progress",auto_update_progress_bar:!0,default_iti:0,minimum_valid_rt:0,experiment_width:null,override_safe_mode:!1,case_sensitive_responses:!1,extensions:[]},e),this.options=e,A(this),window.location.protocol=="file:"&&(e.override_safe_mode===!1||typeof e.override_safe_mode=="undefined")&&(e.use_webaudio=!1,this.isFileProtocolUsed=!0,console.warn("jsPsych detected that it is running via the file:// protocol and not on a web server. To prevent issues with cross-origin requests, Web Audio and video preloading have been disabled. If you would like to override this setting, you can set 'override_safe_mode' to 'true' in initJsPsych. For more information, see: https://www.jspsych.org/overview/running-experiments")),this.data=new Le(this.dataDependencies),this.pluginAPI=ze(this),this.extensionManager=new _(this.extensionManagerDependencies,e.extensions)}version(){return Ee.version}run(e){return $(this,null,function*(){typeof e=="undefined"&&console.error("No timeline declared in jsPsych.run(). Cannot start experiment."),e.length===0&&console.error("No trials have been added to the timeline (the timeline is an empty array). Cannot start experiment."),this.timeline=new w(this.timelineDependencies,e),yield this.prepareDom(),yield this.extensionManager.initializeExtensions(),document.documentElement.setAttribute("jspsych","present"),this.experimentStartTime=new Date,yield this.timeline.run(),yield Promise.resolve(this.options.on_finish(this.data.get())),this.endMessage&&(this.getDisplayElement().innerHTML=this.endMessage),this.data.removeInteractionListeners()})}simulate(e){return $(this,arguments,function*(t,i="data-only",s={}){this.simulationMode=i,this.simulationOptions=s,yield this.run(t)})}getProgress(){var e,t,i,s;return{total_trials:(e=this.timeline)==null?void 0:e.getNaiveTrialCount(),current_trial_global:(i=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?i:0,percent_complete:((s=this.timeline)==null?void 0:s.getNaiveProgress())*100}}getStartTime(){return this.experimentStartTime}getTotalTime(){return this.experimentStartTime?new Date().getTime()-this.experimentStartTime.getTime():0}getDisplayElement(){return this.displayElement}getDisplayContainerElement(){return this.displayContainerElement}abortExperiment(e,t={}){this.endMessage=e,this.timeline.abort(),this.pluginAPI.cancelAllKeyboardResponses(),this.pluginAPI.clearAllTimeouts(),this.finishTrial(t)}abortCurrentTimeline(){var e;let t=(e=this.timeline)==null?void 0:e.getLatestNode();t instanceof T&&(t=t.parent),t instanceof w&&t.abort()}abortTimelineByName(e){var t;const i=(t=this.timeline)==null?void 0:t.getActiveTimelineByName(e);i&&i.abort()}getCurrentTrial(){var e;const t=(e=this.timeline)==null?void 0:e.getLatestNode();if(t instanceof T)return t.description}getInitSettings(){return this.options}timelineVariable(e){return new D(e)}evaluateTimelineVariable(e){var t,i;return(i=(t=this.timeline)==null?void 0:t.getLatestNode())==null?void 0:i.evaluateTimelineVariable(new D(e))}pauseExperiment(){var e;(e=this.timeline)==null||e.pause()}resumeExperiment(){var e;(e=this.timeline)==null||e.resume()}getSafeModeStatus(){return this.isFileProtocolUsed}getTimeline(){var e;return(e=this.timeline)==null?void 0:e.description.timeline}get extensions(){var e,t;return(t=(e=this.extensionManager)==null?void 0:e.extensions)!=null?t:{}}prepareDom(){return $(this,null,function*(){document.readyState!=="complete"&&(yield new Promise(s=>{window.addEventListener("load",s)}));const e=this.options;if(typeof e.display_element=="undefined"){let s=document.body;s||(s=document.createElement("body"),document.documentElement.appendChild(s)),document.querySelector("html").style.height="100%",s.style.margin="0px",s.style.height="100%",s.style.width="100%",e.display_element=s}else{const s=e.display_element instanceof Element?e.display_element:document.querySelector("#"+e.display_element);s===null?console.error("The display_element specified in initJsPsych() does not exist in the DOM."):e.display_element=s}const t=document.createElement("div");t.id="jspsych-content";const i=document.createElement("div");if(i.className="jspsych-content-wrapper",i.appendChild(t),this.displayContainerElement=e.display_element,this.displayContainerElement.appendChild(i),this.displayElement=t,e.experiment_width!==null&&(this.displayElement.style.width=e.experiment_width+"px"),e.display_element.tabIndex=0,this.displayContainerElement.classList.add("jspsych-display-element"),this.displayElement.classList.add("jspsych-content"),this.data.createInteractionListeners(),window.addEventListener("beforeunload",e.on_close),this.options.show_progress_bar){const s=document.createElement("div");s.id="jspsych-progressbar-container",this.progressBar=new ht(s,this.options.message_progress_bar),this.getDisplayContainerElement().insertAdjacentElement("afterbegin",s)}})}finishTrial(e){this.finishTrialPromise.resolve(e)}}class v extends Error{constructor(e="The global `jsPsych` variable is no longer available in jsPsych v7."){super(`${e} Please follow the migration guide at https://www.jspsych.org/7.0/support/migration-v7/ to update your experiment.`),this.name="MigrationError"}}window.jsPsych={get init(){throw new v("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.")},get data(){throw new v},get randomization(){throw new v},get turk(){throw new v},get pluginAPI(){throw new v},get ALL_KEYS(){throw new v('jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.')},get NO_KEYS(){throw new v('jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.')}},typeof window!="undefined"&&window.hasOwnProperty("webkitAudioContext")&&!window.hasOwnProperty("AudioContext")&&(window.AudioContext=webkitAudioContext);function Mt(r){const e=new ge(r);return Object.defineProperties(e,Object.fromEntries(Object.entries({init:"`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.",ALL_KEYS:'jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.',NO_KEYS:'jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.',currentTimelineNodeID:"`currentTimelineNodeID()` was renamed to `getCurrentTimelineNodeID()` in jsPsych v7.",progress:"`progress()` was renamed to `getProgress()` in jsPsych v7.",startTime:"`startTime()` was renamed to `getStartTime()` in jsPsych v7.",totalTime:"`totalTime()` was renamed to `getTotalTime()` in jsPsych v7.",currentTrial:"`currentTrial()` was renamed to `getCurrentTrial()` in jsPsych v7.",initSettings:"`initSettings()` was renamed to `getInitSettings()` in jsPsych v7.",allTimelineVariables:"`allTimelineVariables()` was renamed to `getAllTimelineVariables()` in jsPsych v7."}).map(([t,i])=>[t,{get(){throw new v(i)}}]))),e}return E.DataCollection=p,E.JsPsych=ge,E.ParameterType=g,E.initJsPsych=Mt,E}({}),initJsPsych=jsPsychModule.initJsPsych;
6
- //# sourceMappingURL=https://unpkg.com/jspsych@8.1.0/dist/index.browser.min.js.map
1
+ var jsPsychModule=function(V){"use strict";var N=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function W(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}const Ke=r=>{const e=new Set;do for(const t of Reflect.ownKeys(r))e.add([r,t]);while((r=Reflect.getPrototypeOf(r))&&r!==Object.prototype);return e};var Ge=(r,{include:e,exclude:t}={})=>{const n=s=>{const u=l=>typeof l=="string"?s===l:l.test(s);return e?e.some(u):t?!t.some(u):!0};for(const[s,u]of Ke(r.constructor.prototype)){if(u==="constructor"||!n(u))continue;const l=Reflect.getOwnPropertyDescriptor(s,u);l&&typeof l.value=="function"&&(r[u]=r[u].bind(r))}return r},Y=W(Ge),Fe="8.2.0",fe=(r,e,t)=>new Promise((n,s)=>{var u=i=>{try{a(t.next(i))}catch(o){s(o)}},l=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(r,e)).next())});class B{constructor(e,t){this.dependencies=e,this.extensionsConfiguration=t,this.extensions=Object.fromEntries(t.map(n=>[B.getExtensionNameByClass(n.type),this.dependencies.instantiateExtension(n.type)]))}static getExtensionNameByClass(e){return e.info.name}getExtensionInstanceByClass(e){return this.extensions[B.getExtensionNameByClass(e)]}initializeExtensions(){return fe(this,null,function*(){yield Promise.all(this.extensionsConfiguration.map(({type:e,params:t={}})=>{this.getExtensionInstanceByClass(e).initialize(t);const n=e.info;!("version"in n)&&!("data"in n)?console.warn(n.name,"is missing the 'version' and 'data' fields. Please update extension as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."):"version"in n?"data"in n||console.warn(n.name,"is missing the 'data' field. Please update extension as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details."):console.warn(n.name,"is missing the 'version' field. Please update extension as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/extension-development/ for more details.")}))})}onStart(e=[]){var t;for(const{type:n,params:s}of e)(t=this.getExtensionInstanceByClass(n))==null||t.on_start(s)}onLoad(e=[]){var t;for(const{type:n,params:s}of e)(t=this.getExtensionInstanceByClass(n))==null||t.on_load(s)}onFinish(){return fe(this,arguments,function*(e=[]){const t=yield Promise.all(e.map(({type:s,params:u})=>{var l;return Promise.resolve((l=this.getExtensionInstanceByClass(s))==null?void 0:l.on_finish(u))})),n=e.length?{extension_type:e.map(({type:s})=>s.info.name),extension_version:e.map(({type:s})=>s.info.version)}:{};return t.unshift(n),Object.assign({},...t)})}}function U(r){return[...new Set(r)]}function j(r){if(!r)return r;let e;if(Array.isArray(r)){e=[];for(const t of r)e.push(j(t));return e}else if(typeof r=="object"&&r!==null){e={};for(const t in r)r.hasOwnProperty(t)&&(e[t]=j(r[t]));return e}else return r}function K(r,e){let t={};for(const n in r)r.hasOwnProperty(n)&&(typeof r[n]=="object"&&e.hasOwnProperty(n)?t[n]=K(r[n],e[n]):t[n]=r[n]);for(const n in e)e.hasOwnProperty(n)&&(t.hasOwnProperty(n)&&typeof e[n]=="object"?t[n]=K(t[n],e[n]):t[n]=e[n]);return t}var Je=Object.freeze({__proto__:null,deepCopy:j,deepMerge:K,unique:U});class X{constructor(e=[]){this.values=e}sum(){let e=0;for(const t of this.values)e+=t;return e}mean(){let e=0,t=0;for(const n of this.values)typeof n!="undefined"&&n!==null&&(e+=n,t++);if(t!==0)return e/t}median(){if(this.values.length===0)return;const e=this.values.slice(0).sort(function(n,s){return n-s}),t=Math.floor(e.length/2);return e.length%2===0?(e[t]+e[t-1])/2:e[t]}min(){return Math.min.apply(null,this.values)}max(){return Math.max.apply(null,this.values)}count(){return this.values.length}variance(){const e=this.mean();let t=0;for(const n of this.values)t+=Math.pow(n-e,2);return t/(this.values.length-1)}sd(){const e=this.variance();return Math.sqrt(e)}frequencies(){const e={};for(const t of this.values)typeof e[t]=="undefined"?e[t]=1:e[t]++;return e}all(e){for(const t of this.values)if(!e(t))return!1;return!0}subset(e){const t=[];for(const n of this.values)e(n)&&t.push(n);return new X(t)}}function We(r,e){const t=new Blob([r],{type:"text/plain"});let n="";typeof window.webkitURL!="undefined"?n=window.webkitURL.createObjectURL(t):n=window.URL.createObjectURL(t);const s=document.createElement("a");s.id="jspsych-download-as-text-link",s.style.display="none",s.download=e,s.href=n,s.click()}function Ye(r){const e=typeof r!="object"?JSON.parse(r):r;let t="",n="";const s=[];for(const u of e)for(const l in u){let a=l+"";a='"'+a.replace(/"/g,'""')+'",',s.includes(l)||(s.push(l),t+=a)}t=t.slice(0,-1),n+=t+`\r
2
+ `;for(const u of e){t="";for(const l of s){let a=typeof u[l]=="undefined"?"":u[l];typeof a=="object"&&(a=JSON.stringify(a));const i=a+"";t+='"'+i.replace(/"/g,'""')+'",'}t=t.slice(0,-1),n+=t+`\r
3
+ `}return n}function Xe(){const r=window.location.search.substr(1).split("&"),e={};for(let t=0;t<r.length;++t){const n=r[t].split("=",2);n.length==1?e[n[0]]="":e[n[0]]=decodeURIComponent(n[1].replace(/\+/g," "))}return e}class b{constructor(e=[]){this.trials=e}push(e){return this.trials.push(e),this}join(e){return this.trials=this.trials.concat(e.values()),this}top(){return this.trials.length<=1?this:new b([this.trials[this.trials.length-1]])}first(e=1){if(e<1)throw`You must query with a positive nonzero integer. Please use a
4
+ different value for n.`;return this.trials.length===0?new b:(e>this.trials.length&&(e=this.trials.length),new b(this.trials.slice(0,e)))}last(e=1){if(e<1)throw`You must query with a positive nonzero integer. Please use a
5
+ different value for n.`;return this.trials.length===0?new b:(e>this.trials.length&&(e=this.trials.length),new b(this.trials.slice(this.trials.length-e,this.trials.length)))}values(){return this.trials}count(){return this.trials.length}readOnly(){return new b(j(this.trials))}addToAll(e){for(const t of this.trials)Object.assign(t,e);return this}addToLast(e){return this.trials.length>0&&Object.assign(this.trials[this.trials.length-1],e),this}filter(e){let t;Array.isArray(e)?t=j(e):t=j([e]);const n=[];for(const s of this.trials){let u=!1;for(const l of t){let a=!0;for(const i of Object.keys(l))typeof s[i]!="undefined"&&s[i]===l[i]||(a=!1);if(a){u=!0;break}}u&&n.push(s)}return new b(n)}filterCustom(e){return new b(this.trials.filter(e))}filterColumns(e){return new b(this.trials.map(t=>Object.fromEntries(e.filter(n=>n in t).map(n=>[n,t[n]]))))}select(e){const t=[];for(const n of this.trials)typeof n[e]!="undefined"&&t.push(n[e]);return new X(t)}ignore(e){Array.isArray(e)||(e=[e]);const t=j(this.trials);for(const n of t)for(const s of e)delete n[s];return new b(t)}uniqueNames(){const e=[];for(const t of this.trials)for(const n of Object.keys(t))e.includes(n)||e.push(n);return e}csv(){return Ye(this.trials)}json(e=!1){return e?JSON.stringify(this.trials,null," "):JSON.stringify(this.trials)}localSave(e,t){e=e.toLowerCase();let n;if(e==="json")n=this.json();else if(e==="csv")n=this.csv();else throw new Error('Invalid format specified for localSave. Must be "json" or "csv".');We(n,t)}}var He=Object.defineProperty,me=Object.getOwnPropertySymbols,Qe=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,ge=(r,e,t)=>e in r?He(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,et=(r,e)=>{for(var t in e||(e={}))Qe.call(e,t)&&ge(r,t,e[t]);if(me)for(var t of me(e))Ze.call(e,t)&&ge(r,t,e[t]);return r};class tt{constructor(e){this.dependencies=e,this.dataProperties={},this.interactionListeners={blur:()=>{this.addInteractionRecord("blur")},focus:()=>{this.addInteractionRecord("focus")},fullscreenchange:()=>{this.addInteractionRecord(document.isFullScreen||document.webkitIsFullScreen||document.mozIsFullScreen||document.fullscreenElement?"fullscreenenter":"fullscreenexit")}},this.reset()}reset(){this.results=new b,this.resultToTrialMap=new WeakMap,this.interactionRecords=new b}get(){return this.results}getInteractionData(){return this.interactionRecords}write(e){const t=e.getResult();Object.assign(t,this.dataProperties),this.results.push(t),this.resultToTrialMap.set(t,e)}addProperties(e){this.results.addToAll(e),this.dataProperties=Object.assign({},this.dataProperties,e)}addDataToLastTrial(e){this.results.addToLast(e)}getLastTrialData(){return this.results.top()}getLastTimelineData(){const e=this.getLastTrialData().values()[0];return new b(e?this.resultToTrialMap.get(e).parent.getResults():[])}displayData(e="json"){e=e.toLowerCase(),e!=="json"&&e!=="csv"&&(console.log("Invalid format declared for displayData function. Using json as default."),e="json");const t=document.createElement("pre");t.id="jspsych-data-display",t.textContent=e==="json"?this.results.json(!0):this.results.csv(),this.dependencies.getDisplayElement().replaceChildren(t)}urlVariables(){return typeof this.query_string=="undefined"&&(this.query_string=Xe()),this.query_string}getURLVariable(e){return this.urlVariables()[e]}addInteractionRecord(e){const t=et({event:e},this.dependencies.getProgress());this.interactionRecords.push(t),this.dependencies.onInteractionRecordAdded(t)}createInteractionListeners(){window.addEventListener("blur",this.interactionListeners.blur),window.addEventListener("focus",this.interactionListeners.focus),document.addEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.addEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}removeInteractionListeners(){window.removeEventListener("blur",this.interactionListeners.blur),window.removeEventListener("focus",this.interactionListeners.focus),document.removeEventListener("fullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("mozfullscreenchange",this.interactionListeners.fullscreenchange),document.removeEventListener("webkitfullscreenchange",this.interactionListeners.fullscreenchange)}}class rt{constructor(e,t=!1,n=0){this.getRootElement=e,this.areResponsesCaseSensitive=t,this.minimumValidRt=n,this.listeners=new Set,this.heldKeys=new Set,this.areRootListenersRegistered=!1,Y(this),this.registerRootListeners()}registerRootListeners(){if(!this.areRootListenersRegistered){const e=this.getRootElement();e&&(e.addEventListener("keydown",this.rootKeydownListener),e.addEventListener("keyup",this.rootKeyupListener),this.areRootListenersRegistered=!0)}}rootKeydownListener(e){for(const t of[...this.listeners])t(e);this.heldKeys.add(this.toLowerCaseIfInsensitive(e.key))}toLowerCaseIfInsensitive(e){return this.areResponsesCaseSensitive?e:e.toLowerCase()}rootKeyupListener(e){this.heldKeys.delete(this.toLowerCaseIfInsensitive(e.key))}isResponseValid(e,t,n){return!t&&this.heldKeys.has(n)?!1:e==="ALL_KEYS"?!0:e==="NO_KEYS"?!1:e.includes(n)}getKeyboardResponse({callback_function:e,valid_responses:t="ALL_KEYS",rt_method:n="performance",persist:s,audio_context:u,audio_context_start_time:l,allow_held_key:a=!1,minimum_valid_rt:i=this.minimumValidRt}){n!=="performance"&&n!=="audio"&&(console.log('Invalid RT method specified in getKeyboardResponse. Defaulting to "performance" method.'),n="performance");const o=n==="performance"?performance.now():l*1e3;this.registerRootListeners(),!this.areResponsesCaseSensitive&&typeof t!="string"&&(t=t.map(c=>c.toLowerCase()));const d=c=>{const h=Math.round((n=="performance"?performance.now():u.currentTime*1e3)-o);if(h<i)return;const p=this.toLowerCaseIfInsensitive(c.key);this.isResponseValid(t,a,p)&&(c.preventDefault(),s||this.cancelKeyboardResponse(d),e({key:c.key,rt:h}))};return this.listeners.add(d),d}cancelKeyboardResponse(e){this.listeners.delete(e)}cancelAllKeyboardResponses(){this.listeners.clear()}compareKeys(e,t){if(typeof e!="string"&&e!==null||typeof t!="string"&&t!==null){console.error("Error in jsPsych.pluginAPI.compareKeys: arguments must be key strings or null.");return}return typeof e=="string"&&typeof t=="string"?this.areResponsesCaseSensitive?e===t:e.toLowerCase()===t.toLowerCase():e===null&&t===null}}var O=(r=>(r[r.BOOL=0]="BOOL",r[r.STRING=1]="STRING",r[r.INT=2]="INT",r[r.FLOAT=3]="FLOAT",r[r.FUNCTION=4]="FUNCTION",r[r.KEY=5]="KEY",r[r.KEYS=6]="KEYS",r[r.SELECT=7]="SELECT",r[r.HTML_STRING=8]="HTML_STRING",r[r.IMAGE=9]="IMAGE",r[r.AUDIO=10]="AUDIO",r[r.VIDEO=11]="VIDEO",r[r.OBJECT=12]="OBJECT",r[r.COMPLEX=13]="COMPLEX",r[r.TIMELINE=14]="TIMELINE",r))(O||{}),H=(r,e,t)=>new Promise((n,s)=>{var u=i=>{try{a(t.next(i))}catch(o){s(o)}},l=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(r,e)).next())});class G{constructor(e,t={useWebAudio:!1}){this.src=e,this.useWebAudio=t.useWebAudio,this.audioContext=t.audioContext||null}load(){return H(this,null,function*(){this.useWebAudio?this.webAudioBuffer=yield this.preloadWebAudio(this.src):this.audio=yield this.preloadHTMLAudio(this.src)})}play(){this.audio instanceof HTMLAudioElement?this.audio.play():(this.audio||(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.start())}stop(){this.audio instanceof HTMLAudioElement?(this.audio.pause(),this.audio.currentTime=0):(this.audio.stop(),this.audio=this.getAudioSourceNode(this.webAudioBuffer))}addEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.addEventListener(e,t)}removeEventListener(e,t){!this.audio&&this.webAudioBuffer&&(this.audio=this.getAudioSourceNode(this.webAudioBuffer)),this.audio.removeEventListener(e,t)}getAudioSourceNode(e){const t=this.audioContext.createBufferSource();return t.buffer=e,t.connect(this.audioContext.destination),t}preloadWebAudio(e){return H(this,null,function*(){const t=yield(yield fetch(e)).arrayBuffer(),n=yield this.audioContext.decodeAudioData(t),s=this.audioContext.createBufferSource();return s.buffer=n,s.connect(this.audioContext.destination),n})}preloadHTMLAudio(e){return H(this,null,function*(){return new Promise((t,n)=>{const s=new Audio(e);s.addEventListener("canplaythrough",()=>{t(s)}),s.addEventListener("error",u=>{n(u)}),s.addEventListener("abort",u=>{n(u)})})})}}var nt=(r,e,t)=>new Promise((n,s)=>{var u=i=>{try{a(t.next(i))}catch(o){s(o)}},l=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(r,e)).next())});const ye=[O.AUDIO,O.IMAGE,O.VIDEO];class it{constructor(e){this.useWebaudio=e,this.video_buffers={},this.context=null,this.audio_buffers=[],this.preload_requests=[],this.img_cache={},this.preloadMap=new Map,this.microphone_recorder=null,this.camera_stream=null,this.camera_recorder=null,this.useWebaudio&&typeof window!="undefined"&&typeof window.AudioContext!="undefined"&&(this.context=new AudioContext)}getVideoBuffer(e){return e.startsWith("blob:")&&(this.video_buffers[e]=e),this.video_buffers[e]}audioContext(){return this.context&&this.context.state!=="running"&&this.context.resume(),this.context}getAudioPlayer(e){return nt(this,null,function*(){return this.audio_buffers[e]instanceof G?this.audio_buffers[e]:(this.audio_buffers[e]=new G(e,{useWebAudio:this.useWebaudio,audioContext:this.context}),yield this.audio_buffers[e].load(),this.audio_buffers[e])})}preloadAudio(e,t=()=>{},n=u=>{},s=u=>{}){e=U(e.flat());let u=0;if(e.length==0){t();return}for(const l of e)this.audio_buffers[l]instanceof G?(u++,n(l),u==e.length&&t()):(this.audio_buffers[l]=new G(l,{useWebAudio:this.useWebaudio,audioContext:this.context}),this.audio_buffers[l].load().then(()=>{u++,n(l),u==e.length&&t()}).catch(a=>{s(a)}))}preloadImages(e,t=()=>{},n=u=>{},s=u=>{}){e=U(e.flat());var u=0;if(e.length===0){t();return}for(let l=0;l<e.length;l++){const a=new Image,i=e[l];a.onload=()=>{u++,n(i),u===e.length&&t()},a.onerror=o=>{s({source:i,error:o})},a.src=i,this.img_cache[i]=a,this.preload_requests.push(a)}}preloadVideo(e,t=()=>{},n=u=>{},s=u=>{}){e=U(e.flat());let u=0;if(e.length===0){t();return}for(const l of e){const a=this.video_buffers,i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType="blob",i.onload=()=>{if(i.status===200||i.status===0){const o=i.response;a[l]=URL.createObjectURL(o),u++,n(l),u===e.length&&t()}},i.onerror=o=>{let d=o;i.status==404&&(d="404"),s({source:l,error:d})},i.onloadend=o=>{i.status==404&&s({source:l,error:"404"})},i.send(),this.preload_requests.push(i)}}getAutoPreloadList(e){const t=Object.fromEntries(ye.map(s=>[s,new Set])),n=(s,u)=>{var l,a,i,o;if(typeof s.timeline!="undefined")for(const d of s.timeline)n(d,(l=s.type)!=null?l:u);else if((i=(a=s.type)!=null?a:u)!=null&&i.info){const{name:d,parameters:c}=((o=s.type)!=null?o:u).info;this.preloadMap.has(d)||this.preloadMap.set(d,Object.fromEntries(Object.entries(c).filter(([h,{type:p,preload:f}])=>ye.includes(p)&&(f!=null?f:!0)).map(([h,{type:p}])=>[h,p])));for(const[h,p]of Object.entries(this.preloadMap.get(d))){const f=s[h],x=t[p];if(typeof f=="string")x.add(f);else if(Array.isArray(f))for(const k of f.flat())typeof k=="string"&&x.add(k)}}};return n({timeline:e}),{images:[...t[O.IMAGE]],audio:[...t[O.AUDIO]],video:[...t[O.VIDEO]]}}cancelPreloads(){for(const e of this.preload_requests)e.onload=()=>{},e.onerror=()=>{},e.oncanplaythrough=()=>{},e.onabort=()=>{};this.preload_requests=[]}initializeMicrophoneRecorder(e){const t=new MediaRecorder(e);this.microphone_recorder=t}getMicrophoneRecorder(){return this.microphone_recorder}initializeCameraRecorder(e,t){this.camera_stream=e;const n=new MediaRecorder(e,t);this.camera_recorder=n}getCameraStream(){return this.camera_stream}getCameraRecorder(){return this.camera_recorder}}var st=Object.defineProperty,ve=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,be=(r,e,t)=>e in r?st(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,we=(r,e)=>{for(var t in e||(e={}))at.call(e,t)&&be(r,t,e[t]);if(ve)for(var t of ve(e))ot.call(e,t)&&be(r,t,e[t]);return r};class lt{constructor(e,t){this.getDisplayContainerElement=e,this.setJsPsychTimeout=t}dispatchEvent(e){this.getDisplayContainerElement().dispatchEvent(e)}keyDown(e){this.dispatchEvent(new KeyboardEvent("keydown",{key:e}))}keyUp(e){this.dispatchEvent(new KeyboardEvent("keyup",{key:e}))}pressKey(e,t=0){t>0?this.setJsPsychTimeout(()=>{this.keyDown(e),this.keyUp(e)},t):(this.keyDown(e),this.keyUp(e))}clickTarget(e,t=0){t>0?this.setJsPsychTimeout(()=>{e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))},t):(e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0})),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0})))}fillTextInput(e,t,n=0){n>0?this.setJsPsychTimeout(()=>{e.value=t},n):e.value=t}getValidKey(e){const t=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"," "];let n;if(e=="NO_KEYS")n=null;else if(e=="ALL_KEYS")n=t[Math.floor(Math.random()*t.length)];else{const s=e.flat();n=s[Math.floor(Math.random()*s.length)]}return n}mergeSimulationData(e,t){return we(we({},e),t==null?void 0:t.data)}ensureSimulationDataConsistency(e,t){if(t.rt&&(t.rt=Math.round(t.rt)),e.trial_duration&&t.rt&&t.rt>e.trial_duration&&(t.rt=null,t.response&&(t.response=null),t.correct&&(t.correct=!1)),e.choices&&e.choices=="NO_KEYS"&&(t.rt&&(t.rt=null),t.response&&(t.response=null)),e.allow_response_before_complete&&e.sequence_reps&&e.frame_time){const n=e.sequence_reps*e.frame_time*e.stimuli.length;t.rt<n&&(t.rt=null,t.response=null)}}}class ut{constructor(){this.timeout_handlers=[]}setTimeout(e,t){const n=window.setTimeout(e,t);return this.timeout_handlers.push(n),n}clearAllTimeouts(){for(const e of this.timeout_handlers)clearTimeout(e);this.timeout_handlers=[]}}function ct(r){const e=r.getInitSettings(),t=new rt(r.getDisplayContainerElement,e.case_sensitive_responses,e.minimum_valid_rt),n=new ut,s=new it(e.use_webaudio),u=new lt(r.getDisplayContainerElement,n.setTimeout.bind(n));return Object.assign({},...[t,n,s,u].map(l=>Y(l)))}var Q={exports:{}};Q.exports,function(r){(function(e,t,n){function s(i){var o=this,d=a();o.next=function(){var c=2091639*o.s0+o.c*23283064365386963e-26;return o.s0=o.s1,o.s1=o.s2,o.s2=c-(o.c=c|0)},o.c=1,o.s0=d(" "),o.s1=d(" "),o.s2=d(" "),o.s0-=d(i),o.s0<0&&(o.s0+=1),o.s1-=d(i),o.s1<0&&(o.s1+=1),o.s2-=d(i),o.s2<0&&(o.s2+=1),d=null}function u(i,o){return o.c=i.c,o.s0=i.s0,o.s1=i.s1,o.s2=i.s2,o}function l(i,o){var d=new s(i),c=o&&o.state,h=d.next;return h.int32=function(){return d.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,c&&(typeof c=="object"&&u(c,d),h.state=function(){return u(d,{})}),h}function a(){var i=4022871197,o=function(d){d=String(d);for(var c=0;c<d.length;c++){i+=d.charCodeAt(c);var h=.02519603282416938*i;i=h>>>0,h-=i,h*=i,i=h>>>0,h-=i,i+=h*4294967296}return(i>>>0)*23283064365386963e-26};return o}t&&t.exports?t.exports=l:this.alea=l})(N,r)}(Q);var xe=Q.exports,ht=W(xe),Z={exports:{}};Z.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.x=0,i.y=0,i.z=0,i.w=0,i.next=function(){var c=i.x^i.x<<11;return i.x=i.y,i.y=i.z,i.z=i.w,i.w^=i.w>>>19^c^c>>>8},a===(a|0)?i.x=a:o+=a;for(var d=0;d<o.length+64;d++)i.x^=o.charCodeAt(d)|0,i.next()}function u(a,i){return i.x=a.x,i.y=a.y,i.z=a.z,i.w=a.w,i}function l(a,i){var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(typeof d=="object"&&u(d,o),c.state=function(){return u(o,{})}),c}t&&t.exports?t.exports=l:this.xor128=l})(N,r)}(Z);var dt=Z.exports,ee={exports:{}};ee.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.next=function(){var c=i.x^i.x>>>2;return i.x=i.y,i.y=i.z,i.z=i.w,i.w=i.v,(i.d=i.d+362437|0)+(i.v=i.v^i.v<<4^(c^c<<1))|0},i.x=0,i.y=0,i.z=0,i.w=0,i.v=0,a===(a|0)?i.x=a:o+=a;for(var d=0;d<o.length+64;d++)i.x^=o.charCodeAt(d)|0,d==o.length&&(i.d=i.x<<10^i.x>>>4),i.next()}function u(a,i){return i.x=a.x,i.y=a.y,i.z=a.z,i.w=a.w,i.v=a.v,i.d=a.d,i}function l(a,i){var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(typeof d=="object"&&u(d,o),c.state=function(){return u(o,{})}),c}t&&t.exports?t.exports=l:this.xorwow=l})(N,r)}(ee);var pt=ee.exports,te={exports:{}};te.exports,function(r){(function(e,t,n){function s(a){var i=this;i.next=function(){var d=i.x,c=i.i,h,p;return h=d[c],h^=h>>>7,p=h^h<<24,h=d[c+1&7],p^=h^h>>>10,h=d[c+3&7],p^=h^h>>>3,h=d[c+4&7],p^=h^h<<7,h=d[c+7&7],h=h^h<<13,p^=h^h<<9,d[c]=p,i.i=c+1&7,p};function o(d,c){var h,p=[];if(c===(c|0))p[0]=c;else for(c=""+c,h=0;h<c.length;++h)p[h&7]=p[h&7]<<15^c.charCodeAt(h)+p[h+1&7]<<13;for(;p.length<8;)p.push(0);for(h=0;h<8&&p[h]===0;++h);for(h==8?p[7]=-1:p[h],d.x=p,d.i=0,h=256;h>0;--h)d.next()}o(i,a)}function u(a,i){return i.x=a.x.slice(),i.i=a.i,i}function l(a,i){a==null&&(a=+new Date);var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(d.x&&u(d,o),c.state=function(){return u(o,{})}),c}t&&t.exports?t.exports=l:this.xorshift7=l})(N,r)}(te);var ft=te.exports,re={exports:{}};re.exports,function(r){(function(e,t,n){function s(a){var i=this;i.next=function(){var d=i.w,c=i.X,h=i.i,p,f;return i.w=d=d+1640531527|0,f=c[h+34&127],p=c[h=h+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,f=c[h]=f^p,i.i=h,f+(d^d>>>16)|0};function o(d,c){var h,p,f,x,k,A=[],z=128;for(c===(c|0)?(p=c,c=null):(c=c+"\0",p=0,z=Math.max(z,c.length)),f=0,x=-32;x<z;++x)c&&(p^=c.charCodeAt((x+32)%c.length)),x===0&&(k=p),p^=p<<10,p^=p>>>15,p^=p<<4,p^=p>>>13,x>=0&&(k=k+1640531527|0,h=A[x&127]^=p+k,f=h==0?f+1:0);for(f>=128&&(A[(c&&c.length||0)&127]=-1),f=127,x=512;x>0;--x)p=A[f+34&127],h=A[f=f+1&127],p^=p<<13,h^=h<<17,p^=p>>>15,h^=h>>>12,A[f]=p^h;d.w=k,d.X=A,d.i=f}o(i,a)}function u(a,i){return i.i=a.i,i.w=a.w,i.X=a.X.slice(),i}function l(a,i){a==null&&(a=+new Date);var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(d.X&&u(d,o),c.state=function(){return u(o,{})}),c}t&&t.exports?t.exports=l:this.xor4096=l})(N,r)}(re);var mt=re.exports,ne={exports:{}};ne.exports,function(r){(function(e,t,n){function s(a){var i=this,o="";i.next=function(){var c=i.b,h=i.c,p=i.d,f=i.a;return c=c<<25^c>>>7^h,h=h-p|0,p=p<<24^p>>>8^f,f=f-c|0,i.b=c=c<<20^c>>>12^h,i.c=h=h-p|0,i.d=p<<16^h>>>16^f,i.a=f-c|0},i.a=0,i.b=0,i.c=-1640531527,i.d=1367130551,a===Math.floor(a)?(i.a=a/4294967296|0,i.b=a|0):o+=a;for(var d=0;d<o.length+20;d++)i.b^=o.charCodeAt(d)|0,i.next()}function u(a,i){return i.a=a.a,i.b=a.b,i.c=a.c,i.d=a.d,i}function l(a,i){var o=new s(a),d=i&&i.state,c=function(){return(o.next()>>>0)/4294967296};return c.double=function(){do var h=o.next()>>>11,p=(o.next()>>>0)/4294967296,f=(h+p)/(1<<21);while(f===0);return f},c.int32=o.next,c.quick=c,d&&(typeof d=="object"&&u(d,o),c.state=function(){return u(o,{})}),c}t&&t.exports?t.exports=l:this.tychei=l})(N,r)}(ne);var gt=ne.exports,Pe={exports:{}};(function(r){(function(e,t,n){var s=256,u=6,l=52,a="random",i=n.pow(s,u),o=n.pow(2,l),d=o*2,c=s-1,h;function p(m,g,P){var v=[];g=g==!0?{entropy:!0}:g||{};var y=A(k(g.entropy?[m,$(t)]:m==null?z():m,3),v),E=new f(v),T=function(){for(var _=E.g(u),I=i,L=0;_<o;)_=(_+L)*s,I*=s,L=E.g(1);for(;_>=d;)_/=2,I/=2,L>>>=1;return(_+L)/I};return T.int32=function(){return E.g(4)|0},T.quick=function(){return E.g(4)/4294967296},T.double=T,A($(E.S),t),(g.pass||P||function(_,I,L,R){return R&&(R.S&&x(R,E),_.state=function(){return x(E,{})}),L?(n[a]=_,I):_})(T,y,"global"in g?g.global:this==n,g.state)}function f(m){var g,P=m.length,v=this,y=0,E=v.i=v.j=0,T=v.S=[];for(P||(m=[P++]);y<s;)T[y]=y++;for(y=0;y<s;y++)T[y]=T[E=c&E+m[y%P]+(g=T[y])],T[E]=g;(v.g=function(_){for(var I,L=0,R=v.i,J=v.j,q=v.S;_--;)I=q[R=c&R+1],L=L*s+q[c&(q[R]=q[J=c&J+I])+(q[J]=I)];return v.i=R,v.j=J,L})(s)}function x(m,g){return g.i=m.i,g.j=m.j,g.S=m.S.slice(),g}function k(m,g){var P=[],v=typeof m,y;if(g&&v=="object")for(y in m)try{P.push(k(m[y],g-1))}catch(E){}return P.length?P:v=="string"?m:m+"\0"}function A(m,g){for(var P=m+"",v,y=0;y<P.length;)g[c&y]=c&(v^=g[c&y]*19)+P.charCodeAt(y++);return $(g)}function z(){try{var m;return h&&(m=h.randomBytes)?m=m(s):(m=new Uint8Array(s),(e.crypto||e.msCrypto).getRandomValues(m)),$(m)}catch(v){var g=e.navigator,P=g&&g.plugins;return[+new Date,e,P,e.screen,$(t)]}}function $(m){return String.fromCharCode.apply(0,m)}if(A(n.random(),t),r.exports){r.exports=p;try{h=require("crypto")}catch(m){}}else n["seed"+a]=p})(typeof self!="undefined"?self:N,[],Math)})(Pe);var yt=Pe.exports,vt=xe,bt=dt,wt=pt,xt=ft,Pt=mt,Et=gt,D=yt;D.alea=vt,D.xor128=bt,D.xorwow=wt,D.xorshift7=xt,D.xor4096=Pt,D.tychei=Et;var _t=D,jt=_t,ie=["ability","able","aboard","about","above","accept","accident","according","account","accurate","acres","across","act","action","active","activity","actual","actually","add","addition","additional","adjective","adult","adventure","advice","affect","afraid","after","afternoon","again","against","age","ago","agree","ahead","aid","air","airplane","alike","alive","all","allow","almost","alone","along","aloud","alphabet","already","also","although","am","among","amount","ancient","angle","angry","animal","announced","another","answer","ants","any","anybody","anyone","anything","anyway","anywhere","apart","apartment","appearance","apple","applied","appropriate","are","area","arm","army","around","arrange","arrangement","arrive","arrow","art","article","as","aside","ask","asleep","at","ate","atmosphere","atom","atomic","attached","attack","attempt","attention","audience","author","automobile","available","average","avoid","aware","away","baby","back","bad","badly","bag","balance","ball","balloon","band","bank","bar","bare","bark","barn","base","baseball","basic","basis","basket","bat","battle","be","bean","bear","beat","beautiful","beauty","became","because","become","becoming","bee","been","before","began","beginning","begun","behavior","behind","being","believed","bell","belong","below","belt","bend","beneath","bent","beside","best","bet","better","between","beyond","bicycle","bigger","biggest","bill","birds","birth","birthday","bit","bite","black","blank","blanket","blew","blind","block","blood","blow","blue","board","boat","body","bone","book","border","born","both","bottle","bottom","bound","bow","bowl","box","boy","brain","branch","brass","brave","bread","break","breakfast","breath","breathe","breathing","breeze","brick","bridge","brief","bright","bring","broad","broke","broken","brother","brought","brown","brush","buffalo","build","building","built","buried","burn","burst","bus","bush","business","busy","but","butter","buy","by","cabin","cage","cake","call","calm","came","camera","camp","can","canal","cannot","cap","capital","captain","captured","car","carbon","card","care","careful","carefully","carried","carry","case","cast","castle","cat","catch","cattle","caught","cause","cave","cell","cent","center","central","century","certain","certainly","chain","chair","chamber","chance","change","changing","chapter","character","characteristic","charge","chart","check","cheese","chemical","chest","chicken","chief","child","children","choice","choose","chose","chosen","church","circle","circus","citizen","city","class","classroom","claws","clay","clean","clear","clearly","climate","climb","clock","close","closely","closer","cloth","clothes","clothing","cloud","club","coach","coal","coast","coat","coffee","cold","collect","college","colony","color","column","combination","combine","come","comfortable","coming","command","common","community","company","compare","compass","complete","completely","complex","composed","composition","compound","concerned","condition","congress","connected","consider","consist","consonant","constantly","construction","contain","continent","continued","contrast","control","conversation","cook","cookies","cool","copper","copy","corn","corner","correct","correctly","cost","cotton","could","count","country","couple","courage","course","court","cover","cow","cowboy","crack","cream","create","creature","crew","crop","cross","crowd","cry","cup","curious","current","curve","customs","cut","cutting","daily","damage","dance","danger","dangerous","dark","darkness","date","daughter","dawn","day","dead","deal","dear","death","decide","declared","deep","deeply","deer","definition","degree","depend","depth","describe","desert","design","desk","detail","determine","develop","development","diagram","diameter","did","die","differ","difference","different","difficult","difficulty","dig","dinner","direct","direction","directly","dirt","dirty","disappear","discover","discovery","discuss","discussion","disease","dish","distance","distant","divide","division","do","doctor","does","dog","doing","doll","dollar","done","donkey","door","dot","double","doubt","down","dozen","draw","drawn","dream","dress","drew","dried","drink","drive","driven","driver","driving","drop","dropped","drove","dry","duck","due","dug","dull","during","dust","duty","each","eager","ear","earlier","early","earn","earth","easier","easily","east","easy","eat","eaten","edge","education","effect","effort","egg","eight","either","electric","electricity","element","elephant","eleven","else","empty","end","enemy","energy","engine","engineer","enjoy","enough","enter","entire","entirely","environment","equal","equally","equator","equipment","escape","especially","essential","establish","even","evening","event","eventually","ever","every","everybody","everyone","everything","everywhere","evidence","exact","exactly","examine","example","excellent","except","exchange","excited","excitement","exciting","exclaimed","exercise","exist","expect","experience","experiment","explain","explanation","explore","express","expression","extra","eye","face","facing","fact","factor","factory","failed","fair","fairly","fall","fallen","familiar","family","famous","far","farm","farmer","farther","fast","fastened","faster","fat","father","favorite","fear","feathers","feature","fed","feed","feel","feet","fell","fellow","felt","fence","few","fewer","field","fierce","fifteen","fifth","fifty","fight","fighting","figure","fill","film","final","finally","find","fine","finest","finger","finish","fire","fireplace","firm","first","fish","five","fix","flag","flame","flat","flew","flies","flight","floating","floor","flow","flower","fly","fog","folks","follow","food","foot","football","for","force","foreign","forest","forget","forgot","forgotten","form","former","fort","forth","forty","forward","fought","found","four","fourth","fox","frame","free","freedom","frequently","fresh","friend","friendly","frighten","frog","from","front","frozen","fruit","fuel","full","fully","fun","function","funny","fur","furniture","further","future","gain","game","garage","garden","gas","gasoline","gate","gather","gave","general","generally","gentle","gently","get","getting","giant","gift","girl","give","given","giving","glad","glass","globe","go","goes","gold","golden","gone","good","goose","got","government","grabbed","grade","gradually","grain","grandfather","grandmother","graph","grass","gravity","gray","great","greater","greatest","greatly","green","grew","ground","group","grow","grown","growth","guard","guess","guide","gulf","gun","habit","had","hair","half","halfway","hall","hand","handle","handsome","hang","happen","happened","happily","happy","harbor","hard","harder","hardly","has","hat","have","having","hay","he","headed","heading","health","heard","hearing","heart","heat","heavy","height","held","hello","help","helpful","her","herd","here","herself","hidden","hide","high","higher","highest","highway","hill","him","himself","his","history","hit","hold","hole","hollow","home","honor","hope","horn","horse","hospital","hot","hour","house","how","however","huge","human","hundred","hung","hungry","hunt","hunter","hurried","hurry","hurt","husband","ice","idea","identity","if","ill","image","imagine","immediately","importance","important","impossible","improve","in","inch","include","including","income","increase","indeed","independent","indicate","individual","industrial","industry","influence","information","inside","instance","instant","instead","instrument","interest","interior","into","introduced","invented","involved","iron","is","island","it","its","itself","jack","jar","jet","job","join","joined","journey","joy","judge","jump","jungle","just","keep","kept","key","kids","kill","kind","kitchen","knew","knife","know","knowledge","known","label","labor","lack","lady","laid","lake","lamp","land","language","large","larger","largest","last","late","later","laugh","law","lay","layers","lead","leader","leaf","learn","least","leather","leave","leaving","led","left","leg","length","lesson","let","letter","level","library","lie","life","lift","light","like","likely","limited","line","lion","lips","liquid","list","listen","little","live","living","load","local","locate","location","log","lonely","long","longer","look","loose","lose","loss","lost","lot","loud","love","lovely","low","lower","luck","lucky","lunch","lungs","lying","machine","machinery","mad","made","magic","magnet","mail","main","mainly","major","make","making","man","managed","manner","manufacturing","many","map","mark","market","married","mass","massage","master","material","mathematics","matter","may","maybe","me","meal","mean","means","meant","measure","meat","medicine","meet","melted","member","memory","men","mental","merely","met","metal","method","mice","middle","might","mighty","mile","military","milk","mill","mind","mine","minerals","minute","mirror","missing","mission","mistake","mix","mixture","model","modern","molecular","moment","money","monkey","month","mood","moon","more","morning","most","mostly","mother","motion","motor","mountain","mouse","mouth","move","movement","movie","moving","mud","muscle","music","musical","must","my","myself","mysterious","nails","name","nation","national","native","natural","naturally","nature","near","nearby","nearer","nearest","nearly","necessary","neck","needed","needle","needs","negative","neighbor","neighborhood","nervous","nest","never","new","news","newspaper","next","nice","night","nine","no","nobody","nodded","noise","none","noon","nor","north","nose","not","note","noted","nothing","notice","noun","now","number","numeral","nuts","object","observe","obtain","occasionally","occur","ocean","of","off","offer","office","officer","official","oil","old","older","oldest","on","once","one","only","onto","open","operation","opinion","opportunity","opposite","or","orange","orbit","order","ordinary","organization","organized","origin","original","other","ought","our","ourselves","out","outer","outline","outside","over","own","owner","oxygen","pack","package","page","paid","pain","paint","pair","palace","pale","pan","paper","paragraph","parallel","parent","park","part","particles","particular","particularly","partly","parts","party","pass","passage","past","path","pattern","pay","peace","pen","pencil","people","per","percent","perfect","perfectly","perhaps","period","person","personal","pet","phrase","physical","piano","pick","picture","pictured","pie","piece","pig","pile","pilot","pine","pink","pipe","pitch","place","plain","plan","plane","planet","planned","planning","plant","plastic","plate","plates","play","pleasant","please","pleasure","plenty","plural","plus","pocket","poem","poet","poetry","point","pole","police","policeman","political","pond","pony","pool","poor","popular","population","porch","port","position","positive","possible","possibly","post","pot","potatoes","pound","pour","powder","power","powerful","practical","practice","prepare","present","president","press","pressure","pretty","prevent","previous","price","pride","primitive","principal","principle","printed","private","prize","probably","problem","process","produce","product","production","program","progress","promised","proper","properly","property","protection","proud","prove","provide","public","pull","pupil","pure","purple","purpose","push","put","putting","quarter","queen","question","quick","quickly","quiet","quietly","quite","rabbit","race","radio","railroad","rain","raise","ran","ranch","range","rapidly","rate","rather","raw","rays","reach","read","reader","ready","real","realize","rear","reason","recall","receive","recent","recently","recognize","record","red","refer","refused","region","regular","related","relationship","religious","remain","remarkable","remember","remove","repeat","replace","replied","report","represent","require","research","respect","rest","result","return","review","rhyme","rhythm","rice","rich","ride","riding","right","ring","rise","rising","river","road","roar","rock","rocket","rocky","rod","roll","roof","room","root","rope","rose","rough","round","route","row","rubbed","rubber","rule","ruler","run","running","rush","sad","saddle","safe","safety","said","sail","sale","salmon","salt","same","sand","sang","sat","satellites","satisfied","save","saved","saw","say","scale","scared","scene","school","science","scientific","scientist","score","screen","sea","search","season","seat","second","secret","section","see","seed","seeing","seems","seen","seldom","select","selection","sell","send","sense","sent","sentence","separate","series","serious","serve","service","sets","setting","settle","settlers","seven","several","shade","shadow","shake","shaking","shall","shallow","shape","share","sharp","she","sheep","sheet","shelf","shells","shelter","shine","shinning","ship","shirt","shoe","shoot","shop","shore","short","shorter","shot","should","shoulder","shout","show","shown","shut","sick","sides","sight","sign","signal","silence","silent","silk","silly","silver","similar","simple","simplest","simply","since","sing","single","sink","sister","sit","sitting","situation","six","size","skill","skin","sky","slabs","slave","sleep","slept","slide","slight","slightly","slip","slipped","slope","slow","slowly","small","smaller","smallest","smell","smile","smoke","smooth","snake","snow","so","soap","social","society","soft","softly","soil","solar","sold","soldier","solid","solution","solve","some","somebody","somehow","someone","something","sometime","somewhere","son","song","soon","sort","sound","source","south","southern","space","speak","special","species","specific","speech","speed","spell","spend","spent","spider","spin","spirit","spite","split","spoken","sport","spread","spring","square","stage","stairs","stand","standard","star","stared","start","state","statement","station","stay","steady","steam","steel","steep","stems","step","stepped","stick","stiff","still","stock","stomach","stone","stood","stop","stopped","store","storm","story","stove","straight","strange","stranger","straw","stream","street","strength","stretch","strike","string","strip","strong","stronger","struck","structure","struggle","stuck","student","studied","studying","subject","substance","success","successful","such","sudden","suddenly","sugar","suggest","suit","sum","summer","sun","sunlight","supper","supply","support","suppose","sure","surface","surprise","surrounded","swam","sweet","swept","swim","swimming","swing","swung","syllable","symbol","system","table","tail","take","taken","tales","talk","tall","tank","tape","task","taste","taught","tax","tea","teach","teacher","team","tears","teeth","telephone","television","tell","temperature","ten","tent","term","terrible","test","than","thank","that","thee","them","themselves","then","theory","there","therefore","these","they","thick","thin","thing","think","third","thirty","this","those","thou","though","thought","thousand","thread","three","threw","throat","through","throughout","throw","thrown","thumb","thus","thy","tide","tie","tight","tightly","till","time","tin","tiny","tip","tired","title","to","tobacco","today","together","told","tomorrow","tone","tongue","tonight","too","took","tool","top","topic","torn","total","touch","toward","tower","town","toy","trace","track","trade","traffic","trail","train","transportation","trap","travel","treated","tree","triangle","tribe","trick","tried","trip","troops","tropical","trouble","truck","trunk","truth","try","tube","tune","turn","twelve","twenty","twice","two","type","typical","uncle","under","underline","understanding","unhappy","union","unit","universe","unknown","unless","until","unusual","up","upon","upper","upward","us","use","useful","using","usual","usually","valley","valuable","value","vapor","variety","various","vast","vegetable","verb","vertical","very","vessels","victory","view","village","visit","visitor","voice","volume","vote","vowel","voyage","wagon","wait","walk","wall","want","war","warm","warn","was","wash","waste","watch","water","wave","way","we","weak","wealth","wear","weather","week","weigh","weight","welcome","well","went","were","west","western","wet","whale","what","whatever","wheat","wheel","when","whenever","where","wherever","whether","which","while","whispered","whistle","white","who","whole","whom","whose","why","wide","widely","wife","wild","will","willing","win","wind","window","wing","winter","wire","wise","wish","with","within","without","wolf","women","won","wonder","wonderful","wood","wooden","wool","word","wore","work","worker","world","worried","worry","worse","worth","would","wrapped","write","writer","writing","written","wrong","wrote","yard","year","yellow","yes","yesterday","yet","you","young","younger","your","yourself","youth","zero","zebra","zipper","zoo","zulu"];function Ee(r){const e=r!=null&&r.seed?new jt(r.seed):null;function t(){return r&&r.maxLength>1?n():s()}function n(){for(var c=!1,h;!c;)h=s(),h.length<=r.maxLength&&(c=!0);return h}function s(){return ie[u(ie.length)]}function u(c){const h=e?e():Math.random();return Math.floor(h*c)}if(typeof r=="undefined")return t();typeof r=="number"&&(r={exactly:r}),r.exactly&&(r.min=r.exactly,r.max=r.exactly),typeof r.wordsPerString!="number"&&(r.wordsPerString=1),typeof r.formatter!="function"&&(r.formatter=c=>c),typeof r.separator!="string"&&(r.separator=" ");for(var l=r.min+u(r.max+1-r.min),a=[],i="",o=0,d=0;d<l*r.wordsPerString;d++)o===r.wordsPerString-1?i+=r.formatter(t(),o):i+=r.formatter(t(),o)+r.separator,o++,(d+1)%r.wordsPerString===0&&(a.push(i),i="",o=0);return typeof r.join=="string"&&(a=a.join(r.join)),a}var kt=Ee;Ee.wordList=ie;var Tt=W(kt),Ot=Object.defineProperty,At=Object.defineProperties,Lt=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,je=(r,e,t)=>e in r?Ot(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ct=(r,e)=>{for(var t in e||(e={}))It.call(e,t)&&je(r,t,e[t]);if(_e)for(var t of _e(e))St.call(e,t)&&je(r,t,e[t]);return r},Mt=(r,e)=>At(r,Lt(e));function Rt(r=Math.random().toString()){return Math.random=ht(r),r}function se(r,e,t=!1){const n=Array.isArray(r),s=Array.isArray(e);if(!n)s?(e=[e[0]],console.log("Unclear parameters given to randomization.repeat. Multiple set sizes specified, but only one item exists to sample. Proceeding using the first set size.")):(r=[r],e=[e]);else if(s){if(r.length!=e.length)if(console.warn("Unclear parameters given to randomization.repeat. Items and repetitions are unequal lengths. Behavior may not be as expected."),e.length<r.length){let a=[];for(let i=0;i<r.length;i++)a.push(e);e=a}else e=e.slice(0,r.length)}else{let a=[];for(let i=0;i<r.length;i++)a.push(e);e=a}let u=[];for(let a=0;a<r.length;a++)for(let i=0;i<e[a];i++)r[a]==null||typeof r[a]!="object"?u.push(r[a]):u.push(Object.assign({},r[a]));let l=S(u);return t&&(l=Kt(l)),l}function S(r){Array.isArray(r)||console.error("Argument to shuffle() must be an array.");const e=r.slice(0);let t=e.length,n,s;for(;t;)s=Math.floor(Math.random()*t--),n=e[t],e[t]=e[s],e[s]=n;return e}function Nt(r,e){Array.isArray(r)||console.error("First argument to shuffleNoRepeats() must be an array."),typeof e!="undefined"&&typeof e!="function"&&console.error("Second argument to shuffleNoRepeats() must be a function."),typeof e=="undefined"&&(e=function(n,s){return n===s});const t=S(r);for(let n=0;n<t.length-1;n++)if(e(t[n],t[n+1])){let s=Math.floor(Math.random()*(t.length-2))+1;for(;e(t[n+1],t[s])||e(t[n+1],t[s+1])||e(t[n+1],t[s-1])||e(t[n],t[s]);)s=Math.floor(Math.random()*(t.length-2))+1;const u=t[s];t[s]=t[n+1],t[n+1]=u}return t}function ke(r,e=!1){const t=r.length;if(t==1)return console.warn("shuffleAlternateGroups() was called with only one group. Defaulting to simple shuffle."),S(r[0]);let n=[];for(let a=0;a<t;a++)n.push(a);e&&(n=S(n));const s=[];let u=null;for(let a=0;a<t;a++)u=u===null?r[a].length:Math.min(u,r[a].length),s.push(S(r[a]));const l=[];for(let a=0;a<u;a++)for(let i=0;i<n.length;i++)l.push(s[n[i]][a]);return l}function Te(r,e){return Array.isArray(r)||console.error("First argument to sampleWithoutReplacement() must be an array"),e>r.length&&console.error("Cannot take a sample larger than the size of the set of items to sample."),S(r).slice(0,e)}function Oe(r,e,t){Array.isArray(r)||console.error("First argument to sampleWithReplacement() must be an array");const n=[];if(typeof t!="undefined"){t.length!==r.length&&console.error("The length of the weights array must equal the length of the array to be sampled from.");let l=0;for(const a of t)l+=a;for(const a of t)n.push(a/l)}else for(let l=0;l<r.length;l++)n.push(1/r.length);const s=[n[0]];for(let l=1;l<n.length;l++)s.push(n[l]+s[l-1]);const u=[];for(let l=0;l<e;l++){const a=Math.random();let i=0;for(;a>s[i];)i++;u.push(r[i])}return u}function Dt(r,e=1,t=!1){let n=[{}];for(const[s,u]of Object.entries(r)){const l=[];for(const a of u)for(const i of n)l.push(Mt(Ct({},i),{[s]:a}));n=l}return se(n,e,t)}function Vt(r=32){let e="";const t="0123456789abcdefghjklmnopqrstuvwxyz";for(let n=0;n<r;n++)e+=t[Math.floor(Math.random()*t.length)];return e}function zt(r,e){if(e<r)throw new Error("Upper boundary must be greater than or equal to lower boundary");return r+Math.floor(Math.random()*(e-r+1))}function $t(r){return Math.random()<=r?1:0}function ae(r,e){return Ut()*e+r}function oe(r){return-Math.log(Math.random())/r}function qt(r,e,t,n=!1){let s=ae(r,e)+oe(t);if(n)for(;s<=0;)s=ae(r,e)+oe(t);return s}function Bt(r){return Tt(r)}function Ut(){for(var r=0,e=0;r===0;)r=Math.random();for(;e===0;)e=Math.random();return Math.sqrt(-2*Math.log(r))*Math.cos(2*Math.PI*e)}function Kt(r){const e={};for(const t of r)for(const n of Object.keys(t))typeof e[n]=="undefined"&&(e[n]=[]),e[n].push(t[n]);return e}var Gt=Object.freeze({__proto__:null,factorial:Dt,randomID:Vt,randomInt:zt,randomWords:Bt,repeat:se,sampleBernoulli:$t,sampleExGaussian:qt,sampleExponential:oe,sampleNormal:ae,sampleWithReplacement:Oe,sampleWithoutReplacement:Te,setSeed:Rt,shuffle:S,shuffleAlternateGroups:ke,shuffleNoRepeats:Nt});function Ae(){const r={previewMode:!1,outsideTurk:!1,hitId:"INVALID_URL_PARAMETER",assignmentId:"INVALID_URL_PARAMETER",workerId:"INVALID_URL_PARAMETER",turkSubmitTo:"INVALID_URL_PARAMETER"},e=function(n,s){s=s.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");const u="[\\?&]"+s+"=([^&#]*)",l=new RegExp(u).exec(n);return l==null?"":l[1]},t=e(window.location.href,"assignmentId")?window.location.href:document.referrer;return["assignmentId","hitId","workerId","turkSubmitTo"].map(function(n){r[n]=unescape(e(t,n))}),r.previewMode=r.assignmentId=="ASSIGNMENT_ID_NOT_AVAILABLE",r.outsideTurk=!r.previewMode&&r.hitId===""&&r.assignmentId==""&&r.workerId=="",r}function Ft(r){const e=Ae(),t=e.assignmentId,n=e.turkSubmitTo;if(!t||!n)return;const s=document.createElement("form");s.method="POST",s.action=n+"/mturk/externalSubmit?assignmentId="+t;for(const u in r)if(r.hasOwnProperty(u)){const l=document.createElement("input");l.type="hidden",l.name=u,l.id=u,l.value=r[u],s.appendChild(l)}document.body.appendChild(s),s.submit()}var Jt=Object.freeze({__proto__:null,submitToTurk:Ft,turkInfo:Ae});class Wt{constructor(e,t){this.containerElement=e,this.message=t,this._progress=0,this.setupElements()}setupElements(){this.messageSpan=document.createElement("span"),this.innerDiv=document.createElement("div"),this.innerDiv.id="jspsych-progressbar-inner",this.update();const e=document.createElement("div");e.id="jspsych-progressbar-outer",e.appendChild(this.innerDiv),this.containerElement.appendChild(this.messageSpan),this.containerElement.appendChild(e)}update(){this.innerDiv.style.width=this._progress*100+"%",typeof this.message=="function"?this.messageSpan.innerHTML=this.message(this._progress):this.messageSpan.innerHTML=this.message}set progress(e){if(typeof e!="number"||e<0||e>1)throw new Error("jsPsych.progressBar.progress must be a number between 0 and 1");this._progress=e,this.update()}get progress(){return this._progress}}class le{constructor(e){this.name=e}}const Yt=["timeline","timeline_variables","name","repetitions","loop_function","conditional_function","randomize_order","sample","on_timeline_start","on_timeline_finish"];function Xt(r){return!ue(r)}function ue(r){return!!r.timeline||Array.isArray(r)}var w=(r=>(r[r.PENDING=0]="PENDING",r[r.RUNNING=1]="RUNNING",r[r.PAUSED=2]="PAUSED",r[r.COMPLETED=3]="COMPLETED",r[r.ABORTED=4]="ABORTED",r))(w||{});class Le{constructor(){this.reset()}reset(){this.promise=new Promise(e=>{this.resolvePromise=e})}get(){return this.promise}resolve(e){this.resolvePromise(e),this.reset()}}function Ht(r){return r&&typeof r.then=="function"}function Qt(r){return new Promise(e=>setTimeout(e,r))}function Ie([r,...e]){let t=r!=null?r:"";for(const n of e)t+=Number.isNaN(Number.parseInt(n))?`.${n}`:`[${n}]`;return t}function Zt(r){return typeof r=="object"&&r!==null}class ce{constructor(){this.cache=new Map}static lookupChild(e,t){let n=!1,s;return Number.isNaN(Number.parseInt(t))?Object.hasOwn(e,t)&&(n=!0,s=e[t]):Number.parseInt(t)<e.length&&(n=!0,s=e[t]),{doesPathExist:n,value:s}}get(e){return this.cache.get(e.join("."))}has(e){return this.cache.has(e.join("."))}initialize(e){this.rootObject=e,this.cache.set("",e)}reset(){this.cache.clear(),this.cache.set("",this.rootObject)}set(e,t){this.cache.set(e.join("."),t)}lookup(e){if(this.has(e))return{doesPathExist:!0,value:this.get(e)};const t=n=>{const s=n.slice(0,-1),u=n[n.length-1];if(!this.has(s)&&s.length>0&&!t(s).doesPathExist)return{doesPathExist:!1};const l=this.get(s);if(!Zt(l))return{doesPathExist:!1};const a=ce.lookupChild(l,u);return a.doesPathExist&&this.set(n,a.value),a};return t(e)}}var er=Object.defineProperty,Se=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Ce=(r,e,t)=>e in r?er(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Me=(r,e)=>{for(var t in e||(e={}))tr.call(e,t)&&Ce(r,t,e[t]);if(Se)for(var t of Se(e))rr.call(e,t)&&Ce(r,t,e[t]);return r};class Re{constructor(e){this.dependencies=e,this.status=w.PENDING,this.parameterValueCache=new ce}getStatus(){return this.status}initializeParameterValueCache(){this.parameterValueCache.initialize(this.description)}resetParameterValueCache(){var e;this.parameterValueCache.reset(),(e=this.parent)==null||e.resetParameterValueCache()}getParameterValue(e,t={}){const{evaluateFunctions:n=!0,recursive:s=!0,cacheResult:u=!0,replaceResult:l}=t;typeof e=="string"&&(e=[e]);let{doesPathExist:a,value:i}=this.parameterValueCache.lookup(e);return!a&&s&&this.parent&&(i=this.parent.getParameterValue(e,t)),typeof i=="function"&&n&&(i=i()),i instanceof le&&(i=this.evaluateTimelineVariable(i)),typeof l=="function"&&(i=l(i)),u&&this.parameterValueCache.set(e,i),i}getDataParameter(){var e;const t=this.getParameterValue("data",{recursive:!1});return Me(Me({},Object.fromEntries(typeof t=="object"?Object.keys(t).map(n=>[n,this.getParameterValue(["data",n])]):[])),(e=this.parent)==null?void 0:e.getDataParameter())}}var nr=Object.defineProperty,ir=Object.defineProperties,sr=Object.getOwnPropertyDescriptors,Ne=Object.getOwnPropertySymbols,ar=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,De=(r,e,t)=>e in r?nr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,he=(r,e)=>{for(var t in e||(e={}))ar.call(e,t)&&De(r,t,e[t]);if(Ne)for(var t of Ne(e))or.call(e,t)&&De(r,t,e[t]);return r},lr=(r,e)=>ir(r,sr(e)),de=(r,e,t)=>new Promise((n,s)=>{var u=i=>{try{a(t.next(i))}catch(o){s(o)}},l=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(r,e)).next())});class F extends Re{constructor(e,t,n){var s;if(super(e),this.description=t,this.parent=n,this.onLoad=()=>{this.runParameterCallback("on_load"),this.dependencies.runOnLoadExtensionCallbacks(this.getParameterValue("extensions"))},this.initializeParameterValueCache(),this.trialObject=j(t),this.pluginClass=this.getParameterValue("type",{evaluateFunctions:!1}),this.pluginInfo=(s=this.pluginClass)==null?void 0:s.info,!this.pluginInfo)throw new Error("Plugin not recognized. Please provide a valid plugin using the 'type' parameter.");!("version"in this.pluginInfo)&&!("data"in this.pluginInfo)?console.warn(this.pluginInfo.name,"is missing the 'version' and 'data' fields. Please update plugin as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):"version"in this.pluginInfo?"data"in this.pluginInfo||console.warn(this.pluginInfo.name,"is missing the 'data' field. Please update plugin as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."):console.warn(this.pluginInfo.name,"is missing the 'version' field. Please update plugin as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details.")}run(){return de(this,null,function*(){var e;this.status=w.RUNNING,this.processParameters(),this.onStart(),this.addCssClasses(),this.pluginInstance=this.dependencies.instantiatePlugin(this.pluginClass),this.result=this.processResult(yield this.executeTrial()),this.dependencies.onTrialResultAvailable(this),this.status=w.COMPLETED,yield this.onFinish(),this.removeCssClasses();const t=(e=this.getParameterValue("post_trial_gap"))!=null?e:this.dependencies.getDefaultIti();t!==0&&this.dependencies.getSimulationMode()!=="data-only"&&(yield Qt(t)),this.resetParameterValueCache()})}executeTrial(){return de(this,null,function*(){const e=this.dependencies.finishTrialPromise.get();let t=!1;e.then(()=>{t=!0});const{trialReturnValue:n,hasTrialBeenSimulated:s}=this.invokeTrialMethod();let u;return Ht(n)?(u=yield Promise.race([n,e]),t&&(u=yield e)):(s||this.onLoad(),u=yield e),this.cleanupTrial(),u})}invokeTrialMethod(){var e;const t=this.dependencies.getSimulationMode();if(t&&typeof this.pluginInstance.simulate=="function"){const n=this.getSimulationOptions();if(n.simulate!==!1)return{hasTrialBeenSimulated:!0,trialReturnValue:this.pluginInstance.simulate(this.trialObject,(e=n.mode)!=null?e:t,n,this.onLoad)}}return{hasTrialBeenSimulated:!1,trialReturnValue:this.pluginInstance.trial(this.dependencies.getDisplayElement(),this.trialObject,this.onLoad)}}cleanupTrial(){this.dependencies.clearAllTimeouts(),this.dependencies.getDisplayElement().innerHTML=""}addCssClasses(){const e=this.getParameterValue("css_classes"),t=this.dependencies.getDisplayElement().classList;typeof e=="string"?t.add(e):Array.isArray(e)&&t.add(...e)}removeCssClasses(){const e=this.getParameterValue("css_classes");e&&this.dependencies.getDisplayElement().classList.remove(...typeof e=="string"?[e]:e)}processResult(e){var t;e||(e={});for(const[s,u]of Object.entries((t=this.getParameterValue("save_trial_parameters"))!=null?t:{}))if(this.pluginInfo.parameters[s])if(u&&!Object.hasOwn(e,s)){let l=this.trialObject[s];typeof l=="function"&&(l=l.toString()),e[s]=l}else!u&&Object.hasOwn(e,s)&&delete e[s];else console.warn(`Non-existent parameter "${s}" specified in save_trial_parameters.`);e=lr(he(he({},this.getDataParameter()),e),{trial_type:this.pluginInfo.name,trial_index:this.index,plugin_version:this.pluginInfo.version?this.pluginInfo.version:null});const n=this.getParameterValue("save_timeline_variables");return n===!0?e.timeline_variables=he({},this.parent.getAllTimelineVariables()):Array.isArray(n)&&(e.timeline_variables=Object.fromEntries(Object.entries(this.parent.getAllTimelineVariables()).filter(([s,u])=>n.includes(s)))),e}runParameterCallback(e,...t){const n=this.getParameterValue(e,{evaluateFunctions:!1});if(n)return n(...t)}onStart(){this.dependencies.onTrialStart(this),this.runParameterCallback("on_start",this.trialObject),this.dependencies.runOnStartExtensionCallbacks(this.getParameterValue("extensions"))}onFinish(){return de(this,null,function*(){const e=yield this.dependencies.runOnFinishExtensionCallbacks(this.getParameterValue("extensions"));Object.assign(this.result,e),yield Promise.resolve(this.runParameterCallback("on_finish",this.getResult())),this.dependencies.onTrialFinished(this)})}evaluateTimelineVariable(e){var t;return(t=this.parent)==null?void 0:t.evaluateTimelineVariable(e)}getParameterValue(e,t={}){return Yt.includes(typeof e=="string"?e:e[0])&&(t.recursive=!1),super.getParameterValue(e,t)}getSimulationOptions(){const e=this.getParameterValue("simulation_options",{replaceResult:(t={})=>{var n,s;if(typeof t=="string"){const u=this.dependencies.getGlobalSimulationOptions();t=(s=(n=u[t])!=null?n:u.default)!=null?s:{}}return K(j(this.dependencies.getGlobalSimulationOptions().default),j(t))}});return typeof e=="undefined"?{}:(e.mode=this.getParameterValue(["simulation_options","mode"]),e.simulate=this.getParameterValue(["simulation_options","simulate"]),e.data=this.getParameterValue(["simulation_options","data"]),typeof e.data=="object"&&(e.data=Object.fromEntries(Object.keys(e.data).map(t=>[t,this.getParameterValue(["simulation_options","data",t])]))),e)}getResult(){return this.getParameterValue("record_data")===!1?void 0:this.result}getResults(){const e=this.getResult();return e?[e]:[]}processParameters(){const e=(n,s,u=[])=>{for(const[l,a]of Object.entries(s)){const i=[...u,l];let o=this.getParameterValue(i,{evaluateFunctions:a.type!==O.FUNCTION,replaceResult:d=>{if(typeof d=="undefined"){if(typeof a.default=="undefined")throw new Error(`You must specify a value for the "${Ie(i)}" parameter in the "${this.pluginInfo.name}" plugin.`);return a.default}else return d}});if(a.array&&!Array.isArray(o)){const d=Ie(i);throw new Error(`A non-array value (\`${o}\`) was provided for the array parameter "${d}" in the "${this.pluginInfo.name}" plugin. Please make sure that "${d}" is an array.`)}a.type===O.COMPLEX&&a.nested&&(a.array?o=o.map((d,c)=>{const h=[...i,c.toString()],p=this.getParameterValue(h);return e(p,a.nested,h),p}):e(o,a.nested,i)),n[l]=o}},t=j(this.description);e(t,this.pluginInfo.parameters),this.trialObject=t}getLatestNode(){return this}getActiveTimelineByName(e){}}var ur=Object.defineProperty,Ve=Object.getOwnPropertySymbols,cr=Object.prototype.hasOwnProperty,hr=Object.prototype.propertyIsEnumerable,ze=(r,e,t)=>e in r?ur(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,$e=(r,e)=>{for(var t in e||(e={}))cr.call(e,t)&&ze(r,t,e[t]);if(Ve)for(var t of Ve(e))hr.call(e,t)&&ze(r,t,e[t]);return r},dr=(r,e,t)=>new Promise((n,s)=>{var u=i=>{try{a(t.next(i))}catch(o){s(o)}},l=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(r,e)).next())});class C extends Re{constructor(e,t,n){super(e),this.parent=n,this.children=[],this.shouldAbort=!1,this.resumePromise=new Le,this.description=Array.isArray(t)?{timeline:t}:t,this.initializeParameterValueCache()}run(){return dr(this,null,function*(){typeof this.index=="undefined"&&(this.index=0),this.status=w.RUNNING;const{conditional_function:e,loop_function:t,repetitions:n=1}=this.description;let s=this.generateTimelineVariableOrder();this.setCurrentTimelineVariablesByIndex(s[0]);let u=!0,l;if(!e||e()){this.onStart();for(let a=0;a<n;a++)do{l=[],u?u=!1:s=this.generateTimelineVariableOrder();for(const i of s){this.setCurrentTimelineVariablesByIndex(i);for(const o of this.description.timeline){const d=this.instantiateChildNode(o),c=this.currentChild;if(this.currentChild=d,d.index=c?c.getLatestNode().index+1:this.index,yield d.run(),this.status===w.PAUSED&&(yield this.resumePromise.get()),this.shouldAbort){this.status=w.ABORTED;return}l.push(...this.currentChild.getResults())}}}while(t&&t(new b(l)));this.onFinish()}this.status=w.COMPLETED})}onStart(){this.description.on_timeline_start&&this.description.on_timeline_start()}onFinish(){this.description.on_timeline_finish&&this.description.on_timeline_finish()}pause(){this.currentChild instanceof C&&this.currentChild.pause(),this.status=w.PAUSED}resume(){this.status==w.PAUSED&&(this.currentChild instanceof C&&this.currentChild.resume(),this.status=w.RUNNING,this.resumePromise.resolve())}abort(){(this.status===w.RUNNING||this.status===w.PAUSED)&&(this.currentChild instanceof C&&this.currentChild.abort(),this.shouldAbort=!0,this.status===w.PAUSED&&this.resume())}instantiateChildNode(e){const t=ue(e)?new C(this.dependencies,e,this):new F(this.dependencies,e,this);return this.children.push(t),t}setCurrentTimelineVariablesByIndex(e){var t;this.currentTimelineVariables=$e($e({},(t=this.parent)==null?void 0:t.getAllTimelineVariables()),e===null?void 0:this.description.timeline_variables[e])}generateTimelineVariableOrder(){var e;const t=(e=this.description.timeline_variables)==null?void 0:e.length;if(!t)return[null];let n=[...Array(t).keys()];const s=this.description.sample;if(s)switch(s.type){case"custom":n=s.fn(n);break;case"with-replacement":n=Oe(n,s.size,s.weights);break;case"without-replacement":n=Te(n,s.size);break;case"fixed-repetitions":n=se(n,s.size);break;case"alternate-groups":n=ke(s.groups,s.randomize_group_order);break;default:throw new Error(`Invalid type "${s.type}" in timeline sample parameters. Valid options for type are "custom", "with-replacement", "without-replacement", "fixed-repetitions", and "alternate-groups"`)}return this.description.randomize_order&&(n=S(n)),n}getAllTimelineVariables(){return this.currentTimelineVariables}evaluateTimelineVariable(e){var t;if((t=this.currentTimelineVariables)!=null&&t.hasOwnProperty(e.name))return this.currentTimelineVariables[e.name];throw new Error(`Timeline variable ${e.name} not found.`)}getResults(){const e=[];for(const t of this.children)if(t instanceof F){const n=t.getResult();n&&e.push(n)}else t instanceof C&&e.push(...t.getResults());return e}getNaiveProgress(){if(this.status===w.PENDING)return 0;const e=this.getLatestNode();if(!e)return 1;let t=e.index;return e.getStatus()===w.COMPLETED&&t++,Math.min(t/this.getNaiveTrialCount(),1)}getNaiveTrialCount(){const e=t=>{var n,s,u;const l=a=>a.map(i=>e(i)).reduce((i,o)=>i+o);if(Array.isArray(t))return l(t);if(Xt(t))return 1;if(ue(t)){let a=((n=t.timeline_variables)==null?void 0:n.length)||1;switch((s=t.sample)==null?void 0:s.type){case"with-replacement":case"without-replacement":a=t.sample.size;break;case"fixed-repetitions":a*=t.sample.size;break;case"alternate-groups":a=t.sample.groups.map(i=>i.length).reduce((i,o)=>i+o,0);break}return l(t.timeline)*((u=t.repetitions)!=null?u:1)*a}return 0};return e(this.description)}getLatestNode(){var e,t;return(t=(e=this.currentChild)==null?void 0:e.getLatestNode())!=null?t:this}getActiveTimelineByName(e){var t;return this.description.name===e?this:(t=this.currentChild)==null?void 0:t.getActiveTimelineByName(e)}}var pr=Object.defineProperty,qe=Object.getOwnPropertySymbols,fr=Object.prototype.hasOwnProperty,mr=Object.prototype.propertyIsEnumerable,Be=(r,e,t)=>e in r?pr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gr=(r,e)=>{for(var t in e||(e={}))fr.call(e,t)&&Be(r,t,e[t]);if(qe)for(var t of qe(e))mr.call(e,t)&&Be(r,t,e[t]);return r},pe=(r,e,t)=>new Promise((n,s)=>{var u=i=>{try{a(t.next(i))}catch(o){s(o)}},l=i=>{try{a(t.throw(i))}catch(o){s(o)}},a=i=>i.done?n(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(r,e)).next())});class Ue{constructor(e){this.turk=Jt,this.randomization=Gt,this.utils=Je,this.options={},this.isFileProtocolUsed=!1,this.finishTrialPromise=new Le,this.timelineDependencies={onTrialStart:t=>{this.options.on_trial_start(t.trialObject),this.getDisplayContainerElement().focus(),this.getDisplayElement().scrollTop=0},onTrialResultAvailable:t=>{const n=t.getResult();n&&(n.time_elapsed=this.getTotalTime(),this.data.write(t))},onTrialFinished:t=>{const n=t.getResult();this.options.on_trial_finish(n),n&&this.options.on_data_update(n),this.progressBar&&this.options.auto_update_progress_bar&&(this.progressBar.progress=this.timeline.getNaiveProgress())},runOnStartExtensionCallbacks:t=>this.extensionManager.onStart(t),runOnLoadExtensionCallbacks:t=>this.extensionManager.onLoad(t),runOnFinishExtensionCallbacks:t=>this.extensionManager.onFinish(t),getSimulationMode:()=>this.simulationMode,getGlobalSimulationOptions:()=>this.simulationOptions,instantiatePlugin:t=>new t(this),getDisplayElement:()=>this.getDisplayElement(),getDefaultIti:()=>this.getInitSettings().default_iti,finishTrialPromise:this.finishTrialPromise,clearAllTimeouts:()=>this.pluginAPI.clearAllTimeouts()},this.extensionManagerDependencies={instantiateExtension:t=>new t(this)},this.dataDependencies={getProgress:()=>{var t,n;return{time:this.getTotalTime(),trial:(n=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?n:0}},onInteractionRecordAdded:t=>{this.options.on_interaction_data_update(t)},getDisplayElement:()=>this.getDisplayElement()},e=gr({display_element:void 0,on_finish:()=>{},on_trial_start:()=>{},on_trial_finish:()=>{},on_data_update:()=>{},on_interaction_data_update:()=>{},on_close:()=>{},use_webaudio:!0,show_progress_bar:!1,message_progress_bar:"Completion Progress",auto_update_progress_bar:!0,default_iti:0,minimum_valid_rt:0,experiment_width:null,override_safe_mode:!1,case_sensitive_responses:!1,extensions:[]},e),this.options=e,Y(this),window.location.protocol=="file:"&&(e.override_safe_mode===!1||typeof e.override_safe_mode=="undefined")&&(e.use_webaudio=!1,this.isFileProtocolUsed=!0,console.warn("jsPsych detected that it is running via the file:// protocol and not on a web server. To prevent issues with cross-origin requests, Web Audio and video preloading have been disabled. If you would like to override this setting, you can set 'override_safe_mode' to 'true' in initJsPsych. For more information, see: https://www.jspsych.org/overview/running-experiments")),this.data=new tt(this.dataDependencies),this.pluginAPI=ct(this),this.extensionManager=new B(this.extensionManagerDependencies,e.extensions)}version(){return Fe}run(e){return pe(this,null,function*(){typeof e=="undefined"&&console.error("No timeline declared in jsPsych.run(). Cannot start experiment."),e.length===0&&console.error("No trials have been added to the timeline (the timeline is an empty array). Cannot start experiment."),this.timeline=new C(this.timelineDependencies,e),yield this.prepareDom(),yield this.extensionManager.initializeExtensions(),document.documentElement.setAttribute("jspsych","present"),this.experimentStartTime=new Date,yield this.timeline.run(),yield Promise.resolve(this.options.on_finish(this.data.get())),this.endMessage&&(this.getDisplayElement().innerHTML=this.endMessage),this.data.removeInteractionListeners()})}simulate(e){return pe(this,arguments,function*(t,n="data-only",s={}){this.simulationMode=n,this.simulationOptions=s,yield this.run(t)})}getProgress(){var e,t,n,s;return{total_trials:(e=this.timeline)==null?void 0:e.getNaiveTrialCount(),current_trial_global:(n=(t=this.timeline)==null?void 0:t.getLatestNode().index)!=null?n:0,percent_complete:((s=this.timeline)==null?void 0:s.getNaiveProgress())*100}}getStartTime(){return this.experimentStartTime}getTotalTime(){return this.experimentStartTime?new Date().getTime()-this.experimentStartTime.getTime():0}getDisplayElement(){return this.displayElement}getDisplayContainerElement(){return this.displayContainerElement}abortExperiment(e,t={}){this.endMessage=e,this.timeline.abort(),this.pluginAPI.cancelAllKeyboardResponses(),this.pluginAPI.clearAllTimeouts(),this.finishTrial(t)}abortCurrentTimeline(){var e;let t=(e=this.timeline)==null?void 0:e.getLatestNode();t instanceof F&&(t=t.parent),t instanceof C&&t.abort()}abortTimelineByName(e){var t;const n=(t=this.timeline)==null?void 0:t.getActiveTimelineByName(e);n&&n.abort()}getCurrentTrial(){var e;const t=(e=this.timeline)==null?void 0:e.getLatestNode();if(t instanceof F)return t.description}getInitSettings(){return this.options}timelineVariable(e){return new le(e)}evaluateTimelineVariable(e){var t,n;return(n=(t=this.timeline)==null?void 0:t.getLatestNode())==null?void 0:n.evaluateTimelineVariable(new le(e))}pauseExperiment(){var e;(e=this.timeline)==null||e.pause()}resumeExperiment(){var e;(e=this.timeline)==null||e.resume()}getSafeModeStatus(){return this.isFileProtocolUsed}getTimeline(){var e;return(e=this.timeline)==null?void 0:e.description.timeline}getCitations(e=[],t="apa"){const n=["apa","bibtex"],s={apa:"de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351 ",bibtex:'@article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '};if(t=t.toLowerCase(),Array.isArray(e))if(n.includes(t)){const u=s[t],l=new Set([u]);for(const a of e)try{const i=a.info.citations[t];l.add(i)}catch(i){console.error(`${a} does not have citation in ${t} format.`)}return Array.from(l).join(`
6
+ `)}else throw new Error("Unsupported citation format");else throw new Error("Expected array of plugins/extensions")}get extensions(){var e,t;return(t=(e=this.extensionManager)==null?void 0:e.extensions)!=null?t:{}}prepareDom(){return pe(this,null,function*(){document.readyState!=="complete"&&(yield new Promise(s=>{window.addEventListener("load",s)}));const e=this.options;if(typeof e.display_element=="undefined"){let s=document.body;s||(s=document.createElement("body"),document.documentElement.appendChild(s)),document.querySelector("html").style.height="100%",s.style.margin="0px",s.style.height="100%",s.style.width="100%",e.display_element=s}else{const s=e.display_element instanceof Element?e.display_element:document.querySelector("#"+e.display_element);s===null?console.error("The display_element specified in initJsPsych() does not exist in the DOM."):e.display_element=s}const t=document.createElement("div");t.id="jspsych-content";const n=document.createElement("div");if(n.className="jspsych-content-wrapper",n.appendChild(t),this.displayContainerElement=e.display_element,this.displayContainerElement.appendChild(n),this.displayElement=t,e.experiment_width!==null&&(this.displayElement.style.width=e.experiment_width+"px"),e.display_element.tabIndex=0,this.displayContainerElement.classList.add("jspsych-display-element"),this.displayElement.classList.add("jspsych-content"),this.data.createInteractionListeners(),window.addEventListener("beforeunload",e.on_close),this.options.show_progress_bar){const s=document.createElement("div");s.id="jspsych-progressbar-container",this.progressBar=new Wt(s,this.options.message_progress_bar),this.getDisplayContainerElement().insertAdjacentElement("afterbegin",s)}})}finishTrial(e){this.finishTrialPromise.resolve(e)}}class M extends Error{constructor(e="The global `jsPsych` variable is no longer available in jsPsych v7."){super(`${e} Please follow the migration guide at https://www.jspsych.org/7.0/support/migration-v7/ to update your experiment.`),this.name="MigrationError"}}window.jsPsych={get init(){throw new M("`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.")},get data(){throw new M},get randomization(){throw new M},get turk(){throw new M},get pluginAPI(){throw new M},get ALL_KEYS(){throw new M('jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.')},get NO_KEYS(){throw new M('jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.')}},typeof window!="undefined"&&window.hasOwnProperty("webkitAudioContext")&&!window.hasOwnProperty("AudioContext")&&(window.AudioContext=webkitAudioContext);function yr(r){const e=new Ue(r);return Object.defineProperties(e,Object.fromEntries(Object.entries({init:"`jsPsych.init()` was replaced by `initJsPsych()` in jsPsych v7.",ALL_KEYS:'jsPsych.ALL_KEYS was replaced by the "ALL_KEYS" string in jsPsych v7.',NO_KEYS:'jsPsych.NO_KEYS was replaced by the "NO_KEYS" string in jsPsych v7.',currentTimelineNodeID:"`currentTimelineNodeID()` was renamed to `getCurrentTimelineNodeID()` in jsPsych v7.",progress:"`progress()` was renamed to `getProgress()` in jsPsych v7.",startTime:"`startTime()` was renamed to `getStartTime()` in jsPsych v7.",totalTime:"`totalTime()` was renamed to `getTotalTime()` in jsPsych v7.",currentTrial:"`currentTrial()` was renamed to `getCurrentTrial()` in jsPsych v7.",initSettings:"`initSettings()` was renamed to `getInitSettings()` in jsPsych v7.",allTimelineVariables:"`allTimelineVariables()` was renamed to `getAllTimelineVariables()` in jsPsych v7."}).map(([t,n])=>[t,{get(){throw new M(n)}}]))),e}return V.DataCollection=b,V.JsPsych=Ue,V.ParameterType=O,V.initJsPsych=yr,V}({}),initJsPsych=jsPsychModule.initJsPsych;
7
+ //# sourceMappingURL=https://unpkg.com/jspsych@8.2.0/dist/index.browser.min.js.map