import { ICallout , ICalloutActionOptions , ICalloutActionMenuEntry , ICalloutManager , ICalloutOptions } from "../../../@types/helper" ; /**
 * Callout Manager
 */ export const CalloutManager = ( ( ) => { return { /** Closes all callouts on the page. */ closeAll : ( ) => { return window [ "CalloutManager" ] . closeAll ( ) ; } , /** Returns true if the associated callout is open. */ containsOneCalloutOpen : ( el ) => { return window [ "CalloutManager" ] . containsOneCalloutOpen ( el ) ; } , /** Returns an callout action entry. */ createAction : ( options ) => { let caOptions = new window [ "CalloutActionOptions" ] ( ) ; for ( let key in options ) { caOptions [ key ] = options [ key ] ; } return new window [ "CalloutAction" ] ( caOptions ) ; } , /** Returns an callout action menu entries. */ createMenuEntries : ( entries ) => { let menuEntries = [ ] ; for ( let i = 0 ; i < entries . length ; i ++ ) { let entry = entries [ i ] ; menuEntries . push ( new window [ "CalloutActionMenuEntry" ] ( entry . text , entry . onClickCallback , entry . iconUrl ) ) ; } return menuEntries ; } , /** Creates a new callout. */ createNew : ( options ) => { return window [ "CalloutManager" ] . createNew ( options ) ; } , /** Checks if the callout id exists, before creating it. */ createNewIfNecessary : ( options ) => { return window [ "CalloutManager" ] . createNewIfNecessary ( options ) ; } , /** Performs an action on each callout on the page. */ forEach : ( callback ) => { return window [ "CalloutManager" ] . forEach ( callback ) ; } , /** Finds the closest launch point and returns the callout associated with it. */ getFromCalloutDescendant : ( descendant ) => { return window [ "CalloutManager" ] . getFromCalloutDescendant ( descendant ) ; } , /** Returns the callout from the specified launch point. */ getFromLaunchPoint : ( launchPoint ) => { return window [ "CalloutManager" ] . getFromLaunchPoint ( launchPoint ) ; } , /** Returns the callout for the specified launch point, null if it doesn't exist. */ getFromLaunchPointIfExists : ( launchPoint ) => { return window [ "CalloutManager" ] . getFromLaunchPointIfExists ( launchPoint ) ; } , /** Returns true if at least one callout is defined on the page is opened or opening. */ isAtLeastOneCalloutOn : ( ) => { return window [ "CalloutManager" ] . isAtLeastOneCalloutOn ( ) ; } , /** Returns true if at least one callout is opened on the page. */ isAtLeastOneCalloutOpen : ( ) => { return window [ "CalloutManager" ] . isAtLeastOneCalloutOpen ( ) ; } , init : ( ) : PromiseLike < void > => { return new Promise ( ( resolve , reject ) => { if ( window [ "CalloutManager" ] ) { resolve ( ) ; } else { window [ "SP" ] . SOD . executeFunc ( "callout.js" , "Callout" , ( ) => { resolve ( ) ; } ) ; } } ) ; } , /** Removes the callout and destroys it. */ remove : ( callout ) => { return window [ "CalloutManager" ] . remove ( callout ) ; } } ; } ) ( ) ;