/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../core/maybe","../EditGeometry"],(function(e,t,i){"use strict";let r=function(){function e(e,t,i){this.editGeometry=e,this.edge=t,this.t=i,this.createdVertex=null,this.left=null,this.right=null}var r=e.prototype;return r.apply=function(){let e="redo";const r=this.edge,s=r.component,d=r.leftVertex,h=r.rightVertex;s.edges.splice(s.edges.indexOf(r),1),t.isNone(this.createdVertex)&&(e="apply",this.createdVertex=new i.Vertex(r.component)),s.vertices.push(this.createdVertex),this.createdVertex.pos=this.editGeometry.coordinateHelper.lerp(r.leftVertex.pos,r.rightVertex.pos,this.t,this.editGeometry.coordinateHelper.createVector()),t.isNone(this.left)&&(this.left=new i.Edge(s,d,this.createdVertex)),this.left.leftVertex.leftEdge?s.edges.push(this.left):s.edges.unshift(this.left),d.rightEdge=this.left,t.isNone(this.right)&&(this.right=new i.Edge(s,this.createdVertex,h)),s.edges.push(this.right),h.leftEdge=this.right,s.updateVertexIndex(this.createdVertex,d.index+1),this.editGeometry.notifyChanges({operation:e,addedVertices:[this.createdVertex]})},r.undo=function(){if(t.isNone(this.createdVertex)||t.isNone(this.left)||t.isNone(this.right))return null;const e=this.edge,i=e.component,r=this.createdVertex.leftEdge,s=this.createdVertex.rightEdge,d=r.leftVertex,h=s.rightVertex;i.vertices.splice(i.vertices.indexOf(this.createdVertex),1),i.edges.splice(i.edges.indexOf(this.left),1),i.edges.splice(i.edges.indexOf(this.right),1),this.edge.leftVertex.leftEdge?i.edges.push(this.edge):i.edges.unshift(this.edge),d.rightEdge=e,h.leftEdge=e,i.updateVertexIndex(d,d.index),this.editGeometry.notifyChanges({operation:"undo",removedVertices:[this.createdVertex]})},r.accumulate=function(){return!1},e}();e.SplitEdge=r,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
