// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import './app_content_dialog.js';
import '//resources/cr_elements/cr_link_row/cr_link_row.js';
import { CrLitElement } from 'chrome://resources/lit/v3_0/lit.rollup.js';
import { getCss } from './app_content_item.css.js';
import { getHtml } from './app_content_item.html.js';
import { createDummyApp } from './web_app_settings_utils.js';
export class AppContentItemElement extends CrLitElement {
    static get is() {
        return 'app-management-app-content-item';
    }
    static get styles() {
        return getCss();
    }
    render() {
        return getHtml.bind(this)();
    }
    static get properties() {
        return {
            app: { type: Object },
            showAppContentDialog: { type: Boolean },
            hidden: {
                type: Boolean,
                reflect: true,
            },
        };
    }
    #app_accessor_storage = createDummyApp();
    get app() { return this.#app_accessor_storage; }
    set app(value) { this.#app_accessor_storage = value; }
    appContentLabel = '';
    appContentSublabel = '';
    #showAppContentDialog_accessor_storage = false;
    get showAppContentDialog() { return this.#showAppContentDialog_accessor_storage; }
    set showAppContentDialog(value) { this.#showAppContentDialog_accessor_storage = value; }
    #hidden_accessor_storage = false;
    get hidden() { return this.#hidden_accessor_storage; }
    set hidden(value) { this.#hidden_accessor_storage = value; }
    willUpdate(changedProperties) {
        super.willUpdate(changedProperties);
        if (changedProperties.has('app')) {
            this.hidden = this.isAppContentHidden_();
        }
    }
    firstUpdated() {
        // Disable hover styles from cr-actionable-row-style because they do not
        // match the style of App Settings.
        this.shadowRoot.querySelector('cr-link-row').toggleAttribute('effectively-disabled_', true);
    }
    onAppContentClick_() {
        this.showAppContentDialog = true;
    }
    onAppContentDialogClose_() {
        this.showAppContentDialog = false;
    }
    // App Content section is hidden when there's no scope_extensions entries.
    isAppContentHidden_() {
        return !this.app.scopeExtensions || !this.app.scopeExtensions.length;
    }
}
customElements.define(AppContentItemElement.is, AppContentItemElement);
