/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/has","../../core/Logger","../../core/reactiveUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","./Component","./UI","../../widgets/Attribution","../../widgets/Compass","../../widgets/NavigationToggle","../../widgets/Zoom"],(function(t,e,i,o,n,s,r,a,c,d,u,p,h,_,f){"use strict";const g="esri.views.ui.DefaultUI";function l(t){return t&&void 0!==t.view}o.getLogger(g);let m=function(e){function i(t){var i;return(i=e.call(this,t)||this)._defaultPositionLookup={attribution:"manual",compass:"top-left","navigation-toggle":"top-left",zoom:"top-left"},i.components=[],i}t._inheritsLoose(i,e);var o=i.prototype;return o.initialize=function(){this._handles.add([n.watch((()=>this.components),this._componentsWatcher.bind(this),n.initial),n.watch((()=>this.view),this._updateViewAwareWidgets.bind(this),n.initial)])},o._add=function(t,i,o,n){if("string"==typeof t&&this._defaultPositionLookup[t]){if(this._find(t))return;t=this._createComponent(t)}e.prototype._add.call(this,t,i,o,n)},o._removeComponents=function(t){t.forEach((t=>{const e=this._find(t);e&&(this.remove(e),e.destroy())}))},o._updateViewAwareWidgets=function(t){this.components.forEach((e=>{const i=this._find(e),o=i&&i.widget;l(o)&&(o.view=t)}))},o._componentsWatcher=function(t,e){this._removeComponents(e),this._addComponents(t),this._adjustPadding(t)},o._adjustPadding=function(t){if(!t.includes("attribution")&&!this._isOverridden("padding")){const{top:t}=this.padding;this.padding=t}},o._addComponents=function(t){this.initialized&&t.forEach((t=>this.add(this._createComponent(t),this._defaultPositionLookup[t])))},o._createComponent=function(t){const e=this._createWidget(t);if(e)return new d({id:t,node:e})},o._createWidget=function(t){return"attribution"===t?this._createAttribution():"compass"===t?this._createCompass():"navigation-toggle"===t?this._createNavigationToggle():"zoom"===t?this._createZoom():void 0},o._createAttribution=function(){return new p({view:this.view})},o._createCompass=function(){return new h({view:this.view})},o._createNavigationToggle=function(){return new _({view:this.view})},o._createZoom=function(){return new f({view:this.view})},i}(u);e.__decorate([s.property()],m.prototype,"components",void 0),m=e.__decorate([c.subclass(g)],m);return m}));
