import { PreviewService, DynamicManagedObjectResolver, hookWidget, hookPreview } from '@c8y/ngx-components';
import { hookWidgetConfig } from '@c8y/ngx-components/context-dashboard';
import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { gettext } from '@c8y/ngx-components/gettext';
import { map } from 'rxjs';
import { defaultWidgetIds } from '@c8y/ngx-components/widgets/definitions';
import { importConfigWithDevice, exportConfigWithDevice } from '@c8y/ngx-components/widgets/import-export-config';

class HtmlWidgetConfigFactory {
    constructor() {
        this.betaPreviewService = inject(PreviewService);
        this.baseWidgetConfigDefinition = [
            {
                widgetId: defaultWidgetIds.HTML,
                providers: () => import('@c8y/ngx-components/widgets/implementations/html-widget').then(m => [
                    m.HtmlWidgetConfigService
                ]),
                label: gettext('Asset selection'),
                loadComponent: () => import('@c8y/ngx-components/context-dashboard').then(m => m.WidgetAssetSelectorComponent),
                priority: 100,
                initialState: {
                    isRequired: false,
                    groupsSelectable: true
                }
            },
            {
                widgetId: defaultWidgetIds.HTML,
                label: gettext('Asset properties'),
                loadComponent: () => import('@c8y/ngx-components/widgets/implementations/html-widget').then(m => m.HtmlWidgetPropertiesSelectorComponent),
                priority: 50
            },
            {
                widgetId: defaultWidgetIds.HTML,
                providers: () => import('@c8y/ngx-components/widgets/implementations/html-widget').then(m => [
                    m.HtmlWidgetConfigService
                ]),
                label: gettext('Settings'),
                loadComponent: () => import('@c8y/ngx-components/widgets/implementations/html-widget').then(m => m.HtmlWidgetConfigComponent),
                priority: 0,
                expanded: true
            }
        ];
    }
    get() {
        return this.betaPreviewService.getState$('ui.html-widget.v2').pipe(map(state => {
            if (state) {
                return this.baseWidgetConfigDefinition;
            }
            return [];
        }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HtmlWidgetConfigFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HtmlWidgetConfigFactory, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HtmlWidgetConfigFactory, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

class HtmlWidgetFactory {
    constructor() {
        this.betaPreviewService = inject(PreviewService);
        this.baseWidgetDefinition = {
            id: defaultWidgetIds.HTML,
            label: gettext('HTML'),
            description: gettext(`Display custom HTML code.`),
            loadComponent: () => import('@c8y/ngx-components/widgets/implementations/html-widget').then(m => m.HtmlWidgetComponent),
            previewImage: 'c8y-style-assets/html-widget-pr.png',
            data: {
                schema: () => import('c8y-schema-loader?interfaceName=HtmlWidgetConfig!@c8y/ngx-components/widgets/implementations/html-widget'),
                export: exportConfigWithDevice,
                import: importConfigWithDevice,
                settings: {
                    noNewWidgets: false,
                    widgetDefaults: {
                        _width: 8,
                        _height: 4
                    }
                }
            },
            resolve: {
                device: DynamicManagedObjectResolver
            }
        };
    }
    get() {
        return this.betaPreviewService.getState$('ui.html-widget.v2').pipe(map(state => {
            if (state) {
                return [this.baseWidgetDefinition];
            }
            return [];
        }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HtmlWidgetFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HtmlWidgetFactory, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: HtmlWidgetFactory, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

const htmlWidgetProviders = [
    hookWidget(HtmlWidgetFactory),
    hookWidgetConfig(HtmlWidgetConfigFactory),
    hookPreview({
        key: 'ui.html-widget.v2',
        label: 'Improved HTML widget',
        description: () => import('@c8y/style/markdown-files/html-widget-preview.md').then(m => m.default),
        settings: {
            reload: true
        }
    })
];

/**
 * Generated bundle index. Do not edit.
 */

export { htmlWidgetProviders };
//# sourceMappingURL=c8y-ngx-components-widgets-definitions-html-widget.mjs.map
