"use strict";var e=require("@kdcloudjs/kwc"),s=require("./shadowBaseClassPrivate.js"),t=require("../focus-DdgBlQbB.js");require("../utilsPrivate-DL4VBetH.js"),require("../client-Co_j5m_k.js"),require("../ssr-RXknEJpO.js"),require("../observable-BXDJFaLN.js"),require("../empty_html-hFq4zm9t.js"),require("../i18n-CP31jeWH.js"),require("./iso8601Utils.js"),require("../colorValid-BBnkvgd_.js"),require("./tooltipLibrary.js"),require("./positionLibrary.js"),require("./primitiveBubble.js"),require("../kddsCommon-CICoPypw.js"),require("../classSet-B5xuJbNb.js"),require("./ariaObserver.js");var i=[function(e,s,t){var i=e?"["+e+"]":"";return"div[data-start]"+i+",\rdiv[data-end]"+i+" {position: fixed;top: 1rem;left: 1rem;}"}];const r=e.parseFragment`<div${"a0:tabindex"} data-start${3}></div>`,o=e.parseFragment`<div${"a0:tabindex"} data-end${3}></div>`,n=[];function a(e,s,t,i){const{ti:a,b:u,sp:d,st:l,s:c}=e,{_m0:_,_m1:m,_m2:h,_m3:p,_m4:f}=i;return[l(r,1,[d(0,{on:m||(i._m1={focus:u(s._focusLastElement)}),attrs:{tabindex:a(s._bookendTabIndex)}},null)]),c("",{key:2,on:h||(i._m2={focusin:u(s._handleFocusIn),focusout:u(s._handleFocusOut)})},n,t),l(o,4,[d(0,{on:f||(i._m4={focus:u(s._focusFirstElement)}),attrs:{tabindex:a(s._bookendTabIndex)}},null)])]}var u=e.registerTemplate(a);a.slots=[""],a.stylesheets=[],a.stylesheetToken="kwc-4840k3f1rh1",a.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\focusTrap-undefined_focusTrap",i&&a.stylesheets.push.apply(a.stylesheets,i),e.freezeTemplate(a);class d extends s{constructor(...e){super(...e),this._startNode=void 0,this._endNode=void 0,this._focused=!1,this._initialized=!1,this._pendingFocusOut=!1}renderedCallback(){this._initialized||(this._initialized=!0,this._startNode=this.template.querySelector("[data-start]"),this._endNode=this.template.querySelector("[data-end]"))}focus(){this._focused||this._focusFirstElement()}get _bookendTabIndex(){return this._focused?"0":"-1"}_handleFocusIn(){this._pendingFocusOut&&(this._pendingFocusOut=!1),this._focused=!0}_handleFocusOut(){this._pendingFocusOut=!0,requestAnimationFrame(()=>{this._pendingFocusOut&&(this._focused=!1)})}_moveFocusTo(e){const s=this._getFocusableElements();if(s.length>0){let t;"last"===e?t=s[s.length-1]:"first"===e&&(t=s[0]),t.focus()}}_focusFirstElement(){this._moveFocusTo("first")}_focusLastElement(){this._moveFocusTo("last")}_getFocusableElements(){return t.findAllTabbableElements(this.template.querySelector("slot"))}}e.registerDecorators(d,{publicMethods:["focus"],fields:["_startNode","_endNode","_focused","_initialized","_pendingFocusOut"]});const l=e.registerComponent(d,{tmpl:u,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\focusTrap-",apiVersion:63});module.exports=l;
