import { Action } from "../core/Action" ; /**
 * JSON representation of input bindings.
 */ export interface BindingsJSON < T > { defaultActions : [ [ T , Action ] ] ; actions : [ [ T , Action ] ] ; } /**
 * Input bindings.
 */ export class Bindings < T > { /**
     * The default bindings.
     */ defaultActions : Map < T , Action > ; /**
     * A collection that maps keys to actions.
     */ actions : Map < T , Action > ; /**
     * Constructs new input bindings.
     */ constructor ( ) { this . defaultActions = new Map < T , Action > ( ) ; this . actions = new Map < T , Action > ( ) ; } return reset ( ) { this . actions = new Map ( this . defaultActions ) ; return this ; } param actions return setDefault ( actions ) { this . defaultActions = actions ; return this . reset ( ) ; } return clearDefault ( ) { this . defaultActions . clear ( ) ; return this ; } return clear ( ) { this . actions . clear ( ) ; return this ; } param bindings return copy ( bindings ) { this . defaultActions = new Map ( bindings . defaultActions ) ; this . actions = new Map ( bindings . actions ) ; return this ; } return clone ( ) { const clone = new Bindings < T > ( ) ; return clone . copy ( this ) ; } param json return fromJSON ( json ) { if ( json !== undefined ) { this . defaultActions = new Map < T , Action > ( json . defaultActions ) ; this . actions = new Map < T , Action > ( json . actions ) ; } return this ; } param key return has ( key ) { return this . actions . has ( key ) ; } param key return get ( key ) { return this . actions . get ( key ) ; } param key param action return set ( key , action ) { this . actions . set ( key , action ) ; return this ; } param key return delete ( key ) { return this . actions . delete ( key ) ; } toJSON ( ) { return { defaultActions : [ ... this . defaultActions ] , actions : [ ... this . actions ] } ; } }