const templates = [ ] ; export const setTemplates = ( id , tpl ) => { templates [ id ] = tpl ; } ; export const TemplateTypes = Object . freeze ( { HOST : 'host' , KNOB : 'knob' , SLOT : 'slot' , PREFIX : 'prefix' , SUFFIX : 'suffix' , WRAPPER : 'wrapper' } ) ; export const isTemplate = ( node ) : node is HTMLTemplateElement => node instanceof HTMLTemplateElement ; const matchTemplate = ( name , type ) => ( tpl ) => { const { element , target } = tpl . dataset ; return element === name && target === type ; } ; export const getTemplateNode = ( node ) : Element | null => isTemplate ( node ) ? node . content . firstElementChild : null ; export const getTemplate = ( id , name , type ) : HTMLTemplateElement | undefined => templates [ id ] . find ( matchTemplate ( name , type ) ) ; export const getTemplates = ( id , name , type ) : HTMLTemplateElement [ ] => templates [ id ] . filter ( matchTemplate ( name , type ) ) ; export const hasTemplate = ( id , name , type ) : boolean => templates [ id ] . some ( matchTemplate ( name , type ) ) ;