YUI.add("resize-constrain",function(v,t){var e=v.Lang,i=e.isBoolean,H=e.isNumber,n=e.isString,h=v.Resize.capitalize,o=function(t){return t instanceof v.Node},_=function(t){return parseFloat(t)||0},s="border",k="constrain",R="host",r="offsetHeight",a="offsetWidth",g="width";function c(){c.superclass.constructor.apply(this,arguments)}v.mix(c,{NAME:"resizeConstrained",NS:"con",ATTRS:{constrain:{setter:function(t){return t=t&&(o(t)||n(t)||t.nodeType)?v.one(t):t}},minHeight:{value:15,validator:H},minWidth:{value:15,validator:H},maxHeight:{value:Infinity,validator:H},maxWidth:{value:Infinity,validator:H},preserveRatio:{value:!1,validator:i},tickX:{value:!1},tickY:{value:!1}}}),v.extend(c,v.Plugin.Base,{constrainSurrounding:null,initializer:function(){var t=this,e=t.get(R);e.delegate.dd.plug(v.Plugin.DDConstrained,{tickX:t.get("tickX"),tickY:t.get("tickY")}),e.after("resize:align",v.bind(t._handleResizeAlignEvent,t)),e.on("resize:start",v.bind(t._handleResizeStartEvent,t))},_checkConstrain:function(t,e,i){var n,o=this,r=o.get(R).info,a=o.constrainSurrounding.border,o=o._getConstrainRegion();o&&(n=r[t]+r[i],(e=o[e]-_(a[h(s,e,g)]))<=n&&(r[i]-=n-e),(n=r[t])<=(e=o[t]+_(a[h(s,t,g)])))&&(r[t]+=e-n,r[i]-=e-n)},_checkHeight:function(){var t=this.get(R),e=t.info,i=this.get("maxHeight")+t.totalVSurrounding,n=this.get("minHeight")+t.totalVSurrounding;this._checkConstrain("top","bottom",r),e.offsetHeight>i&&t._checkSize(r,i),e.offsetHeight<n&&t._checkSize(r,n)},_checkRatio:function(){var t,e,i,n=this,o=n.get(R),r=o.info,a=o.originalInfo,h=a.offsetWidth,s=a.offsetHeight,g=a.top,c=a.left,d=a.bottom,a=a.right,f=function(){return r.offsetWidth/h},u=function(){return r.offsetHeight/s},l=o.changeHeightHandles;n.get(k)&&o.changeHeightHandles&&o.changeWidthHandles&&(i=n._getConstrainRegion(),t=n.constrainSurrounding.border,d=i.bottom-_(t.borderBottomWidth)-d,e=c-(i.left+_(t.borderLeftWidth)),a=i.right-_(t.borderRightWidth)-a,i=g-(i.top+_(t.borderTopWidth)),l=o.changeLeftHandles&&o.changeTopHandles?i<e:o.changeLeftHandles?d<e:o.changeTopHandles?i<a:d<a),l?(r.offsetWidth=h*u(),n._checkWidth(),r.offsetHeight=s*f()):(r.offsetHeight=s*f(),n._checkHeight(),r.offsetWidth=h*u()),o.changeTopHandles&&(r.top=g+(s-r.offsetHeight)),o.changeLeftHandles&&(r.left=c+(h-r.offsetWidth)),v.each(r,function(t,e){H(t)&&(r[e]=Math.round(t))})},_checkRegion:function(){var t=this.get(R),e=this._getConstrainRegion();return v.DOM.inRegion(null,e,!0,t.info)},_checkWidth:function(){var t=this.get(R),e=t.info,i=this.get("maxWidth")+t.totalHSurrounding,n=this.get("minWidth")+t.totalHSurrounding;this._checkConstrain("left","right",a),e.offsetWidth<n&&t._checkSize(a,n),e.offsetWidth>i&&t._checkSize(a,i)},_getConstrainRegion:function(){var t=this.get(R).get("node"),e=this.get(k),i=null;return i=e?"view"===e?t.get("viewportRegion"):o(e)?e.get("region"):e:i},_handleResizeAlignEvent:function(){var t=this,e=t.get(R);t._checkHeight(),t._checkWidth(),t.get("preserveRatio")&&t._checkRatio(),t.get(k)&&!t._checkRegion()&&(e.info=e.lastInfo)},_handleResizeStartEvent:function(){var t=this.get(k),e=this.get(R);this.constrainSurrounding=e._getBoxSurroundingInfo(t)}}),v.namespace("Plugin"),v.Plugin.ResizeConstrained=c},"patched-v3.18.7",{requires:["plugin","resize-base"]});