import { api } from './index.js' ; type Frag = { _startMark : Text ; } ; /** Insert a node into an existing node. */ const insert = ( el , value , endMark ? , current ? , startNode ? ) => { el = ( endMark && endMark . parentNode ) || el ; startNode = ( startNode || current instanceof Node && current ) as ChildNode | null ; if ( value === current ) { } else if ( ( ! current || typeof current === 'string' ) && ( typeof value === 'string' || ( typeof value === 'number' && ( value += '' ) ) ) ) { if ( ( current as unknown ) == null || ! el . firstChild ) { if ( endMark ) { api . add ( el , value , endMark ) ; } else { el . textContent = value as string ; } } else { if ( endMark ) { ( endMark . previousSibling || el . lastChild ) . data = value ; } else { el . firstChild . data = value ; } } current = value ; } else if ( api . patch ( value , ( v ) => current = api . insert ( el , v , endMark , current , startNode ) , el ) ) { } else { if ( endMark ) { if ( current ) { if ( ! startNode ) { startNode = ( ( current as { _startMark ? : Text ; } ) . _startMark && ( current as Frag ) . _startMark . nextSibling ) || endMark . previousSibling ; } api . rm ( el , startNode , endMark ) ; } } else { el . textContent = '' ; } current = value && value !== true ? api . add ( el , value as string | number , endMark ) : undefined ; } return current ; } ; export { insert } ;