import { Observable , fromEvent , mapTo , mergeMap , of , switchMap , takeWhile , tap , withLatestFrom } from "rxjs" ; import { getElements } from "~/browser" ; /**
 * Patch options
 */ interface PatchOptions { document$ : Observable < Document > ; tablet$ : Observable < boolean > ; } param options export function patchIndeterminate ( { document$ , tablet$ } ) { document$ . pipe ( switchMap ( ( ) => of ( ... getElements < HTMLInputElement > ( "[data-md-state=indeterminate]" ) ) ) , tap ( el => { el . indeterminate = true ; el . checked = false ; } ) , mergeMap ( el => fromEvent ( el , "change" ) . pipe ( takeWhile ( ( ) => el . hasAttribute ( "data-md-state" ) ) , mapTo ( el ) ) ) , withLatestFrom ( tablet$ ) ) . subscribe ( ( [ el , tablet ] ) => { el . removeAttribute ( "data-md-state" ) ; if ( tablet ) el . checked = false ; } ) ; }