Liferay.Loader.define("data-engine-js-components-web@1.0.79/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:l}=(0,o.usePage)(),[i,c]=(0,n.useState)(0);return(0,n.useLayoutEffect)((()=>{if(t.current&&(null==l?void 0:l.current))if(t.current.querySelector(".loading-animation"))setTimeout((()=>c((e=>e+1))),5);else if(!document.activeElement||!Liferay.ThemeDisplay.isControlPanel()&&document.activeElement.querySelector("input")&&"hidden"===document.activeElement.querySelector("input").type||(null==l?void 0:l.current.parentNode.className.includes("ddm-form-builder-app"))){!function(){const e=document.querySelector('div[class^="lfr-layout-structure-item');var t;(null==e?void 0:e.querySelector(".portlet-forms"))||null===(t=document.querySelectorAll(".lfr-ddm__default-page-header-title,.lfr-ddm__default-page-header-description,.lfr-ddm-form-page-title,.lfr-ddm-form-page-description"))||void 0===t||t.forEach((e=>e.removeAttribute("tabindex")))}();const e=null==l?void 0:l.current.parentNode.getElementsByClassName("lfr-ddm__default-page-header-title")[0];u(e);const t=null==e?void 0:e.innerHTML,r=null==l?void 0:l.current.parentNode.getElementsByClassName(".lfr-ddm__default-page-header-description")[0],n=null==r?void 0:r.innerHTML,o=document.activeElement.querySelector(".ddm-layout-builder:not(.hide)"),i=null==o?void 0:o.querySelector('input:not([type="hidden"])'),c=document.querySelector(".ddm-form-builder--sidebar-open"),d=l.current.querySelector(".ddm-user-view-content"),a=Liferay.Language.get("untitled-form");t&&t!==a||n||!i||l.current.contains(document.activeElement)||!c&&!d||(i.focus({behavior:"smooth",preventScroll:!1}),i.select&&i.select()),u(e)}}),[r,t,l,i]),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=l();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 u=n?Object.getOwnPropertyDescriptor(e,o):null;u&&(u.get||u.set)?Object.defineProperty(r,o,u):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 l(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}function u(e){if(e){var t;const r=e.getBoundingClientRect(),n=null===(t=document.querySelector(".control-menu-container"))||void 0===t?void 0:t.clientHeight;window.scroll(r.x-n,r.y-n)}}}}));
//# sourceMappingURL=AutoFocus.es.js.map