define("@wsb/guac-widget-shared/lib/components/DynamicFontScaler-6cccd626.js",["exports","~/c/_rollupPluginBabelHelpers","~/c/dynamicFontScaler"],(function(t,e,n){"use strict";function o(t){let e,{containerId:n,targetId:o,fontSizes:r,maxLines:i,prioritizeDefault:s}=t;if("undefined"==typeof document)return;const a=document.getElementById(n),c=document.getElementById(o);function l(t){return function(t){const e=parseInt(y(t,"padding-left")||0,10),n=parseInt(y(t,"padding-right")||0,10);return t.scrollWidth+e+n}(t)<=a.clientWidth&&function(t){const e=t.offsetHeight,n=parseInt(y(t,"line-height"),10)||1;return Math.floor(e/n)}(t)<=i}function p(t){return parseInt(y(t,"font-size")||0,10)}function d(t){if(1===t.length)return t[0];const e=t.filter(l);if(1===e.length)return e[0];if(!e.length)return function(t){return t.sort(((t,e)=>p(t)-p(e)))[0]}(t);return e.sort(((t,e)=>p(e)-p(t)))[0]}function u(){if(!a||!c||e===window.innerWidth)return;if(c.hasAttribute("data-font-scaled"))return void g();e=window.innerWidth;const t=Array.prototype.slice.call(a.querySelectorAll(`[data-scaler-id="scaler-${n}"]`)).sort(((t,e)=>r.indexOf(t.getAttribute("data-size"))-r.indexOf(e.getAttribute("data-size"))));if(a.clientWidth&&t.length){const e=a.style.width||"";a.style.width="100%",t.forEach((t=>{t.style.display="inline-block",t.style.maxWidth=`${a.clientWidth}px`}));const n=d(t);!function(t){t.forEach((t=>{t.style.display="none",t.style.maxWidth=""}))}(t),a.style.width=e;const r=y(n,"font-size"),i=c.getAttribute("data-last-size");if(r&&r!==i){if(s){const t=y(c,"font-size");if(parseInt(r,10)>=parseInt(t,10))return}c.setAttribute("data-last-size",r);let t=document.querySelector(`#${o}-style`);t||(t=document.createElement("style"),t.id=`${o}-style`,document.head.appendChild(t)),t.textContent=`#${c.id} { font-size: ${r} !important; }`}}}function g(){c&&c.removeAttribute("data-last-size");const t=document.querySelector(`#${o}-style`);t&&t.parentNode.removeChild(t)}function y(t,e){return document.defaultView.getComputedStyle(t).getPropertyValue(e)}return u(),window.addEventListener("resize",u),()=>{g(),window.removeEventListener("resize",u)}}const{Bootstrap:r}=(global.Core||guac["@wsb/guac-widget-core"]).components,{XXLARGE:i,XLARGE:s,LARGE:a}=(global.Core||guac["@wsb/guac-widget-core"]).constants.fontSizes,{PUBLISH:c}=(global.Core||guac["@wsb/guac-widget-core"]).constants.renderModes;class l extends(global.React||guac.react).Component{getDynamicFontScaler(){return n.d({...this.props})}componentDidUpdate(){this.invokeScript()}componentDidMount(){this.invokeScript()}invokeScript(){const{scriptOnly:t,renderMode:e}=this.props;t&&e===c||(this.detachScript(),this._detachScript=o(this.getDynamicFontScaler().scriptProps))}detachScript(){this._detachScript&&this._detachScript()}componentWillUnmount(){this.detachScript()}render(){const{renderMode:t,scriptOnly:e}=this.props;if(e)return t===c?(global.React||guac.react).createElement(r.JS,{id:"DynamicFontScaler",script:o.toString(),scriptOnly:!0}):(window.wsb=window.wsb||{},window.wsb.DynamicFontScaler=window.wsb.DynamicFontScaler||o,null);const{element:n,scriptProps:i}=this.getDynamicFontScaler();return t===c?(global.React||guac.react).createElement((global.React||guac.react).Fragment,null,n,(global.React||guac.react).createElement(r.JS,{id:"DynamicFontScaler",script:o.toString(),props:i})):n}}e.a(l,"propTypes",{typography:(global.PropTypes||guac["prop-types"]).string,text:(global.PropTypes||guac["prop-types"]).string.isRequired,containerId:(global.PropTypes||guac["prop-types"]).string.isRequired,font:(global.PropTypes||guac["prop-types"]).string,renderMode:(global.PropTypes||guac["prop-types"]).oneOf(Object.values((global.Core||guac["@wsb/guac-widget-core"]).constants.renderModes)),targetId:(global.PropTypes||guac["prop-types"]).string.isRequired,fontSizes:(global.PropTypes||guac["prop-types"]).arrayOf((global.PropTypes||guac["prop-types"]).oneOf(Object.values((global.Core||guac["@wsb/guac-widget-core"]).constants.fontSizes))),style:(global.PropTypes||guac["prop-types"]).object,maxLines:(global.PropTypes||guac["prop-types"]).number,Tag:(global.PropTypes||guac["prop-types"]).node,prioritizeDefault:(global.PropTypes||guac["prop-types"]).bool,scriptOnly:(global.PropTypes||guac["prop-types"]).bool}),e.a(l,"defaultProps",{fontSizes:[i,s,a],scriptOnly:!1}),t.default=l,Object.defineProperty(t,"__esModule",{value:!0})})),"undefined"!=typeof window&&(window.global=window);
//# sourceMappingURL=DynamicFontScaler-6cccd626.js.map
