Liferay.Loader.define("data-engine-js-components-web@1.0.112/js/core/components/AutoFocus.es",["module","exports","require","liferay!frontend-js-react-web$react","../hooks/usePage.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoFocus=function AutoFocus({children:e}){const t=(0,n.useRef)(),{activePage:r,containerElement:c}=(0,o.usePage)(),[u,i]=(0,n.useState)(0);return(0,n.useLayoutEffect)((()=>{if(t.current&&(null==c?void 0:c.current))if(t.current.querySelector(".loading-animation"))setTimeout((()=>i((e=>e+1))),5);else if(!document.activeElement){const e=t.current.querySelector("input"),r=document.querySelector(".ddm-form-builder--sidebar-open"),n=c.current.querySelector(".ddm-user-view-content");e&&!c.current.contains(document.activeElement)&&(r||n)&&(e.focus(),e.select&&e.select())}}),[r,t,c,u]),n.default.cloneElement(e,{ref:e=>{t.current=e}})};var n=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var c=n?Object.getOwnPropertyDescriptor(e,o):null;c&&(c.get||c.set)?Object.defineProperty(r,o,c):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),o=r("../hooks/usePage.es");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}}}));
//# sourceMappingURL=AutoFocus.es.js.map