text: define(["lodash","coreUtils"],function(n,e){return function(n){function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var t={};return e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="",e(e.s=32)}({0:function(e,t){e.exports=n},1:function(n,e,t){"use strict";function r(n){return U.get(n,["conversionData","desktopOnly"],!1)}function o(n){return"text"===U.get(n,["conversionData","category"])}function i(n){return"graphic"===U.get(n,["conversionData","category"])||c(n)}function u(n){return n&&"wysiwyg.viewer.components.Group"===n.componentType}function a(n){return"columns"===U.get(n,["conversionData","category"])}function c(n){return"photo"===U.get(n,["conversionData","category"])}function s(n){return"masterPage"===U.get(n,"id")}function f(n){var e=function(n){return U.get(n.conversionData,"isScreenWidth",!1)||U.get(n.conversionData,"stretchHorizontally",!1)||U.some(n.components,e)};return h(n)||e(n)}function l(n){return U.get(n.conversionData,"isScreenWidth",!1)||U.some(n.components,l)}function m(n,e,t){void 0===e&&(e=0),void 0===t&&(t=0),U.forEach(n,function(n){n.layout.x+=e,n.layout.y+=t})}function p(n,e,t){v(n,[e],t),m([e],-n.layout.x,-n.layout.y)}function v(n,e,t){var r=M(n);e.length&&r&&(t=void 0!==t?t:r.length,r.splice.apply(r,[t,0].concat(e)))}function g(n,e){var t=M(n);U.remove(t,function(n){return U.includes(e,n)})}function d(n,e){if(u(n)){var t=U.findIndex(e.components,{id:n.id});U.forEach(n.components.reverse(),function(r){v(e,[r],t),m([r],n.layout.x,n.layout.y)}),U.remove(e.components,n)}}function y(n,e){return U.some(M(n),function(n){return e(n)||n&&y(n,e)})}function E(n,e,t){if(!s(n)&&e&&(t||!U.isEmpty(e))){var r=U(e).reject(["conversionData.isInvisible",!0]).reduce(function(n,e){return U.max([n,e.layout.y+e.layout.height,0])},0);if(U.get(n,["conversionData","hasTightYMargin"])||U.get(n,["conversionData","hasTightBottomMargin"]))return r;return r+(f(n)?w.conversionConfig.SECTION_MOBILE_MARGIN_Y:w.conversionConfig.COMPONENT_MOBILE_MARGIN_Y+U.get(n.conversionData,"borderWidth",0))}}function T(n,e,t,r){void 0===r&&(r=0);var o=E(n,e,t);if(U.isNumber(o)){var i=U.get(n,["conversionData","minHeight"],r);n.layout.height=Math.max(i,o)}}function h(n){return C(n)||N(n)}function C(n){return"Page"===n.type}function _(n){return"Container"===n.type}function N(n){return U.has(n.conversionData,"siteSegmentRole")}function R(n){var e=H.objectUtils.cloneDeep(n),t=U.has(e,"components")?"components":"children";return U.set(e,t,n.mobileComponents||[])}function x(n,e){if(e.id===n)return e;var t=null;return U.find(M(e),function(e){return t=x(n,e)}),t}function D(n,e){if(n.length>e)return void(n.length=0);for(var t=function(n,e){return U.size(U.intersection(n,e))>0},r=n.length-1;r>=0;r--)!function(e){var r=U.findLastIndex(n,function(r,o){return o<e&&t(n[e],r)});-1!==r&&(n[r]=n[r].concat(U.difference(n[e],n[r])),n.splice(e,1))}(r)}function I(n,e){var t=M(n);return U.map(e,function(n){return U.find(t,{id:n})||null})}function O(n,e){var t=M(e);if(U.find(t,{id:n}))return e;var r=null;return U.find(t,function(e){return r=O(n,e)}),r}function S(n){if(n&&0!==n.length){var e=U.min(U.map(n,"layout.x")),t=U.min(U.map(n,"layout.y"));return{x:e,y:t,width:U.max(U.map(n,function(n){return n.layout.x+n.layout.width}))-e,height:U.max(U.map(n,function(n){return n.layout.y+n.layout.height}))-t,rotationInDegrees:0}}}function P(){return{x:w.conversionConfig.MOBILE_WIDTH-(w.conversionConfig.TINY_MENU_SIZE+w.conversionConfig.SITE_SEGMENT_PADDING_X),y:w.conversionConfig.SECTION_MOBILE_MARGIN_Y,rotationInDegrees:0}}function M(n){return n.components||n.children}function A(n,e){void 0===n&&(n=[]),void 0===e&&(e=[]);var t=function(n,e){return Math.min(n[1],e[1])-e[0]};return n[0]<=e[0]?t(n,e):t(e,n)}function G(n,e){var t=function(n){return[n.layout.y,n.layout.height+n.layout.y]};return A(t(n),t(e))}function L(n,e){if(l(n))return e.layout.width;if(l(e))return n.layout.width;var t=function(n){return[n.layout.x,n.layout.width+n.layout.x]};return A(t(n),t(e))}function V(n,e){return l(n)?n.layout.height>=e.layout.height||X(n)>X(e):!l(e)&&X(n)>X(e)}function z(n,e,t){var r=L(n,e),o=G(n,e);if(r<=0||o<=0)return!1;var i=r*o,u=Math.min(X(n),X(e));return i>0&&i/u>=t}function b(n){return!!_(n)&&("columns"===n.conversionData.category?1===U.size(n.components)&&U.isEmpty(n.components[0].components):U.isEmpty(n.components))}function B(n,e){return a(e)&&U.get(n,["conversionData","isInvisible"],!1)}function F(n,e,t){void 0===e&&(e=!1);for(var r=[[n]],o=0;o<r.length;o++){var i=r[o];U.forEach(i,function(n){var t=e?U.get(n,"mobileComponents"):M(n);U.isEmpty(t)||r.push(t)})}return U(r).flatten().remove(t).keyBy("id").value()}Object.defineProperty(e,"__esModule",{value:!0});var U=t(0),w=t(2),H=t(3),Y=function(n){return U.get(n,"componentType")===w.conversionConfig.VIRTUAL_GROUP_TYPES.MERGE};e.isMergeVirtualGroup=Y;var j=function(n){return U.get(n,"componentType")===w.conversionConfig.VIRTUAL_GROUP_TYPES.RESCALE};e.isRescaleVirtualGroup=j;var W=function(n){return j(n)||Y(n)};e.isVirtualGroup=W,e.isDesktopOnlyComponent=r,e.isTextComponent=o,e.isGraphicComponent=i,e.isGroupComponent=u,e.isColumnsContainerComponent=a,e.isImageComponent=c,e.isMasterPage=s,e.shouldStretchToScreenWidth=f,e.isScreenWidthComponent=l,e.translateComps=m,e.reparentComponent=p,e.addComponentsTo=v,e.removeChildrenFrom=g,e.removeGroup=d,e.containsComponent=y,e.getHeightAccordingToChildren=E,e.ensureContainerTightlyWrapsChildren=T,e.isSiteSegmentOrPage=h,e.isPageComponent=C,e.isContainerComponent=_,e.isSiteSegment=N,e.extractMobilePage=R,e.getComponentByIdFromStructure=x,e.unifyGroups=D,e.getComponentsByIds=I,e.getParent=O,e.getSnugLayout=S,e.getTinyMenuDefaultPosition=P,e.getChildren=M,e.getRangesOverlap=A,e.getYOverlap=G,e.getXOverlap=L;var X=function(n){return n.layout.width*n.layout.height};e.hasGreaterArea=V,e.haveSufficientOverlap=z,e.isEmptyContainer=b,e.shouldReparentCompToChildOfContainer=B,e.getAllCompsInStructure=F},18:function(n,e,t){"use strict";function r(n,e){var t=a.createEventsQueue(n,e);return a.createFragments(t)}function o(n){if(u.size(n)<=1)return n;var e=u.map(r(n,"y"),"comps");return u.reduce(e,function(e,t){if(1===u.size(t))return e.concat(t);var o=u.map(r(t,"x"),"comps"),i=u.flatMap(o,function(e){return 1===u.size(e)?e:u.sortBy(e,u.findIndex.bind(null,n))});return e.concat(i)},[])}function i(n){var e=c.getChildren(n);if(!e)return{};var t=o(e),r=u.set({},n.id,u.map(t,"id")),a=u.map(e,i);return u.assign.apply(u,[r].concat(a))}Object.defineProperty(e,"__esModule",{value:!0});var u=t(0),a=t(8),c=t(1);e.splitToFragments=r,e.sortSiblings=o,e.getComponentsOrder=i},2:function(n,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={MOBILE_WIDTH:320,MARGIN_BETWEEN_TEXT_AND_NON_TEXT:20,COMPONENT_MOBILE_MARGIN_X:10,COMPONENT_MOBILE_MARGIN_Y:10,SECTION_MOBILE_MARGIN_Y:20,SITE_SEGMENT_PADDING_X:20,TINY_MENU_SIZE:50,TEXT_MAX_LENGTH_FOR_RESCALING:25,MIN_WIDTH_FOR_ENLARGE:140,DEFAULT_TEXT_HEIGHT:10,VIRTUAL_GROUP_TYPES:{RESCALE:"RESCALE_VIRTUAL_GROUP",MERGE:"MERGE_VIRTUAL_GROUP"}};e.conversionConfig=r},3:function(n,t){n.exports=e},32:function(n,e,t){"use strict";var r=t(1),o=t(18),i={translateComponents:r.translateComps,getSnugLayout:r.getSnugLayout,splitToFragments:o.splitToFragments,sortSiblings:o.sortSiblings,getComponentsOrder:o.getComponentsOrder};n.exports=i},4:function(n,e,t){"use strict";function r(n,e,t,r){void 0===r&&(r=m);var o=f.get(n,["layout",t]),i=f.get(e,["layout",t]);return Math.abs(o-i)<=r*f.min([v(n,t),v(e,t)])}function o(n,e,t,r){void 0===r&&(r=m);var o=f.get(n,t),i=f.get(e,t);return Math.abs(o-i)<=r*f.min([o,i])}function i(n,e,t){return n===e||f.size(n)===f.size(e)&&!u(n,t)&&!u(e,t)&&f.every(n,function(n,i){var u=e[i];return n.componentType===u.componentType&&r(n,u,t)&&("text"===n.conversionData.category?o(n,u,["conversionData","averageNormalizedFontSize"]):o(n,u,["layout","height"])&&o(n,u,["layout","width"]))})}function u(n,e){var t=f.findIndex(n,function(t,r){if(0===r)return!1;var o=g(n[r-1],e),i=t.layout[e]-o;return i<0||i>f.min([v(n[r-1],e),v(t,e)])});return-1!==t&&t!==n.length-1}function a(n){var e=l.getChildren(n);return f.map(n.conversionData.componentsOrder,function(n){return f.find(e,{id:n})})}function c(n,e){var t=f.map(l.getChildren(n),"id");return f.sortBy(e,function(n){return t.indexOf(n.id)})}function s(n){var e=f.pick(n.conversionData.mobileHints,["recommendedWidth","recommendedHeight","recommendedScale","recommendedOrder"]);return!f.isEmpty(e)}Object.defineProperty(e,"__esModule",{value:!0});var f=t(0),l=t(1),m=.1,p=function(n){return 0===n?0:n/Math.abs(n)};e.getSign=p;var v=function(n,e){return"x"===e?n.layout.width:n.layout.height};e.getComponentSize=v;var g=function(n,e){return n.layout[e]+v(n,e)};e.getComponentEndCoordinate=g;var d=function(n,e){return p(n.layout.y-e.layout.y)};e.compareComponentsByY=d,e.areSimilarFragments=i,e.getOrderedComponents=a;var y=function(n){return l.isRescaleVirtualGroup(n)&&"reorder"!==n.conversionData.rescaleMethod||n.conversionData.structuralContainer};e.shouldUseNaturalOrder=y,e.sortComponentsByNaturalOrder=c,e.hasMobileHintsPresets=s},8:function(n,e,t){"use strict";function r(n,e){var t=R(e.y).partition({eventType:I.START_EVENT}).map(function(n){return R.map(n,"coordinate")}).value(),r=R.max(t[0]),o=R.min(t[1]);return R.findIndex(n,function(n){var e=n.comps[0];return 1===n.comps.length&&e.conversionData.keepIfVerticalDivider&&e.layout.y<=o&&x.getComponentEndCoordinate(e,"y")>=r})}function o(n,e){return R.transform(n,function(n,t,r){var o=e(r);return n[o]=n[o]||{comps:[],distanceToPreviousFragment:t.distanceToPreviousFragment},n[o].comps=n[o].comps.concat(t.comps),n},[])}function i(n,e,t){return R.assign(t,{fragments:[{comps:n,distanceToPreviousFragment:-1}],fragmentsEvents:[e]})}function u(n,e){var t=n.coordinate-e.coordinate;return 0!==t?x.getSign(t):n.compRef===e.compRef?n.eventType===I.END_EVENT?1:-1:n.eventType===I.END_EVENT?-1:1}function a(n,e){var t=R.findLastIndex(n,function(n){if(n.coordinate===e.coordinate){if(n.eventType===I.START_EVENT&&e.eventType===I.START_EVENT)return n.size>e.size;if(n.eventType===I.END_EVENT&&e.eventType===I.END_EVENT)return n.size<e.size;if(n.eventType===I.START_EVENT&&e.eventType===I.END_EVENT)return n.compRef===e.compRef;if(n.eventType===I.END_EVENT&&e.eventType===I.START_EVENT)return n.compRef!==e.compRef}return n.coordinate<e.coordinate});return n.splice(t+1,0,e),n}function c(n,e){var t=R.transform(n,function(n,t){var r=t.layout[e]||0,o=x.getComponentEndCoordinate(t,e)||r,i=x.getComponentSize(t,e)||0;return a(n,{eventType:I.START_EVENT,compRef:t,coordinate:r,size:i}),a(n,{eventType:I.END_EVENT,compRef:t,coordinate:o,size:i}),n},[]);return R.map(t,function(n){return R.omit(n,"size")})}function s(n){var e=[],t=[];return R.forEach(n,function(n){var r=R.last(t);if(n.eventType===I.START_EVENT){if(R.isEmpty(e)){var o=r?n.coordinate-R.last(r.events).coordinate:-1,i={events:[n],distanceToPreviousFragment:o};t.push(i)}else r.events.push(n);e.push(n)}else R.remove(e,{compRef:n.compRef}),r.events.push(n)}),R.map(t,function(n){return{comps:M(n.events),distanceToPreviousFragment:n.distanceToPreviousFragment}})}function f(n,e,t){var r=R.maxBy(n,"distanceToPreviousFragment"),i=R.findIndex(n,r),u=function(n){return n<i?0:1},a=o(n,u),c=[n[i-1],r],s=R.filter(e[A(t)],function(n){return R.some(c,function(e){return R.includes(e.comps,n.compRef)})}),f={fragmentsEvents:v(e,a),fragments:a},l=m(c,s,t);return R.assign(f,{maxCompsDistance:l})}function l(n,e){return R(n).map(function(n,t){return t?R.map(n,function(n){return R.defaults({closestPoint:n.compRef.layout[e]},n)}):R.map(n,function(n){return R.defaults({closestPoint:x.getComponentEndCoordinate(n.compRef,e)},n)})}).map(function(n,e){return R.reduce(n,function(n,t){var r=R.last(n);return r&&r.eventType!==I.END_EVENT?r.compRef===t.compRef?n.concat([t]):((e&&t.closestPoint<r.closestPoint||!e&&t.closestPoint>r.closestPoint)&&n.splice(n.length-1,1,t),n):n.concat(t.eventType===I.START_EVENT?[t]:[])},[])}).value()}function m(n,e,t){for(var r=R.partition(e,function(e){return R.includes(n[0].comps,e.compRef)}),o=l(r,t),i=[0,0],u=[[],[]],a=-1/0;i[0]<o[0].length||i[1]<o[1].length;){var c=function(){return i[0]===o[0].length||i[1]===o[1].length?i[0]===o[0].length?1:0:o[0][i[0]].coordinate<=o[1][i[1]].coordinate?0:1}(),s=o[c][i[c]++];if(s.eventType!==I.END_EVENT){u[c].push(s);var f=[R.maxBy(u[0],"closestPoint"),R.minBy(u[1],"closestPoint")],m=R.get(f,[1,"closestPoint"])-R.get(f,[0,"closestPoint"]);!R.isNaN(m)&&m>a&&(a=m)}else R.remove(u[c],{compRef:s.compRef})}return a}function p(n,e){return R.transform(n,function(n,t){var r=R.findIndex(e,function(n){return R.includes(n.comps,t.compRef)});return n[r]=(n[r]||[]).concat([t]),n},[])}function v(n,e){var t=p(n.x,e),r=p(n.y,e);return R.map(R.keys(e),function(n){return R.assign({},{x:t[n],y:r[n]})})}function g(n,e,t){var r=null;return R.forEach(P,function(o,i){if(!t[i])return!0;var u=o(e.y,n,"y"),a=o(e.x,n,"x");return null===(r=u&&a?null:u||a)}),r}function d(n,e){var t=R.size(e.x)>1?f(e.x,n,"x"):null,r=R.size(e.y)>1?f(e.y,n,"y"):null;if(t&&r){var o=S.HORIZONTAL*t.maxCompsDistance>S.VERTICAL*r.maxCompsDistance?t:r;return R.pick(o,["fragments","fragmentsEvents"])}return t||r}function y(n,e,t){return g(n,e,t)||d(n,e)}function E(n,e){e=x.sortComponentsByNaturalOrder(n,e),e=R.sortBy(e,"layout.y");var t="overlayGroup_"+e[0].id;return R.forEach(e,function(n){return R.set(n,["conversionData","overlayGroupId"],t)}),e}function T(n,e,t,r){if(R.size(e)<2)return e||[];var o=R.mapValues(t,s);if(1===R.size(o.x)&&1===R.size(o.y))return r.detectSemanticGroups&&r.useOverlapRules?E(n,e):h(n,e,r);var i=y(t,o,{mirrorPattern:!0,verticalDivider:!0,chessPattern:!0,singleCompRow:!0});return 1===R.size(i.fragments)?i.fragments[0].comps:R.flatMap(i.fragments,function(e,t){return T(n,e.comps,i.fragmentsEvents[t],r)})}function h(n,e,t){var r=function(n){return R.some(n,"conversionData.originalLayout")};if(r(e)||R.some(e,function(n){return r(n)}))return _(e),e;C(e);var o=c(e,"y"),i=c(e,"x"),u=T(n,e,{y:o,x:i},t);return _(u),u}function C(n){R.forEach(n,function(n){var e=n.layout,t=R.assign(D.objectUtils.cloneDeep(e),{height:e.height*O,width:e.width*O});n.layout=t,R.set(n,["conversionData","originalLayout"],e)})}function _(n,e){void 0===e&&(e=!0),R.forEach(n,function(n){var e=R.get(n,["conversionData","originalLayout"]);e&&(n.layout=D.objectUtils.cloneDeep(e),delete n.conversionData.originalLayout)}),e&&R.forEach(n,function(n){return _(n.components,!1)})}function N(n,e,t){var r=c(e,"y"),o=c(e,"x"),i=T(n,e,{y:r,x:o},t);n.conversionData.componentsOrder=R.map(i,"id")}Object.defineProperty(e,"__esModule",{value:!0});var R=t(0),x=t(4),D=t(3),I={START_EVENT:"start",END_EVENT:"end"},O=.9,S={HORIZONTAL:1,VERTICAL:1.25},P={singleCompRow:function(n,e,t){if("x"===t)return null;var r=R.findIndex(n,function(n){return 1===R.size(n.comps)});if(-1===r)return null;var i=function(n){return x.getSign(n-r)+x.getSign(r)},u=o(n,i);return{type:"singleCompRow",fragments:u,fragmentsEvents:v(e,u)}},verticalDivider:function(n,e,t){var i=function(n){return 1===R.size(n.comps)};if(R.size(n)<3||R.every(n,i)||"y"===t)return null;var u=r(n,e);if(-1===u)return null;R.set(n[u].comps[0],["conversionData","isVerticalDivider"],!0);var a=function(n){return x.getSign(n-u)+x.getSign(u)},c=o(n,a);return{type:"verticalDivider",fragments:c,fragmentsEvents:v(e,c)}},mirrorPattern:function(n,e,t){if(R.size(n)<2)return null;var r=v(e,n),o=A(t),u=R.map(r,function(n){return M(n[o])}),a=R.every(u,function(n){return x.areSimilarFragments(n,u[0],o)});return a&&a?i(R.flatten(u),e,{type:"mirrorPattern"}):null},chessPattern:function(n,e,t){var r=function(n){return 2===R.size(n.comps)};if("y"!==t||R.size(n)<2||!R.every(n,r))return null;var o=v(e,n),u=R.map(o,function(n){return M(n.x)}),a=R.flatMap(u,function(n,e){return G(e)?n:R.reverse(n)}),c=a[0].conversionData.category,s="text"===c?"photo":"text",f=function(n,e){return n.conversionData.category===(G(e)?c:s)};return R.every(a,f)?i(a,e,{type:"chessPattern"}):null}},M=function(n){return R(n).map("compRef").uniq().value()};e.extractCompsFromEvents=M;var A=function(n){return"x"===n?"y":"x"},G=function(n){return n%2==0};e.createEventsQueue=c,e.createFragments=s,e.splitAxisEventsByFragments=p,e.setComponentsOrder=N;var L={isEven:G,transformLayouts:C,restoreLayouts:_,extractCompsFromEvents:M,getPerpendicularAxis:A,compareEvents:u,refragment:o,splitAxisEventsByFragments:p,splitAllEventsByFragments:v,calculateMaxCompsDistance:m,sortComponentsByNaturalOrder:x.sortComponentsByNaturalOrder};e.testAPI=L}})});
  //# sourceMappingURL=mobileLayoutUtils.js.map