import { Observable , combineLatest , delay , distinctUntilChanged , filter , fromEvent , map , merge , startWith , withLatestFrom } from "rxjs" ; import { watchElementFocus } from "~/browser" ; import { Component } from "../../_" ; /**
 * Icon search query
 */ export interface IconSearchQuery { value : string ; focus : boolean ; } param el returns export function mountIconSearchQuery ( el ) { const focus$ = watchElementFocus ( el ) ; const value$ = merge ( fromEvent ( el , "keyup" ) , fromEvent ( el , "focus" ) . pipe ( delay ( 1 ) ) ) . pipe ( map ( ( ) => el . value ) , startWith ( el . value ) , distinctUntilChanged ( ) ) ; focus$ . pipe ( filter ( active => ! active ) , withLatestFrom ( value$ ) ) . subscribe ( ( [ , value ] ) => { const path = document . location . pathname ; if ( value . length ) ga ( "send" , "pageview" , `${ path }?q=[icon]+${ value }` ) ; } ) ; return combineLatest ( [ value$ , focus$ ] ) . pipe ( map ( ( [ value , focus ] ) => ( { ref : el , value , focus } ) ) ) ; }