/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../CIMCursor","../CurveHelper","../enums","../GeometryWalker"],(function(t,e,s,n,i,a){"use strict";let r=function(){function t(){}return t.local=function(){return null===t.instance&&(t.instance=new t),t.instance},t.prototype.execute=function(t,e,s,n){return new h(t,e,s)},t}();r.instance=null;let h=function(t){function s(e,s,n){var i,r,h;return(h=t.call(this,e,!0,!0)||this)._walker=new a.GeometryWalker,h._walker.updateTolerance(n),h._endings=s.lineDashEnding,h._customDashPos=-(null!=(i=s.offsetAlongLine)?i:0)*n,h._offsetAtEnd=(null!=(r=s.customEndingOffset)?r:0)*n,h._pattern=new a.DashPattern,h._pattern.init(s.dashTemplate,!0),h._pattern.scale(n),h}return e._inheritsLoose(s,t),s.prototype.processPath=function(t){if(0===this._pattern.length())return this.iteratePath=!1,{paths:[t]};if(!this.iteratePath){let e=!0;switch(this._endings){case i.LineDashEnding.HalfPattern:case i.LineDashEnding.HalfGap:default:this._pattern.extPtGap=0;break;case i.LineDashEnding.FullPattern:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.firstValue());break;case i.LineDashEnding.FullGap:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.lastValue());break;case i.LineDashEnding.NoConstraint:this.isClosed||(e=!1);break;case i.LineDashEnding.Custom:this.isClosed||(this._pattern.extPtGap=.5*this._offsetAtEnd)}const s=this._walker.calculatePathLength(t);if(this._pattern.isEmpty()||s<.1*this._pattern.length())return{paths:[t]};if(!this._walker.init(t,this._pattern,e))return{paths:[t]}}let e;if(this.iteratePath)e=this._pattern.nextValue();else{let t;switch(this._endings){case i.LineDashEnding.HalfPattern:default:t=.5*this._pattern.firstValue();break;case i.LineDashEnding.HalfGap:t=.5*-this._pattern.lastValue();break;case i.LineDashEnding.FullGap:t=-this._pattern.lastValue();break;case i.LineDashEnding.FullPattern:t=0;break;case i.LineDashEnding.NoConstraint:case i.LineDashEnding.Custom:t=-this._customDashPos}let s=t/this._pattern.length();s-=Math.floor(s),t=s*this._pattern.length(),this._pattern.reset(),e=this._pattern.nextValue();let n=!1;for(;t>=e;)t-=e,e=this._pattern.nextValue(),n=!n;e-=t,n?(this._walker.nextPosition(e),e=this._pattern.nextValue()):this.isClosed&&(this._firstCurve=this._walker.nextCurve(e),e=this._pattern.nextValue(),this._walker.nextPosition(e),e=this._pattern.nextValue())}let s=this._walker.nextCurve(e);return s?this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(this._firstCurve.splice(0,1),n.PathHelper.mergePath(s,this._firstCurve),this._firstCurve=null)):(e=this._pattern.nextValue(),!this._walker.nextPosition(e)||this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(s=this._firstCurve,this._firstCurve=null)):this.iteratePath=!0):(this.iteratePath=!1,s=this._firstCurve,this._firstCurve=null),{paths:[s]}},s}(s.PathGeometryCursor);t.EffectDashes=r,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
