{"version":3,"file":"692.391aca6789a76823fff9.js","mappings":"gIACA,MAAMA,EAAiBC,OAAOD,gBAAkBE,EAAAA,GAIhD,IAAIC,EAAQC,SAASC,cAAc,QAC/BC,EAAK,EACLC,EAAK,EACLC,EAAM,EAGV,MAAMC,EAAcA,CAACC,EAAEC,KAChBD,GAAKH,GAAMI,GAAKL,GACfL,OAAOW,uBAAsB,MAEtBF,GAAKH,GAAOG,GAAKH,GAAMM,KAAKC,IAAIH,EAAIH,GAN1B,MAOTA,EAAMG,EACNP,SAASW,gBAAgBC,MAAMC,YAAY,oBAAsB,GAAET,QAGpEE,GAAKH,IACJA,EAAKG,EACLN,SAASW,gBAAgBC,MAAMC,YAAY,YAAc,GAAEV,QAG5DI,GAAKL,IACJA,EAAKK,EACLP,SAASW,gBAAgBC,MAAMC,YAAY,aAAe,GAAEX,OAChE,GAER,EAKEY,EAAUd,SAASe,cAAc,OACvCD,EAAQE,aAAa,KAAK,YAC1BF,EAAQE,aAAa,cAAc,QACnCF,EAAQE,aAAa,QAAQ,+EAC7BjB,EAAMkB,YAAYH,GAIY,IAAIlB,GAAesB,IAC7C,IAAK,IAAIC,KAASD,EAAS,CACvB,MAAME,EAAKD,EAAME,YACjBhB,EAAYe,EAAGE,MAAMF,EAAGG,OAC5B,KAGkBC,QAAQV,E","sources":["webpack://Chaos Karts/./wwwroot/app/src/js/viewport-size.js"],"sourcesContent":["import { ResizeObserver as Polyfill } from '@juggle/resize-observer';\r\nconst ResizeObserver = window.ResizeObserver || Polyfill;\r\n\r\n// add element to body for accurately reporting viewport size\r\n\r\nlet $body = document.querySelector('body'),\r\n vh = 0,\r\n vw = 0,\r\n vih = 0,\r\n vihChangeThreshold = 90; // value larger than IOS Safari viewport height change on scroll\r\n\r\nconst vpSizeCheck = (w,h) => {\r\n if(w != vw || h != vh) {\r\n window.requestAnimationFrame(() => {\r\n // only change --vpInitialHeight if the width has changed or the height difference > 40px;\r\n if(w != vw || (w == vw && Math.abs(h - vih) > vihChangeThreshold)) {\r\n vih = h;\r\n document.documentElement.style.setProperty('--vpInitialHeight', `${vih}px`);\r\n }\r\n // vw\r\n if(w != vw) {\r\n vw = w;\r\n document.documentElement.style.setProperty('--vpWidth', `${vw}px`);\r\n }\r\n // vh\r\n if(h != vh) {\r\n vh = h;\r\n document.documentElement.style.setProperty('--vpHeight', `${vh}px`);\r\n }\r\n });\r\n }\r\n};\r\n\r\n// add element to body\r\n\r\nconst vpSizer = document.createElement('div');\r\nvpSizer.setAttribute('id','vp-sizer');\r\nvpSizer.setAttribute('aria-hidden','true');\r\nvpSizer.setAttribute('style','position:fixed;z-index:-1;top:0;left:0;bottom:0;right:0;pointer-events:none');\r\n$body.appendChild(vpSizer);\r\n\r\n// add resize observer\r\n\r\nconst vpSizerResizeObserver = new ResizeObserver(entries => {\r\n for (let entry of entries) {\r\n const cr = entry.contentRect;\r\n vpSizeCheck(cr.width,cr.height);\r\n }\r\n});\r\n\r\nvpSizerResizeObserver.observe(vpSizer);"],"names":["ResizeObserver","window","Polyfill","$body","document","querySelector","vh","vw","vih","vpSizeCheck","w","h","requestAnimationFrame","Math","abs","documentElement","style","setProperty","vpSizer","createElement","setAttribute","appendChild","entries","entry","cr","contentRect","width","height","observe"],"sourceRoot":""}