import {useEffect, useState, type RefObject} from "react";
export interface Element_Size {width:number;height:number;}
export function use_element_size(ref: RefObject<HTMLElement>): Element_Size {const [size,set_size]=useState<Element_Size>({width:0,height:0});useEffect(()=>{const element=ref.current;if(!element)return;const observer=new ResizeObserver(entries=>{const rect=entries[0]?.contentRect;if(rect)set_size({width:rect.width,height:rect.height});});observer.observe(element);return()=>observer.disconnect();},[ref]);return size;}
