function e(e,t,n,i){var a,r=arguments.length,o=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(r<3?a(o):r>3?a(t,n,o):a(t,n))||o);return r>3&&o&&Object.defineProperty(t,n,o),o}var t=window&&window.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},t.apply(this,arguments)};["angle-degree","area-acre","area-hectare","concentr-percent","digital-bit","digital-byte","digital-gigabit","digital-gigabyte","digital-kilobit","digital-kilobyte","digital-megabit","digital-megabyte","digital-petabyte","digital-terabit","digital-terabyte","duration-day","duration-hour","duration-millisecond","duration-minute","duration-month","duration-second","duration-week","duration-year","length-centimeter","length-foot","length-inch","length-kilometer","length-meter","length-mile-scandinavian","length-mile","length-millimeter","length-yard","mass-gram","mass-kilogram","mass-ounce","mass-pound","mass-stone","temperature-celsius","temperature-fahrenheit","volume-fluid-ounce","volume-gallon","volume-liter","volume-milliliter"].map((function(e){return e.replace(/^(.*?)-/,"")}));var n,i,a,r=window&&window.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},n(e,t)},function(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),o=window&&window.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},o.apply(this,arguments)};function s(e){return e.substr(0,e.indexOf("."))}!function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="MISSING_LOCALE_DATA",t}r(t,e)}(Error),function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(i||(i={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(a||(a={}));var c=["closed","locked","off"],l=function(e,t,n,i){i=i||{},n=null==n?{}:n;var a=new Event(t,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});return a.detail=n,e.dispatchEvent(a),a},d=function(e){l(window,"haptic",e)},u=function(e,t){return function(e,t,n){void 0===n&&(n=!0);var i,a=s(t),r="group"===a?"homeassistant":a;switch(a){case"lock":i=n?"unlock":"lock";break;case"cover":i=n?"open_cover":"close_cover";break;default:i=n?"turn_on":"turn_off"}return e.callService(r,i,{entity_id:t})}(e,t,c.includes(e.states[t].state))},h=function(e,t,n,i){if(i||(i={action:"more-info"}),!i.confirmation||i.confirmation.exemptions&&i.confirmation.exemptions.some((function(e){return e.user===t.user.id}))||(d("warning"),confirm(i.confirmation.text||"Are you sure you want to "+i.action+"?")))switch(i.action){case"more-info":(n.entity||n.camera_image)&&l(e,"hass-more-info",{entityId:n.entity?n.entity:n.camera_image});break;case"navigate":i.navigation_path&&function(e,t,n){void 0===n&&(n=!1),n?history.replaceState(null,"",t):history.pushState(null,"",t),l(window,"location-changed",{replace:n})}(0,i.navigation_path);break;case"url":i.url_path&&window.open(i.url_path);break;case"toggle":n.entity&&(u(t,n.entity),d("success"));break;case"call-service":if(!i.service)return void d("failure");var a=i.service.split(".",2);t.callService(a[0],a[1],i.service_data,i.target),d("success");break;case"fire-dom-event":l(e,"ll-custom",i)}};function m(e){return void 0!==e&&"none"!==e.action}var p=function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null};
/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const f=window,g=f.ShadowRoot&&(void 0===f.ShadyCSS||f.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,v=Symbol(),_=new WeakMap;class y{constructor(e,t,n){if(this._$cssResult$=!0,n!==v)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(g&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=_.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&_.set(t,e))}return e}toString(){return this.cssText}}const b=e=>new y("string"==typeof e?e:e+"",void 0,v),w=(e,...t)=>{const n=1===e.length?e[0]:t.reduce(((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1]),e[0]);return new y(n,e,v)},x=(e,t)=>{g?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const n=document.createElement("style"),i=f.litNonce;void 0!==i&&n.setAttribute("nonce",i),n.textContent=t.cssText,e.appendChild(n)}))},C=g?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return b(t)})(e):e
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */;var $;const k=window,E=k.trustedTypes,M=E?E.emptyScript:"",S=k.reactiveElementPolyfillSupport,T={toAttribute(e,t){switch(t){case Boolean:e=e?M:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},A=(e,t)=>t!==e&&(t==t||e==e),z={attribute:!0,type:String,converter:T,reflect:!1,hasChanged:A};class j extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,n)=>{const i=this._$Ep(n,t);void 0!==i&&(this._$Ev.set(i,n),e.push(i))})),e}static createProperty(e,t=z){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const n="symbol"==typeof e?Symbol():"__"+e,i=this.getPropertyDescriptor(e,n,t);void 0!==i&&Object.defineProperty(this.prototype,e,i)}}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(i){const a=this[e];this[t]=i,this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||z}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const n of t)this.createProperty(n,e[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(C(e))}else void 0!==e&&t.push(C(e));return t}static _$Ep(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,n;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return x(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$EO(e,t,n=z){var i;const a=this.constructor._$Ep(e,n);if(void 0!==a&&!0===n.reflect){const r=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:T).toAttribute(t,n.type);this._$El=e,null==r?this.removeAttribute(a):this.setAttribute(a,r),this._$El=null}}_$AK(e,t){var n;const i=this.constructor,a=i._$Ev.get(e);if(void 0!==a&&this._$El!==a){const e=i.getPropertyOptions(a),r="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(n=e.converter)||void 0===n?void 0:n.fromAttribute)?e.converter:T;this._$El=a,this[a]=r.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,n){let i=!0;void 0!==e&&(((n=n||this.constructor.getPropertyOptions(e)).hasChanged||A)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===n.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,n))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(n)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(n)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
var O;j.finalized=!0,j.elementProperties=new Map,j.elementStyles=[],j.shadowRootOptions={mode:"open"},null==S||S({ReactiveElement:j}),(null!==($=k.reactiveElementVersions)&&void 0!==$?$:k.reactiveElementVersions=[]).push("1.6.1");const I=window,R=I.trustedTypes,D=R?R.createPolicy("lit-html",{createHTML:e=>e}):void 0,P=`lit$${(Math.random()+"").slice(9)}$`,L="?"+P,N=`<${L}>`,U=document,F=(e="")=>U.createComment(e),H=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Z=Array.isArray,q=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,V=/-->/g,W=/>/g,B=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),Y=/'/g,Q=/"/g,G=/^(?:script|style|textarea|title)$/i,K=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),X=Symbol.for("lit-noChange"),J=Symbol.for("lit-nothing"),ee=new WeakMap,te=U.createTreeWalker(U,129,null,!1),ne=(e,t)=>{const n=e.length-1,i=[];let a,r=2===t?"<svg>":"",o=q;for(let t=0;t<n;t++){const n=e[t];let s,c,l=-1,d=0;for(;d<n.length&&(o.lastIndex=d,c=o.exec(n),null!==c);)d=o.lastIndex,o===q?"!--"===c[1]?o=V:void 0!==c[1]?o=W:void 0!==c[2]?(G.test(c[2])&&(a=RegExp("</"+c[2],"g")),o=B):void 0!==c[3]&&(o=B):o===B?">"===c[0]?(o=null!=a?a:q,l=-1):void 0===c[1]?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=void 0===c[3]?B:'"'===c[3]?Q:Y):o===Q||o===Y?o=B:o===V||o===W?o=q:(o=B,a=void 0);const u=o===B&&e[t+1].startsWith("/>")?" ":"";r+=o===q?n+N:l>=0?(i.push(s),n.slice(0,l)+"$lit$"+n.slice(l)+P+u):n+P+(-2===l?(i.push(void 0),t):u)}const s=r+(e[n]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==D?D.createHTML(s):s,i]};class ie{constructor({strings:e,_$litType$:t},n){let i;this.parts=[];let a=0,r=0;const o=e.length-1,s=this.parts,[c,l]=ne(e,t);if(this.el=ie.createElement(c,n),te.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(i=te.nextNode())&&s.length<o;){if(1===i.nodeType){if(i.hasAttributes()){const e=[];for(const t of i.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(P)){const n=l[r++];if(e.push(t),void 0!==n){const e=i.getAttribute(n.toLowerCase()+"$lit$").split(P),t=/([.?@])?(.*)/.exec(n);s.push({type:1,index:a,name:t[2],strings:e,ctor:"."===t[1]?ce:"?"===t[1]?de:"@"===t[1]?ue:se})}else s.push({type:6,index:a})}for(const t of e)i.removeAttribute(t)}if(G.test(i.tagName)){const e=i.textContent.split(P),t=e.length-1;if(t>0){i.textContent=R?R.emptyScript:"";for(let n=0;n<t;n++)i.append(e[n],F()),te.nextNode(),s.push({type:2,index:++a});i.append(e[t],F())}}}else if(8===i.nodeType)if(i.data===L)s.push({type:2,index:a});else{let e=-1;for(;-1!==(e=i.data.indexOf(P,e+1));)s.push({type:7,index:a}),e+=P.length-1}a++}}static createElement(e,t){const n=U.createElement("template");return n.innerHTML=e,n}}function ae(e,t,n=e,i){var a,r,o,s;if(t===X)return t;let c=void 0!==i?null===(a=n._$Co)||void 0===a?void 0:a[i]:n._$Cl;const l=H(t)?void 0:t._$litDirective$;return(null==c?void 0:c.constructor)!==l&&(null===(r=null==c?void 0:c._$AO)||void 0===r||r.call(c,!1),void 0===l?c=void 0:(c=new l(e),c._$AT(e,n,i)),void 0!==i?(null!==(o=(s=n)._$Co)&&void 0!==o?o:s._$Co=[])[i]=c:n._$Cl=c),void 0!==c&&(t=ae(e,c._$AS(e,t.values),c,i)),t}class re{constructor(e,t){this.u=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(e){var t;const{el:{content:n},parts:i}=this._$AD,a=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:U).importNode(n,!0);te.currentNode=a;let r=te.nextNode(),o=0,s=0,c=i[0];for(;void 0!==c;){if(o===c.index){let t;2===c.type?t=new oe(r,r.nextSibling,this,e):1===c.type?t=new c.ctor(r,c.name,c.strings,this,e):6===c.type&&(t=new he(r,this,e)),this.u.push(t),c=i[++s]}o!==(null==c?void 0:c.index)&&(r=te.nextNode(),o++)}return a}p(e){let t=0;for(const n of this.u)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class oe{constructor(e,t,n,i){var a;this.type=2,this._$AH=J,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=i,this._$Cm=null===(a=null==i?void 0:i.isConnected)||void 0===a||a}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cm}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ae(this,e,t),H(e)?e===J||null==e||""===e?(this._$AH!==J&&this._$AR(),this._$AH=J):e!==this._$AH&&e!==X&&this.g(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>Z(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.k(e):this.g(e)}O(e,t=this._$AB){return this._$AA.parentNode.insertBefore(e,t)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}g(e){this._$AH!==J&&H(this._$AH)?this._$AA.nextSibling.data=e:this.T(U.createTextNode(e)),this._$AH=e}$(e){var t;const{values:n,_$litType$:i}=e,a="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=ie.createElement(i.h,this.options)),i);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===a)this._$AH.p(n);else{const e=new re(a,this),t=e.v(this.options);e.p(n),this.T(t),this._$AH=e}}_$AC(e){let t=ee.get(e.strings);return void 0===t&&ee.set(e.strings,t=new ie(e)),t}k(e){Z(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,i=0;for(const a of e)i===t.length?t.push(n=new oe(this.O(F()),this.O(F()),this,this.options)):n=t[i],n._$AI(a),i++;i<t.length&&(this._$AR(n&&n._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cm=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class se{constructor(e,t,n,i,a){this.type=1,this._$AH=J,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=a,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=J}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,n,i){const a=this.strings;let r=!1;if(void 0===a)e=ae(this,e,t,0),r=!H(e)||e!==this._$AH&&e!==X,r&&(this._$AH=e);else{const i=e;let o,s;for(e=a[0],o=0;o<a.length-1;o++)s=ae(this,i[n+o],t,o),s===X&&(s=this._$AH[o]),r||(r=!H(s)||s!==this._$AH[o]),s===J?e=J:e!==J&&(e+=(null!=s?s:"")+a[o+1]),this._$AH[o]=s}r&&!i&&this.j(e)}j(e){e===J?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class ce extends se{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===J?void 0:e}}const le=R?R.emptyScript:"";class de extends se{constructor(){super(...arguments),this.type=4}j(e){e&&e!==J?this.element.setAttribute(this.name,le):this.element.removeAttribute(this.name)}}class ue extends se{constructor(e,t,n,i,a){super(e,t,n,i,a),this.type=5}_$AI(e,t=this){var n;if((e=null!==(n=ae(this,e,t,0))&&void 0!==n?n:J)===X)return;const i=this._$AH,a=e===J&&i!==J||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==J&&(i===J||a);a&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==n?n:this.element,e):this._$AH.handleEvent(e)}}class he{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){ae(this,e)}}const me=I.litHtmlPolyfillSupport;null==me||me(ie,oe),(null!==(O=I.litHtmlVersions)&&void 0!==O?O:I.litHtmlVersions=[]).push("2.6.1");
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
var pe,fe;class ge extends j{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const n=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=n.firstChild),n}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{var i,a;const r=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:t;let o=r._$litPart$;if(void 0===o){const e=null!==(a=null==n?void 0:n.renderBefore)&&void 0!==a?a:null;r._$litPart$=o=new oe(t.insertBefore(F(),e),e,void 0,null!=n?n:{})}return o._$AI(e),o})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return X}}ge.finalized=!0,ge._$litElement$=!0,null===(pe=globalThis.litElementHydrateSupport)||void 0===pe||pe.call(globalThis,{LitElement:ge});const ve=globalThis.litElementPolyfillSupport;null==ve||ve({LitElement:ge}),(null!==(fe=globalThis.litElementVersions)&&void 0!==fe?fe:globalThis.litElementVersions=[]).push("3.2.2");
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const _e=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:n,elements:i}=t;return{kind:n,elements:i,finisher(t){customElements.define(e,t)}}})(e,t)
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */,ye=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(n){n.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(n){n.createProperty(t.key,e)}};function be(e){return(t,n)=>void 0!==n?((e,t,n)=>{t.constructor.createProperty(n,e)})(e,t,n):ye(e,t)
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */}function we(e){return be({...e,state:!0})}
/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var xe;null===(xe=window.HTMLSlotElement)||void 0===xe||xe.prototype.assignedElements;
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const Ce={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},$e=e=>(...t)=>({_$litDirective$:e,values:t});class ke{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
/**
 * @license
 * Copyright 2018 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const Ee=$e(class extends ke{constructor(e){var t;if(super(e),e.type!==Ce.ATTRIBUTE||"class"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter((t=>e[t])).join(" ")+" "}update(e,[t]){var n,i;if(void 0===this.nt){this.nt=new Set,void 0!==e.strings&&(this.st=new Set(e.strings.join(" ").split(/\s/).filter((e=>""!==e))));for(const e in t)t[e]&&!(null===(n=this.st)||void 0===n?void 0:n.has(e))&&this.nt.add(e);return this.render(t)}const a=e.element.classList;this.nt.forEach((e=>{e in t||(a.remove(e),this.nt.delete(e))}));for(const e in t){const n=!!t[e];n===this.nt.has(e)||(null===(i=this.st)||void 0===i?void 0:i.has(e))||(n?(a.add(e),this.nt.add(e)):(a.remove(e),this.nt.delete(e)))}return X}}),Me=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Se=e=>void 0===e.strings,Te={},Ae=(e,t=Te)=>e._$AH=t
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */,ze=(e,t)=>{var n,i;const a=e._$AN;if(void 0===a)return!1;for(const e of a)null===(i=(n=e)._$AO)||void 0===i||i.call(n,t,!1),ze(e,t);return!0},je=e=>{let t,n;do{if(void 0===(t=e._$AM))break;n=t._$AN,n.delete(e),e=t}while(0===(null==n?void 0:n.size))},Oe=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(void 0===n)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),De(t)}};
/**
 * @license
 * Copyright 2020 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */function Ie(e){void 0!==this._$AN?(je(this),this._$AM=e,Oe(this)):this._$AM=e}function Re(e,t=!1,n=0){const i=this._$AH,a=this._$AN;if(void 0!==a&&0!==a.size)if(t)if(Array.isArray(i))for(let e=n;e<i.length;e++)ze(i[e],!1),je(i[e]);else null!=i&&(ze(i,!1),je(i));else ze(this,e)}const De=e=>{var t,n,i,a;e.type==Ce.CHILD&&(null!==(t=(i=e)._$AP)&&void 0!==t||(i._$AP=Re),null!==(n=(a=e)._$AQ)&&void 0!==n||(a._$AQ=Ie))};class Pe extends ke{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),Oe(this),this.isConnected=e._$AU}_$AO(e,t=!0){var n,i;e!==this.isConnected&&(this.isConnected=e,e?null===(n=this.reconnected)||void 0===n||n.call(this):null===(i=this.disconnected)||void 0===i||i.call(this)),t&&(ze(this,e),je(this))}setValue(e){if(Se(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}
/**
 * @license
 * Copyright 2020 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const Le=()=>new Ne;class Ne{}const Ue=new WeakMap,Fe=$e(class extends Pe{render(e){return J}update(e,[t]){var n;const i=t!==this.Y;return i&&void 0!==this.Y&&this.rt(void 0),(i||this.lt!==this.ct)&&(this.Y=t,this.dt=null===(n=e.options)||void 0===n?void 0:n.host,this.rt(this.ct=e.element)),J}rt(e){var t;if("function"==typeof this.Y){const n=null!==(t=this.dt)&&void 0!==t?t:globalThis;let i=Ue.get(n);void 0===i&&(i=new WeakMap,Ue.set(n,i)),void 0!==i.get(this.Y)&&this.Y.call(this.dt,void 0),i.set(this.Y,e),void 0!==e&&this.Y.call(this.dt,e)}else this.Y.value=e}get lt(){var e,t,n;return"function"==typeof this.Y?null===(t=Ue.get(null!==(e=this.dt)&&void 0!==e?e:globalThis))||void 0===t?void 0:t.get(this.Y):null===(n=this.Y)||void 0===n?void 0:n.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),He=$e(class extends ke{constructor(e){var t;if(super(e),e.type!==Ce.ATTRIBUTE||"style"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,n)=>{const i=e[n];return null==i?t:t+`${n=n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`}),"")}update(e,[t]){const{style:n}=e.element;if(void 0===this.vt){this.vt=new Set;for(const e in t)this.vt.add(e);return this.render(t)}this.vt.forEach((e=>{null==t[e]&&(this.vt.delete(e),e.includes("-")?n.removeProperty(e):n[e]="")}));for(const e in t){const i=t[e];null!=i&&(this.vt.add(e),e.includes("-")?n.setProperty(e,i):n[e]=i)}return X}});
/**
 * @license
 * Copyright 2018 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */function Ze(e,t){return e===t||e!=e&&t!=t}function qe(e,t){for(var n=e.length;n--;)if(Ze(e[n][0],t))return n;return-1}var Ve=Array.prototype.splice;function We(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}We.prototype.clear=function(){this.__data__=[],this.size=0},We.prototype.delete=function(e){var t=this.__data__,n=qe(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ve.call(t,n,1),--this.size,!0)},We.prototype.get=function(e){var t=this.__data__,n=qe(t,e);return n<0?void 0:t[n][1]},We.prototype.has=function(e){return qe(this.__data__,e)>-1},We.prototype.set=function(e,t){var n=this.__data__,i=qe(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this};var Be="object"==typeof global&&global&&global.Object===Object&&global,Ye="object"==typeof self&&self&&self.Object===Object&&self,Qe=Be||Ye||Function("return this")(),Ge=Qe.Symbol,Ke=Object.prototype,Xe=Ke.hasOwnProperty,Je=Ke.toString,et=Ge?Ge.toStringTag:void 0;var tt=Object.prototype.toString;var nt="[object Null]",it="[object Undefined]",at=Ge?Ge.toStringTag:void 0;function rt(e){return null==e?void 0===e?it:nt:at&&at in Object(e)?function(e){var t=Xe.call(e,et),n=e[et];try{e[et]=void 0;var i=!0}catch(e){}var a=Je.call(e);return i&&(t?e[et]=n:delete e[et]),a}(e):function(e){return tt.call(e)}(e)}function ot(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var st="[object AsyncFunction]",ct="[object Function]",lt="[object GeneratorFunction]",dt="[object Proxy]";function ut(e){if(!ot(e))return!1;var t=rt(e);return t==ct||t==lt||t==st||t==dt}var ht,mt=Qe["__core-js_shared__"],pt=(ht=/[^.]+$/.exec(mt&&mt.keys&&mt.keys.IE_PROTO||""))?"Symbol(src)_1."+ht:"";var ft=Function.prototype.toString;function gt(e){if(null!=e){try{return ft.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var vt=/^\[object .+?Constructor\]$/,_t=Function.prototype,yt=Object.prototype,bt=_t.toString,wt=yt.hasOwnProperty,xt=RegExp("^"+bt.call(wt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ct(e){return!(!ot(e)||(t=e,pt&&pt in t))&&(ut(e)?xt:vt).test(gt(e));var t}function $t(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ct(n)?n:void 0}var kt=$t(Qe,"Map"),Et=$t(Object,"create");var Mt="__lodash_hash_undefined__",St=Object.prototype.hasOwnProperty;var Tt=Object.prototype.hasOwnProperty;var At="__lodash_hash_undefined__";function zt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function jt(e,t){var n=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function Ot(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}zt.prototype.clear=function(){this.__data__=Et?Et(null):{},this.size=0},zt.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},zt.prototype.get=function(e){var t=this.__data__;if(Et){var n=t[e];return n===Mt?void 0:n}return St.call(t,e)?t[e]:void 0},zt.prototype.has=function(e){var t=this.__data__;return Et?void 0!==t[e]:Tt.call(t,e)},zt.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Et&&void 0===t?At:t,this},Ot.prototype.clear=function(){this.size=0,this.__data__={hash:new zt,map:new(kt||We),string:new zt}},Ot.prototype.delete=function(e){var t=jt(this,e).delete(e);return this.size-=t?1:0,t},Ot.prototype.get=function(e){return jt(this,e).get(e)},Ot.prototype.has=function(e){return jt(this,e).has(e)},Ot.prototype.set=function(e,t){var n=jt(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this};var It=200;function Rt(e){var t=this.__data__=new We(e);this.size=t.size}Rt.prototype.clear=function(){this.__data__=new We,this.size=0},Rt.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Rt.prototype.get=function(e){return this.__data__.get(e)},Rt.prototype.has=function(e){return this.__data__.has(e)},Rt.prototype.set=function(e,t){var n=this.__data__;if(n instanceof We){var i=n.__data__;if(!kt||i.length<It-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Ot(i)}return n.set(e,t),this.size=n.size,this};var Dt=function(){try{var e=$t(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();function Pt(e,t,n){"__proto__"==t&&Dt?Dt(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var Lt=Object.prototype.hasOwnProperty;function Nt(e,t,n){var i=e[t];Lt.call(e,t)&&Ze(i,n)&&(void 0!==n||t in e)||Pt(e,t,n)}function Ut(e,t,n,i){var a=!n;n||(n={});for(var r=-1,o=t.length;++r<o;){var s=t[r],c=i?i(n[s],e[s],s,n,e):void 0;void 0===c&&(c=e[s]),a?Pt(n,s,c):Nt(n,s,c)}return n}function Ft(e){return null!=e&&"object"==typeof e}var Ht="[object Arguments]";function Zt(e){return Ft(e)&&rt(e)==Ht}var qt=Object.prototype,Vt=qt.hasOwnProperty,Wt=qt.propertyIsEnumerable,Bt=Zt(function(){return arguments}())?Zt:function(e){return Ft(e)&&Vt.call(e,"callee")&&!Wt.call(e,"callee")},Yt=Array.isArray;var Qt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Gt=Qt&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Gt&&Gt.exports===Qt?Qe.Buffer:void 0,Xt=(Kt?Kt.isBuffer:void 0)||function(){return!1},Jt=9007199254740991,en=/^(?:0|[1-9]\d*)$/;function tn(e,t){var n=typeof e;return!!(t=null==t?Jt:t)&&("number"==n||"symbol"!=n&&en.test(e))&&e>-1&&e%1==0&&e<t}var nn=9007199254740991;function an(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=nn}var rn={};function on(e){return function(t){return e(t)}}rn["[object Float32Array]"]=rn["[object Float64Array]"]=rn["[object Int8Array]"]=rn["[object Int16Array]"]=rn["[object Int32Array]"]=rn["[object Uint8Array]"]=rn["[object Uint8ClampedArray]"]=rn["[object Uint16Array]"]=rn["[object Uint32Array]"]=!0,rn["[object Arguments]"]=rn["[object Array]"]=rn["[object ArrayBuffer]"]=rn["[object Boolean]"]=rn["[object DataView]"]=rn["[object Date]"]=rn["[object Error]"]=rn["[object Function]"]=rn["[object Map]"]=rn["[object Number]"]=rn["[object Object]"]=rn["[object RegExp]"]=rn["[object Set]"]=rn["[object String]"]=rn["[object WeakMap]"]=!1;var sn="object"==typeof exports&&exports&&!exports.nodeType&&exports,cn=sn&&"object"==typeof module&&module&&!module.nodeType&&module,ln=cn&&cn.exports===sn&&Be.process,dn=function(){try{var e=cn&&cn.require&&cn.require("util").types;return e||ln&&ln.binding&&ln.binding("util")}catch(e){}}(),un=dn&&dn.isTypedArray,hn=un?on(un):function(e){return Ft(e)&&an(e.length)&&!!rn[rt(e)]},mn=Object.prototype.hasOwnProperty;function pn(e,t){var n=Yt(e),i=!n&&Bt(e),a=!n&&!i&&Xt(e),r=!n&&!i&&!a&&hn(e),o=n||i||a||r,s=o?function(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}(e.length,String):[],c=s.length;for(var l in e)!t&&!mn.call(e,l)||o&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||tn(l,c))||s.push(l);return s}var fn=Object.prototype;function gn(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||fn)}function vn(e,t){return function(n){return e(t(n))}}var _n=vn(Object.keys,Object),yn=Object.prototype.hasOwnProperty;function bn(e){return null!=e&&an(e.length)&&!ut(e)}function wn(e){return bn(e)?pn(e):function(e){if(!gn(e))return _n(e);var t=[];for(var n in Object(e))yn.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}var xn=Object.prototype.hasOwnProperty;function Cn(e){if(!ot(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=gn(e),n=[];for(var i in e)("constructor"!=i||!t&&xn.call(e,i))&&n.push(i);return n}function $n(e){return bn(e)?pn(e,!0):Cn(e)}var kn="object"==typeof exports&&exports&&!exports.nodeType&&exports,En=kn&&"object"==typeof module&&module&&!module.nodeType&&module,Mn=En&&En.exports===kn?Qe.Buffer:void 0,Sn=Mn?Mn.allocUnsafe:void 0;function Tn(e,t){if(t)return e.slice();var n=e.length,i=Sn?Sn(n):new e.constructor(n);return e.copy(i),i}function An(e,t){var n=-1,i=e.length;for(t||(t=Array(i));++n<i;)t[n]=e[n];return t}function zn(){return[]}var jn=Object.prototype.propertyIsEnumerable,On=Object.getOwnPropertySymbols,In=On?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,i=null==e?0:e.length,a=0,r=[];++n<i;){var o=e[n];t(o,n,e)&&(r[a++]=o)}return r}(On(e),(function(t){return jn.call(e,t)})))}:zn;function Rn(e,t){for(var n=-1,i=t.length,a=e.length;++n<i;)e[a+n]=t[n];return e}var Dn=vn(Object.getPrototypeOf,Object),Pn=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Rn(t,In(e)),e=Dn(e);return t}:zn;function Ln(e,t,n){var i=t(e);return Yt(e)?i:Rn(i,n(e))}function Nn(e){return Ln(e,wn,In)}function Un(e){return Ln(e,$n,Pn)}var Fn=$t(Qe,"DataView"),Hn=$t(Qe,"Promise"),Zn=$t(Qe,"Set"),qn=$t(Qe,"WeakMap"),Vn="[object Map]",Wn="[object Promise]",Bn="[object Set]",Yn="[object WeakMap]",Qn="[object DataView]",Gn=gt(Fn),Kn=gt(kt),Xn=gt(Hn),Jn=gt(Zn),ei=gt(qn),ti=rt;(Fn&&ti(new Fn(new ArrayBuffer(1)))!=Qn||kt&&ti(new kt)!=Vn||Hn&&ti(Hn.resolve())!=Wn||Zn&&ti(new Zn)!=Bn||qn&&ti(new qn)!=Yn)&&(ti=function(e){var t=rt(e),n="[object Object]"==t?e.constructor:void 0,i=n?gt(n):"";if(i)switch(i){case Gn:return Qn;case Kn:return Vn;case Xn:return Wn;case Jn:return Bn;case ei:return Yn}return t});var ni=ti,ii=Object.prototype.hasOwnProperty;var ai=Qe.Uint8Array;function ri(e){var t=new e.constructor(e.byteLength);return new ai(t).set(new ai(e)),t}var oi=/\w*$/;var si=Ge?Ge.prototype:void 0,ci=si?si.valueOf:void 0;function li(e,t){var n=t?ri(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var di="[object Boolean]",ui="[object Date]",hi="[object Map]",mi="[object Number]",pi="[object RegExp]",fi="[object Set]",gi="[object String]",vi="[object Symbol]",_i="[object ArrayBuffer]",yi="[object DataView]",bi="[object Float32Array]",wi="[object Float64Array]",xi="[object Int8Array]",Ci="[object Int16Array]",$i="[object Int32Array]",ki="[object Uint8Array]",Ei="[object Uint8ClampedArray]",Mi="[object Uint16Array]",Si="[object Uint32Array]";function Ti(e,t,n){var i,a,r,o=e.constructor;switch(t){case _i:return ri(e);case di:case ui:return new o(+e);case yi:return function(e,t){var n=t?ri(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case bi:case wi:case xi:case Ci:case $i:case ki:case Ei:case Mi:case Si:return li(e,n);case hi:return new o;case mi:case gi:return new o(e);case pi:return(r=new(a=e).constructor(a.source,oi.exec(a))).lastIndex=a.lastIndex,r;case fi:return new o;case vi:return i=e,ci?Object(ci.call(i)):{}}}var Ai=Object.create,zi=function(){function e(){}return function(t){if(!ot(t))return{};if(Ai)return Ai(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function ji(e){return"function"!=typeof e.constructor||gn(e)?{}:zi(Dn(e))}var Oi="[object Map]";var Ii=dn&&dn.isMap,Ri=Ii?on(Ii):function(e){return Ft(e)&&ni(e)==Oi},Di="[object Set]";var Pi=dn&&dn.isSet,Li=Pi?on(Pi):function(e){return Ft(e)&&ni(e)==Di},Ni=1,Ui=2,Fi=4,Hi="[object Arguments]",Zi="[object Function]",qi="[object GeneratorFunction]",Vi="[object Object]",Wi={};function Bi(e,t,n,i,a,r){var o,s=t&Ni,c=t&Ui,l=t&Fi;if(n&&(o=a?n(e,i,a,r):n(e)),void 0!==o)return o;if(!ot(e))return e;var d=Yt(e);if(d){if(o=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&ii.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!s)return An(e,o)}else{var u=ni(e),h=u==Zi||u==qi;if(Xt(e))return Tn(e,s);if(u==Vi||u==Hi||h&&!a){if(o=c||h?{}:ji(e),!s)return c?function(e,t){return Ut(e,Pn(e),t)}(e,function(e,t){return e&&Ut(t,$n(t),e)}(o,e)):function(e,t){return Ut(e,In(e),t)}(e,function(e,t){return e&&Ut(t,wn(t),e)}(o,e))}else{if(!Wi[u])return a?e:{};o=Ti(e,u,s)}}r||(r=new Rt);var m=r.get(e);if(m)return m;r.set(e,o),Li(e)?e.forEach((function(i){o.add(Bi(i,t,n,i,e,r))})):Ri(e)&&e.forEach((function(i,a){o.set(a,Bi(i,t,n,a,e,r))}));var p=d?void 0:(l?c?Un:Nn:c?$n:wn)(e);return function(e,t){for(var n=-1,i=null==e?0:e.length;++n<i&&!1!==t(e[n],n,e););}(p||e,(function(i,a){p&&(i=e[a=i]),Nt(o,a,Bi(i,t,n,a,e,r))})),o}Wi[Hi]=Wi["[object Array]"]=Wi["[object ArrayBuffer]"]=Wi["[object DataView]"]=Wi["[object Boolean]"]=Wi["[object Date]"]=Wi["[object Float32Array]"]=Wi["[object Float64Array]"]=Wi["[object Int8Array]"]=Wi["[object Int16Array]"]=Wi["[object Int32Array]"]=Wi["[object Map]"]=Wi["[object Number]"]=Wi[Vi]=Wi["[object RegExp]"]=Wi["[object Set]"]=Wi["[object String]"]=Wi["[object Symbol]"]=Wi["[object Uint8Array]"]=Wi["[object Uint8ClampedArray]"]=Wi["[object Uint16Array]"]=Wi["[object Uint32Array]"]=!0,Wi["[object Error]"]=Wi[Zi]=Wi["[object WeakMap]"]=!1;var Yi=1,Qi=4;function Gi(e){return Bi(e,Yi|Qi)}var Ki="__lodash_hash_undefined__";function Xi(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Ot;++t<n;)this.add(e[t])}function Ji(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;)if(t(e[n],n,e))return!0;return!1}function ea(e,t){return e.has(t)}Xi.prototype.add=Xi.prototype.push=function(e){return this.__data__.set(e,Ki),this},Xi.prototype.has=function(e){return this.__data__.has(e)};var ta=1,na=2;function ia(e,t,n,i,a,r){var o=n&ta,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var u=-1,h=!0,m=n&na?new Xi:void 0;for(r.set(e,t),r.set(t,e);++u<s;){var p=e[u],f=t[u];if(i)var g=o?i(f,p,u,t,e,r):i(p,f,u,e,t,r);if(void 0!==g){if(g)continue;h=!1;break}if(m){if(!Ji(t,(function(e,t){if(!ea(m,t)&&(p===e||a(p,e,n,i,r)))return m.push(t)}))){h=!1;break}}else if(p!==f&&!a(p,f,n,i,r)){h=!1;break}}return r.delete(e),r.delete(t),h}function aa(e){var t=-1,n=Array(e.size);return e.forEach((function(e,i){n[++t]=[i,e]})),n}function ra(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var oa=1,sa=2,ca="[object Boolean]",la="[object Date]",da="[object Error]",ua="[object Map]",ha="[object Number]",ma="[object RegExp]",pa="[object Set]",fa="[object String]",ga="[object Symbol]",va="[object ArrayBuffer]",_a="[object DataView]",ya=Ge?Ge.prototype:void 0,ba=ya?ya.valueOf:void 0;var wa=1,xa=Object.prototype.hasOwnProperty;var Ca=1,$a="[object Arguments]",ka="[object Array]",Ea="[object Object]",Ma=Object.prototype.hasOwnProperty;function Sa(e,t,n,i,a,r){var o=Yt(e),s=Yt(t),c=o?ka:ni(e),l=s?ka:ni(t),d=(c=c==$a?Ea:c)==Ea,u=(l=l==$a?Ea:l)==Ea,h=c==l;if(h&&Xt(e)){if(!Xt(t))return!1;o=!0,d=!1}if(h&&!d)return r||(r=new Rt),o||hn(e)?ia(e,t,n,i,a,r):function(e,t,n,i,a,r,o){switch(n){case _a:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case va:return!(e.byteLength!=t.byteLength||!r(new ai(e),new ai(t)));case ca:case la:case ha:return Ze(+e,+t);case da:return e.name==t.name&&e.message==t.message;case ma:case fa:return e==t+"";case ua:var s=aa;case pa:var c=i&oa;if(s||(s=ra),e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;i|=sa,o.set(e,t);var d=ia(s(e),s(t),i,a,r,o);return o.delete(e),d;case ga:if(ba)return ba.call(e)==ba.call(t)}return!1}(e,t,c,n,i,a,r);if(!(n&Ca)){var m=d&&Ma.call(e,"__wrapped__"),p=u&&Ma.call(t,"__wrapped__");if(m||p){var f=m?e.value():e,g=p?t.value():t;return r||(r=new Rt),a(f,g,n,i,r)}}return!!h&&(r||(r=new Rt),function(e,t,n,i,a,r){var o=n&wa,s=Nn(e),c=s.length;if(c!=Nn(t).length&&!o)return!1;for(var l=c;l--;){var d=s[l];if(!(o?d in t:xa.call(t,d)))return!1}var u=r.get(e),h=r.get(t);if(u&&h)return u==t&&h==e;var m=!0;r.set(e,t),r.set(t,e);for(var p=o;++l<c;){var f=e[d=s[l]],g=t[d];if(i)var v=o?i(g,f,d,t,e,r):i(f,g,d,e,t,r);if(!(void 0===v?f===g||a(f,g,n,i,r):v)){m=!1;break}p||(p="constructor"==d)}if(m&&!p){var _=e.constructor,y=t.constructor;_==y||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof y&&y instanceof y||(m=!1)}return r.delete(e),r.delete(t),m}(e,t,n,i,a,r))}function Ta(e,t,n,i,a){return e===t||(null==e||null==t||!Ft(e)&&!Ft(t)?e!=e&&t!=t:Sa(e,t,n,i,Ta,a))}function Aa(e,t){return Ta(e,t)}function za(e,t,n){(void 0!==n&&!Ze(e[t],n)||void 0===n&&!(t in e))&&Pt(e,t,n)}var ja,Oa=function(e,t,n){for(var i=-1,a=Object(e),r=n(e),o=r.length;o--;){var s=r[ja?o:++i];if(!1===t(a[s],s,a))break}return e};var Ia="[object Object]",Ra=Function.prototype,Da=Object.prototype,Pa=Ra.toString,La=Da.hasOwnProperty,Na=Pa.call(Object);function Ua(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function Fa(e,t,n,i,a,r,o){var s=Ua(e,n),c=Ua(t,n),l=o.get(c);if(l)za(e,n,l);else{var d,u=r?r(s,c,n+"",e,t,o):void 0,h=void 0===u;if(h){var m=Yt(c),p=!m&&Xt(c),f=!m&&!p&&hn(c);u=c,m||p||f?Yt(s)?u=s:Ft(d=s)&&bn(d)?u=An(s):p?(h=!1,u=Tn(c,!0)):f?(h=!1,u=li(c,!0)):u=[]:function(e){if(!Ft(e)||rt(e)!=Ia)return!1;var t=Dn(e);if(null===t)return!0;var n=La.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Pa.call(n)==Na}(c)||Bt(c)?(u=s,Bt(s)?u=function(e){return Ut(e,$n(e))}(s):ot(s)&&!ut(s)||(u=ji(c))):h=!1}h&&(o.set(c,u),a(u,c,i,r,o),o.delete(c)),za(e,n,u)}}function Ha(e,t,n,i,a){e!==t&&Oa(t,(function(r,o){if(a||(a=new Rt),ot(r))Fa(e,t,o,n,Ha,i,a);else{var s=i?i(Ua(e,o),r,o+"",e,t,a):void 0;void 0===s&&(s=r),za(e,o,s)}}),$n)}function Za(e){return e}var qa=Math.max;var Va=Dt?function(e,t){return Dt(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:Za,Wa=800,Ba=16,Ya=Date.now;var Qa,Ga,Ka,Xa=(Qa=Va,Ga=0,Ka=0,function(){var e=Ya(),t=Ba-(e-Ka);if(Ka=e,t>0){if(++Ga>=Wa)return arguments[0]}else Ga=0;return Qa.apply(void 0,arguments)});function Ja(e,t){return Xa(function(e,t,n){return t=qa(void 0===t?e.length-1:t,0),function(){for(var i=arguments,a=-1,r=qa(i.length-t,0),o=Array(r);++a<r;)o[a]=i[t+a];a=-1;for(var s=Array(t+1);++a<t;)s[a]=i[a];return s[t]=n(o),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,s)}}(e,t,Za),e+"")}var er,tr=(er=function(e,t,n){Ha(e,t,n)},Ja((function(e,t){var n=-1,i=t.length,a=i>1?t[i-1]:void 0,r=i>2?t[2]:void 0;for(a=er.length>3&&"function"==typeof a?(i--,a):void 0,r&&function(e,t,n){if(!ot(n))return!1;var i=typeof t;return!!("number"==i?bn(n)&&tn(t,n.length):"string"==i&&t in n)&&Ze(n[t],e)}(t[0],t[1],r)&&(a=i<3?void 0:a,i=1),e=Object(e);++n<i;){var o=t[n];o&&er(e,o,n,a)}return e}))),nr=function(){return Qe.Date.now()},ir=/\s/;var ar=/^\s+/;function rr(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&ir.test(e.charAt(t)););return t}(e)+1).replace(ar,""):e}var or="[object Symbol]";function sr(e){return"symbol"==typeof e||Ft(e)&&rt(e)==or}var cr=NaN,lr=/^[-+]0x[0-9a-f]+$/i,dr=/^0b[01]+$/i,ur=/^0o[0-7]+$/i,hr=parseInt;function mr(e){if("number"==typeof e)return e;if(sr(e))return cr;if(ot(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ot(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=rr(e);var n=dr.test(e);return n||ur.test(e)?hr(e.slice(2),n?2:8):lr.test(e)?cr:+e}var pr="Expected a function",fr=Math.max,gr=Math.min;function vr(e,t,n){var i,a,r,o,s,c,l=0,d=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError(pr);function m(t){var n=i,r=a;return i=a=void 0,l=t,o=e.apply(r,n)}function p(e){var n=e-c;return void 0===c||n>=t||n<0||u&&e-l>=r}function f(){var e=nr();if(p(e))return g(e);s=setTimeout(f,function(e){var n=t-(e-c);return u?gr(n,r-(e-l)):n}(e))}function g(e){return s=void 0,h&&i?m(e):(i=a=void 0,o)}function v(){var e=nr(),n=p(e);if(i=arguments,a=this,c=e,n){if(void 0===s)return function(e){return l=e,s=setTimeout(f,t),d?m(e):o}(c);if(u)return clearTimeout(s),s=setTimeout(f,t),m(c)}return void 0===s&&(s=setTimeout(f,t)),o}return t=mr(t)||0,ot(n)&&(d=!!n.leading,r=(u="maxWait"in n)?fr(mr(n.maxWait)||0,t):r,h="trailing"in n?!!n.trailing:h),v.cancel=function(){void 0!==s&&clearTimeout(s),l=0,i=c=a=s=void 0},v.flush=function(){return void 0===s?o:g(nr())},v}var _r="Expected a function";function yr(e,t,n){var i=!0,a=!0;if("function"!=typeof e)throw new TypeError(_r);return ot(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),vr(e,t,{leading:i,maxWait:t,trailing:a})}const br=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],wr=(()=>{if("undefined"==typeof document)return!1;const e=br[0],t={};for(const n of br){const i=n?.[1];if(i in document){for(const[i,a]of n.entries())t[e[i]]=a;return t}}return!1})(),xr={change:wr.fullscreenchange,error:wr.fullscreenerror};let Cr={request:(e=document.documentElement,t)=>new Promise(((n,i)=>{const a=()=>{Cr.off("change",a),n()};Cr.on("change",a);const r=e[wr.requestFullscreen](t);r instanceof Promise&&r.then(a).catch(i)})),exit:()=>new Promise(((e,t)=>{if(!Cr.isFullscreen)return void e();const n=()=>{Cr.off("change",n),e()};Cr.on("change",n);const i=document[wr.exitFullscreen]();i instanceof Promise&&i.then(n).catch(t)})),toggle:(e,t)=>Cr.isFullscreen?Cr.exit():Cr.request(e,t),onchange(e){Cr.on("change",e)},onerror(e){Cr.on("error",e)},on(e,t){const n=xr[e];n&&document.addEventListener(n,t,!1)},off(e,t){const n=xr[e];n&&document.removeEventListener(n,t,!1)},raw:wr};Object.defineProperties(Cr,{isFullscreen:{get:()=>Boolean(document[wr.fullscreenElement])},element:{enumerable:!0,get:()=>document[wr.fullscreenElement]??void 0},isEnabled:{enumerable:!0,get:()=>Boolean(document[wr.fullscreenEnabled])}}),wr||(Cr={isEnabled:!1});var $r=Cr;function kr(e,t,n,i=20,a=0){let r=[];if(a>=i)return r;const o=e=>{const r=e.assignedNodes().filter((e=>1===e.nodeType));return r.length>0?kr(r[0].parentElement,t,n,i,a+1):[]},s=Array.from(e.children||[]);for(const e of s)t(e)||(n(e)&&r.push(e),null!=e.shadowRoot?r.push(...kr(e.shadowRoot,t,n,i,a+1)):"SLOT"===e.tagName?r.push(...o(e)):r.push(...kr(e,t,n,i,a+1)));return r}function Er(e){return e.hasAttribute("hidden")||e.hasAttribute("aria-hidden")&&"false"!==e.getAttribute("aria-hidden")||"none"===e.style.display||"0"===e.style.opacity||"hidden"===e.style.visibility||"collapse"===e.style.visibility}function Mr(e){return"-1"!==e.getAttribute("tabindex")&&!Er(e)&&!function(e){return e.hasAttribute("disabled")||e.hasAttribute("aria-disabled")&&"false"!==e.getAttribute("aria-disabled")}(e)&&(e.hasAttribute("tabindex")||(e instanceof HTMLAnchorElement||e instanceof HTMLAreaElement)&&e.hasAttribute("href")||e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLIFrameElement)}const Sr=new Map;const Tr=document.createElement("template");Tr.innerHTML='\n\t<div id="start"></div>\n\t<div id="backup"></div>\n\t<slot></slot>\n\t<div id="end"></div>\n';class Ar extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const e=this.attachShadow({mode:"open"});e.appendChild(Tr.content.cloneNode(!0)),this.$backup=e.querySelector("#backup"),this.$start=e.querySelector("#start"),this.$end=e.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(e){e?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return kr(this,Er,Mr)}trapFocus(e){if(this.inactive)return;let t=this.getFocusableElements();t.length>0?(e?t[t.length-1].focus():t[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(e){!function(e,t,n){const i=Sr.get(n);null!=i&&window.clearTimeout(i),Sr.set(n,window.setTimeout((()=>{e(),Sr.delete(n)}),t))}((()=>{this.focused!==e&&(this._focused=e,this.render())}),0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}function zr(e){return Number(e.getAttribute("data-dialog-count"))||0}function jr(e,t){e.setAttribute("data-dialog-count",t.toString())}function Or(e=document.activeElement){return null!=e&&null!=e.shadowRoot&&null!=e.shadowRoot.activeElement?Or(e.shadowRoot.activeElement):e}window.customElements.define("focus-trap",Ar);const Ir=document.createElement("template");Ir.innerHTML='\n  <style>*{box-sizing:border-box}:host{padding:var(--dialog-container-padding,5vw 24px);z-index:var(--dialog-z-index,12345678);outline:none}#backdrop,:host{position:fixed;top:0;left:0;bottom:0;right:0}:host,:host([center]) #dialog{overflow-x:var(--dialog-overflow-x,hidden);overflow-y:var(--dialog-overflow-y,auto);overscroll-behavior:contain;-webkit-overflow-scrolling:touch}:host([center]){display:flex;align-items:center;justify-content:center;overflow:hidden}:host([center]) #dialog{max-height:var(--dialog-max-height,100%)}:host(:not(:defined)),:host(:not([open])){display:none}#backdrop{background:var(--dialog-backdrop-bg,rgba(0,0,0,.6));animation:fadeIn var(--dialog-animation-duration,.1s) var(--dialog-animation-easing,ease-out);z-index:-1}#dialog{animation:scaleIn var(--dialog-animation-duration,.1s) var(--dialog-animation-easing,ease-out);border-radius:var(--dialog-border-radius,12px);box-shadow:var(--dialog-box-shadow,0 2px 10px -5px rgba(0,0,0,.6));max-width:var(--dialog-max-width,700px);width:var(--dialog-width,100%);padding:var(--dialog-padding,24px);max-height:var(--dialog-max-height,unset);height:var(--dialog-height,auto);color:var(--dialog-color,currentColor);background:var(--dialog-bg,#fff);z-index:1;position:relative;display:flex;flex-direction:column;margin:0 auto;border:none}::slotted(article),article{flex-grow:1;overflow-y:auto;-webkit-overflow-scrolling:touch}::slotted(footer),::slotted(header),footer,header{flex-shrink:0}@keyframes scaleIn{0%{transform:scale(.9) translateY(30px);opacity:0}to{transform:scale(1) translateY(0);opacity:1}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}</style>\n  <div id="backdrop" part="backdrop"></div>\n  <focus-trap id="dialog" part="dialog">\n    <slot></slot>\n  </focus-trap>\n';class Rr extends HTMLElement{constructor(){super(),this.$scrollContainer=document.documentElement,this.$previousActiveElement=null;const e=this.attachShadow({mode:"open"});e.appendChild(Ir.content.cloneNode(!0)),this.$dialog=e.querySelector("#dialog"),this.$backdrop=e.querySelector("#backdrop"),this.onBackdropClick=this.onBackdropClick.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.setAttribute("aria-modal","true"),this.$dialog.setAttribute("role","alertdialog")}static get observedAttributes(){return["open","center"]}get open(){return this.hasAttribute("open")}set open(e){e?this.setAttribute("open",""):this.removeAttribute("open")}get center(){return this.hasAttribute("center")}set center(e){e?this.setAttribute("center",""):this.removeAttribute("center")}connectedCallback(){this.$backdrop.addEventListener("click",this.onBackdropClick)}disconnectedCallback(){this.$backdrop.removeEventListener("click",this.onBackdropClick),this.open&&this.didClose()}show(){this.open=!0}close(e){this.result=e,this.open=!1}onBackdropClick(){this.assertClosing()&&this.close()}onKeyDown(e){if("Escape"===e.code)this.assertClosing()&&(this.close(),e.stopImmediatePropagation())}assertClosing(){return this.dispatchEvent(new CustomEvent("closing",{cancelable:!0}))}didOpen(){this.$previousActiveElement=Or(document.activeElement),requestAnimationFrame((()=>{this.$dialog.focusFirstElement()})),this.tabIndex=0,this.$scrollContainer.style.overflow="hidden",this.addEventListener("keydown",this.onKeyDown,{capture:!0,passive:!0}),jr(this.$scrollContainer,zr(this.$scrollContainer)+1),this.dispatchEvent(new CustomEvent("open"))}didClose(){this.removeEventListener("keydown",this.onKeyDown,{capture:!0}),jr(this.$scrollContainer,Math.max(0,zr(this.$scrollContainer)-1)),zr(this.$scrollContainer)<=0&&(this.$scrollContainer.style.overflow=""),this.tabIndex=-1,null!=this.$previousActiveElement&&(this.$previousActiveElement.focus(),this.$previousActiveElement=null),this.dispatchEvent(new CustomEvent("close",{detail:this.result}))}attributeChangedCallback(e,t,n){if("open"===e)this.open?this.didOpen():this.didClose()}}customElements.define("web-dialog",Rr);var Dr,Pr,Lr="5.2.0",Nr="Fri, 23 Jun 2023 15:26:26 GMT",Ur="Thu, 22 Jun 2023 09:21:26 -0600",Fr="5.2.0-HEAD+g69249b6";!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),i={};for(const e of n)i[e]=t[e];return e.objectValues(i)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(Dr||(Dr={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(Pr||(Pr={}));const Hr=Dr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Zr=e=>{switch(typeof e){case"undefined":return Hr.undefined;case"string":return Hr.string;case"number":return isNaN(e)?Hr.nan:Hr.number;case"boolean":return Hr.boolean;case"function":return Hr.function;case"bigint":return Hr.bigint;case"symbol":return Hr.symbol;case"object":return Array.isArray(e)?Hr.array:null===e?Hr.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Hr.promise:"undefined"!=typeof Map&&e instanceof Map?Hr.map:"undefined"!=typeof Set&&e instanceof Set?Hr.set:"undefined"!=typeof Date&&e instanceof Date?Hr.date:Hr.object;default:return Hr.unknown}},qr=Dr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Vr extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},n={_errors:[]},i=e=>{for(const a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(i);else if("invalid_return_type"===a.code)i(a.returnTypeError);else if("invalid_arguments"===a.code)i(a.argumentsError);else if(0===a.path.length)n._errors.push(t(a));else{let e=n,i=0;for(;i<a.path.length;){const n=a.path[i];i===a.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(a))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Dr.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=(e=>e.message)){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Vr.create=e=>new Vr(e);const Wr=(e,t)=>{let n;switch(e.code){case qr.invalid_type:n=e.received===Hr.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case qr.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Dr.jsonStringifyReplacer)}`;break;case qr.unrecognized_keys:n=`Unrecognized key(s) in object: ${Dr.joinValues(e.keys,", ")}`;break;case qr.invalid_union:n="Invalid input";break;case qr.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Dr.joinValues(e.options)}`;break;case qr.invalid_enum_value:n=`Invalid enum value. Expected ${Dr.joinValues(e.options)}, received '${e.received}'`;break;case qr.invalid_arguments:n="Invalid function arguments";break;case qr.invalid_return_type:n="Invalid function return type";break;case qr.invalid_date:n="Invalid date";break;case qr.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Dr.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case qr.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case qr.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case qr.custom:n="Invalid input";break;case qr.invalid_intersection_types:n="Intersection results could not be merged";break;case qr.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case qr.not_finite:n="Number must be finite";break;default:n=t.defaultError,Dr.assertNever(e)}return{message:n}};let Br=Wr;function Yr(){return Br}const Qr=e=>{const{data:t,path:n,errorMaps:i,issueData:a}=e,r=[...n,...a.path||[]],o={...a,path:r};let s="";const c=i.filter((e=>!!e)).slice().reverse();for(const e of c)s=e(o,{data:t,defaultError:s}).message;return{...a,path:r,message:a.message||s}};function Gr(e,t){const n=Qr({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,Yr(),Wr].filter((e=>!!e))});e.common.issues.push(n)}class Kr{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if("aborted"===i.status)return Xr;"dirty"===i.status&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t)n.push({key:await e.key,value:await e.value});return Kr.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:t,value:a}=i;if("aborted"===t.status)return Xr;if("aborted"===a.status)return Xr;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),(void 0!==a.value||i.alwaysSet)&&(n[t.value]=a.value)}return{status:e.value,value:n}}}const Xr=Object.freeze({status:"aborted"}),Jr=e=>({status:"dirty",value:e}),eo=e=>({status:"valid",value:e}),to=e=>"aborted"===e.status,no=e=>"dirty"===e.status,io=e=>"valid"===e.status,ao=e=>"undefined"!=typeof Promise&&e instanceof Promise;var ro;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(ro||(ro={}));class oo{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const so=(e,t)=>{if(io(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Vr(e.common.issues);return this._error=t,this._error}}};function co(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:i,description:a}=e;if(t&&(n||i))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:a};return{errorMap:(e,t)=>"invalid_type"!==e.code?{message:t.defaultError}:void 0===t.data?{message:null!=i?i:t.defaultError}:{message:null!=n?n:t.defaultError},description:a}}class lo{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Zr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Kr,ctx:{common:e.parent.common,data:e.data,parsedType:Zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ao(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:null!==(n=null==t?void 0:t.async)&&void 0!==n&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Zr(e)},a=this._parseSync({data:e,path:i.path,parent:i});return so(i,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Zr(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(ao(i)?i:Promise.resolve(i));return so(n,a)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,i)=>{const a=e(t),r=()=>i.addIssue({code:qr.custom,...n(t)});return"undefined"!=typeof Promise&&a instanceof Promise?a.then((e=>!!e||(r(),!1))):!!a||(r(),!1)}))}refinement(e,t){return this._refinement(((n,i)=>!!e(n)||(i.addIssue("function"==typeof t?t(n,i):t),!1)))}_refinement(e){return new Xo({schema:this,typeName:ls.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Jo.create(this,this._def)}nullable(){return es.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Oo.create(this,this._def)}promise(){return Ko.create(this,this._def)}or(e){return Do.create([this,e],this._def)}and(e){return Uo.create(this,e,this._def)}transform(e){return new Xo({...co(this._def),schema:this,typeName:ls.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ts({...co(this._def),innerType:this,defaultValue:t,typeName:ls.ZodDefault})}brand(){return new rs({typeName:ls.ZodBranded,type:this,...co(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ns({...co(this._def),innerType:this,catchValue:t,typeName:ls.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return os.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const uo=/^c[^\s-]{8,}$/i,ho=/^[a-z][a-z0-9]*$/,mo=/[0-9A-HJKMNP-TV-Z]{26}/,po=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,fo=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/,go=/^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u,vo=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,_o=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function yo(e,t){return!("v4"!==t&&t||!vo.test(e))||!("v6"!==t&&t||!_o.test(e))}class bo extends lo{constructor(){super(...arguments),this._regex=(e,t,n)=>this.refinement((t=>e.test(t)),{validation:t,code:qr.invalid_string,...ro.errToObj(n)}),this.nonempty=e=>this.min(1,ro.errToObj(e)),this.trim=()=>new bo({...this._def,checks:[...this._def.checks,{kind:"trim"}]}),this.toLowerCase=()=>new bo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]}),this.toUpperCase=()=>new bo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==Hr.string){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.string,received:t.parsedType}),Xr}const t=new Kr;let n;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("max"===a.kind)e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("length"===a.kind){const i=e.data.length>a.value,r=e.data.length<a.value;(i||r)&&(n=this._getOrReturnCtx(e,n),i?Gr(n,{code:qr.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):r&&Gr(n,{code:qr.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if("email"===a.kind)fo.test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"email",code:qr.invalid_string,message:a.message}),t.dirty());else if("emoji"===a.kind)go.test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"emoji",code:qr.invalid_string,message:a.message}),t.dirty());else if("uuid"===a.kind)po.test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"uuid",code:qr.invalid_string,message:a.message}),t.dirty());else if("cuid"===a.kind)uo.test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"cuid",code:qr.invalid_string,message:a.message}),t.dirty());else if("cuid2"===a.kind)ho.test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"cuid2",code:qr.invalid_string,message:a.message}),t.dirty());else if("ulid"===a.kind)mo.test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"ulid",code:qr.invalid_string,message:a.message}),t.dirty());else if("url"===a.kind)try{new URL(e.data)}catch(i){n=this._getOrReturnCtx(e,n),Gr(n,{validation:"url",code:qr.invalid_string,message:a.message}),t.dirty()}else if("regex"===a.kind){a.regex.lastIndex=0;a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"regex",code:qr.invalid_string,message:a.message}),t.dirty())}else if("trim"===a.kind)e.data=e.data.trim();else if("includes"===a.kind)e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.dirty());else if("toLowerCase"===a.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===a.kind)e.data=e.data.toUpperCase();else if("startsWith"===a.kind)e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty());else if("endsWith"===a.kind)e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty());else if("datetime"===a.kind){((i=a).precision?i.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${i.precision}}Z$`):0===i.precision?i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):i.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$")).test(e.data)||(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.invalid_string,validation:"datetime",message:a.message}),t.dirty())}else"ip"===a.kind?yo(e.data,a.version)||(n=this._getOrReturnCtx(e,n),Gr(n,{validation:"ip",code:qr.invalid_string,message:a.message}),t.dirty()):Dr.assertNever(a);var i;return{status:t.value,value:e.data}}_addCheck(e){return new bo({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ro.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ro.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ro.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ro.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ro.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ro.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ro.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ro.errToObj(e)})}datetime(e){var t;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,...ro.errToObj(null==e?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ro.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...ro.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ro.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ro.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ro.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ro.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ro.errToObj(t)})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function wo(e,t){const n=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,a=n>i?n:i;return parseInt(e.toFixed(a).replace(".",""))%parseInt(t.toFixed(a).replace(".",""))/Math.pow(10,a)}bo.create=e=>{var t;return new bo({checks:[],typeName:ls.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...co(e)})};class xo extends lo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==Hr.number){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.number,received:t.parsedType}),Xr}let t;const n=new Kr;for(const i of this._def.checks)if("int"===i.kind)Dr.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty());else if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else"multipleOf"===i.kind?0!==wo(e.data,i.value)&&(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.not_finite,message:i.message}),n.dirty()):Dr.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ro.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ro.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ro.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ro.toString(t))}setLimit(e,t,n,i){return new xo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ro.toString(i)}]})}_addCheck(e){return new xo({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ro.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ro.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ro.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ro.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ro.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ro.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ro.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ro.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ro.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&Dr.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}xo.create=e=>new xo({checks:[],typeName:ls.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...co(e)});class Co extends lo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==Hr.bigint){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.bigint,received:t.parsedType}),Xr}let t;const n=new Kr;for(const i of this._def.checks)if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),Gr(t,{code:qr.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):Dr.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ro.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ro.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ro.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ro.toString(t))}setLimit(e,t,n,i){return new Co({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ro.toString(i)}]})}_addCheck(e){return new Co({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ro.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ro.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ro.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ro.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ro.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Co.create=e=>{var t;return new Co({checks:[],typeName:ls.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...co(e)})};class $o extends lo{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==Hr.boolean){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.boolean,received:t.parsedType}),Xr}return eo(e.data)}}$o.create=e=>new $o({typeName:ls.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...co(e)});class ko extends lo{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==Hr.date){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.date,received:t.parsedType}),Xr}if(isNaN(e.data.getTime())){return Gr(this._getOrReturnCtx(e),{code:qr.invalid_date}),Xr}const t=new Kr;let n;for(const i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),Gr(n,{code:qr.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Dr.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ko({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ro.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ro.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}ko.create=e=>new ko({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:ls.ZodDate,...co(e)});class Eo extends lo{_parse(e){if(this._getType(e)!==Hr.symbol){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.symbol,received:t.parsedType}),Xr}return eo(e.data)}}Eo.create=e=>new Eo({typeName:ls.ZodSymbol,...co(e)});class Mo extends lo{_parse(e){if(this._getType(e)!==Hr.undefined){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.undefined,received:t.parsedType}),Xr}return eo(e.data)}}Mo.create=e=>new Mo({typeName:ls.ZodUndefined,...co(e)});class So extends lo{_parse(e){if(this._getType(e)!==Hr.null){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.null,received:t.parsedType}),Xr}return eo(e.data)}}So.create=e=>new So({typeName:ls.ZodNull,...co(e)});class To extends lo{constructor(){super(...arguments),this._any=!0}_parse(e){return eo(e.data)}}To.create=e=>new To({typeName:ls.ZodAny,...co(e)});class Ao extends lo{constructor(){super(...arguments),this._unknown=!0}_parse(e){return eo(e.data)}}Ao.create=e=>new Ao({typeName:ls.ZodUnknown,...co(e)});class zo extends lo{_parse(e){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.never,received:t.parsedType}),Xr}}zo.create=e=>new zo({typeName:ls.ZodNever,...co(e)});class jo extends lo{_parse(e){if(this._getType(e)!==Hr.undefined){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.void,received:t.parsedType}),Xr}return eo(e.data)}}jo.create=e=>new jo({typeName:ls.ZodVoid,...co(e)});class Oo extends lo{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==Hr.array)return Gr(t,{code:qr.invalid_type,expected:Hr.array,received:t.parsedType}),Xr;if(null!==i.exactLength){const e=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(e||a)&&(Gr(t,{code:e?qr.too_big:qr.too_small,minimum:a?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(null!==i.minLength&&t.data.length<i.minLength.value&&(Gr(t,{code:qr.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),null!==i.maxLength&&t.data.length>i.maxLength.value&&(Gr(t,{code:qr.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map(((e,n)=>i.type._parseAsync(new oo(t,e,t.path,n))))).then((e=>Kr.mergeArray(n,e)));const a=[...t.data].map(((e,n)=>i.type._parseSync(new oo(t,e,t.path,n))));return Kr.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Oo({...this._def,minLength:{value:e,message:ro.toString(t)}})}max(e,t){return new Oo({...this._def,maxLength:{value:e,message:ro.toString(t)}})}length(e,t){return new Oo({...this._def,exactLength:{value:e,message:ro.toString(t)}})}nonempty(e){return this.min(1,e)}}function Io(e){if(e instanceof Ro){const t={};for(const n in e.shape){const i=e.shape[n];t[n]=Jo.create(Io(i))}return new Ro({...e._def,shape:()=>t})}return e instanceof Oo?new Oo({...e._def,type:Io(e.element)}):e instanceof Jo?Jo.create(Io(e.unwrap())):e instanceof es?es.create(Io(e.unwrap())):e instanceof Fo?Fo.create(e.items.map((e=>Io(e)))):e}Oo.create=(e,t)=>new Oo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ls.ZodArray,...co(t)});class Ro extends lo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=Dr.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Hr.object){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.object,received:t.parsedType}),Xr}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),r=[];if(!(this._def.catchall instanceof zo&&"strip"===this._def.unknownKeys))for(const e in n.data)a.includes(e)||r.push(e);const o=[];for(const e of a){const t=i[e],a=n.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new oo(n,a,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof zo){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of r)o.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)r.length>0&&(Gr(n,{code:qr.unrecognized_keys,keys:r}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of r){const i=n.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new oo(n,i,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of o){const n=await t.key;e.push({key:n,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>Kr.mergeObjectSync(t,e))):Kr.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return ro.errToObj,new Ro({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{var i,a,r,o;const s=null!==(r=null===(a=(i=this._def).errorMap)||void 0===a?void 0:a.call(i,t,n).message)&&void 0!==r?r:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(o=ro.errToObj(e).message)&&void 0!==o?o:s}:{message:s}}}:{}})}strip(){return new Ro({...this._def,unknownKeys:"strip"})}passthrough(){return new Ro({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ro({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ro({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ls.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ro({...this._def,catchall:e})}pick(e){const t={};return Dr.objectKeys(e).forEach((n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])})),new Ro({...this._def,shape:()=>t})}omit(e){const t={};return Dr.objectKeys(this.shape).forEach((n=>{e[n]||(t[n]=this.shape[n])})),new Ro({...this._def,shape:()=>t})}deepPartial(){return Io(this)}partial(e){const t={};return Dr.objectKeys(this.shape).forEach((n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()})),new Ro({...this._def,shape:()=>t})}required(e){const t={};return Dr.objectKeys(this.shape).forEach((n=>{if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof Jo;)e=e._def.innerType;t[n]=e}})),new Ro({...this._def,shape:()=>t})}keyof(){return Yo(Dr.objectKeys(this.shape))}}Ro.create=(e,t)=>new Ro({shape:()=>e,unknownKeys:"strip",catchall:zo.create(),typeName:ls.ZodObject,...co(t)}),Ro.strictCreate=(e,t)=>new Ro({shape:()=>e,unknownKeys:"strict",catchall:zo.create(),typeName:ls.ZodObject,...co(t)}),Ro.lazycreate=(e,t)=>new Ro({shape:e,unknownKeys:"strip",catchall:zo.create(),typeName:ls.ZodObject,...co(t)});class Do extends lo{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map((async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map((e=>new Vr(e.ctx.common.issues)));return Gr(t,{code:qr.invalid_union,unionErrors:n}),Xr}));{let e;const i=[];for(const a of n){const n={...t,common:{...t.common,issues:[]},parent:null},r=a._parseSync({data:t.data,path:t.path,parent:n});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:n}),n.common.issues.length&&i.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const a=i.map((e=>new Vr(e)));return Gr(t,{code:qr.invalid_union,unionErrors:a}),Xr}}get options(){return this._def.options}}Do.create=(e,t)=>new Do({options:e,typeName:ls.ZodUnion,...co(t)});const Po=e=>e instanceof Wo?Po(e.schema):e instanceof Xo?Po(e.innerType()):e instanceof Bo?[e.value]:e instanceof Qo?e.options:e instanceof Go?Object.keys(e.enum):e instanceof ts?Po(e._def.innerType):e instanceof Mo?[void 0]:e instanceof So?[null]:null;class Lo extends lo{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Hr.object)return Gr(t,{code:qr.invalid_type,expected:Hr.object,received:t.parsedType}),Xr;const n=this.discriminator,i=t.data[n],a=this.optionsMap.get(i);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(Gr(t,{code:qr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Xr)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const n of t){const t=Po(n.shape[e]);if(!t)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of t){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,n)}}return new Lo({typeName:ls.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...co(n)})}}function No(e,t){const n=Zr(e),i=Zr(t);if(e===t)return{valid:!0,data:e};if(n===Hr.object&&i===Hr.object){const n=Dr.objectKeys(t),i=Dr.objectKeys(e).filter((e=>-1!==n.indexOf(e))),a={...e,...t};for(const n of i){const i=No(e[n],t[n]);if(!i.valid)return{valid:!1};a[n]=i.data}return{valid:!0,data:a}}if(n===Hr.array&&i===Hr.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let i=0;i<e.length;i++){const a=No(e[i],t[i]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}return n===Hr.date&&i===Hr.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Uo extends lo{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(e,i)=>{if(to(e)||to(i))return Xr;const a=No(e.value,i.value);return a.valid?((no(e)||no(i))&&t.dirty(),{status:t.value,value:a.data}):(Gr(n,{code:qr.invalid_intersection_types}),Xr)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((([e,t])=>i(e,t))):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Uo.create=(e,t,n)=>new Uo({left:e,right:t,typeName:ls.ZodIntersection,...co(n)});class Fo extends lo{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Hr.array)return Gr(n,{code:qr.invalid_type,expected:Hr.array,received:n.parsedType}),Xr;if(n.data.length<this._def.items.length)return Gr(n,{code:qr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Xr;!this._def.rest&&n.data.length>this._def.items.length&&(Gr(n,{code:qr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map(((e,t)=>{const i=this._def.items[t]||this._def.rest;return i?i._parse(new oo(n,e,n.path,t)):null})).filter((e=>!!e));return n.common.async?Promise.all(i).then((e=>Kr.mergeArray(t,e))):Kr.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Fo({...this._def,rest:e})}}Fo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fo({items:e,typeName:ls.ZodTuple,rest:null,...co(t)})};class Ho extends lo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Hr.object)return Gr(n,{code:qr.invalid_type,expected:Hr.object,received:n.parsedType}),Xr;const i=[],a=this._def.keyType,r=this._def.valueType;for(const e in n.data)i.push({key:a._parse(new oo(n,e,n.path,e)),value:r._parse(new oo(n,n.data[e],n.path,e))});return n.common.async?Kr.mergeObjectAsync(t,i):Kr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return new Ho(t instanceof lo?{keyType:e,valueType:t,typeName:ls.ZodRecord,...co(n)}:{keyType:bo.create(),valueType:e,typeName:ls.ZodRecord,...co(t)})}}class Zo extends lo{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Hr.map)return Gr(n,{code:qr.invalid_type,expected:Hr.map,received:n.parsedType}),Xr;const i=this._def.keyType,a=this._def.valueType,r=[...n.data.entries()].map((([e,t],r)=>({key:i._parse(new oo(n,e,n.path,[r,"key"])),value:a._parse(new oo(n,t,n.path,[r,"value"]))})));if(n.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const n of r){const i=await n.key,a=await n.value;if("aborted"===i.status||"aborted"===a.status)return Xr;"dirty"!==i.status&&"dirty"!==a.status||t.dirty(),e.set(i.value,a.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const n of r){const i=n.key,a=n.value;if("aborted"===i.status||"aborted"===a.status)return Xr;"dirty"!==i.status&&"dirty"!==a.status||t.dirty(),e.set(i.value,a.value)}return{status:t.value,value:e}}}}Zo.create=(e,t,n)=>new Zo({valueType:t,keyType:e,typeName:ls.ZodMap,...co(n)});class qo extends lo{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Hr.set)return Gr(n,{code:qr.invalid_type,expected:Hr.set,received:n.parsedType}),Xr;const i=this._def;null!==i.minSize&&n.data.size<i.minSize.value&&(Gr(n,{code:qr.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),null!==i.maxSize&&n.data.size>i.maxSize.value&&(Gr(n,{code:qr.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const a=this._def.valueType;function r(e){const n=new Set;for(const i of e){if("aborted"===i.status)return Xr;"dirty"===i.status&&t.dirty(),n.add(i.value)}return{status:t.value,value:n}}const o=[...n.data.values()].map(((e,t)=>a._parse(new oo(n,e,n.path,t))));return n.common.async?Promise.all(o).then((e=>r(e))):r(o)}min(e,t){return new qo({...this._def,minSize:{value:e,message:ro.toString(t)}})}max(e,t){return new qo({...this._def,maxSize:{value:e,message:ro.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}qo.create=(e,t)=>new qo({valueType:e,minSize:null,maxSize:null,typeName:ls.ZodSet,...co(t)});class Vo extends lo{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Hr.function)return Gr(t,{code:qr.invalid_type,expected:Hr.function,received:t.parsedType}),Xr;function n(e,n){return Qr({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Yr(),Wr].filter((e=>!!e)),issueData:{code:qr.invalid_arguments,argumentsError:n}})}function i(e,n){return Qr({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Yr(),Wr].filter((e=>!!e)),issueData:{code:qr.invalid_return_type,returnTypeError:n}})}const a={errorMap:t.common.contextualErrorMap},r=t.data;return this._def.returns instanceof Ko?eo((async(...e)=>{const t=new Vr([]),o=await this._def.args.parseAsync(e,a).catch((i=>{throw t.addIssue(n(e,i)),t})),s=await r(...o),c=await this._def.returns._def.type.parseAsync(s,a).catch((e=>{throw t.addIssue(i(s,e)),t}));return c})):eo(((...e)=>{const t=this._def.args.safeParse(e,a);if(!t.success)throw new Vr([n(e,t.error)]);const o=r(...t.data),s=this._def.returns.safeParse(o,a);if(!s.success)throw new Vr([i(o,s.error)]);return s.data}))}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Vo({...this._def,args:Fo.create(e).rest(Ao.create())})}returns(e){return new Vo({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Vo({args:e||Fo.create([]).rest(Ao.create()),returns:t||Ao.create(),typeName:ls.ZodFunction,...co(n)})}}class Wo extends lo{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Wo.create=(e,t)=>new Wo({getter:e,typeName:ls.ZodLazy,...co(t)});class Bo extends lo{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Gr(t,{received:t.data,code:qr.invalid_literal,expected:this._def.value}),Xr}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Yo(e,t){return new Qo({values:e,typeName:ls.ZodEnum,...co(t)})}Bo.create=(e,t)=>new Bo({value:e,typeName:ls.ZodLiteral,...co(t)});class Qo extends lo{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return Gr(t,{expected:Dr.joinValues(n),received:t.parsedType,code:qr.invalid_type}),Xr}if(-1===this._def.values.indexOf(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return Gr(t,{received:t.data,code:qr.invalid_enum_value,options:n}),Xr}return eo(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Qo.create(e)}exclude(e){return Qo.create(this.options.filter((t=>!e.includes(t))))}}Qo.create=Yo;class Go extends lo{_parse(e){const t=Dr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Hr.string&&n.parsedType!==Hr.number){const e=Dr.objectValues(t);return Gr(n,{expected:Dr.joinValues(e),received:n.parsedType,code:qr.invalid_type}),Xr}if(-1===t.indexOf(e.data)){const e=Dr.objectValues(t);return Gr(n,{received:n.data,code:qr.invalid_enum_value,options:e}),Xr}return eo(e.data)}get enum(){return this._def.values}}Go.create=(e,t)=>new Go({values:e,typeName:ls.ZodNativeEnum,...co(t)});class Ko extends lo{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Hr.promise&&!1===t.common.async)return Gr(t,{code:qr.invalid_type,expected:Hr.promise,received:t.parsedType}),Xr;const n=t.parsedType===Hr.promise?t.data:Promise.resolve(t.data);return eo(n.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}Ko.create=(e,t)=>new Ko({type:e,typeName:ls.ZodPromise,...co(t)});class Xo extends lo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ls.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null;if("preprocess"===i.type){const e=i.transform(n.data);return n.common.async?Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:n.path,parent:n}))):this._def.schema._parseSync({data:e,path:n.path,parent:n})}const a={addIssue:e=>{Gr(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),"refinement"===i.type){const e=e=>{const t=i.refinement(e,a);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===i.status?Xr:("dirty"===i.status&&t.dirty(),e(i.value),{status:t.value,value:i.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((n=>"aborted"===n.status?Xr:("dirty"===n.status&&t.dirty(),e(n.value).then((()=>({status:t.value,value:n.value}))))))}if("transform"===i.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!io(e))return e;const r=i.transform(e.value,a);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((e=>io(e)?Promise.resolve(i.transform(e.value,a)).then((e=>({status:t.value,value:e}))):e))}Dr.assertNever(i)}}Xo.create=(e,t,n)=>new Xo({schema:e,typeName:ls.ZodEffects,effect:t,...co(n)}),Xo.createWithPreprocess=(e,t,n)=>new Xo({schema:t,effect:{type:"preprocess",transform:e},typeName:ls.ZodEffects,...co(n)});class Jo extends lo{_parse(e){return this._getType(e)===Hr.undefined?eo(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Jo.create=(e,t)=>new Jo({innerType:e,typeName:ls.ZodOptional,...co(t)});class es extends lo{_parse(e){return this._getType(e)===Hr.null?eo(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}es.create=(e,t)=>new es({innerType:e,typeName:ls.ZodNullable,...co(t)});class ts extends lo{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Hr.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ts.create=(e,t)=>new ts({innerType:e,typeName:ls.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...co(t)});class ns extends lo{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ao(i)?i.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new Vr(n.common.issues)},input:n.data})}))):{status:"valid",value:"valid"===i.status?i.value:this._def.catchValue({get error(){return new Vr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ns.create=(e,t)=>new ns({innerType:e,typeName:ls.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...co(t)});class is extends lo{_parse(e){if(this._getType(e)!==Hr.nan){const t=this._getOrReturnCtx(e);return Gr(t,{code:qr.invalid_type,expected:Hr.nan,received:t.parsedType}),Xr}return{status:"valid",value:e.data}}}is.create=e=>new is({typeName:ls.ZodNaN,...co(e)});const as=Symbol("zod_brand");class rs extends lo{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class os extends lo{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?Xr:"dirty"===e.status?(t.dirty(),Jr(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?Xr:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new os({in:e,out:t,typeName:ls.ZodPipeline})}}const ss=(e,t={},n)=>e?To.create().superRefine(((i,a)=>{var r,o;if(!e(i)){const e="function"==typeof t?t(i):"string"==typeof t?{message:t}:t,s=null===(o=null!==(r=e.fatal)&&void 0!==r?r:n)||void 0===o||o,c="string"==typeof e?{message:e}:e;a.addIssue({code:"custom",...c,fatal:s})}})):To.create(),cs={object:Ro.lazycreate};var ls;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline"}(ls||(ls={}));const ds=bo.create,us=xo.create,hs=is.create,ms=Co.create,ps=$o.create,fs=ko.create,gs=Eo.create,vs=Mo.create,_s=So.create,ys=To.create,bs=Ao.create,ws=zo.create,xs=jo.create,Cs=Oo.create,$s=Ro.create,ks=Ro.strictCreate,Es=Do.create,Ms=Lo.create,Ss=Uo.create,Ts=Fo.create,As=Ho.create,zs=Zo.create,js=qo.create,Os=Vo.create,Is=Wo.create,Rs=Bo.create,Ds=Qo.create,Ps=Go.create,Ls=Ko.create,Ns=Xo.create,Us=Jo.create,Fs=es.create,Hs=Xo.createWithPreprocess,Zs=os.create,qs={string:e=>bo.create({...e,coerce:!0}),number:e=>xo.create({...e,coerce:!0}),boolean:e=>$o.create({...e,coerce:!0}),bigint:e=>Co.create({...e,coerce:!0}),date:e=>ko.create({...e,coerce:!0})},Vs=Xr;var Ws=Object.freeze({__proto__:null,defaultErrorMap:Wr,setErrorMap:function(e){Br=e},getErrorMap:Yr,makeIssue:Qr,EMPTY_PATH:[],addIssueToContext:Gr,ParseStatus:Kr,INVALID:Xr,DIRTY:Jr,OK:eo,isAborted:to,isDirty:no,isValid:io,isAsync:ao,get util(){return Dr},get objectUtil(){return Pr},ZodParsedType:Hr,getParsedType:Zr,ZodType:lo,ZodString:bo,ZodNumber:xo,ZodBigInt:Co,ZodBoolean:$o,ZodDate:ko,ZodSymbol:Eo,ZodUndefined:Mo,ZodNull:So,ZodAny:To,ZodUnknown:Ao,ZodNever:zo,ZodVoid:jo,ZodArray:Oo,ZodObject:Ro,ZodUnion:Do,ZodDiscriminatedUnion:Lo,ZodIntersection:Uo,ZodTuple:Fo,ZodRecord:Ho,ZodMap:Zo,ZodSet:qo,ZodFunction:Vo,ZodLazy:Wo,ZodLiteral:Bo,ZodEnum:Qo,ZodNativeEnum:Go,ZodPromise:Ko,ZodEffects:Xo,ZodTransformer:Xo,ZodOptional:Jo,ZodNullable:es,ZodDefault:ts,ZodCatch:ns,ZodNaN:is,BRAND:as,ZodBranded:rs,ZodPipeline:os,custom:ss,Schema:lo,ZodSchema:lo,late:cs,get ZodFirstPartyTypeKind(){return ls},coerce:qs,any:ys,array:Cs,bigint:ms,boolean:ps,date:fs,discriminatedUnion:Ms,effect:Ns,enum:Ds,function:Os,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>ss((t=>t instanceof e),t),intersection:Ss,lazy:Is,literal:Rs,map:zs,nan:hs,nativeEnum:Ps,never:ws,null:_s,nullable:Fs,number:us,object:$s,oboolean:()=>ps().optional(),onumber:()=>us().optional(),optional:Us,ostring:()=>ds().optional(),pipeline:Zs,preprocess:Hs,promise:Ls,record:As,set:js,strictObject:ks,string:ds,symbol:gs,transformer:Ns,tuple:Ts,undefined:vs,union:Es,unknown:bs,void:xs,NEVER:Vs,ZodIssueCode:qr,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:Vr});const Bs="https://github.com/dermotduffy/frigate-hass-card",Ys=`${Bs}#troubleshooting`,Qs="cameras",Gs=`${Qs}.#.camera_entity`,Ks=`${Qs}.#.frigate.camera_name`,Xs=`${Qs}.#.frigate.client_id`,Js=`${Qs}.#.frigate.labels`,ec=`${Qs}.#.frigate.url`,tc=`${Qs}.#.frigate.zones`,nc=`${Qs}.#.go2rtc.modes`,ic=`${Qs}.#.go2rtc.stream`,ac=`${Qs}.#.hide`,rc=`${Qs}.#.icon`,oc=`${Qs}.#.id`,sc=`${Qs}.#.image.refresh_seconds`,cc=`${Qs}.#.image.url`,lc=`${Qs}.#.motioneye.images.directory_pattern`,dc=`${Qs}.#.motioneye.images.file_pattern`,uc=`${Qs}.#.motioneye.movies.directory_pattern`,hc=`${Qs}.#.motioneye.movies.file_pattern`,mc=`${Qs}.#.motioneye.url`,pc=`${Qs}.#.title`,fc=`${Qs}.#.webrtc_card.entity`,gc=`${Qs}.#.webrtc_card.url`,vc=`${Qs}.#.live_provider`,_c=`${Qs}.#.dependencies.cameras`,yc=`${Qs}.#.dependencies.all_cameras`,bc=`${Qs}.#.triggers.motion`,wc=`${Qs}.#.triggers.occupancy`,xc=`${Qs}.#.triggers.entities`,Cc="cameras_global",$c=`${Cc}.image`,kc=`${Cc}.jsmpeg`,Ec=`${Cc}.webrtc_card`,Mc=`${Cc}.triggers.occupancy`,Sc=`${Cc}.image.refresh_seconds`,Tc="view",Ac=`${Tc}.camera_select`,zc=`${Tc}.dark_mode`,jc=`${Tc}.default`,Oc=`${Tc}.timeout_seconds`,Ic=`${Tc}.update_cycle_camera`,Rc=`${Tc}.update_force`,Dc=`${Tc}.update_seconds`,Pc=`${Tc}.scan`,Lc=`${Pc}.enabled`,Nc=`${Pc}.show_trigger_status`,Uc=`${Pc}.untrigger_reset`,Fc=`${Pc}.untrigger_seconds`,Hc="media_gallery",Zc=`${Hc}.controls.filter.mode`,qc=`${Hc}.controls.thumbnails.show_details`,Vc=`${Hc}.controls.thumbnails.show_download_control`,Wc=`${Hc}.controls.thumbnails.show_favorite_control`,Bc=`${Hc}.controls.thumbnails.show_timeline_control`,Yc=`${Hc}.controls.thumbnails.size`,Qc="media_viewer",Gc=`${Qc}.auto_play`,Kc=`${Qc}.auto_pause`,Xc=`${Qc}.auto_mute`,Jc=`${Qc}.auto_unmute`,el=`${Qc}.draggable`,tl=`${Qc}.lazy_load`,nl=`${Qc}.snapshot_click_plays_clip`,il=`${Qc}.transition_effect`,al=`${Qc}.controls.builtin`,rl=`${Qc}.controls.next_previous.style`,ol=`${Qc}.controls.next_previous.size`,sl=`${Qc}.controls.thumbnails.mode`,cl=`${Qc}.controls.thumbnails.show_details`,ll=`${Qc}.controls.thumbnails.show_download_control`,dl=`${Qc}.controls.thumbnails.show_favorite_control`,ul=`${Qc}.controls.thumbnails.show_timeline_control`,hl=`${Qc}.controls.thumbnails.size`,ml=`${Qc}.controls.timeline.clustering_threshold`,pl=`${Qc}.controls.timeline.media`,fl=`${Qc}.controls.timeline.mode`,gl=`${Qc}.controls.timeline.show_recordings`,vl=`${Qc}.controls.timeline.style`,_l=`${Qc}.controls.timeline.window_seconds`,yl=`${Qc}.zoomable`,bl=`${Qc}.controls.title.mode`,wl=`${Qc}.controls.title.duration_seconds`,xl=`${Qc}.layout.fit`,Cl=`${Qc}.layout.position.x`,$l=`${Qc}.layout.position.y`,kl="live",El=`${kl}.auto_play`,Ml=`${kl}.auto_pause`,Sl=`${kl}.auto_mute`,Tl=`${kl}.auto_unmute`,Al=`${kl}.controls.builtin`,zl=`${kl}.controls.next_previous.style`,jl=`${kl}.controls.next_previous.size`,Ol=`${kl}.controls.thumbnails.media`,Il=`${kl}.controls.thumbnails.mode`,Rl=`${kl}.controls.thumbnails.size`,Dl=`${kl}.controls.thumbnails.show_details`,Pl=`${kl}.controls.thumbnails.show_download_control`,Ll=`${kl}.controls.thumbnails.show_favorite_control`,Nl=`${kl}.controls.thumbnails.show_timeline_control`,Ul=`${kl}.controls.timeline.clustering_threshold`,Fl=`${kl}.controls.timeline.media`,Hl=`${kl}.controls.timeline.mode`,Zl=`${kl}.controls.timeline.show_recordings`,ql=`${kl}.controls.timeline.style`,Vl=`${kl}.controls.timeline.window_seconds`,Wl=`${kl}.controls.title.mode`,Bl=`${kl}.controls.title.duration_seconds`,Yl=`${kl}.layout.fit`,Ql=`${kl}.layout.position.x`,Gl=`${kl}.layout.position.y`,Kl=`${kl}.draggable`,Xl=`${kl}.lazy_load`,Jl=`${kl}.lazy_unload`,ed=`${kl}.preload`,td=`${kl}.transition_effect`,nd=`${kl}.show_image_during_load`,id=`${kl}.microphone.disconnect_seconds`,ad=`${kl}.microphone.always_connected`,rd=`${kl}.zoomable`,od="image",sd=`${od}.layout.fit`,cd=`${od}.layout.position.x`,ld=`${od}.layout.position.y`,dd=`${od}.mode`,ud=`${od}.refresh_seconds`,hd=`${od}.url`,md=`${od}.zoomable`,pd="timeline",fd=`${pd}.window_seconds`,gd=`${pd}.clustering_threshold`,vd=`${pd}.media`,_d=`${pd}.show_recordings`,yd=`${pd}.style`,bd=`${pd}.controls.thumbnails.mode`,wd=`${pd}.controls.thumbnails.size`,xd=`${pd}.controls.thumbnails.show_details`,Cd=`${pd}.controls.thumbnails.show_download_control`,$d=`${pd}.controls.thumbnails.show_favorite_control`,kd=`${pd}.controls.thumbnails.show_timeline_control`,Ed="menu",Md=`${Ed}.alignment`,Sd=`${Ed}.position`,Td=`${Ed}.style`,Ad=`${Ed}.button_size`,zd=`${Ed}.buttons`,jd=`${Ed}.buttons.cameras`,Od=`${Ed}.buttons.clips`,Id=`${Ed}.buttons.download`,Rd=`${Ed}.buttons.frigate`,Dd=`${Ed}.buttons.camera_ui`,Pd=`${Ed}.buttons.fullscreen`,Ld=`${Ed}.buttons.image`,Nd=`${Ed}.buttons.live`,Ud=`${Ed}.buttons.media_player`,Fd=`${Ed}.buttons.snapshots`,Hd=`${Ed}.buttons.timeline`,Zd="dimensions",qd=`${Zd}.aspect_ratio`,Vd=`${Zd}.aspect_ratio_mode`,Wd=`${Zd}.max_height`,Bd=`${Zd}.min_height`,Yd="overrides",Qd="performance",Gd=`${Qd}.features.animated_progress_indicator`,Kd=`${Qd}.features.media_chunk_size`,Xd=`${Qd}.profile`,Jd=`${Qd}.style.box_shadow`,eu=`${Qd}.style.border_radius`,tu=1e3,nu="frigate";function iu(e){if(e instanceof Ws.ZodDefault)return iu(e.removeDefault());if(e instanceof Ws.ZodObject){const t={};for(const n in e.shape){const i=e.shape[n];t[n]=Ws.ZodOptional.create(iu(i))}return new Ws.ZodObject({...e._def,shape:()=>t})}return e instanceof Ws.ZodArray?Ws.ZodArray.create(iu(e.element)):e instanceof Ws.ZodOptional?Ws.ZodOptional.create(iu(e.unwrap())):e instanceof Ws.ZodNullable?Ws.ZodNullable.create(iu(e.unwrap())):e instanceof Ws.ZodTuple?Ws.ZodTuple.create(e.items.map((e=>iu(e)))):e}function au(e){const t=e.format();return Object.keys(t).filter((e=>!e.startsWith("_")))}const ru=e=>{const t=new Set;if(e&&e.issues)for(let n=0;n<e.issues.length;n++){const i=e.issues[n];if("invalid_union"==i.code){const e=i.unionErrors;for(let n=0;n<e.length;n++){const i=ru(e[n]);i&&i.size&&i.forEach(t.add,t)}}else if("invalid_type"==i.code){if("type"==i.path[i.path.length-1])return null;t.add(ou(i.path))}else"custom"!=i.code&&t.add(ou(i.path))}return t},ou=e=>{let t="";for(let n=0;n<e.length;n++){const i=e[n];"number"==typeof i?t+="["+i+"]":t?t+=" -> "+i:t=i}return t},su=20,cu=175,lu=75,du=["live","clip","clips","snapshot","snapshots","recording","recordings","image","timeline"],uu="live",hu=["left","right","top","bottom"],mu=hu,pu=100,fu=["all","unselected","hidden","never"],gu=["all","selected","visible","never"];class vu extends Error{constructor(e,t){super(e),this.context=t}}const _u=Ws.object({confirmation:Ws.boolean().or(Ws.object({text:Ws.string().optional(),exemptions:Ws.object({user:Ws.string()}).array().optional()})).optional()}),yu=_u.extend({action:Ws.literal("toggle")}),bu=_u.extend({action:Ws.literal("call-service"),service:Ws.string(),service_data:Ws.object({}).passthrough().optional()}),wu=_u.extend({action:Ws.literal("navigate"),navigation_path:Ws.string()}),xu=_u.extend({action:Ws.literal("url"),url_path:Ws.string()}),Cu=_u.extend({action:Ws.literal("more-info")}),$u=_u.extend({action:Ws.literal("fire-dom-event")}).passthrough(),ku=_u.extend({action:Ws.literal("none")}),Eu=$u.extend({action:Ws.literal("custom:frigate-card-action").transform((()=>"fire-dom-event")).or(Ws.literal("fire-dom-event")),card_id:Ws.string().optional()}),Mu=["camera_ui","default","diagnostics","expand","download","fullscreen","menu_toggle","mute","live_substream_on","live_substream_off","microphone_mute","microphone_unmute","play","pause","screenshot","unmute"],Su=Eu.extend({frigate_card_action:Ws.enum(du)}),Tu=Eu.extend({frigate_card_action:Ws.enum(Mu)}),Au=Eu.extend({frigate_card_action:Ws.literal("camera_select"),camera:Ws.string()}),zu=Eu.extend({frigate_card_action:Ws.literal("live_substream_select"),camera:Ws.string()}),ju=Eu.extend({frigate_card_action:Ws.literal("media_player"),media_player:Ws.string(),media_player_action:Ws.enum(["play","stop"])}),Ou=Ws.union([Su,Tu,Au,zu,ju]),Iu=Ws.union([yu,bu,wu,xu,Cu,ku,$u,Ou]),Ru=Ws.object({tap_action:Iu.or(Iu.array()).optional(),hold_action:Iu.or(Iu.array()).optional(),double_tap_action:Iu.or(Iu.array()).optional(),start_tap_action:Iu.or(Iu.array()).optional(),end_tap_action:Iu.or(Iu.array()).optional()}).passthrough(),Du=Ws.object({actions:Ru.optional()}),Pu=Ru.extend({style:Ws.object({}).passthrough().optional(),title:Ws.string().nullable().optional()}),Lu=Pu.extend({type:Ws.literal("state-badge"),entity:Ws.string()}),Nu=Pu.extend({type:Ws.literal("state-icon"),entity:Ws.string(),icon:Ws.string().optional(),state_color:Ws.boolean().default(!0)}),Uu=Pu.extend({type:Ws.literal("state-label"),entity:Ws.string(),attribute:Ws.string().optional(),prefix:Ws.string().optional(),suffix:Ws.string().optional()}),Fu=Pu.extend({type:Ws.literal("service-button"),title:Ws.string(),service:Ws.string(),service_data:Ws.object({}).passthrough().optional()}),Hu=Pu.extend({type:Ws.literal("icon"),icon:Ws.string(),entity:Ws.string().optional()}),Zu=Pu.extend({type:Ws.literal("image"),entity:Ws.string().optional(),image:Ws.string().optional(),camera_image:Ws.string().optional(),camera_view:Ws.string().optional(),state_image:Ws.object({}).passthrough().optional(),filter:Ws.string().optional(),state_filter:Ws.object({}).passthrough().optional(),aspect_ratio:Ws.string().optional()}),qu=Ws.object({entity:Ws.string(),state:Ws.string().optional(),state_not:Ws.string().optional()}).array(),Vu=Ws.object({type:Ws.literal("conditional"),conditions:qu,elements:Ws.lazy((()=>mh))}),Wu=Ws.object({type:Ws.string().superRefine(((e,t)=>{e.match(/^custom:(?!frigate-card).+/)||t.addIssue({code:Ws.ZodIssueCode.custom,message:"Frigate-card custom elements must match specific schemas",fatal:!0})}))}).passthrough(),Bu={refresh_seconds:1},Yu=Ws.object({url:Ws.string().optional(),refresh_seconds:Ws.number().min(0).default(Bu.refresh_seconds)}),Qu={always_connected:!1,disconnect_seconds:60},Gu=Ws.object({always_connected:Ws.boolean().default(Qu.always_connected),disconnect_seconds:Ws.number().min(0).default(Qu.disconnect_seconds)}).default(Qu),Ku=Ws.object({modes:Ws.enum(["webrtc","mse","mp4","mjpeg"]).array().optional(),stream:Ws.string().optional()}),Xu=Yu,Ju=Ws.object({entity:Ws.string().optional(),url:Ws.string().optional()}).passthrough(),eh=Ws.object({options:Ws.object({audio:Ws.boolean().optional(),video:Ws.boolean().optional(),pauseWhenHidden:Ws.boolean().optional(),disableGl:Ws.boolean().optional(),disableWebAssembly:Ws.boolean().optional(),preserveDrawingBuffer:Ws.boolean().optional(),progressive:Ws.boolean().optional(),throttled:Ws.boolean().optional(),chunkSize:Ws.number().optional(),maxAudioLag:Ws.number().optional(),videoBufferSize:Ws.number().optional(),audioBufferSize:Ws.number().optional()}).optional()}),th={dependencies:{all_cameras:!1,cameras:[]},engine:"auto",frigate:{client_id:"frigate"},hide:!1,image:{refresh_seconds:1},live_provider:"auto",motioneye:{images:{directory_pattern:"%Y-%m-%d",file_pattern:"%H-%M-%S"},movies:{directory_pattern:"%Y-%m-%d",file_pattern:"%H-%M-%S"}},triggers:{motion:!1,occupancy:!0,entities:[]}},nh=Ws.object({camera_entity:Ws.string().optional(),icon:Ws.string().optional(),title:Ws.string().optional(),hide:Ws.boolean().optional(),id:Ws.string().optional(),dependencies:Ws.object({all_cameras:Ws.boolean().default(th.dependencies.all_cameras),cameras:Ws.string().array().default(th.dependencies.cameras)}).default(th.dependencies),triggers:Ws.object({motion:Ws.boolean().default(th.triggers.motion),occupancy:Ws.boolean().default(th.triggers.occupancy),entities:Ws.string().array().default(th.triggers.entities)}).default(th.triggers),engine:Ws.enum(["auto","frigate","generic","motioneye"]).default("auto"),frigate:Ws.object({url:Ws.string().optional(),client_id:Ws.string().default(th.frigate.client_id),camera_name:Ws.string().optional(),labels:Ws.string().array().optional(),zones:Ws.string().array().optional()}).default(th.frigate),motioneye:Ws.object({url:Ws.string().optional(),images:Ws.object({directory_pattern:Ws.string().includes("%").default(th.motioneye.images.directory_pattern),file_pattern:Ws.string().includes("%").default(th.motioneye.images.file_pattern)}).default(th.motioneye.images),movies:Ws.object({directory_pattern:Ws.string().includes("%").default(th.motioneye.movies.directory_pattern),file_pattern:Ws.string().includes("%").default(th.motioneye.movies.file_pattern)}).default(th.motioneye.movies)}).default(th.motioneye),live_provider:Ws.enum(["auto","image","ha","jsmpeg","go2rtc","webrtc-card"]).default(th.live_provider),go2rtc:Ku.optional(),image:Xu.default(th.image),jsmpeg:eh.optional(),webrtc_card:Ju.optional()}).default(th),ih=nh.array().min(1),ah=Ws.object({enabled:Ws.boolean().default(!0).optional(),priority:Ws.number().min(0).max(100).default(50).optional(),alignment:Ws.enum(["matching","opposing"]).default("matching").optional(),icon:Ws.string().optional()}),rh=ah.merge(Hu).extend({type:Ws.literal("custom:frigate-card-menu-icon")}),oh=ah.merge(Nu).extend({type:Ws.literal("custom:frigate-card-menu-state-icon")}).merge(ah),sh=Pu.extend({entity:Ws.string().optional(),icon:Ws.string().optional(),state_color:Ws.boolean().default(!0),selected:Ws.boolean().default(!1),subtitle:Ws.string().optional(),enabled:Ws.boolean().default(!0)}),ch=ah.merge(Hu).extend({type:Ws.literal("custom:frigate-card-menu-submenu"),items:sh.array()}),lh=ah.merge(Nu).extend({type:Ws.literal("custom:frigate-card-menu-submenu-select"),options:Ws.record(sh.deepPartial()).optional()}),dh=Ws.object({view:Ws.string().array().optional(),fullscreen:Ws.boolean().optional(),expand:Ws.boolean().optional(),camera:Ws.string().array().optional(),media_loaded:Ws.boolean().optional(),state:qu.optional(),media_query:Ws.string().optional()}),uh=Ws.object({type:Ws.literal("custom:frigate-card-conditional"),conditions:dh,elements:Ws.lazy((()=>mh))}),hh=Ws.preprocess((e=>{if(!e||"object"!=typeof e||!e.service)return e;const t={...e};return["left","right","up","down","zoom_in","zoom_out","home"].forEach((n=>{`data_${n}`in e&&!(`actions_${n}`in e)&&(t[`actions_${n}`]={tap_action:{action:"call-service",service:e.service,service_data:e[`data_${n}`]}},delete t[`data_${n}`])})),t}),Ws.object({type:Ws.literal("custom:frigate-card-ptz"),style:Ws.object({}).passthrough().optional(),orientation:Ws.enum(["vertical","horizontal"]).default("vertical").optional(),service:Ws.string().optional(),actions_left:Ru.optional(),actions_right:Ru.optional(),actions_up:Ru.optional(),actions_down:Ru.optional(),actions_zoom_in:Ru.optional(),actions_zoom_out:Ru.optional(),actions_home:Ru.optional()})),mh=Ws.union([oh,rh,ch,lh,uh,hh,Lu,Nu,Uu,Fu,Hu,Zu,Vu,Wu]).array().optional(),ph=Ws.object({fit:Ws.enum(["contain","cover","fill"]).optional(),position:Ws.object({x:Ws.number().min(0).max(100).optional(),y:Ws.number().min(0).max(100).optional()}).optional()}),fh={default:uu,camera_select:"current",timeout_seconds:300,update_seconds:0,update_force:!1,update_cycle_camera:!1,dark_mode:"off",scan:{enabled:!1,show_trigger_status:!0,untrigger_seconds:0,untrigger_reset:!0}},gh=Ws.object({default:Ws.enum(du).default(fh.default),camera_select:Ws.enum([...du,"current"]).default(fh.camera_select),timeout_seconds:Ws.number().default(fh.timeout_seconds),update_seconds:Ws.number().default(fh.update_seconds),update_force:Ws.boolean().default(fh.update_force),update_cycle_camera:Ws.boolean().default(fh.update_cycle_camera),update_entities:Ws.string().array().optional(),render_entities:Ws.string().array().optional(),dark_mode:Ws.enum(["on","off","auto"]).optional(),scan:Ws.object({enabled:Ws.boolean().default(fh.scan.enabled),show_trigger_status:Ws.boolean().default(fh.scan.show_trigger_status),untrigger_seconds:Ws.number().default(fh.scan.untrigger_seconds),untrigger_reset:Ws.boolean().default(fh.scan.untrigger_reset)}).default(fh.scan)}).merge(Du).default(fh),vh={mode:"url",zoomable:!0,...Bu},_h=Yu.extend({mode:Ws.enum(["screensaver","camera","url"]).default(vh.mode),layout:ph.optional(),zoomable:Ws.boolean().default(vh.zoomable)}).merge(Du).default(vh),yh={size:100,show_details:!0,show_favorite_control:!0,show_timeline_control:!0,show_download_control:!0},bh=Ws.object({size:Ws.number().min(75).max(cu).default(yh.size),show_details:Ws.boolean().default(yh.show_details),show_favorite_control:Ws.boolean().default(yh.show_favorite_control),show_timeline_control:Ws.boolean().default(yh.show_timeline_control),show_download_control:Ws.boolean().default(yh.show_download_control)}),wh={...yh,mode:"right"},xh=bh.extend({mode:Ws.enum(["none","above","below","left","right"]).default(wh.mode)}),Ch={clustering_threshold:3,media:"all",window_seconds:3600,show_recordings:!0,style:"stack"},$h=Ws.enum(["all","clips","snapshots"]),kh=Ws.object({clustering_threshold:Ws.number().optional().default(Ch.clustering_threshold),media:$h.optional().default(Ch.media),window_seconds:Ws.number().min(60).max(86400).optional().default(Ch.window_seconds),show_recordings:Ws.boolean().optional().default(Ch.show_recordings),style:Ws.enum(["stack","ribbon"]).optional().default(Ch.style)}),Eh={...Ch,mode:"none",style:"ribbon"},Mh=kh.extend({mode:Ws.enum(["none","above","below"]).default(Eh.mode),style:kh.shape.style.default(Eh.style)}),Sh=Ws.object({style:Ws.enum(["none","chevrons","icons","thumbnails"]),size:Ws.number().min(su)}),Th=Ws.enum(["none","slide"]),Ah=Ws.object({mode:Ws.enum(["none","popup-top-right","popup-top-left","popup-bottom-right","popup-bottom-left"]),duration_seconds:Ws.number().min(0).max(60)}),zh={auto_play:"all",auto_pause:"never",auto_mute:"all",auto_unmute:"never",preload:!1,lazy_load:!0,lazy_unload:"never",draggable:!0,zoomable:!0,transition_effect:"slide",show_image_during_load:!0,controls:{builtin:!0,next_previous:{size:48,style:"chevrons"},thumbnails:{...wh,media:"all"},timeline:Eh,title:{mode:"popup-bottom-right",duration_seconds:2}},microphone:{...Qu}},jh=xh.extend({media:Ws.enum(["all","clips","snapshots"]).default(zh.controls.thumbnails.media)}),Oh=Ws.object({controls:Ws.object({builtin:Ws.boolean().default(zh.controls.builtin),next_previous:Sh.extend({style:Ws.enum(["none","chevrons","icons"]).default(zh.controls.next_previous.style),size:Sh.shape.size.default(zh.controls.next_previous.size)}).default(zh.controls.next_previous),thumbnails:jh.default(zh.controls.thumbnails),timeline:Mh.default(zh.controls.timeline),title:Ah.extend({mode:Ah.shape.mode.default(zh.controls.title.mode),duration_seconds:Ah.shape.duration_seconds.default(zh.controls.title.duration_seconds)}).default(zh.controls.title)}).default(zh.controls),show_image_during_load:Ws.boolean().default(zh.show_image_during_load),layout:ph.optional(),microphone:Gu.default(zh.microphone),zoomable:Ws.boolean().default(zh.zoomable)}).merge(Du),Ih=Oh.extend({auto_play:Ws.enum(gu).default(zh.auto_play),auto_pause:Ws.enum(fu).default(zh.auto_pause),auto_mute:Ws.enum(fu).default(zh.auto_mute),auto_unmute:Ws.enum(gu).default(zh.auto_unmute),preload:Ws.boolean().default(zh.preload),lazy_load:Ws.boolean().default(zh.lazy_load),lazy_unload:Ws.enum(fu).default(zh.lazy_unload),draggable:Ws.boolean().default(zh.draggable),transition_effect:Th.default(zh.transition_effect)}).default(zh),Rh={priority:50,enabled:!0},Dh={priority:50,enabled:!1},Ph={style:"hidden",position:"top",alignment:"left",buttons:{frigate:Rh,cameras:Rh,substreams:Rh,live:Rh,clips:Rh,snapshots:Rh,image:Dh,timeline:Rh,download:Rh,camera_ui:Rh,fullscreen:Rh,expand:Dh,media_player:Rh,microphone:{...Dh,type:"momentary"},mute:Dh,play:Dh,recordings:Dh,screenshot:Dh},button_size:40},Lh=ah.extend({enabled:ah.shape.enabled.default(Rh.enabled),priority:ah.shape.priority.default(Rh.priority)}),Nh=ah.extend({enabled:ah.shape.enabled.default(Dh.enabled),priority:ah.shape.priority.default(Dh.priority)}),Uh=Ws.object({style:Ws.enum(["none","hidden","overlay","hover","hover-card","outside"]).default(Ph.style),position:Ws.enum(hu).default(Ph.position),alignment:Ws.enum(mu).default(Ph.alignment),buttons:Ws.object({frigate:Lh.default(Ph.buttons.frigate),cameras:Lh.default(Ph.buttons.cameras),substreams:Lh.default(Ph.buttons.substreams),live:Lh.default(Ph.buttons.live),clips:Lh.default(Ph.buttons.clips),snapshots:Lh.default(Ph.buttons.snapshots),image:Nh.default(Ph.buttons.image),timeline:Lh.default(Ph.buttons.timeline),download:Lh.default(Ph.buttons.download),camera_ui:Lh.default(Ph.buttons.camera_ui),fullscreen:Lh.default(Ph.buttons.fullscreen),expand:Nh.default(Ph.buttons.expand),media_player:Lh.default(Ph.buttons.media_player),microphone:Nh.extend({type:Ws.enum(["momentary","toggle"]).default(Ph.buttons.microphone.type)}).default(Ph.buttons.microphone),recordings:Nh.default(Ph.buttons.recordings),mute:Nh.default(Ph.buttons.mute),play:Nh.default(Ph.buttons.play),screenshot:Nh.default(Ph.buttons.screenshot)}).default(Ph.buttons),button_size:Ws.number().min(su).default(Ph.button_size)}).default(Ph),Fh={auto_play:"all",auto_pause:"all",auto_mute:"all",auto_unmute:"never",lazy_load:!0,draggable:!0,zoomable:!0,transition_effect:"slide",snapshot_click_plays_clip:!0,controls:{builtin:!0,next_previous:{size:48,style:"thumbnails"},thumbnails:wh,timeline:Eh,title:{mode:"popup-bottom-right",duration_seconds:2}}},Hh=Sh.extend({style:Ws.enum(["none","thumbnails","chevrons"]).default(Fh.controls.next_previous.style),size:Sh.shape.size.default(Fh.controls.next_previous.size)}),Zh=Ws.object({auto_play:Ws.enum(gu).default(Fh.auto_play),auto_pause:Ws.enum(fu).default(Fh.auto_pause),auto_mute:Ws.enum(fu).default(Fh.auto_mute),auto_unmute:Ws.enum(gu).default(Fh.auto_unmute),lazy_load:Ws.boolean().default(Fh.lazy_load),draggable:Ws.boolean().default(Fh.draggable),zoomable:Ws.boolean().default(Fh.zoomable),transition_effect:Th.default(Fh.transition_effect),snapshot_click_plays_clip:Ws.boolean().default(Fh.snapshot_click_plays_clip),controls:Ws.object({builtin:Ws.boolean().default(Fh.controls.builtin),next_previous:Hh.default(Fh.controls.next_previous),thumbnails:xh.default(Fh.controls.thumbnails),timeline:Mh.default(Fh.controls.timeline),title:Ah.extend({mode:Ah.shape.mode.default(Fh.controls.title.mode),duration_seconds:Ah.shape.duration_seconds.default(Fh.controls.title.duration_seconds)}).default(Fh.controls.title)}).default(Fh.controls),layout:ph.optional()}).merge(Du).default(Fh),qh={...wh,show_details:!1},Vh={controls:{thumbnails:qh,filter:{mode:"right"}}},Wh=xh.extend({show_details:Ws.boolean().default(qh.show_details)}),Bh=Ws.object({controls:Ws.object({thumbnails:Wh.default(Vh.controls.thumbnails),filter:Ws.object({mode:Ws.enum(["none","left","right"]).default(Vh.controls.filter.mode)}).default(Vh.controls.filter)}).default(Vh.controls)}).merge(Du).default(Vh),Yh={aspect_ratio_mode:"dynamic",aspect_ratio:[16,9],max_height:"100vh",min_height:"100px"},Qh=Ws.object({aspect_ratio_mode:Ws.enum(["dynamic","static","unconstrained"]).default(Yh.aspect_ratio_mode),aspect_ratio:Ws.number().array().length(2).or(Ws.string().regex(/^\s*\d+\s*[:\/]\s*\d+\s*$/).transform((e=>e.split(/[:\/]/).map((e=>Number(e)))))).default(Yh.aspect_ratio),max_height:Ws.string().default(Yh.max_height),min_height:Ws.string().default(Yh.min_height)}).default(Yh),Gh={...Ch,controls:{thumbnails:wh}},Kh=kh.extend({controls:Ws.object({thumbnails:xh.default(Gh.controls.thumbnails)}).default(Gh.controls)}).default(Gh),Xh=Ws.object({cameras:iu(ih).optional(),cameras_global:iu(nh).optional(),live:iu(Oh).optional(),menu:iu(Uh).optional(),image:iu(_h).optional(),view:iu(gh).optional(),dimensions:iu(Qh).optional()}),Jh=Ws.object({conditions:dh,overrides:Xh}).array().optional();Ws.object({conditions:dh,overrides:Oh}).array().optional();const em=Iu.array().optional(),tm=Ws.object({conditions:dh,actions:em,actions_not:em}).array().optional(),nm={profile:"high",features:{animated_progress_indicator:!0,media_chunk_size:50},style:{border_radius:!0,box_shadow:!0}},im=Ws.object({profile:Ws.enum(["low","high"]).default(nm.profile),features:Ws.object({animated_progress_indicator:Ws.boolean().default(nm.features.animated_progress_indicator),media_chunk_size:Ws.number().min(0).max(1e3).default(nm.features.media_chunk_size)}).default(nm.features),style:Ws.object({border_radius:Ws.boolean().default(nm.style.border_radius),box_shadow:Ws.boolean().default(nm.style.box_shadow)}).default(nm.style)}).default(nm),am={logging:!1},rm=Ws.object({logging:Ws.boolean().default(am.logging)}).default(am),om=Ws.object({cameras:iu(ih),cameras_global:nh,view:gh,menu:Uh,live:Ih,media_gallery:Bh,media_viewer:Zh,image:_h,elements:mh,dimensions:Qh,timeline:Kh,performance:im,debug:rm,automations:tm,overrides:Jh,card_mod:Ws.unknown(),card_id:Ws.string().regex(/^\w+$/).optional(),type:Ws.string(),test_gui:Ws.boolean().optional()}),sm={cameras:th,view:fh,menu:Ph,live:zh,media_gallery:Vh,media_viewer:Fh,image:vh,timeline:Gh,performance:nm,debug:am};Ws.discriminatedUnion("type",[rh,oh,ch,lh]);const cm={info:10,error:20,connection:30,diagnostics:40},lm=Ws.object({url:Ws.string(),mime_type:Ws.string()}),dm=Ws.object({path:Ws.string()});function um(e){if(!e)return null;const t=Ou.safeParse(e);return t.success?t.data:null}function hm(e,t){return"camera_select"===e||"live_substream_select"===e?t?.camera?{action:"fire-dom-event",frigate_card_action:e,camera:t.camera,...t.cardID&&{card_id:t.cardID}}:null:"media_player"===e?t?.media_player&&t.media_player_action?{action:"fire-dom-event",frigate_card_action:e,media_player:t.media_player,media_player_action:t.media_player_action,...t.cardID&&{card_id:t.cardID}}:null:{action:"fire-dom-event",frigate_card_action:e,...t?.cardID&&{card_id:t.cardID}}}function mm(e,t){if(e&&t)return"tap"==e&&t.tap_action?t.tap_action:"hold"==e&&t.hold_action?t.hold_action:"double_tap"==e&&t.double_tap_action?t.double_tap_action:"end_tap"==e&&t.end_tap_action?t.end_tap_action:"start_tap"==e&&t.start_tap_action?t.start_tap_action:void 0}const pm=(e,t,n,i,a)=>!(!a&&"tap"!=i)&&(fm(e,t,n,a),!0),fm=(e,t,n,i)=>{Array.isArray(i)?i.forEach((i=>h(e,t,n,i))):h(e,t,n,i)},gm=e=>Array.isArray(e)?!!e.find((e=>m(e))):m(e),vm=e=>{e.stopPropagation()};class _m{constructor(){this._timer=null}stop(){this._timer&&(window.clearTimeout(this._timer),this._timer=null)}isRunning(){return null!==this._timer}start(e,t){this.stop(),this._timer=window.setTimeout((()=>{this._timer=null,t()}),1e3*e)}startRepeated(e,t){this.stop(),this._timer=window.setInterval((()=>{t()}),1e3*e)}}class ym extends HTMLElement{constructor(){super(...arguments),this.holdTime=.4,this.holdTimer=new _m,this.doubleClickTimer=new _m,this.held=!1}connectedCallback(){["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach((e=>{document.addEventListener(e,(()=>{this.holdTimer.stop()}),{passive:!0})}))}bind(e,t){if(e.actionHandlerOptions)return void(e.actionHandlerOptions=t);e.actionHandlerOptions=t,e.addEventListener("contextmenu",(e=>{const t=e||window.event;return t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0,t.returnValue=!1,!1}));const n=()=>{this.held=!1,this.holdTimer.start(this.holdTime,(()=>{this.held=!0})),l(e,"action",{action:"start_tap"})},i=t=>{const n=e.actionHandlerOptions;n?.allowPropagation||vm(t),["touchend","touchcancel"].includes(t.type)&&!this.held||(this.holdTimer.stop(),l(e,"action",{action:"end_tap"}),n?.hasHold&&this.held?l(e,"action",{action:"hold"}):n?.hasDoubleClick?"click"===t.type&&t.detail<2||!this.doubleClickTimer.isRunning()?this.doubleClickTimer.start(.25,(()=>l(e,"action",{action:"tap"}))):(this.doubleClickTimer.stop(),l(e,"action",{action:"double_tap"})):l(e,"action",{action:"tap"}))};e.addEventListener("touchstart",n,{passive:!0}),e.addEventListener("touchend",i),e.addEventListener("touchcancel",i),e.addEventListener("mousedown",n,{passive:!0}),e.addEventListener("click",i),e.addEventListener("keyup",(e=>{"Enter"===e.key&&i(e)}))}}customElements.define("action-handler-frigate-card",ym);const bm=(e,t)=>{const n=(()=>{const e=document.body;if(e.querySelector("action-handler-frigate-card"))return e.querySelector("action-handler-frigate-card");const t=document.createElement("action-handler-frigate-card");return e.appendChild(t),t})();n&&n.bind(e,t)},wm=$e(class extends ke{update(e,[t]){return bm(e.element,t),X}render(e){}});var xm={frigate_card:"Frigate card",frigate_card_description:"A Lovelace card for use with Frigate",live:"Live",no_media:"No media to display",recordings:"Recordings",version:"Version"},Cm={cameras:{camera_entity:"Camera Entity",dependencies:{all_cameras:"Show events for all cameras with this camera",cameras:"Show events for specific cameras with this camera",editor_label:"Dependency Options"},engines:{editor_label:"Camera engine options"},frigate:{camera_name:"Frigate camera name (Autodetected from entity)",client_id:"Frigate client id (For >1 Frigate server)",editor_label:"Frigate Options",labels:"Frigate labels/object filters",url:"Frigate server URL",zones:"Frigate zones"},go2rtc:{editor_label:"go2rtc Options",modes:{editor_label:"go2rtc Modes",mjpeg:"Motion JPEG (MJPEG)",mp4:"MPEG-4 (MP4)",mse:"Media Source Extensions (MSE)",webrtc:"Web Real-Time Communication (WebRTC)"},stream:"go2rtc stream name"},hide:"Hide camera from UI",icon:"Icon for this camera (Autodetected from entity)",id:"Unique id for this camera in this card",image:{editor_label:"Image Options",refresh_seconds:"Number of seconds after which to refresh live image (0=never)",url:"Image URL to use instead of camera entity snapshot"},live_provider:"Live view provider for this camera",live_provider_options:{editor_label:"Live provider options"},live_providers:{auto:"Automatic",go2rtc:"go2rtc",ha:"Home Assistant video stream (i.e. HLS, LL-HLS, WebRTC via HA)",image:"Home Assistant images",jsmpeg:"JSMpeg","webrtc-card":"WebRTC Card (i.e. AlexxIT's WebRTC Card)"},motioneye:{editor_label:"MotionEye Options",images:{directory_pattern:"Images directory pattern",file_pattern:"Images file pattern"},movies:{directory_pattern:"Movies directory pattern",file_pattern:"Movies file pattern"},url:"MotionEye UI URL"},title:"Title for this camera (Autodetected from entity)",triggers:{editor_label:"Trigger Options",entities:"Trigger from other entities",motion:"Trigger by auto-detecting the motion sensor",occupancy:"Trigger by auto-detecting the occupancy sensor"},webrtc_card:{editor_label:"WebRTC Card Options",entity:"WebRTC Card Camera Entity (Not a Frigate camera)",url:"WebRTC Card Camera URL"}},common:{controls:{builtin:"Built-in video controls",filter:{editor_label:"Media Filter",mode:"Filter mode",modes:{left:"Media filter in a drawer to the left",none:"No media filter",right:"Media filter in a drawer to the right"}},next_previous:{editor_label:"Next & Previous",size:"Next & previous control size in pixels",style:"Next & previous control style",styles:{chevrons:"Chevrons",icons:"Icons",none:"None",thumbnails:"Thumbnails"}},thumbnails:{editor_label:"Thumbnails",media:"Whether to show thumbnails of clips or snapshots",medias:{clips:"Clip thumbnails",snapshots:"Snapshot thumbnails"},mode:"Thumbnails mode",modes:{above:"Thumbnails above",below:"Thumbnails below",left:"Thumbnails in a drawer to the left",none:"No thumbnails",right:"Thumbnails in a drawer to the right"},show_details:"Show details with thumbnails",show_download_control:"Show download control on thumbnails",show_favorite_control:"Show favorite control on thumbnails",show_timeline_control:"Show timeline control on thumbnails",size:"Thumbnails size in pixels"},timeline:{editor_label:"Mini Timeline",mode:"Mode",modes:{above:"Above",below:"Below",none:"None"}},title:{duration_seconds:"Seconds to display popup title (0=forever)",editor_label:"Popup Title Controls",mode:"Popup title display mode",modes:{none:"No title display","popup-bottom-left":"Popup on the bottom left","popup-bottom-right":"Popup on the bottom right","popup-top-left":"Popup on the top left","popup-top-right":"Popup on the top right"}}},layout:{fit:"Layout fit",fits:{contain:"Media is contained/letterboxed",cover:"Media expands proportionally to cover the card",fill:"Media is stretched to fill the card"},position:{x:"Horizontal placement percentage",y:"Vertical placement percentage"}},media_action_conditions:{all:"All opportunities",hidden:"On browser/tab hiding",never:"Never",selected:"On selection",unselected:"On unselection",visible:"On browser/tab visibility"},timeline:{clustering_threshold:"The count of events at which they are clustered (0=no clustering)",media:"The media the timeline displays",medias:{all:"All media types",clips:"Clips",snapshots:"Snapshots"},show_recordings:"Show recordings",style:"Timeline style",styles:{ribbon:"Events on a single ribbon",stack:"Stacked & clustered events"},window_seconds:"The default length of the timeline view in seconds"}},dimensions:{aspect_ratio:"Default aspect ratio (e.g. '16:9')",aspect_ratio_mode:"Aspect ratio mode",aspect_ratio_modes:{dynamic:"Aspect ratio adjusts to media",static:"Static aspect ratio",unconstrained:"Unconstrained aspect ratio"},max_height:"Maximum card height in CSS units (e.g. '100vh')",min_height:"Minimum card height in CSS units (e.g. '100px')"},image:{layout:"Image Layout",mode:"Image view mode",modes:{camera:"Home Assistant camera snapshot of camera entity",screensaver:"Embedded Frigate logo",url:"Arbitrary image specified by URL"},refresh_seconds:"Number of seconds after which to refresh (0=never)",url:"Static image URL for image view",zoomable:"Image can be zoomed/panned"},live:{auto_mute:"Automatically mute live cameras",auto_pause:"Automatically pause live cameras",auto_play:"Automatically play live cameras",auto_unmute:"Automatically unmute live cameras",controls:{editor_label:"Live Controls"},draggable:"Live cameras view can be dragged/swiped",layout:"Live Layout",lazy_load:"Live cameras are lazily loaded",lazy_unload:"Live cameras are lazily unloaded",microphone:{always_connected:"Always keep the microphone connected",disconnect_seconds:"Seconds after which to disconnect microphone (0=never)",editor_label:"Microphone",enabled:"Microphone enabled"},preload:"Preload live view in the background",show_image_during_load:"Show still image while the live stream is loading",transition_effect:"Live camera transition effect",zoomable:"Live cameras can be zoomed/panned"},media_viewer:{auto_mute:"Automatically mute media",auto_pause:"Automatically pause media",auto_play:"Automatically play media",auto_unmute:"Automatically unmute media",controls:{editor_label:"Media Viewer Controls"},draggable:"Media Viewer can be dragged/swiped",layout:"Media Viewer Layout",lazy_load:"Media Viewer media is lazily loaded in carousel",snapshot_click_plays_clip:"Clicking on a snapshot plays a related clip",transition_effect:"Media Viewer transition effect",transition_effects:{none:"No transition",slide:"Slide transition"},zoomable:"Media Viewer can be zoomed/panned"},menu:{alignment:"Menu alignment",alignments:{bottom:"Aligned to the bottom",left:"Aligned to the left",right:"Aligned to the right",top:"Aligned to the top"},button_size:"Menu button size in pixels",buttons:{alignment:"Button alignment",alignments:{matching:"Matching the menu alignment",opposing:"Opposing the menu alignment"},camera_ui:"Camera user interface",cameras:"Cameras",clips:"Clips",download:"Download",enabled:"Button enabled",expand:"Expand",frigate:"Frigate menu / Default view",fullscreen:"Fullscreen",icon:"Icon",image:"Image",live:"Live",media_player:"Send to media player",microphone:"Microphone",mute:"Mute / Unmute",play:"Play / Pause",priority:"Priority",recordings:"Recordings",screenshot:"Screenshot",snapshots:"Snapshots",substreams:"Substream(s)",timeline:"Timeline",type:"Button type",types:{momentary:"Momentary",toggle:"Toggle"}},position:"Menu position",positions:{bottom:"Positioned on the bottom",left:"Positioned on the left",right:"Positioned on the right",top:"Positioned on the top"},style:"Menu style",styles:{hidden:"Hidden menu",hover:"Hover menu","hover-card":"Hover menu (card-wide)",none:"No menu",outside:"Outside menu",overlay:"Overlay menu"}},overrides:{info:"This card configuration has manually specified overrides configured which may override values shown in the visual editor, please consult the code editor to view/modify these overrides"},performance:{features:{animated_progress_indicator:"Animated Progress Indicator",editor_label:"Feature Options",media_chunk_size:"Media chunk size"},profile:"Performance profile",profiles:{high:"High/full performance",low:"Low performance"},style:{border_radius:"Curves",box_shadow:"Shadows",editor_label:"Style Options"},warning:"This card is in low profile mode so defaults have changed to optimize performance"},view:{camera_select:"View for newly selected cameras",dark_mode:"Dark mode",dark_modes:{auto:"Auto",off:"Off",on:"On"},default:"Default view",scan:{enabled:"Scan mode enabled",scan_mode:"Scan mode",show_trigger_status:"Show pulsing border when triggered",untrigger_reset:"Reset the view to default after untrigger",untrigger_seconds:"Seconds after inactive state change to untrigger"},timeout_seconds:"Reset to default view X seconds after user action (0=never)",update_cycle_camera:"Cycle through cameras when default view updates",update_force:"Force card updates (ignore user interaction)",update_seconds:"Refresh default view every X seconds (0=never)",views:{clip:"Most recent clip",clips:"Clips gallery",current:"Current view",image:"Static image",live:"Live view",recording:"Most recent recording",recordings:"Recordings gallery",snapshot:"Most recent snapshot",snapshots:"Snapshots gallery",timeline:"Timeline view"}}},$m={add_new_camera:"Add new camera",button:"Button",camera:"Camera",cameras:"Cameras",cameras_secondary:"What cameras to render on this card",delete:"Delete",dimensions:"Dimensions",dimensions_secondary:"Dimensions & shape options",image:"Image",image_secondary:"Static image view options",live:"Live",live_secondary:"Live camera view options",media_gallery:"Media gallery",media_gallery_secondary:"Media gallery options",media_viewer:"Media viewer",media_viewer_secondary:"Viewer for static media (clips, snapshots or recordings)",menu:"Menu",menu_secondary:"Menu look & feel options",move_down:"Move down",move_up:"Move up",overrides:"Overrides are active",overrides_secondary:"Dynamic configuration overrides detected",performance:"Performance",performance_secondary:"Card performance options",timeline:"Timeline",timeline_secondary:"Event timeline options",upgrade:"Upgrade",upgrade_available:"An automatic card configuration upgrade is available",view:"View",view_secondary:"What the card should show and how to show it"},km={ptz:{down:"Down",home:"Home",left:"Left",right:"Right",up:"Up",zoom_in:"Zoom In",zoom_out:"Zoom Out"}},Em={could_not_render_elements:"Could not render picture elements",could_not_resolve:"Could not resolve media URL",diagnostics:"Card diagnostics. Please review for confidential information prior to sharing",download_no_media:"No media to download",download_sign_failed:"Could not sign media URL for download",duplicate_camera_id:"Duplicate Frigate camera id for the following camera, use the 'id' parameter to uniquely identify cameras",empty_response:"Received empty response from Home Assistant for request",failed_response:"Failed to receive response from Home Assistant for request",failed_retain:"Could not retain event",failed_sign:"Could not sign Home Assistant URL",image_load_error:"The image could not be loaded",invalid_configuration:"Invalid configuration",invalid_configuration_no_hint:"No location hint available (bad or missing type?)",invalid_elements_config:"Invalid picture elements configuration",invalid_response:"Received invalid response from Home Assistant for request",jsmpeg_no_player:"Could not start JSMPEG player",live_camera_no_endpoint:"Could not get camera endpoint for this live provider (incomplete configuration?)",live_camera_not_found:"The configured camera_entity was not found",live_camera_unavailable:"Camera unavailable",no_camera_engine:"Could not determine suitable engine for camera",no_camera_entity:"Could not find camera entity",no_camera_entity_for_triggers:"A camera entity is required in order to autodetect triggers",no_camera_id:"Could not determine camera id for the following camera, may need to set 'id' parameter manually",no_camera_name:"Could not determine a Frigate camera name for camera (or one of its dependents), please specify either 'camera_entity' or 'camera_name'",no_live_camera:"The camera_entity parameter must be set and valid for this live provider",no_visible_cameras:"No visible cameras found, you must configure at least one non-hidden camera",reconnecting:"Reconnecting",timeline_no_cameras:"No Frigate cameras to show in timeline",too_many_automations:"Too many nested automation calls, please check your configuration for loops",troubleshooting:"Check troubleshooting",unknown:"Unknown error",upgrade_available:"An automated card configuration upgrade is available, please visit the visual card editor",webrtc_card_reported_error:"WebRTC Card reported an error",webrtc_card_waiting:"Waiting for WebRTC Card to load ..."},Mm={camera:"Camera",duration:"Duration",in_progress:"In Progress",score:"Score",seek:"Seek",start:"Start",tag:"Tag",what:"What",where:"Where"},Sm={all:"All",camera:"Camera",favorite:"Favorite",media_type:"Media Type",media_types:{clips:"Clips",recordings:"Recordings",snapshots:"Snapshots"},not_favorite:"Not Favorite",select_camera:"Select camera...",select_favorite:"Select favorite...",select_media_type:"Select media type...",select_tag:"Select tag...",select_what:"Select what...",select_when:"Select when...",select_where:"Select where...",tag:"Tag",what:"What",when:"When",whens:{past_month:"Past Month",past_week:"Past Week",today:"Today",yesterday:"Yesterday"},where:"Where"},Tm={camera:"Camera",duration:"Duration",events:"Events",in_progress:"In Progress",seek:"Seek",start:"Start"},Am={download:"Download media",no_thumbnail:"No thumbnail available",retain_indefinitely:"Media will be indefinitely retained",timeline:"See media in timeline"},zm={pan_behavior:{pan:"Pan",seek:"Pan seeks across all media","seek-in-media":"Pan seeks within selected media item only"},select_date:"Choose date"},jm={common:xm,config:Cm,editor:$m,elements:km,error:Em,event:Mm,media_filter:Sm,recording:Tm,thumbnail:Am,timeline:zm};const Om="en",Im={[Om]:Object.freeze({__proto__:null,common:xm,config:Cm,editor:$m,elements:km,error:Em,event:Mm,media_filter:Sm,recording:Tm,thumbnail:Am,timeline:zm,default:jm})};let Rm;function Dm(e){const t=e=>e.replace("-","_"),n=e?.language??e?.selectedLanguage;if(n)return t(n);const i=localStorage.getItem("selectedLanguage");if(i){const e=JSON.parse(i);if(e)return t(e)}for(const e of navigator.languages){const n=t(e);if(n&&n in Im)return n}return Om}function Pm(e,t="",n=""){let i="";try{i=e.split(".").reduce(((e,t)=>e[t]),Im[Rm??Om])}catch(e){}return i||(i=e.split(".").reduce(((e,t)=>e[t]),Im[Om])),""!==t&&""!==n&&(i=i.replace(t,n)),i}class Lm extends vu{}class Nm{constructor(e){this._priorEvaluations=new Map,this._nestedAutomationExecutions=0,this._automations=e}execute(e,t,n){const i=[];for(const e of this._automations??[]){const t=n.evaluateCondition(e.conditions),a=t?e.actions:e.actions_not,r=this._priorEvaluations.get(e);this._priorEvaluations.set(e,t),t!==r&&a&&i.push(a)}if(++this._nestedAutomationExecutions,this._nestedAutomationExecutions>10)throw new Lm(Pm("error.too_many_automations"));i.forEach((n=>{fm(e,t,{},n)})),--this._nestedAutomationExecutions}}function Um(e){if(null===e||!0===e||!1===e)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function Fm(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function Hm(e){return Hm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hm(e)}function Zm(e){Fm(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||"object"===Hm(e)&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn((new Error).stack)),new Date(NaN))}function qm(e,t){Fm(2,arguments);var n=Zm(e),i=Um(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}function Vm(e,t){Fm(2,arguments);var n=Zm(e),i=Um(t);if(isNaN(i))return new Date(NaN);if(!i)return n;var a=n.getDate(),r=new Date(n.getTime());return r.setMonth(n.getMonth()+i+1,0),a>=r.getDate()?r:(n.setFullYear(r.getFullYear(),r.getMonth(),a),n)}function Wm(e){return Wm="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wm(e)}function Bm(e,t){if(Fm(2,arguments),!t||"object"!==Wm(t))return new Date(NaN);var n=t.years?Um(t.years):0,i=t.months?Um(t.months):0,a=t.weeks?Um(t.weeks):0,r=t.days?Um(t.days):0,o=t.hours?Um(t.hours):0,s=t.minutes?Um(t.minutes):0,c=t.seconds?Um(t.seconds):0,l=Zm(e),d=i||n?Vm(l,i+12*n):l,u=r||a?qm(d,r+7*a):d,h=1e3*(c+60*(s+60*o));return new Date(u.getTime()+h)}const Ym=(e,t)=>0!=((e.attributes.supported_features??0)&t),Qm=e=>(e=>Ym(e,4)&&"number"==typeof e.attributes.in_progress)(e)||!!e.attributes.in_progress,Gm=e=>{switch(e){case"armed_away":return"mdi:shield-lock";case"armed_vacation":return"mdi:shield-airplane";case"armed_home":return"mdi:shield-home";case"armed_night":return"mdi:shield-moon";case"armed_custom_bypass":return"mdi:security";case"pending":case"arming":return"mdi:shield-sync";case"triggered":return"mdi:bell-ring";case"disarmed":return"mdi:shield-off";default:return"mdi:shield"}},Km=(e,t)=>{const n="off"===e;switch(t?.attributes.device_class){case"battery":return n?"mdi:battery":"mdi:battery-outline";case"battery_charging":return n?"mdi:battery":"mdi:battery-charging";case"cold":return n?"mdi:thermometer":"mdi:snowflake";case"connectivity":return n?"mdi:close-network-outline":"mdi:check-network-outline";case"door":return n?"mdi:door-closed":"mdi:door-open";case"garage_door":return n?"mdi:garage":"mdi:garage-open";case"power":case"plug":return n?"mdi:power-plug-off":"mdi:power-plug";case"gas":case"problem":case"safety":case"tamper":return n?"mdi:check-circle":"mdi:alert-circle";case"smoke":return n?"mdi:check-circle":"mdi:smoke";case"heat":return n?"mdi:thermometer":"mdi:fire";case"light":return n?"mdi:brightness5":"mdi:brightness-7";case"lock":return n?"mdi:lock":"mdi:lock-open";case"moisture":return n?"mdi:water-off":"mdi:water";case"motion":return n?"mdi:motion-sensor-off":"mdi:motion-sensor";case"occupancy":case"presence":return n?"mdi:home-outline":"mdi:home";case"opening":return n?"mdi:square":"mdi:square-outline";case"running":return n?"mdi:stop":"mdi:play";case"sound":return n?"mdi:music-note-off":"mdi:music-note";case"update":return n?"mdi:package":"mdi:package-up";case"vibration":return n?"mdi:crop-portrait":"mdi:vibrate";case"window":return n?"mdi:window-closed":"mdi:window-open";default:return n?"mdi:radiobox-blank":"mdi:checkbox-marked-circle"}},Xm=(e,t)=>{const n="closed"!==e;switch(t?.attributes.device_class){case"garage":switch(e){case"opening":return"mdi:arrow-up-box";case"closing":return"mdi:arrow-down-box";case"closed":return"mdi:garage";default:return"mdi:garage-open"}case"gate":switch(e){case"opening":case"closing":return"mdi:gate-arrow-right";case"closed":return"mdi:gate";default:return"mdi:gate-open"}case"door":return n?"mdi:door-open":"mdi:door-closed";case"damper":return n?"md:circle":"mdi:circle-slice-8";case"shutter":switch(e){case"opening":return"mdi:arrow-up-box";case"closing":return"mdi:arrow-down-box";case"closed":return"mdi:window-shutter";default:return"mdi:window-shutter-open"}case"curtain":switch(e){case"opening":return"mdi:arrow-split-vertical";case"closing":return"mdi:arrow-collapse-horizontal";case"closed":return"mdi:curtains-closed";default:return"mdi:curtains"}case"blind":case"shade":switch(e){case"opening":return"mdi:arrow-up-box";case"closing":return"mdi:arrow-down-box";case"closed":return"mdi:blinds";default:return"mdi:blinds-open"}case"window":switch(e){case"opening":return"mdi:arrow-up-box";case"closing":return"mdi:arrow-down-box";case"closed":return"mdi:window-closed";default:return"mdi:window-open"}}switch(e){case"opening":return"mdi:arrow-up-box";case"closing":return"mdi:arrow-down-box";case"closed":return"mdi:window-closed";default:return"mdi:window-open"}},Jm={apparent_power:"mdi:flash",aqi:"mdi:air-filter",carbon_dioxide:"mdi:molecule-co2",carbon_monoxide:"mdi:molecule-co",current:"mdi:current-ac",date:"mdi:calendar",energy:"mdi:lightning-bolt",frequency:"mdi:sine-wave",gas:"mdi:gas-cylinder",humidity:"mdi:water-percent",illuminance:"mdi:brightness-5",monetary:"mdi:cash",nitrogen_dioxide:"mdi:molecule",nitrogen_monoxide:"mdi:molecule",nitrous_oxide:"mdi:molecule",ozone:"mdi:molecule",pm1:"mdi:molecule",pm10:"mdi:molecule",pm25:"mdi:molecule",power:"mdi:flash",power_factor:"mdi:angle-acute",pressure:"mdi:gauge",reactive_power:"mdi:flash",signal_strength:"mdi:wifi",sulphur_dioxide:"mdi:molecule",temperature:"mdi:thermometer",timestamp:"mdi:clock",volatile_organic_compounds:"mdi:molecule",voltage:"mdi:sine-wave"},ep={10:"mdi:battery-10",20:"mdi:battery-20",30:"mdi:battery-30",40:"mdi:battery-40",50:"mdi:battery-50",60:"mdi:battery-60",70:"mdi:battery-70",80:"mdi:battery-80",90:"mdi:battery-90",100:"mdi:battery"},tp={10:"mdi:battery-charging-10",20:"mdi:battery-charging-20",30:"mdi:battery-charging-30",40:"mdi:battery-charging-40",50:"mdi:battery-charging-50",60:"mdi:battery-charging-60",70:"mdi:battery-charging-70",80:"mdi:battery-charging-80",90:"mdi:battery-charging-90",100:"mdi:battery-charging"},np=(e,t)=>{const n=Number(e);if(isNaN(n))return"off"===e?"mdi:battery":"on"===e?"mdi:battery-alert":"mdi:battery-unknown";const i=10*Math.round(n/10);return t&&n>=10?tp[i]:t?"mdi:battery-charging-outline":n<=5?"mdi:battery-alert-variant-outline":ep[i]},ip=e=>{const t=e?.attributes.device_class;if(t&&t in Jm)return Jm[t];if("battery"===t)return e?((e,t)=>{const n=e.state;return np(n,"on"===t?.state)})(e):"mdi:battery";const n=e?.attributes.unit_of_measurement;return"°C"===n||"°F"===n?"mdi:thermometer":void 0},ap="mdi:bookmark",rp={alert:"mdi:alert",air_quality:"mdi:air-filter",automation:"mdi:robot",calendar:"mdi:calendar",camera:"mdi:video",climate:"mdi:thermostat",configurator:"mdi:cog",conversation:"mdi:text-to-speech",counter:"mdi:counter",fan:"mdi:fan",google_assistant:"mdi:google-assistant",group:"mdi:google-circles-communities",homeassistant:"mdi:home-assistant",homekit:"mdi:home-automation",image_processing:"mdi:image-filter-frames",input_button:"mdi:gesture-tap-button",input_datetime:"mdi:calendar-clock",input_number:"mdi:ray-vertex",input_select:"mdi:format-list-bulleted",input_text:"mdi:form-textbox",light:"mdi:lightbulb",mailbox:"mdi:mailbox",notify:"mdi:comment-alert",number:"mdi:ray-vertex",persistent_notification:"mdi:bell",person:"mdi:account",plant:"mdi:flower",proximity:"mdi:apple-safari",remote:"mdi:remote",scene:"mdi:palette",script:"mdi:script-text",select:"mdi:format-list-bulleted",sensor:"mdi:eye",siren:"mdi:bullhorn",simple_alarm:"mdi:bell",sun:"mdi:white-balance-sunny",timer:"mdi:timer-outline",updater:"mdi:cloud-upload",vacuum:"mdi:robot-vacuum",water_heater:"mdi:thermometer",weather:"mdi:weather-cloudy",zone:"mdi:map-marker-radius"};function op(e,t,n){switch(e){case"alarm_control_panel":return Gm(n);case"binary_sensor":return Km(n,t);case"button":switch(t?.attributes.device_class){case"restart":return"mdi:restart";case"update":return"mdi:package-up";default:return"mdi:gesture-tap-button"}case"cover":return Xm(n,t);case"device_tracker":return"router"===t?.attributes.source_type?"home"===n?"mdi:lan-connect":"mdi:lan-disconnect":["bluetooth","bluetooth_le"].includes(t?.attributes.source_type)?"home"===n?"mdi:bluetooth-connect":"mdi:bluetooth":"not_home"===n?"mdi:account-arrow-right":"mdi:account";case"humidifier":return n&&"off"===n?"mdi:air-humidifier-off":"mdi:air-humidifier";case"input_boolean":return"on"===n?"mdi:check-circle-outline":"mdi:close-circle-outline";case"lock":switch(n){case"unlocked":return"mdi:lock-open";case"jammed":return"mdi:lock-alert";case"locking":case"unlocking":return"mdi:lock-clock";default:return"mdi:lock"}case"media_player":switch(t?.attributes.device_class){case"speaker":switch(n){case"playing":return"mdi:speaker-play";case"paused":return"mdi:speaker-pause";case"off":return"mdi:speaker-off";default:return"mdi:speaker"}case"tv":switch(n){case"playing":return"mdi:television-play";case"paused":return"mdi:television-pause";case"off":return"mdi:television-off";default:return"mdi:television"}default:switch(n){case"playing":case"paused":return"mdi:cast-connected";case"off":return"mdi:cast-off";default:return"mdi:cast"}}case"switch":switch(t?.attributes.device_class){case"outlet":return"on"===n?"mdi:power-plug":"mdi:power-plug-off";case"switch":return"on"===n?"mdi:toggle-switch":"mdi:toggle-switch-off";default:return"mdi:flash"}case"zwave":switch(n){case"dead":return"mdi:emoticon-dead";case"sleeping":return"mdi:sleep";case"initializing":return"mdi:timer-sand";default:return"mdi:z-wave"}case"sensor":{const e=ip(t);if(e)return e;break}case"input_datetime":if(!t?.attributes.has_date)return"mdi:clock";if(!t.attributes.has_time)return"mdi:calendar";break;case"sun":return"above_horizon"===t?.state?rp[e]:"mdi:weather-night";case"update":return"on"===t?.state?Qm(t)?"mdi:package-down":"mdi:package-up":"mdi:package"}return e in rp?rp[e]:(console.warn(`Unable to find icon for domain: ${e}`),ap)}function sp(e){if(!e)return ap;if(e.attributes.icon)return e.attributes.icon;return op(s(e.entity_id),e,e.state)}async function cp(e,t,n,i=!1){let a;try{a=await e.callWS(n)}catch(e){if(!(e instanceof Error))throw new vu(Pm("error.failed_response"),{request:n,response:e});throw e}if(!a)throw new vu(Pm("error.empty_response"),{request:n});const r=i?t.safeParse(JSON.parse(a)):t.safeParse(a);if(!r.success)throw new vu(Pm("error.invalid_response"),{request:n,response:a,invalid_keys:au(r.error)});return r.data}async function lp(e,t,n){const i={type:"auth/sign_path",path:t,expires:n},a=await cp(e,dm,i);return a?e.hassUrl(a.path):null}function dp(e,t,n,i){if(!e||!n||!n.length)return[];const a=[];for(const r of n){const n=t?.states[r],o=e.states[r];if((i?.stateOnly&&n?.state!==o?.state||!i?.stateOnly&&n!==o)&&(a.push({entity:r,oldState:n,newState:o}),i?.firstOnly))break}return a}function up(e,t,n,i){return!!dp(e,t,n,{...i,firstOnly:!0}).length}function hp(e){if("off"===e.state||!e.attributes.brightness)return"";return`brightness(${(e.attributes.brightness+245)/5}%)`}function mp(e){return"off"===e.state?"":e.attributes.rgb_color?`rgb(${e.attributes.rgb_color.join(",")})`:""}function pp(e){return{color:mp(e),filter:hp(e)}}const fp=e=>{const t=e.entity_id.split(".")[0];let n=e.state;return"climate"===t&&(n=e.attributes.hvac_action),n};function gp(e,t){if(!t.entity)return t;const n=e.states[t.entity];n&&t.state_color&&(t.style={...pp(n),...t.style}),t.title=t.title??(n?.attributes?.friendly_name||t.entity),t.icon=t.icon??sp(n);const i=n?function(e){return s(e.entity_id)}(n):void 0;return t.data_domain=t.state_color||"light"===i&&!1!==t.state_color?i:void 0,n&&(t.data_state=fp(n)),t}function vp(e,t){return t?e?.states[t]?.attributes?.friendly_name:void 0}function _p(e,t){return sp(t?e?.states[t]:null)}const yp=async()=>{if(["ha-selector","ha-menu-button","ha-camera-stream","ha-hls-player","ha-web-rtc-player","ha-icon","ha-circular-progress","ha-icon-button","ha-card","ha-svg-icon","ha-button-menu"].every((e=>customElements.get(e))))return!0;const e=await window.loadCardHelpers(),t=await e.createCardElement({type:"picture-glance",entities:[],camera_image:"dummy-to-load-editor-components"});return!!t.constructor.getConfigElement&&(await t.constructor.getConfigElement(),!0)},bp=e=>!!e&&["on","open"].includes(e.state),wp=(e,t)=>{if(!e)return[];const n=Object.keys(e.states).filter((e=>!t||e.substr(0,e.indexOf("."))===t));return n.sort(),n};function xp(e,t){return e&&t&&t.startsWith("/")?e.hassUrl(t):t??null}var Cp=6e4,$p=36e5,kp=1e3;function Ep(e,t){return Fm(2,arguments),Zm(e).getTime()-Zm(t).getTime()}var Mp={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}},Sp="trunc";function Tp(e){return e?Mp[e]:Mp[Sp]}function Ap(e,t,n){Fm(2,arguments);var i=Ep(e,t)/1e3;return Tp(null==n?void 0:n.roundingMethod)(i)}function zp(e){return zp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},zp(e)}function jp(e){if(Fm(1,arguments),!function(e){return Fm(1,arguments),e instanceof Date||"object"===zp(e)&&"[object Date]"===Object.prototype.toString.call(e)}(e)&&"number"!=typeof e)return!1;var t=Zm(e);return!isNaN(Number(t))}function Op(e,t){return Fm(2,arguments),function(e,t){Fm(2,arguments);var n=Zm(e).getTime(),i=Um(t);return new Date(n+i)}(e,-Um(t))}var Ip=864e5;function Rp(e){Fm(1,arguments);var t=Zm(e),n=t.getUTCDay(),i=(n<1?7:0)+n-1;return t.setUTCDate(t.getUTCDate()-i),t.setUTCHours(0,0,0,0),t}function Dp(e){Fm(1,arguments);var t=Zm(e),n=t.getUTCFullYear(),i=new Date(0);i.setUTCFullYear(n+1,0,4),i.setUTCHours(0,0,0,0);var a=Rp(i),r=new Date(0);r.setUTCFullYear(n,0,4),r.setUTCHours(0,0,0,0);var o=Rp(r);return t.getTime()>=a.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1}var Pp=6048e5;function Lp(e){Fm(1,arguments);var t=Zm(e),n=Rp(t).getTime()-function(e){Fm(1,arguments);var t=Dp(e),n=new Date(0);return n.setUTCFullYear(t,0,4),n.setUTCHours(0,0,0,0),Rp(n)}(t).getTime();return Math.round(n/Pp)+1}var Np={};function Up(){return Np}function Fp(e,t){var n,i,a,r,o,s,c,l;Fm(1,arguments);var d=Up(),u=Um(null!==(n=null!==(i=null!==(a=null!==(r=null==t?void 0:t.weekStartsOn)&&void 0!==r?r:null==t||null===(o=t.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.weekStartsOn)&&void 0!==a?a:d.weekStartsOn)&&void 0!==i?i:null===(c=d.locale)||void 0===c||null===(l=c.options)||void 0===l?void 0:l.weekStartsOn)&&void 0!==n?n:0);if(!(u>=0&&u<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var h=Zm(e),m=h.getUTCDay(),p=(m<u?7:0)+m-u;return h.setUTCDate(h.getUTCDate()-p),h.setUTCHours(0,0,0,0),h}function Hp(e,t){var n,i,a,r,o,s,c,l;Fm(1,arguments);var d=Zm(e),u=d.getUTCFullYear(),h=Up(),m=Um(null!==(n=null!==(i=null!==(a=null!==(r=null==t?void 0:t.firstWeekContainsDate)&&void 0!==r?r:null==t||null===(o=t.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==a?a:h.firstWeekContainsDate)&&void 0!==i?i:null===(c=h.locale)||void 0===c||null===(l=c.options)||void 0===l?void 0:l.firstWeekContainsDate)&&void 0!==n?n:1);if(!(m>=1&&m<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setUTCFullYear(u+1,0,m),p.setUTCHours(0,0,0,0);var f=Fp(p,t),g=new Date(0);g.setUTCFullYear(u,0,m),g.setUTCHours(0,0,0,0);var v=Fp(g,t);return d.getTime()>=f.getTime()?u+1:d.getTime()>=v.getTime()?u:u-1}var Zp=6048e5;function qp(e,t){Fm(1,arguments);var n=Zm(e),i=Fp(n,t).getTime()-function(e,t){var n,i,a,r,o,s,c,l;Fm(1,arguments);var d=Up(),u=Um(null!==(n=null!==(i=null!==(a=null!==(r=null==t?void 0:t.firstWeekContainsDate)&&void 0!==r?r:null==t||null===(o=t.locale)||void 0===o||null===(s=o.options)||void 0===s?void 0:s.firstWeekContainsDate)&&void 0!==a?a:d.firstWeekContainsDate)&&void 0!==i?i:null===(c=d.locale)||void 0===c||null===(l=c.options)||void 0===l?void 0:l.firstWeekContainsDate)&&void 0!==n?n:1),h=Hp(e,t),m=new Date(0);return m.setUTCFullYear(h,0,u),m.setUTCHours(0,0,0,0),Fp(m,t)}(n,t).getTime();return Math.round(i/Zp)+1}function Vp(e,t){for(var n=e<0?"-":"",i=Math.abs(e).toString();i.length<t;)i="0"+i;return n+i}var Wp=function(e,t){var n=e.getUTCFullYear(),i=n>0?n:1-n;return Vp("yy"===t?i%100:i,t.length)},Bp=function(e,t){var n=e.getUTCMonth();return"M"===t?String(n+1):Vp(n+1,2)},Yp=function(e,t){return Vp(e.getUTCDate(),t.length)},Qp=function(e,t){return Vp(e.getUTCHours()%12||12,t.length)},Gp=function(e,t){return Vp(e.getUTCHours(),t.length)},Kp=function(e,t){return Vp(e.getUTCMinutes(),t.length)},Xp=function(e,t){return Vp(e.getUTCSeconds(),t.length)},Jp=function(e,t){var n=t.length,i=e.getUTCMilliseconds();return Vp(Math.floor(i*Math.pow(10,n-3)),t.length)},ef="midnight",tf="noon",nf="morning",af="afternoon",rf="evening",of="night",sf={G:function(e,t,n){var i=e.getUTCFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(i,{width:"abbreviated"});case"GGGGG":return n.era(i,{width:"narrow"});default:return n.era(i,{width:"wide"})}},y:function(e,t,n){if("yo"===t){var i=e.getUTCFullYear(),a=i>0?i:1-i;return n.ordinalNumber(a,{unit:"year"})}return Wp(e,t)},Y:function(e,t,n,i){var a=Hp(e,i),r=a>0?a:1-a;return"YY"===t?Vp(r%100,2):"Yo"===t?n.ordinalNumber(r,{unit:"year"}):Vp(r,t.length)},R:function(e,t){return Vp(Dp(e),t.length)},u:function(e,t){return Vp(e.getUTCFullYear(),t.length)},Q:function(e,t,n){var i=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return Vp(i,2);case"Qo":return n.ordinalNumber(i,{unit:"quarter"});case"QQQ":return n.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(i,{width:"narrow",context:"formatting"});default:return n.quarter(i,{width:"wide",context:"formatting"})}},q:function(e,t,n){var i=Math.ceil((e.getUTCMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return Vp(i,2);case"qo":return n.ordinalNumber(i,{unit:"quarter"});case"qqq":return n.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(i,{width:"narrow",context:"standalone"});default:return n.quarter(i,{width:"wide",context:"standalone"})}},M:function(e,t,n){var i=e.getUTCMonth();switch(t){case"M":case"MM":return Bp(e,t);case"Mo":return n.ordinalNumber(i+1,{unit:"month"});case"MMM":return n.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(i,{width:"narrow",context:"formatting"});default:return n.month(i,{width:"wide",context:"formatting"})}},L:function(e,t,n){var i=e.getUTCMonth();switch(t){case"L":return String(i+1);case"LL":return Vp(i+1,2);case"Lo":return n.ordinalNumber(i+1,{unit:"month"});case"LLL":return n.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(i,{width:"narrow",context:"standalone"});default:return n.month(i,{width:"wide",context:"standalone"})}},w:function(e,t,n,i){var a=qp(e,i);return"wo"===t?n.ordinalNumber(a,{unit:"week"}):Vp(a,t.length)},I:function(e,t,n){var i=Lp(e);return"Io"===t?n.ordinalNumber(i,{unit:"week"}):Vp(i,t.length)},d:function(e,t,n){return"do"===t?n.ordinalNumber(e.getUTCDate(),{unit:"date"}):Yp(e,t)},D:function(e,t,n){var i=function(e){Fm(1,arguments);var t=Zm(e),n=t.getTime();t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);var i=n-t.getTime();return Math.floor(i/Ip)+1}(e);return"Do"===t?n.ordinalNumber(i,{unit:"dayOfYear"}):Vp(i,t.length)},E:function(e,t,n){var i=e.getUTCDay();switch(t){case"E":case"EE":case"EEE":return n.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},e:function(e,t,n,i){var a=e.getUTCDay(),r=(a-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(r);case"ee":return Vp(r,2);case"eo":return n.ordinalNumber(r,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,i){var a=e.getUTCDay(),r=(a-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(r);case"cc":return Vp(r,t.length);case"co":return n.ordinalNumber(r,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){var i=e.getUTCDay(),a=0===i?7:i;switch(t){case"i":return String(a);case"ii":return Vp(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},a:function(e,t,n){var i=e.getUTCHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){var i,a=e.getUTCHours();switch(i=12===a?tf:0===a?ef:a/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){var i,a=e.getUTCHours();switch(i=a>=17?rf:a>=12?af:a>=4?nf:of,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if("ho"===t){var i=e.getUTCHours()%12;return 0===i&&(i=12),n.ordinalNumber(i,{unit:"hour"})}return Qp(e,t)},H:function(e,t,n){return"Ho"===t?n.ordinalNumber(e.getUTCHours(),{unit:"hour"}):Gp(e,t)},K:function(e,t,n){var i=e.getUTCHours()%12;return"Ko"===t?n.ordinalNumber(i,{unit:"hour"}):Vp(i,t.length)},k:function(e,t,n){var i=e.getUTCHours();return 0===i&&(i=24),"ko"===t?n.ordinalNumber(i,{unit:"hour"}):Vp(i,t.length)},m:function(e,t,n){return"mo"===t?n.ordinalNumber(e.getUTCMinutes(),{unit:"minute"}):Kp(e,t)},s:function(e,t,n){return"so"===t?n.ordinalNumber(e.getUTCSeconds(),{unit:"second"}):Xp(e,t)},S:function(e,t){return Jp(e,t)},X:function(e,t,n,i){var a=(i._originalDate||e).getTimezoneOffset();if(0===a)return"Z";switch(t){case"X":return lf(a);case"XXXX":case"XX":return df(a);default:return df(a,":")}},x:function(e,t,n,i){var a=(i._originalDate||e).getTimezoneOffset();switch(t){case"x":return lf(a);case"xxxx":case"xx":return df(a);default:return df(a,":")}},O:function(e,t,n,i){var a=(i._originalDate||e).getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+cf(a,":");default:return"GMT"+df(a,":")}},z:function(e,t,n,i){var a=(i._originalDate||e).getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+cf(a,":");default:return"GMT"+df(a,":")}},t:function(e,t,n,i){var a=i._originalDate||e;return Vp(Math.floor(a.getTime()/1e3),t.length)},T:function(e,t,n,i){return Vp((i._originalDate||e).getTime(),t.length)}};function cf(e,t){var n=e>0?"-":"+",i=Math.abs(e),a=Math.floor(i/60),r=i%60;if(0===r)return n+String(a);var o=t||"";return n+String(a)+o+Vp(r,2)}function lf(e,t){return e%60==0?(e>0?"-":"+")+Vp(Math.abs(e)/60,2):df(e,t)}function df(e,t){var n=t||"",i=e>0?"-":"+",a=Math.abs(e);return i+Vp(Math.floor(a/60),2)+n+Vp(a%60,2)}var uf=function(e,t){switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},hf=function(e,t){switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},mf={p:hf,P:function(e,t){var n,i=e.match(/(P+)(p+)?/)||[],a=i[1],r=i[2];if(!r)return uf(e,t);switch(a){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",uf(a,t)).replace("{{time}}",hf(r,t))}};function pf(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}var ff=["D","DD"],gf=["YY","YYYY"];function vf(e){return-1!==ff.indexOf(e)}function _f(e){return-1!==gf.indexOf(e)}function yf(e,t,n){if("YYYY"===e)throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(t,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("YY"===e)throw new RangeError("Use `yy` instead of `YY` (in `".concat(t,"`) for formatting years to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("D"===e)throw new RangeError("Use `d` instead of `D` (in `".concat(t,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if("DD"===e)throw new RangeError("Use `dd` instead of `DD` (in `".concat(t,"`) for formatting days of the month to the input `").concat(n,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var bf={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function wf(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var xf={date:wf({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:wf({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:wf({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Cf={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function $f(e){return function(t,n){var i;if("formatting"===(null!=n&&n.context?String(n.context):"standalone")&&e.formattingValues){var a=e.defaultFormattingWidth||e.defaultWidth,r=null!=n&&n.width?String(n.width):a;i=e.formattingValues[r]||e.formattingValues[a]}else{var o=e.defaultWidth,s=null!=n&&n.width?String(n.width):e.defaultWidth;i=e.values[s]||e.values[o]}return i[e.argumentCallback?e.argumentCallback(t):t]}}function kf(e){return function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.width,a=i&&e.matchPatterns[i]||e.matchPatterns[e.defaultMatchWidth],r=t.match(a);if(!r)return null;var o,s=r[0],c=i&&e.parsePatterns[i]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(c)?function(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n;return}(c,(function(e){return e.test(s)})):function(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(e[n]))return n;return}(c,(function(e){return e.test(s)}));return o=e.valueCallback?e.valueCallback(l):l,{value:o=n.valueCallback?n.valueCallback(o):o,rest:t.slice(s.length)}}}var Ef,Mf={code:"en-US",formatDistance:function(e,t,n){var i,a=bf[e];return i="string"==typeof a?a:1===t?a.one:a.other.replace("{{count}}",t.toString()),null!=n&&n.addSuffix?n.comparison&&n.comparison>0?"in "+i:i+" ago":i},formatLong:xf,formatRelative:function(e,t,n,i){return Cf[e]},localize:{ordinalNumber:function(e,t){var n=Number(e),i=n%100;if(i>20||i<10)switch(i%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:$f({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:$f({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:$f({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:$f({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:$f({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(Ef={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:function(e){return parseInt(e,10)}},function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.match(Ef.matchPattern);if(!n)return null;var i=n[0],a=e.match(Ef.parsePattern);if(!a)return null;var r=Ef.valueCallback?Ef.valueCallback(a[0]):a[0];return{value:r=t.valueCallback?t.valueCallback(r):r,rest:e.slice(i.length)}}),era:kf({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:kf({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:kf({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:kf({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:kf({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},Sf=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Tf=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Af=/^'([^]*?)'?$/,zf=/''/g,jf=/[a-zA-Z]/;function Of(e,t,n){var i,a,r,o,s,c,l,d,u,h,m,p,f,g,v,_,y,b;Fm(2,arguments);var w=String(t),x=Up(),C=null!==(i=null!==(a=null==n?void 0:n.locale)&&void 0!==a?a:x.locale)&&void 0!==i?i:Mf,$=Um(null!==(r=null!==(o=null!==(s=null!==(c=null==n?void 0:n.firstWeekContainsDate)&&void 0!==c?c:null==n||null===(l=n.locale)||void 0===l||null===(d=l.options)||void 0===d?void 0:d.firstWeekContainsDate)&&void 0!==s?s:x.firstWeekContainsDate)&&void 0!==o?o:null===(u=x.locale)||void 0===u||null===(h=u.options)||void 0===h?void 0:h.firstWeekContainsDate)&&void 0!==r?r:1);if(!($>=1&&$<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var k=Um(null!==(m=null!==(p=null!==(f=null!==(g=null==n?void 0:n.weekStartsOn)&&void 0!==g?g:null==n||null===(v=n.locale)||void 0===v||null===(_=v.options)||void 0===_?void 0:_.weekStartsOn)&&void 0!==f?f:x.weekStartsOn)&&void 0!==p?p:null===(y=x.locale)||void 0===y||null===(b=y.options)||void 0===b?void 0:b.weekStartsOn)&&void 0!==m?m:0);if(!(k>=0&&k<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!C.localize)throw new RangeError("locale must contain localize property");if(!C.formatLong)throw new RangeError("locale must contain formatLong property");var E=Zm(e);if(!jp(E))throw new RangeError("Invalid time value");var M=Op(E,pf(E)),S={firstWeekContainsDate:$,weekStartsOn:k,locale:C,_originalDate:E};return w.match(Tf).map((function(e){var t=e[0];return"p"===t||"P"===t?(0,mf[t])(e,C.formatLong):e})).join("").match(Sf).map((function(i){if("''"===i)return"'";var a=i[0];if("'"===a)return function(e){var t=e.match(Af);if(!t)return e;return t[1].replace(zf,"'")}(i);var r=sf[a];if(r)return null!=n&&n.useAdditionalWeekYearTokens||!_f(i)||yf(i,t,String(e)),null!=n&&n.useAdditionalDayOfYearTokens||!vf(i)||yf(i,t,String(e)),r(M,i,C.localize,S);if(a.match(jf))throw new RangeError("Format string contains an unescaped latin alphabet character `"+a+"`");return i})).join("")}function If(e,t,n){e.dispatchEvent(new CustomEvent(`frigate-card:${t}`,{bubbles:!0,composed:!0,detail:n}))}function Rf(e){if(!e)return;return e.split(/[_\s]+/).map((e=>e[0].toUpperCase()+e.substring(1))).join(" ")}function Df(e,t,n){const i=e[t];return e.splice(t,1),e.splice(n,0,i),e}const Pf=e=>Array.isArray(e)?e:[e];function Lf(e,t){return!Aa(e,t)}function Nf(e,t=console.warn){e instanceof vu&&e.context?t(e,e.context):t(e)}const Uf=()=>window.matchMedia("(hover: hover) and (pointer: fine)").matches,Ff=(e,t)=>Of(e,"yyyy-MM-dd HH:mm"+(t?":ss":"")),Hf=e=>Of(e,"yyyy-MM-dd"),Zf=(e,t)=>{window.requestIdleCallback?window.requestIdleCallback(e,{...t&&{timeout:t}}):e()};function qf(e,t){const n=function(e,t,n){Fm(2,arguments);var i=Ep(e,t)/$p;return Tp(null==n?void 0:n.roundingMethod)(i)}(t,e),i=function(e,t,n){Fm(2,arguments);var i=Ep(e,t)/Cp;return Tp(null==n?void 0:n.roundingMethod)(i)}(t,e)-60*n;let a="";return n&&(a+=`${n}h `),i&&(a+=`${i}m `),a+=`${Ap(t,e)-60*n*60-60*i}s`,a}const Vf=async(e,t)=>await Promise.all(Array.from(e).map((e=>t(e)))),Wf=e=>new Date(`${e}T00:00:00`),Bf=async e=>{await new Promise((t=>setTimeout(t,1e3*e)))},Yf=e=>!isNaN(e.getTime()),Qf=(e,t,n,i)=>{t?e.setAttribute(n,i??""):e.removeAttribute(n)},Gf=Ws.lazy((()=>Ws.object({title:Ws.string(),media_class:Ws.string(),media_content_type:Ws.string(),media_content_id:Ws.string(),can_play:Ws.boolean(),can_expand:Ws.boolean(),children_media_class:Ws.string().nullable().optional(),thumbnail:Ws.string().nullable(),children:Ws.array(Gf).nullable().optional()}))),Kf="video",Xf="image",Jf=60;class eg{constructor(e){this._cache=e}async walkBrowseMedias(e,t,n){return t&&t.length?(await Vf(t,(async t=>await this._walkBrowseMedia(e,t,n)))).flat():[]}async _walkBrowseMedia(e,t,n){const i=await Vf(t.targets,(async i=>await this._browseMedia(e,i,{useCache:n?.useCache,metadataGenerator:t.metadataGenerator}))),a=[];for(const e of i)for(const n of e.children??[])t.matcher(n)&&a.push(n);const r=t.advance?t.advance(a):null;if(!r||!r.length)return a;const o=new Set(r.map((e=>e.targets)).flat()),s=[];for(const e of a)o.has(e)||s.push(e);const c=await this.walkBrowseMedias(e,r,n);return s.concat(c)}async _browseMedia(e,t,n){const i="object"==typeof t?t.media_content_id:t,a=n?.useCache??1?this._cache.get(i):null;if(a)return a;const r={type:"media_source/browse_media",media_content_id:i},o=await cp(e,Gf,r);if(n?.metadataGenerator)for(const e of o.children??[])e._metadata=n.metadataGenerator(e,"object"==typeof t?t:void 0)??void 0;return(n?.useCache??1)&&this._cache.set(i,o,Bm(new Date,{seconds:60})),o}}function tg(e,t){for(var n=-1,i=null==e?0:e.length,a=Array(i);++n<i;)a[n]=t(e[n],n,e);return a}var ng=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ig=/^\w*$/;function ag(e,t){if(Yt(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!sr(e))||(ig.test(e)||!ng.test(e)||null!=t&&e in Object(t))}var rg="Expected a function";function og(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(rg);var n=function(){var i=arguments,a=t?t.apply(this,i):i[0],r=n.cache;if(r.has(a))return r.get(a);var o=e.apply(this,i);return n.cache=r.set(a,o)||r,o};return n.cache=new(og.Cache||Ot),n}og.Cache=Ot;var sg=500;var cg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lg=/\\(\\)?/g,dg=function(e){var t=og(e,(function(e){return n.size===sg&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(cg,(function(e,n,i,a){t.push(i?a.replace(lg,"$1"):n||e)})),t})),ug=1/0,hg=Ge?Ge.prototype:void 0,mg=hg?hg.toString:void 0;function pg(e){if("string"==typeof e)return e;if(Yt(e))return tg(e,pg)+"";if(sr(e))return mg?mg.call(e):"";var t=e+"";return"0"==t&&1/e==-ug?"-0":t}function fg(e){return null==e?"":pg(e)}function gg(e,t){return Yt(e)?e:ag(e,t)?[e]:dg(fg(e))}var vg=1/0;function _g(e){if("string"==typeof e||sr(e))return e;var t=e+"";return"0"==t&&1/e==-vg?"-0":t}function yg(e,t){for(var n=0,i=(t=gg(t,e)).length;null!=e&&n<i;)e=e[_g(t[n++])];return n&&n==i?e:void 0}var bg=1,wg=2;function xg(e){return e==e&&!ot(e)}function Cg(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}}function $g(e){var t=function(e){for(var t=wn(e),n=t.length;n--;){var i=t[n],a=e[i];t[n]=[i,a,xg(a)]}return t}(e);return 1==t.length&&t[0][2]?Cg(t[0][0],t[0][1]):function(n){return n===e||function(e,t,n,i){var a=n.length,r=a,o=!i;if(null==e)return!r;for(e=Object(e);a--;){var s=n[a];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++a<r;){var c=(s=n[a])[0],l=e[c],d=s[1];if(o&&s[2]){if(void 0===l&&!(c in e))return!1}else{var u=new Rt;if(i)var h=i(l,d,c,e,t,u);if(!(void 0===h?Ta(d,l,bg|wg,i,u):h))return!1}}return!0}(n,e,t)}}function kg(e,t,n){var i=null==e?void 0:yg(e,t);return void 0===i?n:i}function Eg(e,t){return null!=e&&t in Object(e)}function Mg(e,t){return null!=e&&function(e,t,n){for(var i=-1,a=(t=gg(t,e)).length,r=!1;++i<a;){var o=_g(t[i]);if(!(r=null!=e&&n(e,o)))break;e=e[o]}return r||++i!=a?r:!!(a=null==e?0:e.length)&&an(a)&&tn(o,a)&&(Yt(e)||Bt(e))}(e,t,Eg)}var Sg=1,Tg=2;function Ag(e){return ag(e)?(t=_g(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return yg(t,e)}}(e);var t}function zg(e){return"function"==typeof e?e:null==e?Za:"object"==typeof e?Yt(e)?(t=e[0],n=e[1],ag(t)&&xg(n)?Cg(_g(t),n):function(e){var i=kg(e,t);return void 0===i&&i===n?Mg(e,t):Ta(n,i,Sg|Tg)}):$g(e):Ag(e);var t,n}var jg=function(e,t){return function(n,i){if(null==n)return n;if(!bn(n))return e(n,i);for(var a=n.length,r=t?a:-1,o=Object(n);(t?r--:++r<a)&&!1!==i(o[r],r,o););return n}}((function(e,t){return e&&Oa(e,t,wn)}));function Og(e,t){if(e!==t){var n=void 0!==e,i=null===e,a=e==e,r=sr(e),o=void 0!==t,s=null===t,c=t==t,l=sr(t);if(!s&&!l&&!r&&e>t||r&&o&&c&&!s&&!l||i&&o&&c||!n&&c||!a)return 1;if(!i&&!r&&!l&&e<t||l&&n&&a&&!i&&!r||s&&n&&a||!o&&a||!c)return-1}return 0}function Ig(e,t,n){t=t.length?tg(t,(function(e){return Yt(e)?function(t){return yg(t,1===e.length?e[0]:e)}:e})):[Za];var i=-1;t=tg(t,on(zg));var a=function(e,t){var n=-1,i=bn(e)?Array(e.length):[];return jg(e,(function(e,a,r){i[++n]=t(e,a,r)})),i}(e,(function(e,n,a){return{criteria:tg(t,(function(t){return t(e)})),index:++i,value:e}}));return function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(a,(function(e,t){return function(e,t,n){for(var i=-1,a=e.criteria,r=t.criteria,o=a.length,s=n.length;++i<o;){var c=Og(a[i],r[i]);if(c)return i>=s?c:c*("desc"==n[i]?-1:1)}return e.index-t.index}(e,t,n)}))}function Rg(e,t,n,i){return null==e?[]:(Yt(t)||(t=null==t?[]:[t]),Yt(n=i?void 0:n)||(n=null==n?[]:[n]),Ig(e,t,n))}function Dg(e,t){return e&&e.length?function(e,t){for(var n=-1,i=e.length,a=0,r=[];++n<i;){var o=e[n],s=t?t(o):o;if(!n||!Ze(s,c)){var c=s;r[a++]=0===o?0:o}}return r}(e,zg(t)):[]}class Pg{constructor(e){this._ranges=e??[]}hasCoverage(e){return this._ranges.some((t=>Ng(t,e)))}add(e){this._ranges.push(e),this._ranges=Fg(this._ranges)}clear(){this._ranges=[]}}class Lg{constructor(e){this._ranges=e??[]}hasCoverage(e){const t=new Date;return this._ranges.some((n=>t<n.expires&&Ng(n,e)))}add(e){this._expireOldRanges(),this._ranges.push(e)}_expireOldRanges(){const e=new Date;this._ranges=this._ranges.filter((t=>e<t.expires))}clear(){this._ranges=[]}}const Ng=(e,t)=>t.start>=e.start&&t.end<=e.end,Ug=(e,t)=>e.start>=t.start&&e.start<=t.end||e.end>=t.start&&e.end<=t.end||e.start<=t.start&&e.end>=t.end,Fg=(e,t=0)=>{const n=[];e=Rg(e,(e=>e.start),"asc");let i=null;for(let a=0;a<e.length;++a){const r=e[a],o=r.start instanceof Date?r.start.getTime():r.start;if(!i){i={...r};continue}(i.end instanceof Date?i.end.getTime():i.end)+1e3*t>=o?r.end>i.end&&(i.end=r.end):(n.push(i),i={...r})}return i&&n.push(i),n};class Hg{constructor(){this._data=[]}get(e){const t=new Date;for(const n of this._data)if((!n.expires||t<=n.expires)&&this._contains(e,n.request))return n.response;return null}clear(){this._data=[]}has(e){return!!this.get(e)}set(e,t,n){this._data.push({request:e,response:t,expires:n}),this._expireOldRequests()}_contains(e,t){return Aa(e,t)}_expireOldRequests(){const e=new Date;this._data=this._data.filter((t=>!t.expires||e<t.expires))}}class Zg extends Hg{}class qg{constructor(e,t){this._ranges=new Pg,this._data=[],this._timeFunc=e,this._idFunc=t}add(e,t){this._ranges.add(e),this._data=Dg(Rg(this._data.concat(t),this._timeFunc,"asc"),this._idFunc)}hasCoverage(e){return this._ranges.hasCoverage(e)}get(e){if(!this.hasCoverage(e))return null;const t=[];for(const n of this._data){const i=this._timeFunc(n);if(i>=e.start.getTime()){if(i>e.end.getTime())break;t.push(n)}}return t}getSize(){return this._data.length}expireMatches(e){this._data=this._data.filter((t=>!e(t)))}}class Vg{constructor(){this._segments=new Map}add(e,t,n){let i=this._segments.get(e);i||(i=new qg((e=>1e3*e.start_time),(e=>e.id)),this._segments.set(e,i)),i.add(t,n)}clear(){this._segments.clear()}hasCoverage(e,t){return!!this._segments.get(e)?.hasCoverage(t)}get(e,t){return this._segments.get(e)?.get(t)??null}getSize(e){return this._segments.get(e)?.getSize()??null}getCameraIDs(){return[...this._segments.keys()]}expireMatches(e,t){this._segments.get(e)?.expireMatches(t)}}class Wg extends vu{}var Bg,Yg,Qg;function Gg(e){Fm(1,arguments);var t=Zm(e);return t.setMinutes(0,0,0),t}function Kg(e){Fm(1,arguments);var t=Zm(e);return t.setMinutes(59,59,999),t}function Xg(e){Fm(1,arguments);var t=Zm(e);return t.setHours(0,0,0,0),t}function Jg(e){Fm(1,arguments);var t=Zm(e);return t.setHours(23,59,59,999),t}function ev(e){return e!=e}function tv(e,t){return!!(null==e?0:e.length)&&function(e,t,n){return t==t?function(e,t,n){for(var i=n-1,a=e.length;++i<a;)if(e[i]===t)return i;return-1}(e,t,n):function(e,t,n,i){for(var a=e.length,r=n+(i?1:-1);i?r--:++r<a;)if(t(e[r],r,e))return r;return-1}(e,ev,n)}(e,t,0)>-1}function nv(e,t,n){for(var i=-1,a=null==e?0:e.length;++i<a;)if(n(t,e[i]))return!0;return!1}!function(e){e.Event="event-query",e.Recording="recording-query",e.RecordingSegments="recording-segments-query",e.MediaMetadata="media-metadata"}(Bg||(Bg={})),function(e){e.Event="event-results",e.Recording="recording-results",e.RecordingSegments="recording-segments-results",e.MediaMetadata="media-metadata-results"}(Yg||(Yg={})),function(e){e.Frigate="frigate",e.Generic="generic",e.MotionEye="motioneye"}(Qg||(Qg={}));var iv=Zn&&1/ra(new Zn([,-0]))[1]==1/0?function(e){return new Zn(e)}:function(){},av=200;function rv(e,t,n){var i=-1,a=tv,r=e.length,o=!0,s=[],c=s;if(n)o=!1,a=nv;else if(r>=av){var l=t?null:iv(e);if(l)return ra(l);o=!1,a=ea,c=new Xi}else c=t?[]:s;e:for(;++i<r;){var d=e[i],u=t?t(d):d;if(d=n||0!==d?d:0,o&&u==u){for(var h=c.length;h--;)if(c[h]===u)continue e;t&&c.push(u),s.push(d)}else a(c,u,n)||(c!==s&&c.push(u),s.push(d))}return s}const ov=(e,t)=>{let n,i;return(e.end.getTime()-e.start.getTime())/1e3<=3600?(n=Gg(e.start),i=Kg(e.end)):(n=Xg(e.start),i=Jg(e.end)),t?.endCap&&(i=function(e){Fm(1,arguments);var t=Zm(e);return t.setSeconds(59,999),t}(sv(i))),{start:n,end:i}},sv=e=>{const t=new Date;return e>t?t:e},cv=e=>{return Rg((n=e=>e.getID()??e,(t=e)&&t.length?rv(t,zg(n)):[]),(e=>e.getStartTime()),"asc");var t,n},lv=e=>e.camera_entity??e.webrtc_card?.entity??null;class dv{constructor(e,t,n){this._entityRegistryManager=e,this._cardWideConfig=n,this._resolvedMediaCache=t}async createEngine(e){let t=null;switch(e){case Qg.Generic:const{GenericCameraManagerEngine:e}=await import("./engine-generic-395b8c68.js");t=new e;break;case Qg.Frigate:const{FrigateCameraManagerEngine:n}=await import("./engine-frigate-2c5e3aa9.js");t=new n(this._cardWideConfig,new Vg,new Zg);break;case Qg.MotionEye:const{MotionEyeCameraManagerEngine:i}=await import("./engine-motioneye-ae70fe08.js");t=new i(new eg(new Hg),this._resolvedMediaCache,new Zg)}return t}async getEngineForCamera(e,t){let n=null;if("frigate"===t.engine)n=Qg.Frigate;else if("motioneye"===t.engine)n=Qg.MotionEye;else if("generic"===t.engine)n=Qg.Generic;else if("auto"===t.engine){const i=lv(t);if(i){let a;try{a=await this._entityRegistryManager.getEntity(e,i)}catch(n){if(e.states[i])return Qg.Generic;throw new Wg(Pm("error.no_camera_entity"),t)}switch(a?.platform){case"frigate":n=Qg.Frigate;break;case"motioneye":n=Qg.MotionEye;break;default:n=Qg.Generic}}else t.frigate.camera_name&&(n=Qg.Frigate)}return n}}function uv(e){return e&&e.length?function(e,t){for(var n,i=-1,a=e.length;++i<a;){var r=t(e[i]);void 0!==r&&(n=void 0===n?r:n+r)}return n}(e,Za):0}const hv=(e,...t)=>{e?.debug?.logging&&console.debug(...t)};function mv(e){return"string"==typeof e?.id&&e.id||"string"==typeof e?.camera_entity&&e.camera_entity||"object"==typeof e?.webrtc_card&&e.webrtc_card&&"string"==typeof e.webrtc_card.entity&&e.webrtc_card.entity||"object"==typeof e?.frigate&&e.frigate&&"string"==typeof e?.frigate.camera_name&&e.frigate.camera_name||""}function pv(e,t){if(!e||!t)return null;const n=e.getStore().getCameras(),i=new Set,a=e=>{const t=n.get(e);if(t){i.add(e);const r=new Set;t.dependencies.cameras.forEach((e=>r.add(e))),t.dependencies.all_cameras&&n.forEach(((e,t)=>r.add(t)));for(const e of r)i.has(e)||a(e)}};return t&&a(t),i}class fv{constructor(){this._allConfigs=new Map,this._visibleConfigs=new Map,this._enginesByCamera=new Map,this._enginesByType=new Map}addCamera(e,t,n){t.hide||this._visibleConfigs.set(e,t),this._allConfigs.set(e,t),this._enginesByCamera.set(e,n),this._enginesByType.set(n.getEngineType(),n)}getCameraConfig(e){return this._allConfigs.get(e)??null}hasCameraID(e){return this._allConfigs.has(e)}hasVisibleCameraID(e){return this._visibleConfigs.has(e)}getCameraCount(){return this._allConfigs.size}getVisibleCameraCount(){return this._visibleConfigs.size}getCameras(){return this._allConfigs}getVisibleCameras(){return this._visibleConfigs}getCameraIDs(){return new Set(this._allConfigs.keys())}getVisibleCameraIDs(){return new Set(this._visibleConfigs.keys())}getCameraConfigForMedia(e){const t=e.getCameraID();return t?this.getCameraConfig(t):null}getEngineOfType(e){return this._enginesByType.get(e)??null}getEngineForCameraID(e){return this._enginesByCamera.get(e)??null}getEnginesForCameraIDs(e){const t=new Map;for(const n of e){const e=this.getEngineForCameraID(n);e&&(t.has(e)||t.set(e,new Set),t.get(e)?.add(n))}return t.size?t:null}getEngineForMedia(e){const t=e.getCameraID();return t?this.getEngineForCameraID(t):null}getAllEngines(){return[...this._enginesByType.values()]}}class gv{static isEventQuery(e){return e.type===Bg.Event}static isRecordingQuery(e){return e.type===Bg.Recording}static isRecordingSegmentsQuery(e){return e.type===Bg.RecordingSegments}static isMediaMetadataQuery(e){return e.type===Bg.MediaMetadata}}class vv{static isEventQueryResult(e){return e.type===Yg.Event}static isRecordingQuery(e){return e.type===Yg.Recording}static isRecordingSegmentsQuery(e){return e.type===Yg.RecordingSegments}static isMediaMetadataQuery(e){return e.type===Yg.MediaMetadata}}class _v{constructor(e,t){this._engineFactory=e,this._cardWideConfig=t,this._store=new fv}async _getEnginesForCameras(e,t){const n=new Map,i=new Map,a=await(async t=>await Vf(t,(t=>this._engineFactory.getEngineForCamera(e,t))))(t);for(const[e,r]of t.entries()){const t=a[e],o=t?i.get(t)??await this._engineFactory.createEngine(t):null;if(!o||!t)throw new Wg(Pm("error.no_camera_engine"),r);i.set(t,o),n.set(r,o)}return n}async _initializeCamera(e,t,n,i){return{inputConfig:i,initializedConfig:await t.initializeCamera(e,n,Gi(i)),engine:t}}async initializeCameras(e,t,n){const i=new Date;n.some((e=>(e=>e.triggers.motion||e.triggers.occupancy)(e)))&&await t.fetchEntityList(e);const a=await this._getEnginesForCameras(e,n);if((await Vf(a.entries(),(async([n,i])=>await this._initializeCamera(e,i,t,n)))).forEach((e=>{const t=mv(e.initializedConfig);if(!t)throw new Wg(Pm("error.no_camera_id"),e.inputConfig);if(this._store.hasCameraID(t))throw new Wg(Pm("error.duplicate_camera_id"),e.inputConfig);this._store.addCamera(t,e.initializedConfig,e.engine)})),!this._store.getVisibleCameraCount())throw new Wg(Pm("error.no_visible_cameras"));hv(this._cardWideConfig,"Frigate Card CameraManager initialized (Cameras: ",this._store.getCameras(),`, Duration: ${((new Date).getTime()-i.getTime())/1e3}s,`,")")}isInitialized(){return this._store.getCameraCount()>0}getStore(){return this._store}generateDefaultEventQueries(e,t){return this._generateDefaultQueries(e,{type:Bg.Event,...t})}generateDefaultRecordingQueries(e,t){return this._generateDefaultQueries(e,{type:Bg.Recording,...t})}generateDefaultRecordingSegmentsQueries(e,t){return this._generateDefaultQueries(e,{type:Bg.RecordingSegments,...t})}async getMediaMetadata(e){const t=new Set,n=new Set,i=new Set,a=new Set,r={type:Bg.MediaMetadata,cameraIDs:this._store.getCameraIDs()},o=await this._handleQuery(e,r);for(const e of o?.values()??[])e.metadata.tags&&e.metadata.tags.forEach(t.add,t),e.metadata.what&&e.metadata.what.forEach(n.add,n),e.metadata.where&&e.metadata.where.forEach(i.add,i),e.metadata.days&&e.metadata.days.forEach(a.add,a);return n.size||i.size||a.size?{...t.size&&{tags:t},...n.size&&{what:n},...i.size&&{where:i},...a.size&&{days:a}}:null}_generateDefaultQueries(e,t){const n=[],i=(a=e)instanceof Set?a:new Set(Pf(a));var a;const r=this._store.getEnginesForCameraIDs(i);if(!r)return null;for(const[e,i]of r){let a=null;gv.isEventQuery(t)?a=e.generateDefaultEventQuery(this._store.getVisibleCameras(),i,t):gv.isRecordingQuery(t)?a=e.generateDefaultRecordingQuery(this._store.getVisibleCameras(),i,t):gv.isRecordingSegmentsQuery(t)&&(a=e.generateDefaultRecordingSegmentsQuery(this._store.getVisibleCameras(),i,t));for(const e of a??[])n.push(e)}return n.length?n:null}async getEvents(e,t,n){return await this._handleQuery(e,t,n)}async getRecordings(e,t,n){return await this._handleQuery(e,t,n)}async getRecordingSegments(e,t,n){return await this._handleQuery(e,t,n)}async executeMediaQueries(e,t,n){return this._convertQueryResultsToMedia(e,await this._handleQuery(e,t,n))}async extendMediaQueries(e,t,n,i,a){const r=e=>{let t=null;for(const i of n){const n=i.getStartTime();n&&(!t||"earliest"===e&&n<t||"latest"===e&&n>t)&&(t=n)}return t},o=this._cardWideConfig?.performance?.features.media_chunk_size??50,s=[],c=[];for(const e of t){const t={...e};if("later"===i){const e=r("latest");e&&(t.start=e)}else if("earlier"===i){const e=r("earliest");e&&(t.end=e)}t.limit=o,c.push({...e,limit:(e.limit??0)+o}),s.push(t)}const l=this._convertQueryResultsToMedia(e,await this._handleQuery(e,s,a));if(!l.length)return null;const d=cv(n.concat(l));return d.length===n.length?null:{queries:c,results:d}}async getMediaDownloadPath(e,t){const n=this._store.getCameraConfigForMedia(t),i=this._store.getEngineForMedia(t);return n&&i?await i.getMediaDownloadPath(e,n,t):null}getMediaCapabilities(e){const t=this._store.getEngineForMedia(e);return t?t.getMediaCapabilities(e):null}async favoriteMedia(e,t,n){const i=this._store.getCameraConfigForMedia(t),a=this._store.getEngineForMedia(t);if(!i||!a)return;const r=new Date;await a.favoriteMedia(e,i,t,n),hv(this._cardWideConfig,"Frigate Card CameraManager favorite request (",`Duration: ${((new Date).getTime()-r.getTime())/1e3}s,`,"Media:",t.getID(),", Favorite:",n,")")}areMediaQueriesResultsFresh(e,t){const n=new Date;for(const i of e){const e=this._store.getEnginesForCameraIDs(i.cameraIDs);for(const[a,r]of e??[]){const e=a.getQueryResultMaxAge({...i,cameraIDs:r});if(null!==e&&Bm(t,{seconds:e})<n)return!1}}return!0}async getMediaSeekTime(e,t,n){const i=t.getStartTime(),a=t.getEndTime(),r=this._store.getCameraConfigForMedia(t),o=this._store.getEngineForMedia(t);return!r||!o||!i||!a||n<i||n>a?null:await o.getMediaSeekTime(e,this._store.getCameras(),t,n)}async _handleQuery(e,t,n){const i=Pf(t),a=new Map,r=new Date,o=async(t,i)=>{if(!i)return;let r=null;gv.isEventQuery(i)?r=await t.getEvents(e,this._store.getCameras(),i,n):gv.isRecordingQuery(i)?r=await t.getRecordings(e,this._store.getCameras(),i,n):gv.isRecordingSegmentsQuery(i)?r=await t.getRecordingSegments(e,this._store.getCameras(),i,n):gv.isMediaMetadataQuery(i)&&(r=await t.getMediaMetadata(e,this._store.getCameras(),i,n)),r?.forEach(((e,t)=>a.set(t,e)))},s=async e=>{const t=this._store.getEnginesForCameraIDs(e.cameraIDs);t&&await Promise.all(Array.from(t.keys()).map((n=>o(n,{...e,cameraIDs:t.get(n)}))))};await Promise.all(i.map((e=>s(e))));const c=uv(Array.from(a.values()).map((e=>Number(e.cached??0))));return hv(this._cardWideConfig,"Frigate Card CameraManager request [Input queries:",i.length,", Cached output queries:",c,", Total output queries:",a.size,", Duration:",((new Date).getTime()-r.getTime())/1e3+"s,",", Queries:",i,", Results:",a,"]"),a}_convertQueryResultsToMedia(e,t){const n=[];for(const[i,a]of t.entries()){const t=this._store.getEngineOfType(a.engine);if(t){let r=null;gv.isEventQuery(i)&&vv.isEventQueryResult(a)?r=t.generateMediaFromEvents(e,this._store.getCameras(),i,a):gv.isRecordingQuery(i)&&vv.isRecordingQuery(a)&&(r=t.generateMediaFromRecordings(e,this._store.getCameras(),i,a)),r&&n.push(...r)}}return cv(n)}getCameraEndpoints(e,t){const n=this._store.getCameraConfig(e),i=this._store.getEngineForCameraID(e);return n&&i?i.getCameraEndpoints(n,t):null}getCameraMetadata(e,t){const n=this._store.getCameraConfig(t),i=this._store.getEngineForCameraID(t);return n&&i?i.getCameraMetadata(e,n):null}getCameraCapabilities(e){const t=this._store.getCameraConfig(e),n=this._store.getEngineForCameraID(e);return t&&n?n.getCameraCapabilities(t):null}getAggregateCameraCapabilities(e){const t=[...e??this._store.getCameraIDs()].map((e=>this.getCameraCapabilities(e)));return{canFavoriteEvents:t.some((e=>e?.canFavoriteEvents)),canFavoriteRecordings:t.some((e=>e?.canFavoriteRecordings)),canSeek:t.some((e=>e?.canSeek)),supportsClips:t.some((e=>e?.supportsClips)),supportsRecordings:t.some((e=>e?.supportsRecordings)),supportsSnapshots:t.some((e=>e?.supportsSnapshots)),supportsTimeline:t.some((e=>e?.supportsTimeline))}}}var yv='.dotdotdot:after {\n  animation: dots 2s linear infinite;\n  content: "";\n  display: inline-block;\n  width: 3em;\n}\n@keyframes dots {\n  0%, 20% {\n    content: ".";\n  }\n  40% {\n    content: "..";\n  }\n  60% {\n    content: "...";\n  }\n  90%, 100% {\n    content: "";\n  }\n}\n\n:host {\n  display: block;\n  height: 100%;\n  width: 100%;\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n  user-select: text;\n  -webkit-user-select: text;\n  color: var(--primary-text-color);\n}\n\ndiv.wrapper {\n  height: 100%;\n}\n\ndiv.message {\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  box-sizing: border-box;\n  height: 100%;\n}\n\ndiv.message.padded {\n  padding: 20px;\n}\n\ndiv.message div.contents {\n  display: flex;\n  flex-direction: column;\n  padding: 10px;\n  margin-top: auto;\n  margin-bottom: auto;\n  min-width: 0;\n}\n\ndiv.message div.icon {\n  padding: 10px;\n}\n\n.vertical {\n  flex-direction: column;\n}\n\n.message a {\n  color: var(--primary-text-color, white);\n  word-break: break-word;\n}\n\n.message pre {\n  margin-top: 20px;\n  white-space: pre-wrap;\n  word-break: break-all;\n}';let bv=class extends ge{constructor(){super(...arguments),this.message=""}render(){const e=this.icon?this.icon:"mdi:information-outline",t={dotdotdot:!!this.dotdotdot};return K` <div class="wrapper">
      <div class="message padded">
        <div class="icon">
          <ha-icon icon="${e}"> </ha-icon>
        </div>
        <div class="contents">
          <span class="${Ee(t)}">
            ${this.message?K`${this.message}${this.context&&"string"==typeof this.context?": "+this.context:""}`:""}
          </span>
          ${this.context&&"string"!=typeof this.context?K`<pre>${JSON.stringify(this.context,null,2)}</pre>`:""}
        </div>
      </div>
    </div>`}static get styles(){return b(yv)}};e([be({attribute:!1})],bv.prototype,"message",void 0),e([be({attribute:!1})],bv.prototype,"context",void 0),e([be({attribute:!1})],bv.prototype,"icon",void 0),e([be({attribute:!0,type:Boolean})],bv.prototype,"dotdotdot",void 0),bv=e([_e("frigate-card-message")],bv);let wv=class extends ge{render(){if(this.message)return K` <frigate-card-message
      .message=${K` ${this.message.message}.
        <a href="${Ys}"> ${Pm("error.troubleshooting")}</a>.`}
      .icon=${"mdi:alert-circle"}
      .context=${this.message.context}
      .dotdotdot=${this.message.dotdotdot}
    >
    </frigate-card-message>`}static get styles(){return b(yv)}};e([be({attribute:!1})],wv.prototype,"message",void 0),wv=e([_e("frigate-card-error-message")],wv);let xv=class extends ge{constructor(){super(...arguments),this.message="",this.animated=!1,this.size="large"}render(){return K` <div class="message vertical">
      ${this.animated?K`<ha-circular-progress active="true" size="${this.size}">
          </ha-circular-progress>`:K`<ha-icon icon="mdi:timer-sand"></ha-icon>`}
      ${this.message?K`<span>${this.message}</span>`:K``}
    </div>`}static get styles(){return b(yv)}};function Cv(e){return"error"===e.type?K` <frigate-card-error-message
      .message=${e}
    ></frigate-card-error-message>`:K` <frigate-card-message
      .message=${e.message}
      .icon=${e.icon}
      .context=${e.context}
      .dotdotdot=${e.dotdotdot}
    ></frigate-card-message>`}function $v(e){return K`
    <frigate-card-progress-indicator
      class="${Ee(e?.classes??{})}"
      .size=${e?.size}
      ${e?.componentRef?Fe(e.componentRef):""}
      .message=${e?.message||""}
      .animated=${e?.cardWideConfig?.performance?.features.animated_progress_indicator??!0}
    >
    </frigate-card-progress-indicator>
  `}function kv(e,t,n,i){If(e,"message",{message:t,type:n,icon:i?.icon,context:i?.context})}function Ev(e,t,n){kv(e,t,"error",{context:n?.context})}function Mv(e,t){t instanceof Error&&Ev(e,t.message,{...t instanceof vu&&{context:t.context}})}function Sv(e,t,n){return null==e?e:function(e,t,n,i){if(!ot(e))return e;for(var a=-1,r=(t=gg(t,e)).length,o=r-1,s=e;null!=s&&++a<r;){var c=_g(t[a]),l=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(a!=o){var d=s[c];void 0===(l=i?i(d,c,s):void 0)&&(l=ot(d)?d:tn(t[a+1])?[]:{})}Nt(s,c,l),s=s[c]}return e}(e,t,n)}e([be({attribute:!1})],xv.prototype,"message",void 0),e([be({attribute:!1})],xv.prototype,"animated",void 0),e([be({attribute:!1})],xv.prototype,"size",void 0),xv=e([_e("frigate-card-progress-indicator")],xv);const Tv=(e,t,n)=>{Sv(e,t,n)},Av=(e,t,n)=>kg(e,t,n),zv=(e,t)=>{let n=t,i=e;if(t&&t.split&&t.includes(".")){const a=t.split(".");n=a[a.length-1],i=Av(e,a.slice(0,-1).join("."))}i&&"object"==typeof i&&delete i[n]},jv=function(e){let t=!1;for(let n=0;n<Qv.length;n++)t=Qv[n](e)||t;return t},Ov=function(e){return jv(Iv(e))},Iv=e=>Gi(e),Rv=function(e,t,n){return i=>{let a=e(i);return"number"!=typeof a||(a=t?Math.max(t,a):a,a=n?Math.min(n,a):a),a}},Dv=function(e){if("number"!=typeof e)return"string"!=typeof e?null:(e=e.replace(/px$/i,""),isNaN(e)?null:Number(e))},Pv=function(e){return null},Lv=(e,t)=>e.replace("#",`[${t.toString()}]`),Nv=function(e,t,n){return function(i){return((e,t,n,i)=>{const a=Av(e,t);if(void 0===a)return!1;const r=i?.transform?i.transform(a):a;return!(t===n&&Aa(a,r)||(null===r?i?.keepOriginal||(zv(e,t),0):void 0===r||(i?.keepOriginal||zv(e,t),Tv(e,n,r),0)))})(i,e,t,n)}},Uv=function(e,t,n){return function(i){let a=Nv(e,t,n)(i);return a=Zv(Yd,Nv(e,t,n),(e=>e.overrides))(i)||a,a}},Fv=function(e,t){return Uv(e,e,{transform:t})},Hv=function(e,t){return Nv(e,e,{transform:t})},Zv=function(e,t,n){return function(i){let a=!1;const r=Av(i,e);return Array.isArray(r)&&r.forEach((e=>{const i=n?n(e):e;i&&"object"==typeof i&&(a=t(i)||a)})),a}},qv=function(e){if("object"!=typeof e)return"boolean"!=typeof e?null:{enabled:e}},Vv=e=>{const t=`${e}.show_controls`;return function(n){let i=!1;return i=Uv(t,`${e}.show_favorite_control`,{keepOriginal:!0})(n)||i,i=Uv(t,`${e}.show_timeline_control`,{keepOriginal:!0})(n)||i,Fv(t,Pv)(n)||i}},Wv=(e,t)=>{const n=i=>{let a=!1;if(i&&"object"==typeof i){const r=t?t(i):i;r&&(a=e(r)||a),Array.isArray(i)?i.filter((e=>"object"==typeof e)).forEach((e=>{a=n(e)||a})):Object.keys(i).filter((e=>"object"==typeof i[e])).forEach((e=>{a=n(i[e])||a}))}return a};return n},Bv=e=>!("object"!=typeof e||!e||void 0===e.mediaLoaded)&&(e.media_loaded=e.mediaLoaded,delete e.mediaLoaded,!0),Yv=e=>!("object"!=typeof e||!e||"custom:frigate-card-action"!==e.action||"frigate_ui"!==e.frigate_card_action)&&(e.frigate_card_action="camera_ui",!0),Qv=[Fv(Rl,Rv(Dv,75,cu)),Fv("event_viewer.controls.thumbnails.size",Rv(Dv,75,cu)),Fv(jl,Rv(Dv,su)),Fv("event_viewer.controls.next_previous.size",Rv(Dv,su)),Fv(Ad,Rv(Dv,su)),Fv("event_gallery.min_columns",Pv),function(e){let t=!1;return t=Uv("menu.mode",Td,{transform:e=>{if("string"==typeof e){const t=e.match(/^(hover|hidden|overlay|above|below|none)/);if(t)switch(t[1]){case"hover":case"hidden":case"overlay":case"none":return t[1];case"above":case"below":return"outside"}}},keepOriginal:!0})(e)||t,t=Uv("menu.mode",Sd,{transform:e=>{if("string"==typeof e){const t=e.match(/(above|below|left|right|top|bottom)$/);if(t)switch(t[1]){case"left":case"right":case"top":case"bottom":return t[1];case"above":return"top";case"below":return"bottom"}}},keepOriginal:!0})(e)||t,Fv("menu.mode",Pv)(e)||t},Fv(Rd,qv),Fv(jd,qv),Fv(Nd,qv),Fv(Od,qv),Fv(Fd,qv),Fv(Ld,qv),Fv(Id,qv),Fv("menu.buttons.frigate_ui",qv),Fv(Pd,qv),Hv(Jl,(e=>"boolean"==typeof e?e?"all":"never":void 0)),Hv(Tl,(e=>"boolean"==typeof e?e?"all":"never":void 0)),Hv("event_viewer.auto_play",(e=>"boolean"==typeof e?e?"all":"never":void 0)),Hv("event_viewer.auto_unmute",(e=>"boolean"==typeof e?e?"all":"never":void 0)),Uv("event_viewer",Qc),Zv(Qs,Nv("camera_name","frigate.camera_name")),Zv(Qs,Nv("client_id","frigate.client_id")),Zv(Qs,Nv("label","frigate.label")),Zv(Qs,Nv("frigate_url","frigate.url")),Zv(Qs,Nv("zone","frigate.zone")),Vv("event_gallery.controls.thumbnails"),Vv("media_viewer.controls.thumbnails"),Vv("live.controls.thumbnails"),Vv("timeline.controls.thumbnails"),Zv(Yd,Bv,(e=>e.conditions)),e=>Wv(Bv,(e=>e.conditions))("object"==typeof e&&e?e.elements:{}),Uv("event_gallery",Hc),Uv("menu.buttons.frigate_ui",Dd),e=>Wv(Yv)("object"==typeof e&&e?e:{}),Zv(Qs,Fv("live_provider",(e=>"frigate-jsmpeg"===e?"jsmpeg":e))),Uv("live.image",$c),Uv("live.jsmpeg",kc),Uv("live.webrtc_card",Ec),Zv(Qs,Uv("frigate.zone","frigate.zones",{transform:e=>Pf(e)})),Zv(Qs,Uv("frigate.label","frigate.labels",{transform:e=>Pf(e)}))];class Gv extends Event{constructor(e,t){super("frigate-card:condition:evaluate",t),this.condition=e}}function Kv(e,t,n,i){const a=Iv(t);let r=!1;if(n)for(const t of n)e.evaluateCondition(t.conditions,i)&&(tr(a,t.overrides),r=!0);return r?a:t}class Xv{constructor(e){this._state={},this._epoch=this._createEpoch(),this._stateListeners=[],this._hasHAStateConditions=!1,this._mediaQueries=[],this._mediaQueryTrigger=()=>this._triggerChange(),e&&this._initConditions(e)}addStateListener(e){this._stateListeners.push(e)}removeStateListener(e){this._stateListeners=this._stateListeners.filter((t=>t!=e))}destroy(){this._mediaQueries.forEach((e=>e.removeEventListener("change",this._mediaQueryTrigger))),this._mediaQueries=[]}setState(e){this._state={...this._state,...e},this._triggerChange()}get hasHAStateConditions(){return this._hasHAStateConditions}getEpoch(){return this._epoch}evaluateCondition(e,t){const n={...this._state,...t};let i=!0;if(e.view?.length&&(i&&=!!n?.view&&e.view.includes(n.view)),void 0!==e.fullscreen&&(i&&=void 0!==n.fullscreen&&e.fullscreen==n.fullscreen),void 0!==e.expand&&(i&&=void 0!==n.expand&&e.expand==n.expand),e.camera?.length&&(i&&=!!n.camera&&e.camera.includes(n.camera)),e.state?.length)for(const t of e.state)i&&=!(!n.state||(t.state||t.state_not)&&(!(t.entity in n.state)||t.state&&n.state[t.entity].state!==t.state||t.state_not&&n.state[t.entity].state===t.state_not));return void 0!==e.media_loaded&&(i&&=void 0!==n.media_loaded&&e.media_loaded==n.media_loaded),e.media_query&&(i&&=window.matchMedia(e.media_query).matches),i}_createEpoch(){return{controller:this}}_triggerChange(){this._epoch=this._createEpoch(),this._stateListeners.forEach((e=>e()))}_initConditions(e){const t=(e=>{const t=[];e.overrides?.forEach((e=>t.push(e.conditions)));const n=e=>{const i=uh.safeParse(e);i.success?(t.push(i.data.conditions),i.data.elements?.forEach(n)):e&&"object"==typeof e&&Object.keys(e).forEach((t=>n(e[t])))};return e.elements?.forEach(n),t})(e);this._hasHAStateConditions=t.some((e=>!!e.state?.length)),t.forEach((e=>{if(e.media_query){const t=window.matchMedia(e.media_query);t.addEventListener("change",this._mediaQueryTrigger),this._mediaQueries.push(t)}}))}}let Jv=class extends ge{constructor(){super(...arguments),this._root=null}createRenderRoot(){return this}_createRoot(){const e=customElements.get("hui-conditional-element");if(!e||!this.hass)throw new Error(Pm("error.could_not_render_elements"));const t=new e;t.hass=this.hass;const n={type:"conditional",conditions:[],elements:this.elements};try{t.setConfig(n)}catch(e){throw console.error(e),new vu(Pm("error.invalid_elements_config"))}return t}willUpdate(e){try{!this.elements||this._root&&!e.has("elements")||(this._root=this._createRoot())}catch(e){return Mv(this,e)}}render(){return K`${this._root||""}`}updated(){this.hass&&this._root&&(this._root.hass=this.hass)}};e([be({attribute:!1})],Jv.prototype,"elements",void 0),e([be({attribute:!1})],Jv.prototype,"conditionControllerEpoch",void 0),e([be({attribute:!1})],Jv.prototype,"hass",void 0),Jv=e([_e("frigate-card-elements-core")],Jv);let e_=class extends ge{constructor(){super(...arguments),this._boundMenuRemoveHandler=this._menuRemoveHandler.bind(this)}_menuRemoveHandler(e){If(this,"menu-remove",e.detail)}_menuAddHandler(e){const t=e.composedPath();t.length&&(t[0].removeEventListener("frigate-card:menu-remove",this._boundMenuRemoveHandler),t[0].addEventListener("frigate-card:menu-remove",this._boundMenuRemoveHandler))}connectedCallback(){super.connectedCallback(),this.addEventListener("frigate-card:menu-add",this._menuAddHandler)}disconnectedCallback(){this.removeEventListener("frigate-card:menu-add",this._menuAddHandler),super.disconnectedCallback()}render(){return K`<frigate-card-elements-core
      .hass=${this.hass}
      .conditionControllerEpoch=${this.conditionControllerEpoch}
      .elements=${this.elements}
    >
    </frigate-card-elements-core>`}static get styles(){return b(":host {\n  position: absolute;\n  inset: 0;\n  overflow: hidden;\n  pointer-events: none;\n}\n\n.element {\n  position: absolute;\n  transform: translate(-50%, -50%);\n  pointer-events: auto;\n}\n\nhui-error-card.element {\n  inset: 0px;\n  transform: unset;\n}")}};e([be({attribute:!1})],e_.prototype,"hass",void 0),e([be({attribute:!1})],e_.prototype,"conditionControllerEpoch",void 0),e([be({attribute:!1})],e_.prototype,"elements",void 0),e_=e([_e("frigate-card-elements")],e_);let t_=class extends ge{setConfig(e){this._config=e}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.className=""}render(){if(function(e,t){if(!t)return!0;const n=new Gv(t,{bubbles:!0,composed:!0});return e.dispatchEvent(n),n.evaluation??!1}(this,this._config.conditions))return K` <frigate-card-elements-core
        .hass=${this.hass}
        .elements=${this._config.elements}
      >
      </frigate-card-elements-core>`}};e([be({attribute:!1,hasChanged:()=>!0})],t_.prototype,"hass",void 0),t_=e([_e("frigate-card-conditional")],t_);class n_ extends ge{constructor(){super(...arguments),this._config=null}setConfig(e){this._config=e}connectedCallback(){super.connectedCallback(),this._config&&If(this,"menu-add",this._config)}disconnectedCallback(){this._config&&If(this,"menu-remove",this._config),super.disconnectedCallback()}}e([we()],n_.prototype,"_config",void 0);let i_=class extends n_{};i_=e([_e("frigate-card-menu-icon")],i_);let a_=class extends n_{};a_=e([_e("frigate-card-menu-state-icon")],a_);let r_=class extends n_{};r_=e([_e("frigate-card-menu-submenu")],r_);let o_=class extends n_{};o_=e([_e("frigate-card-menu-submenu-select")],o_);let s_=class extends ge{constructor(){super(...arguments),this._config=null}setConfig(e){this._config=e}willUpdate(e){e.has("_config")&&this.setAttribute("data-orientation",this._config?.orientation??"vertical")}_actionHandler(e,t){e.stopPropagation();const n=e.detail.action,i=mm(n,t);t&&i&&this.hass&&pm(this,this.hass,t,n,i)}render(){if(!this._config)return;const e=(e,t,n)=>{const i=gm(n?.hold_action),a=gm(n?.double_tap_action);return K`<ha-icon
        class=${Ee({[e]:!0,disabled:!n})}
        icon=${t}
        .actionHandler=${wm({hasHold:i,hasDoubleClick:a})}
        .title=${Pm(`elements.ptz.${e}`)}
        @action=${e=>this._actionHandler(e,n)}
      ></ha-icon>`};return K` <div class="ptz">
      <div class="ptz-move">
        ${e("right","mdi:arrow-right",this._config.actions_right)}
        ${e("left","mdi:arrow-left",this._config.actions_left)}
        ${e("up","mdi:arrow-up",this._config.actions_up)}
        ${e("down","mdi:arrow-down",this._config.actions_down)}
      </div>
      ${this._config.actions_zoom_in||this._config.actions_zoom_out?K` <div class="ptz-zoom">
            ${e("zoom_in","mdi:plus",this._config.actions_zoom_in)}
            ${e("zoom_out","mdi:minus",this._config.actions_zoom_out)}
          </div>`:K``}
      ${this._config.actions_home?K`
            <div class="ptz-home">
              ${e("home","mdi:home",this._config.actions_home)}
            </div>
          `:K``}
    </div>`}static get styles(){return b(":host {\n  position: relative;\n  width: fit-content;\n  height: fit-content;\n  --frigate-card-ptz-icon-size: 24px;\n}\n\n/*****************\n * Main Containers\n *****************/\n.ptz {\n  display: flex;\n  gap: 10px;\n  color: var(--light-primary-color);\n  opacity: 0.4;\n  transition: opacity 0.3s ease-in-out;\n}\n\n:host([data-orientation=vertical]) .ptz {\n  flex-direction: column;\n}\n\n:host([data-orientation=horizontal]) .ptz {\n  flex-direction: row;\n}\n\n.ptz:hover {\n  opacity: 1;\n}\n\n:host([data-orientation=vertical]) .ptz div {\n  width: calc(var(--frigate-card-ptz-icon-size) * 3);\n}\n\n:host([data-orientation=horizontal]) .ptz div {\n  height: calc(var(--frigate-card-ptz-icon-size) * 3);\n}\n\n.ptz-move,\n.ptz-zoom,\n.ptz-home {\n  position: relative;\n  background-color: rgba(0, 0, 0, 0.3);\n}\n\n.ptz-move {\n  height: calc(var(--frigate-card-ptz-icon-size) * 3);\n  width: calc(var(--frigate-card-ptz-icon-size) * 3);\n  border-radius: 50%;\n}\n\n:host([data-orientation=horizontal]) .ptz .ptz-zoom,\n:host([data-orientation=horizontal]) .ptz .ptz-home {\n  width: calc(var(--frigate-card-ptz-icon-size) * 1.5);\n}\n\n:host([data-orientation=vertical]) .ptz .ptz-zoom,\n:host([data-orientation=vertical]) .ptz .ptz-home {\n  height: calc(var(--frigate-card-ptz-icon-size) * 1.5);\n}\n\n.ptz-zoom,\n.ptz-home {\n  border-radius: var(--ha-card-border-radius, 4px);\n}\n\n/***********\n * PTZ Icons\n ***********/\nha-icon {\n  position: absolute;\n  --mdc-icon-size: var(--frigate-card-ptz-icon-size);\n}\n\nha-icon:not(.disabled) {\n  cursor: pointer;\n}\n\n.disabled {\n  color: var(--disabled-text-color);\n}\n\n.up {\n  top: 5px;\n  left: 50%;\n  transform: translateX(-50%);\n}\n\n.down {\n  bottom: 5px;\n  left: 50%;\n  transform: translateX(-50%);\n}\n\n.left {\n  left: 5px;\n  top: 50%;\n  transform: translateY(-50%);\n}\n\n.right {\n  right: 5px;\n  top: 50%;\n  transform: translateY(-50%);\n}\n\n:host([data-orientation=vertical]) .zoom_in {\n  right: 5px;\n  top: 50%;\n}\n\n:host([data-orientation=vertical]) .zoom_out {\n  left: 5px;\n  top: 50%;\n}\n\n:host([data-orientation=horizontal]) .zoom_in {\n  left: 50%;\n  top: 5px;\n}\n\n:host([data-orientation=horizontal]) .zoom_out {\n  left: 50%;\n  bottom: 5px;\n}\n\n:host([data-orientation=vertical]) .zoom_in,\n:host([data-orientation=vertical]) .zoom_out {\n  transform: translateY(-50%);\n}\n\n:host([data-orientation=horizontal]) .zoom_in,\n:host([data-orientation=horizontal]) .zoom_out {\n  transform: translateX(-50%);\n}\n\n.home {\n  top: 50%;\n  left: 50%;\n  transform: translateX(-50%) translateY(-50%);\n}")}};e([be({attribute:!1})],s_.prototype,"hass",void 0),e([we()],s_.prototype,"_config",void 0),s_=e([_e("frigate-card-ptz")],s_);
/**
 * @license
 * Copyright 2018 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const c_=e=>null!=e?e:J;const l_="m 4.8759466,22.743573 c 0.0866,0.69274 0.811811,1.16359 0.37885,1.27183 -0.43297,0.10824 -2.32718,-3.43665 -2.7601492,-4.95202 -0.4329602,-1.51538 -0.6764993,-3.22017 -0.5682593,-4.19434 0.1082301,-0.97417 5.7097085,-2.48955 5.7097085,-2.89545 0,-0.4059 -1.81304,-0.0271 -1.89422,-0.35178 -0.0812,-0.32472 1.36925,-0.12989 1.75892,-0.64945 0.60885,-0.81181 1.3800713,-0.6765 1.8671505,-1.1094696 0.4870902,-0.4329599 1.0824089,-2.0836399 1.1906589,-2.7871996 0.108241,-0.70357 -1.0824084,-1.51538 -1.4071389,-2.05658 -0.3247195,-0.54121 0.7035702,-0.92005 3.1931099,-1.94834 2.48954,-1.02829 10.39114,-3.30134994 10.49938,-3.03074994 0.10824,0.27061 -2.59779,1.40713994 -4.492,2.11069994 -1.89422,0.70357 -4.97909,2.05658 -4.97909,2.43542 0,0.37885 0.16236,0.67651 0.0541,1.54244 -0.10824,0.86593 -0.12123,1.2702597 -0.32472,1.8400997 -0.1353,0.37884 -0.2706,1.27183 0,2.0836295 0.21648,0.64945 0.92005,1.13653 1.24477,1.24478 0.2706,0.018 1.01746,0.0433 1.8401,0 1.02829,-0.0541 2.48954,0.0541 2.48954,0.32472 0,0.2706 -2.21894,0.10824 -2.21894,0.48708 0,0.37885 2.27306,-0.0541 2.21894,0.32473 -0.0541,0.37884 -1.89422,0.21648 -2.86839,0.21648 -0.77933,0 -1.93031,-0.0361 -2.43542,-0.21648 l -0.10824,0.37884 c -0.18038,0 -0.55744,0.10824 -0.94711,0.10824 -0.48708,0 -0.51414,0.16236 -1.40713,0.16236 -0.892989,0 -0.622391,-0.0541 -1.4341894,-0.10824 -0.81181,-0.0541 -3.842561,2.27306 -4.383761,3.03075 -0.54121,0.75768 -0.21649,2.59778 -0.21649,3.43665 0,0.75379 -0.10824,2.43542 0,3.30135 z";const d_=(e,t,n)=>{const i=e.states[t],a=n?.state?n.state:i?i.state:null;if(!a)return null;const r=s(t),o=i?i.attributes:null;return n?.entity?.translation_key&&e.localize(`component.${n.entity.platform}.entity.${r}.${n.entity.translation_key}.state.${a}`)||o?.device_class&&e.localize(`component.${r}.state.${o.device_class}.${a}`)||e.localize(`component.${r}.state._.${a}`)||a};let u_=class extends ge{_renderItem(e){if(!this.hass)return;const t=gp(this.hass,{...e});return K`
      <mwc-list-item
        style="${He(t.style||{})}"
        graphic=${c_(t.icon?"icon":void 0)}
        ?twoline=${!!e.subtitle}
        ?selected=${e.selected}
        ?activated=${e.selected}
        ?disabled=${!1===e.enabled}
        aria-label="${t.title||""}"
        @action=${t=>{t.detail.config=e}}
        .actionHandler=${wm({hasHold:gm(e.hold_action),hasDoubleClick:gm(e.double_tap_action)})}
      >
        <span>${t.title||""}</span>
        ${e.subtitle?K`<span slot="secondary">${e.subtitle}</span>`:""}
        ${(e=>e.icon?K` <ha-icon
          style="${He(e.style||{})}"
          data-domain=${c_(e.data_domain)}
          data-state=${c_(e.data_state)}
          slot="graphic"
          icon="${e.icon||""}"
        >
        </ha-icon>`:K``)(t)}
      </mwc-list-item>
    `}render(){return this.submenu?K`
      <ha-button-menu
        corner=${"BOTTOM_LEFT"}
        @closed=${e=>e.stopPropagation()}
        @click=${e=>vm(e)}
      >
        <ha-icon-button
          style="${He(this.submenu.style||{})}"
          class="button"
          slot="trigger"
          .label=${this.submenu.title||""}
          .actionHandler=${wm({allowPropagation:!0,hasHold:gm(this.submenu.hold_action),hasDoubleClick:gm(this.submenu.double_tap_action)})}
        >
          <ha-icon icon="${this.submenu.icon}"></ha-icon>
        </ha-icon-button>
        ${this.submenu.items.map(this._renderItem.bind(this))}
      </ha-button-menu>
    `:K``}static get styles(){return b("ha-icon-button.button {\n  color: var(--secondary-color, white);\n  background-color: rgba(0, 0, 0, 0.6);\n  border-radius: 50%;\n  padding: 0px;\n  margin: 3px;\n  --ha-icon-display: block;\n  /* Buttons can always be clicked */\n  pointer-events: auto;\n  opacity: 0.9;\n}\n\n@keyframes pulse {\n  0% {\n    opacity: 1;\n  }\n  50% {\n    opacity: 0.6;\n  }\n  100% {\n    opacity: 1;\n  }\n}\nha-icon[data-domain=alert][data-state=on],\nha-icon[data-domain=automation][data-state=on],\nha-icon[data-domain=binary_sensor][data-state=on],\nha-icon[data-domain=calendar][data-state=on],\nha-icon[data-domain=camera][data-state=streaming],\nha-icon[data-domain=cover][data-state=open],\nha-icon[data-domain=fan][data-state=on],\nha-icon[data-domain=humidifier][data-state=on],\nha-icon[data-domain=light][data-state=on],\nha-icon[data-domain=input_boolean][data-state=on],\nha-icon[data-domain=lock][data-state=unlocked],\nha-icon[data-domain=media_player][data-state=on],\nha-icon[data-domain=media_player][data-state=paused],\nha-icon[data-domain=media_player][data-state=playing],\nha-icon[data-domain=script][data-state=on],\nha-icon[data-domain=sun][data-state=above_horizon],\nha-icon[data-domain=switch][data-state=on],\nha-icon[data-domain=timer][data-state=active],\nha-icon[data-domain=vacuum][data-state=cleaning],\nha-icon[data-domain=group][data-state=on],\nha-icon[data-domain=group][data-state=home],\nha-icon[data-domain=group][data-state=open],\nha-icon[data-domain=group][data-state=locked],\nha-icon[data-domain=group][data-state=problem] {\n  color: var(--paper-item-icon-active-color, #fdd835);\n}\n\nha-icon[data-domain=climate][data-state=cooling] {\n  color: var(--cool-color, var(--state-climate-cool-color));\n}\n\nha-icon[data-domain=climate][data-state=heating] {\n  color: var(--heat-color, var(--state-climate-heat-color));\n}\n\nha-icon[data-domain=climate][data-state=drying] {\n  color: var(--dry-color, var(--state-climate-dry-color));\n}\n\nha-icon[data-domain=alarm_control_panel] {\n  color: var(--alarm-color-armed, var(--label-badge-red));\n}\n\nha-icon[data-domain=alarm_control_panel][data-state=disarmed] {\n  color: var(--alarm-color-disarmed, var(--label-badge-green));\n}\n\nha-icon[data-domain=alarm_control_panel][data-state=pending],\nha-icon[data-domain=alarm_control_panel][data-state=arming] {\n  color: var(--alarm-color-pending, var(--label-badge-yellow));\n  animation: pulse 1s infinite;\n}\n\nha-icon[data-domain=alarm_control_panel][data-state=triggered] {\n  color: var(--alarm-color-triggered, var(--label-badge-red));\n  animation: pulse 1s infinite;\n}\n\nha-icon[data-domain=plant][data-state=problem],\nha-icon[data-domain=zwave][data-state=dead] {\n  color: var(--state-icon-error-color);\n}\n\n/* Color the icon if unavailable */\nha-icon[data-state=unavailable] {\n  color: var(--state-unavailable-color);\n}\n\nha-icon-button[data-domain=alert][data-state=on],\nha-icon-button[data-domain=automation][data-state=on],\nha-icon-button[data-domain=binary_sensor][data-state=on],\nha-icon-button[data-domain=calendar][data-state=on],\nha-icon-button[data-domain=camera][data-state=streaming],\nha-icon-button[data-domain=cover][data-state=open],\nha-icon-button[data-domain=fan][data-state=on],\nha-icon-button[data-domain=humidifier][data-state=on],\nha-icon-button[data-domain=light][data-state=on],\nha-icon-button[data-domain=input_boolean][data-state=on],\nha-icon-button[data-domain=lock][data-state=unlocked],\nha-icon-button[data-domain=media_player][data-state=on],\nha-icon-button[data-domain=media_player][data-state=paused],\nha-icon-button[data-domain=media_player][data-state=playing],\nha-icon-button[data-domain=script][data-state=on],\nha-icon-button[data-domain=sun][data-state=above_horizon],\nha-icon-button[data-domain=switch][data-state=on],\nha-icon-button[data-domain=timer][data-state=active],\nha-icon-button[data-domain=vacuum][data-state=cleaning],\nha-icon-button[data-domain=group][data-state=on],\nha-icon-button[data-domain=group][data-state=home],\nha-icon-button[data-domain=group][data-state=open],\nha-icon-button[data-domain=group][data-state=locked],\nha-icon-button[data-domain=group][data-state=problem] {\n  color: var(--paper-item-icon-active-color, #fdd835);\n}\n\nha-icon-button[data-domain=climate][data-state=cooling] {\n  color: var(--cool-color, var(--state-climate-cool-color));\n}\n\nha-icon-button[data-domain=climate][data-state=heating] {\n  color: var(--heat-color, var(--state-climate-heat-color));\n}\n\nha-icon-button[data-domain=climate][data-state=drying] {\n  color: var(--dry-color, var(--state-climate-dry-color));\n}\n\nha-icon-button[data-domain=alarm_control_panel] {\n  color: var(--alarm-color-armed, var(--label-badge-red));\n}\n\nha-icon-button[data-domain=alarm_control_panel][data-state=disarmed] {\n  color: var(--alarm-color-disarmed, var(--label-badge-green));\n}\n\nha-icon-button[data-domain=alarm_control_panel][data-state=pending],\nha-icon-button[data-domain=alarm_control_panel][data-state=arming] {\n  color: var(--alarm-color-pending, var(--label-badge-yellow));\n  animation: pulse 1s infinite;\n}\n\nha-icon-button[data-domain=alarm_control_panel][data-state=triggered] {\n  color: var(--alarm-color-triggered, var(--label-badge-red));\n  animation: pulse 1s infinite;\n}\n\nha-icon-button[data-domain=plant][data-state=problem],\nha-icon-button[data-domain=zwave][data-state=dead] {\n  color: var(--state-icon-error-color);\n}\n\n/* Color the icon if unavailable */\nha-icon-button[data-state=unavailable] {\n  color: var(--state-unavailable-color);\n}\n\n:host {\n  pointer-events: auto;\n}\n\nmwc-list-item {\n  z-index: 20;\n}")}};e([be({attribute:!1})],u_.prototype,"hass",void 0),e([be({attribute:!1})],u_.prototype,"submenu",void 0),u_=e([_e("frigate-card-submenu")],u_);let h_=class extends ge{shouldUpdate(e){const t=e.get("hass");return!e.has("hass")||!t||!this.submenuSelect||up(this.hass,t,[this.submenuSelect.entity])}async _refreshOptionTitles(){if(!this.hass||!this.submenuSelect)return;const e=this.submenuSelect.entity,t=this.hass.states[e]?.attributes?.options,n=await(this.entityRegistryManager?.getEntity(this.hass,e))??null,i={};for(const a of t){const t=d_(this.hass,e,{...n&&{entity:n},state:a});t&&(i[a]=t)}this._optionTitles=i}willUpdate(){if(!this.submenuSelect||!this.hass)return;this._optionTitles||this._refreshOptionTitles();const e=this.submenuSelect.entity,t=this.hass.states[e],n=t?.attributes?.options;if(!t||!n)return;const i={icon:op("select"),...gp(this.hass,this.submenuSelect),...this.submenuSelect,type:"custom:frigate-card-menu-submenu",items:[]};delete i.options;for(const a of n){const n=this._optionTitles?.[a]??a;i.items.push({state_color:!0,selected:t.state===a,enabled:!0,title:n||a,...(e.startsWith("select.")||e.startsWith("input_select."))&&{tap_action:{action:"call-service",service:e.startsWith("select.")?"select.select_option":"input_select.select_option",service_data:{entity_id:e,option:a}}},...this.submenuSelect.options&&this.submenuSelect.options[a]})}this._generatedSubmenu=i}render(){return K` <frigate-card-submenu
      .hass=${this.hass}
      .submenu=${this._generatedSubmenu}
    ></frigate-card-submenu>`}};var m_;e([be({attribute:!1})],h_.prototype,"hass",void 0),e([be({attribute:!1})],h_.prototype,"submenuSelect",void 0),e([be({attribute:!1})],h_.prototype,"entityRegistryManager",void 0),e([we()],h_.prototype,"_optionTitles",void 0),h_=e([_e("frigate-card-submenu-select")],h_);let p_=m_=class extends ge{constructor(){super(...arguments),this.expanded=!1,this.buttons=[]}set menuConfig(e){this._menuConfig=e,e&&this.style.setProperty("--frigate-card-menu-button-size",`${e.button_size}px`),this.setAttribute("data-style",e.style),this.setAttribute("data-position",e.position),this.setAttribute("data-alignment",e.alignment)}static isHidingMenu(e){return"hidden"===e?.style??!1}toggleMenu(){this._isHidingMenu()&&(this.expanded=!this.expanded)}_isHidingMenu(){return m_.isHidingMenu(this._menuConfig)}_isMenuToggleAction(e){if(!e)return!1;const t=um(e);return!!t&&"menu_toggle"==t.frigate_card_action}_actionHandler(e,t){if(!e)return;e.detail.config&&(t=e.detail.config),e.stopPropagation();const n=e.detail.action;let i=mm(n,t);if(!t||!n)return;let a=!1,r=!1;if(Array.isArray(i)){const e=i.length;i=i.filter((e=>!this._isMenuToggleAction(e))),i.length!=e&&(r=!0),i.length&&(a=pm(this,this.hass,t,n,i))}else this._isMenuToggleAction(i)?r=!0:a=pm(this,this.hass,t,n,i);this._isHidingMenu()&&(r?this.expanded=!this.expanded:a&&(this.expanded=!1))}willUpdate(e){const t=this._menuConfig?.style,n=(e,n)=>{if("hidden"===t){if(e.icon===nu)return-1;if(n.icon===nu)return 1}return void 0===e.priority||void 0!==n.priority&&n.priority>e.priority?1:void 0===n.priority||void 0!==e.priority&&n.priority<e.priority?-1:0};(e.has("_menuConfig")||e.has("buttons"))&&this.buttons.sort(n)}_renderButton(e){if("custom:frigate-card-menu-submenu"===e.type)return K` <frigate-card-submenu
        .hass=${this.hass}
        .submenu=${e}
        @action=${this._actionHandler.bind(this)}
      >
      </frigate-card-submenu>`;if("custom:frigate-card-menu-submenu-select"===e.type)return K` <frigate-card-submenu-select
        .hass=${this.hass}
        .submenuSelect=${e}
        .entityRegistryManager=${this.entityRegistryManager}
        @action=${this._actionHandler.bind(this)}
      >
      </frigate-card-submenu-select>`;let t={...e};const n=t.icon===nu?l_:"";this.hass&&"custom:frigate-card-menu-state-icon"===e.type&&(t=gp(this.hass,t));const i=gm(e.hold_action),a=gm(e.double_tap_action);return K` <ha-icon-button
      data-domain=${c_(t.data_domain)}
      data-state=${c_(t.data_state)}
      class="${Ee({button:!0})}"
      style="${He(t.style||{})}"
      .actionHandler=${wm({hasHold:i,hasDoubleClick:a})}
      .label=${t.title||""}
      @action=${t=>this._actionHandler(t,e)}
    >
      ${n?K`<ha-svg-icon .path="${n}"></ha-svg-icon>`:K`<ha-icon
            icon="${t.icon||"mdi:gesture-tap-button"}"
          ></ha-icon>`}
    </ha-icon-button>`}render(){if(!this._menuConfig)return;const e=this._menuConfig.style;if("none"===e)return;const t=("hidden"!==e||this.expanded?this.buttons.filter((e=>!e.alignment||"matching"===e.alignment)):this.buttons.filter((e=>e.icon===nu))).filter((e=>!1!==e.enabled)),n="hidden"!==e||this.expanded?this.buttons.filter((e=>"opposing"===e.alignment&&!1!==e.enabled)):[],i={flex:String(t.length)},a={flex:String(n.length)};return K` <div class="matching" style="${He(i)}">
        ${t.map((e=>this._renderButton(e)))}
      </div>
      <div class="opposing" style="${He(a)}">
        ${n.map((e=>this._renderButton(e)))}
      </div>`}static get styles(){return b('ha-icon-button.button {\n  color: var(--secondary-color, white);\n  background-color: rgba(0, 0, 0, 0.6);\n  border-radius: 50%;\n  padding: 0px;\n  margin: 3px;\n  --ha-icon-display: block;\n  /* Buttons can always be clicked */\n  pointer-events: auto;\n  opacity: 0.9;\n}\n\n@keyframes pulse {\n  0% {\n    opacity: 1;\n  }\n  50% {\n    opacity: 0.6;\n  }\n  100% {\n    opacity: 1;\n  }\n}\nha-icon[data-domain=alert][data-state=on],\nha-icon[data-domain=automation][data-state=on],\nha-icon[data-domain=binary_sensor][data-state=on],\nha-icon[data-domain=calendar][data-state=on],\nha-icon[data-domain=camera][data-state=streaming],\nha-icon[data-domain=cover][data-state=open],\nha-icon[data-domain=fan][data-state=on],\nha-icon[data-domain=humidifier][data-state=on],\nha-icon[data-domain=light][data-state=on],\nha-icon[data-domain=input_boolean][data-state=on],\nha-icon[data-domain=lock][data-state=unlocked],\nha-icon[data-domain=media_player][data-state=on],\nha-icon[data-domain=media_player][data-state=paused],\nha-icon[data-domain=media_player][data-state=playing],\nha-icon[data-domain=script][data-state=on],\nha-icon[data-domain=sun][data-state=above_horizon],\nha-icon[data-domain=switch][data-state=on],\nha-icon[data-domain=timer][data-state=active],\nha-icon[data-domain=vacuum][data-state=cleaning],\nha-icon[data-domain=group][data-state=on],\nha-icon[data-domain=group][data-state=home],\nha-icon[data-domain=group][data-state=open],\nha-icon[data-domain=group][data-state=locked],\nha-icon[data-domain=group][data-state=problem] {\n  color: var(--paper-item-icon-active-color, #fdd835);\n}\n\nha-icon[data-domain=climate][data-state=cooling] {\n  color: var(--cool-color, var(--state-climate-cool-color));\n}\n\nha-icon[data-domain=climate][data-state=heating] {\n  color: var(--heat-color, var(--state-climate-heat-color));\n}\n\nha-icon[data-domain=climate][data-state=drying] {\n  color: var(--dry-color, var(--state-climate-dry-color));\n}\n\nha-icon[data-domain=alarm_control_panel] {\n  color: var(--alarm-color-armed, var(--label-badge-red));\n}\n\nha-icon[data-domain=alarm_control_panel][data-state=disarmed] {\n  color: var(--alarm-color-disarmed, var(--label-badge-green));\n}\n\nha-icon[data-domain=alarm_control_panel][data-state=pending],\nha-icon[data-domain=alarm_control_panel][data-state=arming] {\n  color: var(--alarm-color-pending, var(--label-badge-yellow));\n  animation: pulse 1s infinite;\n}\n\nha-icon[data-domain=alarm_control_panel][data-state=triggered] {\n  color: var(--alarm-color-triggered, var(--label-badge-red));\n  animation: pulse 1s infinite;\n}\n\nha-icon[data-domain=plant][data-state=problem],\nha-icon[data-domain=zwave][data-state=dead] {\n  color: var(--state-icon-error-color);\n}\n\n/* Color the icon if unavailable */\nha-icon[data-state=unavailable] {\n  color: var(--state-unavailable-color);\n}\n\nha-icon-button[data-domain=alert][data-state=on],\nha-icon-button[data-domain=automation][data-state=on],\nha-icon-button[data-domain=binary_sensor][data-state=on],\nha-icon-button[data-domain=calendar][data-state=on],\nha-icon-button[data-domain=camera][data-state=streaming],\nha-icon-button[data-domain=cover][data-state=open],\nha-icon-button[data-domain=fan][data-state=on],\nha-icon-button[data-domain=humidifier][data-state=on],\nha-icon-button[data-domain=light][data-state=on],\nha-icon-button[data-domain=input_boolean][data-state=on],\nha-icon-button[data-domain=lock][data-state=unlocked],\nha-icon-button[data-domain=media_player][data-state=on],\nha-icon-button[data-domain=media_player][data-state=paused],\nha-icon-button[data-domain=media_player][data-state=playing],\nha-icon-button[data-domain=script][data-state=on],\nha-icon-button[data-domain=sun][data-state=above_horizon],\nha-icon-button[data-domain=switch][data-state=on],\nha-icon-button[data-domain=timer][data-state=active],\nha-icon-button[data-domain=vacuum][data-state=cleaning],\nha-icon-button[data-domain=group][data-state=on],\nha-icon-button[data-domain=group][data-state=home],\nha-icon-button[data-domain=group][data-state=open],\nha-icon-button[data-domain=group][data-state=locked],\nha-icon-button[data-domain=group][data-state=problem] {\n  color: var(--paper-item-icon-active-color, #fdd835);\n}\n\nha-icon-button[data-domain=climate][data-state=cooling] {\n  color: var(--cool-color, var(--state-climate-cool-color));\n}\n\nha-icon-button[data-domain=climate][data-state=heating] {\n  color: var(--heat-color, var(--state-climate-heat-color));\n}\n\nha-icon-button[data-domain=climate][data-state=drying] {\n  color: var(--dry-color, var(--state-climate-dry-color));\n}\n\nha-icon-button[data-domain=alarm_control_panel] {\n  color: var(--alarm-color-armed, var(--label-badge-red));\n}\n\nha-icon-button[data-domain=alarm_control_panel][data-state=disarmed] {\n  color: var(--alarm-color-disarmed, var(--label-badge-green));\n}\n\nha-icon-button[data-domain=alarm_control_panel][data-state=pending],\nha-icon-button[data-domain=alarm_control_panel][data-state=arming] {\n  color: var(--alarm-color-pending, var(--label-badge-yellow));\n  animation: pulse 1s infinite;\n}\n\nha-icon-button[data-domain=alarm_control_panel][data-state=triggered] {\n  color: var(--alarm-color-triggered, var(--label-badge-red));\n  animation: pulse 1s infinite;\n}\n\nha-icon-button[data-domain=plant][data-state=problem],\nha-icon-button[data-domain=zwave][data-state=dead] {\n  color: var(--state-icon-error-color);\n}\n\n/* Color the icon if unavailable */\nha-icon-button[data-state=unavailable] {\n  color: var(--state-unavailable-color);\n}\n\n:host {\n  --frigate-card-menu-button-size: 40px;\n  --mdc-icon-button-size: var(--frigate-card-menu-button-size);\n  --mdc-icon-size: calc(var(--mdc-icon-button-size) / 2);\n  pointer-events: none;\n  display: flex;\n  flex-direction: row;\n  justify-content: space-between;\n}\n\n/***********************************\n * Aligned divs: matching & opposing\n ***********************************/\ndiv.matching,\ndiv.opposing {\n  display: flex;\n  flex-wrap: wrap;\n  flex-direction: row;\n  align-items: flex-start;\n  min-width: 0px;\n  min-height: 0px;\n}\n\ndiv.matching {\n  justify-content: flex-start;\n}\n\ndiv.opposing {\n  justify-content: flex-end;\n}\n\n/********************\n * Outside menu style\n ********************/\n:host([data-style=outside]) {\n  width: 100%;\n  background: var(--secondary-background-color);\n}\n\n/************************************\n * Match menu rounded corners to card\n ************************************/\n:host([data-position=top]),\n:host([data-position=left]) {\n  border-top-left-radius: var(--ha-card-border-radius, 4px);\n}\n\n:host([data-position=top]),\n:host([data-position=right]) {\n  border-top-right-radius: var(--ha-card-border-radius, 4px);\n}\n\n:host([data-position=bottom]),\n:host([data-position=left]) {\n  border-bottom-left-radius: var(--ha-card-border-radius, 4px);\n}\n\n:host([data-position=bottom]),\n:host([data-position=right]) {\n  border-bottom-right-radius: var(--ha-card-border-radius, 4px);\n}\n\n/**************************************\n * Positioning for absolute menu styles\n **************************************/\n:host(:not([data-style=outside])[data-position=top]),\n:host(:not([data-style=outside])[data-position=left][data-alignment=top]),\n:host(:not([data-style=outside])[data-position=right][data-alignment=top]) {\n  top: 0px;\n}\n\n:host(:not([data-style=outside])[data-position=bottom]),\n:host(:not([data-style=outside])[data-position=left][data-alignment=bottom]),\n:host(:not([data-style=outside])[data-position=right][data-alignment=bottom]) {\n  bottom: 0px;\n}\n\n:host(:not([data-style=outside])[data-position=left]),\n:host(:not([data-style=outside])[data-position=top][data-alignment=left]),\n:host(:not([data-style=outside])[data-position=bottom][data-alignment=left]) {\n  left: 0px;\n}\n\n:host(:not([data-style=outside])[data-position=right]),\n:host(:not([data-style=outside])[data-position=top][data-alignment=right]),\n:host(:not([data-style=outside])[data-position=bottom][data-alignment=right]) {\n  right: 0px;\n}\n\n/********************************************************\n * Hack: Ensure host & div expand for column flex layouts\n ********************************************************/\n:host(:not([data-style=outside])[data-position=left]) {\n  writing-mode: vertical-lr;\n}\n\n:host(:not([data-style=outside])[data-position=right]) {\n  writing-mode: vertical-rl;\n}\n\n:host(:not([data-style=outside])[data-style=overlay][data-position=left]) div > *,\n:host(:not([data-style=outside])[data-style=overlay][data-position=right]) div > *,\n:host(:not([data-style=outside])[data-style*=hover][data-position=left]) div > *,\n:host(:not([data-style=outside])[data-style*=hover][data-position=right]) div > *,\n:host(:not([data-style=outside])[data-style=hidden][data-position=left]) div > *,\n:host(:not([data-style=outside])[data-style=hidden][data-position=right]) div > * {\n  writing-mode: horizontal-tb;\n}\n\n/**********************\n * "Reverse" alignments\n **********************/\n:host(:not([data-style=outside])[data-position=left][data-alignment=bottom]),\n:host(:not([data-style=outside])[data-position=right][data-alignment=bottom]),\n:host([data-position=top][data-alignment=right]),\n:host([data-position=bottom][data-alignment=right]),\n:host(:not([data-style=outside])[data-position=left][data-alignment=bottom]) div,\n:host(:not([data-style=outside])[data-position=right][data-alignment=bottom]) div,\n:host([data-position=top][data-alignment=right]) div,\n:host([data-position=bottom][data-alignment=right]) div {\n  flex-direction: row-reverse;\n}\n\n/****************************\n * Wrap upwards on the bottom\n ****************************/\n:host(:not([data-style=outside])[data-position=bottom]) div {\n  flex-wrap: wrap-reverse;\n}\n\n/********************************************\n * Positioning for absolute based menu styles\n ********************************************/\n:host([data-style=overlay]),\n:host([data-style*=hover]),\n:host([data-style=hidden]) {\n  position: absolute;\n  overflow: hidden;\n  width: calc(var(--frigate-card-menu-button-size) + 6px);\n  height: calc(var(--frigate-card-menu-button-size) + 6px);\n}\n\n:host([data-style=overlay][data-position=top]),\n:host([data-style=overlay][data-position=bottom]),\n:host([data-style*=hover][data-position=top]),\n:host([data-style*=hover][data-position=bottom]),\n:host([data-style=hidden][data-position=top][expanded]),\n:host([data-style=hidden][data-position=bottom][expanded]) {\n  width: 100%;\n  height: auto;\n  overflow: visible;\n  background: linear-gradient(90deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0));\n}\n\n:host([data-style=overlay][data-position=left]),\n:host([data-style=overlay][data-position=right]),\n:host([data-style*=hover][data-position=left]),\n:host([data-style*=hover][data-position=right]),\n:host([data-style=hidden][data-position=left][expanded]),\n:host([data-style=hidden][data-position=right][expanded]) {\n  height: 100%;\n  width: auto;\n  overflow: visible;\n  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0));\n}')}};function f_(e){return"number"==typeof e}function g_(e){return"[object Object]"===Object.prototype.toString.call(e)}function v_(e){return g_(e)||function(e){return Array.isArray(e)}(e)}function __(e){return Math.abs(e)}function y_(e){return e?e/__(e):0}function b_(e,t){return __(e-t)}function w_(e){return $_(e).map(Number)}function x_(e){return e[C_(e)]}function C_(e){return Math.max(0,e.length-1)}function $_(e){return Object.keys(e)}function k_(e,t){return[e,t].reduce((function(e,t){return $_(t).forEach((function(n){var i=e[n],a=t[n],r=g_(i)&&g_(a);e[n]=r?k_(i,a):a})),e}),{})}function E_(e,t){var n=$_(e),i=$_(t);return n.length===i.length&&n.every((function(n){var i=e[n],a=t[n];return"function"==typeof i?"".concat(i)==="".concat(a):v_(i)&&v_(a)?E_(i,a):i===a}))}function M_(e,t){var n={start:function(){return 0},center:function(e){return i(e)/2},end:i};function i(e){return t-e}var a={measure:function(i){return f_(e)?t*Number(e):n[e](i)}};return a}function S_(e,t){var n=__(e-t);function i(t){return t<e}function a(e){return e>t}function r(e){return i(e)||a(e)}var o={length:n,max:t,min:e,constrain:function(n){return r(n)?i(n)?e:t:n},reachedAny:r,reachedMax:a,reachedMin:i,removeOffset:function(e){return n?e-n*Math.ceil((e-t)/n):e}};return o}function T_(e,t,n){var i=S_(0,e),a=i.min,r=i.constrain,o=e+1,s=c(t);function c(e){return n?__((o+e)%o):r(e)}function l(){return s}function d(e){return s=c(e),u}var u={add:function(e){return d(l()+e)},clone:function(){return T_(e,l(),n)},get:l,set:d,min:a,max:e};return u}function A_(){var e=[];var t={add:function(n,i,a,r){return void 0===r&&(r={passive:!0}),n.addEventListener(i,a,r),e.push((function(){return n.removeEventListener(i,a,r)})),t},removeAll:function(){return e=e.filter((function(e){return e()})),t}};return t}function z_(e){var t=e;function n(e){return t/=e,a}function i(e){return f_(e)?e:e.get()}var a={add:function(e){return t+=i(e),a},divide:n,get:function(){return t},multiply:function(e){return t*=e,a},normalize:function(){return 0!==t&&n(t),a},set:function(e){return t=i(e),a},subtract:function(e){return t-=i(e),a}};return a}function j_(e,t,n,i,a,r,o,s,c,l,d,u,h,m,p,f){var g=e.cross,v=["INPUT","SELECT","TEXTAREA"],_={passive:!1},y=z_(0),b=A_(),w=A_(),x=h.measure(20),C={mouse:300,touch:400},$={mouse:500,touch:600},k=p?5:16,E=1,M=0,S=0,T=!1,A=!1,z=!1,j=!1;function O(e){if(!((j=!a.isTouchEvent(e))&&0!==e.button||function(e){var t=e.nodeName||"";return v.indexOf(t)>-1}(e.target))){var t,o=b_(i.get(),r.get())>=2,s=j||!o;T=!0,a.pointerDown(e),y.set(i),i.set(r),c.useBaseMass().useSpeed(80),t=j?document:n,w.add(t,"touchmove",I,_).add(t,"touchend",R).add(t,"mousemove",I,_).add(t,"mouseup",R),M=a.readPoint(e),S=a.readPoint(e,g),u.emit("pointerDown"),s&&(z=!1)}}function I(e){if(!A&&!j){if(!e.cancelable)return R(e);var n=a.readPoint(e),r=a.readPoint(e,g),s=b_(n,M),c=b_(r,S);if(!(A=s>c)&&!z)return R(e)}var l=a.pointerMove(e);!z&&l&&(z=!0),o.start(),i.add(t.apply(l)),e.preventDefault()}function R(e){var n=l.byDistance(0,!1).index!==d.get(),r=a.pointerUp(e)*(p?$:C)[j?"mouse":"touch"],o=function(e,t){var n=d.clone().add(-1*y_(e)),i=n.get()===d.min||n.get()===d.max,a=l.byDistance(e,!p).distance;return p||__(e)<x?a:!m&&i?.4*a:f&&t?.5*a:l.byIndex(n.get(),0).distance}(t.apply(r),n),h=function(e,t){if(0===e||0===t)return 0;if(__(e)<=__(t))return 0;var n=b_(__(e),__(t));return __(n/e)}(r,o),g=b_(i.get(),y.get())>=.5,v=n&&h>.75,_=__(r)<x,b=v?10:k,M=v?E+2.5*h:E;g&&!j&&(z=!0),A=!1,T=!1,w.removeAll(),c.useSpeed(_?9:b).useMass(M),s.distance(o,!p),j=!1,u.emit("pointerUp")}function D(e){z&&(e.stopPropagation(),e.preventDefault())}return{addActivationEvents:function(){var e=n;b.add(e,"dragstart",(function(e){return e.preventDefault()}),_).add(e,"touchmove",(function(){}),_).add(e,"touchend",(function(){})).add(e,"touchstart",O).add(e,"mousedown",O).add(e,"touchcancel",R).add(e,"contextmenu",R).add(e,"click",D,!0)},clickAllowed:function(){return!z},pointerDown:function(){return T},removeAllEvents:function(){b.removeAll(),w.removeAll()}}}function O_(e,t,n){var i,a,r=(i=2,a=Math.pow(10,i),function(e){return Math.round(e*a)/a}),o=z_(0),s=z_(0),c=z_(0),l=0,d=t,u=n;function h(e){return d=e,p}function m(e){return u=e,p}var p={direction:function(){return l},seek:function(t){c.set(t).subtract(e);var n,i,a,r,h=(n=c.get(),(a=0)+(n-(i=0))/(100-i)*(d-a));return l=y_(c.get()),c.normalize().multiply(h).subtract(o),(r=c).divide(u),s.add(r),p},settle:function(t){var n=t.get()-e.get(),i=!r(n);return i&&e.set(t),i},update:function(){o.add(s),e.add(o),s.multiply(0)},useBaseMass:function(){return m(n)},useBaseSpeed:function(){return h(t)},useMass:m,useSpeed:h};return p}function I_(e,t,n,i,a){var r=a.measure(10),o=a.measure(50),s=.85,c=!1;return{constrain:function(a){if(!c&&e.reachedAny(n.get())&&e.reachedAny(t.get())){var l=e.reachedMin(t.get())?"min":"max",d=__(e[l]-t.get()),u=n.get()-t.get(),h=Math.min(d/o,s);n.subtract(u*h),!a&&__(u)<r&&(n.set(e.constrain(n.get())),i.useSpeed(10).useMass(3))}},toggleActive:function(e){c=!e}}}function R_(e,t,n,i){var a=S_(-t+e,n[0]),r=n.map(a.constrain);return{snapsContained:function(){if(t<=e)return[a.max];if("keepSnaps"===i)return r;var n=function(){var e=r[0],t=x_(r),n=r.lastIndexOf(e),i=r.indexOf(t)+1;return S_(n,i)}(),o=n.min,s=n.max;return r.slice(o,s)}()}}function D_(e,t,n,i){var a=S_(t.min+.1,t.max+.1),r=a.reachedMin,o=a.reachedMax;var s={loop:function(t){if(function(e){return 1===e?o(n.get()):-1===e&&r(n.get())}(t)){var a=e*(-1*t);i.forEach((function(e){return e.add(a)}))}}};return s}function P_(e){var t=e.max,n=e.length;var i={get:function(e){return(e-t)/-n}};return i}function L_(e,t,n,i,a){var r=i.reachedAny,o=i.removeOffset,s=i.constrain;function c(e){return e.concat().sort((function(e,t){return __(e)-__(t)}))[0]}function l(t,i){var a=[t,t+n,t-n];if(!e)return a[0];if(!i)return c(a);var r=a.filter((function(e){return y_(e)===i}));return c(r)}var d={byDistance:function(n,i){var c=a.get()+n,d=function(n){var i=e?o(n):s(n),a=t.map((function(e){return e-i})).map((function(e){return l(e,0)})).map((function(e,t){return{diff:e,index:t}})).sort((function(e,t){return __(e.diff)-__(t.diff)}));return{index:a[0].index,distance:i}}(c),u=d.index,h=d.distance,m=!e&&r(c);return!i||m?{index:u,distance:n}:{index:u,distance:n+l(t[u]-h,0)}},byIndex:function(e,n){return{index:e,distance:l(t[e]-a.get(),n)}},shortcut:l};return d}function N_(e,t,n){var i="x"===e.scroll?function(e){return"translate3d(".concat(e,"px,0px,0px)")}:function(e){return"translate3d(0px,".concat(e,"px,0px)")},a=n.style,r=!1;return{clear:function(){r||(a.transform="",n.getAttribute("style")||n.removeAttribute("style"))},to:function(e){r||(a.transform=i(t.apply(e.get())))},toggleActive:function(e){r=!e}}}function U_(e,t,n,i,a,r,o,s,c){var l,d=w_(a),u=w_(a).reverse(),h=(l=r[0]-1,f(p(u,l),"end")).concat(function(){var e=n-r[0]-1,t=p(d,e);return f(t,"start")}());function m(e,t){return e.reduce((function(e,t){return e-a[t]}),t)}function p(e,t){return e.reduce((function(e,n){return m(e,t)>0?e.concat([n]):e}),[])}function f(n,a){var r="start"===a,l=r?-i:i,d=o.findSlideBounds([l]);return n.map((function(n){var a=r?0:-i,o=r?i:0,l=d.filter((function(e){return e.index===n}))[0],u=l[r?"end":"start"],h=z_(-1),m=z_(-1),p=N_(e,t,c[n]);return{index:n,location:m,translate:p,target:function(){return h.set(s.get()>u?a:o)}}}))}var g={canLoop:function(){return h.every((function(e){var t=e.index,i=d.filter((function(e){return e!==t}));return m(i,n)<=.1}))},clear:function(){h.forEach((function(e){return e.translate.clear()}))},loop:function(){h.forEach((function(e){var t=e.target,n=e.translate,i=e.location,a=t();a.get()!==i.get()&&(0===a.get()?n.clear():n.to(a),i.set(a))}))},loopPoints:h};return g}function F_(e,t,n,i,a,r,o){var s=a.removeOffset,c=a.constrain,l=.5,d=r?[0,t,-t]:[0],u=h(d,o);function h(t,a){var r=t||d,o=function(e){var t=e||0;return n.map((function(e){return S_(l,e-l).constrain(e*t)}))}(a);return r.reduce((function(t,a){var r=i.map((function(t,i){return{start:t-n[i]+o[i]+a,end:t+e-o[i]+a,index:i}}));return t.concat(r)}),[])}return{check:function(e,t){var n=r?s(e):c(e);return(t||u).reduce((function(e,t){var i=t.index,a=t.start,r=t.end;return!(-1!==e.indexOf(i))&&(a<n&&r>n)?e.concat([i]):e}),[])},findSlideBounds:h}}function H_(e,t,n){var i=f_(n);var a={groupSlides:function(a){return i?function(e,t){return w_(e).filter((function(e){return e%t==0})).map((function(n){return e.slice(n,n+t)}))}(a,n):function(n){return w_(n).reduce((function(n,i){var a=t.slice(x_(n),i+1).reduce((function(e,t){return e+t}),0);return!i||a>e?n.concat(i):n}),[]).map((function(e,t,i){return n.slice(e,i[t+1])}))}(a)}};return a}function Z_(e,t,n,i,a){var r=i.align,o=i.axis,s=i.direction,c=i.startIndex,l=i.inViewThreshold,d=i.loop,u=i.speed,h=i.dragFree,m=i.slidesToScroll,p=i.skipSnaps,f=i.containScroll,g=t.getBoundingClientRect(),v=n.map((function(e){return e.getBoundingClientRect()})),_=function(e){var t="rtl"===e?-1:1,n={apply:function(e){return e*t}};return n}(s),y=function(e,t){var n="y"===e?"y":"x";return{scroll:n,cross:"y"===e?"x":"y",startEdge:"y"===n?"top":"rtl"===t?"right":"left",endEdge:"y"===n?"bottom":"rtl"===t?"left":"right",measureSize:function(e){var t=e.width,i=e.height;return"x"===n?t:i}}}(o,s),b=y.measureSize(g),w=function(e){var t={measure:function(t){return e*(t/100)}};return t}(b),x=M_(r,b),C=!d&&""!==f,$=function(e,t,n,i,a){var r=e.measureSize,o=e.startEdge,s=e.endEdge,c=n[0]&&a,l=function(){if(!c)return 0;var e=n[0];return __(t[o]-e[o])}(),d=function(){if(!c)return 0;var e=window.getComputedStyle(x_(i));return parseFloat(e.getPropertyValue("margin-".concat(s)))}(),u=n.map(r),h=n.map((function(e,t,n){var i=!t,a=t===C_(n);return i?u[t]+l:a?u[t]+d:n[t+1][o]-e[o]})).map(__);return{slideSizes:u,slideSizesWithGaps:h}}(y,g,v,n,d||""!==f),k=$.slideSizes,E=$.slideSizesWithGaps,M=H_(b,E,m),S=function(e,t,n,i,a,r,o){var s,c=e.startEdge,l=e.endEdge,d=r.groupSlides,u=d(i).map((function(e){return x_(e)[l]-e[0][c]})).map(__).map(t.measure),h=i.map((function(e){return n[c]-e[c]})).map((function(e){return-__(e)})),m=(s=x_(h)-x_(a),d(h).map((function(e){return e[0]})).map((function(e,t,n){var i=!t,a=t===C_(n);return o&&i?0:o&&a?s:e+u[t]})));return{snaps:h,snapsAligned:m}}(y,x,g,v,E,M,C),T=S.snaps,A=S.snapsAligned,z=-x_(T)+x_(E),j=R_(b,z,A,f).snapsContained,O=C?j:A,I=function(e,t,n){var i,a;return{limit:(i=t[0],a=x_(t),S_(n?i-e:a,i))}}(z,O,d).limit,R=T_(C_(O),c,d),D=R.clone(),P=w_(n),L=function(e){var t=0;function n(e,n){return function(){e===!!t&&n()}}function i(){t=window.requestAnimationFrame(e)}return{proceed:n(!0,i),start:n(!1,i),stop:n(!0,(function(){window.cancelAnimationFrame(t),t=0}))}}((function(){d||B.scrollBounds.constrain(B.dragHandler.pointerDown()),B.scrollBody.seek(F).update();var e=B.scrollBody.settle(F);e&&!B.dragHandler.pointerDown()&&(B.animation.stop(),a.emit("settle")),e||a.emit("scroll"),d&&(B.scrollLooper.loop(B.scrollBody.direction()),B.slideLooper.loop()),B.translate.to(U),B.animation.proceed()})),N=O[R.get()],U=z_(N),F=z_(N),H=O_(U,u,1),Z=L_(d,O,z,I,F),q=function(e,t,n,i,a,r){function o(i){var o=i.distance,s=i.index!==t.get();o&&(e.start(),a.add(o)),s&&(n.set(t.get()),t.set(i.index),r.emit("select"))}var s={distance:function(e,t){o(i.byDistance(e,t))},index:function(e,n){var a=t.clone().set(e);o(i.byIndex(a.get(),n))}};return s}(L,R,D,Z,F,a),V=F_(b,z,k,T,I,d,l),W=j_(y,_,e,F,function(e){var t,n,i=170;function a(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}function r(e){return e.timeStamp}function o(t,n){var i=n||e.scroll,r="client".concat("x"===i?"X":"Y");return(a(t)?t.touches[0]:t)[r]}return{isTouchEvent:a,pointerDown:function(e){return t=e,n=e,o(e)},pointerMove:function(e){var a=o(e)-o(n),s=r(e)-r(t)>i;return n=e,s&&(t=e),a},pointerUp:function(e){if(!t||!n)return 0;var a=o(n)-o(t),s=r(e)-r(t),c=r(e)-r(n)>i,l=a/s;return s&&!c&&__(l)>.1?l:0},readPoint:o}}(y),U,L,q,H,Z,R,a,w,d,h,p),B={containerRect:g,slideRects:v,animation:L,axis:y,direction:_,dragHandler:W,eventStore:A_(),percentOfView:w,index:R,indexPrevious:D,limit:I,location:U,options:i,scrollBody:H,scrollBounds:I_(I,U,F,H,w),scrollLooper:D_(z,I,U,[U,F]),scrollProgress:P_(I),scrollSnaps:O,scrollTarget:Z,scrollTo:q,slideLooper:U_(y,_,b,z,E,O,V,U,n),slidesToScroll:M,slidesInView:V,slideIndexes:P,target:F,translate:N_(y,_,t)};return B}e([be({attribute:!1})],p_.prototype,"hass",void 0),e([be({attribute:!0,type:Boolean,reflect:!0})],p_.prototype,"expanded",void 0),e([we()],p_.prototype,"_menuConfig",void 0),e([be({attribute:!1})],p_.prototype,"buttons",void 0),e([be({attribute:!1})],p_.prototype,"entityRegistryManager",void 0),p_=m_=e([_e("frigate-card-menu")],p_);var q_={align:"center",axis:"x",containScroll:"",direction:"ltr",slidesToScroll:1,breakpoints:{},dragFree:!1,draggable:!0,inViewThreshold:0,loop:!1,skipSnaps:!1,speed:10,startIndex:0,active:!0};function V_(){function e(e,t){return k_(e,t||{})}var t={merge:e,areEqual:function(e,t){return JSON.stringify($_(e.breakpoints||{}))===JSON.stringify($_(t.breakpoints||{}))&&E_(e,t)},atMedia:function(t){var n=t.breakpoints||{},i=$_(n).filter((function(e){return window.matchMedia(e).matches})).map((function(e){return n[e]})).reduce((function(t,n){return e(t,n)}),{});return e(t,i)}};return t}function W_(e,t,n){var i,a,r,o,s,c=A_(),l=V_(),d=function(){var e=V_(),t=e.atMedia,n=e.areEqual,i=[],a=[];function r(e){var i=t(e.options);return function(){return!n(i,t(e.options))}}var o={init:function(e,n){return a=e.map(r),(i=e.filter((function(e){return t(e.options).active}))).forEach((function(e){return e.init(n)})),e.reduce((function(e,t){var n;return Object.assign(e,((n={})[t.name]=t,n))}),{})},destroy:function(){i=i.filter((function(e){return e.destroy()}))},haveChanged:function(){return a.some((function(e){return e()}))}};return o}(),u=function(){var e={};function t(t){return e[t]||[]}var n={emit:function(e){return t(e).forEach((function(t){return t(e)})),n},off:function(i,a){return e[i]=t(i).filter((function(e){return e!==a})),n},on:function(i,a){return e[i]=t(i).concat([a]),n}};return n}(),h=u.on,m=u.off,p=w,f=!1,g=l.merge(q_,W_.globalOptions),v=l.merge(g),_=[],y=0;function b(t,n){if(!f){var c,h;if(c="container"in e&&e.container,h="slides"in e&&e.slides,r="root"in e?e.root:e,o=c||r.children[0],s=h||[].slice.call(o.children),g=l.merge(g,t),v=l.atMedia(g),i=Z_(r,o,s,v,u),y=i.axis.measureSize(r.getBoundingClientRect()),!v.active)return x();if(i.translate.to(i.location),_=n||_,a=d.init(_,E),v.loop){if(!i.slideLooper.canLoop())return x(),b({loop:!1},n),void(g=l.merge(g,{loop:!0}));i.slideLooper.loop()}v.draggable&&o.offsetParent&&s.length&&i.dragHandler.addActivationEvents()}}function w(e,t){var n=k();x(),b(l.merge({startIndex:n},e),t),u.emit("reInit")}function x(){i.dragHandler.removeAllEvents(),i.animation.stop(),i.eventStore.removeAll(),i.translate.clear(),i.slideLooper.clear(),d.destroy()}function C(e){var t=i[e?"target":"location"].get(),n=v.loop?"removeOffset":"constrain";return i.slidesInView.check(i.limit[n](t))}function $(e,t,n){v.active&&!f&&(i.scrollBody.useBaseMass().useSpeed(t?100:v.speed),i.scrollTo.index(e,n||0))}function k(){return i.index.get()}var E={canScrollNext:function(){return i.index.clone().add(1).get()!==k()},canScrollPrev:function(){return i.index.clone().add(-1).get()!==k()},clickAllowed:function(){return i.dragHandler.clickAllowed()},containerNode:function(){return o},internalEngine:function(){return i},destroy:function(){f||(f=!0,c.removeAll(),x(),u.emit("destroy"))},off:m,on:h,plugins:function(){return a},previousScrollSnap:function(){return i.indexPrevious.get()},reInit:p,rootNode:function(){return r},scrollNext:function(e){$(i.index.clone().add(1).get(),!0===e,-1)},scrollPrev:function(e){$(i.index.clone().add(-1).get(),!0===e,1)},scrollProgress:function(){return i.scrollProgress.get(i.location.get())},scrollSnapList:function(){return i.scrollSnaps.map(i.scrollProgress.get)},scrollTo:$,selectedScrollSnap:k,slideNodes:function(){return s},slidesInView:C,slidesNotInView:function(e){var t=C(e);return i.slideIndexes.filter((function(e){return-1===t.indexOf(e)}))}};return b(t,n),c.add(window,"resize",(function(){var e=l.atMedia(g),t=!l.areEqual(e,v),n=i.axis.measureSize(r.getBoundingClientRect()),a=y!==n,o=d.haveChanged();(a||t||o)&&w(),u.emit("resize")})),setTimeout((function(){return u.emit("init")}),0),E}function B_(){return B_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},B_.apply(this,arguments)}W_.globalOptions=void 0,W_.optionsHandler=V_;var Y_=function(e,t){return void 0===t&&(t=.996),e*t/(1-t)};function Q_(e,t){if(e.length!==t.length)throw new Error("vectors must be same length");return e.map((function(e,n){return e+t[n]}))}function G_(e){return Math.max.apply(Math,e.map(Math.abs))}function K_(e){return Object.freeze(e),Object.values(e).forEach((function(e){null===e||"object"!=typeof e||Object.isFrozen(e)||K_(e)})),e}var X_=[1,18,"undefined"!=typeof window&&window.innerHeight||800];var J_=[-1,-1,-1];var ey=function(e){return B_({},e,{axisDelta:e.axisDelta.map((function(e){return t=e,n=-700,i=700,Math.min(Math.max(n,t),i);var t,n,i}))})},ty=.6,ny=.96,iy=2,ay=5,ry=K_({preventWheelAction:!0,reverseSign:[!0,!0,!1]}),oy=400;function sy(){return{isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:1/0,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:oy}}function cy(e){void 0===e&&(e={});var t,n,i,a=function(){var e={};function t(t,n){e[t]=(e[t]||[]).filter((function(e){return e!==n}))}return K_({on:function(n,i){return e[n]=(e[n]||[]).concat(i),function(){return t(n,i)}},off:t,dispatch:function(t,n){t in e&&e[t].forEach((function(e){return e(n)}))}})}(),r=a.on,o=a.off,s=a.dispatch,c=ry,l=sy(),d=!1,u=function(e){Array.isArray(e)?e.forEach((function(e){return p(e)})):p(e)},h=function(e){return void 0===e&&(e={}),Object.values(e).some((function(e){return null==e}))?c:c=K_(B_({},ry,c,e))},m=function(e){var i=B_({event:t,isStart:!1,isEnding:!1,isMomentumCancel:!1,isMomentum:l.isMomentum,axisDelta:[0,0,0],axisVelocity:l.axisVelocity,axisMovement:l.axisMovement,get axisMovementProjection(){return Q_(i.axisMovement,i.axisVelocity.map((function(e){return Y_(e)})))}},e);s("wheel",B_({},i,{previous:n})),n=i},p=function(e){var n=ey(function(e,t){if(!t)return e;var n=!0===t?J_:t.map((function(e){return e?-1:1}));return B_({},e,{axisDelta:e.axisDelta.map((function(e,t){return e*n[t]}))})}(function(e){var t=e.deltaX*X_[e.deltaMode],n=e.deltaY*X_[e.deltaMode],i=(e.deltaZ||0)*X_[e.deltaMode];return{timeStamp:e.timeStamp,axisDelta:[t,n,i]}}(e),c.reverseSign)),i=n.axisDelta,a=n.timeStamp,r=G_(i);e.preventDefault&&function(e,t){var n=c.preventWheelAction,i=t[0],a=t[1],r=t[2];if("boolean"==typeof n)return n;switch(n){case"x":return Math.abs(i)>=e;case"y":return Math.abs(a)>=e;case"z":return Math.abs(r)>=e;default:return!1}}(r,i)&&e.preventDefault(),l.isStarted?l.isMomentum&&r>Math.max(2,2*l.lastAbsDelta)&&($(!0),x()):x(),0===r&&Object.is&&Object.is(e.deltaX,-0)?d=!0:(t=e,l.axisMovement=Q_(l.axisMovement,i),l.lastAbsDelta=r,l.scrollPointsToMerge.push({axisDelta:i,timeStamp:a}),f(),m({axisDelta:i,isStart:!l.isStartPublished}),l.isStartPublished=!0,C())},f=function(){var e;l.scrollPointsToMerge.length===iy?(l.scrollPoints.unshift({axisDeltaSum:l.scrollPointsToMerge.map((function(e){return e.axisDelta})).reduce(Q_),timeStamp:(e=l.scrollPointsToMerge.map((function(e){return e.timeStamp})),e.reduce((function(e,t){return e+t}))/e.length)}),v(),l.scrollPointsToMerge.length=0,l.scrollPoints.length=1,l.isMomentum||b()):l.isStartPublished||g()},g=function(){var e;l.axisVelocity=(e=l.scrollPointsToMerge,e[e.length-1]).axisDelta.map((function(e){return e/l.willEndTimeout}))},v=function(){var e=l.scrollPoints,t=e[0],n=e[1];if(n&&t){var i=t.timeStamp-n.timeStamp;if(!(i<=0)){var a=t.axisDeltaSum.map((function(e){return e/i})),r=a.map((function(e,t){return e/(l.axisVelocity[t]||1)}));l.axisVelocity=a,l.accelerationFactors.push(r),_(i)}}},_=function(e){var t=10*Math.ceil(e/10)*1.2;l.isMomentum||(t=Math.max(100,2*t)),l.willEndTimeout=Math.min(1e3,Math.round(t))},y=function(e){return 0===e||e<=ny&&e>=ty},b=function(){if(l.accelerationFactors.length>=ay){if(d&&(d=!1,G_(l.axisVelocity)>=.2))return void w();var e=l.accelerationFactors.slice(-1*ay);e.every((function(e){var t=!!e.reduce((function(e,t){return e&&e<1&&e===t?1:0})),n=e.filter(y).length===e.length;return t||n}))&&w(),l.accelerationFactors=e}},w=function(){l.isMomentum=!0},x=function(){(l=sy()).isStarted=!0,l.startTime=Date.now(),n=void 0,d=!1},C=function(){clearTimeout(i),i=setTimeout($,l.willEndTimeout)},$=function(e){void 0===e&&(e=!1),l.isStarted&&(l.isMomentum&&e?m({isEnding:!0,isMomentumCancel:!0}):m({isEnding:!0}),l.isMomentum=!1,l.isStarted=!1)},k=function(e){var t=[],n=function(n){n.removeEventListener("wheel",e),t=t.filter((function(e){return e!==n}))};return K_({observe:function(i){return i.addEventListener("wheel",e,{passive:!1}),t.push(i),function(){return n(i)}},unobserve:n,disconnect:function(){t.forEach(n)}})}(u),E=k.observe,M=k.unobserve,S=k.disconnect;return h(e),K_({on:r,off:o,observe:E,unobserve:M,disconnect:S,feedWheel:u,updateOptions:h})}var ly={active:!0,breakpoints:{},wheelDraggingClass:"is-wheel-dragging",forceWheelAxis:void 0,target:void 0};function dy(e){var t,n=W_.optionsHandler(),i=n.merge(ly,dy.globalOptions),a=function(){};var r={name:"wheelGestures",options:n.merge(i,e),init:function(e){var i,o;t=n.atMedia(r.options);var s,c=e.internalEngine(),l=null!=(i=t.target)?i:e.containerNode().parentNode,d=null!=(o=t.forceWheelAxis)?o:c.options.axis,u=cy({preventWheelAction:d,reverseSign:[!0,!0,!1]}),h=u.observe(l),m=u.on("wheel",(function(e){var n=e.axisDelta,i=n[0],r=n[1],o="x"===d?i:r,c="x"===d?r:i,u=e.isMomentum&&e.previous&&!e.previous.isMomentum,h=e.isEnding&&!e.isMomentum||u;Math.abs(o)>Math.abs(c)&&!p&&!e.isMomentum&&function(e){try{_(s=new MouseEvent("mousedown",e.event))}catch(e){return a()}p=!0,document.documentElement.addEventListener("mousemove",g,!0),document.documentElement.addEventListener("mouseup",g,!0),void document.documentElement.addEventListener("mousedown",g,!0),t.wheelDraggingClass&&l.classList.add(t.wheelDraggingClass)}(e);if(!p)return;h?function(e){p=!1,_(v("mouseup",e)),f(),t.wheelDraggingClass&&l.classList.remove(t.wheelDraggingClass)}(e):_(v("mousemove",e))})),p=!1;function f(){document.documentElement.removeEventListener("mousemove",g,!0),document.documentElement.removeEventListener("mouseup",g,!0),document.documentElement.removeEventListener("mousedown",g,!0)}function g(e){p&&e.isTrusted&&e.stopImmediatePropagation()}function v(e,t){var n,i;if(d===c.options.axis){var a=t.axisMovement;n=a[0],i=a[1]}else{var r=t.axisMovement;i=r[0],n=r[1]}return new MouseEvent(e,{clientX:s.clientX+n,clientY:s.clientY+i,screenX:s.screenX+n,screenY:s.screenY+i,movementX:n,movementY:i,button:0,bubbles:!0,cancelable:!0,composed:!0})}function _(t){e.containerNode().dispatchEvent(t)}a=function(){h(),m(),f()}},destroy:function(){return a()}};return r}dy.globalOptions=void 0;var uy=":host {\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  margin-left: 5px;\n  padding: 5px;\n  color: var(--primary-text-color);\n  overflow: hidden;\n  column-gap: 5%;\n}\n\ndiv.title {\n  font-size: 1.2rem;\n  font-weight: bold;\n}\n\ndiv.details {\n  flex: 1;\n  display: flex;\n  flex-direction: column;\n  flex-wrap: wrap;\n  --mdc-icon-size: 16px;\n  min-height: 0px;\n}";const hy=(e,t,n,i)=>{const a={...i?.cardWideConfig&&{cardWideConfig:i.cardWideConfig}};return K` ${t.render({initial:()=>i?.inProgressFunc?.()??$v(a),pending:()=>i?.inProgressFunc?.()??$v(a),error:t=>{Nf(t),Mv(e,t)},complete:n})}`},my=0,py=Symbol();
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */class fy{constructor(e,t,n){this.o=0,this.status=0,this.autoRun=!0,this.i=e,this.i.addController(this);const i="object"==typeof t?t:{task:t,args:n};this.t=i.task,this.h=i.args,void 0!==i.autoRun&&(this.autoRun=i.autoRun),this.taskComplete=new Promise(((e,t)=>{this.l=e,this.u=t}))}hostUpdated(){this.performTask()}async performTask(){var e;const t=null===(e=this.h)||void 0===e?void 0:e.call(this);this.shouldRun(t)&&this.run(t)}shouldRun(e){return this.autoRun&&this.v(e)}async run(e){var t;let n,i;null!=e||(e=null===(t=this.h)||void 0===t?void 0:t.call(this)),2!==this.status&&3!==this.status||(this.taskComplete=new Promise(((e,t)=>{this.l=e,this.u=t}))),this.status=1,this._=void 0,this.m=void 0,this.i.requestUpdate();const a=++this.o;try{n=await this.t(e)}catch(e){i=e}this.o===a&&(n===py?this.status=0:(void 0===i?(this.status=2,this.l(n)):(this.status=3,this.u(i)),this.m=n,this._=i),this.i.requestUpdate())}get value(){return this.m}get error(){return this._}render(e){var t,n,i,a;switch(this.status){case 0:return null===(t=e.initial)||void 0===t?void 0:t.call(e);case 1:return null===(n=e.pending)||void 0===n?void 0:n.call(e);case 2:return null===(i=e.complete)||void 0===i?void 0:i.call(e,this.value);case 3:return null===(a=e.error)||void 0===a?void 0:a.call(e,this.error);default:this.status}}v(e){const t=this.T;return this.T=e,Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.some(((e,n)=>A(e,t[n]))):e!==t}}const gy=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,vy=(e,t,n,i=!0)=>new fy(e,{args:()=>[!!t(),n()],task:async([e,n])=>{const i=t();return e&&i&&n?(async(e,t)=>e&&t?t.startsWith("data:")||t.match(gy)?t:new Promise(((n,i)=>{e?e.fetchWithAuth(t).then((e=>e.blob())).then((e=>{const t=new FileReader;t.onload=()=>{const e=t.result;n("string"==typeof e?e:null)},t.onerror=e=>i(e),t.readAsDataURL(e)})):i()})):null)(i,n):null},autoRun:i});class _y{static isEvent(e){return this.isClip(e)||this.isSnapshot(e)}static isRecording(e){return"recording"===e.getMediaType()}static isClip(e){return"clip"===e.getMediaType()}static isSnapshot(e){return"snapshot"===e.getMediaType()}static isVideo(e){return this.isClip(e)||this.isRecording(e)}}const yy=(e,t="download")=>{const n=new URL(e).origin===window.location.origin,i=e.startsWith("data:");if(navigator.userAgent.startsWith("Home Assistant/")||navigator.userAgent.startsWith("HomeAssistant/")||!n&&!i)window.open(e,"_blank");else{const n=document.createElement("a");n.setAttribute("download",t),n.href=e,n.click(),n.remove()}},by=async(e,t,n)=>{const i=await t.getMediaDownloadPath(e,n);if(!i)throw new vu(Pm("error.download_no_media"));let a=i.endpoint;if(i.sign){let t;try{t=await lp(e,i.endpoint)}catch(e){Nf(e)}if(!t)throw new vu(Pm("error.download_sign_failed"));a=t}yy(a)},wy=300;let xy=class extends ge{constructor(){super(),this._intersectionObserver=new IntersectionObserver(this._intersectionHandler.bind(this))}connectedCallback(){this._intersectionObserver.observe(this),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._intersectionObserver.disconnect()}willUpdate(e){e.has("thumbnail")&&(this._embedThumbnailTask=vy(this,(()=>this.hass),(()=>this.thumbnail),!1),this._intersectionObserver.unobserve(this),this._intersectionObserver.observe(this))}_intersectionHandler(e){this._embedThumbnailTask?.status===my&&e.some((e=>e.isIntersecting))&&this._embedThumbnailTask?.run()}render(){if(!this._embedThumbnailTask)return;const e=K`<ha-icon
      icon="mdi:image-off"
      title=${Pm("thumbnail.no_thumbnail")}
    ></ha-icon> `;return K`${this.thumbnail?hy(this,this._embedThumbnailTask,(e=>e?K`<img src="${e}" />`:K``),{inProgressFunc:()=>e}):e} `}static get styles(){return b(":host {\n  display: block;\n  overflow: hidden;\n  aspect-ratio: 1/1;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n}\n\nimg {\n  display: block;\n}\n\nimg,\nha-icon {\n  display: inline-block;\n  vertical-align: top;\n  margin: 0;\n  border-radius: var(--frigate-card-css-border-radius, var(--ha-card-border-radius, 4px));\n  max-width: var(--frigate-card-thumbnail-size);\n  max-height: 100%;\n  aspect-ratio: 1/1;\n  object-fit: cover;\n}\n\nha-icon {\n  --mdc-icon-size: 50%;\n  color: var(--primary-text-color);\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  border: 1px solid rgba(255, 255, 255, 0.3);\n  box-sizing: border-box;\n  opacity: 0.2;\n}")}};e([be({attribute:!1})],xy.prototype,"thumbnail",void 0),e([be({attribute:!1})],xy.prototype,"hass",void 0),xy=e([_e("frigate-card-thumbnail-feature-event")],xy);let Cy=class extends ge{render(){if(this.date)return K`
      <div class="title">${Of(this.date,"HH:mm")}</div>
      <div class="subtitle">${Of(this.date,"MMM do")}</div>
      ${this.cameraTitle?K`<div class="camera">${this.cameraTitle}</div>`:K``}
    `}static get styles(){return b(":host {\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n  align-items: center;\n  aspect-ratio: 1/1;\n  overflow: hidden;\n  max-width: var(--frigate-card-thumbnail-size);\n  max-height: var(--frigate-card-thumbnail-size);\n  padding: 10px;\n  border: 1px solid var(--secondary-color);\n  background-color: var(--secondary-background-color);\n  border-radius: var(--frigate-card-css-border-radius, var(--ha-card-border-radius, 4px));\n  box-sizing: border-box;\n  color: var(--primary-text-color);\n}\n\ndiv {\n  text-align: center;\n}\n\ndiv.title {\n  font-size: 1.5rem;\n}\n\ndiv.camera {\n  font-size: 0.7em;\n}")}};e([be({attribute:!1})],Cy.prototype,"date",void 0),e([be({attribute:!1})],Cy.prototype,"cameraTitle",void 0),Cy=e([_e("frigate-card-thumbnail-feature-recording")],Cy);let $y=class extends ge{render(){if(!this.media)return;const e=this.media.getScore(),t=e?(100*e).toFixed(2)+"%":null,n=this.media.getStartTime(),i=n?Ff(n):null,a=this.media.getEndTime(),r=n&&a?qf(n,a):null,o=this.media.inProgress()?Pm("event.in_progress"):null,s=Rf(this.media.getWhat()?.join(", "))??null,c=Rf(this.media.getWhere()?.join(", "))??null,l=Rf(this.media.getTags()?.join(", "))??null,d=s||l?(s??"")+(s&&l?": ":"")+(l??""):null,u=this.seek?Of(this.seek,"HH:mm:ss"):null;return K`
      ${d?K` <div class="title">
            <span title=${d}>${d}</span>
            ${t?K`<span title="${t}">${t}</span>`:""}
          </div>`:""}
      <div class="details">
        ${i?K` <div>
                <ha-icon
                  title=${Pm("event.start")}
                  .icon=${"mdi:calendar-clock-outline"}
                ></ha-icon>
                <span title="${i}">${i}</span>
              </div>
              ${r||o?K` <div>
                    <ha-icon
                      title=${Pm("event.duration")}
                      .icon=${"mdi:clock-outline"}
                    ></ha-icon>
                    ${r?K`<span title="${r}">${r}</span>`:""}
                    ${o?K`<span title="${o}">${o}</span>`:""}
                  </div>`:""}`:""}
        ${this.cameraTitle?K` <div>
              <ha-icon title=${Pm("event.camera")} .icon=${"mdi:cctv"}></ha-icon>
              <span title="${this.cameraTitle}">${this.cameraTitle}</span>
            </div>`:""}
        ${c?K` <div>
              <ha-icon
                title=${Pm("event.where")}
                .icon=${"mdi:map-marker-outline"}
              ></ha-icon>
              <span title="${c}">${c}</span>
            </div>`:K``}
        ${l?K` <div>
              <ha-icon title=${Pm("event.tag")} .icon=${"mdi:tag"}></ha-icon>
              <span title="${l}">${l}</span>
            </div>`:K``}
        ${u?K` <div>
              <ha-icon
                title=${Pm("event.seek")}
                .icon=${"mdi:clock-fast"}
              ></ha-icon>
              <span title="${u}">${u}</span>
            </div>`:K``}
      </div>
    `}static get styles(){return b(uy)}};e([be({attribute:!1})],$y.prototype,"media",void 0),e([be({attribute:!1})],$y.prototype,"seek",void 0),e([be({attribute:!1})],$y.prototype,"cameraTitle",void 0),$y=e([_e("frigate-card-thumbnail-details-event")],$y);let ky=class extends ge{render(){if(!this.media)return;const e=this.media.getStartTime(),t=e?Ff(e):null,n=this.media.getEndTime(),i=e&&n?qf(e,n):null,a=this.media.inProgress()?Pm("recording.in_progress"):null,r=this.seek?Of(this.seek,"HH:mm:ss"):null,o=this.media.getEventCount();return K`
      ${this.cameraTitle?K` <div class="title">
            <span title="${this.cameraTitle}">${this.cameraTitle}</span>
          </div>`:""}
      <div class="details">
        ${t?K` <div>
                <ha-icon
                  title=${Pm("recording.start")}
                  .icon=${"mdi:calendar-clock-outline"}
                ></ha-icon>
                <span title="${t}">${t}</span>
              </div>
              ${i||a?K` <div>
                    <ha-icon
                      title=${Pm("recording.duration")}
                      .icon=${"mdi:clock-outline"}
                    ></ha-icon>
                    ${i?K`<span title="${i}">${i}</span>`:""}
                    ${a?K`<span title="${a}">${a}</span>`:""}
                  </div>`:""}`:""}
        ${r?K` <div>
              <ha-icon
                title=${Pm("event.seek")}
                .icon=${"mdi:clock-fast"}
              ></ha-icon>
              <span title="${r}">${r}</span>
            </div>`:K``}
        ${null!==o?K`<div>
              <ha-icon
                title=${Pm("recording.events")}
                .icon=${"mdi:shield-alert"}
              ></ha-icon>
              <span title="${o}">${o}</span>
            </div>`:""}
      </div>
    `}static get styles(){return b(uy)}};e([be({attribute:!1})],ky.prototype,"media",void 0),e([be({attribute:!1})],ky.prototype,"seek",void 0),e([be({attribute:!1})],ky.prototype,"cameraTitle",void 0),ky=e([_e("frigate-card-thumbnail-details-recording")],ky);let Ey=class extends ge{constructor(){super(...arguments),this.details=!1,this.show_favorite_control=!1,this.show_timeline_control=!1,this.show_download_control=!1}render(){if(!this.media||!this.cameraManager||!this.hass)return;const e=this.media.getThumbnail(),t=this.media.getTitle()??"",n={star:!0,starred:!!this.media?.isFavorite()},i=this.show_timeline_control&&this.view&&(!_y.isRecording(this.media)||this.media.getStartTime()&&this.media.getEndTime()),a=this.cameraManager?.getMediaCapabilities(this.media),r=this.show_favorite_control&&this.media&&this.hass&&a?.canFavorite,o=this.show_download_control&&this.hass&&this.media.getID()&&a?.canDownload,s=this.cameraManager.getCameraMetadata(this.hass,this.media.getCameraID())?.title;return K`
      ${_y.isEvent(this.media)?K`<frigate-card-thumbnail-feature-event
            aria-label="${t??""}"
            title=${t}
            .hass=${this.hass}
            .thumbnail=${e??void 0}
          ></frigate-card-thumbnail-feature-event>`:_y.isRecording(this.media)?K`<frigate-card-thumbnail-feature-recording
            aria-label="${t??""}"
            title="${t??""}"
            .cameraTitle=${this.details?void 0:s}
            .date=${this.media.getStartTime()??void 0}
          ></frigate-card-thumbnail-feature-recording>`:K``}
      ${r?K` <ha-icon
            class="${Ee(n)}"
            icon=${this.media.isFavorite()?"mdi:star":"mdi:star-outline"}
            title=${Pm("thumbnail.retain_indefinitely")}
            @click=${async e=>{if(vm(e),this.hass&&this.media){try{await(this.cameraManager?.favoriteMedia(this.hass,this.media,!this.media?.isFavorite()))}catch(e){return void Nf(e)}this.requestUpdate()}}}
          /></ha-icon>`:""}
      ${this.details&&_y.isEvent(this.media)?K`<frigate-card-thumbnail-details-event
            .media=${this.media??void 0}
            .cameraTitle=${s}
            .seek=${this.seek}
          ></frigate-card-thumbnail-details-event>`:this.details&&_y.isRecording(this.media)?K`<frigate-card-thumbnail-details-recording
            .media=${this.media??void 0}
            .cameraTitle=${s}
            .seek=${this.seek}
          ></frigate-card-thumbnail-details-recording>`:K``}
      ${i?K`<ha-icon
            class="timeline"
            icon="mdi:target"
            title=${Pm("thumbnail.timeline")}
            @click=${e=>{vm(e),this.view&&this.media&&this.view.evolve({view:"timeline",queryResults:this.view.queryResults?.clone().selectResultIfFound((e=>e===this.media))}).removeContext("timeline").dispatchChangeEvent(this)}}
          ></ha-icon>`:""}
      ${o?K` <ha-icon
            class="download"
            icon=${"mdi:download"}
            title=${Pm("thumbnail.download")}
            @click=${async e=>{if(vm(e),this.hass&&this.cameraManager&&this.media)try{await by(this.hass,this.cameraManager,this.media)}catch(e){Mv(this,e)}}}
          ></ha-icon>`:""}
    `}static get styles(){return b(":host {\n  display: flex;\n  flex-direction: row;\n  box-sizing: border-box;\n  position: relative;\n  overflow: hidden;\n  transition: transform 0.2s linear;\n}\n\n:host(:not([details])) {\n  aspect-ratio: 1/1;\n}\n\n:host([details]) {\n  border: 1px solid var(--primary-color);\n  border-radius: var(--frigate-card-css-border-radius, var(--ha-card-border-radius, 4px));\n  padding: 2px;\n  background-color: var(--primary-background-color, black);\n}\n\n:host(:hover) {\n  transform: scale(1.04);\n}\n\nha-icon {\n  position: absolute;\n  border-radius: 50%;\n  opacity: 0.5;\n  color: var(--primary-color);\n  cursor: pointer;\n  transition: opacity 0.2s ease-in-out, color 0.2s ease-in-out;\n}\n\nha-icon:hover {\n  opacity: 1;\n}\n\nha-icon.star {\n  top: 3px;\n  left: 3px;\n}\n\nha-icon.star.starred {\n  color: gold;\n}\n\nha-icon.timeline {\n  top: 3px;\n  right: 3px;\n}\n\nha-icon.download {\n  right: 3px;\n  bottom: 3px;\n}\n\nfrigate-card-thumbnail-details-event, frigate-card-thumbnail-details-recording {\n  flex: 1;\n}")}};e([be({attribute:!1})],Ey.prototype,"hass",void 0),e([be({attribute:!1})],Ey.prototype,"cameraManager",void 0),e([be({attribute:!0})],Ey.prototype,"media",void 0),e([be({attribute:!0,type:Boolean})],Ey.prototype,"details",void 0),e([be({attribute:!0,type:Boolean})],Ey.prototype,"show_favorite_control",void 0),e([be({attribute:!0,type:Boolean})],Ey.prototype,"show_timeline_control",void 0),e([be({attribute:!0,type:Boolean})],Ey.prototype,"show_download_control",void 0),e([be({attribute:!1})],Ey.prototype,"seek",void 0),e([be({attribute:!1})],Ey.prototype,"view",void 0),Ey=e([_e("frigate-card-thumbnail")],Ey);let My=class extends ge{constructor(){super(...arguments),this.direction="horizontal",this.selected=0,this._refSlot=Le(),this._scrolling=!1,this._reInitOnSettle=!1,this._carouselReInitInPlace=yr(this._carouselReInitInPlaceInternal.bind(this),500,{trailing:!0})}connectedCallback(){super.connectedCallback(),this.requestUpdate()}disconnectedCallback(){this._destroyCarousel(),super.disconnectedCallback()}willUpdate(e){["direction","carouselOptions","carouselPlugins"].some((t=>e.has(t)))&&this._destroyCarousel()}getCarouselSelected(){const e=this._carousel?.selectedScrollSnap(),t=void 0!==e?this._carousel?.slideNodes()[e]??null:null;return void 0!==e&&t?{index:e,element:t}:null}carousel(){return this._carousel??null}_carouselReInitInPlaceInternal(){(e=>{window.requestAnimationFrame((()=>{this._carousel?.reInit({...e})}))})({startIndex:this.selected})}carouselReInitWhenSafe(){this._scrolling?this._reInitOnSettle=!0:this._carouselReInitInPlace()}getCarouselPlugins(){return this._carousel?.plugins()??null}updated(e){super.updated(e),this._carousel||this._initCarousel(),e.has("selected")&&this._carousel?.scrollTo(this.selected,"none"===this.transitionEffect)}_destroyCarousel(){this._carousel&&this._carousel.destroy(),this._carousel=void 0}_initCarousel(){const e=this.renderRoot.querySelector(".embla__viewport"),t={root:e,slides:this._refSlot.value?.assignedElements({flatten:!0})};if(e&&t.slides){this._carousel=W_(t,{axis:"horizontal"==this.direction?"x":"y",speed:30,startIndex:this.selected,...this.carouselOptions},this.carouselPlugins);const e=()=>{const e=this.getCarouselSelected();e&&If(this,"carousel:select",e),this.requestUpdate()};this._carousel.on("init",e),this._carousel.on("select",e),this._carousel.on("scroll",(()=>{this._scrolling=!0})),this._carousel.on("settle",(()=>{this._scrolling=!1,this._reInitOnSettle&&(this._reInitOnSettle=!1,this._carouselReInitInPlace())})),this._carousel.on("settle",(()=>{const e=this.getCarouselSelected();e&&If(this,"carousel:settle",e)}))}}_slotChanged(){this._destroyCarousel(),this.requestUpdate()}render(){const e=this._refSlot.value?.assignedElements({flatten:!0})||[],t=this.carouselOptions?.loop||this.selected>0,n=this.carouselOptions?.loop||this.selected+1<e.length;return K` <div class="embla">
      ${t?K`<slot name="previous"></slot>`:""}
      <div class="embla__viewport">
        <div class="embla__container">
          <slot ${Fe(this._refSlot)} @slotchange=${this._slotChanged.bind(this)}></slot>
        </div>
      </div>
      ${n?K`<slot name="next"></slot>`:""}
    </div>`}static get styles(){return b(":host {\n  display: block;\n  height: 100%;\n  width: 100%;\n}\n\n.embla {\n  width: 100%;\n  height: 100%;\n  margin-left: auto;\n  margin-right: auto;\n}\n\n.embla__container {\n  display: flex;\n  width: 100%;\n  height: 100%;\n  user-select: none;\n  -webkit-touch-callout: none;\n  -khtml-user-select: none;\n  -webkit-tap-highlight-color: transparent;\n}\n\n:host([direction=vertical]) .embla__container {\n  flex-direction: column;\n}\n\n:host([direction=horizontal]) .embla__container {\n  flex-direction: row;\n}\n\n.embla__viewport {\n  width: 100%;\n  height: 100%;\n  overflow: hidden;\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n}\n\n.embla__viewport.is-draggable {\n  cursor: move;\n  cursor: grab;\n}\n\n.embla__viewport.is-dragging {\n  cursor: grabbing;\n}\n\n:host([direction=vertical]) ::slotted(.embla__slide) {\n  margin-bottom: 5px;\n}\n\n:host([direction=horizontal]) ::slotted(.embla__slide) {\n  margin-right: 5px;\n}")}};e([be({attribute:!0,reflect:!0})],My.prototype,"direction",void 0),e([be({attribute:!1})],My.prototype,"carouselOptions",void 0),e([be({attribute:!1})],My.prototype,"carouselPlugins",void 0),e([be({attribute:!1})],My.prototype,"selected",void 0),e([be({attribute:!0})],My.prototype,"transitionEffect",void 0),My=e([_e("frigate-card-carousel")],My);let Sy=class extends ge{constructor(){super(),this._refCarousel=Le(),this.selected=0,this._carouselOptions={containScroll:"keepSnaps",dragFree:!0},this._carouselPlugins=[dy({forceWheelAxis:"y"})],this._resizeObserver=new ResizeObserver(this._resizeHandler.bind(this))}_resizeHandler(){this._refCarousel.value?.carouselReInitWhenSafe()}connectedCallback(){super.connectedCallback(),this._resizeObserver.observe(this)}disconnectedCallback(){this._resizeObserver.disconnect(),super.disconnectedCallback()}_getSlides(){if(!this.view?.query||!this.view.queryResults?.hasResults())return[];const e=[];for(let t=0;t<this.view.queryResults.getResultsCount();++t){const n=this._renderThumbnail(t);n&&(e[t]=n)}return e}willUpdate(e){if(e.has("config")){this.config?.size&&this.style.setProperty("--frigate-card-thumbnail-size",`${this.config.size}px`);const e=this._getDirection();e?this.setAttribute("direction",e):this.removeAttribute("direction")}e.has("selected")&&this.style.setProperty("--frigate-card-carousel-thumbnail-opacity",void 0===this.selected?"1.0":"0.4")}_renderThumbnail(e){const t=this.view?.queryResults?.getResult(e)??null;if(!t||!this.view)return;const n={embla__slide:!0,"slide-selected":this.selected===e},i=this.view?.context?.mediaViewer?.seek;return K` <frigate-card-thumbnail
      class="${Ee(n)}"
      .cameraManager=${this.cameraManager}
      .hass=${this.hass}
      .media=${t}
      .view=${this.view}
      .seek=${i&&t.includesTime(i)?i:void 0}
      ?details=${!!this.config?.show_details}
      ?show_favorite_control=${this.config?.show_favorite_control}
      ?show_timeline_control=${this.config?.show_timeline_control}
      ?show_download_control=${this.config?.show_download_control}
      @click=${t=>{this.view&&this.view.queryResults&&If(this,"thumbnail-carousel:tap",{queryResults:this.view.queryResults.clone().selectResult(e)}),vm(t)}}
    >
    </frigate-card-thumbnail>`}_getDirection(){return"left"===this.config?.mode||"right"===this.config?.mode?"vertical":"above"===this.config?.mode||"below"===this.config?.mode?"horizontal":void 0}render(){const e=this._getSlides();if(e.length&&this.config&&"none"!==this.config.mode)return K`<frigate-card-carousel
      ${Fe(this._refCarousel)}
      direction=${c_(this._getDirection())}
      .selected=${this.selected??0}
      .carouselOptions=${this._carouselOptions}
      .carouselPlugins=${this._carouselPlugins}
    >
      ${e}
    </frigate-card-carousel>`}static get styles(){return b(":host {\n  --frigate-card-thumbnail-size-max: 175px;\n  --frigate-card-thumbnail-details-width: calc(\n    var(--frigate-card-thumbnail-size) + 200px\n  );\n}\n\n:host {\n  display: block;\n  width: 100%;\n  height: 100%;\n  --frigate-card-carousel-thumbnail-opacity: 1;\n}\n\n:host([direction=vertical]) {\n  height: 100%;\n}\n\n:host([direction=horizontal]) {\n  height: auto;\n}\n\n.embla__slide {\n  flex: 0 0 auto;\n  opacity: var(--frigate-card-carousel-thumbnail-opacity);\n}\n\n.embla__slide.slide-selected {\n  opacity: 1;\n}\n\nfrigate-card-thumbnail {\n  width: var(--frigate-card-thumbnail-size);\n  height: var(--frigate-card-thumbnail-size);\n  max-width: 100%;\n}\n\nfrigate-card-thumbnail[details] {\n  width: var(--frigate-card-thumbnail-details-width);\n}")}};e([be({attribute:!1})],Sy.prototype,"hass",void 0),e([be({attribute:!1})],Sy.prototype,"view",void 0),e([be({attribute:!1})],Sy.prototype,"cameraManager",void 0),e([be({attribute:!1})],Sy.prototype,"config",void 0),e([be({attribute:!1})],Sy.prototype,"selected",void 0),Sy=e([_e("frigate-card-thumbnail-carousel")],Sy);class Ty{constructor(e){this._queries=null,e&&(this._queries=e)}clone(){return Gi(this)}getQueries(){return this._queries}setQueries(e){this._queries=e}}class Ay extends Ty{convertToClipsQueries(){for(const e of this._queries??[])delete e.hasSnapshot,e.hasClip=!0}clone(){return Gi(this)}}class zy extends Ty{}class jy{static areEventQueries(e){return e instanceof Ay}static areRecordingQueries(e){return e instanceof zy}}class Oy{constructor(e){this.view=e.view,this.camera=e.camera,this.query=e.query??null,this.queryResults=e.queryResults??null,this.context=e.context??null}static isMajorMediaChange(e,t){return!e||!t||e.view!==t.view||e.camera!==t.camera||"live"===t.view&&e.context?.live?.overrides?.get(e.camera)!==t.context?.live?.overrides?.get(t.camera)||"live"!==t.view&&e.queryResults!==t.queryResults}static adoptFromViewIfAppropriate(e,t){if(!t)return;let n=null;if(jy.areEventQueries(t.query)){const e=t.query.getQueries();e?.every((e=>e.hasClip))?n="clips":e?.every((e=>e.hasSnapshot))&&(n="snapshots")}else jy.areRecordingQueries(t.query)&&(n="recordings");const i=!e.query||!e.queryResults,a=t.isViewerView()&&e.isGalleryView()&&e.view===n,r=t?.is("media")&&e.is("media");if(i&&(a?(t.query&&(e.query=t.query),t.queryResults&&(e.queryResults=t.queryResults)):r&&n&&(e.view="clips"===n?"clip":"snapshots"===n?"snapshot":"recording")),t.is("live")&&e.is("live")&&t.context?.live?.overrides&&!e.context?.live?.overrides){const n=e.context?.live??{};n.overrides=t.context.live.overrides,e.mergeInContext({live:n})}}clone(){return new Oy({view:this.view,camera:this.camera,query:this.query?.clone()??null,queryResults:this.queryResults?.clone()??null,context:this.context})}evolve(e){return new Oy({view:void 0!==e.view?e.view:this.view,camera:void 0!==e.camera?e.camera:this.camera,query:void 0!==e.query?e.query:this.query?.clone()??null,queryResults:void 0!==e.queryResults?e.queryResults:this.queryResults?.clone()??null,context:void 0!==e.context?e.context:this.context})}mergeInContext(e){return this.context={...this.context,...e},this}removeContext(e){return this.context&&delete this.context[e],this}is(e){return this.view==e}isGalleryView(){return["clips","snapshots","recordings"].includes(this.view)}isAnyMediaView(){return this.isViewerView()||this.is("live")||this.is("image")}isViewerView(){return["clip","snapshot","media","recording"].includes(this.view)}getDefaultMediaType(){return["clip","clips"].includes(this.view)?"clips":["snapshot","snapshots"].includes(this.view)?"snapshots":["recording","recordings"].includes(this.view)?"recordings":null}dispatchChangeEvent(e){If(e,"view:change",this)}}const Iy=(e,t)=>{If(e,"view:change-context",t)},Ry=document.createElement("template");Ry.innerHTML='<style>\n:host {\n  background-color: #ffffff;\n  width: 350px;\n  max-width: 75vw;\n\n  visibility: hidden;\n  transition: visibility 0.5s;\n}\n\n:host([open]) {\n  visibility: visible;\n}\n\n::slotted(div) {\n  box-sizing: border-box;\n}\n\n#d {\n  position: fixed;\n  z-index: 99;\n  background-color: inherit;\n  -webkit-overflow-scrolling: touch;\n  overflow: auto;\n  overscroll-behavior: contain;\n  backdrop-filter: var(--side-drawer-backdrop-filter, none);\n\n  top: 0;\n  bottom: 0;\n  left: 0;\n  height: 100%;\n  box-sizing: border-box;\n  transform: translateX(-100%);\n  transition: var(\n    --side-drawer-transition,\n    transform 0.25s ease-out\n  );\n  width: inherit;\n  max-width: inherit;\n  border-top-right-radius: inherit;\n  border-bottom-right-radius: inherit;\n}\n\n:host([open]) #d {\n  transform: none;\n  box-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.5);\n}\n\n#fs {\n  position: fixed;\n  z-index: 98;\n  background-color: #000000;\n  backdrop-filter: var(--side-drawer-backdrop-filter, none);\n\n  top: 0;\n  bottom: 0;\n  right: -30px; /* hide scrollbar until overscroll bug is fixed */\n  height: 100vh;\n  transition: var(\n    --side-drawer-overlay-transition,\n    opacity linear 0.25s\n  );\n  width: calc(\n    100vw + 30px\n  ); /* put back to just 100vw once overscroll bug fixed */\n  opacity: 0;\n  visibility: hidden;\n\n  overflow: auto;\n  overscroll-behavior: contain;\n}\n\n:host([open]) #fs {\n  opacity: var(--side-drawer-overlay-opacity, 0.7);\n  visibility: visible;\n}\n\n/*\n   * Workaround for bug https://bugs.chromium.org/p/chromium/issues/detail?id=813094\n   * Once bug is fixed and in the wild we can remove this element and make #if overflow:hidden\n   * and set "right: 0; width: 100vw" for #fs\n   */\n#ifs {\n  height: calc(100vh + 1px);\n}\n</style>\n<div id="d"><slot></slot></div>\n<div id="fs"><div id="ifs"></div></div>\n';class Dy extends HTMLElement{constructor(){super();const e=this.attachShadow({mode:"open"});e.appendChild(Ry.content.cloneNode(!0)),this._freeSpaceDiv=e.getElementById("fs")}connectedCallback(){this._freeSpaceDiv&&this._freeSpaceDiv.addEventListener("click",this.handleFreeSpaceDivClick),this.upgradeProperty("open")}disconnectedCallback(){document.removeEventListener("keyup",this.handleKeyUp)}upgradeProperty(e){if(this.hasOwnProperty(e)){let t=this[e];delete this[e],this[e]=t}}handleKeyUp=e=>{if(!e.altKey&&"Escape"===e.key)e.preventDefault(),this.open=!1};get open(){return this.hasAttribute("open")}set open(e){e?this.hasAttribute("open")||this.setAttribute("open",""):this.hasAttribute("open")&&this.removeAttribute("open")}static get observedAttributes(){return["open"]}attributeChangedCallback(e,t,n){"open"===e&&(this.open?(this.setAttribute("tabindex","0"),this.setAttribute("aria-disabled","false"),this.focus({preventScroll:!0}),document.addEventListener("keyup",this.handleKeyUp),this.dispatchEvent(new CustomEvent("open",{bubbles:!0}))):(this.setAttribute("tabindex","-1"),this.setAttribute("aria-disabled","true"),document.removeEventListener("keyup",this.handleKeyUp),this.dispatchEvent(new CustomEvent("close",{bubbles:!0}))))}handleFreeSpaceDivClick=()=>{this.open=!1}}customElements.define("side-drawer",Dy);let Py=class extends ge{constructor(){super(...arguments),this.location="left",this.control=!0,this.open=!1,this.empty=!0,this._refDrawer=Le(),this._refSlot=Le(),this._resizeObserver=new ResizeObserver((()=>this._hideDrawerIfNecessary())),this._isHoverableDevice=Uf()}firstUpdated(e){super.firstUpdated(e);const t=document.createElement("style");t.innerHTML=":host {\n  width: unset;\n}\n\n#fs {\n  display: none;\n  width: 100%;\n  inset: 0;\n}\n\n#d,\n#fs {\n  height: 100%;\n  position: absolute;\n}\n\n#d {\n  overflow: visible;\n  max-width: 90%;\n}\n\n:host([location=right]) #d {\n  left: unset;\n  right: 0;\n  transform: translateX(100%);\n}\n\n:host([location=right][open]) #d {\n  transform: none;\n  box-shadow: var(--frigate-card-css-box-shadow, 0px 0px 25px 0px black);\n}\n\n#ifs {\n  height: 100%;\n}",this._refDrawer.value?.shadowRoot?.appendChild(t)}_slotChanged(){const e=this._refSlot.value?.assignedElements({flatten:!0});this._resizeObserver.disconnect();for(const t of e??[])this._resizeObserver.observe(t);this._hideDrawerIfNecessary()}_hideDrawerIfNecessary(){if(!this._refDrawer.value)return;const e=this._refSlot.value?.assignedElements({flatten:!0});this.empty=!e||!e.length||e.every((e=>{const t=e.getBoundingClientRect();return!t.width||!t.height}))}render(){return K`
      <side-drawer
        ${Fe(this._refDrawer)}
        location="${this.location}"
        ?open=${this.open}
        @mouseleave=${()=>{this.open&&(this.open=!1)}}
      >
        ${this.control?K`
              <div
                class="control-surround"
                @click=${e=>{vm(e),this.open=!this.open}}
              >
                <ha-icon
                  class="control"
                  icon="${this.open?this.icons?.open??"mdi:menu-open":this.icons?.closed??"mdi:menu"}"
                  @mouseenter=${()=>{this._isHoverableDevice&&!this.open&&(this.open=!0)}}
                >
                </ha-icon>
              </div>
            `:""}
        <slot ${Fe(this._refSlot)} @slotchange=${()=>this._slotChanged()}></slot>
      </side-drawer>
    `}static get styles(){return b("side-drawer {\n  background-color: var(--card-background-color);\n}\n\ndiv.control-surround {\n  position: absolute;\n  bottom: 50%;\n  transform: translateY(50%);\n  z-index: 0;\n  padding-top: 20px;\n  padding-bottom: 20px;\n}\n\n:host([location=left]) div.control-surround {\n  padding-right: 12px;\n  left: 100%;\n}\n\n:host([location=right]) div.control-surround {\n  padding-left: 12px;\n  right: 100%;\n}\n\n:host([empty]), :host([empty]) > * {\n  visibility: hidden;\n}\n\n:host(:not([empty])), :host(:not([empty])) > * {\n  visibility: visible;\n}\n\nha-icon.control {\n  color: var(--secondary-color, white);\n  background-color: rgba(0, 0, 0, 0.7);\n  opacity: 0.5;\n  pointer-events: all;\n  --mdc-icon-size: 20px;\n  padding-top: 20px;\n  padding-bottom: 20px;\n  transition: opacity 0.5s ease;\n}\n\n:host([open]) ha-icon.control, ha-icon.control:hover {\n  opacity: 1;\n  background-color: black;\n}\n\n:host([location=left]) ha-icon.control {\n  border-top-right-radius: 20px;\n  border-bottom-right-radius: 20px;\n}\n\n:host([location=right]) ha-icon.control {\n  border-top-left-radius: 20px;\n  border-bottom-left-radius: 20px;\n}")}};e([be({attribute:!0,reflect:!0})],Py.prototype,"location",void 0),e([be({attribute:!0,reflect:!0,type:Boolean})],Py.prototype,"control",void 0),e([be({type:Boolean,reflect:!0,attribute:!0})],Py.prototype,"open",void 0),e([be({attribute:!1})],Py.prototype,"icons",void 0),e([be({type:Boolean,reflect:!0,attribute:!0})],Py.prototype,"empty",void 0),Py=e([_e("frigate-card-drawer")],Py);let Ly=class extends ge{constructor(){super(...arguments),this._refDrawerLeft=Le(),this._refDrawerRight=Le(),this._boundDrawerHandler=this._drawerHandler.bind(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("frigate-card:drawer:open",this._boundDrawerHandler),this.addEventListener("frigate-card:drawer:close",this._boundDrawerHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("frigate-card:drawer:open",this._boundDrawerHandler),this.removeEventListener("frigate-card:drawer:close",this._boundDrawerHandler)}_drawerHandler(e){const t=e.detail.drawer,n=e.type.endsWith(":open");"left"===t&&this._refDrawerLeft.value?this._refDrawerLeft.value.open=n:"right"===t&&this._refDrawerRight.value&&(this._refDrawerRight.value.open=n)}render(){return K` <slot name="above"></slot>
      <slot></slot>
      <frigate-card-drawer
        ${Fe(this._refDrawerLeft)}
        location="left"
        .icons=${this.drawerIcons?.left}
      >
        <slot name="left"></slot>
      </frigate-card-drawer>
      <frigate-card-drawer
        ${Fe(this._refDrawerRight)}
        location="right"
        .icons=${this.drawerIcons?.right}
      >
        <slot name="right"></slot>
      </frigate-card-drawer>
      <slot name="below"></slot>`}static get styles(){return b(":host {\n  width: 100%;\n  height: 100%;\n  display: flex;\n  flex-direction: column;\n  position: relative;\n  overflow: hidden;\n}\n\n::slotted(:not([slot])) {\n  flex: 1;\n  min-height: 0px;\n}")}};e([be({attribute:!1})],Ly.prototype,"drawerIcons",void 0),Ly=e([_e("frigate-card-surround-basic")],Ly);var Ny=4;class Uy{constructor(e,t){this._results=null,this._resultsTimestamp=null,this._selectedIndex=null,e&&this.setResults(e),void 0!==t&&this.selectResult(t)}clone(){return Bi(this,Ny)}isSupersetOf(e){if(!this._results||!e._results)return!1;const t=new Set(this._results.map((e=>e.getID()))),n=new Set(e._results.map((e=>e.getID())));return!(!t||!n||t.has(null)||n.has(null))&&((e,t)=>{for(const n of t)if(!e.has(n))return!1;return!0})(t,n)}getResults(){return this._results}getResultsCount(){return this._results?.length??0}hasResults(){return!!this._results}setResults(e){this._results=e,this._resultsTimestamp=new Date}getResult(e){return this._results&&void 0!==e?this._results[e]:null}getSelectedResult(){return null===this._selectedIndex?null:this.getResult(this._selectedIndex)}getSelectedIndex(){return this._selectedIndex}hasSelectedResult(){return null!==this.getSelectedResult()}resetSelectedResult(){return this._selectedIndex=null,this}getResultsTimestamp(){return this._resultsTimestamp}selectResult(e){return(null===e||this._results&&e>=0&&e<this._results.length)&&(this._selectedIndex=e),this}selectResultIfFound(e){for(const[t,n]of this._results?.entries()??[])if(e(n)){this._selectedIndex=t;break}return this}selectBestResult(e){if(this._results){const t=e(this._results);null!==t&&(this._selectedIndex=t)}return this}}const Fy=async(e,t,n,i,a,r)=>{const o=pv(n,a.camera);if(!o)return;const s=Hy(n,i,o,{mediaType:r?.mediaType});s&&(await Vy(e,t,n,a,s,{targetView:r?.targetView,select:r?.select}))?.dispatchChangeEvent(e)},Hy=(e,t,n,i)=>{const a=t.performance?.features.media_chunk_size??50,r=e.generateDefaultEventQueries(n,{limit:a,..."clips"===i?.mediaType&&{hasClip:!0},..."snapshots"===i?.mediaType&&{hasSnapshot:!0}});return r?new Ay(r):null},Zy=async(e,t,n,i,a,r)=>{const o=pv(n,a.camera);if(!o)return;const s=qy(n,i,o);s&&(await Vy(e,t,n,a,s,{targetView:r?.targetView,select:r?.select}))?.dispatchChangeEvent(e)},qy=(e,t,n,i)=>{const a=t.performance?.features.media_chunk_size??50,r=e.generateDefaultRecordingQueries(n,{limit:a,...i?.start&&{start:i.start},...i?.end&&{end:i.end}});return r?new zy(r):null},Vy=async(e,t,n,i,a,r)=>{let o;const s=a.getQueries();if(!s)return null;try{o=await n.executeMediaQueries(t,s)}catch(t){return Nf(t),Mv(e,t),null}if(!o)return null;const c=new Uy(o,"latest"===r?.select&&o.length?o.length-1:void 0);let l={};return"time"===r?.select&&r?.targetTime&&(c.selectBestResult((e=>Wy(e,r.targetTime))),l={mediaViewer:{seek:r.targetTime}}),i?.evolve({query:a,queryResults:c,view:r?.targetView,camera:r?.targetCameraID}).mergeInContext(l)??null},Wy=(e,t)=>{let n;for(const[i,a]of e.entries()){const e=a.getStartTime(),r=a.getUsableEndTime();if(a.includesTime(t)&&e&&r){const t=r.getTime()-e.getTime();(!n||t>n.duration)&&(n={index:i,duration:t})}}return n?n.index:null};let By=class extends ge{async _fetchMedia(){this.cameraManager&&this.cardWideConfig&&this.fetchMedia&&this.hass&&this.view&&!this.view.query&&this.thumbnailConfig&&"none"!==this.thumbnailConfig.mode&&(this.view.context?.thumbnails?.fetch??1)&&await Fy(this,this.hass,this.cameraManager,this.cardWideConfig,this.view,{targetView:this.view.view,mediaType:this.fetchMedia,select:"latest"})}_hasDrawer(){return!!this.thumbnailConfig&&["left","right"].includes(this.thumbnailConfig.mode)}willUpdate(e){this.timelineConfig?.mode&&"none"!==this.timelineConfig.mode&&import("./timeline-6aa9e747.js"),e.has("view")&&Oy.isMajorMediaChange(e.get("view"),this.view)&&(this._cameraIDsForTimeline=this._getCameraIDsForTimeline()??void 0),["view","fetch","browseMediaParams"].some((t=>e.has(t)))&&this._fetchMedia()}_getCameraIDsForTimeline(){return this.view?this.view?.is("live")?pv(this.cameraManager,this.view.camera):this.view.isViewerView()?new Set(this.view.query?.getQueries()?.map((e=>[...e.cameraIDs])).flat()):null:null}render(){if(!this.hass||!this.view)return;const e=(e,t)=>{this.thumbnailConfig&&this._hasDrawer()&&If(e.composedPath()[0],"drawer:"+t,{drawer:this.thumbnailConfig.mode})};return K` <frigate-card-surround-basic
      @frigate-card:thumbnails:open=${t=>e(t,"open")}
      @frigate-card:thumbnails:close=${t=>e(t,"close")}
    >
      ${this.thumbnailConfig&&"none"!==this.thumbnailConfig.mode?K` <frigate-card-thumbnail-carousel
            slot=${this.thumbnailConfig.mode}
            .hass=${this.hass}
            .config=${this.thumbnailConfig}
            .cameraManager=${this.cameraManager}
            .view=${this.view}
            .selected=${this.view.queryResults?.getSelectedIndex()??void 0}
            @frigate-card:view:change=${t=>e(t,"close")}
            @frigate-card:thumbnail-carousel:tap=${e=>{const t=e.detail.queryResults.getSelectedResult();t&&this.view?.evolve({view:"media",queryResults:e.detail.queryResults,...t.getCameraID()&&{camera:t.getCameraID()}}).removeContext("timeline").dispatchChangeEvent(e.composedPath()[0])}}
          >
          </frigate-card-thumbnail-carousel>`:""}
      ${this.timelineConfig&&"none"!==this.timelineConfig.mode?K` <frigate-card-timeline-core
            slot=${this.timelineConfig.mode}
            .hass=${this.hass}
            .view=${this.view}
            .itemClickAction=${this.view.isViewerView()||!this.thumbnailConfig||"none"===this.thumbnailConfig?.mode?"play":"select"}
            .cameraIDs=${this._cameraIDsForTimeline}
            .mini=${!0}
            .timelineConfig=${this.timelineConfig}
            .thumbnailConfig=${this.thumbnailConfig}
            .cameraManager=${this.cameraManager}
            .cardWideConfig=${this.cardWideConfig}
          >
          </frigate-card-timeline-core>`:""}
      <slot></slot>
    </frigate-card-surround-basic>`}static get styles(){return b(":host {\n  width: 100%;\n  height: 100%;\n  display: block;\n}")}};e([be({attribute:!1})],By.prototype,"hass",void 0),e([be({attribute:!1})],By.prototype,"view",void 0),e([be({attribute:!1,hasChanged:Lf})],By.prototype,"thumbnailConfig",void 0),e([be({attribute:!1,hasChanged:Lf})],By.prototype,"timelineConfig",void 0),e([be({attribute:!1,hasChanged:Lf})],By.prototype,"fetchMedia",void 0),e([be({attribute:!1})],By.prototype,"cameraManager",void 0),e([be({attribute:!1})],By.prototype,"cardWideConfig",void 0),By=e([_e("frigate-card-surround")],By);let Yy=class extends ge{willUpdate(e){(e.has("view")||e.has("config"))&&((this.view?.is("live")||this._shouldLivePreload())&&import("./live-e0c9196c.js"),this.view?.isGalleryView()?import("./gallery-6281c347.js"):this.view?.isViewerView()?import("./viewer-b95bc789.js"):this.view?.is("image")?import("./image-0b99ab11.js"):this.view?.is("timeline")&&import("./timeline-6aa9e747.js")),e.has("hide")&&(this.hide?this.setAttribute("hidden",""):this.removeAttribute("hidden"))}shouldUpdate(e){return!0}_shouldLivePreload(){return!!this.config?.live.preload}render(){if(!this.hass||!this.config||!this.nonOverriddenConfig)return K``;const e={hidden:this._shouldLivePreload()&&!this.view?.is("live")},t={hidden:!!this.hide},n=this.view?.is("live")?this.config.live.controls.thumbnails:this.view?.isViewerView()?this.config.media_viewer.controls.thumbnails:this.view?.is("timeline")?this.config.timeline.controls.thumbnails:void 0,i=this.view?.is("live")?this.config.live.controls.timeline:this.view?.isViewerView()?this.config.media_viewer.controls.timeline:void 0,a=this.view?this.cameraManager?.getStore().getCameraConfig(this.view.camera)??null:null;return K` <frigate-card-surround
      class="${Ee(t)}"
      .hass=${this.hass}
      .view=${this.view}
      .fetchMedia=${this.view?.is("live")?this.config.live.controls.thumbnails.media:void 0}
      .thumbnailConfig=${this.hide?void 0:n}
      .timelineConfig=${this.hide?void 0:i}
      .cameraManager=${this.cameraManager}
      .cardWideConfig=${this.cardWideConfig}
    >
      ${!this.hide&&this.view?.is("image")&&a?K` <frigate-card-image
            .imageConfig=${this.config.image}
            .view=${this.view}
            .hass=${this.hass}
            .cameraConfig=${a}
            .supportZoom=${!0}
          >
          </frigate-card-image>`:""}
      ${!this.hide&&this.view?.isGalleryView()?K` <frigate-card-gallery
            .hass=${this.hass}
            .view=${this.view}
            .galleryConfig=${this.config.media_gallery}
            .cameraManager=${this.cameraManager}
            .cardWideConfig=${this.cardWideConfig}
          >
          </frigate-card-gallery>`:""}
      ${!this.hide&&this.view?.isViewerView()?K`
            <frigate-card-viewer
              .hass=${this.hass}
              .view=${this.view}
              .viewerConfig=${this.config.media_viewer}
              .resolvedMediaCache=${this.resolvedMediaCache}
              .cameraManager=${this.cameraManager}
              .cardWideConfig=${this.cardWideConfig}
            >
            </frigate-card-viewer>
          `:""}
      ${!this.hide&&this.view?.is("timeline")?K` <frigate-card-timeline
            .hass=${this.hass}
            .view=${this.view}
            .timelineConfig=${this.config.timeline}
            .cameraManager=${this.cameraManager}
            .cardWideConfig=${this.cardWideConfig}
          >
          </frigate-card-timeline>`:""}
      ${this._shouldLivePreload()||!this.hide&&this.view?.is("live")?K`
              <frigate-card-live
                .hass=${this.hass}
                .view=${this.view}
                .liveConfig=${this.nonOverriddenConfig.live}
                .conditionControllerEpoch=${this.conditionControllerEpoch}
                .liveOverrides=${r="live",o=this.config.overrides,o?.filter((e=>r in e.overrides)).map((e=>({conditions:e.conditions,overrides:e.overrides[r]})))??[]}
                .cameraManager=${this.cameraManager}
                .cardWideConfig=${this.cardWideConfig}
                .microphoneStream=${this.microphoneStream}
                class="${Ee(e)}"
              >
              </frigate-card-live>
            `:""}
    </frigate-card-surround>`;var r,o}static get styles(){return b(":host {\n  width: 100%;\n  height: 100%;\n  display: block;\n}\n\n:host([hidden]),\n.hidden {\n  display: none;\n}")}};e([be({attribute:!1})],Yy.prototype,"hass",void 0),e([be({attribute:!1})],Yy.prototype,"view",void 0),e([be({attribute:!1})],Yy.prototype,"cameraManager",void 0),e([be({attribute:!1})],Yy.prototype,"config",void 0),e([be({attribute:!1})],Yy.prototype,"nonOverriddenConfig",void 0),e([be({attribute:!1})],Yy.prototype,"cardWideConfig",void 0),e([be({attribute:!1})],Yy.prototype,"resolvedMediaCache",void 0),e([be({attribute:!1})],Yy.prototype,"conditionControllerEpoch",void 0),e([be({attribute:!1})],Yy.prototype,"hide",void 0),e([be({attribute:!1})],Yy.prototype,"microphoneStream",void 0),Yy=e([_e("frigate-card-views")],Yy);const Qy={[Il]:"none",[sl]:"none",[bd]:"none",[Zl]:!1,[gl]:!1,[_d]:!1,[Sl]:"never",[Gc]:"never",[Kc]:"never",[Xc]:"never",[Jl]:"all",[Kl]:!1,[el]:!1,[td]:"none",[il]:"none",[nd]:!1,[rl]:"chevrons",[bl]:"none",[Wl]:"none",[Td]:"outside",[`${Rd}.enabled`]:!1,[`${Hd}.enabled`]:!1,[`${Hd}.enabled`]:!1,[`${Ud}.enabled`]:!1,[Vc]:!1,[Wc]:!1,[Bc]:!1,[qc]:!1,[Pl]:!1,[Ll]:!1,[Nl]:!1,[Dl]:!1,[ll]:!1,[dl]:!1,[ul]:!1,[cl]:!1,[Cd]:!1,[$d]:!1,[kd]:!1,[xd]:!1,[Gd]:!1,[Kd]:10,[eu]:!1,[Jd]:!1,[nl]:!1,[Mc]:!1,[Sc]:10},Gy=(e,t)=>{const n=iu(om).safeParse(e);if(n.success){const e=n.data;Object.entries(Qy).forEach((([n,i])=>((e,t,n,i)=>{void 0===Av(e,n)&&Tv(t,n,i)})(e,t,n,i)))}return t},Ky={box_shadow:"none",border_radius:"0px"};const Xy=Ws.object({model:Ws.string().nullable(),config_entries:Ws.string().array(),manufacturer:Ws.string().nullable()}).array();class Jy{constructor(){this._cache=new Map}has(e){return this._cache.has(e)}getMatches(e){return[...this._cache.values()].filter(e)}get(e){return this._cache.get(e)}set(e){const t=e=>this._cache.set(e.entity_id,e);Array.isArray(e)?e.forEach(t):t(e)}}const eb=Ws.object({config_entry_id:Ws.string().nullable(),device_id:Ws.string().nullable(),disabled_by:Ws.string().nullable(),entity_id:Ws.string(),hidden_by:Ws.string().nullable(),platform:Ws.string(),translation_key:Ws.string().nullable(),unique_id:Ws.string().or(Ws.number()).optional()}),tb=eb.array();class nb{constructor(e){this._fetchedEntityList=!1,this._cache=e}async getEntity(e,t){const n=this._cache.get(t);if(n)return n;const i=await cp(e,eb,{type:"config/entity_registry/get",entity_id:t});return this._cache.set(i),i}async getMatchingEntities(e,t){return await this.fetchEntityList(e),this._cache.getMatches(t)}async getEntities(e,t){const n=new Map;return await Promise.all(t.map((async t=>{let i=null;try{i=await this.getEntity(e,t)}catch{return}i&&n.set(t,i)}))),n}async fetchEntityList(e){if(this._fetchedEntityList)return;const t=await cp(e,tb,{type:"config/entity_registry/list"});this._cache.set(t),this._fetchedEntityList=!0}}class ib extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if("function"==typeof this.onEviction)for(const[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(e,t.value),this.delete(e))}_getOrDeleteIfExpired(e,t){if(!1===this._deleteIfExpired(e,t))return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield e)}}for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(!1===this._deleteIfExpired(e,t))return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){const i="number"==typeof n&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;this.cache.has(e)?this.cache.set(e,{value:t,expiry:i}):this._set(e,{value:t,expiry:i})}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):!!this.oldCache.has(e)&&!this._deleteIfExpired(e,this.oldCache.get(e))}peek(e){return this.cache.has(e)?this._peek(e,this.cache):this.oldCache.has(e)?this._peek(e,this.oldCache):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const n=e[t],[i,a]=n;!1===this._deleteIfExpired(i,a)&&(yield[i,a.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){const n=e[t],[i,a]=n;if(!this.cache.has(i)){!1===this._deleteIfExpired(i,a)&&(yield[i,a.value])}}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[n,i]of this.entriesAscending())e.call(t,i,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}class ab{constructor(){this._cache=new ib({maxSize:1e3})}has(e){return this._cache.has(e)}get(e){return this._cache.get(e)}set(e,t){this._cache.set(e,t)}}const rb=async(e,t,n)=>{const i=n?n.get(t):void 0;if(i)return i;const a={type:"media_source/resolve_media",media_content_id:t};let r=null;try{r=await cp(e,lm,a)}catch(e){Nf(e)}return n&&r&&n.set(t,r),r};var ob;!function(e){e.INITIALIZING="initializing",e.INITIALIZED="initialized"}(ob||(ob={}));class sb{constructor(){this._state=new Map}async initializeMultipleIfNecessary(e){return(await Vf(Object.entries(e),(async([e,t])=>this.initializeIfNecessary(e,t)))).every(Boolean)}async initializeIfNecessary(e,t){const n=this._state.get(e);return n===ob.INITIALIZED||n!==ob.INITIALIZING&&(t?(this._state.set(e,ob.INITIALIZING),await t(),this._state.set(e,ob.INITIALIZED)):this._state.set(e,ob.INITIALIZED),!0)}uninitialize(e){return this._state.delete(e)}isInitialized(e){return this._state.get(e)==ob.INITIALIZED}isInitializedMultiple(e){return e.every((e=>this.isInitialized(e)))}}class cb{constructor(){this._current=null,this._lastKnown=null}set(e){this._current=e,this._lastKnown=e}get(){return this._current}getLastKnown(){return this._lastKnown}clear(){this._current=null}has(){return!!this._current}}const lb=50,db=lb;function ub(e,t){let n;return n=e instanceof Event?e.composedPath()[0]:e,n instanceof HTMLImageElement?{width:n.naturalWidth,height:n.naturalHeight,...t}:n instanceof HTMLVideoElement?{width:n.videoWidth,height:n.videoHeight,...t}:n instanceof HTMLCanvasElement?{width:n.width,height:n.height,player:t?.player,...t}:null}function hb(e,t,n){const i=ub(t,n);i&&mb(e,i)}function mb(e,t){If(e,"media:loaded",t)}function pb(e){If(e,"media:unloaded")}function fb(e){If(e,"media:volumechange")}function gb(e){If(e,"media:play")}function vb(e){If(e,"media:pause")}function _b(e){return e.height>=lb&&e.width>=db}const yb=e=>{const t=e?.context?.live?.overrides?.get(e.camera);return!!t&&t!==e.camera};class bb{constructor(){this._dynamicMenuButtons=[]}addDynamicMenuButton(e){this._dynamicMenuButtons.includes(e)||this._dynamicMenuButtons.push(e)}removeDynamicMenuButton(e){this._dynamicMenuButtons=this._dynamicMenuButtons.filter((t=>t!=e))}calculateButtons(e,t,n,i,a,r){const o=n.getStore().getVisibleCameras(),s=i.camera,c=n.getStore().getCameraConfig(s),l=pv(n,s),d=i.queryResults?.getSelectedResult(),u=n.getAggregateCameraCapabilities(l),h=d?n?.getMediaCapabilities(d):null,m=[];if(m.push({icon:nu,...t.menu.buttons.frigate,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.frigate"),tap_action:"hidden"===t.menu?.style?hm("menu_toggle"):hm("default"),hold_action:hm("diagnostics")}),o){const i=Array.from(o,(([t,i])=>{const a=hm("camera_select",{camera:t}),r=n.getCameraMetadata(e,t)??void 0;return{enabled:!0,icon:r?.icon,entity:i.camera_entity,state_color:!0,title:r?.title,selected:s===t,...a&&{tap_action:a}}}));m.push({icon:"mdi:video-switch",...t.menu.buttons.cameras,type:"custom:frigate-card-menu-submenu",title:Pm("config.menu.buttons.cameras"),items:i})}if(s&&l&&i.is("live")){const a=[...l],r=i.context?.live?.overrides?.get(s);if(2===a.length)m.push({icon:"mdi:video-input-component",style:r&&r!==s?this._getEmphasizedStyle():{},title:Pm("config.menu.buttons.substreams"),...t.menu.buttons.substreams,type:"custom:frigate-card-menu-icon",tap_action:hm(yb(i)?"live_substream_off":"live_substream_on")});else if(a.length>2){const o=Array.from(a,(t=>{const a=hm("live_substream_select",{camera:t}),r=n.getCameraMetadata(e,t)??void 0,o=n.getStore().getCameraConfig(t);return{enabled:!0,icon:r?.icon,entity:o?.camera_entity,state_color:!0,title:r?.title,selected:(i.context?.live?.overrides?.get(s)??s)===t,...a&&{tap_action:a}}}));m.push({icon:"mdi:video-input-component",title:Pm("config.menu.buttons.substreams"),style:r&&r!==s?this._getEmphasizedStyle():{},...t.menu.buttons.substreams,type:"custom:frigate-card-menu-submenu",items:o})}}if(m.push({icon:"mdi:cctv",...t.menu.buttons.live,type:"custom:frigate-card-menu-icon",title:Pm("config.view.views.live"),style:i.is("live")?this._getEmphasizedStyle():{},tap_action:hm("live")}),u?.supportsClips&&m.push({icon:"mdi:filmstrip",...t.menu.buttons.clips,type:"custom:frigate-card-menu-icon",title:Pm("config.view.views.clips"),style:i?.is("clips")?this._getEmphasizedStyle():{},tap_action:hm("clips"),hold_action:hm("clip")}),u?.supportsSnapshots&&m.push({icon:"mdi:camera",...t.menu.buttons.snapshots,type:"custom:frigate-card-menu-icon",title:Pm("config.view.views.snapshots"),style:i?.is("snapshots")?this._getEmphasizedStyle():{},tap_action:hm("snapshots"),hold_action:hm("snapshot")}),u?.supportsRecordings&&m.push({icon:"mdi:album",...t.menu.buttons.recordings,type:"custom:frigate-card-menu-icon",title:Pm("config.view.views.recordings"),style:i.is("recordings")?this._getEmphasizedStyle():{},tap_action:hm("recordings"),hold_action:hm("recording")}),m.push({icon:"mdi:image",...t.menu.buttons.image,type:"custom:frigate-card-menu-icon",title:Pm("config.view.views.image"),style:i?.is("image")?this._getEmphasizedStyle():{},tap_action:hm("image")}),u?.supportsTimeline&&m.push({icon:"mdi:chart-gantt",...t.menu.buttons.timeline,type:"custom:frigate-card-menu-icon",title:Pm("config.view.views.timeline"),style:i.is("timeline")?this._getEmphasizedStyle():{},tap_action:hm("timeline")}),h?.canDownload&&!this._isBeingCasted()&&m.push({icon:"mdi:download",...t.menu.buttons.download,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.download"),tap_action:hm("download")}),r?.cameraURL&&m.push({icon:"mdi:web",...t.menu.buttons.camera_ui,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.camera_ui"),tap_action:hm("camera_ui")}),r?.microphoneController&&r?.currentMediaLoadedInfo?.capabilities?.supports2WayAudio){const e=r.microphoneController.isForbidden(),n=r.microphoneController.isMuted(),i=t.menu.buttons.microphone.type;m.push({icon:e?"mdi:microphone-message-off":n?"mdi:microphone-off":"mdi:microphone",...t.menu.buttons.microphone,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.microphone"),style:e||n?{}:this._getEmphasizedStyle(!0),...!e&&"momentary"===i&&{start_tap_action:hm("microphone_unmute"),end_tap_action:hm("microphone_mute")},...!e&&"toggle"===i&&{tap_action:hm(r.microphoneController.isMuted()?"microphone_unmute":"microphone_mute")}})}if($r.isEnabled&&!this._isBeingCasted()&&m.push({icon:$r.isFullscreen?"mdi:fullscreen-exit":"mdi:fullscreen",...t.menu.buttons.fullscreen,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.fullscreen"),tap_action:hm("fullscreen"),style:$r.isFullscreen?this._getEmphasizedStyle():{}}),m.push({icon:a?"mdi:arrow-collapse-all":"mdi:arrow-expand-all",...t.menu.buttons.expand,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.expand"),tap_action:hm("expand"),style:a?this._getEmphasizedStyle():{}}),r?.mediaPlayers?.length&&(i?.isViewerView()||i.is("live")&&c?.camera_entity)){const n=r.mediaPlayers.map((t=>{const n=vp(e,t)||t,i=e.states[t],a=hm("media_player",{media_player:t,media_player_action:"play"}),r=hm("media_player",{media_player:t,media_player_action:"stop"}),o=!i||"unavailable"===i.state;return{enabled:!0,selected:!1,icon:_p(e,t),entity:t,state_color:!1,title:n,disabled:o,...!o&&a&&{tap_action:a},...!o&&r&&{hold_action:r}}}));m.push({icon:"mdi:cast",...t.menu.buttons.media_player,type:"custom:frigate-card-menu-submenu",title:Pm("config.menu.buttons.media_player"),items:n})}if(r?.currentMediaLoadedInfo&&r.currentMediaLoadedInfo.player){if(r.currentMediaLoadedInfo.capabilities?.supportsPause){const e=r.currentMediaLoadedInfo.player.isPaused();m.push({icon:e?"mdi:play":"mdi:pause",...t.menu.buttons.play,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.play"),tap_action:hm(e?"play":"pause")})}if(r.currentMediaLoadedInfo.capabilities?.hasAudio){const e=r.currentMediaLoadedInfo.player.isMuted();m.push({icon:e?"mdi:volume-off":"mdi:volume-high",...t.menu.buttons.mute,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.mute"),tap_action:hm(e?"unmute":"mute")})}}r?.currentMediaLoadedInfo&&r.currentMediaLoadedInfo.player&&m.push({icon:"mdi:monitor-screenshot",...t.menu.buttons.screenshot,type:"custom:frigate-card-menu-icon",title:Pm("config.menu.buttons.screenshot"),tap_action:hm("screenshot")});const p=this._dynamicMenuButtons.map((e=>({style:this._getStyleFromActions(t,i,e),...e})));return m.concat(p)}_getEmphasizedStyle(e){return e?{animation:"pulse 3s infinite",color:"var(--error-color, white)"}:{color:"var(--primary-color, white)"}}_getStyleFromActions(e,t,n){for(const i of[n.tap_action,n.double_tap_action,n.hold_action,n.start_tap_action,n.end_tap_action]){const n=Array.isArray(i)?i:[i];for(const i of n){if(!i||"fire-dom-event"!==i.action||!("frigate_card_action"in i))continue;const n=i;if(du.some((e=>e===n.frigate_card_action&&t?.is(n.frigate_card_action)))||"default"===n.frigate_card_action&&t.is(e.view.default)||"fullscreen"===n.frigate_card_action&&$r.isEnabled&&$r.isFullscreen||"camera_select"===n.frigate_card_action&&t.camera===n.camera)return this._getEmphasizedStyle()}}return{}}_isBeingCasted(){return!!navigator.userAgent.match(/CrKey\//)}}class wb{constructor(e){this._timer=new _m,this._mute=!0,this._disconnectSeconds=e??0}async connect(){try{this._stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}catch(e){Nf(e),this._stream=null}this._setMute()}async disconnect(){this._stream?.getTracks().forEach((e=>e.stop())),this._stream=void 0}getStream(){return this._stream??void 0}_setMute(){this._stream?.getTracks().forEach((e=>{e.enabled=!this._mute})),this._startTimer()}mute(){this._mute=!0,this._setMute()}unmute(){this._mute=!1,this._setMute()}isConnected(){return!!this._stream}isForbidden(){return null===this._stream}isMuted(){return!this._stream||this._stream.getTracks().every((e=>!e.enabled))}_startTimer(){this._disconnectSeconds&&this._timer.start(this._disconnectSeconds,(()=>{this.disconnect()}))}}const xb=()=>{const e=new URLSearchParams(window.location.search),t=[],n=new RegExp(/^frigate-card-action(:(?<cardID>\w+))?:(?<action>\w+)/);for(const[i,a]of e.entries()){const e=i.match(n);if(!e||!e.groups)continue;const r=e.groups.cardID,o=e.groups.action;let s=null;switch(o){case"camera_select":case"live_substream_select":a&&(s=hm(o,{camera:a,cardID:r}));break;case"camera_ui":case"clip":case"clips":case"default":case"diagnostics":case"download":case"expand":case"image":case"live":case"menu_toggle":case"recording":case"recordings":case"snapshot":case"snapshots":case"timeline":s=hm(o,{cardID:r});break;default:console.warn(`Frigate card received unknown card action in query string: ${o}`)}s&&t.push(s)}return t},Cb=e=>{const t=document.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;const n=t.getContext("2d");return n?(n.drawImage(e,0,0,t.width,t.height),t.toDataURL("image/jpeg")):null};var $b;console.info(`%c FRIGATE-HASS-CARD \n%c ${Pm("common.version")} ${Lr} `,"color: pink; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"frigate-card",name:Pm("common.frigate_card"),description:Pm("common.frigate_card_description"),preview:!0,documentationURL:Bs}),function(e){e.LANGUAGES="languages",e.SIDE_LOAD_ELEMENTS="side-load-elements",e.MEDIA_PLAYERS="media-players",e.CAMERAS="cameras",e.MICROPHONE="microphone"}($b||($b={}));let kb=class extends ge{constructor(){super(),this._panel=!1,this._expand=!1,this._menuButtonController=new bb,this._mediaLoadedInfoController=new cb,this._refMenu=Le(),this._refMain=Le(),this._refElements=Le(),this._refViews=Le(),this._interactionTimer=new _m,this._updateTimer=new _m,this._untriggerTimer=new _m,this._message=null,this._resolvedMediaCache=new ab,this._boundMouseHandler=yr(this._mouseHandler.bind(this),1e3),this._boundCardActionEventHandler=this._cardActionEventHandler.bind(this),this._boundFullscreenHandler=this._fullscreenHandler.bind(this),this._triggers=new Map,this._initializer=new sb,this._locationChangeHandler=()=>{this.hasUpdated&&xb().forEach((e=>this._cardActionHandler(e)))},this._entityRegistryManager=new nb(new Jy)}set hass(e){this._hass=e,this._hass&&(this._refMenu.value&&(this._refMenu.value.hass=this._hass),this._refElements.value&&(this._refElements.value.hass=this._hass),this._refViews.value&&(this._refViews.value.hass=this._hass)),this._conditionController?.hasHAStateConditions&&this._conditionController.setState({state:this._hass.states}),this._setLightOrDarkMode()}static async getConfigElement(){return await import("./editor-7b16019d.js"),document.createElement("frigate-card-editor")}static getStubConfig(e,t){return{cameras:[{camera_entity:t.find((e=>e.startsWith("camera.")))}]}}_requestUpdateForComponentsThatUseConditions(){this._refViews.value&&(this._refViews.value.conditionControllerEpoch=this._conditionController?.getEpoch()),this._refElements.value&&(this._refElements.value.conditionControllerEpoch=this._conditionController?.getEpoch())}_overrideConfig(){if(!this._conditionController)return;const e=Kv(this._conditionController,this._config,this._config.overrides);Aa(e,this._overriddenConfig)||(Aa(e.cameras,this._overriddenConfig?.cameras)&&Aa(e.cameras_global,this._overriddenConfig?.cameras_global)||this._initializer.uninitialize($b.CAMERAS),this._overriddenConfig=e)}_getSelectedCameraConfig(){return this._view&&this._cameraManager?this._cameraManager.getStore().getCameraConfig(this._view.camera):null}setConfig(e){if(!e)throw new Error(Pm("error.invalid_configuration"));const t=om.safeParse(e);if(!t.success){const n=Ov(e),i=ru(t.error);let a="";throw n&&"yaml"!==p().mode&&(a=`${Pm("error.upgrade_available")}. `),new Error(a+`${Pm("error.invalid_configuration")}: `+(i&&i.size?JSON.stringify([...i],null," "):Pm("error.invalid_configuration_no_hint")))}const n="low"!==t.data.performance.profile?t.data:Gy(e,t.data);n.test_gui&&p().setEditMode(!0),this._rawConfig=e,this._config=n,this._cardWideConfig={performance:n.performance,debug:n.debug},this._overriddenConfig=void 0,this._cameraManager=void 0,this._view=void 0,this._message=null,this._setupConditionController(),this._automationsController=new Nm(this._config.automations),this._setLightOrDarkMode(),this._setPropertiesForMinMaxHeight(),this._untrigger()}_setupConditionController(){this._conditionController?.destroy(),this._conditionController=new Xv(this._config),this._conditionController.addStateListener(this._overrideConfig.bind(this)),this._conditionController.addStateListener(this._requestUpdateForComponentsThatUseConditions.bind(this)),this._conditionController.addStateListener(this._executeAutomations.bind(this)),this._conditionController.setState({view:void 0,fullscreen:this._isInFullscreen(),expand:this._expand,camera:void 0,...this._hass&&this._conditionController?.hasHAStateConditions&&{state:this._hass.states},media_loaded:this._mediaLoadedInfoController.has()})}_executeAutomations(){if("error"!==this._message?.type&&this._hass&&this._conditionController)try{this._automationsController?.execute(this,this._hass,this._conditionController)}catch(e){this._handleThrownError(e)}}_getConfig(){return this._overriddenConfig||this._config}_changeView(e){hv(this._cardWideConfig,"Frigate Card view change: ",e?.view??e?.viewName??"[default]");const t=e=>{Oy.isMajorMediaChange(this._view,e)&&this._mediaLoadedInfoController.clear(),this._view?.view!==e.view&&this._resetMainScroll(),Oy.adoptFromViewIfAppropriate(e,this._view),this._view=e,this._conditionController?.setState({view:this._view.view,camera:this._view.camera})};if((e?.resetMessage??1)&&(this._message=null),e?.view)t(e.view);else{let n=null;if(this._cameraManager){const t=this._cameraManager.getStore().getVisibleCameras();if(t)if(e?.cameraID&&t.has(e.cameraID))n=e.cameraID;else if(this._view?.camera&&this._getConfig().view.update_cycle_camera){const e=Array.from(t.keys()),i=e.indexOf(this._view.camera);n=e[i+1>=e.length?0:i+1]}else n=t.keys().next().value}n&&(t(new Oy({view:e?.viewName??this._getConfig().view.default,camera:n})),this._startUpdateTimer())}}_setLightOrDarkMode(){"on"===this._getConfig().view.dark_mode||"auto"===this._getConfig().view.dark_mode&&(!this._interactionTimer.isRunning()||this._hass?.themes.darkMode)?this.setAttribute("dark",""):this.removeAttribute("dark")}_changeViewHandler(e){this._changeView({view:e.detail})}_addViewContextHandler(e){this._changeView({view:this._view?.clone().mergeInContext(e.detail)})}willUpdate(e){e.has("_cardWideConfig")&&((e,t)=>{const n=t?.style??{};for(const t of Object.keys(n)){const i=`--frigate-card-css-${t.replaceAll("_","-")}`;!1===n[t]?e.style.setProperty(i,Ky[t]):e.style.removeProperty(i)}})(this,this._cardWideConfig?.performance),e.has("_view")&&this._setPropertiesForExpandedMode();const t=e.get("_overriddenConfig")??e.get("_config"),n=this._getConfig();if((!this._microphoneController||e.has("_overriddenConfig")||e.has("_config"))&&t?.live.microphone.disconnect_seconds!==n.live.microphone.disconnect_seconds){const e=this._getConfig();this._microphoneController=new wb(e.live.microphone.always_connected?void 0:e.live.microphone.disconnect_seconds)}this._initializeBackground()}_setPropertiesForMinMaxHeight(){this.style.setProperty("--frigate-card-max-height",this._getConfig().dimensions.max_height),this.style.setProperty("--frigate-card-min-height",this._getConfig().dimensions.min_height)}_getMostRecentTrigger(){const e=[...this._triggers.entries()].sort(((e,t)=>t[1].getTime()-e[1].getTime()));return e.length?e[0][0]:null}_updateTriggeredCameras(e){if(!this._view||!this._isAutomatedViewUpdateAllowed(!0))return!1;const t=new Date;let n=!1,i=!1;const a=this._cameraManager?.getStore().getVisibleCameras();for(const[n,r]of a?.entries()??[]){const a=r.triggers.entities??[],o=dp(this._hass,e,a,{stateOnly:!0}).some((e=>bp(e.newState))),s=a.every((e=>!bp(this._hass?.states[e])));o?(this._triggers.set(n,t),i=!0):s&&this._triggers.has(n)&&(this._triggers.delete(n),i=!0)}if(i)if(this._triggers.size){const e=this._getMostRecentTrigger();!e||this._view.camera===e&&this._view.is("live")||(this._changeView({view:new Oy({view:"live",camera:e})}),n=!0)}else this._startUntriggerTimer();return n}_isTriggered(){return!!this._triggers.size||this._untriggerTimer.isRunning()}_untrigger(){const e=this._isTriggered();this._triggers.clear(),this._untriggerTimer.stop(),e&&this.requestUpdate()}_startUntriggerTimer(){this._untriggerTimer.start(this._getConfig().view.scan.untrigger_seconds,(()=>{this._untrigger(),this._isAutomatedViewUpdateAllowed()&&this._getConfig().view.scan.untrigger_reset&&this._changeView()}))}_handleThrownError(e){e instanceof Error&&Nf(e),e instanceof vu&&this._setMessageAndUpdate({message:e.message,type:"error",context:e.context})}async _initializeCameras(e,t,n){this._cameraManager=new _v(new dv(this._entityRegistryManager,this._resolvedMediaCache,n),this._cardWideConfig);const i=t.cameras.map((e=>tr(Gi(t.cameras_global),e)));try{await this._cameraManager.initializeCameras(e,this._entityRegistryManager,i)}catch(e){this._handleThrownError(e)}if(!this._view){xb().find((e=>(e=>{switch(e.frigate_card_action){case"clip":case"clips":case"image":case"live":case"recording":case"recordings":case"snapshot":case"snapshots":case"timeline":return!0}return!1})(e)||"diagnostics"===e.frigate_card_action))||this._changeView({resetMessage:!1})}}async _initializeMicrophone(){await(this._microphoneController?.connect())}async _initializeMediaPlayers(e){const t=Object.keys(this._hass?.states||{}).filter((e=>{if(e.startsWith("media_player.")){const t=this._hass?.states[e];if(t&&"unavailable"!==t.state&&Ym(t,131072))return!0}return!1}));let n;try{n=await this._entityRegistryManager.getEntities(e,t)}catch(e){return void Nf(e)}this._mediaPlayers=t.filter((e=>{const t=n.get(e);return!t||!t.hidden_by}))}_initializeMandatory(){if(this._initializer.isInitializedMultiple([$b.LANGUAGES,$b.SIDE_LOAD_ELEMENTS,$b.CAMERAS]))return!0;const e=this._hass,t=this._getConfig(),n=this._cardWideConfig;return!!(e&&t&&n)&&(this._initializer.initializeMultipleIfNecessary({[$b.LANGUAGES]:async()=>await(async e=>{const t=Dm(e);"it"===t?Im[t]=await import("./lang-it-0e2e946c.js"):"pt"===t?Im[t]=await import("./lang-pt-PT-440b6dfd.js"):"pt_BR"===t&&(Im[t]=await import("./lang-pt-BR-1648942c.js")),t&&(Rm=t)})(e),[$b.SIDE_LOAD_ELEMENTS]:async()=>await yp()}).then((i=>!!i&&this._initializer.initializeIfNecessary($b.CAMERAS,(async()=>await this._initializeCameras(e,t,n))))).then((e=>{if(e)return this.requestUpdate()})),!1)}_initializeBackground(){const e=this._hass,t=this._getConfig();e&&t&&(this._initializer.isInitializedMultiple([...t.menu.buttons.media_player.enabled?[$b.MEDIA_PLAYERS]:[],...t.live.microphone.always_connected?[$b.MICROPHONE]:[]])||this._initializer.initializeMultipleIfNecessary({...t.menu.buttons.media_player.enabled&&{[$b.MEDIA_PLAYERS]:async()=>await this._initializeMediaPlayers(e)},...t.live.microphone.always_connected&&{[$b.MICROPHONE]:async()=>await this._initializeMicrophone()}}).then((e=>{e&&this.requestUpdate()})))}shouldUpdate(e){if(!this._initializeMandatory())return!1;const t=e.get("_hass");let n=!t||1!=e.size;if(!t&&!this._hass?.connected||t&&t.connected!==!!this._hass?.connected)return this._hass?.connected?this._changeView():this._setMessageAndUpdate({message:Pm("error.reconnecting"),icon:"mdi:lan-disconnect",type:"connection",dotdotdot:!0},!0),!0;if(t){const e=this._getSelectedCameraConfig();this._getConfig().view.scan.enabled&&this._updateTriggeredCameras(t)?n=!0:this._isAutomatedViewUpdateAllowed()&&up(this._hass,t,[...this._getConfig().view.update_entities||[],...e?.triggers.entities||[]])?(this._changeView(),n=!0):n||=up(this._hass,t,[...this._getConfig().view.render_entities??[],...this._mediaPlayers??[]])}return n}async _downloadViewerMedia(){const e=this._view?.queryResults?.getSelectedResult();if(this._hass&&this._cameraManager&&e)try{await by(this._hass,this._cameraManager,e)}catch(e){this._handleThrownError(e)}}_mediaPlayerAction(e,t){if(!(["play","stop"].includes(t)&&this._view&&this._hass&&this._cameraManager))return;let n=null,i=null,a=null,r=null;const o=this._getSelectedCameraConfig();if(!o)return;const s=o.camera_entity??null,c=this._view.queryResults?.getSelectedResult();this._view.isViewerView()&&c?(n=c.getContentID(),i=c.getContentType(),a=c.getTitle(),r=c.getThumbnail()):this._view?.is("live")&&s&&(n=`media-source://camera/${s}`,i="application/vnd.apple.mpegurl",a=this._cameraManager.getCameraMetadata(this._hass,this._view.camera)?.title??null,r=this._hass?.states[s]?.attributes?.entity_picture??null),n&&i&&("play"===t?this._hass?.callService("media_player","play_media",{entity_id:e,media_content_id:n,media_content_type:i,extra:{...a&&{title:a},...r&&{thumb:r}}}):"stop"===t&&this._hass?.callService("media_player","media_stop",{entity_id:e}))}_cardActionEventHandler(e){if("detail"in e){const t=um(e.detail);t&&this._cardActionHandler(t)}}_cardActionHandler(e){if(!this._cameraManager)return;if(e.card_id&&this._getConfig().card_id!==e.card_id)return;const t=e.frigate_card_action;switch(t){case"default":this._changeView();break;case"clip":case"clips":case"image":case"live":case"recording":case"recordings":case"snapshot":case"snapshots":case"timeline":this._changeView({viewName:t,cameraID:this._view?.camera});break;case"download":this._downloadViewerMedia();break;case"camera_ui":const n=this._getCameraURLFromContext();n&&window.open(n);break;case"expand":this._setExpand(!this._expand);break;case"fullscreen":$r.toggle(this);break;case"menu_toggle":this._refMenu.value?.toggleMenu();break;case"camera_select":const i=e.camera;if(this._view&&this._cameraManager?.getStore().hasVisibleCameraID(i)){const e=this._getConfig().view.camera_select,t="current"===e?this._view.view:e,n=this.isViewSupportedByCamera(i,t)?t:uu;this._changeView({view:new Oy({view:n,camera:i})})}break;case"live_substream_select":if(this._view){const t=((e,t)=>{const n=e.context?.live?.overrides??new Map;return n.set(e.camera,t),e.clone().mergeInContext({live:{overrides:n}})})(this._view,e.camera);t&&this._changeView({view:t})}break;case"live_substream_off":if(this._view){const e=(e=>{const t=e.clone(),n=t.context?.live?.overrides;return n&&n.has(e.camera)&&t.context?.live?.overrides?.delete(e.camera),t})(this._view);e&&this._changeView({view:e})}break;case"live_substream_on":if(this._view){const e=((e,t)=>{const n=[...pv(e,t.camera)];if(n.length<=1)return t.clone();const i=t.clone(),a=i.context?.live?.overrides??new Map,r=a.get(i.camera)??i.camera,o=n.indexOf(r),s=o<0?0:(o+1)%n.length;return a.set(t.camera,n[s]),i.mergeInContext({live:{overrides:a}}),i})(this._cameraManager,this._view);e&&this._changeView({view:e})}break;case"media_player":this._mediaPlayerAction(e.media_player,e.media_player_action);break;case"diagnostics":this._diagnostics();break;case"microphone_mute":this._microphoneController?.mute(),this.requestUpdate();break;case"microphone_unmute":this._microphoneController?.isConnected()||this._microphoneController?.isForbidden()?this._microphoneController?.isConnected()&&(this._microphoneController.unmute(),this.requestUpdate()):(this._microphoneController?.unmute(),this._initializeMicrophone().then((()=>this.requestUpdate())));break;case"mute":this._mediaLoadedInfoController.get()?.player?.mute();break;case"unmute":this._mediaLoadedInfoController.get()?.player?.unmute();break;case"play":this._mediaLoadedInfoController.get()?.player?.play();break;case"pause":this._mediaLoadedInfoController.get()?.player?.pause();break;case"screenshot":this._mediaLoadedInfoController.get()?.player?.getScreenshotURL().then((e=>{e&&yy(e,(e=>{if(e?.is("live")||e?.is("image"))return`${e.view}-${e.camera}-${Of(new Date,"yyyy-MM-dd-HH-mm-ss")}.jpg`;if(e?.isViewerView()){const t=e.queryResults?.getSelectedResult(),n=t?.getID()??null;return`${e.view}-${e.camera}${n?`-${n}`:""}.jpg`}return"screenshot.jpg"})(this._view))}));break;default:console.warn(`Frigate card received unknown card action: ${t}`)}}isViewSupportedByCamera(e,t){const n=this._cameraManager?.getCameraCapabilities(e);switch(t){case"live":case"image":return!0;case"clip":case"clips":return!!n?.supportsClips;case"snapshot":case"snapshots":return!!n?.supportsSnapshots;case"recording":case"recordings":return!!n?.supportsRecordings;case"timeline":return!!n?.supportsTimeline;case"media":return!!n?.supportsClips||!!n?.supportsSnapshots||!!n?.supportsRecordings}return!1}async _diagnostics(){if(this._hass){let e=[];try{e=await(async e=>await cp(e,Xy,{type:"config/device_registry/list"}))(this._hass)}catch(e){}const t=e.filter((e=>"Frigate"===e.manufacturer)),n=new Map;t.forEach((e=>{e.config_entries.forEach((t=>{e.model&&n.set(t,e.model)}))})),this._setMessageAndUpdate({message:Pm("error.diagnostics"),type:"diagnostics",icon:"mdi:information",context:{ha_version:this._hass.config.version,card_version:Lr,browser:navigator.userAgent,date:new Date,frigate_version:Object.fromEntries(n),lang:Dm(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,git:{build_version:Fr,build_date:Nr,commit_date:Ur},...this._rawConfig&&{config:this._rawConfig}}})}}_getCameraURLFromContext(){if(!this._view)return null;const e=this._view.camera,t=this._view.queryResults?.getSelectedResult()??null;return(this._cameraManager?.getCameraEndpoints(e,{view:this._view.view,...t&&{media:t}})??null)?.ui?.endpoint??null}_actionHandler(e,t){const n=e.detail.action,i=e.currentTarget,a=mm(n,t);this._hass&&t&&i&&n&&a&&pm(i,this._hass,t,e.detail.action,a),this._startInteractionTimer()}_mouseHandler(){this._startInteractionTimer()}_startInteractionTimer(){this._interactionTimer.stop(),this._untrigger(),this._getConfig().view.timeout_seconds&&this._interactionTimer.start(this._getConfig().view.timeout_seconds,(()=>{this._isAutomatedViewUpdateAllowed()&&(this._changeView(),this._setLightOrDarkMode())})),this._setLightOrDarkMode()}_startUpdateTimer(){this._updateTimer.stop(),this._getConfig().view.update_seconds&&this._updateTimer.start(this._getConfig().view.update_seconds,(()=>{this._isAutomatedViewUpdateAllowed()?this._changeView():this._startUpdateTimer()}))}_isAutomatedViewUpdateAllowed(e){return(e||!this._isTriggered())&&(this._getConfig().view.update_force||!this._interactionTimer.isRunning())}_renderMenu(){if(this._hass&&this._cameraManager&&this._view)return K`
      <frigate-card-menu
        ${Fe(this._refMenu)}
        .hass=${this._hass}
        .menuConfig=${this._getConfig().menu}
        .buttons=${this._menuButtonController.calculateButtons(this._hass,this._getConfig(),this._cameraManager,this._view,this._expand,{currentMediaLoadedInfo:this._mediaLoadedInfoController.get(),mediaPlayers:this._mediaPlayers,cameraURL:this._getCameraURLFromContext(),microphoneController:this._microphoneController})}
        .entityRegistryManager=${this._entityRegistryManager}
      ></frigate-card-menu>
    `}_setMessageAndUpdate(e,t){const n=this._message?cm[this._message.type]??0:0,i=cm[e.type]??0;(!this._message||i>=n)&&(this._message=e,this._mediaUnloadedHandler(),t||(this.requestUpdate(),this._resetMainScroll()))}_resetMainScroll(){this._refMain.value?.scroll({top:0})}_messageHandler(e){return this._setMessageAndUpdate(e.detail)}_mediaLoadedHandler(e){const t=e.detail;_b(t)&&(hv(this._cardWideConfig,"Frigate Card media load: ",t),this._mediaLoadedInfoController.set(t),this._setPropertiesForExpandedMode(),this._conditionController?.setState({media_loaded:this._mediaLoadedInfoController.has()}),this.requestUpdate())}_setPropertiesForExpandedMode(){const e=this._mediaLoadedInfoController.getLastKnown();this.style.setProperty("--frigate-card-expand-aspect-ratio",this._view?.isAnyMediaView()&&e?`${e.width} / ${e.height}`:"unset"),this.style.setProperty("--frigate-card-expand-width",this._view?.isAnyMediaView()?"none":"var(--frigate-card-expand-max-width)"),this.style.setProperty("--frigate-card-expand-height",this._view?.isAnyMediaView()?"none":"var(--frigate-card-expand-max-height)")}_mediaUnloadedHandler(){this._mediaLoadedInfoController.clear(),this._conditionController?.setState({media_loaded:!1})}firstUpdated(){this._locationChangeHandler()}connectedCallback(){super.connectedCallback(),$r.isEnabled&&$r.on("change",this._boundFullscreenHandler),this.addEventListener("mousemove",this._boundMouseHandler),this.addEventListener("ll-custom",this._boundCardActionEventHandler),this._panel=(e=>{const t=e.getRootNode();return!!(t&&t instanceof ShadowRoot&&"HUI-PANEL-VIEW"===t.host.tagName)})(this),window.addEventListener("location-changed",this._locationChangeHandler),window.addEventListener("popstate",this._locationChangeHandler),this._locationChangeHandler()}disconnectedCallback(){this._mediaUnloadedHandler(),$r.isEnabled&&$r.off("change",this._boundFullscreenHandler),this.removeEventListener("mousemove",this._boundMouseHandler),this.removeEventListener("ll-custom",this._boundCardActionEventHandler),window.removeEventListener("location-changed",this._locationChangeHandler),window.removeEventListener("popstate",this._locationChangeHandler),super.disconnectedCallback()}_isAspectRatioEnforced(){const e=this._getConfig().dimensions.aspect_ratio_mode;return!($r.isEnabled&&$r.isFullscreen||this._expand||"unconstrained"==e||"dynamic"==e&&(this._view?.isAnyMediaView()||this._view?.is("timeline")))}_getAspectRatioStyle(){if(!this._isAspectRatioEnforced())return"auto";const e=this._getConfig().dimensions.aspect_ratio_mode,t=this._mediaLoadedInfoController.getLastKnown();if(t&&"dynamic"===e)return`${t.width} / ${t.height}`;const n=this._getConfig().dimensions.aspect_ratio;return n?`${n[0]} / ${n[1]}`:"16 / 9"}_getMergedActions(){if(this._message||this._view?.is("timeline"))return{};let e;return this._view?.is("live")?e=this._getConfig().live.actions:this._view?.isGalleryView()?e=this._getConfig().media_gallery?.actions:this._view?.isViewerView()?e=this._getConfig().media_viewer.actions:this._view?.is("image")&&(e=this._getConfig().image?.actions),{...this._getConfig().view.actions,...e}}_isInFullscreen(){return $r.isEnabled&&$r.isFullscreen}_setExpand(e){e&&this._isInFullscreen()&&$r.exit(),this._expand=e,this._conditionController?.setState({expand:this._expand})}_fullscreenHandler(){this._isInFullscreen()&&(this._expand=!1),this._conditionController?.setState({fullscreen:this._isInFullscreen(),expand:this._expand}),this.requestUpdate()}_renderInDialogIfNecessary(e){return this._expand?K` <web-dialog
        open
        center
        @close=${()=>{this._setExpand(!1)}}
      >
        ${e}
      </web-dialog>`:e}render(){if(!this._hass)return;const e={"aspect-ratio":this._getAspectRatioStyle()},t={triggered:!!this._isTriggered()&&this._getConfig().view.scan.show_trigger_status},n={main:!0,"curve-top":"outside"!==this._getConfig().menu.style||"top"!==this._getConfig().menu.position,"curve-bottom":"outside"!==this._getConfig().menu.style||"top"===this._getConfig().menu.position},i=this._getMergedActions(),a="outside"===this._getConfig().menu.style&&"top"===this._getConfig().menu.position;return this._renderInDialogIfNecessary(K` <ha-card
      id="ha-card"
      .actionHandler=${wm({hasHold:gm(i.hold_action),hasDoubleClick:gm(i.double_tap_action)})}
      class="${Ee(t)}"
      style="${He(e)}"
      @action=${e=>this._actionHandler(e,i)}
      @frigate-card:message=${this._messageHandler.bind(this)}
      @frigate-card:view:change=${this._changeViewHandler.bind(this)}
      @frigate-card:view:change-context=${this._addViewContextHandler.bind(this)}
      @frigate-card:media:loaded=${this._mediaLoadedHandler.bind(this)}
      @frigate-card:media:unloaded=${this._mediaUnloadedHandler.bind(this)}
      @frigate-card:media:volumechange=${()=>this.requestUpdate()}
      @frigate-card:media:play=${()=>this.requestUpdate()}
      @frigate-card:media:pause=${()=>this.requestUpdate()}
      @frigate-card:render=${()=>this.requestUpdate()}
    >
      ${a?this._renderMenu():""}
      <div ${Fe(this._refMain)} class="${Ee(n)}">
        ${this._cameraManager?.isInitialized()||this._message?K`<frigate-card-views
              ${Fe(this._refViews)}
              .hass=${this._hass}
              .view=${this._view}
              .cardWideConfig=${this._cardWideConfig}
              .cameraManager=${this._cameraManager}
              .resolvedMediaCache=${this._resolvedMediaCache}
              .config=${this._getConfig()}
              .nonOverriddenConfig=${this._config}
              .conditionControllerEpoch=${this._conditionController?.getEpoch()}
              .hide=${!!this._message}
              .microphoneStream=${this._microphoneController?.getStream()}
            ></frigate-card-views>`:$v({cardWideConfig:this._cardWideConfig})}
        ${this._message?Cv(this._message):""}
      </div>
      ${a?"":this._renderMenu()}
      ${this._getConfig().elements?K` <frigate-card-elements
            ${Fe(this._refElements)}
            .hass=${this._hass}
            .elements=${this._getConfig().elements}
            .conditionControllerEpoch=${this._conditionController?.getEpoch()}
            @frigate-card:menu-add=${e=>{this._menuButtonController.addDynamicMenuButton(e.detail),this.requestUpdate()}}
            @frigate-card:menu-remove=${e=>{this._menuButtonController.removeDynamicMenuButton(e.detail),this.requestUpdate()}}
            @frigate-card:condition:evaluate=${e=>{e.evaluation=this._conditionController?.evaluateCondition(e.condition)}}
          >
          </frigate-card-elements>`:""}
    </ha-card>`)}static get styles(){return b(":host {\n  display: block;\n  position: relative;\n  background-color: var(--card-background-color);\n  border-radius: var(--ha-card-border-radius, 4px);\n  max-height: var(--frigate-card-max-height);\n  min-height: var(--frigate-card-min-height);\n  --frigate-card-expand-max-height: calc( ( 100vh - (2 * 56px) ) * 0.85 );\n  --frigate-card-expand-max-width: 85vw;\n  --frigate-card-expand-width: none;\n  --frigate-card-expand-height: none;\n  --frigate-card-expand-aspect-ratio: unset;\n  --frigate-card-max-height: none;\n  --frigate-card-min-height: none;\n}\n\n:host([dark]) {\n  filter: brightness(75%);\n}\n\n:host([panel]) {\n  height: 100%;\n}\n\ndiv.main {\n  position: relative;\n  overflow: auto;\n  width: 100%;\n  height: 100%;\n  margin: auto;\n  display: block;\n  transform: translateZ(0);\n  box-sizing: border-box;\n  scrollbar-width: none;\n  -ms-overflow-style: none;\n}\n\n/* Hide scrollbar for Chrome, Safari and Opera */\ndiv.main::-webkit-scrollbar {\n  display: none;\n}\n\ndiv.main.curve-top {\n  border-top-left-radius: var(--ha-card-border-radius, 4px);\n  border-top-right-radius: var(--ha-card-border-radius, 4px);\n}\n\ndiv.main.curve-bottom {\n  border-bottom-left-radius: var(--ha-card-border-radius, 4px);\n  border-bottom-right-radius: var(--ha-card-border-radius, 4px);\n}\n\n/* The 'hover' menu mode is styled applied outside of the menu itself */\nfrigate-card-menu[data-style*=hover] {\n  z-index: 1;\n  transition: opacity 0.5s ease;\n}\n\n.main + frigate-card-menu[data-style*=hover] {\n  opacity: 0;\n}\n\nfrigate-card-menu[data-style=hover]:hover {\n  opacity: 1;\n}\n\n.main:hover + frigate-card-menu[data-style=hover-card],\nfrigate-card-menu[data-style=hover-card]:hover {\n  opacity: 1;\n}\n\nha-card {\n  display: flex;\n  flex-direction: column;\n  margin: auto;\n  border: 0px;\n  overflow: visible;\n  width: 100%;\n  height: 100%;\n  position: static;\n  color: var(--secondary-text-color, white);\n}\n\nha-card.triggered {\n  animation: warning-pulse 5s infinite;\n}\n@keyframes warning-pulse {\n  0% {\n    border: solid 2px rgba(0, 0, 0, 0);\n  }\n  50% {\n    border: solid 2px var(--warning-color);\n  }\n  100% {\n    border: solid 2px rgba(0, 0, 0, 0);\n  }\n}\n\n/************\n * Fullscreen\n *************/\n:host(:fullscreen) #ha-card {\n  border-radius: 0px;\n  box-shadow: none;\n  margin: 0;\n}\n\n:host(:-webkit-full-screen) #ha-card {\n  border-radius: 0px;\n  box-shadow: none;\n  margin: 0;\n}\n\n:host(:fullscreen) div.main,\n:host(:fullscreen) frigate-card-menu {\n  border-radius: 0px;\n}\n\n:host(:-webkit-full-screen) div.main,\n:host(:-webkit-full-screen) frigate-card-menu {\n  border-radius: 0px;\n}\n\n/***************\n * Expanded mode\n ***************/\nweb-dialog {\n  --dialog-padding: 0px;\n  --dialog-container-padding: 0px;\n  --dialog-max-height: var(--frigate-card-expand-max-height);\n  --dialog-max-width: var(--frigate-card-expand-max-width);\n  --dialog-width: var(--frigate-card-expand-width);\n  --dialog-height: var(--frigate-card-expand-height);\n  --dialog-overflow-x: visible;\n  --dialog-overflow-y: visible;\n  max-height: 100vh;\n}\n\nweb-dialog::part(dialog) {\n  aspect-ratio: var(--frigate-card-expand-aspect-ratio);\n  border-radius: 0px;\n  background: transparent;\n}")}getCardSize(){const e=this._mediaLoadedInfoController.getLastKnown();return e?e.height/50:6}};e([we()],kb.prototype,"_hass",void 0),e([we()],kb.prototype,"_config",void 0),e([we()],kb.prototype,"_cardWideConfig",void 0),e([we()],kb.prototype,"_overriddenConfig",void 0),e([we()],kb.prototype,"_view",void 0),e([be({attribute:"panel",type:Boolean,reflect:!0})],kb.prototype,"_panel",void 0),e([we()],kb.prototype,"_expand",void 0),kb=e([_e("frigate-card")],kb);export{nd as $,wp as A,su as B,Pc as C,jv as D,jc as E,pu as F,Ac as G,zc as H,Oc as I,Dc as J,Rc as K,Ic as L,Td as M,Sd as N,Md as O,Ad as P,ed as Q,Kl as R,rd as S,lu as T,Xl as U,Jl as V,El as W,Ml as X,Sl as Y,Tl as Z,td as _,Gy as a,cd as a$,Al as a0,zl as a1,jl as a2,Rl as a3,Dl as a4,Ll as a5,Nl as a6,Pl as a7,Ol as a8,Il as a9,il as aA,nl as aB,al as aC,rl as aD,ol as aE,hl as aF,cl as aG,dl as aH,ul as aI,ll as aJ,sl as aK,bl as aL,wl as aM,fl as aN,vl as aO,_l as aP,ml as aQ,pl as aR,gl as aS,xl as aT,Cl as aU,$l as aV,dd as aW,hd as aX,ud as aY,md as aZ,sd as a_,Wl as aa,Bl as ab,Hl as ac,ql as ad,Vl as ae,Ul as af,Fl as ag,Zl as ah,Yl as ai,Ql as aj,Gl as ak,id as al,ad as am,Yc as an,qc as ao,Wc as ap,Bc as aq,Vc as ar,Zc as as,Gc as at,Kc as au,Xc as av,Jc as aw,el as ax,yl as ay,tl as az,yp as b,Ff as b$,ld as b0,wd as b1,xd as b2,$d as b3,kd as b4,Cd as b5,bd as b6,Vd as b7,qd as b8,Wd as b9,mc as bA,lc as bB,dc as bC,uc as bD,hc as bE,nc as bF,ic as bG,sc as bH,cc as bI,fc as bJ,gc as bK,yc as bL,_c as bM,wc as bN,bc as bO,xc as bP,sm as bQ,Qs as bR,Qg as bS,_p as bT,Ws as bU,Wf as bV,cp as bW,vu as bX,Fm as bY,Zm as bZ,Um as b_,Bd as ba,Xd as bb,Gd as bc,Kd as bd,tu as be,eu as bf,Jd as bg,zv as bh,Tv as bi,b as bj,e as bk,be as bl,we as bm,_e as bn,Df as bo,Gs as bp,vc as bq,pc as br,rc as bs,oc as bt,ac as bu,Ks as bv,ec as bw,Js as bx,tc as by,Xs as bz,Iv as c,_b as c$,Aa as c0,rv as c1,yr as c2,lv as c3,Wg as c4,_y as c5,Bg as c6,Zf as c7,Vf as c8,Yg as c9,Mf as cA,mf as cB,_f as cC,yf as cD,vf as cE,Op as cF,pf as cG,$e as cH,ke as cI,J as cJ,Ae as cK,Ev as cL,kv as cM,mb as cN,Lf as cO,Le as cP,dy as cQ,Kv as cR,Fe as cS,Iy as cT,vm as cU,pb as cV,X as cW,_m as cX,vy as cY,hy as cZ,vr as c_,Bm as ca,hv as cb,Gg as cc,Kg as cd,Rg as ce,uv as cf,Of as cg,Hf as ch,Kf as ci,Xf as cj,rb as ck,xp as cl,Jf as cm,Ug as cn,Yf as co,Xg as cp,Jg as cq,$p as cr,Cp as cs,kp as ct,Hp as cu,Fp as cv,Rp as cw,qp as cx,Lp as cy,Up as cz,vp as d,c_ as d0,If as d1,W_ as d2,x as d3,Ay as d4,Vy as d5,zy as d6,jy as d7,Nf as d8,Zy as d9,qy as dA,Ap as dB,Qf as dC,mr as dD,Qe as dE,fg as dF,Pe as dG,Me as dH,lp as dI,fy as dJ,Fy as da,$v as db,Bf as dc,wy as dd,Uy as de,Cv as df,qm as dg,Vm as dh,Cb as di,hb as dj,fb as dk,gb as dl,vb as dm,w as dn,Ce as dp,Se as dq,up as dr,ub as ds,Pg as dt,Lg as du,ov as dv,sv as dw,Fg as dx,Uf as dy,Wy as dz,Lc as e,Nc as f,Av as g,Uc as h,Ov as i,Fc as j,zd as k,Pm as l,yd as m,fd as n,Ee as o,Rf as p,gd as q,vd as r,ge as s,_d as t,cu as u,mv as v,Lv as w,l_ as x,K as y,l as z};
