Build 567923stable
Module 464651
8,586 characters · in 3d3b05863accbf32.jsDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ff:()=>x,JZ:()=>_,Fk:()=>C,FV:()=>A,oV:()=>E,se:()=>I}),n(321073);var l=n(64700),i=n(735438),s=n.n(i),r=n(741918),a=n(788413),o=n(602034);let u=[r.D$.TAB];function c(e,t,n){return null!=t&&null!=n?`#${(0,o.Aq)(e,t,n)}`:`[data-ref-id=${e}]`}function d(e){return document.querySelector(e)}var m=n(23339),h=n(319060),p=n(60587),f=n(652215);let g=(0,m.xI)(h.A.EMOJI_PICKER_CONSTANTS_EMOJI_LIST_PADDING_LEFT),E=e=>{let{gridWrapperRef:t,containerWidth:n,showingEmptyState:i,listPaddingLeft:r=g,listScrollbarWidth:a=8}=e,[o,u]=l.useState(void 0),c=l.useCallback(()=>{if(null==t.current)return null;u(t.current.offsetWidth-r-a)},[t,r,a]);return l.useLayoutEffect(()=>{c()},[n,c,i]),l.useEffect(()=>{let e=s().debounce(c,250);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[c]),o};function A(e){let{activeCategoryIndex:t,listRef:n,searchQuery:i}=e,s=l.useRef(i),r=l.useRef(!0);l.useLayoutEffect(()=>{""===i&&""!==s.current&&n.current?.scrollToSectionTop(t),s.current=i},[i,t,n]),l.useLayoutEffect(()=>{r.current&&(n.current?.scrollToSectionTop(t),r.current=!1)},[t,n]),l.useEffect(()=>{s.current=i},[i])}let C=e=>{let{activeCategoryIndex:t,listRef:n,isScrolling:i,searchQuery:r,scrollOffset:a=0,onActiveCategoryIndexChange:o,disableForSearch:u=!0}=e,c=l.useRef(f.An1),d=l.useRef(t);d.current=t;let m=l.useMemo(()=>s().debounce(()=>{i.current=!1},250),[i]),h=l.useMemo(()=>s().debounce(e=>{""!==r&&u||(window.cancelAnimationFrame(c.current),c.current=window.requestAnimationFrame(()=>{let t=n.current?.getSectionDescriptors();if(null==t)return;let l=t.findIndex((n,l)=>{let i=t[l+1],s=e+a>=n.offset.top,r=null!=i&&e+a<i.offset.top;return null!=i&&!s&&!r||s&&r||s&&null==i}),i=-1===l?0:l;d.current!==i&&o(i)}))},0),[r,n,a,o,u]);return l.useCallback(e=>{i.current=!0,m(),h(e)},[i,m,h])};function x(e){let{columnCounts:t,gridNavigatorId:n,itemGrid:i,itemList:s,onGridNavigatorItemSelect:m,onGridNavigatorPositionChange:h}=e,p=l.useRef(!1),f=l.useCallback((e,t)=>{let n=i[t];if(null!=n)return n[e]},[i]),g=l.useCallback(e=>{let{focusedX:t,focusedY:n}=e;p.current=!0;let l=f(t,n);if(null==l)return;let{visibleRowIndex:i,columnIndex:r}=l;h(r,i),null!=s.current&&s.current.scrollRowIntoView(n)},[f,s,h]),{dispatch:E,getItemProps:A,getRowProps:C,getContainerProps:x}=function(e){let{navId:t,columnCounts:n,focusedX:i=0,focusedY:s=0,onSelect:m,prepareFocus:h,getNewFocusPosition:p,maintainFocusPosition:f=!0,enabled:g=!0,onDispatch:E,autoFocusElement:A=!0,useVirtualFocus:C=!1}=e,x=l.useCallback((e,t)=>{let n=(0,a.A)(e,t);return null!=E&&E(e,n,t),n},[E]),[I,_]=l.useReducer(x,{focusedX:i,focusedY:s,columnCounts:n}),{columnCounts:S,focusedX:y,focusedY:v}=I,[T]=l.useState(()=>(0,o.nF)(_,16));return l.useEffect(()=>{_({type:a.n.UPDATE_COLUMN_COUNTS,columnCounts:n})},[n]),function(e){let{navId:t,columnCounts:n,focusedX:i,focusedY:s,onSelect:m,prepareFocus:h,getNewFocusPosition:p,dispatch:f,maintainFocusPosition:g,enabled:E,autoFocusElement:A,useVirtualFocus:C}=e,x=l.useRef(E),I=d(c(t,i,s)),[_,S]=l.useState(!1),[y,v]=l.useState(!1),[T,N]=l.useState(!1),[j]=l.useState(()=>new o.Lp(e=>{let[t,n]=e.split(",").map(Number);return()=>{S(!0),f({type:a.n.SET_FOCUSED_POSITION,x:t,y:n})}}));l.useEffect(()=>()=>j.clean(),[j]);let b=l.useCallback(e=>{if(!x.current||!A)return!1;e.focus()},[A]),R=l.useCallback((e,n)=>{let l=c(t,e,n);(null!=h?h(e,n,l):Promise.resolve()).then(()=>{let e=d(l);null!=e?(b(e),v(!1)):requestAnimationFrame(()=>v(!0))})},[t,h,b]),P=l.useCallback(function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],[n,l]=null!=p?p(i,s):[i,s];if((n!==i||l!==s)&&(f({type:a.n.SET_FOCUSED_POSITION,x:n,y:l}),!e))return void N(!0);let r=d(c(t,n,l));null!=r&&(N(!0),b(r))},[f,i,s,p,t,b]),[L,M]=l.useState(!1);l.useEffect(()=>{if(!L||!_)return;M(!1);let e=d(c(t,i,s));if(null!=e)return void b(e);S(!1);let n=d(c(t));null!=n&&b(n)},[t,L,_,b,i,s]);let O=l.useCallback(e=>{x.current&&null==e&&M(!0)},[]);l.useEffect(()=>{_&&y&&null!=I&&(b(I),v(!1))},[y,I]),l.useEffect(()=>{_&&(T||R(i,s),N(!1))},[i,s]);let w=l.useCallback(e=>{if(!x.current)return;if(!C&&u.includes(e.key)&&!(e.shiftKey||e.altKey||e.metaKey||e.ctrlKey)&&e.currentTarget===e.target){e.preventDefault(),e.stopPropagation(),P();return}let t=function(e){switch(e.key){case r.D$.ENTER:return r.X2.SELECT_FOCUSED_ITEM;case r.D$.UP:return r.X2.NAVIGATE_UP;case r.D$.DOWN:return r.X2.NAVIGATE_DOWN;case r.D$.RIGHT:return r.X2.NAVIGATE_RIGHT;case r.D$.LEFT:return r.X2.NAVIGATE_LEFT;case r.D$.HOME:if(e.ctrlKey)return r.X2.NAVIGATE_START;return r.X2.NAVIGATE_INLINE_START;case r.D$.END:if(e.ctrlKey)return r.X2.NAVIGATE_END;return r.X2.NAVIGATE_INLINE_END}}(e);switch(t){case r.X2.NAVIGATE_UP:case r.X2.NAVIGATE_DOWN:case r.X2.NAVIGATE_RIGHT:case r.X2.NAVIGATE_LEFT:case r.X2.NAVIGATE_INLINE_START:case r.X2.NAVIGATE_INLINE_END:case r.X2.NAVIGATE_START:case r.X2.NAVIGATE_END:0!==n.length&&(0!==i||0!==s||t!==r.X2.NAVIGATE_LEFT)&&(e.preventDefault(),e.stopPropagation()),f({type:t});return;case r.X2.SELECT_FOCUSED_ITEM:if(A&&I?.ownerDocument.activeElement!==I||e.repeat)return;e.preventDefault(),e.stopPropagation(),f({type:t}),null!=m?m(i,s,e):null!=I&&I.click()}},[P,f,A,I,m,i,s]),k=l.useCallback(e=>e.currentTarget!==e.target?(_||(S(!0),N(!0)),!1):_?(P(!1),!1):void(g&&null!=I?R(i,s):P(!0)),[_,g,I,P,R,i,s]),D=l.useCallback(e=>{if(e.target!==e.currentTarget){if(e.currentTarget.contains(e.relatedTarget))return!1;S(!1)}},[]),U=l.useMemo(()=>Math.max(...n),[n]),G=l.useCallback(()=>({role:"grid","aria-rowcount":n.length,"aria-colcount":U,tabIndex:_&&g?-1:0,"data-ref-id":t,onKeyDown:w,onFocus:k,onBlur:D}),[n.length,U,_,g,t,w,k,D]),F=l.useCallback((e,n)=>{let l={role:"gridcell","aria-rowindex":n+1,"aria-colindex":e+1,id:(0,o.Aq)(t,e,n),tabIndex:g&&e===i&&n===s?0:-1,onFocus:j.get(`${e},${n}`)};return e===i&&n===s&&(l.ref=O),l},[t,g,i,s,j,O]),V=l.useCallback(e=>({role:"row","aria-rowindex":e+1}),[]);return l.useMemo(()=>({dispatch:f,getContainerProps:G,getItemProps:F,getRowProps:V}),[f,G,F,V])}({navId:t,columnCounts:S,focusedX:y,focusedY:v,dispatch:T,onSelect:m,prepareFocus:h,getNewFocusPosition:p,maintainFocusPosition:f,enabled:g,autoFocusElement:A,useVirtualFocus:C})}({navId:n,columnCounts:t,onDispatch:l.useCallback((e,t,n)=>{switch(n.type){case r.X2.NAVIGATE_UP:case r.X2.NAVIGATE_DOWN:case r.X2.NAVIGATE_RIGHT:case r.X2.NAVIGATE_LEFT:case r.X2.NAVIGATE_INLINE_START:case r.X2.NAVIGATE_INLINE_END:case r.X2.NAVIGATE_START:case r.X2.NAVIGATE_END:case r.X2.NAVIGATE_CROSSLINE_START:case r.X2.NAVIGATE_CROSSLINE_END:g(t)}},[g]),onSelect:l.useCallback((e,t,n)=>{let l=f(e,t);null!=l&&m(l,n)},[f,m]),autoFocusElement:!1,useVirtualFocus:!0}),{gridContainerProps:I,handleGridContainerKeyDown:_}=l.useMemo(()=>{let e=x();return{gridContainerProps:e,handleGridContainerKeyDown:e.onKeyDown}},[x]);return l.useEffect(()=>{function e(){p.current=!1}return window.addEventListener("mousemove",e),()=>window.removeEventListener("mousemove",e)},[]),{gridDispatch:E,getItemProps:A,getRowProps:C,gridContainerProps:I,handleGridContainerKeyDown:_,isUsingKeyboardNavigation:p}}function I(e){let{categories:t,collapsedCategories:n,gridWidth:i=0,listPaddingRight:s=0,itemNodeWidth:r,itemNodeMargin:a=0}=e;return l.useMemo(()=>{let e=Math.max(1,Math.floor((i-s+a)/(r+a))),l=Math.floor(Math.max(a,(i-s-r*e)/(e-1))),o=[],u=[],c=[],d=0,m=0,h=0;if(0!==i)for(let l of t)l.items.length>0&&function(t,n){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Math.ceil(t.length/e);u[m]=l?0:i;for(let s=0;s<i;s++){let i=s*e,r=i+e,a=t.slice(i,r).map((e,t)=>({item:e,gridSectionIndex:m,rowIndex:d,columnIndex:t,visibleRowIndex:h,category:n}));l||(h++,c.push(a),o.push(a.length)),d++}m++}(l.items,l.categoryInfo.type,n?.has(`${l.key}`)??!1);return{expressionsGrid:c,rowCount:d,rowCountBySection:u,columnCounts:o,gutterWidth:l}},[t,n,i,a,r,s])}function _(e){let{columnCounts:t,expressionsGrid:n,expressionsListRef:i,store:s,gridNavigatorId:r,onSelectItem:o}=e,{gridDispatch:u,getItemProps:c,getRowProps:d,gridContainerProps:m,handleGridContainerKeyDown:h,isUsingKeyboardNavigation:f}=x({columnCounts:t,gridNavigatorId:r,itemGrid:n,itemList:i,onGridNavigatorItemSelect:o,onGridNavigatorPositionChange:s.setInspectedExpressionPosition});return l.useEffect(()=>s.subscribe(e=>e.inspectedExpressionPosition,e=>{if(null==e)return;let{columnIndex:t,rowIndex:n,source:l}=e;l!==p.t.GRID_NAVIGATOR_EVENT&&u({type:a.n.SET_FOCUSED_POSITION,x:t,y:n})}),[u,s]),{getItemProps:c,getRowProps:d,gridContainerProps:m,handleGridContainerKeyDown:h,isUsingKeyboardNavigation:f}}}