/* * 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 h from"@typo3/backend/storage/client.js";import f from"@typo3/core/document-service.js";import m from"@typo3/core/event/debounce-event.js";import d from"@typo3/core/event/regular-event.js";import p from"mark.js";import S from"@typo3/backend/utility/dom-helper.js";import y from"~labels/backend.messages";class g{constructor(){this.searchValueSelector=".t3js-collapse-search-term",this.searchValue="",this.markInstances=[],f.ready().then(()=>{if(this.treeContainers=document.querySelectorAll(".t3js-collapse-states-search-tree"),this.treeContainers.length!==0){this.numberOfSearchMatchesContainer=document.querySelectorAll(".t3js-collapse-states-search-numberOfSearchMatches"),this.searchField=document.querySelector(this.searchValueSelector),this.searchForm=this.searchField.closest("form"),this.searchSessionKey=this.searchField.dataset.persistCollapseSearchKey,this.searchValue=h.get(this.searchSessionKey)??"",this.registerEvents();for(let e=0;e{this.searchField.value===""&&this.searchForm.requestSubmit()}).bindTo(this.searchField),new m("input",()=>{this.searchForm.requestSubmit()}).bindTo(this.searchField),new d("submit",e=>{e.preventDefault();for(let t=0;t{if(r===null)return;const o=r.parentElement.querySelector('[data-bs-toggle="collapse"]')?.dataset.bsTarget;o!==void 0&&n.add(o.substring(1));const l=S.parents(r,".collapse");for(const i of l)n.add(i.id)});const u=Array.from(t.querySelectorAll(".collapse"));for(const r of u){const o=r.classList.contains("show"),l=r.id;if(n.has(l)){if(!o){const i=document.querySelector('[data-bs-target="#'+l+'"]');i.classList.remove("collapsed"),i.setAttribute("aria-expanded","true"),r.classList.add("show")}}else if(o){const i=document.querySelector('[data-bs-target="#'+l+'"]');i.classList.add("collapsed"),i.setAttribute("aria-expanded","false"),r.classList.remove("show")}}a.mark(e,{element:"span",className:"text-highlight"})}findNodesByIdentifier(e,t){return Array.from(t.querySelectorAll(".treelist-label")).filter(s=>s.textContent.toLowerCase().includes(e))}findNodesByValue(e,t){return Array.from(t.querySelectorAll(".treelist-value")).filter(a=>a.textContent.toLowerCase().includes(e)).map(a=>a.previousElementSibling)}findNodesByComment(e,t){return Array.from(t.querySelectorAll(".treelist-comment")).filter(s=>s.textContent.toLowerCase().includes(e))}findNodesByConstantSubstitution(e,t){return Array.from(t.querySelectorAll(".treelist-constant-substitution")).filter(s=>s.textContent.toLowerCase().includes(e))}}var b=new g;export{b as default};