/*! $AC$ PennController.newVoiceRecorder(name,file) Creates a new VoiceRecorder element $AC$$AC$ PennController.getVoiceRecorder(name) Retrieves an existing Video element $AC$$AC$ global.PennController.InitiateRecorder(url,message) Sets the URL where to upload the recordings and creates a trial inviting the user to activate their microphone $AC$$AC$ VoiceRecorder PElement.play() Starts playing back the recording $AC$$AC$ VoiceRecorder PElement.record() Starts recording $AC$$AC$ VoiceRecorder PElement.stop() Stops playback or recording $AC$$AC$ VoiceRecorder PElement.wait() Waits until recording stops before proceeding $AC$$AC$ VoiceRecorder PElement.settings.once() Will disable the recording interface after the first recording is complete $AC$$AC$ VoiceRecorder PElement.settings.log() Will log events in the results file $AC$$AC$ VoiceRecorder PElement.test.hasPlayed() Checks that the recording was fully played back before $AC$$AC$ VoiceRecorder PElement.test.playing() Checks that the recording is currently being played back $AC$$AC$ VoiceRecorder PElement.test.recorded() Checks that recording has happened $AC$$AC$ global.PennController.DownloadVoiceButton(text) Returns an HTML string representing a button to download an archive of the recordings $AC$ */!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=137)}({137:function(e,t){window.PennController._AddElementType("VoiceRecorder",function(e){let t,r,n,o=[],i="",s=!1,a=[],l=[],d=[];window.PennController.InitiateRecorder=function(o,c){o.match(/^http.+/i)||e.debug.error("VoiceRecorder's save URL is incorrect",o),i=o,s=!0;let u=e.controllers.new();u.id="InitiateRecorder",u.runHeader=!1,u.runFooter=!1,e.controllers.list.pop(),e.tmpItems.push(u),u.sequence=(()=>new Promise(o=>{let i=e.controllers.running;if(!navigator.mediaDevices)return i.element.append($("

Sorry, you cannot complete this experiment because your browser does not support voice recording.

"));c||(c="This experiment collects voice recording samples from its participants. Your browser should now be prompting a permission request to use your recording device (if applicable). By giving your authorization to record, and by participating in this experiment, you are giving permission to the designer(s) of this experiment to anonymously collect the voice samples recorded during this experiment. The output audio files will be uploaded to and hosted on a server designated by the experimenter(s). If you accept the request, a label will remain visible at the top of this window throughout the whole experiment, indicating whether you are being recorded."),i.element.append($("

"+c+"

"));let s=[];navigator.mediaDevices.getUserMedia({audio:!0}).then(function(e){(t=new MediaRecorder(e)).recording=!1,t.onstop=function(e){n.css({"font-weight":"normal",color:"black","background-color":"lightgray"}),n.html("Not recording"),r.filename=r.id+".mp3",r.blob=new Blob(s,{type:"audio/mpeg"}),r.audioPlayer.src=URL.createObjectURL(r.blob),s=[],r=null,l.shift().call(),t.recording=!1},t.onstart=function(e){n.css({"font-weight":"bold",color:"white","background-color":"red"}),n.html("Recording..."),t.recording=!0,a.shift().call()},t.ondataavailable=function(e){s.push(e.data)},i.element.append($("By clicking this link I understand that I grant this experiment's script access to my recording device for the purpose of uploading voice recordings to the server designated by the experimenter(s).").addClass("Message-continue-link").click(o)),(n=$("
Not recording
")).css({position:"fixed",top:0,left:"50%",transform:"translateX(-50%)",padding:"2px","background-color":"lightgray"}),$("#bod").append(n)}).catch(function(e){i.element.append($("

The following error occurred: "+e+"

"))})}));let p=u.log;return u.log=((...e)=>{d.push(e),p.apply(u,e)}),u},e.Prerun(()=>{let t=window.conf_modifyRunningOrder;window.conf_modifyRunningOrder=function(r){if(t instanceof Function&&(r=t.apply(this,[r])),!s)return r;let n=!1,a=[-1,-1];for(let e=0;e=0&&alert("WARNING: upload of voice archive set AFTER sending of results; check your Sequence definition.")):"__SendResults__"==r[e][t].controller&&a[0]<0&&!n&&(a=[e,t]);if(!n){let t=e.controllers.new();t.id="UploadRecordings",t.runHeader=!1,t.runFooter=!1,t.countsForProgressBar=!1,t.sequence=(()=>new Promise(t=>{let r=e.controllers.running;r.element.append($("

Please wait while the archive is being uploaded to the server...

"));let n=new e.utils.JSZip;for(let e in o)n.file(o[e].name,o[e].data);n.generateAsync({compression:"DEFLATE",type:"blob"}).then(function(n){window.PennController.downloadVoiceRecordingsArchive=(()=>e.utils.saveAs(n,"VoiceRecordingsArchive.zip"));let o=e.utils.guidGenerator()+".zip";var s=new File([n],o),a=new FormData;a.append("fileName",o),a.append("file",s),a.append("mimeType","application/zip");var l=new XMLHttpRequest;l.open("POST",i,!0),l.onreadystatechange=(()=>{if(4==l.readyState){r.save("PennController","UploadRecordings","Filename",o,Date.now(),"NULL"),200==l.status&&!l.responseText.match(/problem|error/i)?r.save("PennController","UploadRecordings","Status","Success",Date.now(),"NULL"):(alert("There was an error uploading the recordings ("+l.responseText+")."),window.PennController.uploadRecordingsError=l.responseText||"error",e.debug.error("VoiceRecorder's Ajax post failed. ("+l.status+")",l.responseText),r.save("PennController","UploadRecordings","Status","Failed",Date.now(),"Error Text: "+l.responseText+"; Status: "+l.status)),t()}}),l.send(a)})}));for(let e=0;e=0?r[a[0]].splice(a[1],0,n):r.push([n])}return r}}),this.immediate=function(e){void 0!==e&&"string"==typeof e&&0!=e.length||(e="VoiceRecorder"),this.id=e},this.uponCreation=function(n){void 0===t&&e.debug.error("Recorder not initiated. Make sure the sequence of items contains an InitiateRecorder PennController."),this.log=!1,this.recordings=[],this.recording=!1,this.audioPlayer=document.createElement("audio"),this.jQueryElement=$("").addClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-ui");let o=$(""}}});