${r("weibull_reliability_curve",i)}
${je(n,i)}
${Ne(n,s,a,l,i)}
${qe(t,i)}
${t?.confidence_interval_low!=null?ze(t,e,i):c}
`}function je(e,i){let t,n,s;return e<.8?(t="early_failures",n="M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z",s="beta_early_failures"):e<=1.2?(t="random_failures",n="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,17H11V15H13V17M13,13H11V7H13V13Z",s="beta_random_failures"):e<=3.5?(t="wear_out",n="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,6A6,6 0 0,1 18,12H12V6Z",s="beta_wear_out"):(t="highly_predictable",n="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z",s="beta_highly_predictable"),o`
${r(s,i)} (\u03B2=${y(e,i,2)})
`}function Ne(e,i,t,n,s){let x=Math.max(t,n,i,1)*1.3,S=50,R=[];for(let k=0;k<=S;k++){let A=k/S*x,he=1-Math.exp(-Math.pow(A/i,e)),me=32+A/x*260,_e=136-he*128;R.push([me,_e])}let Z=R.map(([k,A])=>`${_(k)},${_(A)}`).join(" "),ot="M32,136 "+R.map(([k,A])=>`L${_(k)},${_(A)}`).join(" ")+` L${_(R[S][0])},136 Z`,j=32+t/x*260,Y=1-Math.exp(-Math.pow(t/i,e)),J=136-Y*128,pe=y((1-Y)*100,s,0),ft=32+n/x*260,ue=[0,.25,.5,.75,1];return o`
${ue.map(k=>{let A=136-k*128;return N`
${y(k*100,s,0)}%
`})}
0
${Math.round(x/2)}
${Math.round(x)}
${t>0?N`
R=${pe}%
`:c}
${n>0&&n!==t?N`
`:c}
${r("weibull_failure_probability",s)}
${t>0?o` ${r("current_interval_marker",s)} `:c}
${n>0&&n!==t?o` ${r("recommended_marker",s)} `:c}
`}function qe(e,i){return o`
${r("characteristic_life",i)}
${Math.round(e.weibull_eta)} ${r("days",i)}
${e.weibull_r_squared!=null?o`
${r("weibull_r_squared",i)}
${y(e.weibull_r_squared,i,3)}
`:c}
`}function ze(e,i,t){let n=e.confidence_interval_low,s=e.confidence_interval_high,a=i.suggested_interval??i.interval_days??0,l=i.interval_days??0,d=Math.max(0,n-5),h=s+5-d,f=(n-d)/h*100,C=(s-n)/h*100,V=(a-d)/h*100,x=l>0?(l-d)/h*100:-1;return o`
${r("confidence_interval",t)}: ${a} ${r("days",t)} (${n}\u2013${s})
${r("confidence_conservative",t)} (${n}${r("days",t).charAt(0)})
${r("confidence_aggressive",t)} (${s}${r("days",t).charAt(0)})
`}function ne(e,i,t){let n=e.degradation_trend!=null&&e.degradation_trend!=="insufficient_data",s=e.days_until_threshold!=null,a=e.environmental_factor!=null&&e.environmental_factor!==1;if(!n&&!s&&!a)return c;let l=e.degradation_trend==="rising"?"M16,6L18.29,8.29L13.41,13.17L9.41,9.17L2,16.59L3.41,18L9.41,12L13.41,16L19.71,9.71L22,12V6H16Z":e.degradation_trend==="falling"?"M16,18L18.29,15.71L13.41,10.83L9.41,14.83L2,7.41L3.41,6L9.41,12L13.41,8L19.71,14.29L22,12V18H16Z":"M22,12L18,8V11H3V13H18V16L22,12Z";return o`
${e.sensor_prediction_urgency?o`
${r("sensor_prediction_urgency",i).replace("{days}",String(Math.round(e.days_until_threshold||0)))}
`:c}
${r("sensor_prediction",i)}
${n?o`
${r("degradation_trend",i)}
${r("trend_"+e.degradation_trend,i)}
${e.degradation_rate!=null?o`${e.degradation_rate>0?"+":""}${y(e.degradation_rate,i,Math.abs(e.degradation_rate)>=10?0:1)} ${e.trigger_entity_info?.unit_of_measurement||""}/${r("day_short",i)} `:c}
`:c}
${s?o`
${r("days_until_threshold",i)}
${e.days_until_threshold===0?r("threshold_exceeded",i):"~"+Math.round(e.days_until_threshold)+" "+r("days",i)}
${e.threshold_prediction_date?o`${G(e.threshold_prediction_date,i)} `:c}
${e.threshold_prediction_confidence?o` `:c}
${(e.prediction_cycles??0)>0?o`${r("prediction_cycles",i)}: ${e.prediction_cycles} `:c}
`:c}
${a&&t.environmental?o`
${r("environmental_adjustment",i)}
${y(e.environmental_factor,i,2)}x
${e.environmental_entity?o`Et(d,e.environmental_entity)}>${e.environmental_entity} `:c}
`:c}
`}function ie(e,i,t,n){let s=Math.max(e||1,i);return o`
${r("current",n)}: ${e??"\u2014"} ${e!=null?r("days",n):""}
${r("recommended",n)}: ${i} ${r("days",n)}
${r(`confidence_${t}`,n)}
`}var se=["month_jan","month_feb","month_mar","month_apr","month_may","month_jun","month_jul","month_aug","month_sep","month_oct","month_nov","month_dec"];function re(e,i,t){if(!t.seasonal||!e.seasonal_factor||e.seasonal_factor===1)return c;let n=se.map(d=>r(d,i)),s=new Date().getMonth(),a=e.seasonal_factors||e.interval_analysis?.seasonal_factors||null,l=a&&a.length===12?a:n.map((d,u)=>{let h=e.seasonal_factor||1,f=Math.sin((u-6)*Math.PI/6)*.3;return Math.max(.7,Math.min(1.3,h+f))});return o`
${r("seasonal_awareness",i)}
${l.map((d,u)=>{let h=d*40,f=d<.9?"low":d>1.1?"high":"normal";return o`
`})}
${r("shorter",i)}
${r("normal",i)}
${r("longer",i)}
`}function ae(e,i){return Fe(e,i)}function Fe(e,i){let t=e.seasonal_factors??e.interval_analysis?.seasonal_factors;if(!t||t.length!==12)return c;let n=e.interval_analysis?.seasonal_reason,s=new Date().getMonth(),a=300,l=100,d=8,h=l-d-4,f=Math.max(...t,1.5),C=a/12,V=C*.65,x=d+h-1/f*h;return o`
${r("seasonal_chart_title",i)}
${n?o`${n==="learned"?r("seasonal_learned",i):r("seasonal_manual",i)} `:c}
${t.map((S,R)=>{let Z=S/f*h,ot=R*C+(C-V)/2,j=d+h-Z,Y=R===s,J=S<1?"var(--success-color, #4caf50)":S>1?"var(--warning-color, #ff9800)":"var(--secondary-text-color)";return N`
`})}
${se.map((S,R)=>o`${r(S,i)} `)}
`}var g=class extends L{constructor(){super(...arguments);this._open=!1;this._entryId=null;this._taskId=null;this._task=null;this._objectName="";this._taskRef=null;this._busy=!1;this._error="";this._showSkip=!1;this._showReset=!1;this._showDetails=!1;this._showAdaptive=!1;this._skipReason="";this._resetDate="";this._features={adaptive:!1,predictions:!1,seasonal:!1,environmental:!1,budget:!1,groups:!1,checklists:!1,schedule_time:!1,completion_actions:!1};this._toast="";this._toastTimer=new Nt;this._access=it;this._currencySymbol="";this._loadSeq=0}get _lang(){return T(this.hass)}async openFor(t,n){(t!==this._entryId||n!==this._taskId)&&(this._task=null),this._entryId=t,this._taskId=n,this._error="",this._showSkip=!1,this._showReset=!1,this._showAdaptive=!1,this._skipReason="",this._resetDate=Rt(new Date),this._open=!0,await Promise.all([this._loadTask(),this._loadFeatures()])}async _loadFeatures(){let t=await M(this.hass);this._features={...this._features,...t.features},this._access=t.access,this._currencySymbol=U(t.budget??void 0),bt(t.budget??void 0)}close(){this._loadSeq++,this._open=!1,this._task=null,this._error="",this._toastTimer.clear(),this._toast=""}_showToast(t,n){this._toast=t,this._toastTimer.schedule(()=>{this._toast=""},n)}async _loadTask(){let t=this._entryId,n=this._taskId;if(!t||!n)return;let s=++this._loadSeq,a="",l=await I(this,{type:"maintenance_supporter/object",entry_id:t},{onError:u=>{a=u}});if(s!==this._loadSeq)return;if(l===void 0){this._error=a;return}this._objectName=l?.object?.name||"";let d=(l?.tasks||[]).find(u=>u.id===n);this._task=d??null,this._taskRef=Ut(l?.object,d),d||(this._error=r("ws_err_not_found",this._lang))}_runWs(t){return this._error="",I(this,t,{busy:n=>{this._busy=n},onError:n=>{this._error=n}})}_notifyChanged(t){this.dispatchEvent(new CustomEvent("task-action-fired",{detail:{entry_id:this._entryId,task_id:this._taskId,action:t},bubbles:!0,composed:!0}))}_onComplete(){!this._entryId||!this._taskId||!this._task||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-H6J55EII.js").then(async({openCompleteDialog:t})=>{let n=this._task,s=[];try{s=(await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/objects",compact:!0})).objects||[]}catch{}t(Ft({entryId:this._entryId,taskId:this._taskId,taskName:n.name,task:n,objects:s,lang:this._lang,features:this._features,currencySymbol:this._currencySymbol}))&&(this._notifyChanged("complete"),this.close())})}async _onSkipConfirm(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/skip",entry_id:this._entryId,task_id:this._taskId,reason:this._skipReason.trim()||null})!==void 0&&(this._notifyChanged("skip"),this.close())}async _onResetConfirm(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/reset",entry_id:this._entryId,task_id:this._taskId,date:this._resetDate||void 0})!==void 0&&(this._notifyChanged("reset"),this.close())}_onEdit(){!this._entryId||!this._taskId||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-H6J55EII.js").then(({openEditTaskDialog:t})=>{t(this._entryId,this._taskId),this.close()})}_onQr(){!this._entryId||!this._taskId||!this._task||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-H6J55EII.js").then(({openQrDialog:t})=>{t({entry_id:this._entryId,task_id:this._taskId,task_name:this._task.name,object_name:this._objectName}),this.close()})}async _onDelete(){if(!this._entryId||!this._taskId||!await O(this.hass,{title:r("delete",this._lang),message:r("delete_task_confirm",this._lang),confirmText:r("delete",this._lang),danger:!0}))return;await this._runWs({type:"maintenance_supporter/task/delete",entry_id:this._entryId,task_id:this._taskId})!==void 0&&(this._notifyChanged("delete"),this.close())}async _onArchive(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/archive",entry_id:this._entryId,task_id:this._taskId})!==void 0&&(this._notifyChanged("archive"),this.close())}async _onUnarchive(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/unarchive",entry_id:this._entryId,task_id:this._taskId})!==void 0&&(this._notifyChanged("unarchive"),this.close())}_onOpenInPanel(){if(!this._entryId||!this._taskId)return;let t=`/maintenance-supporter?entry_id=${encodeURIComponent(this._entryId)}&task_id=${encodeURIComponent(this._taskId)}`;history.pushState(null,"",t),window.dispatchEvent(new CustomEvent("location-changed")),this.close()}async _applySuggestion(){if(!this._entryId||!this._taskId||!this._task?.suggested_interval)return;await this._runWs({type:"maintenance_supporter/task/apply_suggestion",entry_id:this._entryId,task_id:this._taskId,interval:this._task.suggested_interval})!==void 0&&(this._showToast(r("suggestion_applied",this._lang)),this._notifyChanged("apply_suggestion"),await this._loadTask())}async _reanalyzeInterval(){if(!this._entryId||!this._taskId)return;let t=await this._runWs({type:"maintenance_supporter/task/analyze_interval",entry_id:this._entryId,task_id:this._taskId});t!==void 0&&(this._showToast(t?.recommended_interval?`${r("reanalyze_result",this._lang)}: ${wt(t.recommended_interval,"days",this._lang)} (${t.data_points} pts)`:r("reanalyze_insufficient_data",this._lang)),await this._loadTask())}_onEditHistoryEntry(t){if(!this._entryId||!this._taskId)return;let n=pt(this._entryId,this._taskId,t,this._task);import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-H6J55EII.js").then(({openHistoryEditDialog:s})=>s(n))}_renderRecommendation(t){if(!this._features.adaptive||!t.suggested_interval||t.suggested_interval===t.interval_days)return c;let n=this._lang;return o`
${r("suggested_interval",n)}
${ie(t.interval_days,t.suggested_interval,t.interval_confidence||"medium",n)}
${q(this.hass?.user,this._access)?o`
${r("apply_suggestion",n)}
`:c}
${r("reanalyze",n)}
`}_renderAdaptive(t){let n=this._lang,s=this._features.adaptive&&t.suggested_interval&&t.suggested_interval!==t.interval_days,a=t.degradation_trend!=null&&t.degradation_trend!=="insufficient_data"||t.days_until_threshold!=null||t.environmental_factor!=null&&t.environmental_factor!==1,l=this._features.adaptive&&t.interval_analysis?.weibull_beta!=null&&t.interval_analysis?.weibull_eta!=null,d=this._features.seasonal&&t.seasonal_factor&&t.seasonal_factor!==1;return!s&&!a&&!l&&!d?o`
${r("adaptive_no_data",n)}
`:o`
${this._toast?o`
${this._toast}
`:c}
${s?this._renderRecommendation(t):c}
${a?ne(t,n,this._features):c}
${l?ee(t,n):c}
${d?o`
${re(t,n,this._features)}
${t.seasonal_factors?.length===12||t.interval_analysis?.seasonal_factors?.length===12?ae(t,n):c}
`:c}
`}_renderDetails(t){let n=this._lang,s=t.history||[],a=t.history_count??s.length,l=ht(s).slice(0,20);return o`
${r("times_performed",n)}
${t.times_performed??0}
${r("total_cost",n)}
${X(t.total_cost??0,this._currencySymbol,n)}
${r("avg_duration",n)}
${tt(t.average_duration!=null?Math.round(t.average_duration):null,n)}
${s.length===0?o`
${r("history_empty",n)}
`:o`
${l.map(d=>mt(d,{lang:n,hass:this.hass,currencySymbol:this._currencySymbol,openEdit:q(this.hass?.user,this._access)?u=>this._onEditHistoryEntry(u):void 0,readingUnit:t.reading_unit,readingSlotDelta:(u,h)=>Mt(s,u,h),taskRef:this._taskRef},{compact:!0}))}
${a>l.length?o`
… +${a-l.length} ${r("older_entries",n)}
`:c}
`}
`}render(){if(!this._open)return c;let t=this._lang,n=this._task,s=q(this.hass?.user,this._access);return F(()=>this.close(),o`
${n?o`
${this._error?o`${this._error}
`:c}
${this._showSkip?o`
`:this._showReset?o`
`:o`
${r("complete",t)}
${n.allow_skip!==!1?o`
{this._showSkip=!0}} .disabled=${this._busy}>
${r("skip",t)}
`:c}
{this._showReset=!0}} .disabled=${this._busy}>
${r("reset",t)}
${s?o`
${r("edit",t)}
`:c}
${r("qr_code",t)}
${s?o`
${n.archived?r("unarchive",t):r("archive",t)}
${r("delete",t)}
`:c}
{this._showDetails=!this._showDetails}}>
${this._showDetails?r("hide_details",t):r("show_details",t)}
${this._features.adaptive||this._features.seasonal||this._features.environmental?o`{this._showAdaptive=!this._showAdaptive}}>
${this._showAdaptive?r("hide_stats",t):r("show_stats",t)}
`:c}
${this._showDetails?this._renderDetails(n):c}
${this._showAdaptive?this._renderAdaptive(n):c}
`}
`:this._error?o`${this._error}
`:o`${r("loading",t)}
`}
`)}updated(t){t.has("_open")&&this._open&&W(this.shadowRoot)}};g.styles=[Lt,z,$`
:host { display: contents; --ms-modal-max-width: 460px; }
.header { display: flex; flex-direction: column; gap: 6px; }
.title { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.task-name { font-size: 18px; font-weight: 600; }
.object { font-size: 13px; color: var(--secondary-text-color); }
.link-inline {
background: transparent; border: none; padding: 0; cursor: pointer;
color: var(--primary-color); font-size: inherit; font-family: inherit;
}
.link-inline:hover { text-decoration: underline; }
.quick-info {
display: flex; flex-wrap: wrap; gap: 12px;
font-size: 12px; color: var(--secondary-text-color);
padding-top: 4px; border-top: 1px solid var(--divider-color);
}
.quick-info strong { color: var(--primary-text-color); font-weight: 500; }
.actions { display: flex; gap: 8px; }
.actions.primary-row { gap: 6px; }
.actions.primary-row .btn { flex: 1; }
.actions.primary-row ha-button { flex: 1; }
/* Edit + QR are admin-tools — left-align as a group; Delete is destructive
so it gets pushed to the far right with margin-left:auto for visual
separation. Earlier this row was flex-end which left a strange empty
gap on the left (user feedback). */
.actions.secondary-row {
padding-top: 8px; border-top: 1px solid var(--divider-color);
justify-content: flex-start;
}
.actions.secondary-row .btn.danger,
.actions.secondary-row ha-button.danger {
margin-left: auto;
}
.actions.secondary-row ha-button { --ha-button-font-size: 13px; }
.btn {
padding: 8px 12px; font-size: 14px;
border-radius: 6px; cursor: pointer;
border: 1px solid var(--divider-color);
background: var(--secondary-background-color, transparent);
color: var(--primary-text-color);
font-weight: 500;
display: inline-flex; align-items: center; gap: 6px;
transition: background 0.12s;
}
.btn:hover { background: var(--state-icon-color, rgba(255,255,255,0.06)); }
.btn[disabled] { opacity: 0.5; cursor: wait; }
.btn.primary {
background: var(--primary-color);
color: var(--text-primary-color, white);
border-color: var(--primary-color);
}
.btn.cancel { background: transparent; }
.btn.ghost { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--error-color); }
.btn ha-icon { --mdc-icon-size: 18px; }
.inline-form { display: flex; flex-direction: column; gap: 8px; }
.inline-form label { font-size: 13px; color: var(--secondary-text-color); }
.inline-form input {
padding: 8px; font-size: 14px;
background: var(--secondary-background-color, #2c2c2c);
color: var(--primary-text-color);
border: 1px solid var(--divider-color, #444);
border-radius: 6px;
}
.inline-actions { display: flex; gap: 8px; justify-content: flex-end; }
.footer { display: flex; justify-content: center; padding-top: 4px; }
.link {
background: transparent; border: none; cursor: pointer;
color: var(--primary-color); font-size: 13px;
display: inline-flex; align-items: center; gap: 4px;
}
.link:hover { text-decoration: underline; }
.link ha-icon { --mdc-icon-size: 14px; }
.loading { padding: 24px; text-align: center; color: var(--secondary-text-color); }
.error {
padding: 8px; border-radius: 6px;
background: rgba(211,47,47,0.1);
color: var(--error-color, #d32f2f); font-size: 13px;
}
/* Details (expandable Show details section) */
.details-toggle { display: flex; justify-content: center; margin-top: 4px; }
.details {
display: flex; flex-direction: column; gap: 12px;
border-top: 1px solid var(--divider-color);
padding-top: 12px;
}
.stats-grid {
display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.stat {
display: flex; flex-direction: column; gap: 2px;
background: var(--secondary-background-color, rgba(255,255,255,0.04));
padding: 8px; border-radius: 6px;
align-items: center;
}
.stat-label { font-size: 11px; color: var(--secondary-text-color); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 16px; font-weight: 600; }
.history-header {
display: flex; align-items: baseline; gap: 8px;
font-size: 14px;
}
.history-count {
font-size: 12px; color: var(--secondary-text-color);
background: var(--secondary-background-color); padding: 2px 8px; border-radius: 999px;
}
.history-empty { color: var(--secondary-text-color); font-style: italic; font-size: 13px; }
/* The rows themselves are the shared renderer's (.history-entry.compact
+ the history-* classes from sharedStyles); only the list chrome is
local. */
.history-list { display: flex; flex-direction: column; max-height: 280px; overflow: auto; }
.history-list .history-entry {
padding: 6px 8px; border-radius: 6px; border-bottom: none; margin-bottom: 6px;
background: var(--secondary-background-color, rgba(255,255,255,0.03));
}
.history-list .history-date { font-size: 11px; }
.history-list .history-details { font-size: 11px; }
.history-more { padding: 8px; text-align: center; font-size: 12px; color: var(--secondary-text-color); font-style: italic; }
/* Adaptive section — wraps the panel renderers (which assume sharedStyles
are present) and adds dialog-specific layout. */
.adaptive-stack {
display: flex; flex-direction: column; gap: 12px;
border-top: 1px solid var(--divider-color);
padding-top: 12px;
}
.adaptive-empty {
padding: 16px; text-align: center;
color: var(--secondary-text-color);
font-style: italic; font-size: 13px;
border-top: 1px solid var(--divider-color);
}
.toast {
padding: 8px 12px; border-radius: 6px;
background: rgba(76, 175, 80, 0.15);
color: #4caf50; font-size: 13px; font-weight: 500;
}
/* The panel's recommendation-card uses ha-button. We use plain
in this dialog's button styles. Re-style the action row to match. */
.recommendation-actions {
display: flex; gap: 8px; margin-top: 8px;
}
/* Constrain SVG charts so they fit the dialog width even on mobile. */
.weibull-section, .seasonal-card-compact { max-width: 100%; }
.weibull-chart svg { max-width: 100%; height: auto; }
.details-toggle { gap: 12px; flex-wrap: wrap; }
`],p([w({attribute:!1})],g.prototype,"hass",2),p([m()],g.prototype,"_open",2),p([m()],g.prototype,"_entryId",2),p([m()],g.prototype,"_taskId",2),p([m()],g.prototype,"_task",2),p([m()],g.prototype,"_objectName",2),p([m()],g.prototype,"_taskRef",2),p([m()],g.prototype,"_busy",2),p([m()],g.prototype,"_error",2),p([m()],g.prototype,"_showSkip",2),p([m()],g.prototype,"_showReset",2),p([m()],g.prototype,"_showDetails",2),p([m()],g.prototype,"_showAdaptive",2),p([m()],g.prototype,"_skipReason",2),p([m()],g.prototype,"_resetDate",2),p([m()],g.prototype,"_features",2),p([m()],g.prototype,"_toast",2),p([m()],g.prototype,"_access",2);customElements.get("maintenance-task-quick-actions-dialog")||customElements.define("maintenance-task-quick-actions-dialog",g);function oe(e){return!!e&&/^https?:\/\//i.test(e)}function le(e){return e?customElements.get("ha-markdown")?o` `:o`${e}`:c}var E=class extends L{constructor(){super(...arguments);this._open=!1;this._entryId=null;this._data=null;this._busy=!1;this._error="";this._access=it}get _lang(){return T(this.hass)}async openFor(t){this._entryId=t,this._error="",this._open=!0,await Promise.all([this._load(),M(this.hass).then(n=>{this._access=n.access})])}close(){this._open=!1,this._data=null,this._error=""}async _load(){if(!this._entryId)return;let t=await I(this,{type:"maintenance_supporter/object",entry_id:this._entryId},{onError:n=>{this._error=n}});t!==void 0&&(this._data=t)}_runWs(t){return this._error="",I(this,t,{busy:n=>{this._busy=n},onError:n=>{this._error=n}})}_onEditObject(){!this._entryId||!this._data||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-H6J55EII.js").then(({openEditObjectDialog:t})=>{t(this._entryId,this._data.object),this.close()})}_onAddTask(){this._entryId&&import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-H6J55EII.js").then(({openCreateTaskDialog:t})=>{t(this._entryId),this.close()})}async _onDelete(){if(!this._entryId||!this._data||!await O(this.hass,{title:r("delete",this._lang),message:r("delete_object_confirm",this._lang),confirmText:r("delete",this._lang),danger:!0}))return;let n=this._entryId;await this._runWs({type:"maintenance_supporter/object/delete",entry_id:n})!==void 0&&(this.dispatchEvent(new CustomEvent("object-deleted",{detail:{entry_id:n},bubbles:!0,composed:!0})),this.close())}async _onArchiveObject(){if(!this._entryId||!this._data)return;let t=!!this._data.object.archived;if(!t&&!await O(this.hass,{title:r("archive_object",this._lang),message:r("confirm_archive_object",this._lang),confirmText:r("archive_object",this._lang)}))return;let n=this._entryId;await this._runWs({type:t?"maintenance_supporter/object/unarchive":"maintenance_supporter/object/archive",entry_id:n})!==void 0&&(this.dispatchEvent(new CustomEvent("object-changed",{detail:{entry_id:n},bubbles:!0,composed:!0})),this.close())}_onTaskClick(t){this._entryId&&import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-H6J55EII.js").then(({openTaskQuickActions:n})=>{n(this._entryId,t)})}render(){if(!this._open)return c;let t=this._lang,n=this._data,s=n?.object,a=n?.tasks||[],l=q(this.hass?.user,this._access);return F(()=>this.close(),o`
${n&&s?o`
${this._error?o`${this._error}
`:c}
${a.length===0?o`
${r("no_tasks",t)}
`:o`
${a.map(d=>o`
this._onTaskClick(d.id)}>
${d.name}
${_t(K(d),t)}
`)}
`}
${s.notes?o`
${r("object_notes_label",t)}
${le(s.notes)}
`:c}
${l?o`
${r("add_task",t)}
${r("edit",t)}
${s.archived?r("unarchive_object",t):r("archive_object",t)}
${r("delete",t)}
`:c}
`:o`${r("loading",t)}
`}
`)}updated(t){t.has("_open")&&this._open&&W(this.shadowRoot)}_renderMetaRow(t){let n=this._lang,s=[];return t.area_id&&s.push([r("area",n),t.area_id]),t.manufacturer&&s.push([r("manufacturer",n),t.manufacturer]),t.model&&s.push([r("model",n),t.model]),t.serial_number&&s.push([r("serial_number_label",n),t.serial_number]),t.installation_date&&s.push([r("installed",n),t.installation_date]),t.warranty_expiry&&s.push([r("warranty",n),t.warranty_expiry]),t.documentation_url&&s.push([r("documentation_url_label",n),t.documentation_url]),s.length===0?c:o`
`}};E.styles=[z,$`
:host { display: contents; }
.header { display: flex; flex-direction: column; gap: 6px; }
.title { font-size: 20px; font-weight: 600; }
.meta { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; border-top: 1px solid var(--divider-color); }
.meta-item { display: flex; gap: 8px; font-size: 12px; }
.meta-label { color: var(--secondary-text-color); min-width: 100px; }
.meta-value { color: var(--primary-text-color); flex: 1; word-break: break-word; }
.meta-value a { color: var(--primary-color); }
.tasks-section, .notes-section { display: flex; flex-direction: column; gap: 6px; }
.section-header { display: flex; align-items: baseline; gap: 8px; }
.count {
font-size: 11px; color: var(--secondary-text-color);
background: var(--secondary-background-color); padding: 2px 8px; border-radius: 999px;
}
.empty { color: var(--secondary-text-color); font-style: italic; font-size: 13px; padding: 8px 0; }
.task-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow: auto; }
.task-row {
display: flex; align-items: center; gap: 10px;
padding: 8px; border-radius: 6px; cursor: pointer;
background: var(--secondary-background-color, rgba(255,255,255,0.03));
transition: background 0.12s;
}
.task-row:hover { background: var(--state-icon-color, rgba(255,255,255,0.06)); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.task-name { flex: 1; font-size: 14px; }
.task-status { font-size: 11px; color: var(--secondary-text-color); text-transform: uppercase; }
.notes-body { white-space: pre-wrap; font-size: 13px; padding: 8px; background: var(--secondary-background-color); border-radius: 6px; }
.notes-body ha-markdown { white-space: normal; }
.actions { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--divider-color); }
.actions .btn { flex: 1; }
.btn {
padding: 8px; font-size: 13px; border-radius: 6px; cursor: pointer;
border: 1px solid var(--divider-color);
background: var(--secondary-background-color, transparent);
color: var(--primary-text-color); font-weight: 500;
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--state-icon-color, rgba(255,255,255,0.06)); }
.btn[disabled] { opacity: 0.5; cursor: wait; }
.btn.primary { background: var(--primary-color); color: var(--text-primary-color, white); border-color: var(--primary-color); }
.btn.danger { color: var(--error-color); }
.btn ha-icon { --mdc-icon-size: 16px; }
.loading { padding: 24px; text-align: center; color: var(--secondary-text-color); }
.error { padding: 8px; border-radius: 6px; background: rgba(211,47,47,0.1); color: var(--error-color); font-size: 13px; }
`],p([w({attribute:!1})],E.prototype,"hass",2),p([m()],E.prototype,"_open",2),p([m()],E.prototype,"_entryId",2),p([m()],E.prototype,"_data",2),p([m()],E.prototype,"_busy",2),p([m()],E.prototype,"_error",2),p([m()],E.prototype,"_access",2);customElements.get("maintenance-object-quick-actions-dialog")||customElements.define("maintenance-object-quick-actions-dialog",E);var de="maintenance-object-dialog",ce="maintenance-task-dialog",We="maintenance-history-edit-dialog",Ve="maintenance-complete-dialog",Ue="maintenance-qr-dialog",Ge="maintenance-task-quick-actions-dialog",Be="maintenance-object-quick-actions-dialog";function at(){return document.querySelector("home-assistant")?.hass}function Ke(){return document.querySelector("home-assistant")?.shadowRoot??document.body}function H(e){let i=Ke(),t=i.querySelector(e)??document.body.querySelector(e);return t?t.parentNode!==i&&i.appendChild(t):(t=document.createElement(e),i.appendChild(t)),t}function P(e){let i=at();if(!i)return!1;e.hass=i;let t=T(i);return yt(t)||vt(t).then(()=>{e.requestUpdate?.()}),xt(i.locale,i.config?.country),!0}function vs(e){return M(e).then(i=>i.rowActionStyle)}function bs(){Ct()}function xs(){let e=H(de);return P(e)?(e.openCreate(),!0):!1}function $s(e,i){let t=H(de);return P(t)?(t.openEdit(e,i),!0):!1}function ks(e="",i){let t=H(ce);if(!P(t))return!1;let n=at();return n?((async()=>{let s=await M(n),a=t;a.checklistsEnabled=s.features.checklists,a.scheduleTimeEnabled=s.features.schedule_time,a.completionActionsEnabled=s.features.completion_actions,a.defaultWarningDays=s.defaultWarningDays,a.openCreate(e,i)})(),!0):!1}function ws(e,i){let t=H(ce);if(!P(t))return!1;let n=at();return n?((async()=>{try{let[s,a]=await Promise.all([n.connection.sendMessagePromise({type:"maintenance_supporter/object",entry_id:e}),M(n)]),l=(s.tasks||[]).find(u=>u.id===i);if(!l){console.warn(`openEditTaskDialog: task ${i} not found in entry ${e}`);return}let d=t;d.checklistsEnabled=a.features.checklists,d.scheduleTimeEnabled=a.features.schedule_time,d.completionActionsEnabled=a.features.completion_actions,d.defaultWarningDays=a.defaultWarningDays,await d.openEdit(e,l)}catch(s){console.warn("openEditTaskDialog: failed to load task/features",s)}})(),!0):!1}function Ts(e){let i=H(We);return P(i)?(i.openEdit(e),!0):!1}function Es(e){let i=H(Ve);return P(i)?(Wt(i,e,T(at())),!0):!1}function As(e){let i=H(Ue);return P(i)?(i.openForTask(e.entry_id,e.task_id,e.object_name,e.task_name),!0):!1}function Ls(e,i){let t=H(Ge);return P(t)?(t.openFor(e,i),!0):!1}function Ss(e){let i=H(Be);return P(i)?(i.openFor(e),!0):!1}export{oe as a,Le as b,He as c,xe as d,Ut as e,On as f,Gt as g,le as h,ye as i,ve as j,ct as k,Ft as l,Wt as m,_ as n,ei as o,ni as p,ii as q,si as r,ri as s,ai as t,oi as u,pt as v,Mn as w,ht as x,Bn as y,Kn as z,mt as A,te as B,ee as C,ne as D,ie as E,re as F,ae as G,vs as H,bs as I,xs as J,$s as K,ks as L,ws as M,Ts as N,Es as O,As as P,Ls as Q,Ss as R};