import Vue from 'vue' ; import type { CreateElement , VNode } from 'vue' ; import type { ExtendedVue } from 'vue/types/vue' ; import type { IconifyIcon , IconifyJSON } from '@iconify/types' ; import type { IconifyHorizontalIconAlignment , IconifyVerticalIconAlignment , IconifyIconSize , } from '@iconify/utils/lib/customisations' ; import { fullIcon } from '@iconify/utils/lib/icon' ; import { parseIconSet } from '@iconify/utils/lib/icon-set/parse' ; import type { IconifyIconCustomisations , IconifyIconProps , IconProps , } from './props' ; import { render } from './render' ; /**
 * Export stuff from props.ts
 */ export { IconifyIconCustomisations , IconifyIconProps , IconProps } ; /**
 * Export types that could be used in component
 */ export { IconifyIcon , IconifyJSON , IconifyHorizontalIconAlignment , IconifyVerticalIconAlignment , IconifyIconSize , } ; /**
 * Storage for icons referred by name
 */ const storage = Object . create ( null ) ; param name param data export function addIcon ( name , data ) { storage [ name ] = fullIcon ( data ) ; } param data param prefix export function addCollection ( data , prefix ? ) { const iconPrefix = typeof prefix === 'string' ? prefix : prefix !== false && typeof data . prefix === 'string' ? data . prefix + ':' : '' ; parseIconSet ( data , ( name , icon ) => { if ( icon ) { storage [ iconPrefix + name ] = icon ; } } , { validate : { fix : true , prefix : iconPrefix , } , } ) ; } /**
 * Component
 */ export const Icon = Vue . extend ( { inheritAttrs : false , render ( createElement ) { const props = this . $attrs ; const icon = typeof props . icon === 'string' ? storage [ props . icon ] : typeof props . icon === 'object' ? fullIcon ( props . icon ) : null ; if ( icon === null || typeof icon !== 'object' || typeof icon . body !== 'string' ) { if ( this . $slots . default ) { const result = this . $slots . default ; if ( result instanceof Array && result . length > 0 ) { return result . length === 1 ? result [ 0 ] : createElement ( 'span' , result ) ; } } return null as unknown as VNode ; } return render ( createElement , props , this . $data , icon ) ; } , } ) ;