/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
import{LitElement as d,html as p}from"lit";import{customElement as h}from"lit/decorators.js";import{lll as a}from"@typo3/core/lit-helper.js";var u=function(n,e,t,i){var c=arguments.length,l=c<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(n,e,t,i);else for(var o=n.length-1;o>=0;o--)(s=n[o])&&(l=(c<3?s(l):c>3?s(e,t,l):s(e,t))||l);return c>3&&l&&Object.defineProperty(e,t,l),l};let r=class extends d{constructor(){super(...arguments),this.settings={collapseAllBtn:"collapse-all-btn",expandAllBtn:"expand-all-btn",searchInput:"search-input",toggleHideUnchecked:"hide-unchecked-btn"},this.hideUncheckedState=!1}createRenderRoot(){return this}render(){return p`<div class="tree-toolbar btn-toolbar"><div class=input-group><span class="input-group-text input-group-icon filter"> <typo3-backend-icon identifier=actions-filter size=small></typo3-backend-icon> </span> <input type=search class="form-control ${this.settings.searchInput}" placeholder=${a("tcatree.findItem")} @input=${e=>this.filter(e)}></div><div class=btn-group><button type=button class="btn btn-default ${this.settings.expandAllBtn}" title=${a("tcatree.expandAll")} @click=${()=>this.expandAll()}><typo3-backend-icon identifier=apps-pagetree-category-expand-all size=small></typo3-backend-icon></button> <button type=button class="btn btn-default ${this.settings.collapseAllBtn}" title=${a("tcatree.collapseAll")} @click=${e=>this.collapseAll(e)}><typo3-backend-icon identifier=apps-pagetree-category-collapse-all size=small></typo3-backend-icon></button> <button type=button class="btn btn-default ${this.settings.toggleHideUnchecked}" title=${a("tcatree.toggleHideUnchecked")} @click=${()=>this.toggleHideUnchecked()}><typo3-backend-icon identifier=apps-pagetree-category-toggle-hide-checked size=small></typo3-backend-icon></button></div></div>`}collapseAll(e){e.preventDefault(),this.tree.nodes.forEach(t=>{t.__parents.length&&this.tree.hideChildren(t)})}expandAll(){this.tree.expandAll()}filter(e){const t=e.target;this.tree.filter(t.value.trim())}toggleHideUnchecked(){this.hideUncheckedState=!this.hideUncheckedState,this.hideUncheckedState?this.tree.nodes.forEach(e=>{e.checked?(this.tree.showParents(e),e.expanded=!0,e.__hidden=!1):(e.expanded=!1,e.__hidden=!0)}):this.tree.nodes.forEach(e=>e.__hidden=!1)}};r=u([h("typo3-backend-form-selecttree-toolbar")],r);export{r as SelectTreeToolbar};
