/* @license Copyright (C) Exontrol. All rights reserved. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,t(e.exontrol||{}))}(this,function(e){"use strict";function t(e){return Math.round(e)}function i(){return Math.max.apply(0,arguments)}function r(){return Math.min.apply(null,arguments)}function o(e,i,r,o,n,l){e.drawLine([t(i),t(r)],[t(o),t(n)],l)}var n=n||window.exontrol;n.Def.Bezier={},n.Mrg(n,function(){function e(e,t){this.init(e,t)}return e.version="3.0",e.type="Bezier",e.Options={tfi:null,locked:null,readOnly:null,wheelChange:null,bezierCoord:null,sizeBezier:null,colorBezier:null,sizeHoverPointControl:null,showBezierControl:null,showBezierDuplicateControl:null,sizeBezierControl:null,colorBezierControl:null,colorLineBezierControl:null,showBezierValue:null,colorBezierValue:null,colorTextBezierValue:null,colorShadowBezierValue:null,colorBezierValueOutside:null,colorTextBezierValueOutside:null,colorShadowBezierValueOutside:null,formatColorBezierValue:null,primitiveBezierValue:null,pArgBezierValue:null,formatBezierValue:null,showBezierScale:null,colorBezierScale:null,colorTextBezierScale:null,colorTextMarginsBezierScale:null,showBezierScaleControl:null,bezierScaleX:null,bezierScaleRangeX:null,bezierScaleY:null,bezierScaleRangeY:null,colorBezierScaleControl:null,highlightBezierScaleProgress:null,showBezierCoord:null,clipBezier:null,restrictBezier:null},e.p1h="bezier.p1.hover",e.p2h="bezier.p2.hover",e.sph="bezier.sp.hover",e.prototype.init=function(t,i){this.oBezier=new n.G.Bezier,this.oBezier.onchange={callback:this.onChange,thisArg:this},this.rtBezierP1=null,this.rtBezierP2=null,this.rtBezierP1Duplicate=null,this.rtBezierP2Duplicate=null,this.oO=n.Mrg(n.Cpy(e.Options),i),this.Shortcuts=null,this.oSts=null,this.oBezierScale={x:.1,y:.1},this.rtBezierScalePoint=null,this.rgMeasureBezierValue=null,this.oMeasureBezierScaleTime=null,this.oMeasureBezierScaleProgress=null,this.oBezierValueExpr=null,this.oColorBezierValueExpr=null,this.canvas=null,this.client=null,this.Listeners=null,this.oLts=null,this.iLts(),this.SetClientRect(t),this.SetOptions(this.oO),n.CC.GetCanvas(t)&&this.SetCanvas(t),n.DPR.Reg(this)},n.SB.addProto(e.prototype),e.prototype.GetOption=function(t){function i(e,t){if(null!=e){var i=e[t];if(null!=i)return i}}var r=i(this.oO,t);return null==r&&(void 0!==this.oDefOpts&&(r=i(this.oDefOpts,t)),null==r&&(r=e.Options[t])),r},e.prototype.opt=function(e,t){var i=this.GetOption(e);return null==i&&null==(i=n.Def.Bezier[e])&&(i=t),i},e.prototype.SetOptions=function(e){this.oO=n.Mrg(this.oO,e),this.oO&&this.oO.bezierCoord&&this.SetBezierCoord(this.oO.bezierCoord),this.updateBezierScale(),this.inv()},e.prototype.GetOptions=function(){return this.oO},e.prototype.GetCanvas=function(){var e=this.canvas;return n.CC.GetCanvas(e)?e:null},e.prototype.SetCanvas=function(e,t){this.udefSts(this.oSts),this.oSts=null,this.resAO(),e=n.CC.GetCanvas(e),!t&&n.CC.SetCanvas(this,e),this.canvas=e,n.CC.GetCanvas(this.canvas)&&this.defSts(this.Shortcuts=this.oSts=new n.Sts)},n.ComboBox&&(e.prototype.dCBl=function(e,t){this.drawBezier(e,t),this.showBezierCoord()&&this.drawBezierCoord(e,t,0)},e.prototype.sCB=function(e){return e&&this.SetOptions({bezierCoord:[0,0,1,1]}),!this.oBezier.isL()},e.prototype.SetCanvas=function(e,t){return n.ComboBox.implExHost(e,"onchange")}(e.prototype.SetCanvas)),e.prototype.SetClientRect=function(e){var t=n.CC.GetCanvas(e);t&&(e=[0,0,t.width,t.height]),this.client=n.C2R(e),this.visAO()||this.resAO()},e.prototype.GetClientRect=function(){return this.client.slice()},e.prototype.GetClientBezier=function(e){var t=(e=e||this.GetClientRect()).slice(),r=[0,0,0,0];if(this.showBezierControl()){var o=this.sizeBezierControl(),n=o[0],l=o[1];r[0]=i(r[0],n/2),r[1]=i(r[1],n/2),r[2]=i(r[2],l/2),r[3]=i(r[3],l/2)}return this.showBezierValue()&&null!=this.rgMeasureBezierValue&&(r[0]=i(r[0],this.rgMeasureBezierValue[0].width/2+4),r[3]=i(r[3],this.rgMeasureBezierValue[0].height/2+4),r[1]=i(r[1],this.rgMeasureBezierValue[1].width/2+4),r[2]=i(r[2],this.rgMeasureBezierValue[1].height/2+4)),this.showBezierScale()&&(null!=this.oMeasureBezierScaleTime&&(r[1]=i(r[1],this.oMeasureBezierScaleTime.width/2),r[3]+=this.oMeasureBezierScaleTime.height+4),null!=this.oMeasureBezierScaleProgress&&(r[0]+=this.oMeasureBezierScaleProgress.width+4)),t[0]+=r[0],t[1]+=r[1],t[2]-=r[0]+r[2],t[3]-=r[1]+r[3],t},e.prototype.showBezierCoord=function(){return this.opt("showBezierCoord",!0)},e.prototype.getBezierCoord=function(){var e="[",t="";return this.oBezier.GetP12().forEach(function(e){t.length&&(t+=", "),t+=n.Format(e)}),e+=t,e+="]"},e.prototype.drawBezierCoord=function(e,t,i){var r=this.oBezier.GetName();null==r?r="":(r=""+r+"",r+="\n"),r+=this.getBezierCoord(),e.drawHTMLText(r,n.IRt(t.slice(),-4,-4),n.ToI(i,262170))},e.prototype.clipBezier=function(){return this.opt("clipBezier",!1)},e.prototype.initMeasureBezier=function(e){this.showBezierValue()&&(this.rgMeasureBezierValue=[],this.rgMeasureBezierValue.push(this.measureBezierValue(e,this.getBezierValue(0))),this.rgMeasureBezierValue.push(this.measureBezierValue(e,this.getBezierValue(1)))),this.showBezierScale()&&(this.oMeasureBezierScaleTime=this.measureBezierScaleTime(e,this.getBezierScaleTime(1)),this.oMeasureBezierScaleProgress=this.measureBezierScaleProgress(e,this.getBezierScaleProgress(1)))},e.prototype.draw=function(e,t,i){if(this.rtBezierP1=null,this.rtBezierP2=null,this.rtBezierP1Duplicate=null,this.rtBezierP2Duplicate=null,this.rtBezierScalePoint=null,e&&!n.EyR(t)){this.initMeasureBezier(e);var r=this.GetClientBezier(t);if(!n.EyR(r)){null!=i&&(this.oDefOpts=this.GetOptions(),this.SetOptions(i));var o=this.showBezierScale(),l=this.showBezierValue(),s=this.clipBezier();s&&e.selClip(t),o&&this.drawBezierScale(e,r),this.drawBezier(e,r),l&&this.drawBezierValue(e,r),this.showBezierScaleControl()&&this.drawBezierScaleControl(e,r),this.showBezierControl()&&this.drawBezierControl(e,t,r),this.showBezierCoord()&&this.drawBezierCoord(e,r),s&&e.resClip(),void 0!==this.oDefOpts&&(this.SetOptions(this.oDefOpts),this.oDefOpts=void 0)}}},e.prototype.convertBezierToView=function(e,t){return{x:(t=t||this.GetClientBezier())[0]+e.x*t[2],y:t[1]+(1-e.y)*t[3]}},e.prototype.convertViewToBezier=function(e,t){var i=this.GetClientBezier(),r=this.convertBezierToView({x:0,y:0},i);return{x:e=(e-r.x)/i[2],y:t=-(t-r.y)/i[3]}},e.prototype.sizeBezierControl=function(){return this.opt("sizeBezierControl",[8,8])},e.prototype.getControlViewPointToRect=function(e){var t=this.sizeBezierControl();return n.RRt(n.G.C2R(e,t[0],t[1]))},e.prototype.sizeHoverPointControl=function(){return this.opt("sizeHoverPointControl",2)},e.prototype.showBezierControl=function(){return!this.isLocked()&&!!this.opt("showBezierControl",!0)},e.prototype.showBezierDuplicateControl=function(){return!this.isLocked()&&this.opt("showBezierDuplicateControl",!0)},e.prototype.colorBezierControl=function(){return this.opt("colorBezierControl","#404040")},e.prototype.colorLineBezierControl=function(){return this.opt("colorLineBezierControl","#808080")},e.prototype.drawBezierControl=function(t,i,r){function l(e,i){n.D.P.fill(t,e,i,"Ellipse")}var s=this.colorBezierControl(),a=this.colorLineBezierControl(),u=t.gAO();t.saveSts("lineDash"),t.setLineDash([2,2]);var h=this.convertBezierToView({x:0,y:0},r),c=this.convertBezierToView(this.oBezier.GetP1(),r);o(t,h.x,h.y,c.x,c.y,a),this.rtBezierP1=this.getControlViewPointToRect(c);var z=this.rtBezierP1;if(u){null!=(y=u.get(this,e.p1h))&&(z=n.R.RectInc(y.state,y.range,z,this.sizeHoverPointControl()))}l(z,s);var p=this.convertBezierToView({x:1,y:1},r),B=this.convertBezierToView(this.oBezier.GetP2(),r);o(t,p.x,p.y,B.x,B.y,a),this.rtBezierP2=this.getControlViewPointToRect(B);var f=this.rtBezierP2;if(u){var y=u.get(this,e.p2h);null!=y&&(f=n.R.RectInc(y.state,y.range,f,this.sizeHoverPointControl()))}if(l(f,s),t.loadSts(),this.rtBezierP1Duplicate=null,this.rtBezierP2Duplicate=null,this.showBezierDuplicateControl()){var S=t.globalAlpha;if(this.clipBezier()||(t.globalAlpha=.5),!n.PInR(c.x,c.y,i)){var v=n.G.RDir(h,c.x-h.x,c.y-h.y,i);null!=v&&(this.rtBezierP1Duplicate=this.getControlViewPointToRect(v),l(this.rtBezierP1Duplicate,s))}if(!n.PInR(B.x,B.y,i)){var d=n.G.RDir(p,B.x-p.x,B.y-p.y,i);null!=d&&(this.rtBezierP2Duplicate=this.getControlViewPointToRect(d),l(this.rtBezierP2Duplicate,s))}t.globalAlpha=S}},e.prototype.sizeBezier=function(){return this.opt("sizeBezier",3)},e.prototype.colorBezier=function(){return this.opt("colorBezier","black")},e.prototype.drawBezier=function(e,t){!function(e,t,i,r){var o;t&&e&&((o=e.exontrol=e.exontrol||{}).ll1x=o.ll1x||0,o.ll1x++),i&&i.call(r),o&&--o.ll1x}(e,!0,function(){var i=t[0],r=t[1],o=t[2],n=t[3];e.saveSts("lineWidth","strokeStyle"),e.lineWidth=this.sizeBezier(),e.strokeStyle=this.colorBezier(),e.beginPath();for(var l=i,s=i+o;l<=s;l++){var a=(l-i)/o,u=r+(1-this.oBezier.Get(a))*n;l===i?e.moveTo(l,u):e.lineTo(l,u)}e.stroke(),e.closePath(),e.loadSts()},this)},e.prototype.AdjustBezierPointToScaleView=function(e){var t=this.GetBezierScale();return e.x=t.x*Math.round(e.x/t.x),e.y=t.y*Math.round(e.y/t.y),e},e.prototype.restrictBezier=function(){return this.opt("restrictBezier",!1)},e.prototype.onChange=function(e,t){this.onchange({point:e,bezier:t})},e.prototype.onchange=function(e){this.oLts.onchange.do(e)},e.prototype.GetBezierCoord=function(){return this.oBezier.GetP12()},e.prototype.SetBezierCoord=function(e){this.oBezier.SetP12(e)},e.prototype.GetBezierP=function(e){switch(e){case 1:return this.oBezier.GetP1();case 2:return this.oBezier.GetP2()}return null},e.prototype.SetBezierP=function(e,t){switch(this.restrictBezier()&&(t.x=n.G.Bezier.adjustX(t.x),t.y=n.G.Bezier.adjustX(t.y)),e){case 1:this.oBezier.SetP1(t);break;case 2:this.oBezier.SetP2(t)}},e.prototype.bezierScaleRange=function(e){var t=e;if(null!=t&&(t.min||t.max)){if(null!=t.min&&(t.min=i(0,~~t.min)),null!=t.max&&(t.max=i(0,~~t.max)),null!=t.min&&null!=t.max){var o=r(t.min,t.max),n=i(t.min,t.max);t.min=o,t.max=n}return t}return null},e.prototype.bezierScaleX=function(){return i(0,n.ToI(this.opt("bezierScaleX",10),10))},e.prototype.bezierScaleRangeX=function(){return this.bezierScaleRange(this.opt("bezierScaleRangeX",{min:1,max:100}))},e.prototype.limitBezierScaleX=function(e){var t=this.bezierScaleRangeX();return null!=t&&(null!=t.min&&(e=i(t.min,e)),null!=t.max&&(e=r(t.max,e))),i(1,e)},e.prototype.bezierScaleY=function(){return i(0,n.ToI(this.opt("bezierScaleY",10),10))},e.prototype.bezierScaleRangeY=function(){return this.bezierScaleRange(this.opt("bezierScaleRangeY",{min:1,max:100}))},e.prototype.limitBezierScaleY=function(e){var t=this.bezierScaleRangeY();return null!=t&&(null!=t.min&&(e=i(t.min,e)),null!=t.max&&(e=r(t.max,e))),i(1,e)},e.prototype.updateBezierScale=function(){var e={x:1/this.limitBezierScaleX(this.bezierScaleX()),y:1/this.limitBezierScaleY(this.bezierScaleY())};this.SetBezierScale(e)},e.prototype.GetBezierScale=function(){var e=this.oBezierScale;return{x:e.x,y:e.y}},e.prototype.SetBezierScale=function(e){e.x=r(1,i(e.x,0)),e.y=r(1,i(e.y,0));var t=this.GetClientRect();if(!n.EyR(t)){var o=t[2],l=t[3],s=Math.round(o/i(1,e.x*o));s=this.limitBezierScaleX(s),e.x=1/s;var a=Math.round(l/i(1,e.y*l));a=this.limitBezierScaleY(a),e.y=1/a}return this.oBezierScale=e},e.prototype.IncBezierScale=function(e,t){var r=this.GetBezierScale(),o=this.GetBezierScale();0!=(e=~~e)&&(r.x=1/i(1/r.x+e)),0!=(t=~~t)&&(r.y=1/i(1/r.y+t)),this.SetBezierScale(r);var n=this.GetBezierScale();return o.x!=n.x||o.y!=n.y},e.prototype.getTfi=function(){return this.opt("tfi")},e.prototype.showBezierScaleControl=function(){return!this.isLocked()&&this.opt("showBezierScaleControl",!0)},e.prototype.colorBezierScaleControl=function(){return this.opt("colorBezierScaleControl","black")},e.prototype.drawBezierScaleControl=function(t,i){var r=this.colorBezierScaleControl();this.rtBezierScalePoint=this.getControlViewPointToRect(this.convertBezierToView(this.GetBezierScale(),i));var o=this.rtBezierScalePoint,l=t.gAO();if(l){var s=l.get(this,e.sph);null!=s&&(o=n.R.RectInc(s.state,s.range,o,this.sizeHoverPointControl()))}n.D.P.fill(t,o,r,"RoundRect",{x:2,y:2})},e.prototype.showBezierScale=function(){return this.opt("showBezierScale",!0)},e.prototype.colorTextBezierScale=function(){return this.opt("colorTextBezierScale","#A0A0A0")},e.prototype.colorTextMarginsBezierScale=function(){return this.opt("colorTextMarginsBezierScale","black")},e.prototype.colorBezierScale=function(){return this.opt("colorBezierScale","rgba(0,0,0,.10)")},e.prototype.highlightBezierScaleProgress=function(){return this.opt("highlightBezierScaleProgress",!0)},e.prototype.getBezierScaleTime=function(e){var t=Math.round(1*e/this.GetBezierScale().x);return{x:e,value:t,sValue:t.toString()}},e.prototype.measureBezierScaleTime=function(e,t){var i=e.sizeHTMLText(t.sValue);return{width:i.width+4,height:i.height+4}},e.prototype.getBezierScaleProgress=function(e){var t=Math.round(1*e/this.GetBezierScale().y);return{y:e,value:t,sValue:t.toString()}},e.prototype.measureBezierScaleProgress=function(e,t){var i=e.sizeHTMLText(t.sValue);return{width:i.width+4,height:i.height+4}},e.prototype.drawBezierScale=function(e,t){var i=t[0],r=t[1],l=t[2],s=t[3],a=this.colorBezierScale(),u=this.colorTextBezierScale(),h=this.colorTextMarginsBezierScale();e.save(),e.setLineDash([1,1]);var c=this.convertBezierToView({x:0,y:0}),z=this.convertBezierToView({x:1,y:0}),p=this.GetBezierScale(),B=(z.x-c.x)*p.x,f=null,y=8,S=null;if(B>0){var v=this.convertBezierToView({x:0,y:0}),d=this.convertBezierToView({x:0,y:1}),g=(v.y-d.y)*p.y;if(g>0){var C=this.highlightBezierScaleProgress(),x=null;C&&(x=new n.Arr);for(var w=Math.round(l/B),V=Math.round(s/g),f=null,y=8,S=null,P=0,m=c.x,T=0;T<=w;m+=B,T++,P+=p.x){var b=0==T,G=T==w;if(null==f||f+y"+O+"",(b||G)&&(O=""+O+"");var D=this.measureBezierScaleTime(e,M),k=n.G.C2R([m,R+4],D.width,D.height,18);(null==S||n.EyR(n.NRt(S,k))||b||G)&&(e.drawHTMLText(O,k,n.DrawTextFormatEnum.exTextAlignCenter),S=k)}if(C){var A=this.oBezier.Get(P),E=Math.round(V*n.G.Bezier.adjustX(A));x.add(E)}}e.drawEdge(t,8,u);for(var L=null,F=null,I=0,m=v.y,T=0;T<=V;m-=g,T++,I+=p.y){var b=0==T,G=T==V;if(null==L||L-y>m||b||G){var X=i-8;o(e,X,m,i+l+8,m,a),L=m}var H=this.getBezierScaleProgress(I),Y=H.sValue,j=b||G,N=!j;null!=x&&x.has(T)&&(j=!0,N=!1),j&&(Y=""+(Y=""+Y+"")+""),N&&(Y=""+Y+"");var W=this.measureBezierScaleProgress(e,H),K=n.G.C2R([X,m],W.width,W.height,36);(null==F||n.EyR(n.NRt(F,K))||b||G)&&(e.drawHTMLText(Y,K,n.DrawTextFormatEnum.exTextAlignCenter|n.DrawTextFormatEnum.exTextAlignVCenter),F=K)}e.drawEdge(t,1,u)}}e.restore()},e.prototype.showBezierValue=function(){return this.opt("showBezierValue",!0)},e.prototype.colorBezierValue=function(){return n.C.Convert(this.opt("colorBezierValue","#FFFF00"))},e.prototype.colorTextBezierValue=function(){return this.opt("colorTextBezierValue","black")},e.prototype.colorShadowBezierValue=function(){return this.opt("colorShadowBezierValue","#808080")},e.prototype.colorBezierValueOutside=function(){return n.C.Convert(this.opt("colorBezierValueOutside","#FFFF00"))},e.prototype.colorTextBezierValueOutside=function(){return this.opt("colorTextBezierValueOutside","black")},e.prototype.colorShadowBezierValueOutside=function(){return this.opt("colorShadowBezierValueOutside","#808080")},e.prototype.primitiveBezierValue=function(){return this.opt("primitiveBezierValue","Ellipse")},e.prototype.pArgBezierValue=function(){return this.opt("pArgBezierValue",null)},e.prototype.formatBezierValue=function(){return this.opt("formatBezierValue","` ` + round( (value MIN 0 MAX 1) * scale) + ` `")},e.prototype.getFormatBezierValue=function(e){var t=this.formatBezierValue(),i=1/this.GetBezierScale().y;if(null!=t){var r=this.oBezierValueExpr;if(null!=r&&r.GetExpr()==t||(r=n.E.Create(t,"value,scale"),this.oBezierValueExpr=r),r.IsValid())return r.Evaluate(function(t){switch(t){case-1:return e;case-2:return i}})}return" "+Math.round(i*n.G.Bezier.adjustX(e))+" "},e.prototype.getBezierValue=function(e){var t=this.oBezier.Get(e);return{x:e,value:t,sValue:this.getFormatBezierValue(t).toString()}},e.prototype.measureBezierValue=function(e,t){var r=e.sizeHTMLText(t.sValue),o=Math.round(3*this.sizeBezier()/2)+1,n=r.width+o,l=r.height+o;l=n=i(l,n);return{width:Math.round(n),height:Math.round(l)}},e.prototype.formatColorBezierValue=function(){return this.opt("formatColorBezierValue","round( color/2 + (color/2 * value))")},e.prototype.getFormatColorBezierValue=function(e,t){var i=this.formatColorBezierValue();this.GetBezierScale().y;if(null!=i){var r=this.oColorBezierValueExpr;if(null!=r&&r.GetExpr()==i||(r=n.E.Create(i,"value,color"),this.oColorBezierValueExpr=r),r.IsValid())return r.Evaluate(function(i){switch(i){case-1:return e;case-2:return t}})}return Math.round(t/2+t/2*e)},e.prototype.drawBezierValue=function(e,t){function i(e,t){return r.getFormatColorBezierValue(e,t)}var r=this,o=(t[0],t[1]),l=t[2],s=t[3],a=this.convertBezierToView({x:0,y:0}),u=this.convertBezierToView({x:1,y:0}),h=this.GetBezierScale(),c=(u.x-a.x)*h.x,z=null;if(c>0){var p=this.convertBezierToView({x:0,y:0}),B=this.convertBezierToView({x:0,y:1});if((p.y-B.y)*h.y>0){var f=this.colorBezierValue(),y=this.colorTextBezierValue(),S=this.colorShadowBezierValue(),v=this.colorBezierValueOutside(),d=this.colorTextBezierValueOutside(),g=this.colorShadowBezierValueOutside(),C=this.primitiveBezierValue(),x=this.pArgBezierValue();e.saveSts("fillStyle","strokeStyle"),e.strokeStyle=e.fillStyle=y;for(var w=Math.round(l/c),V=0,V=0,P=a.x,m=0;m<=w;P+=c,m++,V+=h.x){var T=0==m,b=m==w,G=this.getBezierValue(V),R=this.measureBezierValue(e,G),M=n.G.C2R([P,o+(1-G.value)*s],R.width,R.height);if(null==z||n.EyR(n.NRt(z,M))||T||b){var O=G.value<0||G.value>1,D=O?v:f;if(!D.IsTrans()){var k="rgb("+i(G.value,D.r)+","+i(G.value,D.g)+","+i(G.value,D.b)+")";n.D.P.fillS(e,M,k,O?g:S,{blur:8,x:0,y:0},C,x)}var A=null;O&&(A=e.fillStyle,e.strokeStyle=e.fillStyle=d),e.drawHTMLText(G.sValue,M,n.DrawTextFormatEnum.exTextAlignCenter|n.DrawTextFormatEnum.exTextAlignVCenter),null!=A&&(e.strokeStyle=e.fillStyle=A),z=M}}e.loadSts()}}},e.prototype.bezierControlFromPoint=function(e){var t=n.G.X(e),i=n.G.Y(e);return null!=this.rtBezierP1&&n.PInfR(t,i,this.rtBezierP1)?1:null!=this.rtBezierP1Duplicate&&n.PInfR(t,i,this.rtBezierP1Duplicate)?1:null!=this.rtBezierP2&&n.PInfR(t,i,this.rtBezierP2)?2:null!=this.rtBezierP2Duplicate&&n.PInfR(t,i,this.rtBezierP2Duplicate)?2:null},e.prototype.bezierScaleFromPoint=function(e){var t=n.G.X(e),i=n.G.Y(e);return!(null==this.rtBezierScalePoint||!n.PInfR(t,i,this.rtBezierScalePoint))},e.prototype.onClickBezierScale=function(e,t){n.RUR.Do(e,function(e){switch(e.drag.status){case 1:this.save=this.GetBezierScale();break;case 0:null!=this.save&&(this.SetBezierScale(this.save),delete this.save,this.inv());break;case 2:var t=e.drag.current,r=this.convertViewToBezier(t.x,t.y);if(e.drag.long||e.ctrlKey||e.altKey){var o=i(r.x,r.y);r.x=o,r.y=o}this.SetBezierScale(r),this.inv()}},this)},e.prototype.onClickBezierControl=function(e,t){var i=t.code;n.RUR.Do(e,function(e){switch(e.drag.status){case 1:this.save=this.GetBezierP(i);break;case 0:null!=this.save&&(this.SetBezierP(i,this.save),delete this.save,this.inv());break;case 2:var t=e.drag.current,r=this.convertViewToBezier(t.x,t.y);(e.drag.long||e.ctrlKey||e.altKey)&&(r=this.AdjustBezierPointToScaleView(r)),this.SetBezierP(i,r),this.inv()}},this)},e.prototype.onmousemove=function(e){var t,i=this.hitTest(this.gPtr(e));return!!i&&(i.cursor&&(t=this.GetCanvas())&&(t.style.cursor=i.cursor),!0)},e.prototype.onwheel=function(e){if(this.isSelectable()){var t=this.gPtr(e);if(null!=t&&n.PInR(t.x,t.y,this.GetClientRect()))return this.dowheel(e)}return!1},e.prototype.dowheel=function(e){var t=n.WhelInc(e);if(t){var i=this.getWheelChange();if(i&&this.showBezierScaleControl()){var r=t<0?-i:i;if(this.IncBezierScale(r,r))return this.inv(),!0}}return!1},e.prototype.oncontextmenu=function(e){var t=this.gPtr(e);return null!=t&&n.PInR(t.x,t.y,this.GetClientRect()),!1},e.prototype.ondown=function(e){var t=this.gPtr(e),i=this.hitTest(t);return null!=i&&(i.callback instanceof Function&&i.callback.call(i.thisArg,e,i),!0)},e.prototype.onkeydown=function(e){this.onkey(e,-1)},e.prototype.onkeyup=function(e){this.onkey(e,0)},e.prototype.onkeypress=function(e){this.onkey(e,1)},e.prototype.onkey=function(e,t){null!=this.oSts&&this.oSts.onkey(e,t)},e.prototype.onlayout=function(e){if(e.IsSave())e.Add("p12",this.oBezier.GetP12()),e.Add("x-scale",this.oBezierScale.x),e.Add("y-scale",this.oBezierScale.y);else{var t=e.GetValue("p12");null!=t&&this.oBezier.SetP12(t);var i=e.GetValue("x-scale");null!=i&&(this.oBezierScale.x=i);var r=e.GetValue("y-scale");null!=r&&(this.oBezierScale.y=r)}},e.prototype.udefSts=function(e){e&&e.RemoveOf(this)},e.prototype.defSts=function(e){},e.prototype.iLts=function(){this.Listeners=this.oLts=new n.Lts,this.oLts.add("onchange")},e.prototype.hitTest=function(e){var t=null;if(null!=e&&this.isSelectable()){var i=this.bezierControlFromPoint(e);i?t={cursor:"pointer",code:i,callback:this.onClickBezierControl,thisArg:this}:this.bezierScaleFromPoint(e)&&(t={cursor:"pointer",code:!0,callback:this.onClickBezierScale,thisArg:this})}return t},e.prototype.onSetAO=function(t){if(t){0!=this.sizeHoverPointControl()&&(this.showBezierScaleControl()&&!t.has(this,e.sph)&&t.set({owner:this,id:e.sph,inv:this.inv,duration:125,hitTest:function(e,t){return this.isAP(e,t)&&this.bezierScaleFromPoint({x:e,y:t})}}),this.showBezierControl()&&(!t.has(this,e.p1h)&&t.set({owner:this,id:e.p1h,inv:this.inv,duration:125,hitTest:function(e,t){return this.isAP(e,t)&&1==this.bezierControlFromPoint({x:e,y:t})}}),!t.has(this,e.p2h)&&t.set({owner:this,id:e.p2h,inv:this.inv,duration:125,hitTest:function(e,t){return this.isAP(e,t)&&2==this.bezierControlFromPoint({x:e,y:t})}})))}},e.prototype.getLocked=function(){return this.opt("locked",!1)||this.opt("readOnly",!1)},e.prototype.getWheelChange=function(){return this.opt("wheelChange",1)},Object.defineProperty(e.prototype,"Options",{get:function(){return this.GetOptions()},set:function(e){this.SetOptions(e)},configurable:!0}),{Bezier:e}}()),e.Bezier=n.Bezier});