// All material copyright ESRI, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.7/esri/copyright.txt for details. //>>built define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper dojo/dom dojo/dom-construct dojo/on ../core/Accessor ../core/Evented ../core/Handles ../core/scheduling ../core/watchUtils ../core/accessorSupport/decorators ./PopupManager ./overlay/ViewOverlay ../widgets/Popup".split(" "),function(z,A,u,f,m,k,v,w,x,y,n,l,e,p,q,r){var h=[0,0];return function(t){function b(){var a=t.call(this)||this;a._domHandles=new y;a._freqInfo={freq:16,time:750};a._overlayRenderTaskHandle= null;a.height=0;a.popup=new r({view:a});a.position=null;a.resizing=!1;a.root=null;a.surface=null;a.suspended=!0;a.ui=null;a.userContent=null;a.width=0;a.watch("cursor",function(d){var c=a.surface;c&&c.setAttribute("data-cursor",d)});a.watch("interacting",function(d){var c=a.surface;c&&c.setAttribute("data-interacting",d.toString())});a._focusEvent=a._focusEvent.bind(a);a._blurEvent=a._blurEvent.bind(a);return a}u(b,t);b.prototype.initialize=function(){this.watch("ui",this._handleUIChange);this._wireUI(this.ui)}; b.prototype.destroy=function(){this.ui.destroy();this.popup&&!this.popup.destroyed&&this.popup.destroy();this.container=null;this._domHandles.destroy()};Object.defineProperty(b.prototype,"container",{set:function(a){var d=this,c=this._get("container");if(c!==a){this._domHandles.remove("dom-size");this._stopMeasuring();if(c){var b=this.surface;b&&(b.removeEventListener("focus",this._focusEvent),b.removeEventListener("blur",this._blurEvent));c.classList.remove("esri-view");this.popupManager.destroy(); this._set("popupManager",null);this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null);this.overlay.destroy();this._set("overlay",null);k.destroy(this.root);this._set("root",null);k.destroy(this.userContent);this._set("userContent",null)}if(a){a.classList.add("esri-view");c=document.createElement("div");for(c.className="esri-view-user-storage";a.hasChildNodes();)c.appendChild(a.firstChild);a.appendChild(c);c=document.createElement("div");c.className= "esri-view-root";a.insertBefore(c,a.firstChild);this._set("root",c);var g=document.createElement("div");g.className="esri-view-surface";g.setAttribute("role","application");g.tabIndex=0;g.addEventListener("focus",this._focusEvent);g.addEventListener("blur",this._blurEvent);m.setSelectable(g,!1);c.appendChild(g);this._set("surface",g);b=new q;c.appendChild(b.surface);this._set("overlay",b);b.watch("needsRender",function(a){a&&!d._overlayRenderTaskHandle?d._overlayRenderTaskHandle=n.addFrameTask({render:function(){d.overlay.render()}}): d._overlayRenderTaskHandle&&(d._overlayRenderTaskHandle.remove(),d._overlayRenderTaskHandle=null)});this._forceReadyCycle();this._domHandles.add(l.init(this,"size",function(a){var c=a[1];g.classList.toggle("esri-view-surface--inset-outline",a[0]>=document.body.clientWidth||c>=document.body.clientHeight)}),"dom-size");this._set("container",a);this._startMeasuring();a=new p({enabled:!0,view:this});this._set("popupManager",a)}else this._set("width",0),this._set("height",0),this._set("position",null), this._set("suspended",!0),this._set("surface",null),this._set("container",null)}},enumerable:!0,configurable:!0});Object.defineProperty(b.prototype,"focused",{get:function(){return document.activeElement===this.surface},enumerable:!0,configurable:!0});Object.defineProperty(b.prototype,"size",{get:function(){return[this.width,this.height]},enumerable:!0,configurable:!0});b.prototype.blur=function(){this.surface&&this.surface.blur()};b.prototype.focus=function(){this.surface&&this.surface.focus()}; b.prototype.pageToContainer=function(a,b,c){var d=this.position;a-=d[0];b-=d[1];c?(c[0]=a,c[1]=b):c=[a,b];return c};b.prototype.containerToPage=function(a,b,c){var d=this.position;a+=d[0];b+=d[1];c?(c[0]=a,c[1]=b):c=[a,b];return c};b.prototype._handleUIChange=function(a,b){b&&(this._domHandles.remove("ui"),b.destroy());a&&this._wireUI(a);this._set("ui",a)};b.prototype._wireUI=function(a){this._domHandles.remove("ui");a&&(a.view=this,this._domHandles.add([l.init(this,"root",function(b){a.container= b?k.create("div",null,b):null}),l.init(this,"popup",function(b,c){c&&(a.remove(c,"popup"),c!==b&&c.destroy());b&&(b.view=a.view,a.add(b,{key:"popup",position:"manual"}))})],"ui"))};b.prototype._focusEvent=function(a){this.notifyChange("focused");this.emit("focus",{native:a})};b.prototype._blurEvent=function(a){this.notifyChange("focused");this.emit("blur",{native:a})};b.prototype._stopMeasuring=function(){this._domHandles.remove("measuring");this._get("resizing")&&this._set("resizing",!1)};b.prototype._startMeasuring= function(){var a=this,b=this._freqInfo;b.freq=16;b.time=750;this._domHandles.add([v(window,"resize",function(){b.freq=16;b.time=750}),n.addFrameTask({prepare:function(b){var c=a._measure(),d=a._freqInfo;d.time+=b.deltaTime;c&&(d.freq=16,a._get("resizing")||a._set("resizing",!0));d.time