"use strict";(self.searchguard_bundle_jsonpfunction=self.searchguard_bundle_jsonpfunction||[]).push([[476],{1476:(e,t,n)=>{n.r(t),n.d(t,{default:()=>O});var s=n(4286),r=n(1728),a=n(3185),o=n(1319),i=n(5008),u=n(1069),c=n(2684),l=n(8307),d=n(872),p=n(1777),b=n(6791);function f(){const e=(0,c.useSidebarService)(),t=(0,u.J)(e.isOpen$(),e.isOpen()),n=(0,u.J)(e.getCurrentAppId$(),e.getCurrentAppId()),r=(0,s.useCallback)((()=>e.close()),[e]),a=(0,s.useCallback)((t=>e.setWidth(t)),[e]);return(0,s.useMemo)((()=>({isOpen:t,currentAppId:n,close:r,setWidth:a})),[t,n,r,a])}const h={name:"ozd7xs",styles:"flex-shrink:0"},m=()=>{const{setWidth:e}=f(),t=function(){const e=(0,c.useSidebarService)();return(0,u.J)(e.getWidth$(),e.getWidth())}(),n=(0,s.useRef)(0),r=(0,s.useRef)(0),a=(0,s.useCallback)((s=>{n.current=s.clientX,r.current=t;const a=t=>{const s=n.current-t.clientX,a=r.current+s;e(a)},o=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",o)};document.addEventListener("mousemove",a),document.addEventListener("mouseup",o)}),[t,e]),l=(0,s.useCallback)((s=>{const a=s.touches[0];n.current=a.clientX,r.current=t;const o=t=>{const s=t.touches[0],a=n.current-s.clientX,o=r.current+a;e(o)},i=()=>{document.removeEventListener("touchmove",o),document.removeEventListener("touchend",i)};document.addEventListener("touchmove",o),document.addEventListener("touchend",i)}),[t,e]),d=(0,s.useCallback)((n=>{let s=0;"ArrowLeft"===n.key?s=10:"ArrowRight"===n.key&&(s=-10),0!==s&&(n.preventDefault(),e(t+s))}),[t,e]);return(0,b.jsx)(o.EuiResizableButton,{css:h,indicator:"border",isHorizontal:!0,onMouseDown:a,onTouchStart:l,onKeyDown:d,"data-test-subj":"sidebarResizeHandle","aria-label":i.i18n.translate("core.ui.chrome.sidebar.resizePanelAriaLabel",{defaultMessage:"Resize side panel. Use left and right arrow keys to adjust width."})})};var v={name:"ow1hpv",styles:"display:flex;flex-direction:row;height:100%;width:100%"};const g=e=>v,x=i.i18n.translate("core.ui.chrome.sidebar.sidebarAriaLabel",{defaultMessage:"Side panel"}),S=()=>{const e=document.querySelector(p.td.join(","));e instanceof HTMLElement&&e.focus()},j=()=>{const e=(0,s.useRef)(null),t=(0,s.useRef)(),n=(0,s.useCallback)((e=>{t.current=e}),[]);return(0,s.useLayoutEffect)((()=>{const n=e.current;return()=>{var e;null!=n&&n.contains(document.activeElement)&&(null!==(e=t.current)&&void 0!==e?e:S)()}}),[]),{asideRef:e,setOnFocusRescue:n}},w=({children:e})=>{const t=(0,d.j)(),n=(0,s.useId)(),{asideRef:r,setOnFocusRescue:a}=j(),i=(0,s.useMemo)((()=>({headingId:n,setOnFocusRescue:a})),[n,a]);return(0,b.jsx)(c.SidebarPanelContext.Provider,{value:i},(0,b.jsx)("aside",{ref:r,css:g,"data-test-subj":"sidebarPanel","aria-labelledby":n,"aria-label":x},(0,b.jsx)(m,null),(0,b.jsx)(o.EuiPanel,{paddingSize:"none",css:(u="project"===t,e=>(0,b.css)("display:flex;flex-direction:column;flex-grow:1;min-width:0;overflow:hidden;",u&&(0,b.css)("border-radius:",e.euiTheme.border.radius.medium,";outline:",(0,l.z)(e),";",(0,o.euiShadow)(e,"xs",{border:"none"}),";",""),";","")),hasBorder:!1,hasShadow:!1,borderRadius:"none"},e)));var u},y=e=>t=>{const{euiTheme:n}=t;return(0,b.css)(e&&(0,o.euiOverflowScroll)(t,{direction:"y"}),";padding:",n.size.m,";flex-grow:1;","")},E=i.i18n.translate("core.ui.chrome.sidebar.sidebarContentLabel",{defaultMessage:"Side panel content"}),L=({children:e,scrollable:t=!1})=>(0,b.jsx)(o.EuiPanel,(0,a.default)({},t&&{tabIndex:0,role:"region","aria-label":E},{css:y(t),hasShadow:!1,paddingSize:"none","data-test-subj":"sidebarBody"}),e);function A(){const{isOpen:e,currentAppId:t}=f(),n=(0,c.useSidebarService)();return e&&t&&n.hasApp(t)?(0,b.jsx)(k,{key:t,appId:t}):null}function k({appId:e}){const t=(0,c.useSidebarService)(),n=t.getApp(e),r=t.getAppDefinition(e),a="pending"===(0,u.J)(n.getStatus$(),n.getStatus()),o=(0,b.jsx)(M,null);return(0,b.jsx)(w,null,(0,b.jsx)(s.Suspense,{fallback:o},a?o:(0,b.jsx)(z,{appApi:n,appDef:r})))}const R=new WeakMap,C=e=>{let t=R.get(e);return t||(t=(0,s.lazy)((async()=>({default:await e()}))),R.set(e,t)),t};function z({appApi:e,appDef:t}){const n=(0,u.J)(e.getState$(),e.getState()),s=null!=t.store,r=C(t.loadComponent),o=s?{state:n,actions:e.actions}:{};return(0,b.jsx)(r,(0,a.default)({onClose:e.close},o))}const I=i.i18n.translate("core.ui.chrome.sidebar.loadingSidebarPanelAriaLabel",{defaultMessage:"side panel"}),M=()=>(0,b.jsx)(L,null,(0,b.jsx)(o.EuiSkeletonText,{lines:8,contentAriaLabel:I}));function O(e){return(0,b.jsx)(r.KibanaSectionErrorBoundary,{sectionName:"Sidebar"},(0,b.jsx)(A,null))}}}]);