/*
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","../../../../core/Handles","../../../../core/maybe","../../../../core/reactiveUtils","../../../../core/screenUtils","../../../../chunks/vec2","../../../../chunks/vec3","../../../../chunks/vec3f64","../../../../chunks/vec4","../../../../chunks/vec4f32","./Object3DVisualElement","../../webgl-engine/lib/GeometryUtil","../../webgl-engine/lib/Material","../../webgl-engine/lib/VertexAttribute","../../webgl-engine/materials/RibbonLineMaterial"],(function(e,t,r,i,n,s,a,c,o,l,u,h,d,_,f,m){"use strict";let y=function(e){function s(t){var i;return(i=e.call(this,t)||this)._handles=new r,i._location=o.create(),i._direction=o.fromValues(1,0,0),i._width=1,i._offset=1,i._length=18,i._color=u.fromValues(1,0,1,1),i._renderOccluded=_.RenderOccludedFlag.OccludeAndTransparent,i.applyProps(t),i}t._inheritsLoose(s,e);var h=s.prototype;return h.setDirectionFromPoints=function(e,t){c.normalize(this._direction,c.subtract(this._direction,t,e)),this._updateGeometry()},h.createExternalResources=function(){const e=new m.RibbonLineMaterial(this.materialParameters);this._handles.add(n.watch((()=>this.view.state.camera),(()=>{this._updateGeometry()}))),this._externalResources={material:e}},h.destroyExternalResources=function(){this._handles.removeAll(),this._externalResources=null},h.createGeometries=function(e){const t=d.createPolylineGeometry([o.create(),o.create()]),r=d.createPolylineGeometry([o.create(),o.create()]),n=i.unwrap(this._externalResources).material;e.addGeometry(t,n),e.addGeometry(r,n),this._updateVertices(e)},h.forEachExternalMaterial=function(e){i.isSome(this._externalResources)&&e(this._externalResources.material)},h._updateMaterial=function(){if(i.isNone(this._externalResources))return;this._externalResources.material.setParameters(this.materialParameters)},h._updateGeometry=function(){const e=this.object;i.isNone(e)||this._updateVertices(e)},h._updateVertices=function(e){const t=this.view.state.camera;t.projectToScreen(this.location,g),c.add(p,this.location,this.direction),t.projectToScreen(p,b),a.normalize(b,a.subtract(b,b,g)),this._updateVertexAttributes(t,e,0,g,b,1),this._updateVertexAttributes(t,e,1,g,b,-1)},h._updateVertexAttributes=function(e,t,r,i,n,s){const c=t.geometryRecords[r],o=c.geometry.getMutableAttribute(f.VertexAttribute.POSITION).data,l=a.scale(x,a.set(x,n[1]*s,n[0]*-s),this.offset+this.width/2),u=a.add(w,a.add(w,a.add(w,i,a.scale(w,n,this.length/2)),l),l),h=a.add(P,u,a.scale(P,n,-this.length));e.unprojectFromScreen(u,p),o[0]=p[0],o[1]=p[1],o[2]=p[2],e.unprojectFromScreen(h,p),o[3]=p[0],o[4]=p[1],o[5]=p[2],t.geometryVertexAttrsUpdated(c)},t._createClass(s,[{key:"location",get:function(){return this._location},set:function(e){c.exactEquals(this._location,e)||(c.copy(this._location,e),this._updateGeometry())}},{key:"direction",get:function(){return this._direction},set:function(e){c.exactEquals(this._direction,e)||(c.copy(this._direction,e),this._updateGeometry())}},{key:"width",get:function(){return this._width},set:function(e){e!==this._width&&(this._width=e,this._updateMaterial())}},{key:"offset",get:function(){return this._offset},set:function(e){e!==this._offset&&(this._offset=e,this._updateGeometry())}},{key:"length",get:function(){return this._length},set:function(e){e!==this._length&&(this._length=e,this._updateGeometry())}},{key:"color",get:function(){return this._color},set:function(e){l.exactEquals(e,this._color)||(l.copy(this._color,e),this._updateMaterial())}},{key:"renderOccluded",get:function(){return this._renderOccluded},set:function(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}},{key:"materialParameters",get:function(){return{width:this._width,color:this._color,renderOccluded:this._renderOccluded}}}]),s}(h.Object3DVisualElement);const p=o.create(),g=s.createScreenPointArray(),b=s.createScreenPointArray(),x=s.createScreenPointArray(),w=s.createScreenPointArray(),P=s.createScreenPointArray();e.ParallelLineVisualElement=y,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
