'use client' import type { FC, PropsWithChildren } from 'react' import { useDebounceFn } from 'ahooks' import * as React from 'react' import { useCallback } from 'react' import { STORAGE_KEYS } from '@/config/storage-keys' import { storage } from '@/utils/storage' import { useResizePanel } from '../nodes/_base/hooks/use-resize-panel' import { SIDEBAR_DEFAULT_WIDTH, SIDEBAR_MAX_WIDTH, SIDEBAR_MIN_WIDTH } from './constants' type SidebarProps = PropsWithChildren const Sidebar: FC = ({ children }) => { const { run: persistWidth } = useDebounceFn( (width: number) => storage.set(STORAGE_KEYS.SKILL.SIDEBAR_WIDTH, width), { wait: 200 }, ) const handleResize = useCallback((width: number) => { persistWidth(width) }, [persistWidth]) const { triggerRef, containerRef } = useResizePanel({ direction: 'horizontal', triggerDirection: 'right', minWidth: SIDEBAR_MIN_WIDTH, maxWidth: SIDEBAR_MAX_WIDTH, onResize: handleResize, }) return ( ) } export default React.memo(Sidebar)