/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";import i from"../../../Widget.js";import{WellKnownSizes as n,Icons as r}from"./responsiveToolbarUtils.js";import{ToolbarGroupBase as s}from"./ToolbarGroupBase.js";import{loadCalciteComponents as a}from"../../../support/componentsUtils.js";import{tsx as l,tsxFragment as c,messageBundle as p}from"../../../support/widget.js";let m=class extends(s(i)){constructor(t){super(t),this.allowCollapse=!0,this.messagesCommon=null}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu")})}static{this.vnodeSelector="calcite-action-group"}get minimumLength(){const{actionChildren:t,scale:o}=this;return t.length?this.allowCollapse?n.groupSeparator+n.groupPadding[o]+(n.action[o]+n.actionPadding[o])*Math.min(t.length,2):n.groupSeparator+n.groupPadding[o]+(n.action[o]+n.actionPadding[o])*t.length:0}get lengthOptions(){const{actionChildren:t,scale:o,minimumLength:e,allowCollapse:i,priority:r}=this,s=[e];if(t.length<=2||!i||r<1)return s;for(let a=1;a<t.length-1;a++)s.push(e+(n.action[o]+n.actionPadding[o])*a);return s}render(){if(!this.actionChildren.length)return l(c,null,void 0);const{budgetedLength:t,actionChildren:o,activeChildElement:e,layout:i,slot:s,scale:a}=this,p=Math.floor((t-n.groupPadding[a]-n.groupSeparator)/(n.action[a]+n.actionPadding[a])),m=[],d=[];if(p>=o.length)m.push(...o);else{const t=e??m.at(0);if(m.push(...o.slice(0,p-1)),d.push(...o.slice(p-1)),t&&d.includes(t)){const[o]=d.splice(d.indexOf(t),1),e=m.pop();m.push(o),e&&d.unshift(e)}}return l("calcite-action-group",{key:"overflow-button-group",layout:i,onclick:t=>this._handleClick(t.target),slot:s},m.map(t=>this._renderManagedAction(t)),d.length>0?l("calcite-action-menu",{key:"split-button-dropdown",label:this.messagesCommon.more,overlayPositioning:"fixed"},l("calcite-action",{icon:r.overflow,key:"split-button-dropdown-trigger",scale:a,slot:"trigger",text:this.messagesCommon.more}),d.map(t=>this._renderManagedAction(t))):void 0)}_renderManagedAction(t){return l("calcite-action",{...t?.properties,"data-action-key":t?.properties?.key,text:t?.properties?.text??""})}};t([o()],m.prototype,"allowCollapse",void 0),t([o()],m.prototype,"minimumLength",null),t([o(),p("esri/t9n/common")],m.prototype,"messagesCommon",void 0),t([o()],m.prototype,"lengthOptions",null),m=t([e("esri.widgets.Sketch.support.ResponsiveToolbar.OverflowGroup")],m);export{m as default};
