import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { input, numberAttribute, signal, effect, Component } from '@angular/core';
import { NgmCopyComponent } from '@metad/ocap-angular/common';

class NgmPrismHighlightComponent {
    constructor() {
        this.code = input.required();
        this.language = input.required();
        this.maximum = input(0, {
            transform: numberAttribute
        });
        this.highlightedCode = signal('');
        this.#effRef = effect(async () => {
            const Prism = await import('prismjs');
            switch (this.language()) {
                case 'sql':
                    await import('prismjs/components/prism-sql');
                    break;
                case 'json':
                    await import('prismjs/components/prism-json');
                    break;
            }
            // await import('prismjs/plugins/toolbar/prism-toolbar')
            // await import('prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard')
            // await import('clipboard')
            this.highlightedCode.set(Prism.highlight(this.maximum() ? this.code().slice(0, this.maximum()) : this.code(), Prism.languages[this.language()], this.language()));
        }, { allowSignalWrites: true });
    }
    #effRef;
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgmPrismHighlightComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: NgmPrismHighlightComponent, isStandalone: true, selector: "ngm-prism-highlight", inputs: { code: { classPropertyName: "code", publicName: "code", isSignal: true, isRequired: true, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: true, transformFunction: null }, maximum: { classPropertyName: "maximum", publicName: "maximum", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ngm-prism-highlight" }, ngImport: i0, template: `<pre class="m-0 overflow-auto"><code [innerHTML]="highlightedCode()" class="m-0"></code></pre>
<ngm-copy class="absolute right-1 top-1 text-lg !text-white rounded-md w-6 h-6 flex justify-center items-center bg-white/30 backdrop-blur-sm" [content]="code()" />
`, isInline: true, styles: [":host{display:block;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: NgmCopyComponent, selector: "ngm-copy", inputs: ["content", "timer"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgmPrismHighlightComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [CommonModule, NgmCopyComponent], selector: 'ngm-prism-highlight', template: `<pre class="m-0 overflow-auto"><code [innerHTML]="highlightedCode()" class="m-0"></code></pre>
<ngm-copy class="absolute right-1 top-1 text-lg !text-white rounded-md w-6 h-6 flex justify-center items-center bg-white/30 backdrop-blur-sm" [content]="code()" />
`, host: {
                        class: 'ngm-prism-highlight'
                    }, styles: [":host{display:block;position:relative}\n"] }]
        }] });

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

export { NgmPrismHighlightComponent };
//# sourceMappingURL=metad-ocap-angular-prism.mjs.map
