!function(t,e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).autofit=e()}(this,(function(){"use strict";function t(t,n){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=function(t,n){if(t){if("string"==typeof t)return e(t,n);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){o&&(t=o);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,c=!0,a=!1;return{s:function(){o=o.call(t)},n:function(){var t=o.next();return c=t.done,t},e:function(t){a=!0,l=t},f:function(){try{c||null==o.return||o.return()}finally{if(a)throw l}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n0&&void 0!==arguments[0]?arguments[0]:{};(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&console.log("autofit.js is running");var e=t.dw,n=void 0===e?1920:e,u=t.dh,f=void 0===u?1080:u,y=t.el,h=void 0===y?"string"==typeof t?t:"body":y,v=t.resize,g=void 0===v||v,p=t.ignore,b=void 0===p?[]:p,S=t.transition,w=void 0===S?"none":S,A=t.delay,x=void 0===A?0:A,j=t.limit,T=void 0===j?.1:j,M=t.cssMode,q=void 0===M?"scale":M,z=t.allowScroll,H=void 0!==z&&z;o=h;var R=document.querySelector(h);if(R){var E=document.createElement("style"),L=document.createElement("style");E.lang="text/css",L.lang="text/css",E.id="autofit-style",L.id="ignoreStyle",!H&&(E.innerHTML="body {overflow: hidden;}");var N=document.querySelector("body");N.appendChild(E),N.appendChild(L),R.style.height="".concat(f,"px"),R.style.width="".concat(n,"px"),R.style.transformOrigin="0 0",!H&&(R.style.overflow="hidden"),m(n,f,R,b,T,q),c=function(){clearTimeout(a),0!=x?a=setTimeout((function(){m(n,f,R,b,T,q),s&&d(i,l,r)}),x):(m(n,f,R,b,T,q),s&&d(i,l,r))},g&&window.addEventListener("resize",c),this.isAutofitRunnig=!0,setTimeout((function(){R.style.transition="".concat(w,"s")}))}else console.error("autofit: '".concat(h,"' is not exist"))},off:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"body";try{var e;window.removeEventListener("resize",c),null===(e=document.querySelector("#autofit-style"))||void 0===e||e.remove();var n=document.querySelector("#ignoreStyle");n&&n.remove();var i=document.querySelector(o||t);i&&(i.style=""),s&&y()}catch(t){console.error("autofit: Failed to remove normally",t),this.isAutofitRunnig=!1}this.isAutofitRunnig&&console.log("autofit.js is off")},elRectification:null,scale:u};function d(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;f.isAutofitRunnig||console.error("autofit.js:autofit has not been initialized yet"),y(),!t&&console.error("autofit.js:bad selector: ".concat(t)),i=t,r=n,l=e;var o=Array.from(document.querySelectorAll(t));if(0!=o.length){for(var c=0,a=o;c5&&void 0!==arguments[5]?arguments[5]:"scale",a=document.documentElement.clientHeight,s=document.documentElement.clientWidth;u=s/al?u:1,f.scale=+u;var d=Math.round(a/Number(u)),y=Math.round(s/Number(u));i.style.height="".concat(d,"px"),i.style.width="".concat(y,"px"),"zoom"===c?i.style.zoom="".concat(u):i.style.transform="scale(".concat(u,")");var m=document.querySelector("#ignoreStyle");m.innerHTML="";var h,v=t(r);try{for(v.s();!(h=v.n()).done;){var g=h.value,p=g.el||g.dom;if("string"==typeof g&&(p=g),p&&("object"!==n(p)||Object.keys(p).length)){var b=g.scale?g.scale:1/Number(u),S=b!=u&&g.fontSize,w=b!=u&&g.width,A=b!=u&&g.height;m.innerHTML+="\n".concat(p," { \n transform: scale(").concat(b,")!important;\n transform-origin: 0 0;\n ").concat(w?"width: ".concat(w,"!important;"):"","\n ").concat(A?"height: ".concat(A,"!important;"):"","\n }"),S&&(m.innerHTML+="\n".concat(p," div ,").concat(p," span,").concat(p," a,").concat(p," * {\n font-size: ").concat(S,"px;\n }"))}else console.error("autofit: found invalid or empty selector/object: ".concat(p))}}catch(t){v.e(t)}finally{v.f()}}return f.elRectification=d,f}));