define("backgroundCommon/mixins/bgVideoMixin",["lodash","react","reactDOM","santaProps"],function(a,b,c,d){"use strict";return{propTypes:{compData:b.PropTypes.object.isRequired,structureComponentId:b.PropTypes.string.isRequired,videoBackgroundAspect:d.Types.SiteAspects.videoBackgroundAspect.isRequired},getInitialState:function(){this.videoBackgroundAspect=this.props.videoBackgroundAspect;this.showOnNextTick=false;this.errorMode=false;this.registerToVideoAspect(this.getVideoData());return this.resetVideoStates(this.getVideoData())},registerToVideoAspect:function(a){this.videoBackgroundAspect.registerVideo(this.props.id,this.getStructureComponentId(),a,this.qualityReady,this,a.autoplay)},getStructureComponentId:function(){return this.props.structureComponentId},resetVideoStates:function(a){return{stopped:true,paused:false,ready:false,active:true,loaded:false,playEnded:false,autoPlay:a.autoplay,videoQuality:this.videoBackgroundAspect.getQuality(this.props.id)}},componentDidMount:function(){var a=this.getVideoData();this.registerToVideoAspect(a);this.setPlaybackSpeed(a.playbackSpeed||1);this.registerEvents()},componentWillUnmount:function(){var a=this.getInstance();a.removeEventListener("timeupdate",this.onTimeUpdate);a.removeEventListener("ended",this.onPlayEnded);a.removeEventListener("error",this.onError);a.removeEventListener("stalled",this.onStalled);this.videoBackgroundAspect.unregisterVideo(this.props.id);this.removeVideoSecurely()},componentWillReceiveProps:function(a){var b=a.compData;var c=this.getVideoData();this.setPlaybackSpeed(b.playbackSpeed||1);var d=this.resetOnSourceChanged(b,c);if(d){return}this.resetPlayEnded(b,c);this.resetInitialPlay(b)},resetInitialPlay:function(a){if(a.autoplay!==this.state.autoPlay){this.registerToVideoAspect(a);this.setState({autoPlay:a.autoplay})}},resetPlayEnded:function(a,b){if(a.loop&&!b.loop){this.setState({playEnded:false})}},resetOnSourceChanged:function(a,b){if(a.videoId!==b.videoId){this.stop();this.registerToVideoAspect(a);this.setState(this.resetVideoStates(a));return true}return false},registerEvents:function(){this.getInstance().addEventListener("timeupdate",this.onTimeUpdate,true);this.getInstance().addEventListener("ended",this.onPlayEnded,true);this.getInstance().addEventListener("error",this.onError,true);this.getInstance().addEventListener("stalled",this.onStalled,true)},isLoadNeeded:function(a,b){var c=a.compData;var d=this.getVideoData();return this.errorMode||c.videoId!==d.videoId||!b.videoQuality||this.state.videoQuality.quality!==b.videoQuality.quality||!this.state.active&&b.active},componentDidUpdate:function(a,b){var c=this.getVideoData();if(this.isLoadNeeded(a,b)){this.errorMode=false;this.load()}if(this.getInstance().paused&&(!b.active&&this.state.active)||!this.state.stopped&&!this.state.paused){this.getInstance().play();this.setPlaybackSpeed(c.playbackSpeed||1);this.videoBackgroundAspect.notifyPlayingChanged(this.props.id)}else if(!b.stopped&&this.state.stopped){this.getInstance().pause();this.videoBackgroundAspect.notifyPlayingChanged(this.props.id);if(this.state.active&&this.state.loaded&&this.getInstance().currentTime>0){this.getInstance().currentTime=0}}else if(!b.paused&&this.state.paused){this.getInstance().pause();this.videoBackgroundAspect.notifyPlayingChanged(this.props.id)}if(!b.ready&&this.state.ready){this.showOnNextTick=true}else if(b.ready&&!this.state.ready){this.getInstance().style.visibility="hidden";this.showOnNextTick=false}},notifyPlayingChange:function(){this.videoBackgroundAspect.notifyPlayingChanged(this.props.id)},getInstance:function(){return c.findDOMNode(this.refs.video)},setPlaybackSpeed:function(a){this.getInstance().playbackRate=a},load:function(){var a=this.getInstance();a.load()},removeVideoSecurely:function(){var b=this.getInstance();b.pause();a.forEach(b.children,function(a){if(a.nodeName.toLowerCase()==="source"){a.setAttribute("src","")}});b.load()},kill:function(){if(this.state.active){this.removeVideoSecurely();this.setState({active:false,ready:false,stopped:true,loaded:false})}},play:function(b){var c={};if(!this.state.active){c={active:true,ready:false,stopped:false,pause:false}}else if(this.state.stopped){c={stopped:false,ready:false}}else if(this.state.paused){c={paused:false}}if(!this.state.videoQuality||b&&b.quality!==this.state.videoQuality.quality){c.videoQuality=b}if(!a.isEmpty(c)){this.setState(c)}},stop:function(b){if(!this.state.stopped){this.setState(a.assign({ready:false,stopped:true,paused:false},b?{playEnded:b}:{}))}},pause:function(b){if(!this.state.stopped&&!this.state.paused){this.setState(a.assign({paused:true},b?{playEnded:b}:{}))}},onPlayEnded:function(){this.pause(true)},onError:function(a){if(a.currentTarget.networkState===a.currentTarget.NETWORK_NO_SOURCE){this.errorMode=true}},onStalled:function(a){if(a.currentTarget.readyState===a.currentTarget.HAVE_NOTHING){this.errorMode=true}},onTimeUpdate:function(){if(!this.state.ready&&this.state.active&&!this.state.stopped){this.setState({ready:true,loaded:true});this.getInstance().currentTime=0}if(this.showOnNextTick&&this.getInstance().currentTime){this.showOnNextTick=false;if(this.getInstance().currentTime>0){this.getInstance().style.visibility="visible"}}},isPlaying:function(){return this.state.active&&!this.state.stopped&&!this.state.paused},getVideoData:function(){return this.props.compData},qualityReady:function(a,b){if(b===this.getVideoData().videoId&&(this.errorMode||!this.isPlaying())){this.registerReLayout();this.setState({videoQuality:a,ready:false,loaded:false})}}}});define("backgroundCommon/mixins/backgroundDetectionMixin",["lodash","react","utils","imageClientApi","color","santaProps"],function(a,b,c,d,e,f){"use strict";var g=c.containerBackgroundUtils;function h(a,b,e){var f=a&&a.uri;if(f){var g={id:f,width:a.width,height:a.height};var h={width:1,height:1};var j=d.getData(d.fittingTypes.SCALE_TO_FILL,g,h).uri;var k=this.props.getMediaFullStaticUrl(j);c.imageUtils.getImageMeanBrightness(k,{width:1,height:1},b,e)}else{var l=i.call(this);b(l.values.hsv[2],l.values.alpha)}}function i(){var a=this.safeGetBgData();return new e(c.colorParser.getColor(this.props.colorsMap,a.color,a.colorOpacity))}function j(a,b){var c=this.props.dynamicColorElementsAspect;c.updateInformation(this.props.id,{brightness:a,alpha:b})}function k(a,b){var c=a&&a.uri;var d=c!==this.lastBackgroundImageUrl;var e=b&&b.hexString();var f=this.lastBackgroundBgColor&&this.lastBackgroundBgColor.hexString();var g=!c&&e!==f;var i=b&&b.values.alpha!==this.lastAlpha;if(d||g||i){h.call(this,a,j.bind(this))}this.lastBackgroundImageUrl=c;this.lastBackgroundBgColor=b;this.lastAlpha=b.values.alpha}return{propTypes:{id:b.PropTypes.string,compDesign:b.PropTypes.object,compData:b.PropTypes.object,colorsMap:f.Types.Theme.colorsMap.isRequired,isMobileView:f.Types.isMobileView.isRequired,dynamicColorElementsAspect:f.Types.SiteAspects.dynamicColorElements.isRequired,getMediaFullStaticUrl:f.Types.ServiceTopology.getMediaFullStaticUrl.isRequired},componentDidMount:function(){if(!this.props.isMobileView){var a=i.call(this);var b=this.getMediaImageData();k.call(this,b,a)}},componentDidUpdate:function(){if(!this.props.isMobileView){var a=i.call(this);var b=a&&a.hexString();var c=this.lastBackgroundBgColor&&this.lastBackgroundBgColor.hexString();var d=this.getMediaImageData();var e=d&&d.uri;var f=b!==c;var g=e!==this.lastBackgroundImageUrl;var h=a&&a.values.alpha!==this.lastAlpha;if(f||g||h){k.call(this,d,a)}}},getMediaImageData:function(){var a=this.safeGetBgData();var b=a.mediaRef;if(b){switch(b.type){case"Image":return b;case"WixVideo":return b.posterImageRef}}return null},safeGetBgData:function(){return this.props.id==="SITE_BACKGROUND"?this.getBgData():g.getBgData(this.props.compDesign,this.props.compData)}}});define("backgroundCommon/components/bgImage",["lodash","react","core","utils"],function(a,b,c,d){"use strict";var e=c.compMixins;return{displayName:"bgImage",mixins:[e.skinBasedComp],propTypes:{compData:b.PropTypes.object.isRequired,"data-type":b.PropTypes.string.isRequired},statics:{useSantaTypes:true},getSkinProperties:function(){var b={width:"100%"};var c={position:"absolute",width:"100%"};if(a.isNumber(this.props.compData.opacity)){c.opacity=this.props.compData.opacity}var e={"":{style:b}};e[d.balataConsts.IMAGE]={style:c,"data-type":this.props["data-type"]};return e}}});define("backgroundCommon/components/bgVideo",["lodash","react","core","backgroundCommon/mixins/bgVideoMixin"],function(a,b,c,d){"use strict";function e(a){return{loop:a.loop?"loop":"",muted:a.mute?"muted":"",preload:a.preload||"auto"}}return{displayName:"bgVideo",mixins:[c.compMixins.skinBasedComp,d],propTypes:{compData:b.PropTypes.object.isRequired},statics:{useSantaTypes:true},getSkinProperties:function(){var a=e(this.props.compData);var b={width:"100%"};var c={visibility:"hidden",position:"absolute"};return{"":{"data-quality":this.state.videoQuality&&this.state.videoQuality.quality,style:b},video:{loop:a.loop,muted:a.muted,preload:a.preload,style:c}}}}});define("backgroundCommon/components/bgMedia",["lodash","react","core","santaProps","imageClientApi","image","backgroundCommon/components/bgImage","backgroundCommon/components/bgVideo","utils"],function(a,b,c,d,e,f,g,h,i){"use strict";var j=c.compMixins;var k=i.containerBackgroundUtils;var l=i.balataConsts;var m=e.fittingTypes;var n=[m.TILE];var o={comp:"wysiwyg.viewer.components.background.bgImage",skin:"skins.viewer.bgImage.bgImageSkin",style:"bgImage",ref:l.IMAGE,"data-type":l.BG_IMAGE};var p={comp:"core.components.Image",skin:"skins.core.ImageNewSkinZoomable",style:"bgImage",ref:l.IMAGE,"data-type":l.IMAGE};var q={comp:"wysiwyg.viewer.components.background.bgVideo",skin:"skins.viewer.bgVideo.bgVideoSkin",style:"bgVideo",ref:l.VIDEO};function r(b){return a.includes(n,b)?o:p}function s(a,b,c,d){var e={};if(c===o.comp){e={ref:o.ref,"data-type":o["data-type"]}}else if(c===p.comp){var f=b.mediaRef.type==="WixVideo"?b.mediaRef.posterImageRef:b.mediaRef;e={ref:p.ref,key:"img_"+d,containerWidth:0,containerHeight:0,imageData:f,displayMode:b.fittingType,alignType:b.alignType,"data-type":p["data-type"]}}else if(c===q.comp){e={structureComponentId:a,ref:q.ref}}return e}function t(a,b){var c=b.mediaRef||null;var d=[];if(c){var e=r(b.fittingType);var f={image:{id:a.id+e.ref,componentType:e.comp,skinPartData:{skin:e.skin,styleId:e.style},compData:b.mediaRef},poster:{id:a.id+e.ref,componentType:e.comp,skinPartData:{skin:e.skin,styleId:e.style},compData:c.posterImageRef},video:{id:a.id+q.ref,componentType:q.comp,skinPartData:{skin:q.skin,styleId:q.style},compData:b.mediaRef}};if(c.type==="Image"){d.push(f.image)}else if(c.type==="WixVideo"){d.push(f.poster);if(a.isDesktopDevice&&!a.isMobileView){d.push(f.video)}}}return d}function u(b){var c=k.getBgData(b.compDesign,b.compData);if(!c){return null}var d=t(b,c);var e=k.getBgEffectName(b.behaviors,b.isDesktopDevice,b.isMobileView);var f=a.map(d,function(d){var f=a.assign({id:d.id},s(b.structureComponentId,c,d.componentType,e));return this.createChildComponent(d.compData,d.componentType,d.skinPartData,f)},this);return f.length===1?a.first(f):f}return{displayName:"bgMedia",mixins:[j.skinBasedComp],propTypes:a.assign({id:b.PropTypes.string.isRequired,rootId:b.PropTypes.string.isRequired,structureComponentId:b.PropTypes.string.isRequired,compData:b.PropTypes.object,compDesign:b.PropTypes.object,compProp:b.PropTypes.object.isRequired,style:b.PropTypes.object.isRequired,renderFixedPositionBackgrounds:d.Types.RenderFlags.renderFixedPositionBackgrounds,componentViewMode:d.Types.RenderFlags.componentViewMode.isRequired,isDesktopDevice:d.Types.Device.isDesktopDevice.isRequired,isMobileView:d.Types.isMobileView.isRequired,behaviors:b.PropTypes.array},d.santaTypesUtils.getSantaTypesByDefinition(f),d.santaTypesUtils.getSantaTypesByDefinition(g),d.santaTypesUtils.getSantaTypesByDefinition(h)),statics:{useSantaTypes:true},getSkinProperties:function(){var b=this.props.compProp.effectName;var c=k.getPositionByEffect(b,this.props.renderFixedPositionBackgrounds);var d=k.getBgData(this.props.compDesign,this.props.compData);var e=a.assign({},this.props.style,{position:c,pointerEvents:"none",top:0});var f=a.mapKeys(a.get(d,"mediaTransforms"),function(a,b){return"data-"+b});return{"":a.assign({key:"media_"+this.props.componentViewMode,children:u.call(this,this.props),style:e,"data-effect":b||"none","data-fitting":d.fittingType,"data-align":d.alignType},f)}},getDefaultSkinName:function(){return"skins.viewer.balata.bgMediaSkin"}}});define("backgroundCommon/components/bgOverlay",["react","lodash","core","utils","santaProps"],function(a,b,c,d,e){"use strict";var f=c.compMixins;function g(a,b){return"url("+d.urlUtils.joinURL(a,b.uri)+")"}function h(a,b,c){var e={};if(a.colorOverlay){e.backgroundColor=d.colorParser.getColor(b,a.colorOverlay,a.colorOverlayOpacity)}if(a.imageOverlay){e.backgroundImage=g(c,a.imageOverlay)}return e}function i(a){var c={width:"100%",height:"100%",position:"absolute"};var d=h(a.compProp,a.colorsMap,a.staticMediaUrl);return b.assign(c,d)}function j(a,b,c){return b&&d.containerBackgroundUtils.isFullScreenByEffect(a,c)}function k(){var a=b.assign({position:"absolute"},this.props.style,{width:"100%",height:"100%"});if(j(this.props.compProp.effectName,this.props.fixedBackgroundColorBalata,this.props.renderFixedPositionBackgrounds)){b.assign(a,{top:0,position:"fixed"})}return a}return{displayName:"bgOverlay",mixins:[f.skinBasedComp],propTypes:{compProp:a.PropTypes.object.isRequired,style:a.PropTypes.object,colorOverlay:a.PropTypes.string,colorOverlayOpacity:a.PropTypes.number,effectName:a.PropTypes.string,colorsMap:e.Types.Theme.colorsMap.isRequired,staticMediaUrl:e.Types.ServiceTopology.staticMediaUrl,fixedBackgroundColorBalata:e.Types.BrowserFlags.fixedBackgroundColorBalata.isRequired,renderFixedPositionBackgrounds:e.Types.RenderFlags.renderFixedPositionBackgrounds},statics:{useSantaTypes:true},getSkinProperties:function(){var a=k.call(this);var b=i(this.props);var c={"":{style:a}};c[d.balataConsts.OVERLAY]={style:b};return c}}});define("backgroundCommon",["backgroundCommon/mixins/bgVideoMixin","backgroundCommon/mixins/backgroundDetectionMixin","backgroundCommon/components/bgImage","backgroundCommon/components/bgMedia","backgroundCommon/components/bgOverlay","backgroundCommon/components/bgVideo"],function(a,b,c,d,e,f){"use strict";return{mixins:{bgVideoMixin:a,backgroundDetectionMixin:b},components:{bgImage:c,bgMedia:d,bgOverlay:e,bgVideo:f}}});