// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import '//resources/cr_elements/cr_icon_button/cr_icon_button.js';
import { assertNotReachedCase } from '//resources/js/assert.js';
import { CrLitElement } from '//resources/lit/v3_0/lit.rollup.js';
import { ContentSettingImageType } from '/shared/toolbar_ui_api_data_model.mojom-webui.js';
import { BrowserProxyImpl } from './browser_proxy.js';
import { getCss } from './content_setting_icon.css.js';
import { getHtml } from './content_setting_icon.html.js';
export class ContentSettingIconElement extends CrLitElement {
    static get is() {
        return 'content-setting-icon';
    }
    static get styles() {
        return getCss();
    }
    render() {
        return getHtml.bind(this)();
    }
    static get properties() {
        return {
            state: { type: Object },
            animating: {
                type: Boolean,
                reflect: true,
            },
        };
    }
    #state_accessor_storage = {
        type: ContentSettingImageType.kCookies,
        isBlocked: false,
        tooltip: '',
        accessibilityString: '',
        isBubbleVisible: false,
        shouldRunAnimation: false,
        explanatoryString: '',
    };
    get state() { return this.#state_accessor_storage; }
    set state(value) { this.#state_accessor_storage = value; }
    #animating_accessor_storage = false;
    get animating() { return this.#animating_accessor_storage; }
    set animating(value) { this.#animating_accessor_storage = value; }
    browserProxy_ = BrowserProxyImpl.getInstance();
    willUpdate(changedProperties) {
        super.willUpdate(changedProperties);
        if (changedProperties.has('state')) {
            this.animating = this.state.shouldRunAnimation;
        }
    }
    onLabelAnimationend_() {
        this.animating = false;
    }
    getIconClass_() {
        const iconType = this.state.type;
        const blocked = this.state.isBlocked;
        switch (iconType) {
            case ContentSettingImageType.kCookies:
                return blocked ? 'icon-database-off' : 'icon-database';
            case ContentSettingImageType.kImages:
                return blocked ? 'icon-photo-off' : 'icon-photo';
            case ContentSettingImageType.kJavaScript:
                return blocked ? 'icon-code-off' : 'icon-code';
            case ContentSettingImageType.kMixedScript:
                return blocked ? 'icon-not-secure-warning-off' :
                    'icon-not-secure-warning';
            case ContentSettingImageType.kSound:
                return blocked ? 'icon-volume-off' : 'icon-volume-up';
            case ContentSettingImageType.kAds:
                return blocked ? 'icon-ads-off' : 'icon-ads';
            case ContentSettingImageType.kGeolocation:
                return blocked ? 'icon-location-off' : 'icon-location';
            case ContentSettingImageType.kProtocolHandlers:
                return blocked ? 'icon-protocol-handler-off' : 'icon-protocol-handler';
            case ContentSettingImageType.kMidiSysex:
                return blocked ? 'icon-midi-off' : 'icon-midi';
            case ContentSettingImageType.kAutomaticDownloads:
                return blocked ? 'icon-file-download-off' : 'icon-file-download';
            case ContentSettingImageType.kClipboardReadWrite:
                return blocked ? 'icon-content-paste-off' : 'icon-content-paste';
            case ContentSettingImageType.kMediaStream:
                return blocked ? 'icon-videocam-off' : 'icon-videocam';
            case ContentSettingImageType.kNotifications:
                return blocked ? 'icon-notifications-off' : 'icon-notifications';
            case ContentSettingImageType.kSensors:
                return blocked ? 'icon-sensors-off' : 'icon-sensors';
            case ContentSettingImageType.kStorageAccess:
                return blocked ? 'icon-storage-access-off' : 'icon-storage-access';
            case ContentSettingImageType.kPopups:
                return blocked ? 'icon-iframe-off' : 'icon-iframe';
            case ContentSettingImageType.kFramebust:
                return blocked ? 'icon-framebust-off' : 'icon-framebust';
            // 
            // 
            default:
                assertNotReachedCase(iconType);
        }
    }
    getAriaLabel_() {
        return this.state.accessibilityString || this.state.tooltip;
    }
    showContentSettingsBubble_() {
        this.browserProxy_.toolbarUIHandler.showContentSettingsBubble(this.state.type);
    }
    onClick_() {
        this.showContentSettingsBubble_();
    }
    onAuxclick_() {
        this.showContentSettingsBubble_();
    }
    onContextmenu_() {
        this.showContentSettingsBubble_();
    }
    onPointerenter_() {
        this.fire('chip-pointerenter');
    }
    onPointerleave_() {
        this.fire('chip-pointerleave');
    }
    onPointercancel_() {
        this.fire('chip-pointercancel');
    }
}
customElements.define(ContentSettingIconElement.is, ContentSettingIconElement);
