/*! maintenance_supporter frontend 2.99.0 */ import"/maintenance_supporter_panelfiles/panel-chunks/chunk-TX2GMEMJ.js";import{H as u,a as n,b as _,c as o,f as p,h as c,l as g,m as a,s}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-3FGYBPXY.js";var d=["round_robin","least_completed","random"],v=["low","normal","high"],m=365,i=class extends c{constructor(){super(...arguments);this._open=!1;this._mode="assign";this._count=0;this._users=[];this._present=[];this._assignKind="one";this._person="";this._pool=new Set;this._rotation=d[0];this._addText="";this._remove=new Set;this._setWarning=!1;this._warning=7;this._setPriority=!1;this._priority="normal";this._setMute=!1;this._mute=!1;this._resolve=null}get _lang(){return u(this.hass)}open(t,e,r){return this._resolve?.(null),this._mode=t,this._count=e.length,this._users=[...r].sort((l,h)=>l.name.localeCompare(h.name)),this._present=[...new Set(e.flatMap(l=>l.labels||[]))].sort((l,h)=>l.localeCompare(h)),this._assignKind="one",this._person="",this._pool=new Set,this._rotation=d[0],this._addText="",this._remove=new Set,this._setWarning=!1,this._warning=7,this._setPriority=!1,this._priority="normal",this._setMute=!1,this._mute=!1,this._open=!0,new Promise(l=>{this._resolve=l})}_finish(t){this._open=!1;let e=this._resolve;this._resolve=null,e?.(t)}changes(){if(this._mode==="assign"){if(this._assignKind==="one")return{responsible_user_id:this._person||null,assignee_pool:null,rotation_strategy:null};let e=this._users.map(r=>r.id).filter(r=>this._pool.has(r));return e.length<2?null:{assignee_pool:e,rotation_strategy:this._rotation,responsible_user_id:null}}if(this._mode==="labels"){let e=[...new Set(this._addText.split(",").map(l=>l.trim()).filter(Boolean))],r=[...this._remove];return e.length||r.length?{labels_add:e,labels_remove:r}:null}let t={};return this._setWarning&&(t.warning_days=this._warning),this._setPriority&&(t.priority=this._priority),this._setMute&&(t.notify_enabled=!this._mute),Object.keys(t).length?t:null}_toggle(t,e){let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r}_renderAssign(t){return o`
${s("bulk_assign_hint",t)}
${this._assignKind==="one"?o``:p} ${this._assignKind==="rotate"?o`
${this._users.map(e=>o``)}
${this._pool.size<2?o`
${s("bulk_rotation_min_two",t)}
`:p}`:p} `}_renderLabels(t){return o` this._addText=e.target.value} > ${this._present.length?o`
${s("bulk_labels_remove",t)}
${this._present.map(e=>o``)}
`:p} `}_renderEdit(t){return o`
${s("bulk_edit_hint",t)}
this._setWarning=e.target.checked} /> ${s("warning_days",t)} {let r=parseInt(e.target.value,10);this._warning=Number.isInteger(r)?Math.min(Math.max(r,0),m):this._warning}} />
this._setPriority=e.target.checked} /> ${s("priority",t)}
this._setMute=e.target.checked} /> ${s("bulk_no_notifications",t)} this._mute=e.target.checked} />
`}render(){if(!this._open)return o``;let t=this._lang,e=this._mode==="assign"?s("bulk_assign",t):this._mode==="labels"?s("labels",t):s("edit",t),r=this.changes()!==null;return o` this._finish(null)}>
${e}
${s("bulk_n_selected",t).replace("{n}",String(this._count))}
${this._mode==="assign"?this._renderAssign(t):this._mode==="labels"?this._renderLabels(t):this._renderEdit(t)}
this._finish(null)}>${s("cancel",t)} this._finish(this.changes())}>${s("save",t)}
`}};i.styles=_` .dialog-title { font-size: 18px; font-weight: 500; padding-bottom: 12px; } .content { display: flex; flex-direction: column; gap: 10px; min-width: min(360px, calc(100vw - 24px)); max-width: 520px; max-height: 60vh; overflow-y: auto; } @media (max-width: 600px) { .content { min-width: 0; max-width: none; max-height: none; } } .count, .hint { color: var(--secondary-text-color); font-size: 13px; } .section-title { font-size: 14px; font-weight: 500; padding-bottom: 4px; border-bottom: 1px solid var(--divider-color); } .choice, .row { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; } .pool { display: flex; flex-direction: column; gap: 4px; padding-left: 26px; } .field { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 14px; } .grow { flex: 1; min-width: 0; } select, input[type="number"] { font: inherit; padding: 4px 6px; border: 1px solid var(--divider-color); border-radius: 4px; background: var(--card-background-color, #fff); color: var(--primary-text-color); max-width: 100%; } input[type="number"] { width: 72px; } select.person { margin-left: 26px; } .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; } `,n([g({attribute:!1})],i.prototype,"hass",2),n([a()],i.prototype,"_open",2),n([a()],i.prototype,"_mode",2),n([a()],i.prototype,"_count",2),n([a()],i.prototype,"_users",2),n([a()],i.prototype,"_present",2),n([a()],i.prototype,"_assignKind",2),n([a()],i.prototype,"_person",2),n([a()],i.prototype,"_pool",2),n([a()],i.prototype,"_rotation",2),n([a()],i.prototype,"_addText",2),n([a()],i.prototype,"_remove",2),n([a()],i.prototype,"_setWarning",2),n([a()],i.prototype,"_warning",2),n([a()],i.prototype,"_setPriority",2),n([a()],i.prototype,"_priority",2),n([a()],i.prototype,"_setMute",2),n([a()],i.prototype,"_mute",2);customElements.get("maintenance-bulk-edit-dialog")||customElements.define("maintenance-bulk-edit-dialog",i);export{i as MaintenanceBulkEditDialog};