Liferay.Loader.define("data-engine-js-components-web@1.0.75/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({children:e}){const t=(0,n.useRef)(),{activePage:r,containerElement:u}=(0,o.usePage)(),[c,i]=(0,n.useState)(0);return(0,n.useLayoutEffect)((()=>{if(t.current&&(null==u?void 0:u.current))if(t.current.querySelector(".loading-animation"))setTimeout((()=>i((e=>e+1))),5);else if(!document.activeElement||!Liferay.ThemeDisplay.isControlPanel()&&document.activeElement.querySelector("input")&&"hidden"===document.activeElement.querySelector("input").type){const e=t.current.closest(".ddm-form-page").querySelector("input:first-of-type"),r=document.querySelector(".ddm-form-builder--sidebar-open"),n=u.current.querySelector(".ddm-user-view-content");e&&!u.current.contains(document.activeElement)&&(r||n)&&(e.focus({behavior:"instant",preventScroll:!1}),e.select&&e.select())}}),[r,t,u,c]),n.default.cloneElement(e,{ref:e=>{t.current=e}})};var n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=u();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 u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}}}));
//# sourceMappingURL=AutoFocus.es.js.map