!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.computeLayout=b()}(this,function(){var a=function(){function a(b){if((!b.layout||b.isDirty)&&(b.layout={width:void 0,height:void 0,top:0,left:0,right:0,bottom:0}),b.style||(b.style={}),b.children||(b.children=[]),b.style.measure&&b.children&&b.children.length)throw new Error("Using custom measure function is supported only for leaf nodes.");return b.children.forEach(a),b}function b(a){return void 0===a}function c(a){return a===P||a===Q}function d(a){return a===R||a===S}function e(a,b){if(void 0!==a.style.marginStart&&c(b))return a.style.marginStart;var d=null;switch(b){case"row":d=a.style.marginLeft;break;case"row-reverse":d=a.style.marginRight;break;case"column":d=a.style.marginTop;break;case"column-reverse":d=a.style.marginBottom}return void 0!==d?d:void 0!==a.style.margin?a.style.margin:0}function f(a,b){if(void 0!==a.style.marginEnd&&c(b))return a.style.marginEnd;var d=null;switch(b){case"row":d=a.style.marginRight;break;case"row-reverse":d=a.style.marginLeft;break;case"column":d=a.style.marginBottom;break;case"column-reverse":d=a.style.marginTop}return null!=d?d:void 0!==a.style.margin?a.style.margin:0}function g(a,b){if(void 0!==a.style.paddingStart&&a.style.paddingStart>=0&&c(b))return a.style.paddingStart;var d=null;switch(b){case"row":d=a.style.paddingLeft;break;case"row-reverse":d=a.style.paddingRight;break;case"column":d=a.style.paddingTop;break;case"column-reverse":d=a.style.paddingBottom}return null!=d&&d>=0?d:void 0!==a.style.padding&&a.style.padding>=0?a.style.padding:0}function h(a,b){if(void 0!==a.style.paddingEnd&&a.style.paddingEnd>=0&&c(b))return a.style.paddingEnd;var d=null;switch(b){case"row":d=a.style.paddingRight;break;case"row-reverse":d=a.style.paddingLeft;break;case"column":d=a.style.paddingBottom;break;case"column-reverse":d=a.style.paddingTop}return null!=d&&d>=0?d:void 0!==a.style.padding&&a.style.padding>=0?a.style.padding:0}function i(a,b){if(void 0!==a.style.borderStartWidth&&a.style.borderStartWidth>=0&&c(b))return a.style.borderStartWidth;var d=null;switch(b){case"row":d=a.style.borderLeftWidth;break;case"row-reverse":d=a.style.borderRightWidth;break;case"column":d=a.style.borderTopWidth;break;case"column-reverse":d=a.style.borderBottomWidth}return null!=d&&d>=0?d:void 0!==a.style.borderWidth&&a.style.borderWidth>=0?a.style.borderWidth:0}function j(a,b){if(void 0!==a.style.borderEndWidth&&a.style.borderEndWidth>=0&&c(b))return a.style.borderEndWidth;var d=null;switch(b){case"row":d=a.style.borderRightWidth;break;case"row-reverse":d=a.style.borderLeftWidth;break;case"column":d=a.style.borderBottomWidth;break;case"column-reverse":d=a.style.borderTopWidth}return null!=d&&d>=0?d:void 0!==a.style.borderWidth&&a.style.borderWidth>=0?a.style.borderWidth:0}function k(a,b){return g(a,b)+i(a,b)}function l(a,b){return h(a,b)+j(a,b)}function m(a,b){return i(a,b)+j(a,b)}function n(a,b){return e(a,b)+f(a,b)}function o(a,b){return k(a,b)+l(a,b)}function p(a){return a.style.justifyContent?a.style.justifyContent:"flex-start"}function q(a){return a.style.alignContent?a.style.alignContent:"flex-start"}function r(a,b){return b.style.alignSelf?b.style.alignSelf:a.style.alignItems?a.style.alignItems:"stretch"}function s(a,b){if(b===O){if(a===P)return Q;if(a===Q)return P}return a}function t(a,b){var c;return c=a.style.direction?a.style.direction:M,c===M&&(c=void 0===b?N:b),c}function u(a){return a.style.flexDirection?a.style.flexDirection:R}function v(a,b){return d(a)?s(P,b):R}function w(a){return a.style.position?a.style.position:"relative"}function x(a){return w(a)===aa&&a.style.flex>0}function y(a){return"wrap"===a.style.flexWrap}function z(a,b){return a.layout[fa[b]]+n(a,b)}function A(a,b){return void 0!==a.style[fa[b]]&&a.style[fa[b]]>=0}function B(a,b){return void 0!==a.style[b]}function C(a){return void 0!==a.style.measure}function D(a,b){return void 0!==a.style[b]?a.style[b]:0}function E(a,b,c){var d={row:a.style.minWidth,"row-reverse":a.style.minWidth,column:a.style.minHeight,"column-reverse":a.style.minHeight}[b],e={row:a.style.maxWidth,"row-reverse":a.style.maxWidth,column:a.style.maxHeight,"column-reverse":a.style.maxHeight}[b],f=c;return void 0!==e&&e>=0&&f>e&&(f=e),void 0!==d&&d>=0&&d>f&&(f=d),f}function F(a,b){return a>b?a:b}function G(a,b){void 0===a.layout[fa[b]]&&A(a,b)&&(a.layout[fa[b]]=F(E(a,b,a.style[fa[b]]),o(a,b)))}function H(a,b,c){b.layout[da[c]]=a.layout[fa[c]]-b.layout[fa[c]]-b.layout[ea[c]]}function I(a,b){return void 0!==a.style[ca[b]]?D(a,ca[b]):-D(a,da[b])}function J(a,d,g,h){var j=t(a,h),J=s(u(a),j),M=v(J,j),N=s(P,j);G(a,J),G(a,M),a.layout.direction=j,a.layout[ca[J]]+=e(a,J)+I(a,J),a.layout[da[J]]+=f(a,J)+I(a,J),a.layout[ca[M]]+=e(a,M)+I(a,M),a.layout[da[M]]+=f(a,M)+I(a,M);var O=a.children.length,ga=o(a,N),ha=o(a,R);if(C(a)){var ia=!b(a.layout[fa[N]]),ja=L;ja=A(a,N)?a.style.width:ia?a.layout[fa[N]]:d-n(a,N),ja-=ga;var ka=L;ka=A(a,R)?a.style.height:b(a.layout[fa[R]])?g-n(a,N):a.layout[fa[R]],ka-=o(a,R);var la=!A(a,N)&&!ia,ma=!A(a,R)&&b(a.layout[fa[R]]);if(la||ma){var na=a.style.measure(ja,ka);la&&(a.layout.width=na.width+ga),ma&&(a.layout.height=na.height+ha)}if(0===O)return}var oa,pa,qa,ra,sa=y(a),ta=p(a),ua=k(a,J),va=k(a,M),wa=o(a,J),xa=o(a,M),ya=!b(a.layout[fa[J]]),za=!b(a.layout[fa[M]]),Aa=c(J),Ba=null,Ca=null,Da=L;ya&&(Da=a.layout[fa[J]]-wa);for(var Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0;O>Fa;){var Ka,La,Ma=0,Na=0,Oa=0,Pa=0,Qa=ya&&ta===T||!ya&&ta!==U,Ra=Qa?O:Ea,Sa=!0,Ta=O,Ua=null,Va=null,Wa=ua,Xa=0;for(oa=Ea;O>oa;++oa){qa=a.children[oa],qa.lineIndex=Ja,qa.nextAbsoluteChild=null,qa.nextFlexChild=null;var Ya=r(a,qa);if(Ya===_&&w(qa)===aa&&za&&!A(qa,M))qa.layout[fa[M]]=F(E(qa,M,a.layout[fa[M]]-xa-n(qa,M)),o(qa,M));else if(w(qa)===ba)for(null===Ba&&(Ba=qa),null!==Ca&&(Ca.nextAbsoluteChild=qa),Ca=qa,pa=0;2>pa;pa++)ra=0!==pa?P:R,!b(a.layout[fa[ra]])&&!A(qa,ra)&&B(qa,ca[ra])&&B(qa,da[ra])&&(qa.layout[fa[ra]]=F(E(qa,ra,a.layout[fa[ra]]-o(a,ra)-n(qa,ra)-D(qa,ca[ra])-D(qa,da[ra])),o(qa,ra)));var Za=0;if(ya&&x(qa)?(Na++,Oa+=qa.style.flex,null===Ua&&(Ua=qa),null!==Va&&(Va.nextFlexChild=qa),Va=qa,Za=o(qa,J)+n(qa,J)):(Ka=L,La=L,Aa?La=A(a,R)?a.layout[fa[R]]-ha:g-n(a,R)-ha:Ka=A(a,N)?a.layout[fa[N]]-ga:d-n(a,N)-ga,0===Ga&&K(qa,Ka,La,j),w(qa)===aa&&(Pa++,Za=z(qa,J))),sa&&ya&&Ma+Za>Da&&oa!==Ea){Pa--,Ga=1;break}Qa&&(w(qa)!==aa||x(qa))&&(Qa=!1,Ra=oa),Sa&&(w(qa)!==aa||Ya!==_&&Ya!==Y||b(qa.layout[fa[M]]))&&(Sa=!1,Ta=oa),Qa&&(qa.layout[ea[J]]+=Wa,ya&&H(a,qa,J),Wa+=z(qa,J),Xa=F(Xa,E(qa,M,z(qa,M)))),Sa&&(qa.layout[ea[M]]+=Ha+va,za&&H(a,qa,M)),Ga=0,Ma+=Za,Fa=oa+1}var $a=0,_a=0,ab=0;if(ab=ya?Da-Ma:F(Ma,0)-Ma,0!==Na){var bb,cb,db=ab/Oa;for(Va=Ua;null!==Va;)bb=db*Va.style.flex+o(Va,J),cb=E(Va,J,bb),bb!==cb&&(ab-=cb,Oa-=Va.style.flex),Va=Va.nextFlexChild;for(db=ab/Oa,0>db&&(db=0),Va=Ua;null!==Va;)Va.layout[fa[J]]=E(Va,J,db*Va.style.flex+o(Va,J)),Ka=L,A(a,N)?Ka=a.layout[fa[N]]-ga:Aa||(Ka=d-n(a,N)-ga),La=L,A(a,R)?La=a.layout[fa[R]]-ha:Aa&&(La=g-n(a,R)-ha),K(Va,Ka,La,j),qa=Va,Va=Va.nextFlexChild,qa.nextFlexChild=null}else ta!==T&&(ta===U?$a=ab/2:ta===V?$a=ab:ta===W?(ab=F(ab,0),_a=Na+Pa-1!==0?ab/(Na+Pa-1):0):ta===X&&(_a=ab/(Na+Pa),$a=_a/2));for(Wa+=$a,oa=Ra;Fa>oa;++oa)qa=a.children[oa],w(qa)===ba&&B(qa,ca[J])?qa.layout[ea[J]]=D(qa,ca[J])+i(a,J)+e(qa,J):(qa.layout[ea[J]]+=Wa,ya&&H(a,qa,J),w(qa)===aa&&(Wa+=_a+z(qa,J),Xa=F(Xa,E(qa,M,z(qa,M)))));var eb=a.layout[fa[M]];for(za||(eb=F(E(a,M,Xa+xa),xa)),oa=Ta;Fa>oa;++oa)if(qa=a.children[oa],w(qa)===ba&&B(qa,ca[M]))qa.layout[ea[M]]=D(qa,ca[M])+i(a,M)+e(qa,M);else{var fb=va;if(w(qa)===aa){var Ya=r(a,qa);if(Ya===_)b(qa.layout[fa[M]])&&(qa.layout[fa[M]]=F(E(qa,M,eb-xa-n(qa,M)),o(qa,M)));else if(Ya!==Y){var gb=eb-xa-z(qa,M);fb+=Ya===Z?gb/2:gb}}qa.layout[ea[M]]+=Ha+fb,za&&H(a,qa,M)}Ha+=Xa,Ia=F(Ia,Wa),Ja+=1,Ea=Fa}if(Ja>1&&za){var hb=a.layout[fa[M]]-xa,ib=hb-Ha,jb=0,kb=va,lb=q(a);lb===$?kb+=ib:lb===Z?kb+=ib/2:lb===_&&hb>Ha&&(jb=ib/Ja);var mb=0;for(oa=0;Ja>oa;++oa){var nb=mb,ob=0;for(pa=nb;O>pa;++pa)if(qa=a.children[pa],w(qa)===aa){if(qa.lineIndex!==oa)break;b(qa.layout[fa[M]])||(ob=F(ob,qa.layout[fa[M]]+n(qa,M)))}for(mb=pa,ob+=jb,pa=nb;mb>pa;++pa)if(qa=a.children[pa],w(qa)===aa){var pb=r(a,qa);if(pb===Y)qa.layout[ea[M]]=kb+e(qa,M);else if(pb===$)qa.layout[ea[M]]=kb+ob-f(qa,M)-qa.layout[fa[M]];else if(pb===Z){var qb=qa.layout[fa[M]];qa.layout[ea[M]]=kb+(ob-qb)/2}else pb===_&&(qa.layout[ea[M]]=kb+e(qa,M))}kb+=ob}}var rb=!1,sb=!1;if(ya||(a.layout[fa[J]]=F(E(a,J,Ia+l(a,J)),wa),(J===Q||J===S)&&(rb=!0)),za||(a.layout[fa[M]]=F(E(a,M,Ha+xa),xa),(M===Q||M===S)&&(sb=!0)),rb||sb)for(oa=0;O>oa;++oa)qa=a.children[oa],rb&&H(a,qa,J),sb&&H(a,qa,M);for(Ca=Ba;null!==Ca;){for(pa=0;2>pa;pa++)ra=0!==pa?P:R,!b(a.layout[fa[ra]])&&!A(Ca,ra)&&B(Ca,ca[ra])&&B(Ca,da[ra])&&(Ca.layout[fa[ra]]=F(E(Ca,ra,a.layout[fa[ra]]-m(a,ra)-n(Ca,ra)-D(Ca,ca[ra])-D(Ca,da[ra])),o(Ca,ra))),B(Ca,da[ra])&&!B(Ca,ca[ra])&&(Ca.layout[ca[ra]]=a.layout[fa[ra]]-Ca.layout[fa[ra]]-D(Ca,da[ra]));qa=Ca,Ca=Ca.nextAbsoluteChild,qa.nextAbsoluteChild=null}}function K(a,b,c,d){a.shouldUpdate=!0;var e=a.style.direction||N,f=!a.isDirty&&a.lastLayout&&a.lastLayout.requestedHeight===a.layout.height&&a.lastLayout.requestedWidth===a.layout.width&&a.lastLayout.parentMaxWidth===b&&a.lastLayout.parentMaxHeight===c&&a.lastLayout.direction===e;f?(a.layout.width=a.lastLayout.width,a.layout.height=a.lastLayout.height,a.layout.top=a.lastLayout.top,a.layout.left=a.lastLayout.left):(a.lastLayout||(a.lastLayout={}),a.lastLayout.requestedWidth=a.layout.width,a.lastLayout.requestedHeight=a.layout.height,a.lastLayout.parentMaxWidth=b,a.lastLayout.parentMaxHeight=c,a.lastLayout.direction=e,a.children.forEach(function(a){a.layout.width=void 0,a.layout.height=void 0,a.layout.top=0,a.layout.left=0}),J(a,b,c,d),a.lastLayout.width=a.layout.width,a.lastLayout.height=a.layout.height,a.lastLayout.top=a.layout.top,a.lastLayout.left=a.layout.left)}var L,M="inherit",N="ltr",O="rtl",P="row",Q="row-reverse",R="column",S="column-reverse",T="flex-start",U="center",V="flex-end",W="space-between",X="space-around",Y="flex-start",Z="center",$="flex-end",_="stretch",aa="relative",ba="absolute",ca={row:"left","row-reverse":"right",column:"top","column-reverse":"bottom"},da={row:"right","row-reverse":"left",column:"bottom","column-reverse":"top"},ea={row:"left","row-reverse":"right",column:"top","column-reverse":"bottom"},fa={row:"width","row-reverse":"width",column:"height","column-reverse":"height"};return{layoutNodeImpl:J,computeLayout:K,fillNodes:a}}();return"object"==typeof exports&&(module.exports=a),function(b){a.fillNodes(b),a.computeLayout(b)}}); //# sourceMappingURL=css-layout.min.js.map