/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as o}from"tslib";import i from"../../core/Accessor.js";import{createTask as e}from"../../core/asyncUtils.js";import{throwIfAborted as t}from"../../core/promiseUtils.js";import{property as s,subclass as a}from"../../core/accessorSupport/decorators.js";import{meshToGraphic as r}from"./utils.js";let m=class extends i{constructor(o){super(o),this._zoomTask=null,this.panoramicZoomViewModel=null,this._updateGraphicsFromTiles=async(o,i,e,s,a)=>{const m=await Promise.all(o.map(async o=>{const i=await o.loadMesh(a);return r(i)}));t(a);const n=s.removeAll();i.clear(),m.forEach((e,t)=>{const s=o[t].key;e.attributes={key:s},i.add(s)}),s.addMany(m),this.viewModel?.set({imagePyramidLevel:e}),this.viewModel?.addManyGraphics(m),this.viewModel?.removeManyGraphics(n)},this._zoomIn=async o=>{if(t(o),!this.viewModel)return this.panoramicZoomViewModel.zoomInFOV();const{imagePyramid:i,yaw:e,hfov:s,vfov:a,pitch:r,tileCache:m,currentGraphics:n,imageRenderer:{size:l},imagePyramidLevel:c}=this.viewModel;if(!i)return this.panoramicZoomViewModel.zoomInFOV();const h=s/l[0],d=i.getLevelWithPixelAngle(h);if(0===c||c===d)return this.panoramicZoomViewModel.zoomInFOV();const p=i.getTiles(d,e,r,s,a);return p?(await this._updateGraphicsFromTiles(p,m,d,n,{signal:o}),this.panoramicZoomViewModel.zoomInFOV()):this.panoramicZoomViewModel.zoomInFOV()},this._zoomOut=async o=>{if(t(o),!this.viewModel)return this.panoramicZoomViewModel.zoomOutFOV();const{imagePyramid:i,yaw:e,hfov:s,vfov:a,pitch:r,tileCache:m,currentGraphics:n,imagePyramidLevel:l,imageRenderer:{size:c}}=this.viewModel;if(!i)return this.panoramicZoomViewModel.zoomOutFOV();const h=i.maximumPyramidLevel,d=s/c[0],p=i.getLevelWithPixelAngle(d);if(h===l||p===l)return this.panoramicZoomViewModel.zoomOutFOV();const u=i.getTiles(p,e,r,s,a);return u?(await this._updateGraphicsFromTiles(u,m,p,n,{signal:o}),this.panoramicZoomViewModel.zoomOutFOV()):this.panoramicZoomViewModel.zoomOutFOV()},this.zoomIn=o=>{(null==this._zoomTask||this._zoomTask.finished)&&(this._zoomTask=e(this._zoomIn,o))},this.zoomOut=o=>{(null==this._zoomTask||this._zoomTask.finished)&&(this._zoomTask=e(this._zoomOut,o))}}};o([s()],m.prototype,"viewModel",void 0),o([s()],m.prototype,"panoramicZoomViewModel",void 0),m=o([a("esri.widgets.PanoramicViewer.PanoramicZoomManager")],m);export{m as PanoramicZoomManager};
