/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{GeometryCursor as e}from"../../../geometry/GeometryCursor.js";import{PathEffectCursor as t}from"../CIMCursor.js";import{CurveHelper as i}from"../CurveHelper.js";class r{static{this.instance=null}static local(){return null===r.instance&&(r.instance=new r),r.instance}execute(e,t,i){return new n(e,t,i)}}class n extends t{constructor(e,t,r){super(e,!0,!0),this._curveHelper=new i;const n=r?.geomUnitsPerPoint;this._beginCut=(void 0!==t.beginCut?t.beginCut:1)*n,this._endCut=(void 0!==t.endCut?t.endCut:1)*n,this._middleCut=(void 0!==t.middleCut?t.middleCut:0)*n,this._invert=void 0!==t.invert&&t.invert,this._beginCut<0&&(this._beginCut=0),this._endCut<0&&(this._endCut=0),this._middleCut<0&&(this._middleCut=0)}processPath(t){const{_beginCut:i,_endCut:r,_middleCut:n}=this,s=t.pathLength(),u=e.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==i||0!==r||0!==n)if(i+r+n>=s)for(u.startPath();t.nextPoint();)u.pushXY(t.x,t.y);else this._curveHelper.appendSubCurve(u,t,0,i),this._curveHelper.appendSubCurve(u,t,.5*(s-n),.5*(s+n)),this._curveHelper.appendSubCurve(u,t,s-r,r)}else if(0===i&&0===r&&0===n)for(u.startPath();t.nextPoint();)u.pushXY(t.x,t.y);else i+r+n<s&&(0===n?this._curveHelper.appendSubCurve(u,t,i,s-r):(this._curveHelper.appendSubCurve(u,t,i,.5*(s-n)),this._curveHelper.appendSubCurve(u,t,.5*(s+n),s-r)));return 0===u.totalSize?null:u}}export{r as EffectCut};
