{"version":3,"file":"ironsource-fusion-ui-components-mobile-previewer-common-base.mjs","sources":["../../../projects/fusion-ui/components/mobile-previewer/common/base/mobile-orientation.enum.ts","../../../projects/fusion-ui/components/mobile-previewer/common/base/mobile-previewer-component-configuration.ts","../../../projects/fusion-ui/components/mobile-previewer/common/base/mobile-previewer.base.component.ts","../../../projects/fusion-ui/components/mobile-previewer/common/base/ironsource-fusion-ui-components-mobile-previewer-common-base.ts"],"sourcesContent":["export enum MobileOrientation {\n    ALL,\n    PORTRAIT,\n    LANDSCAPE\n}\n","import {MobileOrientation} from './mobile-orientation.enum';\nimport {Component, Type} from '@angular/core';\n\nexport interface MobilePreviewerComponentConfiguration {\n    orientation?: MobileOrientation;\n    staticComponentSize?: {width?: string; height?: string};\n    element?: Node;\n    component?: {\n        type: Type<Component>;\n        data?: {[key: string]: any};\n    };\n}\n\nexport const WIDTH_STATIC = '568';\nexport const HEIGHT_STATIC = '320';\nexport const BORDER_WIDTH = 2.6;\nexport const DEVICE_ORIENTATION = ['tablet-portrait', 'tablet-landscape', 'phone-portrait', 'phone-landscape'];\n","import {Directive, ElementRef, Input, OnInit} from '@angular/core';\nimport {MobileOrientation} from './mobile-orientation.enum';\nimport {\n    BORDER_WIDTH,\n    DEVICE_ORIENTATION,\n    HEIGHT_STATIC,\n    MobilePreviewerComponentConfiguration,\n    WIDTH_STATIC\n} from './mobile-previewer-component-configuration';\nimport {CapitalizePipe} from '@ironsource/fusion-ui/pipes/string';\nimport {isNullOrUndefined} from '@ironsource/fusion-ui/utils';\n\n@Directive()\nexport abstract class MobilePreviewerBaseComponent implements OnInit {\n    _configurations: MobilePreviewerComponentConfiguration = {component: {type: null}};\n    @Input()\n    set configurations(configurations: MobilePreviewerComponentConfiguration) {\n        this._configurations = configurations;\n        this.isStaticSize =\n            !isNullOrUndefined(configurations?.staticComponentSize?.height) ||\n            !isNullOrUndefined(configurations?.staticComponentSize?.width);\n        if (this.isStaticSize) {\n            this._configurations.staticComponentSize.width = configurations.staticComponentSize.width || WIDTH_STATIC;\n            this._configurations.staticComponentSize.height = configurations.staticComponentSize.height || HEIGHT_STATIC;\n        }\n\n        switch (this._configurations.orientation) {\n            case MobileOrientation.PORTRAIT:\n                this.devices = DEVICE_ORIENTATION.filter(device => device.includes('portrait'));\n                break;\n            case MobileOrientation.LANDSCAPE:\n                this.devices = DEVICE_ORIENTATION.filter(device => device.includes('landscape'));\n                break;\n            case MobileOrientation.ALL:\n            default:\n                this.devices = DEVICE_ORIENTATION;\n                break;\n        }\n    }\n\n    get configurations(): MobilePreviewerComponentConfiguration {\n        return this._configurations;\n    }\n\n    _selectedDevice = '';\n    isStaticSize = false;\n    refresh = true;\n    devices: string[];\n\n    public get selectedDevice() {\n        return this._capitalizePipe.transform(this._selectedDevice.replace('-', ' '));\n    }\n\n    public get staticHeight(): number {\n        return Number(this._configurations?.staticComponentSize?.height);\n    }\n\n    public get height() {\n        let height: number;\n        switch (this._selectedDevice) {\n            case 'phone-portrait':\n                height = 568;\n                break;\n            case 'phone-landscape':\n                height = 320;\n                break;\n            case 'tablet-portrait':\n                height = 614;\n                break;\n            case 'tablet-landscape':\n                height = 461;\n                break;\n        }\n\n        return height;\n    }\n\n    public get width() {\n        let width: number;\n        switch (this._selectedDevice) {\n            case 'phone-portrait':\n                width = 320;\n                break;\n            case 'phone-landscape':\n                width = 568;\n                break;\n            case 'tablet-portrait':\n                width = 461;\n                break;\n            case 'tablet-landscape':\n                width = 614;\n                break;\n        }\n\n        return width;\n    }\n\n    public get calculatedContentSize() {\n        const ratio = this.width / this.height;\n        return {\n            width: Math.floor((this.staticHeight - this.borderWidth) * ratio) + 1,\n            height: Math.floor(this.staticHeight - this.borderWidth)\n        };\n    }\n\n    private borderWidth = BORDER_WIDTH;\n\n    constructor(private elementRef: ElementRef, private _capitalizePipe: CapitalizePipe) {}\n\n    ngOnInit() {\n        this._selectedDevice = this.configurations.orientation === MobileOrientation.PORTRAIT ? 'phone-portrait' : 'phone-landscape';\n    }\n\n    isDeviceSelected(device: string) {\n        return this._selectedDevice === device;\n    }\n\n    isDeviceLandscape(device: string) {\n        return device.includes('landscape');\n    }\n\n    selectDevice(device: string) {\n        this._selectedDevice = device;\n        this.refresh = !this.refresh;\n    }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;IAAY,kBAIX;AAJD,CAAA,UAAY,iBAAiB,EAAA;AACzB,IAAA,iBAAA,CAAA,iBAAA,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAAA,KAAG,CAAA;AACH,IAAA,iBAAA,CAAA,iBAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAQ,CAAA;AACR,IAAA,iBAAA,CAAA,iBAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,GAAA,WAAS,CAAA;AACb,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,GAI5B,EAAA,CAAA,CAAA;;ACSM,MAAM,YAAY,GAAG,MAAM;AAC3B,MAAM,aAAa,GAAG,MAAM;AAC5B,MAAM,YAAY,GAAG,IAAI;AACzB,MAAM,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB;;MCHvF,4BAA4B,CAAA;IAE9C,IACI,cAAc,CAAC,cAAqD,EAAA;AACpE,QAAA,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;AACtC,QAAA,IAAI,CAAC,YAAY;AACb,YAAA,CAAC,iBAAiB,CAAC,cAAc,EAAE,mBAAmB,EAAE,MAAM,CAAC;gBAC/D,CAAC,iBAAiB,CAAC,cAAc,EAAE,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACnE,IAAI,IAAI,CAAC,YAAY,EAAE;AACnB,YAAA,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,KAAK,GAAG,cAAc,CAAC,mBAAmB,CAAC,KAAK,IAAI,YAAY,CAAC;AAC1G,YAAA,IAAI,CAAC,eAAe,CAAC,mBAA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