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,EAAG,EAAE;KAC7E,CAAC;IACF,kBAAkB;IACX,+BAAc,GAAmE,cAAM,OAAA;QAC9F,EAAC,IAAI,EAAE,UAAU,GAAG;QACpB,EAAC,IAAI,EAAE,QAAQ,GAAG;QAClB,EAAC,IAAI,EAAE,gBAAgB,GAAG;QAC1B,EAAC,IAAI,EAAE,aAAa,GAAG;QACvB,EAAC,IAAI,EAAE,sBAAsB,GAAG;KAC/B,EAN6F,CAM7F,CAAC;IACK,+BAAc,GAA2C;QAChE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC7B,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAClC,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/B,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC9B,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/B,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;KAC9B,CAAC;IACF,uBAAC;AAAD,CAAC,AArID,IAqIC","sourcesContent":["import {\n Directive, Input, Output, EventEmitter, OnInit, OnDestroy, Renderer,\n ElementRef, TemplateRef, ViewContainerRef\n} from '@angular/core';\nimport { PopoverConfig } from './popover.config';\nimport { ComponentLoaderFactory, ComponentLoader } from '../component-loader';\nimport { PopoverContainerComponent } from './popover-container.component';\n\n/**\n * A lightweight, extensible directive for fancy popover creation.\n */\n\nexport class PopoverDirective implements OnInit, OnDestroy {\n /**\n * Content to be displayed as popover.\n */\n public popover: string | TemplateRef<any>;\n /**\n * Title of a popover.\n */\n public popoverTitle: string;\n /**\n * Placement of a popover. Accepts: \"top\", \"bottom\", \"left\", \"right\"\n */\n public placement: 'top' | 'bottom' | 'left' | 'right';\n /**\n * Specifies events that should trigger. Supports a space separated list of\n * event names.\n */\n public triggers: string;\n /**\n * A selector specifying the element the popover should be appended to.\n * Currently only supports \"body\".\n */\n public container: string;\n\n /**\n * Returns whether or not the popover is currently being shown\n */\n \n public get isOpen(): boolean { return this._popover.isShown; }\n\n public set isOpen(value: boolean) {\n if (value) {this.show();} else {this.hide();}\n }\n\n /**\n * Emits an event when the popover is shown\n */\n public onShown: EventEmitter<any>;\n /**\n * Emits an event when the popover is hidden\n */\n public onHidden: EventEmitter<any>;\n\n private _popover: ComponentLoader<PopoverContainerComponent>;\n\n public constructor(_elementRef: ElementRef,\n _renderer: Renderer,\n _viewContainerRef: ViewContainerRef,\n _config: PopoverConfig,\n cis: ComponentLoaderFactory) {\n this._popover = cis\n .createLoader<PopoverContainerComponent>(_elementRef, _viewContainerRef, _renderer)\n .provide({provide: PopoverConfig, useValue: _config});\n Object.assign(this, _config);\n this.onShown = this._popover.onShown;\n this.onHidden = this._popover.onHidden;\n }\n\n /**\n * Opens an element’s popover. This is considered a “manual” triggering of\n * the popover.\n */\n public show(): void {\n if (this._popover.isShown) {\n return;\n }\n\n this._popover\n .attach(PopoverContainerComponent)\n .to(this.container)\n .position({attachment: this.placement})\n .show({\n content: this.popover,\n placement: this.placement,\n title: this.popoverTitle\n });\n this.isOpen = true;\n }\n\n /**\n * Closes an element’s popover. This is considered a “manual” triggering of\n * the popover.\n */\n public hide(): void {\n if (this.isOpen) {\n this._popover.hide();\n this.isOpen = false;\n }\n }\n\n /**\n * Toggles an element’s popover. This is considered a “manual” triggering of\n * the popover.\n */\n public toggle(): void {\n if (this.isOpen) {\n return this.hide();\n }\n\n this.show();\n }\n\n public ngOnInit(): any {\n this._popover.listen({\n triggers: this.triggers,\n show: () => this.show()\n });\n }\n\n public ngOnDestroy(): any {\n this._popover.dispose();\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Directive, args: [{selector: '[popover]', exportAs: 'bs-popover'}, ] },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: ElementRef, },\n{type: Renderer, },\n{type: ViewContainerRef, },\n{type: PopoverConfig, },\n{type: ComponentLoaderFactory, },\n];\nstatic propDecorators: {[key: string]: DecoratorInvocation[]} = {\n'popover': [{ type: Input },],\n'popoverTitle': [{ type: Input },],\n'placement': [{ type: Input },],\n'triggers': [{ type: Input },],\n'container': [{ type: Input },],\n'isOpen': [{ type: Input },],\n'onShown': [{ type: Output },],\n'onHidden': [{ type: Output },],\n};\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file