/*
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"],(function(e,t,n,i,s){"use strict";let r=function(){function e(){}return e.local=function(){return null===e.instance&&(e.instance=new e),e.instance},e.prototype.execute=function(e,t,n,i){return new o(e,t,n)},e}();r.instance=null;let o=function(e){function r(t,n,s){var r;return(r=e.call(this,t,!1,!0)||this)._curveHelper=new i.CurveHelper,r._angleToLine=void 0===n.angleToLine||n.angleToLine,r._offset=void 0!==n.offset?n.offset*s:0,r._type=n.extremityPlacement,r._position=void 0!==n.offsetAlongLine?n.offsetAlongLine*s:0,r._beginProcessed=!1,r}t._inheritsLoose(r,e);var o=r.prototype;return o.processPath=function(e){let t;switch(this._type){case s.ExtremityPlacement.Both:default:this._beginProcessed?(t=this._atExtremities(e,this._position,!1),this._beginProcessed=!1,this.iteratePath=!1):(t=this._atExtremities(e,this._position,!0),this._beginProcessed=!0,this.iteratePath=!0);break;case s.ExtremityPlacement.JustBegin:t=this._atExtremities(e,this._position,!0);break;case s.ExtremityPlacement.JustEnd:t=this._atExtremities(e,this._position,!1);case s.ExtremityPlacement.None:}return t},o._atExtremities=function(e,t,i){const s=e.length;if(s<2)return null;const r=i?1:s-2,o=i?s:-1,l=i?1:-1;let a,c=0,u=i?e[0]:e[s-1];for(let h=r;h!==o;h+=l){a=u,u=e[h];const i=this._curveHelper.calculateLength(a,u);if(c+i>t){const e=(t-c)/i,[s,r]=this._curveHelper.getAngleCS(a,u,e),o=n.getCoord2D(a,u,e);return this.internalPlacement.setTranslate(o[0]-this._offset*r,o[1]+this._offset*s),this._angleToLine&&this.internalPlacement.setRotateCS(-s,-r),this.internalPlacement}c+=i}return null},r}(n.PathTransformationCursor);e.PlacementAtExtremities=r,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
