{"version":3,"file":"fullscreen.polyfill.js","sources":["../src/index.js"],"sourcesContent":["const spec = [\n\t'fullscreen',\n\t'fullscreenEnabled',\n\t'fullscreenElement',\n\t'fullscreenchange',\n\t'fullscreenerror',\n\t'exitFullscreen',\n\t'requestFullscreen'\n]\n\nconst webkit = [\n\t'webkitIsFullScreen',\n\t'webkitFullscreenEnabled',\n\t'webkitFullscreenElement',\n\t'webkitfullscreenchange',\n\t'webkitfullscreenerror',\n\t'webkitExitFullscreen',\n\t'webkitRequestFullscreen'\n]\n\nconst moz = [\n\t'mozFullScreen',\n\t'mozFullScreenEnabled',\n\t'mozFullScreenElement',\n\t'mozfullscreenchange',\n\t'mozfullscreenerror',\n\t'mozCancelFullScreen',\n\t'mozRequestFullScreen'\n]\n\nconst ms = [\n\t'',\n\t'msFullscreenEnabled',\n\t'msFullscreenElement',\n\t'MSFullscreenChange',\n\t'MSFullscreenError',\n\t'msExitFullscreen',\n\t'msRequestFullscreen'\n]\n\n// Make sure document exist, if it doesn't make it a dumb object\ndocument ? document : (document = {})\n\n// Get the vendor fullscreen prefixed api\nconst fsVendorKeywords = (function getFullscreenApi () {\n\tconst fullscreenEnabled = [spec[1], webkit[1], moz[1], ms[1]].find((prefix) => document[prefix])\n\treturn [spec, webkit, moz, ms].find((vendor) => {\n\t\treturn vendor.find((prefix) => prefix === fullscreenEnabled)\n\t}) || []\n})()\n\nfunction handleEvent (eventType, event) {\n\tdocument[spec[0]] = document[fsVendorKeywords[0]] ||\n\t\t!!document[fsVendorKeywords[2]] || false\n\tdocument[spec[1]] = document[fsVendorKeywords[1]] || false\n\tdocument[spec[2]] = document[fsVendorKeywords[2]] || null\n\tdocument.dispatchEvent(new Event(eventType), event.target)\n}\n\nfunction setupShim () {\n\t// fullscreen\n\t// Defaults to false for cases like MS where they do not have this\n\t// attribute. Another way to check whether fullscreen is active is to look\n\t// at the fullscreenElement attribute.\n\tdocument[spec[0]] = document[fsVendorKeywords[0]] || \n\t\t!!document[fsVendorKeywords[2]] || false\n\n\t// fullscreenEnabled\n\tdocument[spec[1]] = document[fsVendorKeywords[1]] || false\n\n\t// fullscreenElement\n\tdocument[spec[2]] = document[fsVendorKeywords[2]] || null\n\n\t// onfullscreenchange\n\tdocument.addEventListener(fsVendorKeywords[3], handleEvent.bind(document, spec[3]), false)\n\n\t// onfullscreenerror\n\tdocument.addEventListener(fsVendorKeywords[4], handleEvent.bind(document, spec[4]), false)\n\n\t// exitFullscreen\n\tdocument[spec[5]] = function () { return document[fsVendorKeywords[5]]() }\n\n\t// requestFullscreen\n\tElement.prototype[spec[6]] = function () {\n\t\treturn this[fsVendorKeywords[6]].apply(this, arguments)\n\t}\n}\n\n// Don't polyfill if it already exist\nexport default document[spec[1]] ? {} : setupShim()\n"],"names":["spec","webkit","moz","ms","document","fullscreenEnabled","fsVendorKeywords","find","prefix","vendor","handleEvent","eventType","event","dispatchEvent","Event","target","addEventListener","bind","prototype","this","apply","arguments"],"mappings":";;;;;;+CAAA,IAAMA,EAAO,CACZ,aACA,oBACA,oBACA,mBACA,kBACA,iBACA,qBAGKC,EAAS,CACd,qBACA,0BACA,0BACA,yBACA,wBACA,uBACA,2BAGKC,EAAM,CACX,gBACA,uBACA,uBACA,sBACA,qBACA,sBACA,wBAGKC,EAAK,CACV,GACA,sBACA,sBACA,qBACA,oBACA,mBACA,uBAIDC,WAAuBA,SAAW,IAGlC,IACOC,EADDC,GACCD,EAAoB,CAACL,EAAK,GAAIC,EAAO,GAAIC,EAAI,GAAIC,EAAG,IAAII,KAAK,SAACC,UAAWJ,SAASI,KACjF,CAACR,EAAMC,EAAQC,EAAKC,GAAII,KAAK,SAACE,UAC7BA,EAAOF,KAAK,SAACC,UAAWA,IAAWH,OACrC,IAGP,SAASK,EAAaC,EAAWC,YACvBZ,EAAK,IAAMI,SAASE,EAAiB,OAC3CF,SAASE,EAAiB,MAAO,WAC3BN,EAAK,IAAMI,SAASE,EAAiB,MAAO,WAC5CN,EAAK,IAAMI,SAASE,EAAiB,KAAO,cAC5CO,cAAc,IAAIC,MAAMH,GAAYC,EAAMG,eAiCrCX,SAASJ,EAAK,IAAM,aAzBzBA,EAAK,IAAMI,SAASE,EAAiB,OAC3CF,SAASE,EAAiB,MAAO,WAG3BN,EAAK,IAAMI,SAASE,EAAiB,MAAO,WAG5CN,EAAK,IAAMI,SAASE,EAAiB,KAAO,cAG5CU,iBAAiBV,EAAiB,GAAII,EAAYO,KAAKb,SAAUJ,EAAK,KAAK,YAG3EgB,iBAAiBV,EAAiB,GAAII,EAAYO,KAAKb,SAAUJ,EAAK,KAAK,YAG3EA,EAAK,IAAM,kBAAqBI,SAASE,EAAiB,oBAG3DY,UAAUlB,EAAK,IAAM,kBACrBmB,KAAKb,EAAiB,IAAIc,MAAMD,KAAME"}