import{StylePropertyTreeElement}from"./StylePropertyTreeElement.js";export class StylePropertyHighlighter{constructor(e){this._styleSidebarPane=e}highlightProperty(e){for(const n of this._styleSidebarPane.allSections())for(let e=n.propertiesTreeOutline.firstChild();e;e=e.nextSibling)e.onpopulate();const{treeElement:t,section:r}=this._findTreeElementAndSection((t=>t.property===e));t&&(t.parent&&t.parent.expand(),this._scrollAndHighlightTreeElement(t),r&&r.element.focus())}findAndHighlightPropertyName(e){const{treeElement:t,section:r}=this._findTreeElementAndSection((t=>t.property.name===e));t&&(this._scrollAndHighlightTreeElement(t),r&&r.element.focus())}_findTreeElementAndSection(e){let t=null,r=null;for(const n of this._styleSidebarPane.allSections()){let l=n.propertiesTreeOutline.firstChild();for(;l&&!t&&l instanceof StylePropertyTreeElement;){if(e(l)){t=l;break}l=l.traverseNextTreeElement(!1,null,!0)}if(t){r=n;break}}return{treeElement:t,section:r}}_scrollAndHighlightTreeElement(e){e.listItemElement.scrollIntoViewIfNeeded(),e.listItemElement.animate([{offset:0,backgroundColor:"rgba(255, 255, 0, 0.2)"},{offset:.1,backgroundColor:"rgba(255, 255, 0, 0.7)"},{offset:1,backgroundColor:"transparent"}],{duration:2e3,easing:"cubic-bezier(0, 0, 0.2, 1)"})}}