/*
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","../../../../../../chunks/tslib.es6","../../../../../../core/HandleOwner","../../../../../../core/maybe","../../../../../../core/reactiveUtils","../../../../../../core/accessorSupport/decorators/property","../../../../../../core/arrayUtils","../../../../../../core/has","../../../../../../core/accessorSupport/ensureType","../../../../../../core/accessorSupport/decorators/subclass","../../../../layers/support/FeatureTileDescriptor3D","../../../../../interactive/snapping/featureSources/featureServiceSource/tileUtils"],(function(e,t,r,i,o,s,n,l,a,c,u,p,f){"use strict";function v({lij:[e,t,r],extent:i}){return{id:`${e}/${t}/${r}`,level:e,row:t,col:r,extent:i}}e.FeatureServiceTiles3D=function(e){function r(t){var r;return(r=e.call(this,t)||this).pointOfInterest=null,r}t._inheritsLoose(r,e);var i=r.prototype;return i.initialize=function(){this.handles.add(s.watch((()=>this.view.featureTiles),(e=>{this.handles.remove(y),e&&this.handles.add(e.addClient(),y)}),s.initial))},i._filterTiles=function(e){if(o.isNone(e))return[];return e.filter((e=>Math.abs(e.measures.screenRect[3]-e.measures.screenRect[1])>d&&e.measures.visibility===p.Visibility.VISIBLE_ON_SURFACE))},t._createClass(r,[{key:"tiles",get:function(){const e=this.tilesCoveringView,t=this.effectivePointOfInterest;if(o.isSome(t)){const r=e.map((e=>f.distanceToTile(t,e)));for(let i=1;i<r.length;i++)if(r[i-1]>r[i])return e.sort(((e,r)=>f.distanceToTile(t,e)-f.distanceToTile(t,r))),e.slice()}return e}},{key:"tilesCoveringView",get:function(){var e,t;return this._filterTiles(null==(e=this.view.featureTiles)||null==(t=e.tiles)?void 0:t.toArray()).map(v)}},{key:"tileInfo",get:function(){var e,t;return null!=(e=null==(t=this.view.featureTiles)?void 0:t.tilingScheme.toTileInfo())?e:null}},{key:"tileSize",get:function(){var e,t;return null!=(e=null==(t=this.view.featureTiles)?void 0:t.tileSize)?e:256}},{key:"effectivePointOfInterest",get:function(){var e;const t=this.pointOfInterest;return o.isSome(t)?t:null==(e=this.view.pointsOfInterest)?void 0:e.focus.location}}]),r}(i.HandleOwner),r.__decorate([n.property({readOnly:!0})],e.FeatureServiceTiles3D.prototype,"tiles",null),r.__decorate([n.property({readOnly:!0})],e.FeatureServiceTiles3D.prototype,"tilesCoveringView",null),r.__decorate([n.property({readOnly:!0})],e.FeatureServiceTiles3D.prototype,"tileInfo",null),r.__decorate([n.property({readOnly:!0})],e.FeatureServiceTiles3D.prototype,"tileSize",null),r.__decorate([n.property({constructOnly:!0})],e.FeatureServiceTiles3D.prototype,"view",void 0),r.__decorate([n.property()],e.FeatureServiceTiles3D.prototype,"pointOfInterest",void 0),r.__decorate([n.property()],e.FeatureServiceTiles3D.prototype,"effectivePointOfInterest",null),e.FeatureServiceTiles3D=r.__decorate([u.subclass("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiles3D")],e.FeatureServiceTiles3D);const d=50,y="feature-tiles";Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
