(function(){var a=null,b=null,c=function(){a=window.URL||window.webkitURL||window.mozURL||window.msURL||window.oURL,b=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia},d={flash:null,container:null,imgFormat:"png",imgWidth:null,imgHeight:null},e=function(a){this._config=g(d,a);if(!this._config.container)throw new Error("Photographer.js requires a container element");this._stream=null,this._photos=[];var e=this._config.container.clientWidth,f=this._config.container.clientHeight;this._config.imgWidth||(this._config.imgWidth=e),this._config.imgHeight||(this._config.imgHeight=f),this._video=document.createElement("video"),this._video.width=e,this._video.height=f,this._config.container.appendChild(this._video),this._canvas=document.createElement("canvas"),this._canvas.width=this._config.imgWidth,this._canvas.height=this._config.imgHeight,this._context=this._canvas.getContext("2d"),c(),b||(this.start=this.stop=this.takePhoto=function(){return!1})},f=e.prototype;f.start=function(){var c=this,d=function(b){c._stream=b;try{c._video.src=a.createObjectURL(b)}catch(d){c._video.src=b}c._video.play()},e=function(a){throw new Error(a)};return b.call(navigator,{video:!0},d,e),!0},f.stop=function(){return this._stream&&this._stream.stop(),delete this._stream,!0},f.takePhoto=function(){this._config.flash&&this._config.flash(this._config.container),this._context.drawImage(this._video,0,0,this._config.imgWidth,this._config.imgHeight);var a=this._canvas.toDataURL("image/"+this._config.imgFormat),b=a.match(/^data:image\/(\w+);/)[1],c={src:a,format:b,width:this._config.imgWidth,height:this._config.imgHeight};return this._photos.push(g(c)),c},f.getPhotos=function(){return this._photos.slice(0)},window.Photographer=e;var g=function(a,b){var c={},d;for(d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);for(d in b)b.hasOwnProperty(d)&&(c[d]=b[d]);return c}})();