UNPKG

esp-web-tools

Version:
1,014 lines • 377 kB
import{e as t,_ as e,o as i,i as s,x as r,a,n as o,t as n,m as l,b as d,E as c,c as h,s as _,D as p,d as u,f,g as E,r as g,h as m,j as v,k as S,l as y,p as b,q as w,u as R,v as A,B as x,w as T,y as C,z as I,A as P,T as O,C as U,F,G as D}from"./styles-BiOOVrm2.js";let M;function k(t,e=H){const i=N(t,e);return i&&(i.tabIndex=0,i.focus()),i}function L(t,e=H){const i=G(t,e);return i&&(i.tabIndex=0,i.focus()),i}function B(t,e=H){for(let i=0;i<t.length;i++){const s=t[i];if(0===s.tabIndex&&e(s))return{item:s,index:i}}return null}function N(t,e=H){for(const i of t)if(e(i))return i;return null}function G(t,e=H){for(let i=t.length-1;i>=0;i--){const s=t[i];if(e(s))return s}return null}function $(t,e,i=H,s=!0){if(e){const r=function(t,e,i=H,s=!0){for(let r=1;r<t.length;r++){const a=(r+e)%t.length;if(a<e&&!s)return null;const o=t[a];if(i(o))return o}return t[e]?t[e]:null}(t,e.index,i,s);return r&&(r.tabIndex=0,r.focus()),r}return k(t,i)}function K(t,e,i=H,s=!0){if(e){const r=function(t,e,i=H,s=!0){for(let r=1;r<t.length;r++){const a=(e-r+t.length)%t.length;if(a>e&&!s)return null;const o=t[a];if(i(o))return o}return t[e]?t[e]:null}(t,e.index,i,s);return r&&(r.tabIndex=0,r.focus()),r}return L(t,i)}function H(t){return!t.disabled}const z={ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",Home:"Home",End:"End"};class Y{constructor(t){this.handleKeydown=t=>{const e=t.key;if(t.defaultPrevented||!this.isNavigableKey(e))return;const i=this.items;if(!i.length)return;const s=B(i,this.isActivatable);t.preventDefault();const r=this.isRtl();let a=null;switch(e){case z.ArrowDown:case r?z.ArrowLeft:z.ArrowRight:a=$(i,s,this.isActivatable,this.wrapNavigation());break;case z.ArrowUp:case r?z.ArrowRight:z.ArrowLeft:a=K(i,s,this.isActivatable,this.wrapNavigation());break;case z.Home:a=k(i,this.isActivatable);break;case z.End:a=L(i,this.isActivatable)}a&&s&&s.item!==a&&(s.item.tabIndex=-1)},this.onDeactivateItems=()=>{const t=this.items;for(const e of t)this.deactivateItem(e)},this.onRequestActivation=t=>{this.onDeactivateItems();const e=t.target;this.activateItem(e),e.focus()},this.onSlotchange=()=>{const t=this.items;let e=!1;for(const i of t){!(!i.disabled&&i.tabIndex>-1)||e?i.tabIndex=-1:(e=!0,i.tabIndex=0)}if(e)return;const i=N(t,this.isActivatable);i&&(i.tabIndex=0)};const{isItem:e,getPossibleItems:i,isRtl:s,deactivateItem:r,activateItem:a,isNavigableKey:o,isActivatable:n,wrapNavigation:l}=t;this.isItem=e,this.getPossibleItems=i,this.isRtl=s,this.deactivateItem=r,this.activateItem=a,this.isNavigableKey=o,this.isActivatable=n,this.wrapNavigation=l??(()=>!0)}get items(){const t=this.getPossibleItems(),e=[];for(const i of t){if(this.isItem(i)){e.push(i);continue}const t=i.item;t&&this.isItem(t)&&e.push(t)}return e}activateNextItem(){const t=this.items,e=B(t,this.isActivatable);return e&&(e.item.tabIndex=-1),$(t,e,this.isActivatable,this.wrapNavigation())}activatePreviousItem(){const t=this.items,e=B(t,this.isActivatable);return e&&(e.item.tabIndex=-1),K(t,e,this.isActivatable,this.wrapNavigation())}}const V=new Set(Object.values(z));class W extends s{get items(){return this.listController.items}constructor(){super(),this.listController=new Y({isItem:t=>t.hasAttribute("md-list-item"),getPossibleItems:()=>this.slotItems,isRtl:()=>"rtl"===getComputedStyle(this).direction,deactivateItem:t=>{t.tabIndex=-1},activateItem:t=>{t.tabIndex=0},isNavigableKey:t=>V.has(t),isActivatable:t=>!t.disabled&&"text"!==t.type}),this.internals=this.attachInternals(),this.internals.role="list",this.addEventListener("keydown",this.listController.handleKeydown)}render(){return r`
      <slot
        @deactivate-items=${this.listController.onDeactivateItems}
        @request-activation=${this.listController.onRequestActivation}
        @slotchange=${this.listController.onSlotchange}>
      </slot>
    `}activateNextItem(){return this.listController.activateNextItem()}activatePreviousItem(){return this.listController.activatePreviousItem()}}e([i({flatten:!0})],W.prototype,"slotItems",void 0);const q=a`:host{background:var(--md-list-container-color, var(--md-sys-color-surface, #fef7ff));color:unset;display:flex;flex-direction:column;outline:none;padding:8px 0;position:relative}
`;q.styleSheet;class Z extends W{}Z.styles=[q],customElements.define("ew-list",Z);class X extends s{constructor(){super(...arguments),this.multiline=!1}render(){return r`
      <slot name="container"></slot>
      <slot class="non-text" name="start"></slot>
      <div class="text">
        <slot name="overline" @slotchange=${this.handleTextSlotChange}></slot>
        <slot
          class="default-slot"
          @slotchange=${this.handleTextSlotChange}></slot>
        <slot name="headline" @slotchange=${this.handleTextSlotChange}></slot>
        <slot
          name="supporting-text"
          @slotchange=${this.handleTextSlotChange}></slot>
      </div>
      <slot class="non-text" name="trailing-supporting-text"></slot>
      <slot class="non-text" name="end"></slot>
    `}handleTextSlotChange(){let t=!1,e=0;for(const i of this.textSlots)if(j(i)&&(e+=1),e>1){t=!0;break}this.multiline=t}}function j(t){for(const i of t.assignedNodes({flatten:!0})){var e;const t=i.nodeType===Node.ELEMENT_NODE,s=i.nodeType===Node.TEXT_NODE&&(null===(e=i.textContent)||void 0===e?void 0:e.match(/\S/));if(t||s)return!0}return!1}e([o({type:Boolean,reflect:!0})],X.prototype,"multiline",void 0),e([function(e){return(i,s)=>t(i,s,{get(){return(this.renderRoot??M??(M=document.createDocumentFragment())).querySelectorAll(e)}})}(".text slot")],X.prototype,"textSlots",void 0);const J=a`:host{color:var(--md-sys-color-on-surface, #1d1b20);font-family:var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-body-large-size, 1rem);font-weight:var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400));line-height:var(--md-sys-typescale-body-large-line-height, 1.5rem);align-items:center;box-sizing:border-box;display:flex;gap:16px;min-height:56px;overflow:hidden;padding:12px 16px;position:relative;text-overflow:ellipsis}:host([multiline]){min-height:72px}[name=overline]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-label-small-size, 0.6875rem);font-weight:var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500));line-height:var(--md-sys-typescale-label-small-line-height, 1rem)}[name=supporting-text]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-body-medium-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-body-medium-size, 0.875rem);font-weight:var(--md-sys-typescale-body-medium-weight, var(--md-ref-typeface-weight-regular, 400));line-height:var(--md-sys-typescale-body-medium-line-height, 1.25rem)}[name=trailing-supporting-text]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-label-small-size, 0.6875rem);font-weight:var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500));line-height:var(--md-sys-typescale-label-small-line-height, 1rem)}[name=container]::slotted(*){inset:0;position:absolute}.default-slot{display:inline}.default-slot,.text ::slotted(*){overflow:hidden;text-overflow:ellipsis}.text{display:flex;flex:1;flex-direction:column;overflow:hidden}
`;J.styleSheet;let Q=class extends X{};Q.styles=[J],Q=e([n("md-item")],Q);const tt=Symbol.for(""),et=t=>{if((null==t?void 0:t.r)===tt)return null==t?void 0:t._$litStatic$},it=(t,...e)=>({_$litStatic$:e.reduce(((e,i,s)=>e+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n            take care to ensure page security.`)})(i)+t[s+1]),t[0]),r:tt}),st=new Map,rt=(t=>(e,...i)=>{const s=i.length;let r,a;const o=[],n=[];let l,d=0,c=!1;for(;d<s;){for(l=e[d];d<s&&void 0!==(a=i[d],r=et(a));)l+=r+e[++d],c=!0;d!==s&&n.push(a),o.push(l),d++}if(d===s&&o.push(e[s]),c){const t=o.join("$$lit$$");void 0===(e=st.get(t))&&(o.raw=o,st.set(t,e=o)),i=n}return t(e,...i)})(r),at=l(s);class ot extends at{constructor(){super(...arguments),this.disabled=!1,this.type="text",this.isListItem=!0,this.href="",this.target=""}get isDisabled(){return this.disabled&&"link"!==this.type}willUpdate(t){this.href&&(this.type="link"),super.willUpdate(t)}render(){return this.renderListItem(r`
      <md-item>
        <div slot="container">
          ${this.renderRipple()} ${this.renderFocusRing()}
        </div>
        <slot name="start" slot="start"></slot>
        <slot name="end" slot="end"></slot>
        ${this.renderBody()}
      </md-item>
    `)}renderListItem(t){const e="link"===this.type;let i;switch(this.type){case"link":i=it`a`;break;case"button":i=it`button`;break;default:i=it`li`}const s="text"!==this.type,r=e&&this.target?this.target:c;return rt`
      <${i}
        id="item"
        tabindex="${this.isDisabled||!s?-1:0}"
        ?disabled=${this.isDisabled}
        role="listitem"
        aria-selected=${this.ariaSelected||c}
        aria-checked=${this.ariaChecked||c}
        aria-expanded=${this.ariaExpanded||c}
        aria-haspopup=${this.ariaHasPopup||c}
        class="list-item ${h(this.getRenderClasses())}"
        href=${this.href||c}
        target=${r}
        @focus=${this.onFocus}
      >${t}</${i}>
    `}renderRipple(){return"text"===this.type?c:r` <md-ripple
      part="ripple"
      for="item"
      ?disabled=${this.isDisabled}></md-ripple>`}renderFocusRing(){return"text"===this.type?c:r` <md-focus-ring
      @visibility-changed=${this.onFocusRingVisibilityChanged}
      part="focus-ring"
      for="item"
      inward></md-focus-ring>`}onFocusRingVisibilityChanged(t){}getRenderClasses(){return{disabled:this.isDisabled}}renderBody(){return r`
      <slot></slot>
      <slot name="overline" slot="overline"></slot>
      <slot name="headline" slot="headline"></slot>
      <slot name="supporting-text" slot="supporting-text"></slot>
      <slot
        name="trailing-supporting-text"
        slot="trailing-supporting-text"></slot>
    `}onFocus(){-1===this.tabIndex&&this.dispatchEvent(new Event("request-activation",{bubbles:!0,composed:!0}))}focus(){var t;null===(t=this.listItemRoot)||void 0===t||t.focus()}click(){this.listItemRoot?this.listItemRoot.click():super.click()}}ot.shadowRootOptions={...s.shadowRootOptions,delegatesFocus:!0},e([o({type:Boolean,reflect:!0})],ot.prototype,"disabled",void 0),e([o({reflect:!0})],ot.prototype,"type",void 0),e([o({type:Boolean,attribute:"md-list-item",reflect:!0})],ot.prototype,"isListItem",void 0),e([o()],ot.prototype,"href",void 0),e([o()],ot.prototype,"target",void 0),e([d(".list-item")],ot.prototype,"listItemRoot",void 0);const nt=a`:host{display:flex;gap:16px;-webkit-tap-highlight-color:rgba(0,0,0,0);--md-ripple-hover-color: var(--md-list-item-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-hover-opacity: var(--md-list-item-hover-state-layer-opacity, 0.08);--md-ripple-pressed-color: var(--md-list-item-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-pressed-opacity: var(--md-list-item-pressed-state-layer-opacity, 0.12)}:host(:is([type=button]:not([disabled]),[type=link])){cursor:pointer}md-focus-ring{z-index:1;--md-focus-ring-shape: 8px}a,button,li{background:none;border:none;cursor:inherit;padding:0;margin:0;text-align:unset;text-decoration:none}.list-item{border-radius:inherit;display:flex;flex:1;gap:inherit;max-width:inherit;min-width:inherit;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0);width:100%}.list-item.interactive{cursor:pointer}.list-item.disabled{opacity:var(--md-list-item-disabled-opacity, 0.3);pointer-events:none}[slot=container]{pointer-events:none}md-ripple{border-radius:inherit}md-item{border-radius:inherit;flex:1;height:100%;color:var(--md-list-item-label-text-color, var(--md-sys-color-on-surface, #1d1b20));font-family:var(--md-list-item-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-list-item-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));line-height:var(--md-list-item-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));font-weight:var(--md-list-item-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));min-height:var(--md-list-item-one-line-container-height, 56px);padding-top:var(--md-list-item-top-space, 12px);padding-bottom:var(--md-list-item-bottom-space, 12px);padding-inline-start:var(--md-list-item-leading-space, 16px);padding-inline-end:var(--md-list-item-trailing-space, 16px);gap:inherit}md-item[multiline]{min-height:var(--md-list-item-two-line-container-height, 72px)}[slot=supporting-text]{color:var(--md-list-item-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-list-item-supporting-text-font, var(--md-sys-typescale-body-medium-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-list-item-supporting-text-size, var(--md-sys-typescale-body-medium-size, 0.875rem));line-height:var(--md-list-item-supporting-text-line-height, var(--md-sys-typescale-body-medium-line-height, 1.25rem));font-weight:var(--md-list-item-supporting-text-weight, var(--md-sys-typescale-body-medium-weight, var(--md-ref-typeface-weight-regular, 400)))}[slot=trailing-supporting-text]{color:var(--md-list-item-trailing-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-list-item-trailing-supporting-text-font, var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-list-item-trailing-supporting-text-size, var(--md-sys-typescale-label-small-size, 0.6875rem));line-height:var(--md-list-item-trailing-supporting-text-line-height, var(--md-sys-typescale-label-small-line-height, 1rem));font-weight:var(--md-list-item-trailing-supporting-text-weight, var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500)))}:is([slot=start],[slot=end])::slotted(*){fill:currentColor}[slot=start]{color:var(--md-list-item-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}[slot=end]{color:var(--md-list-item-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}@media(forced-colors: active){.disabled slot{color:GrayText}.list-item.disabled{color:GrayText;opacity:1}}
`;nt.styleSheet;class lt extends ot{}lt.styles=[nt],customElements.define("ew-list-item",lt);class dt extends p{}dt.styles=[_],customElements.define("ew-divider",dt);const ct=Symbol("createValidator"),ht=Symbol("getValidityAnchor"),_t=Symbol("privateValidator"),pt=Symbol("privateSyncValidity"),ut=Symbol("privateCustomValidationMessage");function ft(t){var e;class i extends t{constructor(){super(...arguments),this[e]=""}get validity(){return this[pt](),this[u].validity}get validationMessage(){return this[pt](),this[u].validationMessage}get willValidate(){return this[pt](),this[u].willValidate}checkValidity(){return this[pt](),this[u].checkValidity()}reportValidity(){return this[pt](),this[u].reportValidity()}setCustomValidity(t){this[ut]=t,this[pt]()}requestUpdate(t,e,i){super.requestUpdate(t,e,i),this[pt]()}firstUpdated(t){super.firstUpdated(t),this[pt]()}[(e=ut,pt)](){this[_t]||(this[_t]=this[ct]());const{validity:t,validationMessage:e}=this[_t].getValidity(),i=!!this[ut],s=this[ut]||e;this[u].setValidity({...t,customError:i},s,this[ht]()??void 0)}[ct](){throw new Error("Implement [createValidator]")}[ht](){throw new Error("Implement [getValidityAnchor]")}}return i}class Et{constructor(t){this.getCurrentState=t,this.currentValidity={validity:{},validationMessage:""}}getValidity(){const t=this.getCurrentState();if(!(!this.prevState||!this.equals(this.prevState,t)))return this.currentValidity;const{validity:e,validationMessage:i}=this.computeValidity(t);return this.prevState=this.copy(t),this.currentValidity={validationMessage:i,validity:{badInput:e.badInput,customError:e.customError,patternMismatch:e.patternMismatch,rangeOverflow:e.rangeOverflow,rangeUnderflow:e.rangeUnderflow,stepMismatch:e.stepMismatch,tooLong:e.tooLong,tooShort:e.tooShort,typeMismatch:e.typeMismatch,valueMissing:e.valueMissing}},this.currentValidity}}class gt extends Et{computeValidity(t){return this.checkboxControl||(this.checkboxControl=document.createElement("input"),this.checkboxControl.type="checkbox"),this.checkboxControl.checked=t.checked,this.checkboxControl.required=t.required,{validity:this.checkboxControl.validity,validationMessage:this.checkboxControl.validationMessage}}equals(t,e){return t.checked===e.checked&&t.required===e.required}copy({checked:t,required:e}){return{checked:t,required:e}}}const mt=l(ft(f(E(s))));class vt extends mt{constructor(){super(),this.checked=!1,this.indeterminate=!1,this.required=!1,this.value="on",this.prevChecked=!1,this.prevDisabled=!1,this.prevIndeterminate=!1,this.addEventListener("click",(t=>{m(t)&&this.input&&(this.focus(),v(this.input))}))}update(t){(t.has("checked")||t.has("disabled")||t.has("indeterminate"))&&(this.prevChecked=t.get("checked")??this.checked,this.prevDisabled=t.get("disabled")??this.disabled,this.prevIndeterminate=t.get("indeterminate")??this.indeterminate),super.update(t)}render(){const t=!this.prevChecked&&!this.prevIndeterminate,e=this.prevChecked&&!this.prevIndeterminate,i=this.prevIndeterminate,s=this.checked&&!this.indeterminate,a=this.indeterminate,o=h({disabled:this.disabled,selected:s||a,unselected:!s&&!a,checked:s,indeterminate:a,"prev-unselected":t,"prev-checked":e,"prev-indeterminate":i,"prev-disabled":this.prevDisabled}),{ariaLabel:n,ariaInvalid:l}=this;return r`
      <div class="container ${o}">
        <input
          type="checkbox"
          id="input"
          aria-checked=${a?"mixed":c}
          aria-label=${n||c}
          aria-invalid=${l||c}
          ?disabled=${this.disabled}
          ?required=${this.required}
          .indeterminate=${this.indeterminate}
          .checked=${this.checked}
          @input=${this.handleInput}
          @change=${this.handleChange} />

        <div class="outline"></div>
        <div class="background"></div>
        <md-focus-ring part="focus-ring" for="input"></md-focus-ring>
        <md-ripple for="input" ?disabled=${this.disabled}></md-ripple>
        <svg class="icon" viewBox="0 0 18 18" aria-hidden="true">
          <rect class="mark short" />
          <rect class="mark long" />
        </svg>
      </div>
    `}handleInput(t){const e=t.target;this.checked=e.checked,this.indeterminate=e.indeterminate}handleChange(t){S(this,t)}[y](){return!this.checked||this.indeterminate?null:this.value}[b](){return String(this.checked)}formResetCallback(){this.checked=this.hasAttribute("checked")}formStateRestoreCallback(t){this.checked="true"===t}[ct](){return new gt((()=>this))}[ht](){return this.input}}vt.shadowRootOptions={...s.shadowRootOptions,delegatesFocus:!0},e([o({type:Boolean})],vt.prototype,"checked",void 0),e([o({type:Boolean})],vt.prototype,"indeterminate",void 0),e([o({type:Boolean})],vt.prototype,"required",void 0),e([o()],vt.prototype,"value",void 0),e([g()],vt.prototype,"prevChecked",void 0),e([g()],vt.prototype,"prevDisabled",void 0),e([g()],vt.prototype,"prevIndeterminate",void 0),e([d("input")],vt.prototype,"input",void 0);const St=a`:host{border-start-start-radius:var(--md-checkbox-container-shape-start-start, var(--md-checkbox-container-shape, 2px));border-start-end-radius:var(--md-checkbox-container-shape-start-end, var(--md-checkbox-container-shape, 2px));border-end-end-radius:var(--md-checkbox-container-shape-end-end, var(--md-checkbox-container-shape, 2px));border-end-start-radius:var(--md-checkbox-container-shape-end-start, var(--md-checkbox-container-shape, 2px));display:inline-flex;height:var(--md-checkbox-container-size, 18px);position:relative;vertical-align:top;width:var(--md-checkbox-container-size, 18px);-webkit-tap-highlight-color:rgba(0,0,0,0);cursor:pointer}:host([disabled]){cursor:default}:host([touch-target=wrapper]){margin:max(0px,(48px - var(--md-checkbox-container-size, 18px))/2)}md-focus-ring{height:44px;inset:unset;width:44px}input{appearance:none;height:48px;margin:0;opacity:0;outline:none;position:absolute;width:48px;z-index:1;cursor:inherit}:host([touch-target=none]) input{height:100%;width:100%}.container{border-radius:inherit;display:flex;height:100%;place-content:center;place-items:center;position:relative;width:100%}.outline,.background,.icon{inset:0;position:absolute}.outline,.background{border-radius:inherit}.outline{border-color:var(--md-checkbox-outline-color, var(--md-sys-color-on-surface-variant, #49454f));border-style:solid;border-width:var(--md-checkbox-outline-width, 2px);box-sizing:border-box}.background{background-color:var(--md-checkbox-selected-container-color, var(--md-sys-color-primary, #6750a4))}.background,.icon{opacity:0;transition-duration:150ms,50ms;transition-property:transform,opacity;transition-timing-function:cubic-bezier(0.3, 0, 0.8, 0.15),linear;transform:scale(0.6)}:where(.selected) :is(.background,.icon){opacity:1;transition-duration:350ms,50ms;transition-timing-function:cubic-bezier(0.05, 0.7, 0.1, 1),linear;transform:scale(1)}md-ripple{border-radius:var(--md-checkbox-state-layer-shape, var(--md-sys-shape-corner-full, 9999px));height:var(--md-checkbox-state-layer-size, 40px);inset:unset;width:var(--md-checkbox-state-layer-size, 40px);--md-ripple-hover-color: var(--md-checkbox-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-hover-opacity: var(--md-checkbox-hover-state-layer-opacity, 0.08);--md-ripple-pressed-color: var(--md-checkbox-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--md-ripple-pressed-opacity: var(--md-checkbox-pressed-state-layer-opacity, 0.12)}.selected md-ripple{--md-ripple-hover-color: var(--md-checkbox-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--md-ripple-hover-opacity: var(--md-checkbox-selected-hover-state-layer-opacity, 0.08);--md-ripple-pressed-color: var(--md-checkbox-selected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-pressed-opacity: var(--md-checkbox-selected-pressed-state-layer-opacity, 0.12)}.icon{fill:var(--md-checkbox-selected-icon-color, var(--md-sys-color-on-primary, #fff));height:var(--md-checkbox-icon-size, 18px);width:var(--md-checkbox-icon-size, 18px)}.mark.short{height:2px;transition-property:transform,height;width:2px}.mark.long{height:2px;transition-property:transform,width;width:10px}.mark{animation-duration:150ms;animation-timing-function:cubic-bezier(0.3, 0, 0.8, 0.15);transition-duration:150ms;transition-timing-function:cubic-bezier(0.3, 0, 0.8, 0.15)}.selected .mark{animation-duration:350ms;animation-timing-function:cubic-bezier(0.05, 0.7, 0.1, 1);transition-duration:350ms;transition-timing-function:cubic-bezier(0.05, 0.7, 0.1, 1)}.checked .mark,.prev-checked.unselected .mark{transform:scaleY(-1) translate(7px, -14px) rotate(45deg)}.checked .mark.short,.prev-checked.unselected .mark.short{height:5.6568542495px}.checked .mark.long,.prev-checked.unselected .mark.long{width:11.313708499px}.indeterminate .mark,.prev-indeterminate.unselected .mark{transform:scaleY(-1) translate(4px, -10px) rotate(0deg)}.prev-unselected .mark{transition-property:none}.prev-unselected.checked .mark.long{animation-name:prev-unselected-to-checked}@keyframes prev-unselected-to-checked{from{width:0}}:where(:hover) .outline{border-color:var(--md-checkbox-hover-outline-color, var(--md-sys-color-on-surface, #1d1b20));border-width:var(--md-checkbox-hover-outline-width, 2px)}:where(:hover) .background{background:var(--md-checkbox-selected-hover-container-color, var(--md-sys-color-primary, #6750a4))}:where(:hover) .icon{fill:var(--md-checkbox-selected-hover-icon-color, var(--md-sys-color-on-primary, #fff))}:where(:focus-within) .outline{border-color:var(--md-checkbox-focus-outline-color, var(--md-sys-color-on-surface, #1d1b20));border-width:var(--md-checkbox-focus-outline-width, 2px)}:where(:focus-within) .background{background:var(--md-checkbox-selected-focus-container-color, var(--md-sys-color-primary, #6750a4))}:where(:focus-within) .icon{fill:var(--md-checkbox-selected-focus-icon-color, var(--md-sys-color-on-primary, #fff))}:where(:active) .outline{border-color:var(--md-checkbox-pressed-outline-color, var(--md-sys-color-on-surface, #1d1b20));border-width:var(--md-checkbox-pressed-outline-width, 2px)}:where(:active) .background{background:var(--md-checkbox-selected-pressed-container-color, var(--md-sys-color-primary, #6750a4))}:where(:active) .icon{fill:var(--md-checkbox-selected-pressed-icon-color, var(--md-sys-color-on-primary, #fff))}:where(.disabled,.prev-disabled) :is(.background,.icon,.mark){animation-duration:0s;transition-duration:0s}:where(.disabled) .outline{border-color:var(--md-checkbox-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));border-width:var(--md-checkbox-disabled-outline-width, 2px);opacity:var(--md-checkbox-disabled-container-opacity, 0.38)}:where(.selected.disabled) .outline{visibility:hidden}:where(.selected.disabled) .background{background:var(--md-checkbox-selected-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));opacity:var(--md-checkbox-selected-disabled-container-opacity, 0.38)}:where(.disabled) .icon{fill:var(--md-checkbox-selected-disabled-icon-color, var(--md-sys-color-surface, #fef7ff))}@media(forced-colors: active){.background{background-color:CanvasText}.selected.disabled .background{background-color:GrayText;opacity:1}.outline{border-color:CanvasText}.disabled .outline{border-color:GrayText;opacity:1}.icon{fill:Canvas}}
`;St.styleSheet;class yt extends vt{}yt.styles=[St],customElements.define("ew-checkbox",yt);class bt{constructor(t){this.targetElement=t,this.state={bold:!1,italic:!1,underline:!1,strikethrough:!1,foregroundColor:null,backgroundColor:null,carriageReturn:!1,lines:[],secret:!1}}logs(){return this.targetElement.innerText}processLine(t){const e=/(?:\033|\\033)(?:\[(.*?)[@-~]|\].*?(?:\007|\033\\))/g;let i=0;const s=document.createElement("span");s.classList.add("line");const r=t=>{if(""===t)return;const e=document.createElement("span");if(this.state.bold&&e.classList.add("log-bold"),this.state.italic&&e.classList.add("log-italic"),this.state.underline&&e.classList.add("log-underline"),this.state.strikethrough&&e.classList.add("log-strikethrough"),this.state.secret&&e.classList.add("log-secret"),null!==this.state.foregroundColor&&e.classList.add(`log-fg-${this.state.foregroundColor}`),null!==this.state.backgroundColor&&e.classList.add(`log-bg-${this.state.backgroundColor}`),e.appendChild(document.createTextNode(t)),s.appendChild(e),this.state.secret){const t=document.createElement("span");t.classList.add("log-secret-redacted"),t.appendChild(document.createTextNode("[redacted]")),s.appendChild(t)}};for(;;){const s=e.exec(t);if(null===s)break;const a=s.index;if(r(t.substring(i,a)),i=a+s[0].length,void 0!==s[1])for(const t of s[1].split(";"))switch(parseInt(t)){case 0:this.state.bold=!1,this.state.italic=!1,this.state.underline=!1,this.state.strikethrough=!1,this.state.foregroundColor=null,this.state.backgroundColor=null,this.state.secret=!1;break;case 1:this.state.bold=!0;break;case 3:this.state.italic=!0;break;case 4:this.state.underline=!0;break;case 5:this.state.secret=!0;break;case 6:this.state.secret=!1;break;case 9:this.state.strikethrough=!0;break;case 22:this.state.bold=!1;break;case 23:this.state.italic=!1;break;case 24:this.state.underline=!1;break;case 29:this.state.strikethrough=!1;break;case 30:this.state.foregroundColor="black";break;case 31:this.state.foregroundColor="red";break;case 32:this.state.foregroundColor="green";break;case 33:this.state.foregroundColor="yellow";break;case 34:this.state.foregroundColor="blue";break;case 35:this.state.foregroundColor="magenta";break;case 36:this.state.foregroundColor="cyan";break;case 37:this.state.foregroundColor="white";break;case 39:this.state.foregroundColor=null;break;case 41:this.state.backgroundColor="red";break;case 42:this.state.backgroundColor="green";break;case 43:this.state.backgroundColor="yellow";break;case 44:this.state.backgroundColor="blue";break;case 45:this.state.backgroundColor="magenta";break;case 46:this.state.backgroundColor="cyan";break;case 47:this.state.backgroundColor="white";break;case 40:case 49:this.state.backgroundColor=null}}return r(t.substring(i)),s}processLines(){const t=this.targetElement.scrollTop>this.targetElement.scrollHeight-this.targetElement.offsetHeight-50,e=this.state.carriageReturn,i=document.createDocumentFragment();if(0!=this.state.lines.length){for(const t of this.state.lines)this.state.carriageReturn&&"\n"!==t&&i.childElementCount&&i.removeChild(i.lastChild),i.appendChild(this.processLine(t)),this.state.carriageReturn=t.includes("\r");e&&"\n"!==this.state.lines[0]?this.targetElement.replaceChild(i,this.targetElement.lastChild):this.targetElement.appendChild(i),this.state.lines=[],t&&(this.targetElement.scrollTop=this.targetElement.scrollHeight)}}addLine(t){0==this.state.lines.length&&setTimeout((()=>this.processLines()),0),this.state.lines.push(t)}}const wt=t=>new Promise((e=>setTimeout(e,t)));class Rt{constructor(){this.chunks=""}transform(t,e){this.chunks+=t;const i=this.chunks.split(/\r?\n/);this.chunks=i.pop(),i.forEach((t=>e.enqueue(t+"\r\n")))}flush(t){t.enqueue(this.chunks)}}class At{transform(t,e){const i=new Date,s=i.getHours().toString().padStart(2,"0"),r=i.getMinutes().toString().padStart(2,"0"),a=i.getSeconds().toString().padStart(2,"0");e.enqueue(`[${s}:${r}:${a}]${t}`)}}class xt extends Error{constructor(t){super(t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}}class Tt extends xt{constructor(t="unsupported command error"){super(t)}}class Ct extends xt{constructor(t){super(`Unexpected chip ID value ${t}. Failed to autodetect chip type.`)}}class It extends xt{constructor(t){super(`Unexpected CHIP magic value 0x${t.toString(16)}. Failed to autodetect chip type.`)}}class Pt extends xt{constructor(t="Security info command does not contain chip ID. This is expected for ESP32-S2 which doesn't support chip ID in security info."){super(t)}}function Ot(t){let e=t.length;for(;--e>=0;)t[e]=0}const Ut=256,Ft=286,Dt=30,Mt=15,kt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Lt=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Bt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Nt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Gt=new Array(576);Ot(Gt);const $t=new Array(60);Ot($t);const Kt=new Array(512);Ot(Kt);const Ht=new Array(256);Ot(Ht);const zt=new Array(29);Ot(zt);const Yt=new Array(Dt);function Vt(t,e,i,s,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=s,this.max_length=r,this.has_stree=t&&t.length}let Wt,qt,Zt;function Xt(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}Ot(Yt);const jt=t=>t<256?Kt[t]:Kt[256+(t>>>7)],Jt=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Qt=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,Jt(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},te=(t,e,i)=>{Qt(t,i[2*e],i[2*e+1])},ee=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},ie=(t,e,i)=>{const s=new Array(16);let r,a,o=0;for(r=1;r<=Mt;r++)o=o+i[r-1]<<1,s[r]=o;for(a=0;a<=e;a++){let e=t[2*a+1];0!==e&&(t[2*a]=ee(s[e]++,e))}},se=t=>{let e;for(e=0;e<Ft;e++)t.dyn_ltree[2*e]=0;for(e=0;e<Dt;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},re=t=>{t.bi_valid>8?Jt(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},ae=(t,e,i,s)=>{const r=2*e,a=2*i;return t[r]<t[a]||t[r]===t[a]&&s[e]<=s[i]},oe=(t,e,i)=>{const s=t.heap[i];let r=i<<1;for(;r<=t.heap_len&&(r<t.heap_len&&ae(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!ae(e,s,t.heap[r],t.depth));)t.heap[i]=t.heap[r],i=r,r<<=1;t.heap[i]=s},ne=(t,e,i)=>{let s,r,a,o,n=0;if(0!==t.sym_next)do{s=255&t.pending_buf[t.sym_buf+n++],s+=(255&t.pending_buf[t.sym_buf+n++])<<8,r=t.pending_buf[t.sym_buf+n++],0===s?te(t,r,e):(a=Ht[r],te(t,a+Ut+1,e),o=kt[a],0!==o&&(r-=zt[a],Qt(t,r,o)),s--,a=jt(s),te(t,a,i),o=Lt[a],0!==o&&(s-=Yt[a],Qt(t,s,o)))}while(n<t.sym_next);te(t,256,e)},le=(t,e)=>{const i=e.dyn_tree,s=e.stat_desc.static_tree,r=e.stat_desc.has_stree,a=e.stat_desc.elems;let o,n,l,d=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<a;o++)0!==i[2*o]?(t.heap[++t.heap_len]=d=o,t.depth[o]=0):i[2*o+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=d<2?++d:0,i[2*l]=1,t.depth[l]=0,t.opt_len--,r&&(t.static_len-=s[2*l+1]);for(e.max_code=d,o=t.heap_len>>1;o>=1;o--)oe(t,i,o);l=a;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],oe(t,i,1),n=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=n,i[2*l]=i[2*o]+i[2*n],t.depth[l]=(t.depth[o]>=t.depth[n]?t.depth[o]:t.depth[n])+1,i[2*o+1]=i[2*n+1]=l,t.heap[1]=l++,oe(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,s=e.max_code,r=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,n=e.stat_desc.extra_base,l=e.stat_desc.max_length;let d,c,h,_,p,u,f=0;for(_=0;_<=Mt;_++)t.bl_count[_]=0;for(i[2*t.heap[t.heap_max]+1]=0,d=t.heap_max+1;d<573;d++)c=t.heap[d],_=i[2*i[2*c+1]+1]+1,_>l&&(_=l,f++),i[2*c+1]=_,c>s||(t.bl_count[_]++,p=0,c>=n&&(p=o[c-n]),u=i[2*c],t.opt_len+=u*(_+p),a&&(t.static_len+=u*(r[2*c+1]+p)));if(0!==f){do{for(_=l-1;0===t.bl_count[_];)_--;t.bl_count[_]--,t.bl_count[_+1]+=2,t.bl_count[l]--,f-=2}while(f>0);for(_=l;0!==_;_--)for(c=t.bl_count[_];0!==c;)h=t.heap[--d],h>s||(i[2*h+1]!==_&&(t.opt_len+=(_-i[2*h+1])*i[2*h],i[2*h+1]=_),c--)}})(t,e),ie(i,d,t.bl_count)},de=(t,e,i)=>{let s,r,a=-1,o=e[1],n=0,l=7,d=4;for(0===o&&(l=138,d=3),e[2*(i+1)+1]=65535,s=0;s<=i;s++)r=o,o=e[2*(s+1)+1],++n<l&&r===o||(n<d?t.bl_tree[2*r]+=n:0!==r?(r!==a&&t.bl_tree[2*r]++,t.bl_tree[32]++):n<=10?t.bl_tree[34]++:t.bl_tree[36]++,n=0,a=r,0===o?(l=138,d=3):r===o?(l=6,d=3):(l=7,d=4))},ce=(t,e,i)=>{let s,r,a=-1,o=e[1],n=0,l=7,d=4;for(0===o&&(l=138,d=3),s=0;s<=i;s++)if(r=o,o=e[2*(s+1)+1],!(++n<l&&r===o)){if(n<d)do{te(t,r,t.bl_tree)}while(0!=--n);else 0!==r?(r!==a&&(te(t,r,t.bl_tree),n--),te(t,16,t.bl_tree),Qt(t,n-3,2)):n<=10?(te(t,17,t.bl_tree),Qt(t,n-3,3)):(te(t,18,t.bl_tree),Qt(t,n-11,7));n=0,a=r,0===o?(l=138,d=3):r===o?(l=6,d=3):(l=7,d=4)}};let he=!1;const _e=(t,e,i,s)=>{Qt(t,0+(s?1:0),3),re(t),Jt(t,i),Jt(t,~i),i&&t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i};var pe=t=>{he||((()=>{let t,e,i,s,r;const a=new Array(16);for(i=0,s=0;s<28;s++)for(zt[s]=i,t=0;t<1<<kt[s];t++)Ht[i++]=s;for(Ht[i-1]=s,r=0,s=0;s<16;s++)for(Yt[s]=r,t=0;t<1<<Lt[s];t++)Kt[r++]=s;for(r>>=7;s<Dt;s++)for(Yt[s]=r<<7,t=0;t<1<<Lt[s]-7;t++)Kt[256+r++]=s;for(e=0;e<=Mt;e++)a[e]=0;for(t=0;t<=143;)Gt[2*t+1]=8,t++,a[8]++;for(;t<=255;)Gt[2*t+1]=9,t++,a[9]++;for(;t<=279;)Gt[2*t+1]=7,t++,a[7]++;for(;t<=287;)Gt[2*t+1]=8,t++,a[8]++;for(ie(Gt,287,a),t=0;t<Dt;t++)$t[2*t+1]=5,$t[2*t]=ee(t,5);Wt=new Vt(Gt,kt,257,Ft,Mt),qt=new Vt($t,Lt,0,Dt,Mt),Zt=new Vt(new Array(0),Bt,0,19,7)})(),he=!0),t.l_desc=new Xt(t.dyn_ltree,Wt),t.d_desc=new Xt(t.dyn_dtree,qt),t.bl_desc=new Xt(t.bl_tree,Zt),t.bi_buf=0,t.bi_valid=0,se(t)},ue=(t,e,i,s)=>{let r,a,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Ut;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),le(t,t.l_desc),le(t,t.d_desc),o=(t=>{let e;for(de(t,t.dyn_ltree,t.l_desc.max_code),de(t,t.dyn_dtree,t.d_desc.max_code),le(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Nt[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=r&&(r=a)):r=a=i+5,i+4<=r&&-1!==e?_e(t,e,i,s):4===t.strategy||a===r?(Qt(t,2+(s?1:0),3),ne(t,Gt,$t)):(Qt(t,4+(s?1:0),3),((t,e,i,s)=>{let r;for(Qt(t,e-257,5),Qt(t,i-1,5),Qt(t,s-4,4),r=0;r<s;r++)Qt(t,t.bl_tree[2*Nt[r]+1],3);ce(t,t.dyn_ltree,e-1),ce(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),ne(t,t.dyn_ltree,t.dyn_dtree)),se(t),s&&re(t)},fe={_tr_init:pe,_tr_stored_block:_e,_tr_flush_block:ue,_tr_tally:(t,e,i)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=i,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(Ht[i]+Ut+1)]++,t.dyn_dtree[2*jt(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{Qt(t,2,3),te(t,256,Gt),(t=>{16===t.bi_valid?(Jt(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var Ee=(t,e,i,s)=>{let r=65535&t|0,a=t>>>16&65535|0,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+e[s++]|0,a=a+r|0}while(--o);r%=65521,a%=65521}return r|a<<16|0};const ge=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var s=0;s<8;s++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var me=(t,e,i,s)=>{const r=ge,a=s+i;t^=-1;for(let i=s;i<a;i++)t=t>>>8^r[255&(t^e[i])];return-1^t},ve={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Se={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:ye,_tr_stored_block:be,_tr_flush_block:we,_tr_tally:Re,_tr_align:Ae}=fe,{Z_NO_FLUSH:xe,Z_PARTIAL_FLUSH:Te,Z_FULL_FLUSH:Ce,Z_FINISH:Ie,Z_BLOCK:Pe,Z_OK:Oe,Z_STREAM_END:Ue,Z_STREAM_ERROR:Fe,Z_DATA_ERROR:De,Z_BUF_ERROR:Me,Z_DEFAULT_COMPRESSION:ke,Z_FILTERED:Le,Z_HUFFMAN_ONLY:Be,Z_RLE:Ne,Z_FIXED:Ge,Z_DEFAULT_STRATEGY:$e,Z_UNKNOWN:Ke,Z_DEFLATED:He}=Se,ze=258,Ye=262,Ve=42,We=113,qe=666,Ze=(t,e)=>(t.msg=ve[e],e),Xe=t=>2*t-(t>4?9:0),je=t=>{let e=t.length;for(;--e>=0;)t[e]=0},Je=t=>{let e,i,s,r=t.w_size;e=t.hash_size,s=e;do{i=t.head[--s],t.head[s]=i>=r?i-r:0}while(--e);e=r,s=e;do{i=t.prev[--s],t.prev[s]=i>=r?i-r:0}while(--e)};let Qe=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const ti=(t,e)=>{let i;if(t.legacy_hash)i=t.ins_h=Qe(t,t.ins_h,t.window[e+3-1]);else{const s=t.window,r=s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24;i=t.ins_h=Math.imul(r,66521)+66521>>>16&t.hash_mask}const s=t.prev[e&t.w_mask]=t.head[i];return t.head[i]=e,s},ei=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},ii=(t,e)=>{we(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ei(t.strm)},si=(t,e)=>{t.pending_buf[t.pending++]=e},ri=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},ai=(t,e,i,s)=>{let r=t.avail_in;return r>s&&(r=s),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),i),1===t.state.wrap?t.adler=Ee(t.adler,e,r,i):2===t.state.wrap&&(t.adler=me(t.adler,e,r,i)),t.next_in+=r,t.total_in+=r,r)},oi=(t,e)=>{let i,s,r=t.max_chain_length,a=t.strstart,o=t.prev_length,n=t.nice_match;const l=t.strstart>t.w_size-Ye?t.strstart-(t.w_size-Ye):0,d=t.window,c=t.w_mask,h=t.prev,_=t.strstart+ze;let p=d[a+o-1],u=d[a+o];t.prev_length>=t.good_match&&(r>>=2),n>t.lookahead&&(n=t.lookahead);do{if(i=e,d[i+o]===u&&d[i+o-1]===p&&d[i]===d[a]&&d[++i]===d[a+1]){a+=2,i++;do{}while(d[++a]===d[++i]&&d[++a]===d[++i]&&d[++a]===d[++i]&&d[++a]===d[++i]&&d[++a]===d[++i]&&d[++a]===d[++i]&&d[++a]===d[++i]&&d[++a]===d[++i]&&a<_);if(s=ze-(_-a),a=_-ze,s>o){if(t.match_start=e,o=s,s>=n)break;p=d[a+o-1],u=d[a+o]}}}while((e=h[e&c])>l&&0!=--r);return o<=t.lookahead?o:t.lookahead},ni=t=>{const e=t.w_size;let i,s,r;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Ye)&&(t.window.set(t.window.subarray(e,e+e-s),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),Je(t),s+=e),0===t.strm.avail_in)break;if(i=ai(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=i,t.legacy_hash){if(t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=Qe(t,t.ins_h,t.window[r+1]);t.insert&&(ti(t,r),r++,t.insert--,!(t.lookahead+t.insert<3)););}else if(t.lookahead+t.insert>3)for(r=t.strstart-t.insert;t.insert&&(ti(t,r),r++,t.insert--,!(t.lookahead+t.insert<=3)););}while(t.lookahead<Ye&&0!==t.strm.avail_in)},li=(t,e)=>{let i,s,r,a=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,n=t.strm.avail_in;do{if(i=65535,r=t.bi_valid+42>>3,t.strm.avail_out<r)break;if(r=t.strm.avail_out-r,s=t.strstart-t.block_start,i>s+t.strm.avail_in&&(i=s+t.strm.avail_in),i>r&&(i=r),i<a&&(0===i&&e!==Ie||e===xe||i!==s+t.strm.avail_in))break;o=e===Ie&&i===s+t.strm.avail_in?1:0,be(t,0,0,o),t.pending_buf[t.pending-4]=i,t.pending_buf[t.pending-3]=i>>8,t.pending_buf[t.pending-2]=~i,t.pending_buf[t.pending-1]=~i>>8,ei(t.strm),s&&(s>i&&(s=i),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+s),t.strm.next_out),t.strm.next_out+=s,t.strm.avail_out-=s,t.strm.total_out+=s,t.block_start+=s,i-=s),i&&(ai(t.strm,t.strm.output,t.strm.next_out,i),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i)}while(0===o);return n-=t.strm.avail_in,n&&(n>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=n&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-n,t.strm.next_in),t.strstart),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:e!==xe&&e!==Ie&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(r=t.window_size-t.strstart,t.strm.avail_in>r&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,r+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),r>t.strm.avail_in&&(r=t.strm.avail_in),r&&(ai(t.strm,t.window,t.strstart,r),t.strstart+=r,t.insert+=r>t.w_size-t.insert?t.w_size-t.insert:r),t.high_water<t.strstart&&(t.high_water=t.strstart),r=t.bi_valid+42>>3,r=t.pending_buf_size-r>65535?65535:t.pending_buf_size-r,a=r>t.w_size?t.w_size:r,s=t.strstart-t.block_start,(s>=a||(s||e===Ie)&&e!==xe&&0===t.strm.avail_in&&s<=r)&&(i=s>r?r:s,o=e===Ie&&0===t.strm.avail_in&&i===s?1:0,be(t,t.block_start,i,o),t.block_start+=i,ei(t.strm)),o?3:1)},di=(t,e)=>{let i,s;for(;;){if(t.lookahead<Ye){if(ni(t),t.lookahead<Ye&&e===xe)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(i=ti(t,t.strstart)),0!==i&&t.strstart-i<=t.w_size-Ye&&(t.match_length=oi(t,i)),t.match_length>=3)if(s=Re(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,i=ti(t,t.strstart)}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.legacy_hash&&(t.ins_h=t.window[t.strstart],t.ins_h=Qe(t,t.ins_h,t.window[t.strstart+1]));else s=Re(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(s&&(ii(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Ie?(ii(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ii(t,!1),0===t.strm.avail_out)?1:2},ci=(t,e)=>{let i,s,r;for(;;){if(t.lookahead<Ye){if(ni(t),t.lookahead<Ye&&e===xe)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(i=ti(t,t.strstart)),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-Ye&&(t.match_length=oi(t,i),t.match_length<=5&&(t.strategy===Le||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,s=Re(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(i=ti(t,t.strstart))}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,s&&(ii(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(s=Re(t,0,t.window[t.strstart-1]),s&&ii(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(s=Re(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Ie?(ii(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ii(t,!1),0===t.strm.avail_out)?1:2};function hi(t,e,i,s,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=s,this.func=r}const _i=[new hi(0,0,0,0,li),new hi(4,4,8,4,di),new hi(4,5,16,8,di),new hi(4,6,32,32,di),new hi(4,4,16,16,ci),new hi(8,16,32,32,ci),new hi(8,16,128,128,ci),new hi(8,32,128,256,ci),new hi(32,128,258,1024,ci),new hi(32,258,258,4096,ci)];function pi(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=He,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),je(this.dyn_ltree),je(this.dyn_dtree),je(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),je(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),je(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const ui=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Ve&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==We&&e.status!==qe?1:0},fi=t=>{if(ui(t))return Ze(t,Fe);t.total_in=t.total_out=0,t.data_type=Ke;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Ve:We,t.adler=2===e.wrap?0:1,e.last_flush=-2,ye(e),Oe},Ei=t=>{const e=fi(t);var i;return e===Oe&&((i=t.state).window_size=2*i.w_size,je(i.head),i.max_lazy_match=_i[i.level].max_lazy,i.good_match=_i[i.level].good_length,i.nice_match=_i[i.level].nice_length,i.max_chain_length=_i[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},gi=(t,e,i,s,r,a,o)=>{if(!t)return Fe;let n=1;if(e===ke&&(e=6),s<0?(n=0,s=-s):s>15&&(n=2,s-=16),r<1||r>9||i!==He||s<8||s>15||e<0||e>9||a<0||a>Ge||8===s&&1!==n)return Ze(t,Fe);8===s&&(s=9);const l=new pi;return t.state=l,l.strm=t,l.status=Ve,l.wrap=n,l.gzhead=null,l.w_bits=s,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.legacy_hash=o?1:0,l.hash_bits=r+7,!l.legacy_hash&&l.hash_bits<15&&(l.hash_bits=15),l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+3-1)/3),l.window=new Uint8Array(2*l.w_size),l.head=new Uint16Array(l.hash_size),l.prev=new Uint16Array(l.w_size),l.lit_bufsize=1<<r+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new Uint8Array(l.pending_buf_size),l.sym_buf=l.lit_bufsize,l.sym_end=3*(l.lit_bufsize-1),l.level=e,l.strategy=a,l.method=i,Ei(t)};var mi=(t,e)=>{let i=e.length;if(ui(t))return Fe;const s=t.state,r=s.wrap;if(2===r||1===r&&s.status!==Ve||s.lookahead)return Fe;if(1===r&&(t.adler=Ee(t.adler,e,i,0)),s.wrap=0,i>=s.w_size){0===r&&(je(s.head),s.strstart=0,s.block_start=0,s.insert=0);let t=new Uint8Array(s.w_size);t.set(e.subarray(i-s.w_size,i),0),e=t,i=s.w_size}const a=t.avail_in,o=t.next_in,n=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,ni(s);s.lookahead>=3;){let t=s.strstart,e=s.lookahead-2;do{ti(s,t),t++}while(--e);s.strstart=t,s.lookahead=2,ni(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,t.next_in=o,t.input=n,t.avail_in=a,s.wrap=r,Oe},vi={deflateInit:(t,e)=>gi(t,e,He,15,8,$e),deflateInit2:gi,deflateReset:Ei,deflateResetKeep:fi,deflateSetHeader:(t,e)=>ui(t)||2!==t.state.wrap?Fe:(t.state.gzhead=e,Oe),deflate:(t,e)=>{if(ui(t)||e>Pe||e<0)return t?Ze(t,Fe):Fe;const i=t.state;if(!t.output||0!==t.avail_in&&!t.input||i.status===qe&&e!==Ie)return Ze(t,0===t.avail_out?Me:Fe);const s=i.last_flush;if(i.last_flush=e,0!==i.pending){if(ei(t),0===t.avail_out)return i.last_flush=-1,Oe}else if(0===t.avail_in&&Xe(e)<=Xe(s)&&e!==Ie)return Ze(t,Me);if(i.status===qe&&0!==t.avail_in)return Ze(t,Me);if(i.status===Ve&&0===i.wrap&&(i.status=We),i.status===Ve){let e=He+(i.w_bits-8<<4)<<8,s=-1;if(s=i.strategy>=Be||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=s<<6,0!==i.strstart&&(e|=32),e+=31-e%31,ri(i,e),0!==i.strstart&&(ri(i,t.adler>>>16),ri(i,65535&t.adler)),t.adler=1,i.status=We,ei(t),0!==i.pending)return i.last_flush=-1,Oe}if(57===i.status)if(t.adler=0,si(i,31),si(i,139),si(i,8),i.gzhead)si(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),si(i,255&i.gzhead.time),si(i,i.gzhead.time>>8&255),si(i,i.gzhead.time>>16&255),si(i,i.gzhead.time>>24&255),si(i,9===i.level?2:i.strategy>=Be||i.level<2?4:0),si(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(si(i,255&i.gzhead.extra.length),si(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=me(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(si(i,0),si(i,0),si(i,0),si(i,0),si(i,0),si(i,9===i.level?2:i.strategy>=Be||i.level<2?4:0),si(i,3),i.status=We,ei(t),0!==i.pending)return i.last_flush=-1,Oe;if(69===i.status){if(i.gzhead.extra){let e=i.pending,s=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+s>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>e&&(t.adler=me(t.adler,i.pending_buf,i.pending-e,e)),i.gzindex+=r,ei(t),0!==i.pending)return i.last_flush=-1,Oe;e=0,s-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+s),i.pending),i.pending+=s,i.gzhead.hcrc&&i.pending>e&&(t.adler=me(t.adler,i.pending_buf,i.pending-e,e)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let e,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(t.adler=me(t.adler,i.pending_buf,i.pending-s,s)),ei(t),0!==i.pending)return i.last_flush=-1,Oe;s=0}e=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,si(i,e)}while(0!==e);i.gzhead.hcrc&&i.pending>s&&(t.adler=me(t.adler,i.pending_buf,i.pending-s,s)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let e,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(t.adler=me(t.adler,i.pending_buf,i.pending-s,s)),ei(t),0!==i.pending)return i.last_flush=-1,Oe;s=0}e=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,si(i,e)}while(0!==e);i.gzhead.hcrc&&i.pending>s&&(t.adler=me(t.adler,i.pending_buf,i.pending-s,s))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(ei(t),0!==i.pending))return i.last_flush=-1,Oe;si(i,255&t.adler),si(i,t.adler>>8&255),t.adler=0}if(i.status=We,ei(t),0!==i.pending)return i.last_flush=-1,Oe}if(0!==t.avail_in||0!==i.lookahead||e!==xe&&i.status!==qe){let s=0===i.level?li(i,e):i.strategy===Be?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(ni(t),0===t.lookahead)){if(e===xe)return 1;break}if(t.match_length=0,i=Re(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(ii(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Ie?(ii(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ii(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===Ne?((t,e)=>{let i,s,r,a;const o=t.window;for(;;){if(t.lookahead<=ze){if(ni(t),t.lookahead<=ze&&e===xe)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,s=o[r],s===o[++r]&&s===o[++r]&&s===o[++r])){a=t.strstart+ze;do{}while(s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&r<a);t.match_length=ze-(a-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=Re(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=Re(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(ii(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Ie?(ii(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ii(t,!1),0===t.strm.avail_out)?1:2})(i,e):_i[i.level].func(i,e);if(3!==s&&4!==s||(i.status=qe),1===s||3===s)return 0===t.avail_out&&(i.last_flush=-1),Oe;if(2===s&&(e===Te?Ae(i):e!==Pe&&(be(i,0,0,!1),e===Ce&&(je(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),ei(t),0===t.avail_out))return i.last_flush=-1,Oe}return e!==Ie?Oe:i.wrap<=0?Ue:(2===i.wrap?(si(i,255&t.adler),si(i,t.adler>>8&255),si(i,t.adler>>16&255),si(i,t.adler>>24&255),si(i,255&t.total_in),si(i,t.total_in>>8&255),si(i,t.total_in>>16&255),si(i,t.total_in>>24&255)):(ri(i,t.adler>>>16),ri(i,65535&t.adler)),ei(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Oe:Ue)},deflateEnd:t=>{if(ui(t))return Fe;const e=t.state.status;return t.state=null,e===We?Ze(t,De):Oe},deflateSetDictionary:mi,deflateInfo:"pako deflate (from Nodeca project)"};const Si=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var yi={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Si(i,e)&&(t[e]=i[e])}}return t},flattenChunks:t=>{let e=0;for(let i=0,s=t.length;i<s;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,s=0,r=t.length;e<r;e++){let r=t[e];i.set(r,s),s+=r.length}return i}};let bi=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){bi=!1}const wi=new Uint8Array(256);for(let t=0;t<256;t++)wi[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;wi[254]=wi[255]=1;var Ri={string2buf:t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,s,r,a,o=t.length,n=0;for(r=0;r<o;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<o&&(s=t.charCodeAt(r+1),56320==(64512&s)&&(i=65536+(i-55296<<10)+(s-56320),r++)),n+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(n),a=0,r=0;a<n;r++)i=t.charCodeAt(r),55296==(64512&i)&&r+1<o&&(s=t.charCodeAt(r+1),56320==(64512&s)&&(i=65536+(i-55296<<10)+(s-56320),r++)),i<128?e[a++]=i:i<2048?(e[a++]=192|i>>>6,e[a++]=128|63&i):i<65536?(e[a++]=224|i>>>12,e[a++]=128|i>>>6&63,e[a++]=128|63&i):(e[a++]=240|i>>>18,e[a++]=128|i>>>12&63,e[a++]=128|i>>>6&63,e[a++]=128|63&i);return e},buf2string:(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let s,r;const a=new Array(2*i);for(r=0,s=0;s<i;){let e=t[s++];if(e<128){a[r++]=e;continue}let o=wi[e];if(o>4)a[r++]=65533,s+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&s<i;)e=e<<6|63&t[s++],o--;o>1?a[r++]=65533:e<65536?a[r++]=e:(e-=65536,a[r++]=55296|e>>10&1023,a[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&bi)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let s=0;s<e;s++)i+=String.fromCharCode(t[s]);return i})(a,r)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+wi[t[i]]>e?i:e}};var Ai=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const xi=Object.prototype.toString,{Z_NO_FLUSH:Ti,Z_SYNC_FLUSH:Ci,Z_FULL_FLUSH:Ii,Z_FINISH:Pi,Z_OK:Oi,Z_STREAM_END:Ui,Z_DEFAULT_COMPRESSION:Fi,Z_DEFAULT_STRATEGY:Di,Z_DEFLATED:Mi}=Se,ki={level:Fi,method:Mi,chunkSize:16384,windowBits:15,memLevel:8,strategy:Di,legacyHash:!0};function Li(t){this.options=yi.assign({},ki,t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ai,this.strm.avail_out=0;let i=vi.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy,e.legacyHash);if(i!==Oi)throw new Error(ve[i]);if(e.header&&vi.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Ri.string2buf(e.dictionary):"[object ArrayBuffer]"===xi.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=vi.deflateSetDictionary(this.strm,t),i!==Oi)throw new Error(ve[i]);this._dict_set=!0}}Li.prototype.push=function(t,e){const i=this.strm,s=this.options.chunkSize;let r,a;if(this.ended)return!1;for(a=e===~~e?e:!0===e?Pi:Ti,"string"==typeof t?i.input=Ri.string2buf(t):"[object ArrayBuffer]"===xi.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(a===Ci||a===Ii)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=vi.deflate(i,a),r===Ui)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=vi.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Oi;if(0!==i.avail_out){if(a>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Li.prototype.onData=function(t){this.chunks.push(t)},Li.prototype.onEnd=function(t){t===Oi&&(this.result=yi.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Bi={deflate:function(t,e){const i=new Li(e);if(i.push(t,!0),i.err)throw i.msg||ve[i.err];return i.result}};const Ni=16209;var Gi=function(t,e){let i,s,r,a,o,n,l,d,c,h,_,p,u,f,E,g,m,v,S,y,b,w,R,A;const x=t.state;i=t.next_in,R=t.input,s=i+(t.avail_in-5),r=t.next_out,A=t.output,a=r-(e-t.avail_out),o=r+(t.avail_out-257),n=x.dmax,l=x.wsize,d=x.whave,c=x.wnext,h=x.window,_=x.hold,p=x.bits,u=x.lencode,f=x.distcode,E=(1<<x.lenbits)-1,g=(1<<x.distbits)-1;t:do{p<15&&(_+=R[i++]<<p,p+=8,_+=R[i++]<<p,p+=8),m=u[_&E];e:for(;;){if(v=m>>>24,_>>>=v,p-=v,v=m>>>16&255,0===v)A[r++]=65535&m;else{if(!(16&v)){if(0==(64&v)){m=u[(65535&m)+(_&(1<<v)-1)];continue e}if(32&v){x.mode=16191;break t}t.msg="invalid literal/length code",x.mode=Ni;break t}S=65535&m,v&=15,v&&(p<v&&(_+=R[i++]<<p,p+=8),S+=_&(1<<v)-1,_>>>=v,p-=v),p<15&&(_+=R[i++]<<p,p+=8,_+=R[i++]<<p,p+=8),m=f[_&g];i:for(;;){if(v=m>>>24,_>>>=v,p-=v,v=m>>>16&255,!(16&v)){if(0==(64&v)){m=f[(65535&m)+(_&(1<<v)-1)];continue i}t.msg="invalid distance code",x.mode=Ni;break t}if(y=65535&m,v&=15,p<v&&(_+=R[i++]<<p,p+=8,p<v&&(_+=R[i++]<<p,p+=8)),y+=_&(1<<v)-1,y>n){t.msg="invalid distance too far back",x.mode=Ni;break t}if(_>>>=v,p-=v,v=r-a,y>v){if(v=y-v,v>d&&x.sane){t.msg="invalid distance too far back",x.mode=Ni;break t}if(b=0,w=h,0===c){if(b+=l-v,v<S){S-=v;do{A[r++]=h[b++]}while(--v);b=r-y,w=A}}else if(c<v){if(b+=l+c-v,v-=c,v<S){S-=v;do{A[r++]=h[b++]}while(--v);if(b=0,c<S){v=c,S-=v;do{A[r++]=h[b++]}while(--v);b=r-y,w=A}}}else if(b+=c-v,v<S){S-=v;do{A[r++]=h[b++]}while(--v);b=r-y,w=A}for(;S>2;)A[r++]=w[b++],A[r++]=w[b++],A[r++]=w[b++],S-=3;S&&(A[r++]=w[b++],S>1&&(A[r++]=w[b++]))}else{b=r-y;do{A[r++]=A[b++],A[r++]=A[b++],A[r++]=A[b++],S-=3}while(S>2);S&&(A[r++]=A[b++],S>1&&(A[r++]=A[b++]))}break}}break}}while(i<s&&r<o);S=p>>3,i-=S,p-=S<<3,_&=(1<<p)-1,t.next_in=i,t.next_out=r,t.avail_in=i<s?s-i+5:5-(i-s),t.avail_out=r<o?o-r+257:257-(r-o),x.hold=_,x.bits=p};const $i=15,Ki=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Hi=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),zi=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Yi=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Vi=(t,e,i,s,r,a,o,n)=>{const l=n.bits;let d,c,h,_,p,u,f=0,E=0,g=0,m=0,v=0,S=0,y=0,b=0,w=0,R=0,A=null;const x=new Uint16Array(16),T=new Uint16Array(16);let C,I,P,O=null;for(f=0;f<=$i;f++)x[f]=0;for(E=0;E<s;E++)x[e[i+E]]++;for(v=l,m=$i;m>=1&&0===x[m];m--);if(v>m&&(v=m),0===m)return r[a++]=20971520,r[a++]=20971520,n.bits=1,0;for(g=1;g<m&&0===x[g];g++);for(v<g&&(v=g),b=1,f=1;f<=$i;f++)if(b<<=1,b-=x[f],b<0)return-1;if(b>0&&(0===t||1!==m))return-1;for(T[1]=0,f=1;f<$i;f++)T[f+1]=T[f]+x[f];for(E=0;E<s;E++)0!==e[i+E]&&(o[T[e[i+E]]++]=E);if(0===t?(A=O=o,u=20):1===t?(A=Ki,O=Hi,u=257):(A=zi,O=Yi,u=0),R=0,E=0,f=g,p=a,S=v,y=0,h=-1,w=1<<v,_=w-1,1===t&&w>852||2===t&&w>592)return 1;for(;;){C=f-y,o[E]+1<u?(I=0,P=o[E]):o[E]>=u?(I=O[o[E]-u],P=A[o[E]-u]):(I=96,P=0),d=1<<f-y,c=1<<S,g=c;do{c-=d,r[p+(R>>y)+c]=C<<24|I<<16|P|0}while(0!==c);for(d=1<<f-1;R&d;)d>>=1;if(0!==d?(R&=d-1,R+=d):R=0,E++,0==--x[f]){if(f===m)break;f=e[i+o[E]]}if(f>v&&(R&_)!==h){for(0===y&&(y=v),p+=g,S=f-y,b=1<<S;S+y<m&&(b-=x[S+y],!(b<=0));)S++,b<<=1;if(w+=1<<S,1===t&&w>852||2===t&&w>592)return 1;h=R&_,r[h]=v<<24|S<<16|p-a|0}}return 0!==R&&(r[p+R]=f-y<<24|64<<16|0),n.bits=v,0};const{Z_FINISH:Wi,Z_BLOCK:qi,Z_TREES:Zi,Z_OK:Xi,Z_STREAM_END:ji,Z_NEED_DICT:Ji,Z_STREAM_ERROR:Qi,Z_DATA_ERROR:ts,Z_MEM_ERROR:es,Z_BUF_ERROR:is,Z_DEFLATED:ss}=Se,rs=16180,as=16190,os=16191,ns=16192,ls=16194,ds=16199,cs=16200,hs=16206,_s=16209,ps=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function us(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const fs=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<rs||e.mode>16211?1:0},Es=t=>{if(fs(t))return Qi;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=rs,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,Xi},gs=t=>{if(fs(t))return Qi;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Es(t)},ms=(t,e)=>{let i;if(fs(t))return Qi;const s=t.state;return e<0?(i=0,e=-e):(i=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?Qi:(null!==s.window&&s.wbits!==e&&(s.window=null),s.wrap=i,s.wbits=e,gs(t))},vs=(t,e)=>{if(!t)return Qi;const i=new us;t.state=i,i.strm=t,i.window=null,i.mode=rs;const s=ms(t,e);return s!==Xi&&(t.state=null),s};let Ss,ys,bs=!0;const ws=t=>{if(bs){Ss=new Int32Array(512),ys=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Vi(1,t.lens,0,288,Ss,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Vi(2,t.lens,0,32,ys,0,t.work,{bits:5}),bs=!1}t.lencode=Ss,t.lenbits=9,t.distcode=ys,t.distbits=5},Rs=(t,e,i,s)=>{let r;const a=t.state;return null===a.window&&(a.window=new Uint8Array(1<<a.wbits)),0===a.wsize&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0),s>=a.wsize?(a.window.set(e.subarray(i-a.wsize,i),0),a.wnext=0,a.whave=a.wsize):(r=a.wsize-a.wnext,r>s&&(r=s),a.window.set(e.subarray(i-s,i-s+r),a.wnext),(s-=r)?(a.window.set(e.subarray(i-s,i),0),a.wnext=s,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=r))),0};var As=(t,e)=>{let i,s,r,a,o,n,l,d,c,h,_,p,u,f,E,g,m,v,S,y,b,w,R=0;const A=new Uint8Array(4);let x,T;const C=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(fs(t)||!t.output||!t.input&&0!==t.avail_in)return Qi;i=t.state,i.mode===os&&(i.mode=ns),o=t.next_out,r=t.output,l=t.avail_out,a=t.next_in,s=t.input,n=t.avail_in,d=i.hold,c=i.bits,h=n,_=l,w=Xi;t:for(;;)switch(i.mode){case rs:if(0===i.wrap){i.mode=ns;break}for(;c<16;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(2&i.wrap&&35615===d){0===i.wbits&&(i.wbits=15),i.check=0,A[0]=255&d,A[1]=d>>>8&255,i.check=me(i.check,A,2,0),d=0,c=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&d)<<8)+(d>>8))%31){t.msg="incorrect header check",i.mode=_s;break}if((15&d)!==ss){t.msg="unknown compression method",i.mode=_s;break}if(d>>>=4,c-=4,b=8+(15&d),0===i.wbits&&(i.wbits=b),b>15||b>i.wbits){t.msg="invalid window size",i.mode=_s;break}i.dmax=1<<i.wbits,i.flags=0,t.adler=i.check=1,i.mode=512&d?16189:os,d=0,c=0;break;case 16181:for(;c<16;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(i.flags=d,(255&i.flags)!==ss){t.msg="unknown compression method",i.mode=_s;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=_s;break}i.head&&(i.head.text=d>>8&1),512&i.flags&&4&i.wrap&&(A[0]=255&d,A[1]=d>>>8&255,i.check=me(i.check,A,2,0)),d=0,c=0,i.mode=16182;case 16182:for(;c<32;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}i.head&&(i.head.time=d),512&i.flags&&4&i.wrap&&(A[0]=255&d,A[1]=d>>>8&255,A[2]=d>>>16&255,A[3]=d>>>24&255,i.check=me(i.check,A,4,0)),d=0,c=0,i.mode=16183;case 16183:for(;c<16;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}i.head&&(i.head.xflags=255&d,i.head.os=d>>8),512&i.flags&&4&i.wrap&&(A[0]=255&d,A[1]=d>>>8&255,i.check=me(i.check,A,2,0)),d=0,c=0,i.mode=16184;case 16184:if(1024&i.flags){for(;c<16;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}i.length=d,i.head&&(i.head.extra_len=d),512&i.flags&&4&i.wrap&&(A[0]=255&d,A[1]=d>>>8&255,i.check=me(i.check,A,2,0)),d=0,c=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(p=i.length,p>n&&(p=n),p&&(i.head&&(b=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(s.subarray(a,a+p),b)),512&i.flags&&4&i.wrap&&(i.check=me(i.check,s,p,a)),n-=p,a+=p,i.length-=p),i.length))break t;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===n)break t;p=0;do{b=s[a+p++],i.head&&b&&i.length<65536&&(i.head.name+=String.fromCharCode(b))}while(b&&p<n);if(512&i.flags&&4&i.wrap&&(i.check=me(i.check,s,p,a)),n-=p,a+=p,b)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===n)break t;p=0;do{b=s[a+p++],i.head&&b&&i.length<65536&&(i.head.comment+=String.fromCharCode(b))}while(b&&p<n);if(512&i.flags&&4&i.wrap&&(i.check=me(i.check,s,p,a)),n-=p,a+=p,b)break t}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;c<16;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(4&i.wrap&&d!==(65535&i.check)){t.msg="header crc mismatch",i.mode=_s;break}d=0,c=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=os;break;case 16189:for(;c<32;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}t.adler=i.check=ps(d),d=0,c=0,i.mode=as;case as:if(0===i.havedict)return t.next_out=o,t.avail_out=l,t.next_in=a,t.avail_in=n,i.hold=d,i.bits=c,Ji;t.adler=i.check=1,i.mode=os;case os:if(e===qi||e===Zi)break t;case ns:if(i.last){d>>>=7&c,c-=7&c,i.mode=hs;break}for(;c<3;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}switch(i.last=1&d,d>>>=1,c-=1,3&d){case 0:i.mode=16193;break;case 1:if(ws(i),i.mode=ds,e===Zi){d>>>=2,c-=2;break t}break;case 2:i.mode=16196;break;case 3:t.msg="invalid block type",i.mode=_s}d>>>=2,c-=2;break;case 16193:for(d>>>=7&c,c-=7&c;c<32;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if((65535&d)!=(d>>>16^65535)){t.msg="invalid stored block lengths",i.mode=_s;break}if(i.length=65535&d,d=0,c=0,i.mode=ls,e===Zi)break t;case ls:i.mode=16195;case 16195:if(p=i.length,p){if(p>n&&(p=n),p>l&&(p=l),0===p)break t;r.set(s.subarray(a,a+p),o),n-=p,a+=p,l-=p,o+=p,i.length-=p;break}i.mode=os;break;case 16196:for(;c<14;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(i.nlen=257+(31&d),d>>>=5,c-=5,i.ndist=1+(31&d),d>>>=5,c-=5,i.ncode=4+(15&d),d>>>=4,c-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=_s;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;c<3;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}i.lens[C[i.have++]]=7&d,d>>>=3,c-=3}for(;i.have<19;)i.lens[C[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,x={bits:i.lenbits},w=Vi(0,i.lens,0,19,i.lencode,0,i.work,x),i.lenbits=x.bits,w){t.msg="invalid code lengths set",i.mode=_s;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;R=i.lencode[d&(1<<i.lenbits)-1],E=R>>>24,g=R>>>16&255,m=65535&R,!(E<=c);){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(m<16)d>>>=E,c-=E,i.lens[i.have++]=m;else{if(16===m){for(T=E+2;c<T;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(d>>>=E,c-=E,0===i.have){t.msg="invalid bit length repeat",i.mode=_s;break}b=i.lens[i.have-1],p=3+(3&d),d>>>=2,c-=2}else if(17===m){for(T=E+3;c<T;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}d>>>=E,c-=E,b=0,p=3+(7&d),d>>>=3,c-=3}else{for(T=E+7;c<T;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}d>>>=E,c-=E,b=0,p=11+(127&d),d>>>=7,c-=7}if(i.have+p>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=_s;break}for(;p--;)i.lens[i.have++]=b}}if(i.mode===_s)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=_s;break}if(i.lenbits=9,x={bits:i.lenbits},w=Vi(1,i.lens,0,i.nlen,i.lencode,0,i.work,x),i.lenbits=x.bits,w){t.msg="invalid literal/lengths set",i.mode=_s;break}if(i.distbits=6,i.distcode=i.distdyn,x={bits:i.distbits},w=Vi(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,x),i.distbits=x.bits,w){t.msg="invalid distances set",i.mode=_s;break}if(i.mode=ds,e===Zi)break t;case ds:i.mode=cs;case cs:if(n>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=a,t.avail_in=n,i.hold=d,i.bits=c,Gi(t,_),o=t.next_out,r=t.output,l=t.avail_out,a=t.next_in,s=t.input,n=t.avail_in,d=i.hold,c=i.bits,i.mode===os&&(i.back=-1);break}for(i.back=0;R=i.lencode[d&(1<<i.lenbits)-1],E=R>>>24,g=R>>>16&255,m=65535&R,!(E<=c);){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(g&&0==(240&g)){for(v=E,S=g,y=m;R=i.lencode[y+((d&(1<<v+S)-1)>>v)],E=R>>>24,g=R>>>16&255,m=65535&R,!(v+E<=c);){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}d>>>=v,c-=v,i.back+=v}if(d>>>=E,c-=E,i.back+=E,i.length=m,0===g){i.mode=16205;break}if(32&g){i.back=-1,i.mode=os;break}if(64&g){t.msg="invalid literal/length code",i.mode=_s;break}i.extra=15&g,i.mode=16201;case 16201:if(i.extra){for(T=i.extra;c<T;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}i.length+=d&(1<<i.extra)-1,d>>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;R=i.distcode[d&(1<<i.distbits)-1],E=R>>>24,g=R>>>16&255,m=65535&R,!(E<=c);){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(0==(240&g)){for(v=E,S=g,y=m;R=i.distcode[y+((d&(1<<v+S)-1)>>v)],E=R>>>24,g=R>>>16&255,m=65535&R,!(v+E<=c);){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}d>>>=v,c-=v,i.back+=v}if(d>>>=E,c-=E,i.back+=E,64&g){t.msg="invalid distance code",i.mode=_s;break}i.offset=m,i.extra=15&g,i.mode=16203;case 16203:if(i.extra){for(T=i.extra;c<T;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}i.offset+=d&(1<<i.extra)-1,d>>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=_s;break}i.mode=16204;case 16204:if(0===l)break t;if(p=_-l,i.offset>p){if(p=i.offset-p,p>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=_s;break}p>i.wnext?(p-=i.wnext,u=i.wsize-p):u=i.wnext-p,p>i.length&&(p=i.length),f=i.window}else f=r,u=o-i.offset,p=i.length;p>l&&(p=l),l-=p,i.length-=p;do{r[o++]=f[u++]}while(--p);0===i.length&&(i.mode=cs);break;case 16205:if(0===l)break t;r[o++]=i.length,l--,i.mode=cs;break;case hs:if(i.wrap){for(;c<32;){if(0===n)break t;n--,d|=s[a++]<<c,c+=8}if(_-=l,t.total_out+=_,i.total+=_,4&i.wrap&&_&&(t.adler=i.check=i.flags?me(i.check,r,_,o-_):Ee(i.check,r,_,o-_)),_=l,4&i.wrap&&(i.flags?d:ps(d))!==i.check){t.msg="incorrect data check",i.mode=_s;break}d=0,c=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;c<32;){if(0===n)break t;n--,d+=s[a++]<<c,c+=8}if(4&i.wrap&&d!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=_s;break}d=0,c=0}i.mode=16208;case 16208:w=ji;break t;case _s:w=ts;break t;case 16210:return es;default:return Qi}return t.next_out=o,t.avail_out=l,t.next_in=a,t.avail_in=n,i.hold=d,i.bits=c,(i.wsize||_!==t.avail_out&&i.mode<_s&&(i.mode<hs||e!==Wi))&&Rs(t,t.output,t.next_out,_-t.avail_out),h-=t.avail_in,_-=t.avail_out,t.total_in+=h,t.total_out+=_,i.total+=_,4&i.wrap&&_&&(t.adler=i.check=i.flags?me(i.check,r,_,t.next_out-_):Ee(i.check,r,_,t.next_out-_)),t.data_type=i.bits+(i.last?64:0)+(i.mode===os?128:0)+(i.mode===ds||i.mode===ls?256:0),(0===h&&0===_||e===Wi)&&w===Xi&&(w=is),w},xs={inflateReset:gs,inflateReset2:ms,inflateResetKeep:Es,inflateInit:t=>vs(t,15),inflateInit2:vs,inflate:As,inflateEnd:t=>{if(fs(t))return Qi;let e=t.state;return e.window&&(e.window=null),t.state=null,Xi},inflateGetHeader:(t,e)=>{if(fs(t))return Qi;const i=t.state;return 0==(2&i.wrap)?Qi:(i.head=e,e.done=!1,Xi)},inflateSetDictionary:(t,e)=>{const i=e.length;let s,r,a;return fs(t)?Qi:(s=t.state,0!==s.wrap&&s.mode!==as?Qi:s.mode===as&&(r=1,r=Ee(r,e,i,0),r!==s.check)?ts:(a=Rs(t,e,i,i),a?(s.mode=16210,es):(s.havedict=1,Xi)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ts=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Cs=Object.prototype.toString,{Z_NO_FLUSH:Is,Z_FINISH:Ps,Z_OK:Os,Z_STREAM_END:Us,Z_NEED_DICT:Fs,Z_STREAM_ERROR:Ds,Z_DATA_ERROR:Ms,Z_MEM_ERROR:ks,Z_BUF_ERROR:Ls}=Se,Bs={chunkSize:65536,windowBits:15,to:""};function Ns(t){this.options=yi.assign({},Bs,t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ai,this.strm.avail_out=0;let i=xs.inflateInit2(this.strm,e.windowBits);if(i!==Os)throw new Error(ve[i]);if(this.header=new Ts,xs.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Ri.string2buf(e.dictionary):"[object ArrayBuffer]"===Cs.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=xs.inflateSetDictionary(this.strm,e.dictionary),i!==Os)))throw new Error(ve[i])}Ns.prototype.push=function(t,e){const i=this.strm,s=this.options.chunkSize,r=this.options.dictionary;let a,o,n;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Ps:Is,"[object ArrayBuffer]"===Cs.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),a=xs.inflate(i,o),a===Fs&&r&&(a=xs.inflateSetDictionary(i,r),a===Os?a=xs.inflate(i,o):a===Ms&&(a=Fs));i.avail_in>0&&a===Us&&2&i.state.wrap&&0!==i.state.flags&&0!==i.input[i.next_in];)xs.inflateReset(i),a=xs.inflate(i,o);switch(a){case Ds:case Ms:case Fs:case ks:return this.onEnd(a),this.ended=!0,!1}if(n=i.avail_out,i.next_out&&(0===i.avail_out||a===Us||o>0))if("string"===this.options.to){let t=Ri.utf8border(i.output,i.next_out),e=i.next_out-t,r=Ri.buf2string(i.output,t);i.next_out=e,i.avail_out=s-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out)),i.avail_out=0,i.next_out=0;if(a!==Os&&a!==Ls||0!==n){if(a===Us)return a=xs.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===i.avail_in){if(o===Ps)return a=xs.inflateEnd(this.strm),this.onEnd(a===Os?Ls:a),this.ended=!0,!1;break}}}return!0},Ns.prototype.onData=function(t){this.chunks.push(t)},Ns.prototype.onEnd=function(t){t===Os&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=yi.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Gs={Inflate:Ns};const{deflate:$s}=Bi,{Inflate:Ks}=Gs;var Hs=$s,zs=Ks;function Ys(t,e,i=255){const s=t.length%e;if(0!==s){const r=new Uint8Array(e-s).fill(i),a=new Uint8Array(t.length+r.length);return a.set(t),a.set(r,t.length),a}return t}function Vs(t,e=239){for(let i=0;i<t.length;i++)e^=t[i];return e}function Ws(t){const e=new Uint8Array(t.length);for(let i=0;i<t.length;i++)e[i]=t.charCodeAt(i);return e}function qs(t){return new Promise((e=>setTimeout(e,t)))}class Zs{constructor(t,e=!1,i=!0){this.device=t,this.tracing=e,this.slipReaderEnabled=!1,this.baudrate=0,this.traceLog="",this.lastTraceTime=Date.now(),this.buffer=new Uint8Array(0),this.onDeviceLostCallback=null,this.SLIP_END=192,this.SLIP_ESC=219,this.SLIP_ESC_END=220,this.SLIP_ESC_ESC=221,this._DTR_state=!1,this.slipReaderEnabled=i}setDeviceLostCallback(t){this.onDeviceLostCallback=t}updateDevice(t){this.device=t,this.trace("Device reference updated")}getInfo(){const t=this.device.getInfo();return t.usbVendorId&&t.usbProductId?`WebSerial VendorID 0x${t.usbVendorId.toString(16)} ProductID 0x${t.usbProductId.toString(16)}`:""}getVid(){return this.device.getInfo().usbVendorId}getPid(){return this.device.getInfo().usbProductId}trace(t){const e=`${`TRACE ${(Date.now()-this.lastTraceTime).toFixed(3)}`} ${t}`;console.log(e),this.traceLog+=e+"\n"}async returnTrace(){try{await navigator.clipboard.writeText(this.traceLog),console.log("Text copied to clipboard!")}catch(t){console.error("Failed to copy text:",t)}}hexify(t){return Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("").padEnd(16," ")}hexConvert(t,e=!0){if(e&&t.length>16){let e="",i=t;for(;i.length>0;){const t=i.slice(0,16),s=String.fromCharCode(...t).split("").map((t=>" "===t||t>=" "&&t<="~"&&"  "!==t?t:".")).join("");i=i.slice(16),e+=`\n    ${this.hexify(t.slice(0,8))} ${this.hexify(t.slice(8))} | ${s}`}return e}return this.hexify(t)}slipWriter(t){const e=[];e.push(192);for(let i=0;i<t.length;i++)219===t[i]?e.push(219,221):192===t[i]?e.push(219,220):e.push(t[i]);return e.push(192),new Uint8Array(e)}async write(t){const e=this.slipWriter(t);if(this.device.writable){const t=this.device.writable.getWriter();this.tracing&&this.trace(`Write ${e.length} bytes: ${this.hexConvert(e)}`),await t.write(e),t.releaseLock()}}appendArray(t,e){const i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i}async readLoop(){for(var t;this.device.readable;){this.reader=null===(t=this.device.readable)||void 0===t?void 0:t.getReader();try{const{value:t,done:e}=await this.reader.read();if(e){this.trace("Serial port done");break}if(t&&t.length){const e=Uint8Array.from(t);this.buffer=this.appendArray(this.buffer,e)}}catch(t){if(t instanceof Error){if(["BufferOverrunError","FramingError","BreakError","ParityError"].includes(t.name)){this.trace(`Recoverable serial port error: ${t.message}`);continue}this.trace(`Unrecoverable serial port error: ${t.message}`);break}if(t instanceof DOMException){this.onDeviceLostCallback?this.onDeviceLostCallback():this.trace(`Unrecoverable serial port error: ${t.message}`);break}this.trace(`Unrecoverable serial port error: ${t}`);break}finally{this.reader.releaseLock()}}this.trace("readLoop exited")}flushInput(){this.buffer=new Uint8Array(0)}async drainInput(t=100,e=400){const i=Date.now()+e;let s=-1;for(;Date.now()<i&&this.buffer.length!==s;)s=this.buffer.length,await qs(t);this.tracing&&this.trace(`Drained ${this.buffer.length} bytes from serial buffer`),this.flushInput()}async flushOutput(){try{if(this.device.writable){const t=this.device.writable.getWriter();await t.close(),t.releaseLock()}}catch(t){this.trace(`Error while flushing output: ${t}`)}}inWaiting(){return this.buffer.length}peek(){return this.buffer}detectPanicHandler(t){const e=new TextDecoder("utf-8").decode(t),i=e.match(/G?uru Meditation Error: (?:Core \d panic'ed \(([a-zA-Z ]*)\))?/)||e.match(/F?atal exception \(\d+\): (?:([a-zA-Z ]*)?.*epc)?/);if(i){const t=i[1]||i[2];throw new Error("Guru Meditation Error detected"+(t?` (${t})`:""))}}async read(t){let e=null,i=!1,s=null;for(;;){const r=Date.now();for(s=new Uint8Array(0);Date.now()-r<t;){if(this.buffer.length>0){s=this.buffer,this.buffer=new Uint8Array(0);break}await qs(1)}if(!s||0===s.length){const t=null===e?"Serial data stream stopped: Possible serial noise or corruption.":"No serial data received.";throw this.tracing&&this.trace(t),new xt(t)}this.tracing&&this.trace(`Read ${s.length} bytes: ${this.hexConvert(s)}`);for(let t=0;t<s.length;t++){const r=s[t];if(null===e){if(r!==this.SLIP_END){this.tracing&&this.trace(`Read invalid data: ${this.hexConvert(s)}`);const t=this.buffer;throw this.tracing&&this.trace(`Remaining data in serial buffer: ${this.hexConvert(t)}`),this.detectPanicHandler(new Uint8Array([...s,...t||[]])),new xt(`Invalid head of packet (0x${r.toString(16)}): Possible serial noise or corruption.`)}e=new Uint8Array(0)}else if(i)if(i=!1,r===this.SLIP_ESC_END)e=this.appendArray(e,new Uint8Array([this.SLIP_END]));else{if(r!==this.SLIP_ESC_ESC){this.tracing&&this.trace(`Read invalid data: ${this.hexConvert(s)}`);const t=this.buffer;throw this.tracing&&this.trace(`Remaining data in serial buffer: ${this.hexConvert(t)}`),this.detectPanicHandler(new Uint8Array([...s,...t||[]])),new xt(`Invalid SLIP escape (0xdb, 0x${r.toString(16)})`)}e=this.appendArray(e,new Uint8Array([this.SLIP_ESC]))}else if(r===this.SLIP_ESC)i=!0;else{if(r===this.SLIP_END){if(this.tracing&&this.trace(`Received full packet: ${this.hexConvert(e)}`),t+1<s.length){const e=s.slice(t+1);this.buffer=this.appendArray(e,this.buffer)}return e}e=this.appendArray(e,new Uint8Array([r]))}}}}async rawRead(t,e){let i;try{if(!this.device.readable)return;for(i=this.device.readable.getReader(),this.reader=i;!e();){const{value:e,done:s}=await i.read();if(s||!e)break;this.tracing&&this.trace(`Read ${e.length} bytes: ${this.hexConvert(e)}`),t(e)}}catch(t){this.trace(`Error reading from serial port: ${t}`),t instanceof Error&&"NetworkError"===t.name&&t.message.includes("device has been lost")&&(this.trace("Device lost detected (NetworkError)"),this.onDeviceLostCallback&&this.onDeviceLostCallback())}finally{null==i||i.releaseLock(),this.reader===i&&(this.reader=void 0)}}async setRTS(t){await this.device.setSignals({requestToSend:t}),await this.setDTR(this._DTR_state)}async setDTR(t){this._DTR_state=t,await this.device.setSignals({dataTerminalReady:t})}async setSignals(t,e,i){t&&(this._DTR_state=t),await this.device.setSignals({dataTerminalReady:t,requestToSend:e,break:i})}async connect(t=115200,e={}){await this.device.open({baudRate:t,dataBits:null==e?void 0:e.dataBits,stopBits:null==e?void 0:e.stopBits,bufferSize:null==e?void 0:e.bufferSize,parity:null==e?void 0:e.parity,flowControl:null==e?void 0:e.flowControl}),this.baudrate=t}async changeBaudrate(t,e={}){const i=this.device;return"function"==typeof i.setBaudRate?(this.tracing&&this.trace(`Changing host baud rate to ${t} in place`),await i.setBaudRate(t),this.baudrate=t,!1):(this.tracing&&this.trace(`Reopening serial port at ${t} baud`),await this.disconnect(),await qs(50),await this.connect(t,e),await qs(50),this.readLoop(),!0)}async waitForUnlock(t){for(;this.device.readable&&this.device.readable.locked||this.device.writable&&this.device.writable.locked;)await qs(t)}async disconnect(){var t,e;(null===(t=this.device.readable)||void 0===t?void 0:t.locked)&&await(null===(e=this.reader)||void 0===e?void 0:e.cancel()),await this.waitForUnlock(400),await this.device.close(),this.reader=void 0}}function Xs(t){return new Promise((e=>setTimeout(e,t)))}class js{constructor(t,e){this.resetDelay=e,this.transport=t}async reset(){await this.transport.setSignals(!1,!0),await Xs(100),await this.transport.setSignals(!0,!1),await Xs(this.resetDelay),await this.transport.setSignals(!1,!1)}}class Js{constructor(t){this.transport=t}async reset(){await this.transport.setRTS(!1),await this.transport.setDTR(!1),await Xs(100),await this.transport.setDTR(!0),await this.transport.setRTS(!1),await Xs(100),await this.transport.setRTS(!0),await this.transport.setDTR(!1),await this.transport.setRTS(!0),await Xs(100),await this.transport.setRTS(!1),await this.transport.setDTR(!1)}}class Qs{constructor(t,e=!1){this.transport=t,this.usingUsbOtg=e,this.transport=t}async reset(){this.usingUsbOtg?(await Xs(200),await this.transport.setRTS(!1),await Xs(200)):(await Xs(100),await this.transport.setRTS(!1))}}class tr{constructor(t,e){this.transport=t,this.sequenceString=e,this.transport=t}async reset(){const t={D:async t=>await this.transport.setDTR(t),R:async t=>await this.transport.setRTS(t),W:async t=>await Xs(t)};try{if(!function(t){const e=["D","R","W"],i=t.split("|");for(const t of i){const i=t[0],s=t.slice(1);if(!e.includes(i))return!1;if("D"===i||"R"===i){if("0"!==s&&"1"!==s)return!1}else if("W"===i){const t=parseInt(s);if(isNaN(t)||t<=0)return!1}}return!0}(this.sequenceString))return;const e=this.sequenceString.split("|");for(const i of e){const e=i[0],s=i.slice(1);"W"===e?await t.W(Number(s)):"D"!==e&&"R"!==e||await t[e]("1"===s)}}catch(t){throw new Error("Invalid custom reset sequence")}}}function er(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ir,sr;var rr=er(sr?ir:(sr=1,ir=function(t){return atob(t)}));async function ar(t,e){let i;switch(t){case"ESP32":i=await import("./esp32-BlyKoTgy.js");break;case"ESP32-C2":i=await import("./esp32c2-Bmu-jpVE.js");break;case"ESP32-C3":i=await import("./esp32c3-81Rr-aQE.js");break;case"ESP32-C5":i=await import("./esp32c5-Bq6mXcb5.js");break;case"ESP32-C6":i=await import("./esp32c6-yQoBKrxY.js");break;case"ESP32-C61":i=await import("./esp32c61-DmDn041x.js");break;case"ESP32-H2":i=await import("./esp32h2-B8bZhHv5.js");break;case"ESP32-H4":i=await import("./esp32h4-KyNsS-mo.js");break;case"ESP32-H21":case"ESP32-E22":break;case"ESP32-P4":i=e&&e<300?await import("./esp32p4-rev1-DEdUM_9Q.js"):await import("./esp32p4-o74i42i3.js");break;case"ESP32-S2":i=await import("./esp32s2-O1Tyu6IT.js");break;case"ESP32-S3":i=await import("./esp32s3-WXxMoV8x.js");break;case"ESP32-S31":i=await import("./esp32s31-Ef8NLP2_.js");break;case"ESP8266":i=await import("./esp8266-DsDItw_h.js")}if(i){const t="default"in i?i.default:i;return{bss_start:t.bss_start,data:t.data,data_start:t.data_start,entry:t.entry,text:t.text,text_start:t.text_start,decodedData:or(t.data),decodedText:or(t.text)}}}function or(t){const e=rr(t).split("").map((function(t){return t.charCodeAt(0)}));return new Uint8Array(e)}class nr{constructor(){this.FLASH_SIZES={"1MB":0,"2MB":16,"4MB":32,"8MB":48,"16MB":64,"32MB":80,"64MB":96,"128MB":112},this.FLASH_FREQUENCY={"80m":15,"40m":0,"26m":1,"20m":2},this.USES_MAGIC_VALUE=!1}getEraseSize(t,e){return e}}class lr extends nr{constructor(){super(...arguments),this.CHIP_NAME="ESP8266",this.USES_MAGIC_VALUE=!0,this.CHIP_DETECT_MAGIC_VALUE=[4293968129],this.EFUSE_RD_REG_BASE=1072693328,this.UART_CLKDIV_REG=1610612756,this.UART_CLKDIV_MASK=1048575,this.XTAL_CLK_DIVIDER=2,this.FLASH_WRITE_SIZE=16384,this.BOOTLOADER_FLASH_OFFSET=0,this.UART_DATE_REG_ADDR=0,this.FLASH_SIZES={"512KB":0,"256KB":16,"1MB":32,"2MB":48,"4MB":64,"2MB-c1":80,"4MB-c1":96,"8MB":128,"16MB":144},this.FLASH_FREQUENCY={"80m":15,"40m":0,"26m":1,"20m":2},this.MEMORY_MAP=[[1072693248,1072693264,"DPORT"],[1073643520,1073741824,"DRAM"],[1074790400,1074823168,"IRAM"],[1075843088,1076760592,"IROM"]],this.SPI_REG_BASE=1610613248,this.SPI_USR_OFFS=28,this.SPI_USR1_OFFS=32,this.SPI_USR2_OFFS=36,this.SPI_MOSI_DLEN_OFFS=0,this.SPI_MISO_DLEN_OFFS=0,this.SPI_W0_OFFS=64,this.getChipFeatures=async t=>{const e=["WiFi"];return"ESP8285"==await this.getChipDescription(t)&&e.push("Embedded Flash"),e}}async readEfuse(t,e){const i=this.EFUSE_RD_REG_BASE+4*e;return t.debug("Read efuse "+i),await t.readReg(i)}async getChipDescription(t){const e=await this.readEfuse(t,2);return 0!=(16&await this.readEfuse(t,0)|65536&e)?"ESP8285":"ESP8266EX"}async getCrystalFreq(t){const e=await t.readReg(this.UART_CLKDIV_REG)&this.UART_CLKDIV_MASK,i=t.transport.baudrate*e/1e6/this.XTAL_CLK_DIVIDER;let s;return s=i>33?40:26,Math.abs(s-i)>1&&t.info("WARNING: Detected crystal freq "+i+"MHz is quite different to normalized freq "+s+"MHz. Unsupported crystal in use?"),s}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async readMac(t){let e=await this.readEfuse(t,0);e>>>=0;let i=await this.readEfuse(t,1);i>>>=0;let s=await this.readEfuse(t,3);s>>>=0;const r=new Uint8Array(6);return 0!=s?(r[0]=s>>16&255,r[1]=s>>8&255,r[2]=255&s):0==(i>>16&255)?(r[0]=24,r[1]=254,r[2]=52):1==(i>>16&255)?(r[0]=172,r[1]=208,r[2]=116):t.error("Unknown OUI"),r[3]=i>>8&255,r[4]=255&i,r[5]=e>>24&255,this._d2h(r[0])+":"+this._d2h(r[1])+":"+this._d2h(r[2])+":"+this._d2h(r[3])+":"+this._d2h(r[4])+":"+this._d2h(r[5])}getEraseSize(t,e){return e}}lr.IROM_MAP_START=1075838976,lr.IROM_MAP_END=1076887552;var dr=Object.freeze({__proto__:null,ESP8266ROM:lr});const cr=233;function hr(t,e){return t+(e-1-t%e)}function _r(t,e){return t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24}class pr{constructor(t,e,i=null,s=0){this.addr=t,this.data=e,this.fileOffs=i,this.flags=s,this.includeInChecksum=!0,0!==this.addr&&this.padToAlignment(4)}copyWithNewAddr(t){return new pr(t,this.data,0)}splitImage(t){const e=new pr(this.addr,this.data.slice(0,t),0);return this.data=this.data.slice(t),this.addr+=t,this.fileOffs=null,e}toString(){let t=`len 0x${this.data.length.toString(16).padStart(5,"0")} load 0x${this.addr.toString(16).padStart(8,"0")}`;return null!==this.fileOffs&&(t+=` file_offs 0x${this.fileOffs.toString(16).padStart(8,"0")}`),t}getMemoryType(t){return t.ROM_LOADER.MEMORY_MAP.filter((t=>t[0]<=this.addr&&this.addr<t[1])).map((t=>t[2]))}padToAlignment(t){this.data=Ys(this.data,t,0)}}class ur extends pr{constructor(t,e,i,s){super(e,i,null,s),this.name=t}toString(){return`${this.name} ${super.toString()}`}}class fr{constructor(t){this.SEG_HEADER_LEN=8,this.SHA256_DIGEST_LEN=32,this.ELF_FLAG_WRITE=1,this.ELF_FLAG_READ=2,this.ELF_FLAG_EXEC=4,this.segments=[],this.entrypoint=0,this.elfSha256=null,this.elfSha256Offset=0,this.padToSize=0,this.flashMode=0,this.flashSizeFreq=0,this.checksum=0,this.datalength=0,this.IROM_ALIGN=0,this.MMU_PAGE_SIZE_CONF=[],this.ROM_LOADER=t}loadCommonHeader(t,e,i){const s=t[e],r=t[e+1];if(this.flashMode=t[e+2],this.flashSizeFreq=t[e+3],this.entrypoint=_r(t,e+4),s!==i)throw new xt(`Invalid firmware image magic=0x${s.toString(16)}`);return r}verify(){if(this.segments.length>16)throw new xt(`Invalid segment count ${this.segments.length} (max 16). Usually this indicates a linker script problem.`)}loadSegment(t,e,i=!1){const s=e,r=_r(t,e),a=_r(t,e+4);this.warnIfUnusualSegment(r,a,i);const o=t.slice(e+8,e+8+a);if(o.length<a)throw new xt(`End of file reading segment 0x${r.toString(16)}, length ${a} (actual length ${o.length})`);const n=new pr(r,o,s);return this.segments.push(n),n}warnIfUnusualSegment(t,e,i){i||(t>1075838976||t<1073610752||e>65536)&&console.warn(`WARNING: Suspicious segment 0x${t.toString(16)}, length ${e}`)}maybePatchSegmentData(t,e){const i=t.length;if(this.elfSha256Offset>=e&&this.elfSha256Offset<e+i){const s=this.elfSha256Offset-e;if(s<this.SEG_HEADER_LEN||s+this.SHA256_DIGEST_LEN>i)throw new xt(`Cannot place SHA256 digest on segment boundary(elf_sha256_offset=${this.elfSha256Offset}, file_pos=${e}, segment_size=${i})`);const r=s-this.SEG_HEADER_LEN;if(!t.slice(r,r+this.SHA256_DIGEST_LEN).every((t=>0===t)))throw new xt(`Contents of segment at SHA256 digest offset 0x${this.elfSha256Offset.toString(16)} are not all zero. Refusing to overwrite.`);if(!this.elfSha256||this.elfSha256.length!==this.SHA256_DIGEST_LEN)throw new xt("ELF SHA256 digest is not properly initialized");const a=t.slice(0,r),o=t.slice(r+this.SHA256_DIGEST_LEN),n=a.length+this.elfSha256.length+o.length,l=new Uint8Array(n);return l.set(a,0),l.set(this.elfSha256,a.length),l.set(o,a.length+this.elfSha256.length),l}return t}saveSegment(t,e,i,s=null){const r=this.maybePatchSegmentData(i.data,e),a=new DataView(t.buffer,e);return a.setUint32(0,i.addr,!0),a.setUint32(4,r.length,!0),t.set(r,e+8),null!==s?Vs(r,s):0}saveFlashSegment(t,e,i,s=null){if("ESP32"===this.ROM_LOADER.CHIP_NAME){const t=(e+i.data.length+this.SEG_HEADER_LEN)%this.IROM_ALIGN;if(t<36){const e=new Uint8Array(i.data.length+(36-t));e.set(i.data),e.fill(0,i.data.length),i.data=e}}return this.saveSegment(t,e,i,s)}readChecksum(t,e){return t[hr(e,16)]}calculateChecksum(){let t=239;for(const e of this.segments)e.includeInChecksum&&(t=Vs(e.data,t));return t}appendChecksum(t,e,i){t[hr(e,16)]=i}writeCommonHeader(t,e,i){t[e]=cr,t[e+1]=i,t[e+2]=this.flashMode,t[e+3]=this.flashSizeFreq;new DataView(t.buffer,e+4).setUint32(0,this.entrypoint,!0)}isIromAddr(t){return lr.IROM_MAP_START<=t&&t<lr.IROM_MAP_END}getIromSegment(){const t=this.segments.filter((t=>this.isIromAddr(t.addr)));if(t.length>0){if(1!==t.length)throw new xt(`Found ${t.length} segments that could be irom0. Bad ELF file?`);return t[0]}return null}getNonIromSegments(){const t=this.getIromSegment();return this.segments.filter((e=>e!==t))}sortSegments(){this.segments.length&&this.segments.sort(((t,e)=>t.addr-e.addr))}mergeAdjacentSegments(){if(!this.segments.length)return;const t=[];for(let e=this.segments.length-1;e>0;e--){const i=this.segments[e-1],s=this.segments[e];if(i.getMemoryType(this).join(",")===s.getMemoryType(this).join(",")&&i.includeInChecksum===s.includeInChecksum&&s.addr===i.addr+i.data.length&&(s.flags&this.ELF_FLAG_EXEC)==(i.flags&this.ELF_FLAG_EXEC)){const t=new Uint8Array(i.data.length+s.data.length);t.set(i.data),t.set(s.data,i.data.length),i.data=t}else t.unshift(s)}t.unshift(this.segments[0]),this.segments=t}setMmuPageSize(t){if(this.MMU_PAGE_SIZE_CONF||t===this.IROM_ALIGN){if(this.MMU_PAGE_SIZE_CONF&&!this.MMU_PAGE_SIZE_CONF.includes(t)){const e=this.MMU_PAGE_SIZE_CONF.map((t=>t/1024+"KB")).join(", ");throw new xt(`${t} bytes is not a valid ${this.ROM_LOADER.CHIP_NAME} page size, select from ${e}.`)}this.IROM_ALIGN=t}else console.warn(`WARNING: Changing MMU page size is not supported on ${this.ROM_LOADER.CHIP_NAME}! `+(0!==this.IROM_ALIGN?`Defaulting to ${this.IROM_ALIGN/1024}KB.`:""))}}class Er extends fr{constructor(t,e=null,i=!0,s=!1){super(t),this.securePad=null,this.flashMode=0,this.flashSizeFreq=0,this.version=1,this.WP_PIN_DISABLED=238,this.wpPin=this.WP_PIN_DISABLED,this.clkDrv=0,this.qDrv=0,this.dDrv=0,this.csDrv=0,this.hdDrv=0,this.wpDrv=0,this.chipId=0,this.minRev=0,this.minRevFull=0,this.maxRevFull=0,this.storedDigest=null,this.calcDigest=null,this.dataLength=0,this.IROM_ALIGN=65536,this.ROM_LOADER=t,this.appendDigest=i,this.ramOnlyHeader=s,null!==e&&this.loadFromFile(e)}async loadFromFile(t){const e=t instanceof Uint8Array?t:Ws(t);let i=0;const s=this.loadCommonHeader(e,i,cr);i+=8,this.loadExtendedHeader(e,i),i+=16;for(let t=0;t<s;t++){i+=8+this.loadSegment(e,i).data.length}if(this.checksum=this.readChecksum(e,i),i=hr(i,16),this.appendDigest){const t=i;this.storedDigest=e.slice(i,i+this.SHA256_DIGEST_LEN);const s=await crypto.subtle.digest("SHA-256",e.slice(0,t));this.calcDigest=new Uint8Array(s),this.dataLength=t-0}this.verify()}isFlashAddr(t){return this.ROM_LOADER.IROM_MAP_START<=t&&t<this.ROM_LOADER.IROM_MAP_END||this.ROM_LOADER.DROM_MAP_START<=t&&t<this.ROM_LOADER.DROM_MAP_END}async save(){let t=0;const e=new Uint8Array(1048576);let i=0;this.writeCommonHeader(e,i,this.segments.length),i+=8,this.saveExtendedHeader(e,i),i+=16;let s=239;const r=this.segments.filter((t=>this.isFlashAddr(t.addr))).sort(((t,e)=>t.addr-e.addr)),a=this.segments.filter((t=>!this.isFlashAddr(t.addr))).sort(((t,e)=>t.addr-e.addr));for(let t=0;t<r.length;t++){const e=r[t];if(e instanceof ur&&".flash.appdesc"===e.name){r.splice(t,1),r.unshift(e);break}}for(let t=0;t<a.length;t++){const e=a[t];if(e instanceof ur&&".dram0.bootdesc"===e.name){a.splice(t,1),a.unshift(e);break}}if(r.length>0){let t=r[0].addr;for(const e of r.slice(1)){if(Math.floor(e.addr/this.IROM_ALIGN)===Math.floor(t/this.IROM_ALIGN))throw new xt(`Segment loaded at 0x${e.addr.toString(16)} lands in same 64KB flash mapping as segment loaded at 0x${t.toString(16)}. Can't generate binary. Suggest changing linker script or ELF to merge sections.`);t=e.addr}}if(this.ramOnlyHeader){for(const r of a)s=this.saveSegment(e,i,r,s),i+=8+r.data.length,t++;this.appendChecksum(e,i,s),i=hr(i,16);for(const a of r.reverse()){let r=this.getAlignmentDataNeeded(a,i);if(r>0){r<this.ROM_LOADER.BOOTLOADER_FLASH_OFFSET-this.SEG_HEADER_LEN&&(r+=this.IROM_ALIGN),r-=this.ROM_LOADER.BOOTLOADER_FLASH_OFFSET;const a=new pr(0,new Uint8Array(r).fill(0),i);s=this.saveSegment(e,i,a,s),i+=8+r,t++}this.saveFlashSegment(e,i,a),i+=8+a.data.length,t++}}else{for(;r.length>0;){const o=r[0],n=this.getAlignmentDataNeeded(o,i);if(n>0){if(a.length>0&&n>this.SEG_HEADER_LEN){const t=a[0].splitImage(n);0===a[0].data.length&&a.shift(),s=this.saveSegment(e,i,t,s)}else{const t=new pr(0,new Uint8Array(n).fill(0),i);s=this.saveSegment(e,i,t,s)}i+=8+n,t++}else{if((i+8)%this.IROM_ALIGN!=o.addr%this.IROM_ALIGN)throw new Error("Flash segment alignment mismatch");s=this.saveFlashSegment(e,i,o,s),r.shift(),i+=8+o.data.length,t++}}for(const r of a)s=this.saveSegment(e,i,r,s),i+=8+r.data.length,t++}if(this.securePad){if(!this.appendDigest)throw new Error("secure_pad only applies if a SHA-256 digest is also appended to the image");const r=(i+this.SEG_HEADER_LEN)%this.IROM_ALIGN,a=16;let o=0;"1"===this.securePad?o=112:"2"===this.securePad&&(o=32);const n=(this.IROM_ALIGN-r-a-o)%this.IROM_ALIGN,l=new pr(0,new Uint8Array(n).fill(0),i);s=this.saveSegment(e,i,l,s),i+=8+n,t++}this.ramOnlyHeader||(this.appendChecksum(e,i,s),i=hr(i,16));const o=i;if(this.ramOnlyHeader?e[1]=a.length:e[1]=t,this.appendDigest){const t=await crypto.subtle.digest("SHA-256",e.slice(0,o)),s=new Uint8Array(t);e.set(s,o),i+=32}if(this.padToSize&&i%this.padToSize!=0){const t=this.padToSize-i%this.padToSize,s=new Uint8Array(t);s.fill(255),e.set(s,i),i+=t}return e}loadExtendedHeader(t,e){const i=new DataView(t.buffer,e);this.wpPin=i.getUint8(0);const s=i.getUint8(1);[this.clkDrv,this.qDrv]=this.splitByte(s);const r=i.getUint8(2);[this.dDrv,this.csDrv]=this.splitByte(r);const a=i.getUint8(3);[this.hdDrv,this.wpDrv]=this.splitByte(a),this.chipId=i.getUint8(4),void 0!==this.ROM_LOADER.IMAGE_CHIP_ID&&this.chipId!==this.ROM_LOADER.IMAGE_CHIP_ID&&console.warn(`Unexpected chip id in image. Expected ${this.ROM_LOADER.IMAGE_CHIP_ID} but value was ${this.chipId}. Is this image for a different chip model?`),this.minRev=i.getUint8(5),this.minRevFull=i.getUint16(6,!0),this.maxRevFull=i.getUint16(8,!0);const o=i.getUint8(15);if(0!==o&&1!==o)throw new Error(`Invalid value for append_digest field (0x${o.toString(16)}). Should be 0 or 1.`);this.appendDigest=1===o}saveExtendedHeader(t,e){var i;const s=new ArrayBuffer(16),r=new DataView(s);r.setUint8(0,this.wpPin),r.setUint8(1,this.joinByte(this.clkDrv,this.qDrv)),r.setUint8(2,this.joinByte(this.dDrv,this.csDrv)),r.setUint8(3,this.joinByte(this.hdDrv,this.wpDrv)),r.setUint8(4,null!==(i=this.ROM_LOADER.IMAGE_CHIP_ID)&&void 0!==i?i:0),r.setUint8(5,this.minRev),r.setUint16(6,this.minRevFull,!0),r.setUint16(8,this.maxRevFull,!0);for(let t=9;t<15;t++)r.setUint8(t,0);r.setUint8(15,this.appendDigest?1:0),t.set(new Uint8Array(s),e)}splitByte(t){return[15&t,t>>4&15]}joinByte(t,e){return 15&t|(15&e)<<4}getAlignmentDataNeeded(t,e){const i=t.addr%this.IROM_ALIGN-this.SEG_HEADER_LEN;let s=this.IROM_ALIGN-e%this.IROM_ALIGN+i;return 0===s||s===this.IROM_ALIGN?0:(s-=this.SEG_HEADER_LEN,s<0&&(s+=this.IROM_ALIGN),s)}}class gr extends fr{constructor(t,e=null){super(t),this.version=1,this.ROM_LOADER=t,this.flashMode=0,this.flashSizeFreq=0,null!==e&&this.loadFromFile(e)}loadFromFile(t){const e=t instanceof Uint8Array?t:Ws(t);let i=0;const s=this.loadCommonHeader(e,i,cr);i+=8;for(let t=0;t<s;t++){i+=8+this.loadSegment(e,i).data.length}this.checksum=this.readChecksum(e,i),this.verify()}defaultOutputName(t){return t+"-"}}class mr extends fr{constructor(t,e=null){super(t),this.version=2,this.ROM_LOADER=t,this.flashMode=0,this.flashSizeFreq=0,null!==e&&this.loadFromFile(e)}async loadFromFile(t){const e=t instanceof Uint8Array?t:Ws(t);let i=0;const s=this.loadCommonHeader(e,i,mr.IMAGE_V2_MAGIC);i+=8,s!==mr.IMAGE_V2_SEGMENT&&console.warn(`Warning: V2 header has unexpected "segment" count ${s} (usually 4)`);const r=this.flashMode,a=this.flashSizeFreq,o=this.entrypoint,n=this.loadSegment(e,i,!0);n.addr=0,n.includeInChecksum=!1,i+=8+n.data.length;const l=this.loadCommonHeader(e,i,cr);i+=8,r!==this.flashMode&&console.warn(`WARNING: Flash mode value in first header (0x${r.toString(16)}) disagrees with second (0x${this.flashMode.toString(16)}). Using second value.`),a!==this.flashSizeFreq&&console.warn(`WARNING: Flash size/freq value in first header (0x${a.toString(16)}) disagrees with second (0x${this.flashSizeFreq.toString(16)}). Using second value.`),o!==this.entrypoint&&console.warn(`WARNING: Entrypoint address in first header (0x${o.toString(16)}) disagrees with second header (0x${this.entrypoint.toString(16)}). Using second value.`);for(let t=0;t<l;t++){i+=8+this.loadSegment(e,i).data.length}this.checksum=this.readChecksum(e,i),this.verify()}defaultOutputName(t){const e=this.getIromSegment();let i=0;null!==e&&(i=e.addr-lr.IROM_MAP_START);return`${t.replace(/\.[^/.]+$/,"")}-0x${(-4096&i).toString(16).padStart(5,"0")}.bin`}}mr.IMAGE_V2_MAGIC=234,mr.IMAGE_V2_SEGMENT=4;class vr extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class Sr extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class yr extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class br extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.MMU_PAGE_SIZE_CONF=[16384,32768,65536],this.ROM_LOADER=t}}class wr extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.MMU_PAGE_SIZE_CONF=[8192,16384,32768,65536],this.ROM_LOADER=t}}class Rr extends wr{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class Ar extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class xr extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class Tr extends wr{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class Cr extends wr{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}class Ir extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.MMU_PAGE_SIZE_CONF=[8192,16384,32768,65536],this.ROM_LOADER=t}}class Pr extends Ar{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.MMU_PAGE_SIZE_CONF=[32768,65536,131072,262144],this.ROM_LOADER=t}}class Or extends Er{constructor(t,e=null,i=!0,s=!1){super(t,e,i,s),this.ROM_LOADER=t}}async function Ur(t,e){const i=e instanceof Uint8Array?e:Ws(e),s=t.CHIP_NAME.toLowerCase().replace(/[-()]/g,"");let r;if("esp8266"!==s)switch(s){case"esp32":r=Er;break;case"esp32s2":r=vr;break;case"esp32s3":r=Sr;break;case"esp32s31":r=Pr;break;case"esp32c3":r=yr;break;case"esp32c2":r=br;break;case"esp32c6":r=wr;break;case"esp32c61":r=Rr;break;case"esp32c5":r=Ar;break;case"esp32e22":r=Or;break;case"esp32h2":r=Tr;break;case"esp32h21":r=Cr;break;case"esp32h4":r=Ir;break;case"esp32p4":r=xr;break;default:throw new xt(`Unsupported chip name: ${s}`)}else{const t=i[0];if(t===cr)r=gr;else{if(t!==mr.IMAGE_V2_MAGIC)throw new xt(`Invalid image magic number: ${t}`);r=mr}}const a=new r(t),o=a;if("function"==typeof o.loadFromFile){const t=o.loadFromFile(i);t instanceof Promise&&await t}return a}class Fr extends nr{constructor(){super(...arguments),this.CHIP_NAME="ESP32",this.IMAGE_CHIP_ID=0,this.USES_MAGIC_VALUE=!0,this.EFUSE_RD_REG_BASE=1073061888,this.DR_REG_SYSCON_BASE=1073111040,this.UART_CLKDIV_REG=1072955412,this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612856,this.XTAL_CLK_DIVIDER=1,this.IROM_MAP_START=1074593792,this.IROM_MAP_END=1077936128,this.DROM_MAP_START=1061158912,this.DROM_MAP_END=1065353216,this.MEMORY_MAP=[[0,65536,"PADDING"],[1061158912,1065353216,"DROM"],[1065353216,1069547520,"EXTRAM_DATA"],[1073217536,1073225728,"RTC_DRAM"],[1073283072,1073741824,"BYTE_ACCESSIBLE"],[1073405952,1073741824,"DRAM"],[1073610752,1073741820,"DIRAM_DRAM"],[1073741824,1074200576,"IROM"],[1074200576,1074233344,"CACHE_PRO"],[1074233344,1074266112,"CACHE_APP"],[1074266112,1074397184,"IRAM"],[1074397184,1074528252,"DIRAM_IRAM"],[1074528256,1074536448,"RTC_IRAM"],[1074593792,1077936128,"IROM"],[1342177280,1342185472,"RTC_DATA"]],this.FLASH_SIZES={"1MB":0,"2MB":16,"4MB":32,"8MB":48,"16MB":64,"32MB":80,"64MB":96,"128MB":112},this.FLASH_FREQUENCY={"80m":15,"40m":0,"26m":1,"20m":2},this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=4096,this.SPI_REG_BASE=1072963584,this.SPI_USR_OFFS=28,this.SPI_USR1_OFFS=32,this.SPI_USR2_OFFS=36,this.SPI_W0_OFFS=128,this.SPI_MOSI_DLEN_OFFS=40,this.SPI_MISO_DLEN_OFFS=44}async readEfuse(t,e){const i=this.EFUSE_RD_REG_BASE+4*e;return t.debug("Read efuse "+i),await t.readReg(i)}async getPkgVersion(t){const e=await this.readEfuse(t,3);let i=e>>9&7;return i+=(e>>2&1)<<3,i}async getChipRevision(t){const e=await this.readEfuse(t,3),i=await this.readEfuse(t,5),s=await t.readReg(this.DR_REG_SYSCON_BASE+124);return 0!=(e>>15&1)?0!=(i>>20&1)?0!=(s>>31&1)?3:2:1:0}async getChipDescription(t){const e=["ESP32-D0WDQ6","ESP32-D0WD","ESP32-D2WD","","ESP32-U4WDH","ESP32-PICO-D4","ESP32-PICO-V3-02"];let i="";const s=await this.getPkgVersion(t),r=await this.getChipRevision(t),a=3==r;return 0!=(1&await this.readEfuse(t,3))&&(e[0]="ESP32-S0WDQ6",e[1]="ESP32-S0WD"),a&&(e[5]="ESP32-PICO-V3"),i=s>=0&&s<=6?e[s]:"Unknown ESP32",!a||0!==s&&1!==s||(i+="-V3"),i+" (revision "+r+")"}async getChipFeatures(t){const e=["Wi-Fi"],i=await this.readEfuse(t,3);0===(2&i)&&e.push(" BT");0!==(1&i)?e.push(" Single Core"):e.push(" Dual Core");if(0!==(8192&i)){0!==(4096&i)?e.push(" 160MHz"):e.push(" 240MHz")}const s=await this.getPkgVersion(t);-1!==[2,4,5,6].indexOf(s)&&e.push(" Embedded Flash"),6===s&&e.push(" Embedded PSRAM");0!==(await this.readEfuse(t,4)>>8&31)&&e.push(" VRef calibration in efuse");0!==(i>>14&1)&&e.push(" BLK3 partially reserved");const r=3&await this.readEfuse(t,6);return e.push(" Coding Scheme "+["None","3/4","Repeat (UNSUPPORTED)","Invalid"][r]),e}async getCrystalFreq(t){const e=await t.readReg(this.UART_CLKDIV_REG)&this.UART_CLKDIV_MASK,i=t.transport.baudrate*e/1e6/this.XTAL_CLK_DIVIDER;let s;return s=i>33?40:26,Math.abs(s-i)>1&&t.info("WARNING: Unsupported crystal in use"),s}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async readMac(t){let e=await this.readEfuse(t,1);e>>>=0;let i=await this.readEfuse(t,2);i>>>=0;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}}var Dr=Object.freeze({__proto__:null,ESP32ROM:Fr});class Mr extends Fr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-C3",this.IMAGE_CHIP_ID=5,this.USES_MAGIC_VALUE=!1,this.EFUSE_BASE=1610647552,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.UART_CLKDIV_REG=1072955412,this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612860,this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=0,this.SPI_REG_BASE=1610620928,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1115684864,this.MEMORY_MAP=[[0,65536,"PADDING"],[1006632960,1015021568,"DROM"],[1070071808,1070465024,"DRAM"],[1070104576,1070596096,"BYTE_ACCESSIBLE"],[1072693248,1072824320,"DROM_MASK"],[1073741824,1074135040,"IROM_MASK"],[1107296256,1115684864,"IROM"],[1077395456,1077805056,"IRAM"],[1342177280,1342185472,"RTC_IRAM"],[1342177280,1342185472,"RTC_DRAM"],[1611653120,1611661312,"MEM_INTERNAL2"]]}async getPkgVersion(t){const e=this.EFUSE_BASE+68+12;return await t.readReg(e)>>21&7}async getChipRevision(t){const e=this.EFUSE_BASE+68+12;return(await t.readReg(e)&7<<18)>>18}async getMinorChipVersion(t){const e=this.EFUSE_BASE+68+20,i=await t.readReg(e)>>23&1,s=this.EFUSE_BASE+68+12;return(i<<3)+(await t.readReg(s)>>18&7)}async getMajorChipVersion(t){const e=this.EFUSE_BASE+68+20;return await t.readReg(e)>>24&3}async getChipDescription(t){const e=await this.getPkgVersion(t),i=await this.getMajorChipVersion(t),s=await this.getMinorChipVersion(t);return`${{0:"ESP32-C3 (QFN32)",1:"ESP8685 (QFN28)",2:"ESP32-C3 AZ (QFN32)",3:"ESP8686 (QFN24)"}[e]||"Unknown ESP32-C3"} (revision v${i}.${s})`}async getFlashCap(t){const e=this.EFUSE_BASE+68+12;return await t.readReg(e)>>27&7}async getFlashVendor(t){const e=this.EFUSE_BASE+68+16;return{1:"XMC",2:"GD",3:"FM",4:"TT",5:"ZBIT"}[await t.readReg(e)>>0&7]||""}async getChipFeatures(t){const e=["Wi-Fi","BLE"],i=await this.getFlashCap(t),s=await this.getFlashVendor(t),r={0:null,1:"Embedded Flash 4MB",2:"Embedded Flash 2MB",3:"Embedded Flash 1MB",4:"Embedded Flash 8MB"}[i],a=void 0!==r?r:"Unknown Embedded Flash";return null!==r&&e.push(`${a} (${s})`),e}async getCrystalFreq(t){return 40}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}getEraseSize(t,e){return e}}var kr=Object.freeze({__proto__:null,ESP32C3ROM:Mr});class Lr extends Mr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-C2",this.IMAGE_CHIP_ID=12,this.EFUSE_BASE=1610647552,this.MAC_EFUSE_REG=this.EFUSE_BASE+64,this.UART_CLKDIV_REG=1610612756,this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612860,this.XTAL_CLK_DIVIDER=1,this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=0,this.SPI_REG_BASE=1610620928,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1111490560,this.MEMORY_MAP=[[0,65536,"PADDING"],[1006632960,1010827264,"DROM"],[1070202880,1070465024,"DRAM"],[1070104576,1070596096,"BYTE_ACCESSIBLE"],[1072693248,1073020928,"DROM_MASK"],[1073741824,1074331648,"IROM_MASK"],[1107296256,1111490560,"IROM"],[1077395456,1077673984,"IRAM"]]}async getPkgVersion(t){const e=this.EFUSE_BASE+64+4;return await t.readReg(e)>>22&7}async getChipRevision(t){const e=this.EFUSE_BASE+64+4;return(await t.readReg(e)&3<<20)>>20}async getChipDescription(t){let e;const i=await this.getPkgVersion(t);e=0===i||1===i?"ESP32-C2":"unknown ESP32-C2";return e+=" (revision "+await this.getChipRevision(t)+")",e}async getChipFeatures(t){return["Wi-Fi","BLE"]}async getCrystalFreq(t){const e=await t.readReg(this.UART_CLKDIV_REG)&this.UART_CLKDIV_MASK,i=t.transport.baudrate*e/1e6/this.XTAL_CLK_DIVIDER;let s;return s=i>33?40:26,Math.abs(s-i)>1&&t.info("WARNING: Unsupported crystal in use"),s}async changeBaudRate(t){26===await this.getCrystalFreq(t)&&t.changeBaud()}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}getEraseSize(t,e){return e}}var Br=Object.freeze({__proto__:null,ESP32C2ROM:Lr});class Nr extends Mr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-C6",this.IMAGE_CHIP_ID=13,this.EFUSE_BASE=1611335680,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.UART_CLKDIV_REG=1072955412,this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612860,this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=0,this.SPI_REG_BASE=1610625024,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1115684864,this.MEMORY_MAP=[[0,65536,"PADDING"],[1107296256,1124073472,"DROM"],[1082130432,1082654720,"DRAM"],[1082130432,1082654720,"BYTE_ACCESSIBLE"],[1074048e3,1074069504,"DROM_MASK"],[1073741824,1074048e3,"IROM_MASK"],[1107296256,1124073472,"IROM"],[1082130432,1082654720,"IRAM"],[1342177280,1342193664,"RTC_IRAM"],[1342177280,1342193664,"RTC_DRAM"],[1611653120,1611661312,"MEM_INTERNAL2"]]}async getPkgVersion(t){const e=this.EFUSE_BASE+68+12;return await t.readReg(e)>>21&7}async getChipRevision(t){const e=this.EFUSE_BASE+68+12;return(await t.readReg(e)&7<<18)>>18}async getChipDescription(t){let e;e=0===await this.getPkgVersion(t)?"ESP32-C6":"unknown ESP32-C6";return e+=" (revision "+await this.getChipRevision(t)+")",e}async getChipFeatures(t){return["Wi-Fi 6","BT 5","IEEE802.15.4"]}async getCrystalFreq(t){return 40}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}getEraseSize(t,e){return e}}var Gr=Object.freeze({__proto__:null,ESP32C6ROM:Nr});class $r extends Nr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-C5",this.IMAGE_CHIP_ID=23,this.BOOTLOADER_FLASH_OFFSET=8192,this.EFUSE_BASE=1611352064,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.UART_CLKDIV_REG=1610612756,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_REG=this.EFUSE_BASE+52,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_SHIFT=10,this.FORCE_USE_KEY_MANAGER_VAL_XTS_AES_KEY=2,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY0_SHIFT=22,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY1_SHIFT=27,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY2_SHIFT=0,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY3_SHIFT=5,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY4_SHIFT=10,this.EFUSE_PURPOSE_KEY5_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY5_SHIFT=15,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG=this.EFUSE_RD_REG_BASE,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT=1<<20,this.EFUSE_SPI_BOOT_CRYPT_CNT_REG=this.EFUSE_BASE+52,this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK=7<<16,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+56,this.EFUSE_SECURE_BOOT_EN_MASK=1<<25,this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1140850688,this.DROM_MAP_START=1107296256,this.DROM_MAP_END=1140850688,this.PCR_SYSCLK_CONF_REG=1611227408,this.PCR_SYSCLK_XTAL_FREQ_V=127<<24,this.PCR_SYSCLK_XTAL_FREQ_S=24,this.XTAL_CLK_DIVIDER=1,this.UARTDEV_BUF_NO=1082520852,this.CHIP_DETECT_MAGIC_VALUE=[285294703,1675706479,1607549039,820080751],this.FLASH_FREQUENCY={"80m":15,"40m":0,"20m":2},this.MEMORY_MAP=[[0,65536,"PADDING"],[1107296256,1140850688,"DROM"],[1082130432,1082523648,"DRAM"],[1082130432,1082523648,"BYTE_ACCESSIBLE"],[1073979392,1074003968,"DROM_MASK"],[1073741824,1073979392,"IROM_MASK"],[1107296256,1140850688,"IROM"],[1082130432,1082523648,"IRAM"],[1342177280,1342193664,"RTC_IRAM"],[1342177280,1342193664,"RTC_DRAM"],[1611653120,1611661312,"MEM_INTERNAL2"]],this.UF2_FAMILY_ID=4145808195,this.EFUSE_MAX_KEY=5,this.PURPOSE_VAL_XTS_AES128_KEY=4,this.KEY_PURPOSES={0:"USER/EMPTY",1:"ECDSA_KEY",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2",12:"KM_INIT_KEY",15:"XTS_AES_128_PSRAM_KEY",16:"ECDSA_KEY_P192",17:"ECDSA_KEY_P384_L",18:"ECDSA_KEY_P384_H"}}async getPkgVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+8)>>26&7}async getMinorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+8)>>0&15}async getMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+8)>>4&3}async getChipDescription(t){let e;e=0===await this.getPkgVersion(t)?"ESP32-C5":"unknown ESP32-C5";return`${e} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["Wi-Fi 6 (dual-band)","BT 5 (LE)","IEEE802.15.4","Single Core + LP Core","240MHz"]}async getCrystalFreq(t){const e=await t.readReg(this.UART_CLKDIV_REG)&this.UART_CLKDIV_MASK,i=t.transport.baudrate*e/1e6/this.XTAL_CLK_DIVIDER;let s;return s=i>45?48:i>33?40:26,Math.abs(s-i)>1&&t.info("WARNING: Unsupported crystal in use"),s}async getCrystalFreqRomExpect(t){return(await t.readReg(this.PCR_SYSCLK_CONF_REG)&this.PCR_SYSCLK_XTAL_FREQ_V)>>this.PCR_SYSCLK_XTAL_FREQ_S}async getKeyBlockPurpose(t,e){if(e<0||e>this.EFUSE_MAX_KEY)throw new Error(`Valid key block numbers must be in range 0-${this.EFUSE_MAX_KEY}`);const i=[[this.EFUSE_PURPOSE_KEY0_REG,this.EFUSE_PURPOSE_KEY0_SHIFT],[this.EFUSE_PURPOSE_KEY1_REG,this.EFUSE_PURPOSE_KEY1_SHIFT],[this.EFUSE_PURPOSE_KEY2_REG,this.EFUSE_PURPOSE_KEY2_SHIFT],[this.EFUSE_PURPOSE_KEY3_REG,this.EFUSE_PURPOSE_KEY3_SHIFT],[this.EFUSE_PURPOSE_KEY4_REG,this.EFUSE_PURPOSE_KEY4_SHIFT],[this.EFUSE_PURPOSE_KEY5_REG,this.EFUSE_PURPOSE_KEY5_SHIFT]],[s,r]=i[e];return await t.readReg(s)>>r&31}async isFlashEncryptionKeyValid(t){const e=[];for(let i=0;i<=this.EFUSE_MAX_KEY;i++){const s=await this.getKeyBlockPurpose(t,i);e.push(s)}if(e.some((t=>t===this.PURPOSE_VAL_XTS_AES128_KEY)))return!0;return 0!=(await t.readReg(this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_REG)>>this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_SHIFT&this.FORCE_USE_KEY_MANAGER_VAL_XTS_AES_KEY)}checkSpiConnection(t,e){if(!e.every((t=>t>=0&&t<=28)))throw new Error("SPI Pin numbers must be in the range 0-28.");e.some((t=>13===t||14===t))&&t.info("GPIO pins 13 and 14 are used by USB-Serial/JTAG, consider using other pins for SPI flash connection.")}async usesUsbJtagSerial(t){const e=this.UARTDEV_BUF_NO;return 3===(255&await t.readReg(e))}async watchdogReset(t){throw t.info("Hard resetting with a watchdog..."),new Error("watchdogReset not yet implemented for ESP32-C5")}async changeBaud(t){if(t.secureDownloadMode)t.info("Baud rate change is not supported in secure download mode. Keeping 115200 baud.");else{if(!t.IS_STUB){const e=await this.getCrystalFreqRomExpect(t),i=await this.getCrystalFreq(t);t.info(`ROM expects crystal freq: ${e} MHz, detected ${i} MHz.`),(48===i&&40===e||40===i&&48===e)&&t.info("Crystal frequency mismatch detected. Baud rate adjustment may be needed but is not fully implemented in this version.")}await t.changeBaud()}}}var Kr=Object.freeze({__proto__:null,ESP32C5ROM:$r});class Hr extends Nr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-C61",this.IMAGE_CHIP_ID=20,this.CHIP_DETECT_MAGIC_VALUE=[871374959,606167151],this.UART_DATE_REG_ADDR=1610612860,this.EFUSE_BASE=1611352064,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY0_SHIFT=0,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY1_SHIFT=4,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY2_SHIFT=8,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY3_SHIFT=12,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY4_SHIFT=16,this.EFUSE_PURPOSE_KEY5_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY5_SHIFT=20,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG=this.EFUSE_RD_REG_BASE,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT=16384,this.EFUSE_SPI_BOOT_CRYPT_CNT_REG=this.EFUSE_BASE+48,this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK=7<<23,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+52,this.EFUSE_SECURE_BOOT_EN_MASK=1<<26,this.FLASH_FREQUENCY={"80m":15,"40m":0,"20m":2},this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1115684864,this.MEMORY_MAP=[[0,65536,"PADDING"],[1098907648,1107296256,"DROM"],[1082130432,1082523648,"DRAM"],[1082130432,1082523648,"BYTE_ACCESSIBLE"],[1074048e3,1074069504,"DROM_MASK"],[1073741824,1074048e3,"IROM_MASK"],[1090519040,1098907648,"IROM"],[1082130432,1082523648,"IRAM"],[1342177280,1342193664,"RTC_IRAM"],[1342177280,1342193664,"RTC_DRAM"],[1611653120,1611661312,"MEM_INTERNAL2"]],this.UF2_FAMILY_ID=2010665156,this.EFUSE_MAX_KEY=5,this.KEY_PURPOSES={0:"USER/EMPTY",1:"ECDSA_KEY",2:"XTS_AES_256_KEY_1",3:"XTS_AES_256_KEY_2",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2",12:"KM_INIT_KEY",13:"XTS_AES_256_KEY_1_PSRAM",14:"XTS_AES_256_KEY_2_PSRAM",15:"XTS_AES_128_KEY_PSRAM"}}async getPkgVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+8)>>26&7}async getMinorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+8)>>0&15}async getMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+8)>>4&3}async getChipDescription(t){let e;e=0===await this.getPkgVersion(t)?"ESP32-C61":"unknown ESP32-C61";return`${e} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["WiFi 6","BT 5"]}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}}var zr=Object.freeze({__proto__:null,ESP32C61ROM:Hr});class Yr extends Nr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-H2",this.IMAGE_CHIP_ID=16,this.EFUSE_BASE=1611335680,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.UART_CLKDIV_REG=1072955412,this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612860,this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=0,this.SPI_REG_BASE=1610625024,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.USB_RAM_BLOCK=2048,this.UARTDEV_BUF_NO_USB=3,this.UARTDEV_BUF_NO=1070526796,this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1115684864,this.MEMORY_MAP=[[0,65536,"PADDING"],[1107296256,1124073472,"DROM"],[1082130432,1082654720,"DRAM"],[1082130432,1082654720,"BYTE_ACCESSIBLE"],[1074048e3,1074069504,"DROM_MASK"],[1073741824,1074048e3,"IROM_MASK"],[1107296256,1124073472,"IROM"],[1082130432,1082654720,"IRAM"],[1342177280,1342193664,"RTC_IRAM"],[1342177280,1342193664,"RTC_DRAM"],[1611653120,1611661312,"MEM_INTERNAL2"]]}async getPkgVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+16)>>0&7}async getMinorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>18&7}async getMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>21&3}async getChipDescription(t){let e;e=0===await this.getPkgVersion(t)?"ESP32-H2":"unknown ESP32-H2";return`${e} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["BT 5 (LE)","IEEE802.15.4","Single Core","96MHz"]}async getCrystalFreq(t){return 32}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async postConnect(t){const e=255&await t.readReg(this.UARTDEV_BUF_NO);t.debug("In _post_connect "+e),e==this.UARTDEV_BUF_NO_USB&&(t.ESP_RAM_BLOCK=this.USB_RAM_BLOCK)}async usesUsbJtagSerial(t){return(255&await t.readReg(this.UARTDEV_BUF_NO))===this.UARTDEV_BUF_NO_USB}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}getEraseSize(t,e){return e}}var Vr=Object.freeze({__proto__:null,ESP32H2ROM:Yr});class Wr extends Fr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-P4",this.IMAGE_CHIP_ID=18,this.IROM_MAP_START=1073741824,this.IROM_MAP_END=1275068416,this.DROM_MAP_START=1073741824,this.DROM_MAP_END=1275068416,this.BOOTLOADER_FLASH_OFFSET=8192,this.CHIP_DETECT_MAGIC_VALUE=[0,182303440],this.UART_DATE_REG_ADDR=1343004812,this.EFUSE_BASE=1343410176,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.SPI_REG_BASE=1342754816,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.SPI_ADDR_REG_MSB=!1,this.USES_MAGIC_VALUE=!1,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_REG=this.EFUSE_BASE+52,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_SHIFT=9,this.FORCE_USE_KEY_MANAGER_VAL_XTS_AES_KEY=2,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY0_SHIFT=24,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY1_SHIFT=28,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY2_SHIFT=0,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY3_SHIFT=4,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY4_SHIFT=8,this.EFUSE_PURPOSE_KEY5_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY5_SHIFT=12,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG=this.EFUSE_RD_REG_BASE,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT=1<<20,this.EFUSE_RD_REPEAT_DATA1_REG=this.EFUSE_BASE+52,this.EFUSE_SPI_BOOT_CRYPT_CNT_REG=this.EFUSE_RD_REPEAT_DATA1_REG,this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK=7<<18,this.EFUSE_DOWNLOAD_MODE_XPD_ON_MASK=65536,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+56,this.EFUSE_SECURE_BOOT_EN_MASK=1<<20,this.PURPOSE_VAL_XTS_AES256_KEY_1=2,this.PURPOSE_VAL_XTS_AES256_KEY_2=3,this.PURPOSE_VAL_XTS_AES128_KEY=4,this.SUPPORTS_ENCRYPTED_FLASH=!0,this.FLASH_ENCRYPTED_WRITE_ALIGN=16,this.USB_RAM_BLOCK=2048,this.GPIO_STRAP_REG=1343094840,this.GPIO_STRAP_SPI_BOOT_MASK=8,this.RTC_CNTL_OPTION1_REG=1343291400,this.RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK=4,this.DR_REG_LPAON_BASE=1343291392,this.DR_REG_PMU_BASE=this.DR_REG_LPAON_BASE+20480,this.DR_REG_LP_SYS_BASE=this.DR_REG_LPAON_BASE+0,this.LP_SYSTEM_REG_ANA_XPD_PAD_GROUP_REG=this.DR_REG_LP_SYS_BASE+268,this.PMU_EXT_LDO_P0_0P1A_ANA_REG=this.DR_REG_PMU_BASE+444,this.PMU_ANA_0P1A_EN_CUR_LIM_0=1<<27,this.PMU_EXT_LDO_P0_0P1A_REG=this.DR_REG_PMU_BASE+440,this.PMU_0P1A_TARGET0_0=255<<23,this.PMU_0P1A_FORCE_TIEH_SEL_0=128,this.PMU_DATE_REG=this.DR_REG_PMU_BASE+1020,this.PMU_DATE_FLASH_FORCE_ON=3,this.UARTDEV_BUF_NO_USB_OTG=5,this.UARTDEV_BUF_NO_USB_JTAG_SERIAL=6,this.DR_REG_LP_WDT_BASE=1343315968,this.RTC_CNTL_WDTCONFIG0_REG=this.DR_REG_LP_WDT_BASE+0,this.RTC_CNTL_WDTCONFIG1_REG=this.DR_REG_LP_WDT_BASE+4,this.RTC_CNTL_WDTWPROTECT_REG=this.DR_REG_LP_WDT_BASE+24,this.RTC_CNTL_WDT_WKEY=1356348065,this.RTC_CNTL_SWD_CONF_REG=this.DR_REG_LP_WDT_BASE+28,this.RTC_CNTL_SWD_AUTO_FEED_EN=1<<18,this.RTC_CNTL_SWD_WPROTECT_REG=this.DR_REG_LP_WDT_BASE+32,this.RTC_CNTL_SWD_WKEY=1356348065,this.MEMORY_MAP=[[0,65536,"PADDING"],[1073741824,1275068416,"DROM"],[1341128704,1341784064,"DRAM"],[1341128704,1341784064,"BYTE_ACCESSIBLE"],[1337982976,1338114048,"DROM_MASK"],[1337982976,1338114048,"IROM_MASK"],[1073741824,1275068416,"IROM"],[1341128704,1341784064,"IRAM"],[1343258624,1343291392,"RTC_IRAM"],[1343258624,1343291392,"RTC_DRAM"],[1611653120,1611661312,"MEM_INTERNAL2"]],this.UF2_FAMILY_ID=1026592404,this.EFUSE_MAX_KEY=5,this.KEY_PURPOSES={0:"USER/EMPTY",1:"ECDSA_KEY",2:"XTS_AES_256_KEY_1",3:"XTS_AES_256_KEY_2",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2",12:"KM_INIT_KEY"}}async getPkgVersion(t){const e=this.EFUSE_BLOCK1_ADDR+8;return await t.readReg(e)>>20&7}async getMinorChipVersion(t){const e=this.EFUSE_BLOCK1_ADDR+8;return await t.readReg(e)>>0&15}async getMajorChipVersion(t){const e=this.EFUSE_BLOCK1_ADDR+8,i=await t.readReg(e);return(i>>23&1)<<2|i>>4&3}async getChipRevision(t){return 100*await this.getMajorChipVersion(t)+await this.getMinorChipVersion(t)}async getStubJsonPath(t){return await this.getChipRevision(t)<300?"./targets/stub_flasher/esp32p4-rev1.json":"./targets/stub_flasher/esp32p4.json"}async getChipDescription(t){return`${{0:"ESP32-P4"}[await this.getPkgVersion(t)]||"Unknown ESP32-P4"} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["High-Performance MCU"]}async getCrystalFreq(t){return 40}async getFlashVoltage(t){}async overrideVddsdio(t){t.debug("VDD_SDIO overrides are not supported for ESP32-P4")}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}async getFlashCryptConfig(t){}async getSecureBootEnabled(t){return 0!=(await t.readReg(this.EFUSE_SECURE_BOOT_EN_REG)&this.EFUSE_SECURE_BOOT_EN_MASK)}async getUartdevBufNo(t){return(await this.getChipRevision(t)<300?1341390512:1341914800)+24}async usesUsbOtg(t){const e=await this.getUartdevBufNo(t);return(255&await t.readReg(e))===this.UARTDEV_BUF_NO_USB_OTG}async usesUsbJtagSerial(t){if(t.secureDownloadMode)return!1;const e=await this.getUartdevBufNo(t);return(255&await t.readReg(e))===this.UARTDEV_BUF_NO_USB_JTAG_SERIAL}async getKeyBlockPurpose(t,e){if(e<0||e>this.EFUSE_MAX_KEY)return void t.debug(`Valid key block numbers must be in range 0-${this.EFUSE_MAX_KEY}`);const i=[[this.EFUSE_PURPOSE_KEY0_REG,this.EFUSE_PURPOSE_KEY0_SHIFT],[this.EFUSE_PURPOSE_KEY1_REG,this.EFUSE_PURPOSE_KEY1_SHIFT],[this.EFUSE_PURPOSE_KEY2_REG,this.EFUSE_PURPOSE_KEY2_SHIFT],[this.EFUSE_PURPOSE_KEY3_REG,this.EFUSE_PURPOSE_KEY3_SHIFT],[this.EFUSE_PURPOSE_KEY4_REG,this.EFUSE_PURPOSE_KEY4_SHIFT],[this.EFUSE_PURPOSE_KEY5_REG,this.EFUSE_PURPOSE_KEY5_SHIFT]],[s,r]=i[e];return await t.readReg(s)>>r&15}async isFlashEncryptionKeyValid(t){const e=[];for(let i=0;i<=this.EFUSE_MAX_KEY;i++){const s=await this.getKeyBlockPurpose(t,i);e.push(s)}if(e.some((t=>t===this.PURPOSE_VAL_XTS_AES128_KEY)))return!0;if(e.some((t=>t===this.PURPOSE_VAL_XTS_AES256_KEY_1))&&e.some((t=>t===this.PURPOSE_VAL_XTS_AES256_KEY_2)))return!0;return 0!=(await t.readReg(this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_REG)>>this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_SHIFT&this.FORCE_USE_KEY_MANAGER_VAL_XTS_AES_KEY)}async postConnect(t){await t.usesUsbOtg()&&(t.ESP_RAM_BLOCK=this.USB_RAM_BLOCK),t.IS_STUB||await this.disableWatchdogs(t),t.secureDownloadMode||await this.powerOnFlash(t)}async disableWatchdogs(t){if(await this.usesUsbJtagSerial(t)){await t.writeReg(this.RTC_CNTL_WDTWPROTECT_REG,this.RTC_CNTL_WDT_WKEY),await t.writeReg(this.RTC_CNTL_WDTCONFIG0_REG,0),await t.writeReg(this.RTC_CNTL_WDTWPROTECT_REG,0),await t.writeReg(this.RTC_CNTL_SWD_WPROTECT_REG,this.RTC_CNTL_SWD_WKEY);const e=await t.readReg(this.RTC_CNTL_SWD_CONF_REG);await t.writeReg(this.RTC_CNTL_SWD_CONF_REG,e|this.RTC_CNTL_SWD_AUTO_FEED_EN),await t.writeReg(this.RTC_CNTL_SWD_WPROTECT_REG,0)}}checkSpiConnection(t,e){if(!e.every((t=>t>=0&&t<=54)))throw new Error("SPI Pin numbers must be in the range 0-54.");e.some((t=>24===t||25===t))&&t.debug("GPIO pins 24 and 25 are used by USB-Serial/JTAG, consider using other pins for SPI flash connection.")}async watchdogReset(t){t.info("Hard resetting with a watchdog..."),await t.writeReg(this.RTC_CNTL_WDTWPROTECT_REG,this.RTC_CNTL_WDT_WKEY),await t.writeReg(this.RTC_CNTL_WDTCONFIG1_REG,2e3),await t.writeReg(this.RTC_CNTL_WDTCONFIG0_REG,-805306110),await t.writeReg(this.RTC_CNTL_WDTWPROTECT_REG,0),await new Promise((t=>setTimeout(t,500)))}async powerOnFlash(t){if(t.secureDownloadMode)throw new Error("Powering on flash in secure download mode is not allowed.");const e=await this.getChipRevision(t);if(301!==e&&302!==e)return;if(302===e){if(await t.readReg(this.EFUSE_RD_REPEAT_DATA1_REG)&this.EFUSE_DOWNLOAD_MODE_XPD_ON_MASK){const e=await t.readReg(this.PMU_DATE_REG);return void((e&this.PMU_DATE_FLASH_FORCE_ON)===this.PMU_DATE_FLASH_FORCE_ON&&await t.writeReg(this.PMU_DATE_REG,e&~this.PMU_DATE_FLASH_FORCE_ON))}}await t.writeReg(this.LP_SYSTEM_REG_ANA_XPD_PAD_GROUP_REG,1),await new Promise((t=>setTimeout(t,10)));let i=await t.readReg(this.PMU_EXT_LDO_P0_0P1A_ANA_REG);await t.writeReg(this.PMU_EXT_LDO_P0_0P1A_ANA_REG,i|this.PMU_ANA_0P1A_EN_CUR_LIM_0),i=await t.readReg(this.PMU_EXT_LDO_P0_0P1A_REG),await t.writeReg(this.PMU_EXT_LDO_P0_0P1A_REG,i|this.PMU_0P1A_FORCE_TIEH_SEL_0),i=await t.readReg(this.PMU_DATE_REG),await t.writeReg(this.PMU_DATE_REG,i|this.PMU_DATE_FLASH_FORCE_ON),await new Promise((t=>setTimeout(t,1))),i=await t.readReg(this.PMU_EXT_LDO_P0_0P1A_ANA_REG),await t.writeReg(this.PMU_EXT_LDO_P0_0P1A_ANA_REG,i&~this.PMU_ANA_0P1A_EN_CUR_LIM_0),i=await t.readReg(this.PMU_EXT_LDO_P0_0P1A_REG),await t.writeReg(this.PMU_EXT_LDO_P0_0P1A_REG,i&~this.PMU_0P1A_TARGET0_0),i=await t.readReg(this.PMU_EXT_LDO_P0_0P1A_REG),await t.writeReg(this.PMU_EXT_LDO_P0_0P1A_REG,128|i),i=await t.readReg(this.PMU_EXT_LDO_P0_0P1A_REG),await t.writeReg(this.PMU_EXT_LDO_P0_0P1A_REG,i&~this.PMU_0P1A_FORCE_TIEH_SEL_0),await new Promise((t=>setTimeout(t,2)))}}var qr=Object.freeze({__proto__:null,ESP32P4ROM:Wr});class Zr extends Fr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-S2",this.IMAGE_CHIP_ID=2,this.IROM_MAP_START=1074266112,this.IROM_MAP_END=1085800448,this.DROM_MAP_START=1056964608,this.DROM_MAP_END=1061093376,this.CHIP_DETECT_MAGIC_VALUE=[1990],this.SPI_REG_BASE=1061167104,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.SPI_ADDR_REG_MSB=!1,this.MAC_EFUSE_REG=1061265476,this.UART_CLKDIV_REG=1061158932,this.SUPPORTS_ENCRYPTED_FLASH=!0,this.FLASH_ENCRYPTED_WRITE_ALIGN=16,this.EFUSE_BASE=1061265408,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.EFUSE_BLOCK2_ADDR=this.EFUSE_BASE+92,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY0_SHIFT=24,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY1_SHIFT=28,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY2_SHIFT=0,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY3_SHIFT=4,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY4_SHIFT=8,this.EFUSE_PURPOSE_KEY5_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY5_SHIFT=12,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG=this.EFUSE_RD_REG_BASE,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT=1<<19,this.EFUSE_SPI_BOOT_CRYPT_CNT_REG=this.EFUSE_BASE+52,this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK=7<<18,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+56,this.EFUSE_SECURE_BOOT_EN_MASK=1<<20,this.EFUSE_RD_REPEAT_DATA3_REG=this.EFUSE_BASE+60,this.EFUSE_RD_REPEAT_DATA3_REG_FLASH_TYPE_MASK=512,this.PURPOSE_VAL_XTS_AES256_KEY_1=2,this.PURPOSE_VAL_XTS_AES256_KEY_2=3,this.PURPOSE_VAL_XTS_AES128_KEY=4,this.UARTDEV_BUF_NO=1073741076,this.UARTDEV_BUF_NO_USB_OTG=2,this.USB_RAM_BLOCK=2048,this.GPIO_STRAP_REG=1061175352,this.GPIO_STRAP_SPI_BOOT_MASK=8,this.GPIO_STRAP_VDDSPI_MASK=16,this.RTC_CNTL_OPTION1_REG=1061191976,this.RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK=1,this.RTCCNTL_BASE_REG=1061191680,this.RTC_CNTL_WDTCONFIG0_REG=this.RTCCNTL_BASE_REG+148,this.RTC_CNTL_WDTCONFIG1_REG=this.RTCCNTL_BASE_REG+152,this.RTC_CNTL_WDTWPROTECT_REG=this.RTCCNTL_BASE_REG+172,this.RTC_CNTL_WDT_WKEY=1356348065,this.MEMORY_MAP=[[0,65536,"PADDING"],[1056964608,1073217536,"DROM"],[1062207488,1073217536,"EXTRAM_DATA"],[1073340416,1073348608,"RTC_DRAM"],[1073340416,1073741824,"BYTE_ACCESSIBLE"],[1073340416,1074208768,"MEM_INTERNAL"],[1073414144,1073741824,"DRAM"],[1073741824,1073848576,"IROM_MASK"],[1073872896,1074200576,"IRAM"],[1074200576,1074208768,"RTC_IRAM"],[1074266112,1082130432,"IROM"],[1342177280,1342185472,"RTC_DATA"]],this.EFUSE_VDD_SPI_REG=this.EFUSE_BASE+52,this.VDD_SPI_XPD=16,this.VDD_SPI_TIEH=32,this.VDD_SPI_FORCE=64,this.UF2_FAMILY_ID=3218951918,this.EFUSE_MAX_KEY=5,this.KEY_PURPOSES={0:"USER/EMPTY",1:"RESERVED",2:"XTS_AES_256_KEY_1",3:"XTS_AES_256_KEY_2",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2"},this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612856,this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=4096}async getPkgVersion(t){const e=this.EFUSE_BLOCK1_ADDR+16;return await t.readReg(e)>>0&15}async getMinorChipVersion(t){return((await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>20&1)<<3)+(await t.readReg(this.EFUSE_BLOCK1_ADDR+16)>>4&7)}async getMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>18&3}async getFlashVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>21&15}async getChipDescription(t){const e=await this.getFlashCap(t)+100*await this.getPsramCap(t),i=await this.getMajorChipVersion(t),s=await this.getMinorChipVersion(t);return`${{0:"ESP32-S2",1:"ESP32-S2FH2",2:"ESP32-S2FH4",102:"ESP32-S2FNR2",100:"ESP32-S2R2"}[e]||"unknown ESP32-S2"} (revision v${i}.${s})`}async getFlashCap(t){return await this.getFlashVersion(t)}async getPsramVersion(t){const e=this.EFUSE_BLOCK1_ADDR+12;return await t.readReg(e)>>28&15}async getPsramCap(t){return await this.getPsramVersion(t)}async getBlock2Version(t){const e=this.EFUSE_BLOCK2_ADDR+16;return await t.readReg(e)>>4&7}async getChipFeatures(t){const e=["Wi-Fi"],i={0:"No Embedded Flash",1:"Embedded Flash 2MB",2:"Embedded Flash 4MB"}[await this.getFlashCap(t)]||"Unknown Embedded Flash";e.push(i);const s={0:"No Embedded Flash",1:"Embedded PSRAM 2MB",2:"Embedded PSRAM 4MB"}[await this.getPsramCap(t)]||"Unknown Embedded PSRAM";e.push(s);const r={0:"No calibration in BLK2 of efuse",1:"ADC and temperature sensor calibration in BLK2 of efuse V1",2:"ADC and temperature sensor calibration in BLK2 of efuse V2"}[await this.getBlock2Version(t)]||"Unknown Calibration in BLK2";return e.push(r),e}async getCrystalFreq(t){return 40}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}getEraseSize(t,e){return e}async usingUsbOtg(t){return(255&await t.readReg(this.UARTDEV_BUF_NO))===this.UARTDEV_BUF_NO_USB_OTG}async postConnect(t){await t.usesUsbOtg()&&(t.ESP_RAM_BLOCK=this.USB_RAM_BLOCK)}}var Xr=Object.freeze({__proto__:null,ESP32S2ROM:Zr});class jr extends Fr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-S3",this.IMAGE_CHIP_ID=9,this.USES_MAGIC_VALUE=!1,this.EFUSE_BASE=1610641408,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.EFUSE_BLOCK2_ADDR=this.EFUSE_BASE+92,this.UART_CLKDIV_REG=1610612756,this.UART_CLKDIV_MASK=1048575,this.UART_DATE_REG_ADDR=1610612864,this.FLASH_WRITE_SIZE=1024,this.BOOTLOADER_FLASH_OFFSET=0,this.SPI_REG_BASE=1610620928,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.USB_RAM_BLOCK=2048,this.UARTDEV_BUF_NO_USB=3,this.UARTDEV_BUF_NO=1070526796,this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1140850688,this.MEMORY_MAP=[[0,65536,"PADDING"],[1006632960,1023410176,"DROM"],[1023410176,1040187392,"EXTRAM_DATA"],[1611653120,1611661312,"RTC_DRAM"],[1070104576,1070596096,"BYTE_ACCESSIBLE"],[1070104576,1077813248,"MEM_INTERNAL"],[1070104576,1070596096,"DRAM"],[1073741824,1073848576,"IROM_MASK"],[1077346304,1077805056,"IRAM"],[1611653120,1611661312,"RTC_IRAM"],[1107296256,1115684864,"IROM"],[1342177280,1342185472,"RTC_DATA"]]}async getChipDescription(t){const e=await this.getMajorChipVersion(t),i=await this.getMinorChipVersion(t);return`${{0:"ESP32-S3 (QFN56)",1:"ESP32-S3-PICO-1 (LGA56)"}[await this.getPkgVersion(t)]||"unknown ESP32-S3"} (revision v${e}.${i})`}async getPkgVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>21&7}async getRawMinorChipVersion(t){return((await t.readReg(this.EFUSE_BLOCK1_ADDR+20)>>23&1)<<3)+(await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>18&7)}async getMinorChipVersion(t){const e=await this.getRawMinorChipVersion(t);return await this.isEco0(t,e)?0:this.getRawMinorChipVersion(t)}async getRawMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+20)>>24&3}async getMajorChipVersion(t){const e=await this.getRawMinorChipVersion(t);return await this.isEco0(t,e)?0:this.getRawMajorChipVersion(t)}async getBlkVersionMajor(t){return await t.readReg(this.EFUSE_BLOCK2_ADDR+16)>>0&3}async getBlkVersionMinor(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>24&7}async isEco0(t,e){return 0==(7&e)&&1===await this.getBlkVersionMajor(t)&&1===await this.getBlkVersionMinor(t)}async getFlashCap(t){const e=this.EFUSE_BASE+68+12;return await t.readReg(e)>>27&7}async getFlashVendor(t){const e=this.EFUSE_BASE+68+16;return{1:"XMC",2:"GD",3:"FM",4:"TT",5:"BY"}[await t.readReg(e)>>0&7]||""}async getPsramCap(t){const e=this.EFUSE_BASE+68+16;return await t.readReg(e)>>3&3}async getPsramVendor(t){const e=this.EFUSE_BASE+68+16;return{1:"AP_3v3",2:"AP_1v8"}[await t.readReg(e)>>7&3]||""}async getChipFeatures(t){const e=["Wi-Fi","BLE"],i=await this.getFlashCap(t),s=await this.getFlashVendor(t),r={0:null,1:"Embedded Flash 8MB",2:"Embedded Flash 4MB"}[i],a=void 0!==r?r:"Unknown Embedded Flash";null!==r&&e.push(`${a} (${s})`);const o=await this.getPsramCap(t),n=await this.getPsramVendor(t),l={0:null,1:"Embedded PSRAM 8MB",2:"Embedded PSRAM 2MB"}[o],d=void 0!==l?l:"Unknown Embedded PSRAM";return null!==l&&e.push(`${d} (${n})`),e}async getCrystalFreq(t){return 40}_d2h(t){const e=(+t).toString(16);return 1===e.length?"0"+e:e}async postConnect(t){await t.usesUsbOtg()&&(t.ESP_RAM_BLOCK=this.USB_RAM_BLOCK)}async usesUsbJtagSerial(t){return(255&await t.readReg(this.UARTDEV_BUF_NO))===this.UARTDEV_BUF_NO_USB}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}getEraseSize(t,e){return e}}var Jr=Object.freeze({__proto__:null,ESP32S3ROM:jr});const Qr={esp8266:new lr,esp32:new Fr,esp32s2:new Zr,esp32s3:new jr,esp32s31:new class extends $r{constructor(){super(...arguments),this.CHIP_NAME="ESP32-S31",this.IMAGE_CHIP_ID=32,this.USES_MAGIC_VALUE=!1,this.IROM_MAP_START=1073741824,this.IROM_MAP_END=1409286144,this.DROM_MAP_START=1073741824,this.DROM_MAP_END=1409286144,this.BOOTLOADER_FLASH_OFFSET=8192,this.UART_DATE_REG_ADDR=540582028,this.UART_CLKDIV_REG=540581908,this.EFUSE_BASE=544296960,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+80,this.MAC_EFUSE_REG=this.EFUSE_BASE+80,this.SPI_REG_BASE=542117888,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.SPI_ADDR_REG_MSB=!1,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY0_SHIFT=0,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY1_SHIFT=5,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY2_SHIFT=10,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY3_SHIFT=15,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY4_SHIFT=20,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG=this.EFUSE_RD_REG_BASE,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT=1<<20,this.EFUSE_SPI_BOOT_CRYPT_CNT_REG=this.EFUSE_BASE+52,this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK=7<<21,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+60,this.EFUSE_SECURE_BOOT_EN_MASK=4,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_REG=this.EFUSE_BASE+52,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_SHIFT=12,this.FORCE_USE_KEY_MANAGER_VAL_XTS_AES_KEY=2,this.PURPOSE_VAL_XTS_AES256_KEY_1=2,this.PURPOSE_VAL_XTS_AES256_KEY_2=3,this.PURPOSE_VAL_XTS_AES128_KEY=4,this.FLASH_ENCRYPTED_WRITE_ALIGN=16,this.USB_RAM_BLOCK=2048,this.MEMORY_MAP=[[0,65536,"PADDING"],[1073741824,1409286144,"DROM"],[788529152,789053440,"DRAM"],[788529152,789053440,"BYTE_ACCESSIBLE"],[796917760,797245440,"DROM_MASK"],[796917760,797245440,"IROM_MASK"],[1073741824,1409286144,"IROM"],[788529152,789053440,"IRAM"],[771751936,771784704,"RTC_IRAM"],[771751936,771784704,"RTC_DRAM"]],this.UF2_FAMILY_ID=822212545,this.EFUSE_MAX_KEY=4,this.KEY_PURPOSES={0:"USER/EMPTY",1:"ECDSA_KEY",2:"XTS_AES_256_KEY_1",3:"XTS_AES_256_KEY_2",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2",12:"KM_INIT_KEY",13:"XTS_AES_256_PSRAM_KEY_1",14:"XTS_AES_256_PSRAM_KEY_2",15:"XTS_AES_128_PSRAM_KEY",16:"ECDSA_KEY_P192",17:"ECDSA_KEY_P384_L",18:"ECDSA_KEY_P384_H",19:"SDC_KEY_DIGEST"}}async getPkgVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+16)>>6&3}async getMinorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>18&15}async getMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>22&3}async getChipRevision(t){return 100*await this.getMajorChipVersion(t)+await this.getMinorChipVersion(t)}async getChipDescription(t){return`${0===await this.getPkgVersion(t)?"ESP32-S31":"unknown ESP32-S31"} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["Wi-Fi 6","BT 5.4 (LE)","IEEE802.15.4","Dual Core + LP Core","300MHz"]}async getCrystalFreq(t){return 40}async getKeyBlockPurpose(t,e){if(e<0||e>this.EFUSE_MAX_KEY)throw new Error(`Valid key block numbers must be in range 0-${this.EFUSE_MAX_KEY}`);const i=[[this.EFUSE_PURPOSE_KEY0_REG,this.EFUSE_PURPOSE_KEY0_SHIFT],[this.EFUSE_PURPOSE_KEY1_REG,this.EFUSE_PURPOSE_KEY1_SHIFT],[this.EFUSE_PURPOSE_KEY2_REG,this.EFUSE_PURPOSE_KEY2_SHIFT],[this.EFUSE_PURPOSE_KEY3_REG,this.EFUSE_PURPOSE_KEY3_SHIFT],[this.EFUSE_PURPOSE_KEY4_REG,this.EFUSE_PURPOSE_KEY4_SHIFT]],[s,r]=i[e];return await t.readReg(s)>>r&31}async isFlashEncryptionKeyValid(t){const e=[];for(let i=0;i<=this.EFUSE_MAX_KEY;i++)e.push(await this.getKeyBlockPurpose(t,i));if(e.some((t=>t===this.PURPOSE_VAL_XTS_AES128_KEY)))return!0;if(e.some((t=>t===this.PURPOSE_VAL_XTS_AES256_KEY_1))&&e.some((t=>t===this.PURPOSE_VAL_XTS_AES256_KEY_2)))return!0;return 0!=(await t.readReg(this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_REG)>>this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_SHIFT&this.FORCE_USE_KEY_MANAGER_VAL_XTS_AES_KEY)}checkSpiConnection(t,e){if(!e.every((t=>t>=0&&t<=60)))throw new Error("SPI Pin numbers must be in the range 0-60.");e.some((t=>33===t||34===t))&&t.info("GPIO pins 33 and 34 are used by USB-Serial/JTAG, consider using other pins for SPI flash connection.")}async postConnect(t){await t.usesUsbOtg()&&(t.ESP_RAM_BLOCK=this.USB_RAM_BLOCK)}async changeBaud(t){await t.changeBaud()}},esp32c3:new Mr,esp32c2:new Lr,esp32c6:new Nr,esp32c61:new Hr,esp32c5:new $r,esp32e22:new class extends Fr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-E22",this.IMAGE_CHIP_ID=31,this.USES_MAGIC_VALUE=!1,this.IROM_MAP_START=1006632960,this.IROM_MAP_END=1073741824,this.DROM_MAP_START=1006632960,this.DROM_MAP_END=1073741824,this.BOOTLOADER_FLASH_OFFSET=0,this.UART_DATE_REG_ADDR=3272614028,this.UART_CLKDIV_REG=3272613908,this.EFUSE_BASE=3288367104,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.SPI_REG_BASE=3271569408,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.SPI_ADDR_REG_MSB=!1,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY0_SHIFT=24,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY1_SHIFT=28,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY2_SHIFT=0,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY3_SHIFT=4,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY4_SHIFT=8,this.EFUSE_PURPOSE_KEY5_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY5_SHIFT=12,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+56,this.EFUSE_SECURE_BOOT_EN_MASK=1<<20,this.PURPOSE_VAL_XTS_AES256_KEY_1=2,this.PURPOSE_VAL_XTS_AES256_KEY_2=3,this.PURPOSE_VAL_XTS_AES128_KEY=4,this.FLASH_ENCRYPTED_WRITE_ALIGN=16,this.USB_RAM_BLOCK=2048,this.MEMORY_MAP=[[0,65536,"PADDING"],[1006632960,1073741824,"DROM"],[822083584,824180736,"DRAM"],[822083584,824180736,"BYTE_ACCESSIBLE"],[805306368,806486016,"DROM_MASK"],[805306368,806486016,"IROM_MASK"],[1006632960,1073741824,"IROM"],[821952512,824180736,"IRAM"],[3221225472,3221258240,"RTC_IRAM"],[3221225472,3221258240,"RTC_DRAM"]],this.EFUSE_MAX_KEY=5,this.KEY_PURPOSES={0:"USER/EMPTY",1:"ECDSA_KEY",2:"XTS_AES_256_KEY_1",3:"XTS_AES_256_KEY_2",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2",12:"KM_INIT_KEY"}}async getPkgVersion(t){return 0}async getMinorChipVersion(t){return 0}async getMajorChipVersion(t){return 0}async getChipRevision(t){return 100*await this.getMajorChipVersion(t)+await this.getMinorChipVersion(t)}async getChipDescription(t){return`${0===await this.getPkgVersion(t)?"ESP32-E22":"unknown ESP32-E22"} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["Wi-Fi 6E (tri-band, 2x2 MU-MIMO)","BT 5.4 (LE) + Classic","Dual Core","500MHz"]}async readMac(t){let e=await t.readReg(this.MAC_EFUSE_REG);e>>>=0;let i=await t.readReg(this.MAC_EFUSE_REG+4);i=i>>>0&65535;const s=new Uint8Array(6);return s[0]=i>>8&255,s[1]=255&i,s[2]=e>>24&255,s[3]=e>>16&255,s[4]=e>>8&255,s[5]=255&e,this._d2h(s[0])+":"+this._d2h(s[1])+":"+this._d2h(s[2])+":"+this._d2h(s[3])+":"+this._d2h(s[4])+":"+this._d2h(s[5])}async getKeyBlockPurpose(t,e){if(e<0||e>this.EFUSE_MAX_KEY)throw new Error(`Valid key block numbers must be in range 0-${this.EFUSE_MAX_KEY}`);const i=[[this.EFUSE_PURPOSE_KEY0_REG,this.EFUSE_PURPOSE_KEY0_SHIFT],[this.EFUSE_PURPOSE_KEY1_REG,this.EFUSE_PURPOSE_KEY1_SHIFT],[this.EFUSE_PURPOSE_KEY2_REG,this.EFUSE_PURPOSE_KEY2_SHIFT],[this.EFUSE_PURPOSE_KEY3_REG,this.EFUSE_PURPOSE_KEY3_SHIFT],[this.EFUSE_PURPOSE_KEY4_REG,this.EFUSE_PURPOSE_KEY4_SHIFT],[this.EFUSE_PURPOSE_KEY5_REG,this.EFUSE_PURPOSE_KEY5_SHIFT]],[s,r]=i[e];return await t.readReg(s)>>r&15}checkSpiConnection(t,e){if(!e.every((t=>t>=0&&t<=52)))throw new Error("SPI Pin numbers must be in the range 0-52.");e.some((t=>18===t||19===t))&&t.info("GPIO pins 18 and 19 are used by USB-OTG, consider using other pins for SPI flash connection.")}async postConnect(t){await t.usesUsbOtg()&&(t.ESP_RAM_BLOCK=this.USB_RAM_BLOCK)}},esp32h2:new Yr,esp32h21:new class extends Yr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-H21",this.IMAGE_CHIP_ID=25,this.USES_MAGIC_VALUE=!1,this.UF2_FAMILY_ID=3067936943,this.DR_REG_LP_WDT_BASE=1611340800,this.RTC_CNTL_WDTCONFIG0_REG=this.DR_REG_LP_WDT_BASE+0,this.RTC_CNTL_WDTWPROTECT_REG=this.DR_REG_LP_WDT_BASE+28,this.RTC_CNTL_SWD_CONF_REG=this.DR_REG_LP_WDT_BASE+32,this.RTC_CNTL_SWD_AUTO_FEED_EN=1<<18,this.RTC_CNTL_SWD_WPROTECT_REG=this.DR_REG_LP_WDT_BASE+36,this.RTC_CNTL_SWD_WKEY=1356348065,this.EFUSE_BASE=1611350016,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY0_SHIFT=24,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY1_SHIFT=28,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY2_SHIFT=0,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY3_SHIFT=4,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY4_SHIFT=8,this.EFUSE_PURPOSE_KEY5_REG=this.EFUSE_BASE+56,this.EFUSE_PURPOSE_KEY5_SHIFT=12,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG=this.EFUSE_RD_REG_BASE,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT=1<<20,this.EFUSE_SPI_BOOT_CRYPT_CNT_REG=this.EFUSE_BASE+52,this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK=7<<18,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+56,this.EFUSE_SECURE_BOOT_EN_MASK=1<<20,this.KEY_PURPOSES={0:"USER/EMPTY",1:"ECDSA_KEY",2:"RESERVED",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2"}}async getPkgVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+20)>>11&7}async getMinorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+20)>>4&15}async getMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+20)>>8&3}async getChipRevision(t){return 100*await this.getMajorChipVersion(t)+await this.getMinorChipVersion(t)}async getChipDescription(t){return`${0===await this.getPkgVersion(t)?"ESP32-H21":"Unknown ESP32-H21"} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["BT 5 (LE)","IEEE802.15.4","Single Core","96MHz"]}async getCrystalFreq(t){return 32}checkSpiConnection(t,e){if(!e.every((t=>t>=0&&t<=27)))throw new Error("SPI Pin numbers must be in the range 0-27.");e.some((t=>26===t||27===t))&&t.info("GPIO pins 26 and 27 are used by USB-Serial/JTAG, consider using other pins for SPI flash connection.")}},esp32p4:new Wr,esp32h4:new class extends Mr{constructor(){super(...arguments),this.CHIP_NAME="ESP32-H4",this.IMAGE_CHIP_ID=28,this.USES_MAGIC_VALUE=!1,this.IROM_MAP_START=1107296256,this.IROM_MAP_END=1115684864,this.DROM_MAP_START=1115684864,this.DROM_MAP_END=1124073472,this.BOOTLOADER_FLASH_OFFSET=8192,this.SPI_REG_BASE=1611239424,this.SPI_USR_OFFS=24,this.SPI_USR1_OFFS=28,this.SPI_USR2_OFFS=32,this.SPI_MOSI_DLEN_OFFS=36,this.SPI_MISO_DLEN_OFFS=40,this.SPI_W0_OFFS=88,this.UART_DATE_REG_ADDR=1610686588,this.EFUSE_BASE=1611339776,this.EFUSE_BLOCK1_ADDR=this.EFUSE_BASE+68,this.MAC_EFUSE_REG=this.EFUSE_BASE+68,this.EFUSE_RD_REG_BASE=this.EFUSE_BASE+48,this.EFUSE_PURPOSE_KEY0_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY0_SHIFT=0,this.EFUSE_PURPOSE_KEY1_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY1_SHIFT=5,this.EFUSE_PURPOSE_KEY2_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY2_SHIFT=10,this.EFUSE_PURPOSE_KEY3_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY3_SHIFT=15,this.EFUSE_PURPOSE_KEY4_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY4_SHIFT=20,this.EFUSE_PURPOSE_KEY5_REG=this.EFUSE_BASE+52,this.EFUSE_PURPOSE_KEY5_SHIFT=25,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT_REG=this.EFUSE_RD_REG_BASE,this.EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT=16384,this.EFUSE_SPI_BOOT_CRYPT_CNT_REG=this.EFUSE_BASE+48,this.EFUSE_SPI_BOOT_CRYPT_CNT_MASK=7<<23,this.EFUSE_SECURE_BOOT_EN_REG=this.EFUSE_BASE+56,this.EFUSE_SECURE_BOOT_EN_MASK=32,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_REG=this.EFUSE_BASE+56,this.EFUSE_FORCE_USE_KEY_MANAGER_KEY_SHIFT=19,this.FORCE_USE_KEY_MANAGER_VAL_XTS_AES_KEY=2,this.PURPOSE_VAL_XTS_AES256_KEY_1=2,this.PURPOSE_VAL_XTS_AES256_KEY_2=3,this.PURPOSE_VAL_XTS_AES128_KEY=4,this.FLASH_ENCRYPTED_WRITE_ALIGN=16,this.FLASH_FREQUENCY={"48m":15,"24m":0,"16m":1,"12m":2},this.MEMORY_MAP=[[0,65536,"PADDING"],[1107296256,1140850688,"DROM"],[1082195968,1082523648,"DRAM"],[1082195968,1082523648,"BYTE_ACCESSIBLE"],[1073741824,1074069504,"DROM_MASK"],[1073741824,1074069504,"IROM_MASK"],[1107296256,1140850688,"IROM"],[1082195968,1082523648,"IRAM"],[1342177280,1342193664,"RTC_IRAM"],[1342177280,1342193664,"RTC_DRAM"],[1610612736,1611661312,"MEM_INTERNAL2"]],this.UF2_FAMILY_ID=2651564682,this.EFUSE_MAX_KEY=5,this.KEY_PURPOSES={0:"USER/EMPTY",1:"ECDSA_KEY",2:"XTS_AES_256_KEY_FLASH_1",3:"XTS_AES_256_KEY_FLASH_2",4:"XTS_AES_128_KEY",5:"HMAC_DOWN_ALL",6:"HMAC_DOWN_JTAG",7:"HMAC_DOWN_DIGITAL_SIGNATURE",8:"HMAC_UP",9:"SECURE_BOOT_DIGEST0",10:"SECURE_BOOT_DIGEST1",11:"SECURE_BOOT_DIGEST2",12:"KM_INIT_KEY",13:"XTS_AES_256_KEY_PSRAM_1",14:"XTS_AES_256_KEY_PSRAM_2",15:"XTS_AES_128_KEY_PSRAM",16:"ECDSA_KEY_P192",17:"ECDSA_KEY_P384_L",18:"ECDSA_KEY_P384_H"}}async getPkgVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+16)>>12&7}async getMinorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>18&15}async getMajorChipVersion(t){return await t.readReg(this.EFUSE_BLOCK1_ADDR+12)>>22&3}async getChipRevision(t){return 100*await this.getMajorChipVersion(t)+await this.getMinorChipVersion(t)}async getChipDescription(t){return`${0===await this.getPkgVersion(t)?"ESP32-H4 (QFN40)":"Unknown ESP32-H4"} (revision v${await this.getMajorChipVersion(t)}.${await this.getMinorChipVersion(t)})`}async getChipFeatures(t){return["BT 5 (LE)","IEEE802.15.4","Dual Core","96MHz"]}async getCrystalFreq(t){return 32}async getKeyBlockPurpose(t,e){if(e<0||e>this.EFUSE_MAX_KEY)throw new Error(`Valid key block numbers must be in range 0-${this.EFUSE_MAX_KEY}`);const i=[[this.EFUSE_PURPOSE_KEY0_REG,this.EFUSE_PURPOSE_KEY0_SHIFT],[this.EFUSE_PURPOSE_KEY1_REG,this.EFUSE_PURPOSE_KEY1_SHIFT],[this.EFUSE_PURPOSE_KEY2_REG,this.EFUSE_PURPOSE_KEY2_SHIFT],[this.EFUSE_PURPOSE_KEY3_REG,this.EFUSE_PURPOSE_KEY3_SHIFT],[this.EFUSE_PURPOSE_KEY4_REG,this.EFUSE_PURPOSE_KEY4_SHIFT],[this.EFUSE_PURPOSE_KEY5_REG,this.EFUSE_PURPOSE_KEY5_SHIFT]],[s,r]=i[e];return await t.readReg(s)>>r&31}checkSpiConnection(t,e){if(!e.every((t=>t>=0&&t<=39)))throw new Error("SPI Pin numbers must be in the range 0-39.");e.some((t=>13===t||14===t))&&t.info("GPIO pins 13 and 14 are used by USB-Serial/JTAG, consider using other pins for SPI flash connection.")}}},ta=Object.values(Qr),ea={SECURE_BOOT_EN:1,SECURE_BOOT_AGGRESSIVE_REVOKE:2,SECURE_DOWNLOAD_ENABLE:4,SECURE_BOOT_KEY_REVOKE0:8,SECURE_BOOT_KEY_REVOKE1:16,SECURE_BOOT_KEY_REVOKE2:32,SOFT_DIS_JTAG:64,HARD_DIS_JTAG:128,DIS_USB:256,DIS_DOWNLOAD_DCACHE:512,DIS_DOWNLOAD_ICACHE:1024};function ia(t){const e={};for(const i of Object.keys(ea))e[i]=0!=(t&ea[i]);return e}const sa=12346;class ra{constructor(t){var e,i,s,r,a,o,n,l;this.ESP_RAM_BLOCK=6144,this.ESP_FLASH_BEGIN=2,this.ESP_FLASH_DATA=3,this.ESP_FLASH_END=4,this.ESP_MEM_BEGIN=5,this.ESP_MEM_END=6,this.ESP_MEM_DATA=7,this.ESP_WRITE_REG=9,this.ESP_READ_REG=10,this.ESP_SPI_ATTACH=13,this.ESP_CHANGE_BAUDRATE=15,this.ESP_FLASH_DEFL_BEGIN=16,this.ESP_FLASH_DEFL_DATA=17,this.ESP_FLASH_DEFL_END=18,this.ESP_SPI_FLASH_MD5=19,this.ESP_GET_SECURITY_INFO=20,this.ESP_ERASE_FLASH=208,this.ESP_ERASE_REGION=209,this.ESP_READ_FLASH=210,this.ESP_RUN_USER_CODE=211,this.ESP_IMAGE_MAGIC=233,this.ESP_CHECKSUM_MAGIC=239,this.ROM_INVALID_RECV_MSG=5,this.DEFAULT_TIMEOUT=3e3,this.ERASE_REGION_TIMEOUT_PER_MB=3e4,this.ERASE_WRITE_TIMEOUT_PER_MB=4e4,this.MD5_TIMEOUT_PER_MB=8e3,this.CHIP_ERASE_TIMEOUT=12e4,this.FLASH_READ_TIMEOUT=1e5,this.MAX_TIMEOUT=2*this.CHIP_ERASE_TIMEOUT,this.WRITE_BLOCK_ATTEMPTS=3,this.WRITE_BLOCK_RETRY_DELAY_MS=150,this.SPI_ADDR_REG_MSB=!0,this.CHIP_DETECT_MAGIC_REG_ADDR=1073745920,this.DETECTED_FLASH_SIZES={18:"256KB",19:"512KB",20:"1MB",21:"2MB",22:"4MB",23:"8MB",24:"16MB",25:"32MB",26:"64MB",27:"128MB",28:"256MB",32:"64MB",33:"128MB",34:"256MB",50:"256KB",51:"512KB",52:"1MB",53:"2MB",54:"4MB",55:"8MB",56:"16MB",57:"32MB",58:"64MB"},this.secureDownloadMode=!1,this.securityInfoCache=null,this.romBaudrate=115200,this.debugLogging=!1,this.syncStubDetected=!1,this.IS_STUB=!1,this.FLASH_WRITE_SIZE=16384,this.transport=t.transport,this.baudrate=t.baudrate,void 0!==t.romBaudrate&&(this.romBaudrate=t.romBaudrate),this.resetConstructors={classicReset:(t,e)=>new js(t,e),customReset:(t,e)=>new tr(t,e),hardReset:(t,e)=>new Qs(t,e),usbJTAGSerialReset:t=>new Js(t)},t.serialOptions&&(this.serialOptions=t.serialOptions),t.terminal&&(this.terminal=t.terminal,this.terminal.clean()),void 0!==t.debugLogging&&(this.debugLogging=t.debugLogging),t.port&&(this.transport=new Zs(t.port)),void 0!==t.enableTracing&&(this.transport.tracing=t.enableTracing),(null===(e=t.resetConstructors)||void 0===e?void 0:e.classicReset)&&(this.resetConstructors.classicReset=null===(i=t.resetConstructors)||void 0===i?void 0:i.classicReset),(null===(s=t.resetConstructors)||void 0===s?void 0:s.customReset)&&(this.resetConstructors.customReset=null===(r=t.resetConstructors)||void 0===r?void 0:r.customReset),(null===(a=t.resetConstructors)||void 0===a?void 0:a.hardReset)&&(this.resetConstructors.hardReset=null===(o=t.resetConstructors)||void 0===o?void 0:o.hardReset),(null===(n=t.resetConstructors)||void 0===n?void 0:n.usbJTAGSerialReset)&&(this.resetConstructors.usbJTAGSerialReset=null===(l=t.resetConstructors)||void 0===l?void 0:l.usbJTAGSerialReset),this.info("esptool.js"),this.info("Serial port "+this.transport.getInfo())}write(t,e=!0){this.terminal?e?this.terminal.writeLine(t):this.terminal.write(t):console.log(t)}error(t,e=!0){this.write(`Error: ${t}`,e)}info(t,e=!0){this.write(t,e)}debug(t,e=!0){this.debugLogging&&this.write(`Debug: ${t}`,e)}_shortToBytearray(t){return new Uint8Array([255&t,t>>8&255])}_intToByteArray(t){return new Uint8Array([255&t,t>>8&255,t>>16&255,t>>24&255])}_byteArrayToInt(t,e,i,s){return t|e<<8|i<<16|s<<24}_appendArray(t,e){const i=new Uint8Array(t.length+e.length);return i.set(t,0),i.set(e,t.length),i}async readPacket(t=null,e=this.DEFAULT_TIMEOUT){for(let i=0;i<100;i++){const i=await this.transport.read(e);if(!i||i.length<8)continue;const s=i[0];if(1!==s)continue;const r=i[1],a=this._byteArrayToInt(i[4],i[5],i[6],i[7]),o=i.slice(8);if(1==s){if(null==t||r==t)return[a,o];if(0!=o[0]&&o[1]==this.ROM_INVALID_RECV_MSG)throw await this.transport.drainInput(),new Tt}}throw new xt("invalid response")}async command(t=null,e=new Uint8Array(0),i=0,s=!0,r=this.DEFAULT_TIMEOUT){if(null!=t){this.transport.flushInput(),this.transport.tracing&&this.transport.trace(`command op:0x${t.toString(16).padStart(2,"0")} data len=${e.length} wait_response=${s?1:0} timeout=${(r/1e3).toFixed(3)} data=${this.transport.hexConvert(e)}`);const a=new Uint8Array(8+e.length);let o;for(a[0]=0,a[1]=t,a[2]=this._shortToBytearray(e.length)[0],a[3]=this._shortToBytearray(e.length)[1],a[4]=this._intToByteArray(i)[0],a[5]=this._intToByteArray(i)[1],a[6]=this._intToByteArray(i)[2],a[7]=this._intToByteArray(i)[3],o=0;o<e.length;o++)a[8+o]=e[o];await this.transport.write(a)}return s?this.readPacket(t,r):[0,new Uint8Array(0)]}async readReg(t,e=this.DEFAULT_TIMEOUT){this.debug(`Read Register:${this.toHex(t)}`);const i=this._intToByteArray(t),s=await this.command(this.ESP_READ_REG,i,void 0,void 0,e);return this.debug(`Read Register Value:${s[0]}`),s[0]}async writeReg(t,e,i=4294967295,s=0,r=0){let a=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));a=this._appendArray(a,this._intToByteArray(i)),a=this._appendArray(a,this._intToByteArray(s)),r>0&&(a=this._appendArray(a,this._intToByteArray(this.chip.UART_DATE_REG_ADDR)),a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(r))),await this.checkCommand("write target memory",this.ESP_WRITE_REG,a)}async sync(){this.debug("Sync");const t=new Uint8Array(36);let e;for(t[0]=7,t[1]=7,t[2]=18,t[3]=32,e=0;e<32;e++)t[4+e]=85;try{let e=await this.command(8,t,void 0,void 0,100);this.syncStubDetected=0===e[0];for(let t=0;t<7;t++)e=await this.readPacket(8,100),this.syncStubDetected=this.syncStubDetected&&0===e[0];return e}catch(t){throw this.debug("Sync err "+t),t}}async _connectAttempt(t="default_reset",e){this.debug("_connect_attempt "+t),e&&await e.reset();const i=this.transport.peek(),s=Array.from(i,(t=>String.fromCharCode(t))).join("").match(/boot:(0x[0-9a-fA-F]+)([\s\S]*?waiting for download)?/);let r=!1,a="",o=!1;s&&(r=!0,a=s[1],o=!!s[2]),this.debug(`bootMode:${a} downloadMode:${o}`);let n="";for(let t=0;t<5;t++)try{this.debug(`Sync connect attempt ${t}`),this.transport.flushInput();const e=await this.sync();return this.debug(e[0].toString()),"success"}catch(t){this.debug(`Error at sync ${t}`),n=t instanceof Error?t.message:"string"==typeof t?t:JSON.stringify(t)}return r&&(n=`Wrong boot mode detected (${a}).\n        This chip needs to be in download mode.`,o&&(n="Download mode successfully detected, but getting no sync reply:\n           The serial TX path seems to be down.")),n}isUsbJtagSerialPort(){return this.transport.getVid()===sa&&4097===this.transport.getPid()}async usesUsbOtg(){const t=this.transport.getVid(),e=this.transport.getPid();return t===sa&&null!=this.chip.IMAGE_CHIP_ID&&e===this.chip.IMAGE_CHIP_ID||(t!==sa||4097!==e)&&((void 0===t||t===sa)&&("function"==typeof this.chip.usesUsbOtg?await this.chip.usesUsbOtg(this):"function"==typeof this.chip.usingUsbOtg&&await this.chip.usingUsbOtg(this)))}async applyUsbFlashWriteSize(){const t=this.chip.USB_RAM_BLOCK;t&&await this.usesUsbOtg()&&(this.FLASH_WRITE_SIZE=t,this.debug(`Using USB_RAM_BLOCK (0x${t.toString(16)}) for FLASH_WRITE_SIZE (USB-OTG)`))}constructResetSequence(t){if("no_reset"===t)return[];if("usb_reset"===t||this.isUsbJtagSerialPort()){if(this.resetConstructors.usbJTAGSerialReset)return this.debug("using USB JTAG Serial Reset"),[this.resetConstructors.usbJTAGSerialReset(this.transport)]}else{const t=50,e=t+500;if(this.resetConstructors.classicReset)return this.debug("using Classic Serial Reset"),[this.resetConstructors.classicReset(this.transport,t),this.resetConstructors.classicReset(this.transport,e)]}return[]}async openAndSync(t,e){let i;this.securityInfoCache=null,this.info("Connecting...",!1),await this.transport.connect(this.romBaudrate,this.serialOptions),this.transport.readLoop();const s=this.constructResetSequence(t);for(let r=0;r<e;r++){const e=s.length>0?s[r%s.length]:null;if(i=await this._connectAttempt(t,e),"success"===i)break}if("success"!==i)throw new xt("Failed to connect with the device");this.debug("Connect attempt successful."),this.info("\n\r",!1)}async connect(t="default_reset",e=7,i=!0){if(await this.openAndSync(t,e),i){this.info("Detecting chip type... ");try{this.applyDetectedChip(await this.identifyChip())}catch(i){if(i instanceof Ct||i instanceof It)throw i;if(!(i instanceof xt))throw i;this.info(" Autodetection failed, trying again..."),await this.transport.disconnect(),await this.openAndSync(t,e),this.info("Detecting chip type... "),this.applyDetectedChip(await this.identifyChipByMagic())}}}async identifyChip(){try{const t=await this.getChipId(),e=this.romFromChipId(t);if(null===e)throw new Ct(t);return await this.readSecureDownloadMode(),e}catch(t){if(t instanceof Ct)throw t;if(!(t instanceof Tt||t instanceof Pt))throw t;this.debug("GET_SECURITY_INFO not supported, falling back to magic value")}return this.identifyChipByMagic()}romFromChipId(t){for(const e of ta)if(!e.USES_MAGIC_VALUE&&t===e.IMAGE_CHIP_ID)return e;return null}async readSecureDownloadMode(){const t=await this.getSecurityInfo();return this.secureDownloadMode=t.parsedFlags.SECURE_DOWNLOAD_ENABLE,this.secureDownloadMode}async identifyChipByMagic(){try{return await this.chipFromMagicValue()}catch(t){if(t instanceof Tt)return await this.readSecureDownloadMode(),Qr.esp32s2;throw t}}applyDetectedChip(t){this.chip=t,void 0!==t.SPI_ADDR_REG_MSB&&(this.SPI_ADDR_REG_MSB=t.SPI_ADDR_REG_MSB)}async chipFromMagicValue(){const t=await this.readReg(this.CHIP_DETECT_MAGIC_REG_ADDR)>>>0;this.debug("Chip Magic "+t.toString(16));const e=await async function(t){switch(t){case 15736195:{const{ESP32ROM:t}=await Promise.resolve().then((function(){return Dr}));return new t}case 203546735:case 1867591791:case 2084675695:{const{ESP32C2ROM:t}=await Promise.resolve().then((function(){return Br}));return new t}case 1763790959:case 456216687:case 1216438383:case 1130455151:{const{ESP32C3ROM:t}=await Promise.resolve().then((function(){return kr}));return new t}case 752910447:{const{ESP32C6ROM:t}=await Promise.resolve().then((function(){return Gr}));return new t}case 606167151:case 871374959:case 1333878895:{const{ESP32C61ROM:t}=await Promise.resolve().then((function(){return zr}));return new t}case 285294703:case 1675706479:case 1607549039:case 820080751:{const{ESP32C5ROM:t}=await Promise.resolve().then((function(){return Kr}));return new t}case 3619110528:case 2548236392:{const{ESP32H2ROM:t}=await Promise.resolve().then((function(){return Vr}));return new t}case 9:{const{ESP32S3ROM:t}=await Promise.resolve().then((function(){return Jr}));return new t}case 1990:{const{ESP32S2ROM:t}=await Promise.resolve().then((function(){return Xr}));return new t}case 4293968129:{const{ESP8266ROM:t}=await Promise.resolve().then((function(){return dr}));return new t}case 0:case 182303440:case 117676761:{const{ESP32P4ROM:t}=await Promise.resolve().then((function(){return qr}));return new t}default:return null}}(t);if(null===e)throw new It(t);return e}async getSecurityInfo(t=!0){if(t&&null!==this.securityInfoCache)return this.securityInfoCache;let e,i=!1;try{e=await this.checkCommand("get security info",this.ESP_GET_SECURITY_INFO,new Uint8Array(0),0,20)}catch(t){if(t instanceof Tt)throw t;e=await this.checkCommand("get security info",this.ESP_GET_SECURITY_INFO,new Uint8Array(0),0,12),i=!0}const s=this._byteArrayToInt(e[0],e[1],e[2],e[3])>>>0,r={flags:s,flashCryptCnt:e[4],keyPurposes:Array.from(e.slice(5,12)),chipId:i?null:this._byteArrayToInt(e[12],e[13],e[14],e[15])>>>0,apiVersion:i?null:this._byteArrayToInt(e[16],e[17],e[18],e[19])>>>0,parsedFlags:ia(s)};return this.securityInfoCache=r,r}async getChipId(){const t=(await this.getSecurityInfo()).chipId;if(null===t)throw new Pt;return this.debug("get_chip_id "+t.toString(16)),t}async detectChip(t="default_reset",e=7){await this.connect(t,e,!0),null!=this.chip?this.info(this.chip.CHIP_NAME):this.info("unknown chip! detectchip has failed.")}async checkCommand(t="",e=null,i=new Uint8Array(0),s=0,r=0,a=this.DEFAULT_TIMEOUT){this.debug("check_command "+t);const o=await this.command(e,i,s,void 0,a);if(o&&o[1]&&o[1].length<r+2){const e=o[1].slice(0,2);throw 0!==e[0]?new xt(`Failed to ${t} failed with status ${e}`):new xt(`Failed to ${t}.\n Only got ${o[1].length} bytes of data.`)}const n=o[1].slice(r,r+2);if(0!==n[0])throw new xt(`Failed to ${t} failed with status ${n}`);return r>0?o[1].slice(0,r):o[0]}async memBegin(t,e,i,s){if(this.IS_STUB){const e=s,i=s+t,r=this.chip.getChipRevision?await this.chip.getChipRevision(this):void 0,a=await ar(this.chip.CHIP_NAME,r);if(a){const t=[[a.bss_start||a.data_start,a.data_start+a.decodedData.length],[a.text_start,a.text_start+a.decodedText.length]];for(const[s,r]of t)if(e<r&&i>s)throw new xt(`Software loader is resident at 0x${s.toString(16).padStart(8,"0")}-0x${r.toString(16).padStart(8,"0")}.\n            Can't load binary at overlapping address range 0x${e.toString(16).padStart(8,"0")}-0x${i.toString(16).padStart(8,"0")}.\n            Either change binary loading address, or use the no-stub option to disable the software loader.`)}}this.debug("mem_begin "+t+" "+e+" "+i+" "+s.toString(16));let r=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));r=this._appendArray(r,this._intToByteArray(i)),r=this._appendArray(r,this._intToByteArray(s)),await this.checkCommand("enter RAM download mode",this.ESP_MEM_BEGIN,r)}checksum(t,e=this.ESP_CHECKSUM_MAGIC){for(let i=0;i<t.length;i++)e^=t[i];return e}async memBlock(t,e){let i=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(e));i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,t);const s=this.checksum(t);await this.checkCommand("write to target RAM",this.ESP_MEM_DATA,i,s)}async memFinish(t){const e=0===t?1:0,i=this._appendArray(this._intToByteArray(e),this._intToByteArray(t));await this.checkCommand("leave RAM download mode",this.ESP_MEM_END,i,void 0,void 0,200)}async flashSpiAttach(t){const e=this._intToByteArray(t);await this.checkCommand("configure SPI flash pins",this.ESP_SPI_ATTACH,e)}timeoutPerMb(t,e){const i=t*(e/1e6);return i<3e3?3e3:i}async flashBegin(t,e){const i=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),s=this.chip.getEraseSize(e,t),r=new Date,a=r.getTime();let o=3e3;0==this.IS_STUB&&(o=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,t)),this.debug("flash begin "+s+" "+i+" "+this.FLASH_WRITE_SIZE+" "+e+" "+t);let n=this._appendArray(this._intToByteArray(s),this._intToByteArray(i));n=this._appendArray(n,this._intToByteArray(this.FLASH_WRITE_SIZE)),n=this._appendArray(n,this._intToByteArray(e)),0==this.IS_STUB&&(n=this._appendArray(n,this._intToByteArray(0))),await this.checkCommand("enter Flash download mode",this.ESP_FLASH_BEGIN,n,void 0,void 0,o);const l=r.getTime();return 0!=t&&0==this.IS_STUB&&this.info("Took "+(l-a)/1e3+"."+(l-a)%1e3+"s to erase flash block"),i}async flashDeflBegin(t,e,i){const s=Math.floor((e+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),r=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),a=new Date,o=a.getTime();let n,l;this.IS_STUB?(n=t,l=this.DEFAULT_TIMEOUT):(n=r*this.FLASH_WRITE_SIZE,l=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,n)),this.info("Compressed "+t+" bytes to "+e+"...");let d=this._appendArray(this._intToByteArray(n),this._intToByteArray(s));d=this._appendArray(d,this._intToByteArray(this.FLASH_WRITE_SIZE)),d=this._appendArray(d,this._intToByteArray(i)),"ESP32-S2"!==this.chip.CHIP_NAME&&"ESP32-S3"!==this.chip.CHIP_NAME&&"ESP32-C3"!==this.chip.CHIP_NAME&&"ESP32-C2"!==this.chip.CHIP_NAME||!1!==this.IS_STUB||(d=this._appendArray(d,this._intToByteArray(0))),await this.checkCommand("enter compressed flash mode",this.ESP_FLASH_DEFL_BEGIN,d,void 0,void 0,l);const c=a.getTime();return 0!=t&&!1===this.IS_STUB&&this.info("Took "+(c-o)/1e3+"."+(c-o)%1e3+"s to erase flash block"),s}async flashBlock(t,e,i){let s=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(e));s=this._appendArray(s,this._intToByteArray(0)),s=this._appendArray(s,this._intToByteArray(0)),s=this._appendArray(s,t);const r=this.checksum(t);for(let t=this.WRITE_BLOCK_ATTEMPTS-1;t>=0;t--)try{return void await this.checkCommand("write to target Flash after seq "+e,this.ESP_FLASH_DATA,s,r,void 0,i)}catch(i){if(0===t)throw i;this.debug(`Block ${e} write failed (${i}), retrying with ${t} attempts left...`),await qs(this.WRITE_BLOCK_RETRY_DELAY_MS)}}async flashDeflBlock(t,e,i){let s=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(e));s=this._appendArray(s,this._intToByteArray(0)),s=this._appendArray(s,this._intToByteArray(0)),s=this._appendArray(s,t);const r=this.checksum(t);this.debug(`flash_defl_block ${Array.from(t.slice(0,2)).map((t=>t.toString(16))).join(" ")}`);for(let t=this.WRITE_BLOCK_ATTEMPTS-1;t>=0;t--)try{return void await this.checkCommand("write compressed data to flash after seq "+e,this.ESP_FLASH_DEFL_DATA,s,r,void 0,i)}catch(i){if(0===t)throw i;this.debug(`Compressed block ${e} write failed (${i}), retrying with ${t} attempts left...`),await qs(this.WRITE_BLOCK_RETRY_DELAY_MS)}}async flashFinish(t=!1,e=this.DEFAULT_TIMEOUT){const i=t?0:1,s=this._intToByteArray(i);await this.checkCommand("leave Flash mode",this.ESP_FLASH_END,s,void 0,void 0,e)}async flashDeflFinish(t=!1,e=this.DEFAULT_TIMEOUT){const i=t?0:1,s=this._intToByteArray(i);await this.checkCommand("leave compressed flash mode",this.ESP_FLASH_DEFL_END,s,void 0,void 0,e)}async runSpiflashCommand(t,e,i,s=null,r=0,a=0){const o=this.chip.SPI_REG_BASE,n=o+0,l=o+4,d=o+this.chip.SPI_USR_OFFS,c=o+this.chip.SPI_USR1_OFFS,h=o+this.chip.SPI_USR2_OFFS,_=o+this.chip.SPI_W0_OFFS;let p;p=null!=this.chip.SPI_MOSI_DLEN_OFFS?async(t,e)=>{const i=o+this.chip.SPI_MOSI_DLEN_OFFS,s=o+this.chip.SPI_MISO_DLEN_OFFS;t>0&&await this.writeReg(i,t-1),e>0&&await this.writeReg(s,e-1);let n=0;a>0&&(n|=a-1),r>0&&(n|=r-1<<f),n&&await this.writeReg(c,n)}:async(t,e)=>{const i=c;let s=(0===e?0:e-1)<<8|(0===t?0:t-1)<<17;a>0&&(s|=a-1),r>0&&(s|=r-1<<f),await this.writeReg(i,s)};const u=1<<18,f=26;if(i>32)throw new xt("Reading more than 32 bits back from a SPI flash operation is unsupported");if(e.length>64)throw new xt("Writing more than 64 bytes of data with one SPI command is unsupported");const E=8*e.length,g=await this.readReg(d),m=await this.readReg(h);let v=1<<31;i>0&&(v|=268435456),E>0&&(v|=134217728),r>0&&(v|=1073741824),a>0&&(v|=536870912),await p(E,i),await this.writeReg(d,v);let S,y=7<<28|t;if(await this.writeReg(h,y),s&&r>0&&(this.SPI_ADDR_REG_MSB&&(s<<=32-r),await this.writeReg(l,s)),0==E)await this.writeReg(_,0);else{e=Ys(e,4,0);const t=[];for(let i=0;i<e.length;i+=4)t.push((e[i]|e[i+1]<<8|e[i+2]<<16|e[i+3]<<24)>>>0);let i=_;for(const e of t)await this.writeReg(i,e),i+=4}for(await this.writeReg(n,u),S=0;S<10&&(y=await this.readReg(n)&u,0!=y);S++);if(10===S)throw new xt("SPI command did not complete in time");const b=await this.readReg(_);return await this.writeReg(d,g),await this.writeReg(h,m),b}async readFlashId(){const t=new Uint8Array(0);return await this.runSpiflashCommand(159,t,24)}async eraseFlash(){this.info("Erasing flash (this may take a while)...");let t=new Date;const e=t.getTime(),i=await this.checkCommand("erase flash",this.ESP_ERASE_FLASH,void 0,void 0,void 0,this.CHIP_ERASE_TIMEOUT);t=new Date;const s=t.getTime();return this.info("Chip erase completed successfully in "+(s-e)/1e3+"s"),i}toHex(t){return Array.prototype.map.call(t,(t=>("00"+t.toString(16)).slice(-2))).join("")}async flashMd5sum(t,e){const i=this.timeoutPerMb(this.MD5_TIMEOUT_PER_MB,e);let s=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));s=this._appendArray(s,this._intToByteArray(0)),s=this._appendArray(s,this._intToByteArray(0));const r=this.IS_STUB?16:32,a=await this.checkCommand("calculate md5sum",this.ESP_SPI_FLASH_MD5,s,void 0,r,i);return this.toHex(a)}async readFlash(t,e,i=null){let s=this._appendArray(this._intToByteArray(t),this._intToByteArray(e));s=this._appendArray(s,this._intToByteArray(4096)),s=this._appendArray(s,this._intToByteArray(1024));const r=await this.checkCommand("read flash",this.ESP_READ_FLASH,s);if(0!=r)throw new xt("Failed to read memory: "+r);let a=new Uint8Array(0);for(;a.length<e;){const t=await this.transport.read(this.FLASH_READ_TIMEOUT);if(!(t instanceof Uint8Array))throw new xt("Failed to read memory: "+t);t.length>0&&(a=this._appendArray(a,t),await this.transport.write(this._intToByteArray(a.length)),i&&i(t,a.length,e))}return a}async runStub(){if(this.syncStubDetected)return this.info("Stub is already running. No upload is necessary."),this.IS_STUB=!0,await this.applyUsbFlashWriteSize(),this.chip;if(this.secureDownloadMode)return this.info("Stub flasher is not supported in Secure Download Mode, it has been disabled."),this.chip;const t=this.chip.getChipRevision?await this.chip.getChipRevision(this):void 0,e=await ar(this.chip.CHIP_NAME,t);if(void 0===e)return this.info(`Stub flasher is not yet supported on ${this.chip.CHIP_NAME}, it has been disabled.`),this.chip;this.info("Uploading stub...");const i=[e.decodedText,e.decodedData];for(let t=0;t<i.length;t++)if(i[t]){const s=0===t?e.text_start:e.data_start,r=i[t].length,a=Math.floor((r+this.ESP_RAM_BLOCK-1)/this.ESP_RAM_BLOCK);await this.memBegin(r,a,this.ESP_RAM_BLOCK,s);for(let e=0;e<a;e++){const s=e*this.ESP_RAM_BLOCK,r=s+this.ESP_RAM_BLOCK;await this.memBlock(i[t].slice(s,r),e)}}this.info("Running stub..."),await this.memFinish(e.entry);const s=await this.transport.read(this.DEFAULT_TIMEOUT),r=String.fromCharCode(...s);if("OHAI"!==r)throw new xt(`Failed to start stub. Unexpected response ${r}`);return this.info("Stub running..."),this.IS_STUB=!0,await this.applyUsbFlashWriteSize(),this.chip}async isResponsive(t=2){for(let e=0;e<t;e++)try{return await this.readReg(this.CHIP_DETECT_MAGIC_REG_ADDR,500),!0}catch(t){this.debug(`Responsiveness probe failed: ${t}`),this.transport.flushInput()}return!1}async changeBaud(){if(this.secureDownloadMode)return void this.info("Baud rate change is not supported in secure download mode. Keeping 115200 baud.");this.info("Changing baudrate to "+this.baudrate);const t=this.IS_STUB?this.romBaudrate:0,e=this._appendArray(this._intToByteArray(this.baudrate),this._intToByteArray(t));await this.command(this.ESP_CHANGE_BAUDRATE,e),this.info("Changed"),this.info("If the chip does not respond to any further commands, consider using a lower baud rate."),await qs(50),this.securityInfoCache=null;let i,s=!1;try{s=await this.transport.changeBaudrate(this.baudrate,this.serialOptions)}catch(t){i=t,this.debug(`Host baud-rate change failed: ${t}`)}await this.transport.drainInput(),!i&&await this.isResponsive()||(i?this.info(`Unable to use ${this.baudrate} baud. Continuing at ${this.romBaudrate} baud.`):s?this.info(`The board reset while the serial port was reopened. Continuing at ${this.romBaudrate} baud.`):this.info(`The board stopped responding after changing baud rate. Continuing at ${this.romBaudrate} baud.`),await this.transport.disconnect(),await qs(50),this.baudrate=this.romBaudrate,this.IS_STUB=!1,await this.connect("default_reset",7,!1),await this.runStub())}async main(t="default_reset"){let e;if(await this.detectChip(t),this.secureDownloadMode)this.info("WARNING: Connected chip is in Secure Download Mode. Register reads (chip description, features, MAC) are not supported."),e=this.chip.CHIP_NAME,this.info("Chip is "+e);else{if(e=await this.chip.getChipDescription(this),this.chip.getChipRevision){const t=await this.chip.getChipRevision(this);this.info("Chip Revision: "+t)}this.info("Chip is "+e),this.info("Features: "+await this.chip.getChipFeatures(this)),this.info("Crystal is "+await this.chip.getCrystalFreq(this)+"MHz"),this.info("MAC: "+await this.chip.readMac(this)),await this.chip.readMac(this),void 0!==this.chip.postConnect&&await this.chip.postConnect(this)}if(await this.runStub(),this.romBaudrate!==this.baudrate&&await this.changeBaud(),!this.secureDownloadMode)try{const t=await this.readFlashId();this.info("Flash ID: "+t.toString(16)),16777215!==t&&0!==t||this.info("WARNING: Failed to communicate with the flash chip,\nread/write operations will fail.\nTry checking the chip connections or removing\nany other hardware connected to IOs.")}catch(t){throw new xt("Unable to verify flash chip connection "+t)}return e}flashSizeBytes(t){let e=-1;return this.transport.trace(`Flash size string ${t}`),-1!==t.toString().indexOf("KB")?e=1024*parseInt(t.toString().slice(0,t.toString().indexOf("KB"))):-1!==t.toString().indexOf("MB")&&(e=1024*parseInt(t.toString().slice(0,t.toString().indexOf("MB")))*1024),this.transport.trace(`Flash size in bytes ${e}`),e}parseFlashSizeArg(t){if(void 0===this.chip.FLASH_SIZES[t])throw new xt("Flash size "+t+" is not supported by this chip type. Supported sizes: "+this.chip.FLASH_SIZES);return this.chip.FLASH_SIZES[t]}async _updateImageFlashParams(t,e,i="keep",s="keep",r="keep"){if(this.debug(`_update_image_flash_params ${r} ${i} ${s}`),t.length<8)return t;if(e!=this.chip.BOOTLOADER_FLASH_OFFSET)return t;if("keep"===r&&"keep"===i&&"keep"===s)return this.info("Not changing the image"),t;const a=t[0];let o=t[2];const n=t[3];if(a!==this.ESP_IMAGE_MAGIC)return this.info("Warning: Image file at 0x"+e.toString(16)+" doesn't look like an image file, so not changing any flash settings."),t;try{(await Ur(this.chip,t)).verify()}catch(i){return this.debug(`Warning: Image file at 0x${e.toString(16)} is not a valid ${this.chip.CHIP_NAME} image, so not changing any flash settings.`),t}const l="ESP8266"!==this.chip.CHIP_NAME&&49===t[23];if("keep"!==i){o={qio:0,qout:1,dio:2,dout:3}[i]}let d=15&n;if("keep"!==s){d={"40m":0,"26m":1,"20m":2,"80m":15}[s]}let c=240&n;"keep"!==r&&(c=this.parseFlashSizeArg(r));const h=o<<8|d+c;this.info("Flash params set to "+h.toString(16));const _=new Uint8Array(t);if(t[2]!==o&&(_[2]=o),t[3]!==d+c&&(_[3]=d+c),l){const t=await Ur(this.chip,_),e=_.slice(0,t.datalength),i=_.slice(t.datalength+t.SHA256_DIGEST_LEN),s=await crypto.subtle.digest("SHA-256",i),r=new Uint8Array(s),a=new Uint8Array(e.length+r.length+i.length);a.set(e,0),a.set(r,e.length),a.set(i,e.length+r.length);const o=a.slice(t.datalength,t.datalength+t.SHA256_DIGEST_LEN);return this.transport.hexify(r)===this.transport.hexify(o)?this.info("SHA digest in image updated"):this.info(`WARNING: SHA recalculation for binary failed!\n\tExpected calculated SHA: ${this.transport.hexify(r)}\n\tSHA stored in binary:    ${this.transport.hexify(o)}`),a}return _}async writeFlash(t){this.debug("EspLoader program");for(let e=0;e<t.fileArray.length;e++)if(!(t.fileArray[e].data instanceof Uint8Array))throw new xt(`File ${e+1} data must be a Uint8Array`);let e,i,s=t.flashSize;if("detect"===t.flashSize){this.info("Configuring flash size...");const t=await this.detectFlashSize();if(!t)throw new xt("Could not auto-detect Flash size. Set flash size explicitly or check the flash connection.");this.info("Detected flash size set to "+t),s=t}if("keep"!==s){const e=this.flashSizeBytes(s);if(e<0)throw new xt(`Invalid flash size: ${s}`);for(let i=0;i<t.fileArray.length;i++)if(t.fileArray[i].data.length+t.fileArray[i].address>e)throw new xt(`File ${i+1} doesn't fit in the available flash`)}!0===this.IS_STUB&&!0===t.eraseAll&&await this.eraseFlash();for(let r=0;r<t.fileArray.length;r++){if(this.debug("Data Length "+t.fileArray[r].data.length),e=t.fileArray[r].data,this.debug("Image Length "+e.length),0===e.length){this.debug("Warning: File is empty");continue}e=Ys(e,4),i=t.fileArray[r].address,e=await this._updateImageFlashParams(e,i,t.flashMode,t.flashFreq,s);let a=null;t.calculateMD5Hash&&(a=t.calculateMD5Hash(e),this.debug("Image MD5 "+a));const o=e.length;let n;if(t.compress){e=Hs(e,{level:9}),n=await this.flashDeflBegin(o,e.length,i)}else n=await this.flashBegin(o,i);let l=0,d=0;const c=e.length;t.reportProgress&&t.reportProgress(r,0,c);let h=new Date;const _=h.getTime();let p=5e3;const u=new zs({chunkSize:1});let f=0;u.onData=function(t){f+=t.byteLength};let E=0;for(;E<e.length;){this.debug("Write loop "+i+" "+l+" "+n),this.info("Writing at 0x"+(i+(t.compress?f:d)).toString(16)+"... ("+Math.floor(100*(l+1)/n)+"%)");const s=Math.min(this.FLASH_WRITE_SIZE,e.length-E),a=e.slice(E,E+s),o=E+s>=e.length;if(t.compress){const t=f;u.push(a,o);const e=f-t;let i=3e3;this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,e)>3e3&&(i=this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,e)),!1===this.IS_STUB&&(p=i),await this.flashDeflBlock(a,l,p),this.IS_STUB&&(p=i)}else{let t=a;a.length<this.FLASH_WRITE_SIZE&&(t=new Uint8Array(this.FLASH_WRITE_SIZE).fill(255),t.set(a));let e=3e3;this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,t.length)>3e3&&(e=this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,t.length)),!1===this.IS_STUB&&(p=e),await this.flashBlock(t,l,p),this.IS_STUB&&(p=e)}d+=a.length,E+=s,l++,t.reportProgress&&t.reportProgress(r,d,c)}this.IS_STUB&&(t.compress?await this.flashDeflFinish(!1,p):await this.flashFinish(!1,p)),h=new Date;const g=h.getTime()-_;if(t.compress?this.info("Wrote "+o+" bytes ("+d+" compressed) at 0x"+i.toString(16)+" in "+g/1e3+" seconds."):this.info("Wrote "+d+" bytes at 0x"+i.toString(16)+" in "+g/1e3+" seconds."),a){this.info("File  md5: "+a);const t=await this.flashMd5sum(i,o);if(this.info("Flash md5: "+t),new String(t).valueOf()!=new String(a).valueOf())throw new xt("MD5 of file does not match data in flash!");this.info("Hash of data verified.")}}this.info("Leaving...")}async flashId(){this.debug("flash_id");const t=await this.readFlashId();this.info("Manufacturer: "+(255&t).toString(16));const e=t>>16&255;this.info("Device: "+(t>>8&255).toString(16)+e.toString(16)),this.info("Detected flash size: "+this.DETECTED_FLASH_SIZES[e])}async detectFlashSize(){this.debug("detectFlashSize");const t=await this.readFlashId()>>16&255,e=this.DETECTED_FLASH_SIZES[t];if(e)return this.info("Auto-detected Flash size: "+e),e;this.info("Could not auto-detect Flash size")}async softReset(t){if(this.IS_STUB){if("ESP8266"!=this.chip.CHIP_NAME)throw new xt("Soft resetting is currently only supported on ESP8266");t?(await this.flashBegin(0,0),await this.flashFinish(!0)):await this.command(this.ESP_RUN_USER_CODE,void 0,void 0,!1)}else{if(t)return;await this.flashBegin(0,0),await this.flashFinish(!1)}}async after(t="hard_reset",e,i){switch(t){case"hard_reset":if(this.resetConstructors.hardReset){this.info("Hard resetting via RTS pin...");const t=null!=e?e:await this.usesUsbOtg(),i=this.resetConstructors.hardReset(this.transport,t);await i.reset()}break;case"soft_reset":this.info("Soft resetting..."),await this.softReset(!1);break;case"no_reset_stub":this.info("Staying in flasher stub.");break;case"custom_reset":if(i||this.info("Custom reset sequence not provided, doing nothing."),this.resetConstructors.customReset||this.info("Custom reset constructor not available, doing nothing."),this.resetConstructors.customReset&&i){this.info("Custom resetting using sequence "+i);const t=this.resetConstructors.customReset(this.transport,i);await t.reset()}break;default:this.info("Staying in bootloader."),this.IS_STUB&&this.softReset(!0)}}}class aa extends HTMLElement{constructor(){super(...arguments),this.allowInput=!0}logs(){var t;return(null===(t=this._console)||void 0===t?void 0:t.logs())||""}connectedCallback(){if(this._console)return;this.attachShadow({mode:"open"}).innerHTML=`\n      <style>\n        :host, input {\n          background-color: #1c1c1c;\n          color: #ddd;\n          font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier,\n            monospace;\n          line-height: 1.45;\n          display: flex;\n          flex-direction: column;\n        }\n        form {\n          display: flex;\n          align-items: center;\n          padding: 0 8px 0 16px;\n        }\n        input {\n          flex: 1;\n          padding: 4px;\n          margin: 0 8px;\n          border: 0;\n          outline: none;\n        }\n        \n  .log {\n    flex: 1;\n    background-color: #1c1c1c;\n    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier,\n      monospace;\n    font-size: 12px;\n    padding: 16px;\n    overflow: auto;\n    line-height: 1.45;\n    border-radius: 3px;\n    white-space: pre-wrap;\n    overflow-wrap: break-word;\n    color: #ddd;\n  }\n\n  .log-bold {\n    font-weight: bold;\n  }\n  .log-italic {\n    font-style: italic;\n  }\n  .log-underline {\n    text-decoration: underline;\n  }\n  .log-strikethrough {\n    text-decoration: line-through;\n  }\n  .log-underline.log-strikethrough {\n    text-decoration: underline line-through;\n  }\n  .log-secret {\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n  }\n  .log-secret-redacted {\n    opacity: 0;\n    width: 1px;\n    font-size: 1px;\n  }\n  .log-fg-black {\n    color: rgb(128, 128, 128);\n  }\n  .log-fg-red {\n    color: rgb(255, 0, 0);\n  }\n  .log-fg-green {\n    color: rgb(0, 255, 0);\n  }\n  .log-fg-yellow {\n    color: rgb(255, 255, 0);\n  }\n  .log-fg-blue {\n    color: rgb(0, 0, 255);\n  }\n  .log-fg-magenta {\n    color: rgb(255, 0, 255);\n  }\n  .log-fg-cyan {\n    color: rgb(0, 255, 255);\n  }\n  .log-fg-white {\n    color: rgb(187, 187, 187);\n  }\n  .log-bg-black {\n    background-color: rgb(0, 0, 0);\n  }\n  .log-bg-red {\n    background-color: rgb(255, 0, 0);\n  }\n  .log-bg-green {\n    background-color: rgb(0, 255, 0);\n  }\n  .log-bg-yellow {\n    background-color: rgb(255, 255, 0);\n  }\n  .log-bg-blue {\n    background-color: rgb(0, 0, 255);\n  }\n  .log-bg-magenta {\n    background-color: rgb(255, 0, 255);\n  }\n  .log-bg-cyan {\n    background-color: rgb(0, 255, 255);\n  }\n  .log-bg-white {\n    background-color: rgb(255, 255, 255);\n  }\n\n        @media (max-width: 600px) {\n          form {\n            padding: 0 4px 0 8px;\n          }\n          .log {\n            font-size: 11px;\n            padding: 8px;\n            border-radius: 0;\n          }\n        }\n      </style>\n      <div class="log"></div>\n      ${this.allowInput?"<form>\n                >\n                <input autofocus>\n              </form>\n            ":""}\n    `;const t=this.shadowRoot.querySelector("div");this._console=new bt(t);let e=!0;if(t.addEventListener("scroll",(()=>{e=t.scrollTop>t.scrollHeight-t.offsetHeight-50})),new ResizeObserver((()=>{e&&(t.scrollTop=t.scrollHeight)})).observe(t),this.allowInput){const t=this.shadowRoot.querySelector("input");this.addEventListener("click",(()=>{var e;""===(null===(e=getSelection())||void 0===e?void 0:e.toString())&&t.focus()})),t.addEventListener("keydown",(t=>{"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),this._sendCommand())}))}const i=new AbortController,s=this._connect(i.signal);this._cancelConnection=()=>(i.abort(),s)}async _connect(t){this.logger.debug("Starting console read loop");try{await this.port.readable.pipeThrough(new TextDecoderStream,{signal:t}).pipeThrough(new TransformStream(new Rt)).pipeThrough(new TransformStream(new At)).pipeTo(new WritableStream({write:t=>{this._console.addLine(t.replace(/\r/g,""))}})),t.aborted||(this._console.addLine(""),this._console.addLine(""),this._console.addLine("Terminal disconnected"))}catch(t){this._console.addLine(""),this._console.addLine(""),this._console.addLine(`Terminal disconnected: ${t}`)}finally{await wt(100),this.logger.debug("Finished console read loop")}}async _sendCommand(){const t=this.shadowRoot.querySelector("input"),e=t.value,i=new TextEncoder,s=this.port.writable.getWriter();await s.write(i.encode(e+"\r\n")),this._console.addLine(`> ${e}\r\n`),t.value="",t.focus();try{s.releaseLock()}catch(t){console.error("Ignoring release lock error",t)}}async disconnect(){this._cancelConnection&&(await this._cancelConnection(),this._cancelConnection=void 0)}async reset(){this.logger.debug("Triggering reset");const t=new Zs(this.port);await t.setRTS(!0),await wt(100);const e=new Qs(t);await e.reset()}}function oa(t,e=!0){return e&&"rtl"===getComputedStyle(t).getPropertyValue("direction").trim()}customElements.define("ewt-console",aa);const na=l(w(f(E(s))));class la extends na{constructor(){super(),this.softDisabled=!1,this.flipIconInRtl=!1,this.href="",this.download="",this.target="",this.ariaLabelSelected="",this.toggle=!1,this.selected=!1,this.flipIcon=oa(this,this.flipIconInRtl),R(this,"click"),this.addEventListener("click",(t=>{if(this.softDisabled||this.disabled&&this.href)return t.stopImmediatePropagation(),void t.preventDefault();const e=this.selected;A(t,(()=>{!this.toggle||this.disabled||t.defaultPrevented||(this.selected=!e,this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})))}))}))}willUpdate(){this.href&&(this.disabled=!1,this.softDisabled=!1)}render(){const t=this.href?it`div`:it`button`,{ariaLabel:e,ariaHasPopup:i,ariaExpanded:s}=this,r=e&&this.ariaLabelSelected,a=this.toggle?this.selected:c;let o=c;return this.href||(o=r&&this.selected?this.ariaLabelSelected:e),rt`<${t}
        class="icon-button ${h(this.getRenderClasses())}"
        id="button"
        aria-label="${o||c}"
        aria-haspopup="${!this.href&&i||c}"
        aria-expanded="${!this.href&&s||c}"
        aria-pressed="${a}"
        aria-disabled=${!this.href&&this.softDisabled||c}
        ?disabled="${!this.href&&this.disabled}">
        ${this.renderFocusRing()}
        ${this.renderRipple()}
        ${this.selected?c:this.renderIcon()}
        ${this.selected?this.renderSelectedIcon():c}
        ${this.href?this.renderLink():this.renderTouchTarget()}
  </${t}>`}renderLink(){const{ariaLabel:t}=this;return r`
      <a
        class="link"
        id="link"
        href="${this.href}"
        download="${this.download||c}"
        target="${this.target||c}"
        aria-label="${t||c}">
        ${this.renderTouchTarget()}
      </a>
    `}getRenderClasses(){return{"flip-icon":this.flipIcon,selected:this.toggle&&this.selected}}renderIcon(){return r`<span class="icon"><slot></slot></span>`}renderSelectedIcon(){return r`<span class="icon icon--selected"
      ><slot name="selected"><slot></slot></slot
    ></span>`}renderTouchTarget(){return r`<span class="touch"></span>`}renderFocusRing(){return r`<md-focus-ring
      part="focus-ring"
      for=${this.href?"link":"button"}></md-focus-ring>`}renderRipple(){const t=!this.href&&(this.disabled||this.softDisabled);return r`<md-ripple
      for=${this.href?"link":c}
      ?disabled="${t}"></md-ripple>`}connectedCallback(){this.flipIcon=oa(this,this.flipIconInRtl),super.connectedCallback()}}la.shadowRootOptions={mode:"open",delegatesFocus:!0},e([o({type:Boolean,attribute:"soft-disabled",reflect:!0})],la.prototype,"softDisabled",void 0),e([o({type:Boolean,attribute:"flip-icon-in-rtl"})],la.prototype,"flipIconInRtl",void 0),e([o()],la.prototype,"href",void 0),e([o()],la.prototype,"download",void 0),e([o()],la.prototype,"target",void 0),e([o({attribute:"aria-label-selected"})],la.prototype,"ariaLabelSelected",void 0),e([o({type:Boolean})],la.prototype,"toggle",void 0),e([o({type:Boolean,reflect:!0})],la.prototype,"selected",void 0),e([g()],la.prototype,"flipIcon",void 0);const da=a`:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0);height:var(--_container-height);width:var(--_container-width);justify-content:center}:host([touch-target=wrapper]){margin:max(0px,(48px - var(--_container-height))/2) max(0px,(48px - var(--_container-width))/2)}md-focus-ring{--md-focus-ring-shape-start-start: var(--_container-shape-start-start);--md-focus-ring-shape-start-end: var(--_container-shape-start-end);--md-focus-ring-shape-end-end: var(--_container-shape-end-end);--md-focus-ring-shape-end-start: var(--_container-shape-end-start)}:host(:is([disabled],[soft-disabled])){pointer-events:none}.icon-button{place-items:center;background:none;border:none;box-sizing:border-box;cursor:pointer;display:flex;place-content:center;outline:none;padding:0;position:relative;text-decoration:none;user-select:none;z-index:0;flex:1;border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-start-radius:var(--_container-shape-end-start);border-end-end-radius:var(--_container-shape-end-end)}.icon ::slotted(*){font-size:var(--_icon-size);height:var(--_icon-size);width:var(--_icon-size);font-weight:inherit}md-ripple{z-index:-1;border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-start-radius:var(--_container-shape-end-start);border-end-end-radius:var(--_container-shape-end-end)}.flip-icon .icon{transform:scaleX(-1)}.icon{display:inline-flex}.link{display:grid;height:100%;outline:none;place-items:center;position:absolute;width:100%}.touch{position:absolute;height:max(48px,100%);width:max(48px,100%)}:host([touch-target=none]) .touch{display:none}@media(forced-colors: active){:host(:is([disabled],[soft-disabled])){--_disabled-icon-color: GrayText;--_disabled-icon-opacity: 1}}
`;da.styleSheet;const ca=a`:host{--_disabled-icon-color: var(--md-icon-button-disabled-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-icon-opacity: var(--md-icon-button-disabled-icon-opacity, 0.38);--_icon-size: var(--md-icon-button-icon-size, 24px);--_selected-focus-icon-color: var(--md-icon-button-selected-focus-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-icon-color: var(--md-icon-button-selected-hover-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-color: var(--md-icon-button-selected-hover-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-hover-state-layer-opacity: var(--md-icon-button-selected-hover-state-layer-opacity, 0.08);--_selected-icon-color: var(--md-icon-button-selected-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-icon-color: var(--md-icon-button-selected-pressed-icon-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-color: var(--md-icon-button-selected-pressed-state-layer-color, var(--md-sys-color-primary, #6750a4));--_selected-pressed-state-layer-opacity: var(--md-icon-button-selected-pressed-state-layer-opacity, 0.12);--_state-layer-height: var(--md-icon-button-state-layer-height, 40px);--_state-layer-shape: var(--md-icon-button-state-layer-shape, var(--md-sys-shape-corner-full, 9999px));--_state-layer-width: var(--md-icon-button-state-layer-width, 40px);--_focus-icon-color: var(--md-icon-button-focus-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-icon-color: var(--md-icon-button-hover-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-state-layer-color: var(--md-icon-button-hover-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-state-layer-opacity: var(--md-icon-button-hover-state-layer-opacity, 0.08);--_icon-color: var(--md-icon-button-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-icon-color: var(--md-icon-button-pressed-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-state-layer-color: var(--md-icon-button-pressed-state-layer-color, var(--md-sys-color-on-surface-variant, #49454f));--_pressed-state-layer-opacity: var(--md-icon-button-pressed-state-layer-opacity, 0.12);--_container-shape-start-start: 0;--_container-shape-start-end: 0;--_container-shape-end-end: 0;--_container-shape-end-start: 0;--_container-height: 0;--_container-width: 0;height:var(--_state-layer-height);width:var(--_state-layer-width)}:host([touch-target=wrapper]){margin:max(0px,(48px - var(--_state-layer-height))/2) max(0px,(48px - var(--_state-layer-width))/2)}md-focus-ring{--md-focus-ring-shape-start-start: var(--_state-layer-shape);--md-focus-ring-shape-start-end: var(--_state-layer-shape);--md-focus-ring-shape-end-end: var(--_state-layer-shape);--md-focus-ring-shape-end-start: var(--_state-layer-shape)}.standard{background-color:rgba(0,0,0,0);color:var(--_icon-color);--md-ripple-hover-color: var(--_hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.standard:hover{color:var(--_hover-icon-color)}.standard:focus{color:var(--_focus-icon-color)}.standard:active{color:var(--_pressed-icon-color)}.standard:is(:disabled,[aria-disabled=true]){color:var(--_disabled-icon-color)}md-ripple{border-radius:var(--_state-layer-shape)}.standard:is(:disabled,[aria-disabled=true]){opacity:var(--_disabled-icon-opacity)}.selected:not(:disabled,[aria-disabled=true]){color:var(--_selected-icon-color)}.selected:not(:disabled,[aria-disabled=true]):hover{color:var(--_selected-hover-icon-color)}.selected:not(:disabled,[aria-disabled=true]):focus{color:var(--_selected-focus-icon-color)}.selected:not(:disabled,[aria-disabled=true]):active{color:var(--_selected-pressed-icon-color)}.selected{--md-ripple-hover-color: var(--_selected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_selected-hover-state-layer-opacity);--md-ripple-pressed-color: var(--_selected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_selected-pressed-state-layer-opacity)}
`;ca.styleSheet;class ha extends la{}ha.styles=[da,ca],customElements.define("ew-icon-button",ha);const _a=a`:host{--_active-indicator-color: var(--md-filled-text-field-active-indicator-color, var(--md-sys-color-on-surface-variant, #49454f));--_active-indicator-height: var(--md-filled-text-field-active-indicator-height, 1px);--_caret-color: var(--md-filled-text-field-caret-color, var(--md-sys-color-primary, #6750a4));--_container-color: var(--md-filled-text-field-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_disabled-active-indicator-color: var(--md-filled-text-field-disabled-active-indicator-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-active-indicator-height: var(--md-filled-text-field-disabled-active-indicator-height, 1px);--_disabled-active-indicator-opacity: var(--md-filled-text-field-disabled-active-indicator-opacity, 0.38);--_disabled-container-color: var(--md-filled-text-field-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-container-opacity: var(--md-filled-text-field-disabled-container-opacity, 0.04);--_disabled-input-text-color: var(--md-filled-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-input-text-opacity: var(--md-filled-text-field-disabled-input-text-opacity, 0.38);--_disabled-label-text-color: var(--md-filled-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-filled-text-field-disabled-label-text-opacity, 0.38);--_disabled-leading-icon-color: var(--md-filled-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-icon-opacity: var(--md-filled-text-field-disabled-leading-icon-opacity, 0.38);--_disabled-supporting-text-color: var(--md-filled-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-supporting-text-opacity: var(--md-filled-text-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-icon-color: var(--md-filled-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-trailing-icon-opacity: var(--md-filled-text-field-disabled-trailing-icon-opacity, 0.38);--_error-active-indicator-color: var(--md-filled-text-field-error-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-focus-active-indicator-color: var(--md-filled-text-field-error-focus-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-focus-caret-color: var(--md-filled-text-field-error-focus-caret-color, var(--md-sys-color-error, #b3261e));--_error-focus-input-text-color: var(--md-filled-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_error-focus-label-text-color: var(--md-filled-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-icon-color: var(--md-filled-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-supporting-text-color: var(--md-filled-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-icon-color: var(--md-filled-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_error-hover-active-indicator-color: var(--md-filled-text-field-error-hover-active-indicator-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-input-text-color: var(--md-filled-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_error-hover-label-text-color: var(--md-filled-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-icon-color: var(--md-filled-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-state-layer-color: var(--md-filled-text-field-error-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_error-hover-state-layer-opacity: var(--md-filled-text-field-error-hover-state-layer-opacity, 0.08);--_error-hover-supporting-text-color: var(--md-filled-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-icon-color: var(--md-filled-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_error-input-text-color: var(--md-filled-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_error-label-text-color: var(--md-filled-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-icon-color: var(--md-filled-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-supporting-text-color: var(--md-filled-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-icon-color: var(--md-filled-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_focus-active-indicator-color: var(--md-filled-text-field-focus-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_focus-active-indicator-height: var(--md-filled-text-field-focus-active-indicator-height, 3px);--_focus-input-text-color: var(--md-filled-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_focus-label-text-color: var(--md-filled-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-icon-color: var(--md-filled-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-supporting-text-color: var(--md-filled-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-icon-color: var(--md-filled-text-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-active-indicator-color: var(--md-filled-text-field-hover-active-indicator-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-active-indicator-height: var(--md-filled-text-field-hover-active-indicator-height, 1px);--_hover-input-text-color: var(--md-filled-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-filled-text-field-hover-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-leading-icon-color: var(--md-filled-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-state-layer-color: var(--md-filled-text-field-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-filled-text-field-hover-state-layer-opacity, 0.08);--_hover-supporting-text-color: var(--md-filled-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-icon-color: var(--md-filled-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-color: var(--md-filled-text-field-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_input-text-font: var(--md-filled-text-field-input-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_input-text-line-height: var(--md-filled-text-field-input-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_input-text-placeholder-color: var(--md-filled-text-field-input-text-placeholder-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-prefix-color: var(--md-filled-text-field-input-text-prefix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-size: var(--md-filled-text-field-input-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_input-text-suffix-color: var(--md-filled-text-field-input-text-suffix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-weight: var(--md-filled-text-field-input-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_label-text-color: var(--md-filled-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-filled-text-field-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-filled-text-field-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_label-text-populated-line-height: var(--md-filled-text-field-label-text-populated-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_label-text-populated-size: var(--md-filled-text-field-label-text-populated-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_label-text-size: var(--md-filled-text-field-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_label-text-weight: var(--md-filled-text-field-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_leading-icon-color: var(--md-filled-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-icon-size: var(--md-filled-text-field-leading-icon-size, 24px);--_supporting-text-color: var(--md-filled-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-filled-text-field-supporting-text-font, var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto)));--_supporting-text-line-height: var(--md-filled-text-field-supporting-text-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_supporting-text-size: var(--md-filled-text-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_supporting-text-weight: var(--md-filled-text-field-supporting-text-weight, var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400)));--_trailing-icon-color: var(--md-filled-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-icon-size: var(--md-filled-text-field-trailing-icon-size, 24px);--_container-shape-start-start: var(--md-filled-text-field-container-shape-start-start, var(--md-filled-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-start-end: var(--md-filled-text-field-container-shape-start-end, var(--md-filled-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-end-end: var(--md-filled-text-field-container-shape-end-end, var(--md-filled-text-field-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-end-start: var(--md-filled-text-field-container-shape-end-start, var(--md-filled-text-field-container-shape, var(--md-sys-shape-corner-none, 0px)));--_icon-input-space: var(--md-filled-text-field-icon-input-space, 16px);--_leading-space: var(--md-filled-text-field-leading-space, 16px);--_trailing-space: var(--md-filled-text-field-trailing-space, 16px);--_top-space: var(--md-filled-text-field-top-space, 16px);--_bottom-space: var(--md-filled-text-field-bottom-space, 16px);--_input-text-prefix-trailing-space: var(--md-filled-text-field-input-text-prefix-trailing-space, 2px);--_input-text-suffix-leading-space: var(--md-filled-text-field-input-text-suffix-leading-space, 2px);--_with-label-top-space: var(--md-filled-text-field-with-label-top-space, 8px);--_with-label-bottom-space: var(--md-filled-text-field-with-label-bottom-space, 8px);--_focus-caret-color: var(--md-filled-text-field-focus-caret-color, var(--md-sys-color-primary, #6750a4));--_with-leading-icon-leading-space: var(--md-filled-text-field-with-leading-icon-leading-space, 12px);--_with-trailing-icon-trailing-space: var(--md-filled-text-field-with-trailing-icon-trailing-space, 12px);--md-filled-field-active-indicator-color: var(--_active-indicator-color);--md-filled-field-active-indicator-height: var(--_active-indicator-height);--md-filled-field-bottom-space: var(--_bottom-space);--md-filled-field-container-color: var(--_container-color);--md-filled-field-container-shape-end-end: var(--_container-shape-end-end);--md-filled-field-container-shape-end-start: var(--_container-shape-end-start);--md-filled-field-container-shape-start-end: var(--_container-shape-start-end);--md-filled-field-container-shape-start-start: var(--_container-shape-start-start);--md-filled-field-content-color: var(--_input-text-color);--md-filled-field-content-font: var(--_input-text-font);--md-filled-field-content-line-height: var(--_input-text-line-height);--md-filled-field-content-size: var(--_input-text-size);--md-filled-field-content-space: var(--_icon-input-space);--md-filled-field-content-weight: var(--_input-text-weight);--md-filled-field-disabled-active-indicator-color: var(--_disabled-active-indicator-color);--md-filled-field-disabled-active-indicator-height: var(--_disabled-active-indicator-height);--md-filled-field-disabled-active-indicator-opacity: var(--_disabled-active-indicator-opacity);--md-filled-field-disabled-container-color: var(--_disabled-container-color);--md-filled-field-disabled-container-opacity: var(--_disabled-container-opacity);--md-filled-field-disabled-content-color: var(--_disabled-input-text-color);--md-filled-field-disabled-content-opacity: var(--_disabled-input-text-opacity);--md-filled-field-disabled-label-text-color: var(--_disabled-label-text-color);--md-filled-field-disabled-label-text-opacity: var(--_disabled-label-text-opacity);--md-filled-field-disabled-leading-content-color: var(--_disabled-leading-icon-color);--md-filled-field-disabled-leading-content-opacity: var(--_disabled-leading-icon-opacity);--md-filled-field-disabled-supporting-text-color: var(--_disabled-supporting-text-color);--md-filled-field-disabled-supporting-text-opacity: var(--_disabled-supporting-text-opacity);--md-filled-field-disabled-trailing-content-color: var(--_disabled-trailing-icon-color);--md-filled-field-disabled-trailing-content-opacity: var(--_disabled-trailing-icon-opacity);--md-filled-field-error-active-indicator-color: var(--_error-active-indicator-color);--md-filled-field-error-content-color: var(--_error-input-text-color);--md-filled-field-error-focus-active-indicator-color: var(--_error-focus-active-indicator-color);--md-filled-field-error-focus-content-color: var(--_error-focus-input-text-color);--md-filled-field-error-focus-label-text-color: var(--_error-focus-label-text-color);--md-filled-field-error-focus-leading-content-color: var(--_error-focus-leading-icon-color);--md-filled-field-error-focus-supporting-text-color: var(--_error-focus-supporting-text-color);--md-filled-field-error-focus-trailing-content-color: var(--_error-focus-trailing-icon-color);--md-filled-field-error-hover-active-indicator-color: var(--_error-hover-active-indicator-color);--md-filled-field-error-hover-content-color: var(--_error-hover-input-text-color);--md-filled-field-error-hover-label-text-color: var(--_error-hover-label-text-color);--md-filled-field-error-hover-leading-content-color: var(--_error-hover-leading-icon-color);--md-filled-field-error-hover-state-layer-color: var(--_error-hover-state-layer-color);--md-filled-field-error-hover-state-layer-opacity: var(--_error-hover-state-layer-opacity);--md-filled-field-error-hover-supporting-text-color: var(--_error-hover-supporting-text-color);--md-filled-field-error-hover-trailing-content-color: var(--_error-hover-trailing-icon-color);--md-filled-field-error-label-text-color: var(--_error-label-text-color);--md-filled-field-error-leading-content-color: var(--_error-leading-icon-color);--md-filled-field-error-supporting-text-color: var(--_error-supporting-text-color);--md-filled-field-error-trailing-content-color: var(--_error-trailing-icon-color);--md-filled-field-focus-active-indicator-color: var(--_focus-active-indicator-color);--md-filled-field-focus-active-indicator-height: var(--_focus-active-indicator-height);--md-filled-field-focus-content-color: var(--_focus-input-text-color);--md-filled-field-focus-label-text-color: var(--_focus-label-text-color);--md-filled-field-focus-leading-content-color: var(--_focus-leading-icon-color);--md-filled-field-focus-supporting-text-color: var(--_focus-supporting-text-color);--md-filled-field-focus-trailing-content-color: var(--_focus-trailing-icon-color);--md-filled-field-hover-active-indicator-color: var(--_hover-active-indicator-color);--md-filled-field-hover-active-indicator-height: var(--_hover-active-indicator-height);--md-filled-field-hover-content-color: var(--_hover-input-text-color);--md-filled-field-hover-label-text-color: var(--_hover-label-text-color);--md-filled-field-hover-leading-content-color: var(--_hover-leading-icon-color);--md-filled-field-hover-state-layer-color: var(--_hover-state-layer-color);--md-filled-field-hover-state-layer-opacity: var(--_hover-state-layer-opacity);--md-filled-field-hover-supporting-text-color: var(--_hover-supporting-text-color);--md-filled-field-hover-trailing-content-color: var(--_hover-trailing-icon-color);--md-filled-field-label-text-color: var(--_label-text-color);--md-filled-field-label-text-font: var(--_label-text-font);--md-filled-field-label-text-line-height: var(--_label-text-line-height);--md-filled-field-label-text-populated-line-height: var(--_label-text-populated-line-height);--md-filled-field-label-text-populated-size: var(--_label-text-populated-size);--md-filled-field-label-text-size: var(--_label-text-size);--md-filled-field-label-text-weight: var(--_label-text-weight);--md-filled-field-leading-content-color: var(--_leading-icon-color);--md-filled-field-leading-space: var(--_leading-space);--md-filled-field-supporting-text-color: var(--_supporting-text-color);--md-filled-field-supporting-text-font: var(--_supporting-text-font);--md-filled-field-supporting-text-line-height: var(--_supporting-text-line-height);--md-filled-field-supporting-text-size: var(--_supporting-text-size);--md-filled-field-supporting-text-weight: var(--_supporting-text-weight);--md-filled-field-top-space: var(--_top-space);--md-filled-field-trailing-content-color: var(--_trailing-icon-color);--md-filled-field-trailing-space: var(--_trailing-space);--md-filled-field-with-label-bottom-space: var(--_with-label-bottom-space);--md-filled-field-with-label-top-space: var(--_with-label-top-space);--md-filled-field-with-leading-content-leading-space: var(--_with-leading-icon-leading-space);--md-filled-field-with-trailing-content-trailing-space: var(--_with-trailing-icon-trailing-space)}
`;_a.styleSheet;class pa extends s{constructor(){super(...arguments),this.disabled=!1,this.error=!1,this.focused=!1,this.label="",this.noAsterisk=!1,this.populated=!1,this.required=!1,this.resizable=!1,this.supportingText="",this.errorText="",this.count=-1,this.max=-1,this.hasStart=!1,this.hasEnd=!1,this.isAnimating=!1,this.refreshErrorAlert=!1,this.disableTransitions=!1}get counterText(){const t=this.count??-1,e=this.max??-1;return t<0||e<=0?"":`${t} / ${e}`}get supportingOrErrorText(){return this.error&&this.errorText?this.errorText:this.supportingText}reannounceError(){this.refreshErrorAlert=!0}update(t){t.has("disabled")&&void 0!==t.get("disabled")&&(this.disableTransitions=!0),this.disabled&&this.focused&&(t.set("focused",!0),this.focused=!1),this.animateLabelIfNeeded({wasFocused:t.get("focused"),wasPopulated:t.get("populated")}),super.update(t)}render(){var t,e,i,s;const a=this.renderLabel(!0),o=this.renderLabel(!1),n=null===(t=this.renderOutline)||void 0===t?void 0:t.call(this,a),l={disabled:this.disabled,"disable-transitions":this.disableTransitions,error:this.error&&!this.disabled,focused:this.focused,"with-start":this.hasStart,"with-end":this.hasEnd,populated:this.populated,resizable:this.resizable,required:this.required,"no-label":!this.label};return r`
      <div class="field ${h(l)}">
        <div class="container-overflow">
          ${null===(e=this.renderBackground)||void 0===e?void 0:e.call(this)}
          <slot name="container"></slot>
          ${null===(i=this.renderStateLayer)||void 0===i?void 0:i.call(this)} ${null===(s=this.renderIndicator)||void 0===s?void 0:s.call(this)} ${n}
          <div class="container">
            <div class="start">
              <slot name="start"></slot>
            </div>
            <div class="middle">
              <div class="label-wrapper">
                ${o} ${n?c:a}
              </div>
              <div class="content">
                <slot></slot>
              </div>
            </div>
            <div class="end">
              <slot name="end"></slot>
            </div>
          </div>
        </div>
        ${this.renderSupportingText()}
      </div>
    `}updated(t){(t.has("supportingText")||t.has("errorText")||t.has("count")||t.has("max"))&&this.updateSlottedAriaDescribedBy(),this.refreshErrorAlert&&requestAnimationFrame((()=>{this.refreshErrorAlert=!1})),this.disableTransitions&&requestAnimationFrame((()=>{this.disableTransitions=!1}))}renderSupportingText(){const{supportingOrErrorText:t,counterText:e}=this;if(!t&&!e)return c;const i=r`<span>${t}</span>`,s=e?r`<span class="counter">${e}</span>`:c,a=this.error&&this.errorText&&!this.refreshErrorAlert;return r`
      <div class="supporting-text" role=${a?"alert":c}>${i}${s}</div>
      <slot
        name="aria-describedby"
        @slotchange=${this.updateSlottedAriaDescribedBy}></slot>
    `}updateSlottedAriaDescribedBy(){for(const t of this.slottedAriaDescribedBy)x(r`${this.supportingOrErrorText} ${this.counterText}`,t),t.setAttribute("hidden","")}renderLabel(t){if(!this.label)return c;let e;e=t?this.focused||this.populated||this.isAnimating:!this.focused&&!this.populated&&!this.isAnimating;const i={hidden:!e,floating:t,resting:!t},s=`${this.label}${this.required&&!this.noAsterisk?"*":""}`;return r`
      <span class="label ${h(i)}" aria-hidden=${!e}
        >${s}</span
      >
    `}animateLabelIfNeeded({wasFocused:t,wasPopulated:e}){var i,s,r;if(!this.label)return;t??(t=this.focused),e??(e=this.populated);if((t||e)===(this.focused||this.populated))return;const a=this.getLabelKeyframes();a.length&&(this.isAnimating=!0,null===(i=this.labelAnimation)||void 0===i||i.cancel(),this.labelAnimation=null===(s=this.floatingLabelEl)||void 0===s?void 0:s.animate(a,{duration:150,easing:T.STANDARD}),null===(r=this.labelAnimation)||void 0===r||r.addEventListener("finish",(()=>{this.isAnimating=!1})))}getLabelKeyframes(){const{floatingLabelEl:t,restingLabelEl:e}=this;if(!t||!e)return[];const{x:i,y:s,height:r}=t.getBoundingClientRect(),{x:a,y:o,height:n}=e.getBoundingClientRect(),l=t.scrollWidth,d=e.scrollWidth;if(0===l||0===d)return[];const c=d/l,h=`translateX(${a-i}px) translateY(${o-s+Math.round((n-r*c)/2)}px) scale(${c})`,_="translateX(0) translateY(0) scale(1)",p=e.clientWidth,u=d>p?p/c+"px":"";return this.focused||this.populated?[{transform:h,width:u},{transform:_,width:u}]:[{transform:_,width:u},{transform:h,width:u}]}getSurfacePositionClientRect(){return this.containerEl.getBoundingClientRect()}}e([o({type:Boolean})],pa.prototype,"disabled",void 0),e([o({type:Boolean})],pa.prototype,"error",void 0),e([o({type:Boolean})],pa.prototype,"focused",void 0),e([o()],pa.prototype,"label",void 0),e([o({type:Boolean,attribute:"no-asterisk"})],pa.prototype,"noAsterisk",void 0),e([o({type:Boolean})],pa.prototype,"populated",void 0),e([o({type:Boolean})],pa.prototype,"required",void 0),e([o({type:Boolean})],pa.prototype,"resizable",void 0),e([o({attribute:"supporting-text"})],pa.prototype,"supportingText",void 0),e([o({attribute:"error-text"})],pa.prototype,"errorText",void 0),e([o({type:Number})],pa.prototype,"count",void 0),e([o({type:Number})],pa.prototype,"max",void 0),e([o({type:Boolean,attribute:"has-start"})],pa.prototype,"hasStart",void 0),e([o({type:Boolean,attribute:"has-end"})],pa.prototype,"hasEnd",void 0),e([i({slot:"aria-describedby"})],pa.prototype,"slottedAriaDescribedBy",void 0),e([g()],pa.prototype,"isAnimating",void 0),e([g()],pa.prototype,"refreshErrorAlert",void 0),e([g()],pa.prototype,"disableTransitions",void 0),e([d(".label.floating")],pa.prototype,"floatingLabelEl",void 0),e([d(".label.resting")],pa.prototype,"restingLabelEl",void 0),e([d(".container")],pa.prototype,"containerEl",void 0);class ua extends pa{renderBackground(){return r` <div class="background"></div> `}renderStateLayer(){return r` <div class="state-layer"></div> `}renderIndicator(){return r`<div class="active-indicator"></div>`}}const fa=a`@layer styles{:host{--_active-indicator-color: var(--md-filled-field-active-indicator-color, var(--md-sys-color-on-surface-variant, #49454f));--_active-indicator-height: var(--md-filled-field-active-indicator-height, 1px);--_bottom-space: var(--md-filled-field-bottom-space, 16px);--_container-color: var(--md-filled-field-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_content-color: var(--md-filled-field-content-color, var(--md-sys-color-on-surface, #1d1b20));--_content-font: var(--md-filled-field-content-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_content-line-height: var(--md-filled-field-content-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_content-size: var(--md-filled-field-content-size, var(--md-sys-typescale-body-large-size, 1rem));--_content-space: var(--md-filled-field-content-space, 16px);--_content-weight: var(--md-filled-field-content-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_disabled-active-indicator-color: var(--md-filled-field-disabled-active-indicator-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-active-indicator-height: var(--md-filled-field-disabled-active-indicator-height, 1px);--_disabled-active-indicator-opacity: var(--md-filled-field-disabled-active-indicator-opacity, 0.38);--_disabled-container-color: var(--md-filled-field-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-container-opacity: var(--md-filled-field-disabled-container-opacity, 0.04);--_disabled-content-color: var(--md-filled-field-disabled-content-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-content-opacity: var(--md-filled-field-disabled-content-opacity, 0.38);--_disabled-label-text-color: var(--md-filled-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-filled-field-disabled-label-text-opacity, 0.38);--_disabled-leading-content-color: var(--md-filled-field-disabled-leading-content-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-content-opacity: var(--md-filled-field-disabled-leading-content-opacity, 0.38);--_disabled-supporting-text-color: var(--md-filled-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-supporting-text-opacity: var(--md-filled-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-content-color: var(--md-filled-field-disabled-trailing-content-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-trailing-content-opacity: var(--md-filled-field-disabled-trailing-content-opacity, 0.38);--_error-active-indicator-color: var(--md-filled-field-error-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-content-color: var(--md-filled-field-error-content-color, var(--md-sys-color-on-surface, #1d1b20));--_error-focus-active-indicator-color: var(--md-filled-field-error-focus-active-indicator-color, var(--md-sys-color-error, #b3261e));--_error-focus-content-color: var(--md-filled-field-error-focus-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-label-text-color: var(--md-filled-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-content-color: var(--md-filled-field-error-focus-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-supporting-text-color: var(--md-filled-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-content-color: var(--md-filled-field-error-focus-trailing-content-color, var(--md-sys-color-error, #b3261e));--_error-hover-active-indicator-color: var(--md-filled-field-error-hover-active-indicator-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-content-color: var(--md-filled-field-error-hover-content-color, var(--md-sys-color-on-surface, #1d1b20));--_error-hover-label-text-color: var(--md-filled-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-content-color: var(--md-filled-field-error-hover-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-state-layer-color: var(--md-filled-field-error-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_error-hover-state-layer-opacity: var(--md-filled-field-error-hover-state-layer-opacity, 0.08);--_error-hover-supporting-text-color: var(--md-filled-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-content-color: var(--md-filled-field-error-hover-trailing-content-color, var(--md-sys-color-on-error-container, #410e0b));--_error-label-text-color: var(--md-filled-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-content-color: var(--md-filled-field-error-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-supporting-text-color: var(--md-filled-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-content-color: var(--md-filled-field-error-trailing-content-color, var(--md-sys-color-error, #b3261e));--_focus-active-indicator-color: var(--md-filled-field-focus-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_focus-active-indicator-height: var(--md-filled-field-focus-active-indicator-height, 3px);--_focus-content-color: var(--md-filled-field-focus-content-color, var(--md-sys-color-on-surface, #1d1b20));--_focus-label-text-color: var(--md-filled-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-content-color: var(--md-filled-field-focus-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-supporting-text-color: var(--md-filled-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-content-color: var(--md-filled-field-focus-trailing-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-active-indicator-color: var(--md-filled-field-hover-active-indicator-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-active-indicator-height: var(--md-filled-field-hover-active-indicator-height, 1px);--_hover-content-color: var(--md-filled-field-hover-content-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-filled-field-hover-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-leading-content-color: var(--md-filled-field-hover-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-state-layer-color: var(--md-filled-field-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-state-layer-opacity: var(--md-filled-field-hover-state-layer-opacity, 0.08);--_hover-supporting-text-color: var(--md-filled-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-content-color: var(--md-filled-field-hover-trailing-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-color: var(--md-filled-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-filled-field-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-filled-field-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_label-text-populated-line-height: var(--md-filled-field-label-text-populated-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_label-text-populated-size: var(--md-filled-field-label-text-populated-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_label-text-size: var(--md-filled-field-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_label-text-weight: var(--md-filled-field-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_leading-content-color: var(--md-filled-field-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-space: var(--md-filled-field-leading-space, 16px);--_supporting-text-color: var(--md-filled-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-filled-field-supporting-text-font, var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto)));--_supporting-text-leading-space: var(--md-filled-field-supporting-text-leading-space, 16px);--_supporting-text-line-height: var(--md-filled-field-supporting-text-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_supporting-text-size: var(--md-filled-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_supporting-text-top-space: var(--md-filled-field-supporting-text-top-space, 4px);--_supporting-text-trailing-space: var(--md-filled-field-supporting-text-trailing-space, 16px);--_supporting-text-weight: var(--md-filled-field-supporting-text-weight, var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400)));--_top-space: var(--md-filled-field-top-space, 16px);--_trailing-content-color: var(--md-filled-field-trailing-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-space: var(--md-filled-field-trailing-space, 16px);--_with-label-bottom-space: var(--md-filled-field-with-label-bottom-space, 8px);--_with-label-top-space: var(--md-filled-field-with-label-top-space, 8px);--_with-leading-content-leading-space: var(--md-filled-field-with-leading-content-leading-space, 12px);--_with-trailing-content-trailing-space: var(--md-filled-field-with-trailing-content-trailing-space, 12px);--_container-shape-start-start: var(--md-filled-field-container-shape-start-start, var(--md-filled-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-start-end: var(--md-filled-field-container-shape-start-end, var(--md-filled-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-end-end: var(--md-filled-field-container-shape-end-end, var(--md-filled-field-container-shape, var(--md-sys-shape-corner-none, 0px)));--_container-shape-end-start: var(--md-filled-field-container-shape-end-start, var(--md-filled-field-container-shape, var(--md-sys-shape-corner-none, 0px)))}.background,.state-layer{border-radius:inherit;inset:0;pointer-events:none;position:absolute}.background{background:var(--_container-color)}.state-layer{visibility:hidden}.field:not(.disabled):hover .state-layer{visibility:visible}.label.floating{position:absolute;top:var(--_with-label-top-space)}.field:not(.with-start) .label-wrapper{margin-inline-start:var(--_leading-space)}.field:not(.with-end) .label-wrapper{margin-inline-end:var(--_trailing-space)}.active-indicator{inset:auto 0 0 0;pointer-events:none;position:absolute;width:100%;z-index:1}.active-indicator::before,.active-indicator::after{border-bottom:var(--_active-indicator-height) solid var(--_active-indicator-color);inset:auto 0 0 0;content:"";position:absolute;width:100%}.active-indicator::after{opacity:0;transition:opacity 150ms cubic-bezier(0.2, 0, 0, 1)}.focused .active-indicator::after{opacity:1}.field:not(.with-start) .content ::slotted(*){padding-inline-start:var(--_leading-space)}.field:not(.with-end) .content ::slotted(*){padding-inline-end:var(--_trailing-space)}.field:not(.no-label) .content ::slotted(:not(textarea)){padding-bottom:var(--_with-label-bottom-space);padding-top:calc(var(--_with-label-top-space) + var(--_label-text-populated-line-height))}.field:not(.no-label) .content ::slotted(textarea){margin-bottom:var(--_with-label-bottom-space);margin-top:calc(var(--_with-label-top-space) + var(--_label-text-populated-line-height))}:hover .active-indicator::before{border-bottom-color:var(--_hover-active-indicator-color);border-bottom-width:var(--_hover-active-indicator-height)}.active-indicator::after{border-bottom-color:var(--_focus-active-indicator-color);border-bottom-width:var(--_focus-active-indicator-height)}:hover .state-layer{background:var(--_hover-state-layer-color);opacity:var(--_hover-state-layer-opacity)}.disabled .active-indicator::before{border-bottom-color:var(--_disabled-active-indicator-color);border-bottom-width:var(--_disabled-active-indicator-height);opacity:var(--_disabled-active-indicator-opacity)}.disabled .background{background:var(--_disabled-container-color);opacity:var(--_disabled-container-opacity)}.error .active-indicator::before{border-bottom-color:var(--_error-active-indicator-color)}.error:hover .active-indicator::before{border-bottom-color:var(--_error-hover-active-indicator-color)}.error:hover .state-layer{background:var(--_error-hover-state-layer-color);opacity:var(--_error-hover-state-layer-opacity)}.error .active-indicator::after{border-bottom-color:var(--_error-focus-active-indicator-color)}.resizable .container{bottom:var(--_focus-active-indicator-height);clip-path:inset(var(--_focus-active-indicator-height) 0 0 0)}.resizable .container>*{top:var(--_focus-active-indicator-height)}}@layer hcm{@media(forced-colors: active){.disabled .active-indicator::before{border-color:GrayText;opacity:1}}}
`;fa.styleSheet;const Ea=a`:host{display:inline-flex;resize:both}.field{display:flex;flex:1;flex-direction:column;writing-mode:horizontal-tb;max-width:100%}.container-overflow{border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-end-radius:var(--_container-shape-end-end);border-end-start-radius:var(--_container-shape-end-start);display:flex;height:100%;position:relative}.container{align-items:center;border-radius:inherit;display:flex;flex:1;max-height:100%;min-height:100%;min-width:min-content;position:relative}.field,.container-overflow{resize:inherit}.resizable:not(.disabled) .container{resize:inherit;overflow:hidden}.disabled{pointer-events:none}slot[name=container]{border-radius:inherit}slot[name=container]::slotted(*){border-radius:inherit;inset:0;pointer-events:none;position:absolute}@layer styles{.start,.middle,.end{display:flex;box-sizing:border-box;height:100%;position:relative}.start{color:var(--_leading-content-color)}.end{color:var(--_trailing-content-color)}.start,.end{align-items:center;justify-content:center}.with-start .start{margin-inline:var(--_with-leading-content-leading-space) var(--_content-space)}.with-end .end{margin-inline:var(--_content-space) var(--_with-trailing-content-trailing-space)}.middle{align-items:stretch;align-self:baseline;flex:1}.content{color:var(--_content-color);display:flex;flex:1;opacity:0;transition:opacity 83ms cubic-bezier(0.2, 0, 0, 1)}.no-label .content,.focused .content,.populated .content{opacity:1;transition-delay:67ms}:is(.disabled,.disable-transitions) .content{transition:none}.content ::slotted(*){all:unset;color:currentColor;font-family:var(--_content-font);font-size:var(--_content-size);line-height:var(--_content-line-height);font-weight:var(--_content-weight);width:100%;overflow-wrap:revert;white-space:revert}.content ::slotted(:not(textarea)){padding-top:var(--_top-space);padding-bottom:var(--_bottom-space)}.content ::slotted(textarea){margin-top:var(--_top-space);margin-bottom:var(--_bottom-space)}:hover .content{color:var(--_hover-content-color)}:hover .start{color:var(--_hover-leading-content-color)}:hover .end{color:var(--_hover-trailing-content-color)}.focused .content{color:var(--_focus-content-color)}.focused .start{color:var(--_focus-leading-content-color)}.focused .end{color:var(--_focus-trailing-content-color)}.disabled .content{color:var(--_disabled-content-color)}.disabled.no-label .content,.disabled.focused .content,.disabled.populated .content{opacity:var(--_disabled-content-opacity)}.disabled .start{color:var(--_disabled-leading-content-color);opacity:var(--_disabled-leading-content-opacity)}.disabled .end{color:var(--_disabled-trailing-content-color);opacity:var(--_disabled-trailing-content-opacity)}.error .content{color:var(--_error-content-color)}.error .start{color:var(--_error-leading-content-color)}.error .end{color:var(--_error-trailing-content-color)}.error:hover .content{color:var(--_error-hover-content-color)}.error:hover .start{color:var(--_error-hover-leading-content-color)}.error:hover .end{color:var(--_error-hover-trailing-content-color)}.error.focused .content{color:var(--_error-focus-content-color)}.error.focused .start{color:var(--_error-focus-leading-content-color)}.error.focused .end{color:var(--_error-focus-trailing-content-color)}}@layer hcm{@media(forced-colors: active){.disabled :is(.start,.content,.end){color:GrayText;opacity:1}}}@layer styles{.label{box-sizing:border-box;color:var(--_label-text-color);overflow:hidden;max-width:100%;text-overflow:ellipsis;white-space:nowrap;z-index:1;font-family:var(--_label-text-font);font-size:var(--_label-text-size);line-height:var(--_label-text-line-height);font-weight:var(--_label-text-weight);width:min-content}.label-wrapper{inset:0;pointer-events:none;position:absolute}.label.resting{position:absolute;top:var(--_top-space)}.label.floating{font-size:var(--_label-text-populated-size);line-height:var(--_label-text-populated-line-height);transform-origin:top left}.label.hidden{opacity:0}.no-label .label{display:none}.label-wrapper{inset:0;position:absolute;text-align:initial}:hover .label{color:var(--_hover-label-text-color)}.focused .label{color:var(--_focus-label-text-color)}.disabled .label{color:var(--_disabled-label-text-color)}.disabled .label:not(.hidden){opacity:var(--_disabled-label-text-opacity)}.error .label{color:var(--_error-label-text-color)}.error:hover .label{color:var(--_error-hover-label-text-color)}.error.focused .label{color:var(--_error-focus-label-text-color)}}@layer hcm{@media(forced-colors: active){.disabled .label:not(.hidden){color:GrayText;opacity:1}}}@layer styles{.supporting-text{color:var(--_supporting-text-color);display:flex;font-family:var(--_supporting-text-font);font-size:var(--_supporting-text-size);line-height:var(--_supporting-text-line-height);font-weight:var(--_supporting-text-weight);gap:16px;justify-content:space-between;padding-inline-start:var(--_supporting-text-leading-space);padding-inline-end:var(--_supporting-text-trailing-space);padding-top:var(--_supporting-text-top-space)}.supporting-text :nth-child(2){flex-shrink:0}:hover .supporting-text{color:var(--_hover-supporting-text-color)}.focus .supporting-text{color:var(--_focus-supporting-text-color)}.disabled .supporting-text{color:var(--_disabled-supporting-text-color);opacity:var(--_disabled-supporting-text-opacity)}.error .supporting-text{color:var(--_error-supporting-text-color)}.error:hover .supporting-text{color:var(--_error-hover-supporting-text-color)}.error.focus .supporting-text{color:var(--_error-focus-supporting-text-color)}}@layer hcm{@media(forced-colors: active){.disabled .supporting-text{color:GrayText;opacity:1}}}
`;Ea.styleSheet;let ga=class extends ua{};ga.styles=[Ea,fa],ga=e([n("md-filled-field")],ga);const ma={},va=C(class extends I{constructor(t){if(super(t),t.type!==P.PROPERTY&&t.type!==P.ATTRIBUTE&&t.type!==P.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!(t=>void 0===t.strings)(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===O||e===c)return e;const i=t.element,s=t.name;if(t.type===P.PROPERTY){if(e===i[s])return O}else if(t.type===P.BOOLEAN_ATTRIBUTE){if(!!e===i.hasAttribute(s))return O}else if(t.type===P.ATTRIBUTE&&i.getAttribute(s)===e+"")return O;return((t,e=ma)=>{t._$AH=e})(t),e}}),Sa="important",ya=" !"+Sa,ba=C(class extends I{constructor(t){var e;if(super(t),t.type!==P.ATTRIBUTE||"style"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,i)=>{const s=t[i];return null==s?e:e+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(t,[e]){const{style:i}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const s=e[t];if(null!=s){this.ft.add(t);const e="string"==typeof s&&s.endsWith(ya);t.includes("-")||e?i.setProperty(t,e?s.slice(0,-11):s,e?Sa:""):i[t]=s}}return O}}),wa={fromAttribute:t=>t??"",toAttribute:t=>t||null},Ra=Symbol("onReportValidity"),Aa=Symbol("privateCleanupFormListeners"),xa=Symbol("privateDoNotReportInvalid"),Ta=Symbol("privateIsSelfReportingValidity"),Ca=Symbol("privateCallOnReportValidity");function Ia(t){var e,i,s;class r extends t{constructor(...t){super(...t),this[e]=new AbortController,this[i]=!1,this[s]=!1,this.addEventListener("invalid",(t=>{!this[xa]&&t.isTrusted&&this.addEventListener("invalid",(()=>{this[Ca](t)}),{once:!0})}),{capture:!0})}checkValidity(){this[xa]=!0;const t=super.checkValidity();return this[xa]=!1,t}reportValidity(){this[Ta]=!0;const t=super.reportValidity();return t&&this[Ca](null),this[Ta]=!1,t}[(e=Aa,i=xa,s=Ta,Ca)](t){const e=null==t?void 0:t.defaultPrevented;if(e)return;this[Ra](t);!e&&(null==t?void 0:t.defaultPrevented)&&(this[Ta]||function(t,e){if(!t)return!0;let i;for(const e of t.elements)if(e.matches(":invalid")){i=e;break}return i===e}(this[u].form,this))&&this.focus()}[Ra](t){throw new Error("Implement [onReportValidity]")}formAssociatedCallback(t){super.formAssociatedCallback&&super.formAssociatedCallback(t),this[Aa].abort(),t&&(this[Aa]=new AbortController,function(t,e,i,s){const r=function(t){if(!Pa.has(t)){const e=new EventTarget;Pa.set(t,e);for(const i of["reportValidity","requestSubmit"]){const s=t[i];t[i]=function(){e.dispatchEvent(new Event("before"));const t=Reflect.apply(s,this,arguments);return e.dispatchEvent(new Event("after")),t}}}return Pa.get(t)}(e);let a,o=!1,n=!1;r.addEventListener("before",(()=>{n=!0,a=new AbortController,o=!1,t.addEventListener("invalid",(()=>{o=!0}),{signal:a.signal})}),{signal:s}),r.addEventListener("after",(()=>{var t;n=!1,null===(t=a)||void 0===t||t.abort(),o||i()}),{signal:s}),e.addEventListener("submit",(()=>{n||i()}),{signal:s})}(this,t,(()=>{this[Ca](null)}),this[Aa].signal))}}return r}const Pa=new WeakMap;class Oa extends Et{computeValidity({state:t,renderedControl:e}){let i=e;Ua(t)&&!i?(i=this.inputControl||document.createElement("input"),this.inputControl=i):i||(i=this.textAreaControl||document.createElement("textarea"),this.textAreaControl=i);const s=Ua(t)?i:null;if(s&&(s.type=t.type),i.value!==t.value&&(i.value=t.value),i.required=t.required,s){const e=t;e.pattern?s.pattern=e.pattern:s.removeAttribute("pattern"),e.min?s.min=e.min:s.removeAttribute("min"),e.max?s.max=e.max:s.removeAttribute("max"),e.step?s.step=e.step:s.removeAttribute("step")}return(t.minLength??-1)>-1?i.setAttribute("minlength",String(t.minLength)):i.removeAttribute("minlength"),(t.maxLength??-1)>-1?i.setAttribute("maxlength",String(t.maxLength)):i.removeAttribute("maxlength"),{validity:i.validity,validationMessage:i.validationMessage}}equals({state:t},{state:e}){const i=t.type===e.type&&t.value===e.value&&t.required===e.required&&t.minLength===e.minLength&&t.maxLength===e.maxLength;return Ua(t)&&Ua(e)?i&&t.pattern===e.pattern&&t.min===e.min&&t.max===e.max&&t.step===e.step:i}copy({state:t}){return{state:Ua(t)?this.copyInput(t):this.copyTextArea(t),renderedControl:null}}copyInput(t){const{type:e,pattern:i,min:s,max:r,step:a}=t;return{...this.copySharedState(t),type:e,pattern:i,min:s,max:r,step:a}}copyTextArea(t){return{...this.copySharedState(t),type:t.type}}copySharedState({value:t,required:e,minLength:i,maxLength:s}){return{value:t,required:e,minLength:i,maxLength:s}}}function Ua(t){return"textarea"!==t.type}const Fa=l(Ia(ft(f(E(s)))));class Da extends Fa{constructor(){super(...arguments),this.error=!1,this.errorText="",this.label="",this.noAsterisk=!1,this.required=!1,this.value="",this.prefixText="",this.suffixText="",this.hasLeadingIcon=!1,this.hasTrailingIcon=!1,this.supportingText="",this.textDirection="",this.rows=2,this.cols=20,this.inputMode="",this.max="",this.maxLength=-1,this.min="",this.minLength=-1,this.noSpinner=!1,this.pattern="",this.placeholder="",this.readOnly=!1,this.multiple=!1,this.step="",this.type="text",this.autocomplete="",this.dirty=!1,this.focused=!1,this.nativeError=!1,this.nativeErrorText=""}get selectionDirection(){return this.getInputOrTextarea().selectionDirection}set selectionDirection(t){this.getInputOrTextarea().selectionDirection=t}get selectionEnd(){return this.getInputOrTextarea().selectionEnd}set selectionEnd(t){this.getInputOrTextarea().selectionEnd=t}get selectionStart(){return this.getInputOrTextarea().selectionStart}set selectionStart(t){this.getInputOrTextarea().selectionStart=t}get valueAsNumber(){const t=this.getInput();return t?t.valueAsNumber:NaN}set valueAsNumber(t){const e=this.getInput();e&&(e.valueAsNumber=t,this.value=e.value)}get valueAsDate(){const t=this.getInput();return t?t.valueAsDate:null}set valueAsDate(t){const e=this.getInput();e&&(e.valueAsDate=t,this.value=e.value)}get hasError(){return this.error||this.nativeError}select(){this.getInputOrTextarea().select()}setRangeText(...t){this.getInputOrTextarea().setRangeText(...t),this.value=this.getInputOrTextarea().value}setSelectionRange(t,e,i){this.getInputOrTextarea().setSelectionRange(t,e,i)}showPicker(){const t=this.getInput();t&&t.showPicker()}stepDown(t){const e=this.getInput();e&&(e.stepDown(t),this.value=e.value)}stepUp(t){const e=this.getInput();e&&(e.stepUp(t),this.value=e.value)}reset(){this.dirty=!1,this.value=this.getAttribute("value")??"",this.nativeError=!1,this.nativeErrorText=""}attributeChangedCallback(t,e,i){"value"===t&&this.dirty||super.attributeChangedCallback(t,e,i)}render(){const t={disabled:this.disabled,error:!this.disabled&&this.hasError,textarea:"textarea"===this.type,"no-spinner":this.noSpinner};return r`
      <span class="text-field ${h(t)}">
        ${this.renderField()}
      </span>
    `}updated(t){const e=this.getInputOrTextarea().value;this.value!==e&&(this.value=e)}renderField(){return rt`<${this.fieldTag}
      class="field"
      count=${this.value.length}
      ?disabled=${this.disabled}
      ?error=${this.hasError}
      error-text=${this.getErrorText()}
      ?focused=${this.focused}
      ?has-end=${this.hasTrailingIcon}
      ?has-start=${this.hasLeadingIcon}
      label=${this.label}
      ?no-asterisk=${this.noAsterisk}
      max=${this.maxLength}
      ?populated=${!!this.value}
      ?required=${this.required}
      ?resizable=${"textarea"===this.type}
      supporting-text=${this.supportingText}
    >
      ${this.renderLeadingIcon()}
      ${this.renderInputOrTextarea()}
      ${this.renderTrailingIcon()}
      <div id="description" slot="aria-describedby"></div>
      <slot name="container" slot="container"></slot>
    </${this.fieldTag}>`}renderLeadingIcon(){return r`
      <span class="icon leading" slot="start">
        <slot name="leading-icon" @slotchange=${this.handleIconChange}></slot>
      </span>
    `}renderTrailingIcon(){return r`
      <span class="icon trailing" slot="end">
        <slot name="trailing-icon" @slotchange=${this.handleIconChange}></slot>
      </span>
    `}renderInputOrTextarea(){const t={direction:this.textDirection},e=this.ariaLabel||this.label||c,i=this.autocomplete,s=(this.maxLength??-1)>-1,a=(this.minLength??-1)>-1;if("textarea"===this.type)return r`
        <textarea
          class="input"
          style=${ba(t)}
          aria-describedby="description"
          aria-invalid=${this.hasError}
          aria-label=${e}
          autocomplete=${i||c}
          name=${this.name||c}
          ?disabled=${this.disabled}
          maxlength=${s?this.maxLength:c}
          minlength=${a?this.minLength:c}
          placeholder=${this.placeholder||c}
          ?readonly=${this.readOnly}
          ?required=${this.required}
          rows=${this.rows}
          cols=${this.cols}
          .value=${va(this.value)}
          @change=${this.redispatchEvent}
          @focus=${this.handleFocusChange}
          @blur=${this.handleFocusChange}
          @input=${this.handleInput}
          @select=${this.redispatchEvent}></textarea>
      `;const o=this.renderPrefix(),n=this.renderSuffix(),l=this.inputMode;return r`
      <div class="input-wrapper">
        ${o}
        <input
          class="input"
          style=${ba(t)}
          aria-describedby="description"
          aria-invalid=${this.hasError}
          aria-label=${e}
          autocomplete=${i||c}
          name=${this.name||c}
          ?disabled=${this.disabled}
          inputmode=${l||c}
          max=${this.max||c}
          maxlength=${s?this.maxLength:c}
          min=${this.min||c}
          minlength=${a?this.minLength:c}
          pattern=${this.pattern||c}
          placeholder=${this.placeholder||c}
          ?readonly=${this.readOnly}
          ?required=${this.required}
          ?multiple=${this.multiple}
          step=${this.step||c}
          type=${this.type}
          .value=${va(this.value)}
          @change=${this.redispatchEvent}
          @focus=${this.handleFocusChange}
          @blur=${this.handleFocusChange}
          @input=${this.handleInput}
          @select=${this.redispatchEvent} />
        ${n}
      </div>
    `}renderPrefix(){return this.renderAffix(this.prefixText,!1)}renderSuffix(){return this.renderAffix(this.suffixText,!0)}renderAffix(t,e){if(!t)return c;return r`<span class="${h({suffix:e,prefix:!e})}">${t}</span>`}getErrorText(){return this.error?this.errorText:this.nativeErrorText}handleFocusChange(){var t;this.focused=(null===(t=this.inputOrTextarea)||void 0===t?void 0:t.matches(":focus"))??!1}handleInput(t){this.dirty=!0,this.value=t.target.value}redispatchEvent(t){S(this,t)}getInputOrTextarea(){return this.inputOrTextarea||(this.connectedCallback(),this.scheduleUpdate()),this.isUpdatePending&&this.scheduleUpdate(),this.inputOrTextarea}getInput(){return"textarea"===this.type?null:this.getInputOrTextarea()}handleIconChange(){this.hasLeadingIcon=this.leadingIcons.length>0,this.hasTrailingIcon=this.trailingIcons.length>0}[y](){return this.value}formResetCallback(){this.reset()}formStateRestoreCallback(t){this.value=t}focus(){this.getInputOrTextarea().focus()}[ct](){return new Oa((()=>({state:this,renderedControl:this.inputOrTextarea})))}[ht](){return this.inputOrTextarea}[Ra](t){null==t||t.preventDefault();const e=this.getErrorText();var i;(this.nativeError=!!t,this.nativeErrorText=this.validationMessage,e===this.getErrorText())&&(null===(i=this.field)||void 0===i||i.reannounceError())}}Da.shadowRootOptions={...s.shadowRootOptions,delegatesFocus:!0},e([o({type:Boolean,reflect:!0})],Da.prototype,"error",void 0),e([o({attribute:"error-text"})],Da.prototype,"errorText",void 0),e([o()],Da.prototype,"label",void 0),e([o({type:Boolean,attribute:"no-asterisk"})],Da.prototype,"noAsterisk",void 0),e([o({type:Boolean,reflect:!0})],Da.prototype,"required",void 0),e([o()],Da.prototype,"value",void 0),e([o({attribute:"prefix-text"})],Da.prototype,"prefixText",void 0),e([o({attribute:"suffix-text"})],Da.prototype,"suffixText",void 0),e([o({type:Boolean,attribute:"has-leading-icon"})],Da.prototype,"hasLeadingIcon",void 0),e([o({type:Boolean,attribute:"has-trailing-icon"})],Da.prototype,"hasTrailingIcon",void 0),e([o({attribute:"supporting-text"})],Da.prototype,"supportingText",void 0),e([o({attribute:"text-direction"})],Da.prototype,"textDirection",void 0),e([o({type:Number})],Da.prototype,"rows",void 0),e([o({type:Number})],Da.prototype,"cols",void 0),e([o({reflect:!0})],Da.prototype,"inputMode",void 0),e([o()],Da.prototype,"max",void 0),e([o({type:Number})],Da.prototype,"maxLength",void 0),e([o()],Da.prototype,"min",void 0),e([o({type:Number})],Da.prototype,"minLength",void 0),e([o({type:Boolean,attribute:"no-spinner"})],Da.prototype,"noSpinner",void 0),e([o()],Da.prototype,"pattern",void 0),e([o({reflect:!0,converter:wa})],Da.prototype,"placeholder",void 0),e([o({type:Boolean,reflect:!0})],Da.prototype,"readOnly",void 0),e([o({type:Boolean,reflect:!0})],Da.prototype,"multiple",void 0),e([o()],Da.prototype,"step",void 0),e([o({reflect:!0})],Da.prototype,"type",void 0),e([o({reflect:!0})],Da.prototype,"autocomplete",void 0),e([g()],Da.prototype,"dirty",void 0),e([g()],Da.prototype,"focused",void 0),e([g()],Da.prototype,"nativeError",void 0),e([g()],Da.prototype,"nativeErrorText",void 0),e([d(".input")],Da.prototype,"inputOrTextarea",void 0),e([d(".field")],Da.prototype,"field",void 0),e([i({slot:"leading-icon"})],Da.prototype,"leadingIcons",void 0),e([i({slot:"trailing-icon"})],Da.prototype,"trailingIcons",void 0);class Ma extends Da{constructor(){super(...arguments),this.fieldTag=it`md-filled-field`}}const ka=a`:host{display:inline-flex;outline:none;resize:both;text-align:start;-webkit-tap-highlight-color:rgba(0,0,0,0)}.text-field,.field{width:100%}.text-field{display:inline-flex}.field{cursor:text}.disabled .field{cursor:default}.text-field,.textarea .field{resize:inherit}slot[name=container]{border-radius:inherit}.icon{color:currentColor;display:flex;align-items:center;justify-content:center;fill:currentColor;position:relative}.icon ::slotted(*){display:flex;position:absolute}[has-start] .icon.leading{font-size:var(--_leading-icon-size);height:var(--_leading-icon-size);width:var(--_leading-icon-size)}[has-end] .icon.trailing{font-size:var(--_trailing-icon-size);height:var(--_trailing-icon-size);width:var(--_trailing-icon-size)}.input-wrapper{display:flex}.input-wrapper>*{all:inherit;padding:0}.input{caret-color:var(--_caret-color);overflow-x:hidden;text-align:inherit}.input::placeholder{color:currentColor;opacity:1}.input::-webkit-calendar-picker-indicator{display:none}.input::-webkit-search-decoration,.input::-webkit-search-cancel-button{display:none}@media(forced-colors: active){.input{background:none}}.no-spinner .input::-webkit-inner-spin-button,.no-spinner .input::-webkit-outer-spin-button{display:none}.no-spinner .input[type=number]{-moz-appearance:textfield}:focus-within .input{caret-color:var(--_focus-caret-color)}.error:focus-within .input{caret-color:var(--_error-focus-caret-color)}.text-field:not(.disabled) .prefix{color:var(--_input-text-prefix-color)}.text-field:not(.disabled) .suffix{color:var(--_input-text-suffix-color)}.text-field:not(.disabled) .input::placeholder{color:var(--_input-text-placeholder-color)}.prefix,.suffix{text-wrap:nowrap;width:min-content}.prefix{padding-inline-end:var(--_input-text-prefix-trailing-space)}.suffix{padding-inline-start:var(--_input-text-suffix-leading-space)}
`;ka.styleSheet;class La extends Ma{constructor(){super(...arguments),this.fieldTag=it`md-filled-field`}}La.styles=[ka,_a],customElements.define("ew-filled-text-field",La);class Ba extends s{connectedCallback(){super.connectedCallback(),this.setAttribute("aria-hidden","true")}render(){return r`<span class="shadow"></span>`}}const Na=a`:host,.shadow,.shadow::before,.shadow::after{border-radius:inherit;inset:0;position:absolute;transition-duration:inherit;transition-property:inherit;transition-timing-function:inherit}:host{display:flex;pointer-events:none;transition-property:box-shadow,opacity}.shadow::before,.shadow::after{content:"";transition-property:box-shadow,opacity;--_level: var(--md-elevation-level, 0);--_shadow-color: var(--md-elevation-shadow-color, var(--md-sys-color-shadow, #000))}.shadow::before{box-shadow:0px calc(1px*(clamp(0,var(--_level),1) + clamp(0,var(--_level) - 3,1) + 2*clamp(0,var(--_level) - 4,1))) calc(1px*(2*clamp(0,var(--_level),1) + clamp(0,var(--_level) - 2,1) + clamp(0,var(--_level) - 4,1))) 0px var(--_shadow-color);opacity:.3}.shadow::after{box-shadow:0px calc(1px*(clamp(0,var(--_level),1) + clamp(0,var(--_level) - 1,1) + 2*clamp(0,var(--_level) - 2,3))) calc(1px*(3*clamp(0,var(--_level),2) + 2*clamp(0,var(--_level) - 2,3))) calc(1px*(clamp(0,var(--_level),4) + 2*clamp(0,var(--_level) - 4,1))) var(--_shadow-color);opacity:.15}
`;Na.styleSheet;let Ga=class extends Ba{};Ga.styles=[Na],Ga=e([n("md-elevation")],Ga);const $a=function(t,e){return new CustomEvent("close-menu",{bubbles:!0,composed:!0,detail:{initiator:t,reason:e,itemPath:[t]}})},Ka={SPACE:"Space",ENTER:"Enter"},Ha="click-selection",za="keydown",Ya={ESCAPE:"Escape",SPACE:Ka.SPACE,ENTER:Ka.ENTER};function Va(t){return Object.values(Ya).some((e=>e===t))}function Wa(t,e){const i=new Event("md-contains",{bubbles:!0,composed:!0});let s=[];const r=t=>{s=t.composedPath()};e.addEventListener("md-contains",r),t.dispatchEvent(i),e.removeEventListener("md-contains",r);return s.length>0}const qa="none",Za="list-root",Xa="first-item",ja="last-item",Ja="end-start",Qa="start-start";class to{constructor(t,e){this.host=t,this.getProperties=e,this.surfaceStylesInternal={display:"none"},this.lastValues={isOpen:!1},this.host.addController(this)}get surfaceStyles(){return this.surfaceStylesInternal}async position(){const{surfaceEl:t,anchorEl:e,anchorCorner:i,surfaceCorner:s,positioning:r,xOffset:a,yOffset:o,disableBlockFlip:n,disableInlineFlip:l,repositionStrategy:d}=this.getProperties(),c=i.toLowerCase().trim(),h=s.toLowerCase().trim();if(!t||!e)return;const _=window.innerWidth,p=window.innerHeight,u=document.createElement("div");u.style.opacity="0",u.style.position="fixed",u.style.display="block",u.style.inset="0",document.body.appendChild(u);const f=u.getBoundingClientRect();u.remove();const E=window.innerHeight-f.bottom,g=window.innerWidth-f.right;this.surfaceStylesInternal={display:"block",opacity:"0"},this.host.requestUpdate(),await this.host.updateComplete,t.popover&&t.isConnected&&t.showPopover();const m=t.getSurfacePositionClientRect?t.getSurfacePositionClientRect():t.getBoundingClientRect(),v=e.getSurfacePositionClientRect?e.getSurfacePositionClientRect():e.getBoundingClientRect(),[S,y]=h.split("-"),[b,w]=c.split("-"),R="ltr"===getComputedStyle(t).direction;let{blockInset:A,blockOutOfBoundsCorrection:x,surfaceBlockProperty:T}=this.calculateBlock({surfaceRect:m,anchorRect:v,anchorBlock:b,surfaceBlock:S,yOffset:o,positioning:r,windowInnerHeight:p,blockScrollbarHeight:E});if(x&&!n){const t="start"===S?"end":"start",e="start"===b?"end":"start",i=this.calculateBlock({surfaceRect:m,anchorRect:v,anchorBlock:e,surfaceBlock:t,yOffset:o,positioning:r,windowInnerHeight:p,blockScrollbarHeight:E});x>i.blockOutOfBoundsCorrection&&(A=i.blockInset,x=i.blockOutOfBoundsCorrection,T=i.surfaceBlockProperty)}let{inlineInset:C,inlineOutOfBoundsCorrection:I,surfaceInlineProperty:P}=this.calculateInline({surfaceRect:m,anchorRect:v,anchorInline:w,surfaceInline:y,xOffset:a,positioning:r,isLTR:R,windowInnerWidth:_,inlineScrollbarWidth:g});if(I&&!l){const t="start"===y?"end":"start",e="start"===w?"end":"start",i=this.calculateInline({surfaceRect:m,anchorRect:v,anchorInline:e,surfaceInline:t,xOffset:a,positioning:r,isLTR:R,windowInnerWidth:_,inlineScrollbarWidth:g});Math.abs(I)>Math.abs(i.inlineOutOfBoundsCorrection)&&(C=i.inlineInset,I=i.inlineOutOfBoundsCorrection,P=i.surfaceInlineProperty)}"move"===d&&(A-=x,C-=I),this.surfaceStylesInternal={display:"block",opacity:"1",[T]:`${A}px`,[P]:`${C}px`},"resize"===d&&(x&&(this.surfaceStylesInternal.height=m.height-x+"px"),I&&(this.surfaceStylesInternal.width=m.width-I+"px")),this.host.requestUpdate()}calculateBlock(t){const{surfaceRect:e,anchorRect:i,anchorBlock:s,surfaceBlock:r,yOffset:a,positioning:o,windowInnerHeight:n,blockScrollbarHeight:l}=t,d="fixed"===o||"document"===o?1:0,c="document"===o?1:0,h="start"===r?1:0,_="end"===r?1:0,p=(s!==r?1:0)*i.height+a,u=h*i.top+_*(n-i.bottom-l);return{blockInset:d*u+c*(h*window.scrollY-_*window.scrollY)+p,blockOutOfBoundsCorrection:Math.abs(Math.min(0,n-u-p-e.height)),surfaceBlockProperty:"start"===r?"inset-block-start":"inset-block-end"}}calculateInline(t){const{isLTR:e,surfaceInline:i,anchorInline:s,anchorRect:r,surfaceRect:a,xOffset:o,positioning:n,windowInnerWidth:l,inlineScrollbarWidth:d}=t,c="fixed"===n||"document"===n?1:0,h="document"===n?1:0,_=e?1:0,p=e?0:1,u="start"===i?1:0,f="end"===i?1:0,E=(s!==i?1:0)*r.width+o,g=_*(u*r.left+f*(l-r.right-d))+p*(u*(l-r.right-d)+f*r.left);let m="start"===i?"inset-inline-start":"inset-inline-end";return"document"!==n&&"fixed"!==n||(m="start"===i&&e||"end"===i&&!e?"left":"right"),{inlineInset:c*g+E+h*(_*(u*window.scrollX-f*window.scrollX)+p*(f*window.scrollX-u*window.scrollX)),inlineOutOfBoundsCorrection:Math.abs(Math.min(0,l-g-E-a.width)),surfaceInlineProperty:m}}hostUpdate(){this.onUpdate()}hostUpdated(){this.onUpdate()}async onUpdate(){const t=this.getProperties();let e=!1;for(const[i,s]of Object.entries(t))if(e=e||s!==this.lastValues[i],e)break;const i=this.lastValues.isOpen!==t.isOpen,s=!!t.anchorEl,r=!!t.surfaceEl;e&&s&&r&&(this.lastValues.isOpen=t.isOpen,t.isOpen?(this.lastValues=t,await this.position(),t.onOpen()):i&&(await t.beforeClose(),this.close(),t.onClose()))}close(){this.surfaceStylesInternal={display:"none"},this.host.requestUpdate();const t=this.getProperties().surfaceEl;null!=t&&t.popover&&null!=t&&t.isConnected&&t.hidePopover()}}const eo=0,io=1,so=2;class ro{constructor(t){this.getProperties=t,this.typeaheadRecords=[],this.typaheadBuffer="",this.cancelTypeaheadTimeout=0,this.isTypingAhead=!1,this.lastActiveRecord=null,this.onKeydown=t=>{this.isTypingAhead?this.typeahead(t):this.beginTypeahead(t)},this.endTypeahead=()=>{this.isTypingAhead=!1,this.typaheadBuffer="",this.typeaheadRecords=[]}}get items(){return this.getProperties().getItems()}get active(){return this.getProperties().active}beginTypeahead(t){this.active&&("Space"===t.code||"Enter"===t.code||t.code.startsWith("Arrow")||"Escape"===t.code||(this.isTypingAhead=!0,this.typeaheadRecords=this.items.map(((t,e)=>[e,t,t.typeaheadText.trim().toLowerCase()])),this.lastActiveRecord=this.typeaheadRecords.find((t=>0===t[io].tabIndex))??null,this.lastActiveRecord&&(this.lastActiveRecord[io].tabIndex=-1),this.typeahead(t)))}typeahead(t){if(t.defaultPrevented)return;if(clearTimeout(this.cancelTypeaheadTimeout),"Enter"===t.code||t.code.startsWith("Arrow")||"Escape"===t.code)return this.endTypeahead(),void(this.lastActiveRecord&&(this.lastActiveRecord[io].tabIndex=-1));"Space"===t.code&&t.preventDefault(),this.cancelTypeaheadTimeout=setTimeout(this.endTypeahead,this.getProperties().typeaheadBufferTime),this.typaheadBuffer+=t.key.toLowerCase();const e=this.lastActiveRecord?this.lastActiveRecord[eo]:-1,i=this.typeaheadRecords.length,s=t=>(t[eo]+i-e)%i,r=this.typeaheadRecords.filter((t=>!t[io].disabled&&t[so].startsWith(this.typaheadBuffer))).sort(((t,e)=>s(t)-s(e)));if(0===r.length)return clearTimeout(this.cancelTypeaheadTimeout),this.lastActiveRecord&&(this.lastActiveRecord[io].tabIndex=-1),void this.endTypeahead();const a=1===this.typaheadBuffer.length;let o;o=this.lastActiveRecord===r[0]&&a?r[1]??r[0]:r[0],this.lastActiveRecord&&(this.lastActiveRecord[io].tabIndex=-1),this.lastActiveRecord=o,o[io].tabIndex=0,o[io].focus()}}const ao=new Set([z.ArrowDown,z.ArrowUp,z.Home,z.End]),oo=new Set([z.ArrowLeft,z.ArrowRight,...ao]);class no extends s{get openDirection(){return"start"===this.menuCorner.split("-")[0]?"DOWN":"UP"}get anchorElement(){return this.anchor?this.getRootNode().querySelector(`#${this.anchor}`):this.currentAnchorElement}set anchorElement(t){this.currentAnchorElement=t,this.requestUpdate("anchorElement")}constructor(){super(),this.anchor="",this.positioning="absolute",this.quick=!1,this.hasOverflow=!1,this.open=!1,this.xOffset=0,this.yOffset=0,this.noHorizontalFlip=!1,this.noVerticalFlip=!1,this.typeaheadDelay=200,this.anchorCorner=Ja,this.menuCorner=Qa,this.stayOpenOnOutsideClick=!1,this.stayOpenOnFocusout=!1,this.skipRestoreFocus=!1,this.defaultFocus=Xa,this.noNavigationWrap=!1,this.typeaheadActive=!0,this.isSubmenu=!1,this.pointerPath=[],this.isRepositioning=!1,this.openCloseAnimationSignal=U(),this.listController=new Y({isItem:t=>t.hasAttribute("md-menu-item"),getPossibleItems:()=>this.slotItems,isRtl:()=>"rtl"===getComputedStyle(this).direction,deactivateItem:t=>{t.selected=!1,t.tabIndex=-1},activateItem:t=>{t.selected=!0,t.tabIndex=0},isNavigableKey:t=>{if(!this.isSubmenu)return oo.has(t);return t===("rtl"===getComputedStyle(this).direction?z.ArrowLeft:z.ArrowRight)||ao.has(t)},wrapNavigation:()=>!this.noNavigationWrap}),this.lastFocusedElement=null,this.typeaheadController=new ro((()=>({getItems:()=>this.items,typeaheadBufferTime:this.typeaheadDelay,active:this.typeaheadActive}))),this.currentAnchorElement=null,this.internals=this.attachInternals(),this.menuPositionController=new to(this,(()=>({anchorCorner:this.anchorCorner,surfaceCorner:this.menuCorner,surfaceEl:this.surfaceEl,anchorEl:this.anchorElement,positioning:"popover"===this.positioning?"document":this.positioning,isOpen:this.open,xOffset:this.xOffset,yOffset:this.yOffset,disableBlockFlip:this.noVerticalFlip,disableInlineFlip:this.noHorizontalFlip,onOpen:this.onOpened,beforeClose:this.beforeClose,onClose:this.onClosed,repositionStrategy:this.hasOverflow&&"popover"!==this.positioning?"move":"resize"}))),this.onWindowResize=()=>{this.isRepositioning||"document"!==this.positioning&&"fixed"!==this.positioning&&"popover"!==this.positioning||(this.isRepositioning=!0,this.reposition(),this.isRepositioning=!1)},this.handleFocusout=async t=>{const e=this.anchorElement;if(this.stayOpenOnFocusout||!this.open||this.pointerPath.includes(e))return;if(t.relatedTarget){if(Wa(t.relatedTarget,this)||0!==this.pointerPath.length&&Wa(t.relatedTarget,e))return}else if(this.pointerPath.includes(this))return;const i=this.skipRestoreFocus;this.skipRestoreFocus=!0,this.close(),await this.updateComplete,this.skipRestoreFocus=i},this.onOpened=async()=>{this.lastFocusedElement=function(t=document){let e=t.activeElement;for(;e&&null!==(i=e)&&void 0!==i&&null!==(i=i.shadowRoot)&&void 0!==i&&i.activeElement;){var i;e=e.shadowRoot.activeElement}return e}();const t=this.items,e=B(t);e&&this.defaultFocus!==qa&&(e.item.tabIndex=-1);let i=!this.quick;switch(this.quick?this.dispatchEvent(new Event("opening")):i=!!await this.animateOpen(),this.defaultFocus){case Xa:const e=N(t);e&&(e.tabIndex=0,e.focus(),await e.updateComplete);break;case ja:const i=G(t);i&&(i.tabIndex=0,i.focus(),await i.updateComplete);break;case Za:this.focus()}i||this.dispatchEvent(new Event("opened"))},this.beforeClose=async()=>{var t,e;(this.open=!1,this.skipRestoreFocus)||(null===(t=this.lastFocusedElement)||void 0===t||null===(e=t.focus)||void 0===e||e.call(t));this.quick||await this.animateClose()},this.onClosed=()=>{this.quick&&(this.dispatchEvent(new Event("closing")),this.dispatchEvent(new Event("closed")))},this.onWindowPointerdown=t=>{this.pointerPath=t.composedPath()},this.onDocumentClick=t=>{if(!this.open)return;const e=t.composedPath();this.stayOpenOnOutsideClick||e.includes(this)||e.includes(this.anchorElement)||(this.open=!1)},this.internals.role="menu",this.addEventListener("keydown",this.handleKeydown),this.addEventListener("keydown",this.captureKeydown,{capture:!0}),this.addEventListener("focusout",this.handleFocusout)}get items(){return this.listController.items}willUpdate(t){t.has("open")&&(this.open?this.removeAttribute("aria-hidden"):this.setAttribute("aria-hidden","true"))}update(t){t.has("open")&&(this.open?this.setUpGlobalEventListeners():this.cleanUpGlobalEventListeners()),t.has("positioning")&&"popover"===this.positioning&&!this.showPopover&&(this.positioning="fixed"),super.update(t)}connectedCallback(){super.connectedCallback(),this.open&&this.setUpGlobalEventListeners()}disconnectedCallback(){super.disconnectedCallback(),this.cleanUpGlobalEventListeners()}getBoundingClientRect(){return this.surfaceEl?this.surfaceEl.getBoundingClientRect():super.getBoundingClientRect()}getClientRects(){return this.surfaceEl?this.surfaceEl.getClientRects():super.getClientRects()}render(){return this.renderSurface()}renderSurface(){return r`
      <div
        class="menu ${h(this.getSurfaceClasses())}"
        style=${ba(this.menuPositionController.surfaceStyles)}
        popover=${"popover"===this.positioning?"manual":c}>
        ${this.renderElevation()}
        <div class="items">
          <div class="item-padding"> ${this.renderMenuItems()} </div>
        </div>
      </div>
    `}renderMenuItems(){return r`<slot
      @close-menu=${this.onCloseMenu}
      @deactivate-items=${this.onDeactivateItems}
      @request-activation=${this.onRequestActivation}
      @deactivate-typeahead=${this.handleDeactivateTypeahead}
      @activate-typeahead=${this.handleActivateTypeahead}
      @stay-open-on-focusout=${this.handleStayOpenOnFocusout}
      @close-on-focusout=${this.handleCloseOnFocusout}
      @slotchange=${this.listController.onSlotchange}></slot>`}renderElevation(){return r`<md-elevation part="elevation"></md-elevation>`}getSurfaceClasses(){return{open:this.open,fixed:"fixed"===this.positioning,"has-overflow":this.hasOverflow}}captureKeydown(t){t.target===this&&!t.defaultPrevented&&Va(t.code)&&(t.preventDefault(),this.close()),this.typeaheadController.onKeydown(t)}async animateOpen(){const t=this.surfaceEl,e=this.slotEl;if(!t||!e)return!0;const i=this.openDirection;this.dispatchEvent(new Event("opening")),t.classList.toggle("animating",!0);const s=this.openCloseAnimationSignal.start(),r=t.offsetHeight,a="UP"===i,o=this.items,n=250/o.length,l=t.animate([{height:"0px"},{height:`${r}px`}],{duration:500,easing:T.EMPHASIZED}),d=e.animate([{transform:a?`translateY(-${r}px)`:""},{transform:""}],{duration:500,easing:T.EMPHASIZED}),c=t.animate([{opacity:0},{opacity:1}],50),h=[];for(let t=0;t<o.length;t++){const e=o[a?o.length-1-t:t],i=e.animate([{opacity:0},{opacity:1}],{duration:250,delay:n*t});e.classList.toggle("md-menu-hidden",!0),i.addEventListener("finish",(()=>{e.classList.toggle("md-menu-hidden",!1)})),h.push([e,i])}let _=t=>{};const p=new Promise((t=>{_=t}));return s.addEventListener("abort",(()=>{l.cancel(),d.cancel(),c.cancel(),h.forEach((([t,e])=>{t.classList.toggle("md-menu-hidden",!1),e.cancel()})),_(!0)})),l.addEventListener("finish",(()=>{t.classList.toggle("animating",!1),this.openCloseAnimationSignal.finish(),_(!1)})),await p}animateClose(){let t;const e=new Promise((e=>{t=e})),i=this.surfaceEl,s=this.slotEl;if(!i||!s)return t(!1),e;const r="UP"===this.openDirection;this.dispatchEvent(new Event("closing")),i.classList.toggle("animating",!0);const a=this.openCloseAnimationSignal.start(),o=i.offsetHeight,n=this.items,l=150,d=50/n.length,c=i.animate([{height:`${o}px`},{height:.35*o+"px"}],{duration:l,easing:T.EMPHASIZED_ACCELERATE}),h=s.animate([{transform:""},{transform:r?`translateY(-${.65*o}px)`:""}],{duration:l,easing:T.EMPHASIZED_ACCELERATE}),_=i.animate([{opacity:1},{opacity:0}],{duration:50,delay:100}),p=[];for(let t=0;t<n.length;t++){const e=n[r?t:n.length-1-t],i=e.animate([{opacity:1},{opacity:0}],{duration:50,delay:50+d*t});i.addEventListener("finish",(()=>{e.classList.toggle("md-menu-hidden",!0)})),p.push([e,i])}return a.addEventListener("abort",(()=>{c.cancel(),h.cancel(),_.cancel(),p.forEach((([t,e])=>{e.cancel(),t.classList.toggle("md-menu-hidden",!1)})),t(!1)})),c.addEventListener("finish",(()=>{i.classList.toggle("animating",!1),p.forEach((([t])=>{t.classList.toggle("md-menu-hidden",!1)})),this.openCloseAnimationSignal.finish(),this.dispatchEvent(new Event("closed")),t(!0)})),e}handleKeydown(t){this.pointerPath=[],this.listController.handleKeydown(t)}setUpGlobalEventListeners(){document.addEventListener("click",this.onDocumentClick,{capture:!0}),window.addEventListener("pointerdown",this.onWindowPointerdown),document.addEventListener("resize",this.onWindowResize,{passive:!0}),window.addEventListener("resize",this.onWindowResize,{passive:!0})}cleanUpGlobalEventListeners(){document.removeEventListener("click",this.onDocumentClick,{capture:!0}),window.removeEventListener("pointerdown",this.onWindowPointerdown),document.removeEventListener("resize",this.onWindowResize),window.removeEventListener("resize",this.onWindowResize)}onCloseMenu(){this.close()}onDeactivateItems(t){t.stopPropagation(),this.listController.onDeactivateItems()}onRequestActivation(t){t.stopPropagation(),this.listController.onRequestActivation(t)}handleDeactivateTypeahead(t){t.stopPropagation(),this.typeaheadActive=!1}handleActivateTypeahead(t){t.stopPropagation(),this.typeaheadActive=!0}handleStayOpenOnFocusout(t){t.stopPropagation(),this.stayOpenOnFocusout=!0}handleCloseOnFocusout(t){t.stopPropagation(),this.stayOpenOnFocusout=!1}close(){this.open=!1;this.slotItems.forEach((t=>{var e;null===(e=t.close)||void 0===e||e.call(t)}))}show(){this.open=!0}activateNextItem(){return this.listController.activateNextItem()??null}activatePreviousItem(){return this.listController.activatePreviousItem()??null}reposition(){this.open&&this.menuPositionController.position()}}e([d(".menu")],no.prototype,"surfaceEl",void 0),e([d("slot")],no.prototype,"slotEl",void 0),e([o()],no.prototype,"anchor",void 0),e([o()],no.prototype,"positioning",void 0),e([o({type:Boolean})],no.prototype,"quick",void 0),e([o({type:Boolean,attribute:"has-overflow"})],no.prototype,"hasOverflow",void 0),e([o({type:Boolean,reflect:!0})],no.prototype,"open",void 0),e([o({type:Number,attribute:"x-offset"})],no.prototype,"xOffset",void 0),e([o({type:Number,attribute:"y-offset"})],no.prototype,"yOffset",void 0),e([o({type:Boolean,attribute:"no-horizontal-flip"})],no.prototype,"noHorizontalFlip",void 0),e([o({type:Boolean,attribute:"no-vertical-flip"})],no.prototype,"noVerticalFlip",void 0),e([o({type:Number,attribute:"typeahead-delay"})],no.prototype,"typeaheadDelay",void 0),e([o({attribute:"anchor-corner"})],no.prototype,"anchorCorner",void 0),e([o({attribute:"menu-corner"})],no.prototype,"menuCorner",void 0),e([o({type:Boolean,attribute:"stay-open-on-outside-click"})],no.prototype,"stayOpenOnOutsideClick",void 0),e([o({type:Boolean,attribute:"stay-open-on-focusout"})],no.prototype,"stayOpenOnFocusout",void 0),e([o({type:Boolean,attribute:"skip-restore-focus"})],no.prototype,"skipRestoreFocus",void 0),e([o({attribute:"default-focus"})],no.prototype,"defaultFocus",void 0),e([o({type:Boolean,attribute:"no-navigation-wrap"})],no.prototype,"noNavigationWrap",void 0),e([i({flatten:!0})],no.prototype,"slotItems",void 0),e([g()],no.prototype,"typeaheadActive",void 0);const lo=a`:host{--md-elevation-level: var(--md-menu-container-elevation, 2);--md-elevation-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));min-width:112px;color:unset;display:contents}md-focus-ring{--md-focus-ring-shape: var(--md-menu-container-shape, var(--md-sys-shape-corner-extra-small, 4px))}.menu{border-radius:var(--md-menu-container-shape, var(--md-sys-shape-corner-extra-small, 4px));display:none;inset:auto;border:none;padding:0px;overflow:visible;background-color:rgba(0,0,0,0);color:inherit;opacity:0;z-index:20;position:absolute;user-select:none;max-height:inherit;height:inherit;min-width:inherit;max-width:inherit;scrollbar-width:inherit}.menu::backdrop{display:none}.fixed{position:fixed}.items{display:block;list-style-type:none;margin:0;outline:none;box-sizing:border-box;background-color:var(--md-menu-container-color, var(--md-sys-color-surface-container, #f3edf7));height:inherit;max-height:inherit;overflow:auto;min-width:inherit;max-width:inherit;border-radius:inherit;scrollbar-width:inherit}.item-padding{padding-block:var(--md-menu-top-space, 8px) var(--md-menu-bottom-space, 8px)}.has-overflow:not([popover]) .items{overflow:visible}.has-overflow.animating .items,.animating .items{overflow:hidden}.has-overflow.animating .items{pointer-events:none}.animating ::slotted(.md-menu-hidden){opacity:0}slot{display:block;height:inherit;max-height:inherit}::slotted(:is(md-divider,[role=separator])){margin:8px 0}@media(forced-colors: active){.menu{border-style:solid;border-color:CanvasText;border-width:1px}}
`;lo.styleSheet;let co=class extends no{};co.styles=[lo],co=e([n("md-menu")],co);class ho extends Et{computeValidity(t){return this.selectControl||(this.selectControl=document.createElement("select")),x(r`<option value=${t.value}></option>`,this.selectControl),this.selectControl.value=t.value,this.selectControl.required=t.required,{validity:this.selectControl.validity,validationMessage:this.selectControl.validationMessage}}equals(t,e){return t.value===e.value&&t.required===e.required}copy({value:t,required:e}){return{value:t,required:e}}}var _o;const po=Symbol("value"),uo=l(Ia(ft(f(E(s)))));class fo extends uo{get value(){return this[po]}set value(t){this.lastUserSetValue=t,this.select(t)}get options(){var t;return(null===(t=this.menu)||void 0===t?void 0:t.items)??[]}get selectedIndex(){const[t,e]=(this.getSelectedOptions()??[])[0]??[];return e??-1}set selectedIndex(t){this.lastUserSetSelectedIndex=t,this.selectIndex(t)}get selectedOptions(){return(this.getSelectedOptions()??[]).map((([t])=>t))}get hasError(){return this.error||this.nativeError}constructor(){super(),this.quick=!1,this.required=!1,this.errorText="",this.label="",this.noAsterisk=!1,this.supportingText="",this.error=!1,this.menuPositioning="popover",this.clampMenuWidth=!1,this.typeaheadDelay=200,this.hasLeadingIcon=!1,this.displayText="",this.menuAlign="start",this[_o]="",this.lastUserSetValue=null,this.lastUserSetSelectedIndex=null,this.lastSelectedOption=null,this.lastSelectedOptionRecords=[],this.nativeError=!1,this.nativeErrorText="",this.focused=!1,this.open=!1,this.defaultFocus=qa,this.prevOpen=this.open,this.selectWidth=0,this.addEventListener("focus",this.handleFocus.bind(this)),this.addEventListener("blur",this.handleBlur.bind(this))}select(t){const e=this.options.find((e=>e.value===t));e&&this.selectItem(e)}selectIndex(t){const e=this.options[t];e&&this.selectItem(e)}reset(){for(const t of this.options)t.selected=t.hasAttribute("selected");this.updateValueAndDisplayText(),this.nativeError=!1,this.nativeErrorText=""}showPicker(){this.open=!0}[(_o=po,Ra)](t){null==t||t.preventDefault();const e=this.getErrorText();var i;(this.nativeError=!!t,this.nativeErrorText=this.validationMessage,e===this.getErrorText())&&(null===(i=this.field)||void 0===i||i.reannounceError())}update(t){if(this.hasUpdated||this.initUserSelection(),this.prevOpen!==this.open&&this.open){const t=this.getBoundingClientRect();this.selectWidth=t.width}this.prevOpen=this.open,super.update(t)}render(){return r`
      <span
        class="select ${h(this.getRenderClasses())}"
        @focusout=${this.handleFocusout}>
        ${this.renderField()} ${this.renderMenu()}
      </span>
    `}async firstUpdated(t){var e;await(null===(e=this.menu)||void 0===e?void 0:e.updateComplete),this.lastSelectedOptionRecords.length||this.initUserSelection(),this.lastSelectedOptionRecords.length||this.options.length||setTimeout((()=>{this.updateValueAndDisplayText()})),super.firstUpdated(t)}getRenderClasses(){return{disabled:this.disabled,error:this.error,open:this.open}}renderField(){const t=this.ariaLabel||this.label;return rt`
      <${this.fieldTag}
          aria-haspopup="listbox"
          role="combobox"
          part="field"
          id="field"
          tabindex=${this.disabled?"-1":"0"}
          aria-label=${t||c}
          aria-describedby="description"
          aria-expanded=${this.open?"true":"false"}
          aria-controls="listbox"
          class="field"
          label=${this.label}
          ?no-asterisk=${this.noAsterisk}
          .focused=${this.focused||this.open}
          .populated=${!!this.displayText}
          .disabled=${this.disabled}
          .required=${this.required}
          .error=${this.hasError}
          ?has-start=${this.hasLeadingIcon}
          has-end
          supporting-text=${this.supportingText}
          error-text=${this.getErrorText()}
          @keydown=${this.handleKeydown}
          @click=${this.handleClick}>
         ${this.renderFieldContent()}
         <div id="description" slot="aria-describedby"></div>
      </${this.fieldTag}>`}renderFieldContent(){return[this.renderLeadingIcon(),this.renderLabel(),this.renderTrailingIcon()]}renderLeadingIcon(){return r`
      <span class="icon leading" slot="start">
        <slot name="leading-icon" @slotchange=${this.handleIconChange}></slot>
      </span>
    `}renderTrailingIcon(){return r`
      <span class="icon trailing" slot="end">
        <slot name="trailing-icon" @slotchange=${this.handleIconChange}>
          <svg height="5" viewBox="7 10 10 5" focusable="false">
            <polygon
              class="down"
              stroke="none"
              fill-rule="evenodd"
              points="7 10 12 15 17 10"></polygon>
            <polygon
              class="up"
              stroke="none"
              fill-rule="evenodd"
              points="7 15 12 10 17 15"></polygon>
          </svg>
        </slot>
      </span>
    `}renderLabel(){return r`<div id="label">${this.displayText||r`&nbsp;`}</div>`}renderMenu(){const t=this.label||this.ariaLabel;return r`<div class="menu-wrapper">
      <md-menu
        id="listbox"
        .defaultFocus=${this.defaultFocus}
        role="listbox"
        tabindex="-1"
        aria-label=${t||c}
        stay-open-on-focusout
        part="menu"
        exportparts="focus-ring: menu-focus-ring"
        anchor="field"
        style=${ba({"--__menu-min-width":`${this.selectWidth}px`,"--__menu-max-width":this.clampMenuWidth?`${this.selectWidth}px`:void 0})}
        no-navigation-wrap
        .open=${this.open}
        .quick=${this.quick}
        .positioning=${this.menuPositioning}
        .typeaheadDelay=${this.typeaheadDelay}
        .anchorCorner=${"start"===this.menuAlign?"end-start":"end-end"}
        .menuCorner=${"start"===this.menuAlign?"start-start":"start-end"}
        @opening=${this.handleOpening}
        @opened=${this.redispatchEvent}
        @closing=${this.redispatchEvent}
        @closed=${this.handleClosed}
        @close-menu=${this.handleCloseMenu}
        @request-selection=${this.handleRequestSelection}
        @request-deselection=${this.handleRequestDeselection}>
        ${this.renderMenuContent()}
      </md-menu>
    </div>`}renderMenuContent(){return r`<slot></slot>`}handleKeydown(t){if(this.open||this.disabled||!this.menu)return;const e=this.menu.typeaheadController,i="Space"===t.code||"ArrowDown"===t.code||"ArrowUp"===t.code||"End"===t.code||"Home"===t.code||"Enter"===t.code;if(!e.isTypingAhead&&i){switch(t.preventDefault(),this.open=!0,t.code){case"Space":case"ArrowDown":case"Enter":this.defaultFocus=qa;break;case"End":this.defaultFocus=ja;break;case"ArrowUp":case"Home":this.defaultFocus=Xa}return}if(1===t.key.length){var s,r;e.onKeydown(t),t.preventDefault();const{lastActiveRecord:i}=e;if(!i)return;null===(s=this.labelEl)||void 0===s||null===(r=s.setAttribute)||void 0===r||r.call(s,"aria-live","polite");this.selectItem(i[io])&&this.dispatchInteractionEvents()}}handleClick(){this.open=!this.open}handleFocus(){this.focused=!0}handleBlur(){this.focused=!1}handleFocusout(t){t.relatedTarget&&Wa(t.relatedTarget,this)||(this.open=!1)}getSelectedOptions(){if(!this.menu)return this.lastSelectedOptionRecords=[],null;const t=this.menu.items;return this.lastSelectedOptionRecords=function(t){const e=[];for(let i=0;i<t.length;i++){const s=t[i];s.selected&&e.push([s,i])}return e}(t),this.lastSelectedOptionRecords}async getUpdateComplete(){var t;return await(null===(t=this.menu)||void 0===t?void 0:t.updateComplete),super.getUpdateComplete()}updateValueAndDisplayText(){const t=this.getSelectedOptions()??[];let e=!1;if(t.length){const[i]=t[0];e=this.lastSelectedOption!==i,this.lastSelectedOption=i,this[po]=i.value,this.displayText=i.displayText}else e=null!==this.lastSelectedOption,this.lastSelectedOption=null,this[po]="",this.displayText="";return e}async handleOpening(t){var e,i,s;if(null===(e=this.labelEl)||void 0===e||null===(i=e.removeAttribute)||void 0===i||i.call(e,"aria-live"),this.redispatchEvent(t),this.defaultFocus!==qa)return;const r=this.menu.items,a=null===(s=B(r))||void 0===s?void 0:s.item;let[o]=this.lastSelectedOptionRecords[0]??[null];a&&a!==o&&(a.tabIndex=-1),o=o??r[0],o&&(o.tabIndex=0,o.focus())}redispatchEvent(t){S(this,t)}handleClosed(t){this.open=!1,this.redispatchEvent(t)}handleCloseMenu(t){const e=t.detail.reason,i=t.detail.itemPath[0];this.open=!1;let s=!1;var r;"click-selection"===e.kind||"keydown"===e.kind&&(r=e.key,Object.values(Ka).some((t=>t===r)))?s=this.selectItem(i):(i.tabIndex=-1,i.blur()),s&&this.dispatchInteractionEvents()}selectItem(t){return(this.getSelectedOptions()??[]).forEach((([e])=>{t!==e&&(e.selected=!1,e.tabIndex=-1)})),t.selected=!0,t.tabIndex=0,this.updateValueAndDisplayText()}handleRequestSelection(t){const e=t.target;this.lastSelectedOptionRecords.some((([t])=>t===e))||this.selectItem(e)}handleRequestDeselection(t){const e=t.target;this.lastSelectedOptionRecords.some((([t])=>t===e))&&this.updateValueAndDisplayText()}initUserSelection(){this.lastUserSetValue&&!this.lastSelectedOptionRecords.length?this.select(this.lastUserSetValue):null===this.lastUserSetSelectedIndex||this.lastSelectedOptionRecords.length?this.updateValueAndDisplayText():this.selectIndex(this.lastUserSetSelectedIndex)}handleIconChange(){this.hasLeadingIcon=this.leadingIcons.length>0}dispatchInteractionEvents(){this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0}))}getErrorText(){return this.error?this.errorText:this.nativeErrorText}[y](){return this.value}formResetCallback(){this.reset()}formStateRestoreCallback(t){this.value=t}click(){var t;null===(t=this.field)||void 0===t||t.click()}[ct](){return new ho((()=>this))}[ht](){return this.field}}fo.shadowRootOptions={...s.shadowRootOptions,delegatesFocus:!0},e([o({type:Boolean})],fo.prototype,"quick",void 0),e([o({type:Boolean})],fo.prototype,"required",void 0),e([o({type:String,attribute:"error-text"})],fo.prototype,"errorText",void 0),e([o()],fo.prototype,"label",void 0),e([o({type:Boolean,attribute:"no-asterisk"})],fo.prototype,"noAsterisk",void 0),e([o({type:String,attribute:"supporting-text"})],fo.prototype,"supportingText",void 0),e([o({type:Boolean,reflect:!0})],fo.prototype,"error",void 0),e([o({attribute:"menu-positioning"})],fo.prototype,"menuPositioning",void 0),e([o({type:Boolean,attribute:"clamp-menu-width"})],fo.prototype,"clampMenuWidth",void 0),e([o({type:Number,attribute:"typeahead-delay"})],fo.prototype,"typeaheadDelay",void 0),e([o({type:Boolean,attribute:"has-leading-icon"})],fo.prototype,"hasLeadingIcon",void 0),e([o({attribute:"display-text"})],fo.prototype,"displayText",void 0),e([o({attribute:"menu-align"})],fo.prototype,"menuAlign",void 0),e([o()],fo.prototype,"value",null),e([o({type:Number,attribute:"selected-index"})],fo.prototype,"selectedIndex",null),e([g()],fo.prototype,"nativeError",void 0),e([g()],fo.prototype,"nativeErrorText",void 0),e([g()],fo.prototype,"focused",void 0),e([g()],fo.prototype,"open",void 0),e([g()],fo.prototype,"defaultFocus",void 0),e([d(".field")],fo.prototype,"field",void 0),e([d("md-menu")],fo.prototype,"menu",void 0),e([d("#label")],fo.prototype,"labelEl",void 0),e([i({slot:"leading-icon",flatten:!0})],fo.prototype,"leadingIcons",void 0);class Eo extends fo{constructor(){super(...arguments),this.fieldTag=it`md-filled-field`}}const go=a`:host{--_text-field-active-indicator-color: var(--md-filled-select-text-field-active-indicator-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-active-indicator-height: var(--md-filled-select-text-field-active-indicator-height, 1px);--_text-field-container-color: var(--md-filled-select-text-field-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_text-field-disabled-active-indicator-color: var(--md-filled-select-text-field-disabled-active-indicator-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-active-indicator-height: var(--md-filled-select-text-field-disabled-active-indicator-height, 1px);--_text-field-disabled-active-indicator-opacity: var(--md-filled-select-text-field-disabled-active-indicator-opacity, 0.38);--_text-field-disabled-container-color: var(--md-filled-select-text-field-disabled-container-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-container-opacity: var(--md-filled-select-text-field-disabled-container-opacity, 0.04);--_text-field-disabled-input-text-color: var(--md-filled-select-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-input-text-opacity: var(--md-filled-select-text-field-disabled-input-text-opacity, 0.38);--_text-field-disabled-label-text-color: var(--md-filled-select-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-label-text-opacity: var(--md-filled-select-text-field-disabled-label-text-opacity, 0.38);--_text-field-disabled-leading-icon-color: var(--md-filled-select-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-leading-icon-opacity: var(--md-filled-select-text-field-disabled-leading-icon-opacity, 0.38);--_text-field-disabled-supporting-text-color: var(--md-filled-select-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-supporting-text-opacity: var(--md-filled-select-text-field-disabled-supporting-text-opacity, 0.38);--_text-field-disabled-trailing-icon-color: var(--md-filled-select-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-trailing-icon-opacity: var(--md-filled-select-text-field-disabled-trailing-icon-opacity, 0.38);--_text-field-error-active-indicator-color: var(--md-filled-select-text-field-error-active-indicator-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-active-indicator-color: var(--md-filled-select-text-field-error-focus-active-indicator-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-input-text-color: var(--md-filled-select-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-error-focus-label-text-color: var(--md-filled-select-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-leading-icon-color: var(--md-filled-select-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-focus-supporting-text-color: var(--md-filled-select-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-trailing-icon-color: var(--md-filled-select-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-active-indicator-color: var(--md-filled-select-text-field-error-hover-active-indicator-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-input-text-color: var(--md-filled-select-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-error-hover-label-text-color: var(--md-filled-select-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-leading-icon-color: var(--md-filled-select-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-hover-state-layer-color: var(--md-filled-select-text-field-error-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-error-hover-state-layer-opacity: var(--md-filled-select-text-field-error-hover-state-layer-opacity, 0.08);--_text-field-error-hover-supporting-text-color: var(--md-filled-select-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-trailing-icon-color: var(--md-filled-select-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-input-text-color: var(--md-filled-select-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-error-label-text-color: var(--md-filled-select-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-leading-icon-color: var(--md-filled-select-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-supporting-text-color: var(--md-filled-select-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-trailing-icon-color: var(--md-filled-select-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-focus-active-indicator-color: var(--md-filled-select-text-field-focus-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-active-indicator-height: var(--md-filled-select-text-field-focus-active-indicator-height, 3px);--_text-field-focus-input-text-color: var(--md-filled-select-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-focus-label-text-color: var(--md-filled-select-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-leading-icon-color: var(--md-filled-select-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-supporting-text-color: var(--md-filled-select-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-trailing-icon-color: var(--md-filled-select-text-field-focus-trailing-icon-color, var(--md-sys-color-primary, #6750a4));--_text-field-hover-active-indicator-color: var(--md-filled-select-text-field-hover-active-indicator-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-hover-active-indicator-height: var(--md-filled-select-text-field-hover-active-indicator-height, 1px);--_text-field-hover-input-text-color: var(--md-filled-select-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-hover-label-text-color: var(--md-filled-select-text-field-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-hover-leading-icon-color: var(--md-filled-select-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-state-layer-color: var(--md-filled-select-text-field-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-hover-state-layer-opacity: var(--md-filled-select-text-field-hover-state-layer-opacity, 0.08);--_text-field-hover-supporting-text-color: var(--md-filled-select-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-trailing-icon-color: var(--md-filled-select-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-input-text-color: var(--md-filled-select-text-field-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-input-text-font: var(--md-filled-select-text-field-input-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_text-field-input-text-line-height: var(--md-filled-select-text-field-input-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_text-field-input-text-size: var(--md-filled-select-text-field-input-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_text-field-input-text-weight: var(--md-filled-select-text-field-input-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_text-field-label-text-color: var(--md-filled-select-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-label-text-font: var(--md-filled-select-text-field-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_text-field-label-text-line-height: var(--md-filled-select-text-field-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_text-field-label-text-populated-line-height: var(--md-filled-select-text-field-label-text-populated-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_text-field-label-text-populated-size: var(--md-filled-select-text-field-label-text-populated-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_text-field-label-text-size: var(--md-filled-select-text-field-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_text-field-label-text-weight: var(--md-filled-select-text-field-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_text-field-leading-icon-color: var(--md-filled-select-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-leading-icon-size: var(--md-filled-select-text-field-leading-icon-size, 24px);--_text-field-supporting-text-color: var(--md-filled-select-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-supporting-text-font: var(--md-filled-select-text-field-supporting-text-font, var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto)));--_text-field-supporting-text-line-height: var(--md-filled-select-text-field-supporting-text-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_text-field-supporting-text-size: var(--md-filled-select-text-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_text-field-supporting-text-weight: var(--md-filled-select-text-field-supporting-text-weight, var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400)));--_text-field-trailing-icon-color: var(--md-filled-select-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-trailing-icon-size: var(--md-filled-select-text-field-trailing-icon-size, 24px);--_text-field-container-shape-start-start: var(--md-filled-select-text-field-container-shape-start-start, var(--md-filled-select-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_text-field-container-shape-start-end: var(--md-filled-select-text-field-container-shape-start-end, var(--md-filled-select-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_text-field-container-shape-end-end: var(--md-filled-select-text-field-container-shape-end-end, var(--md-filled-select-text-field-container-shape, var(--md-sys-shape-corner-none, 0px)));--_text-field-container-shape-end-start: var(--md-filled-select-text-field-container-shape-end-start, var(--md-filled-select-text-field-container-shape, var(--md-sys-shape-corner-none, 0px)));--md-filled-field-active-indicator-color: var(--_text-field-active-indicator-color);--md-filled-field-active-indicator-height: var(--_text-field-active-indicator-height);--md-filled-field-container-color: var(--_text-field-container-color);--md-filled-field-container-shape-end-end: var(--_text-field-container-shape-end-end);--md-filled-field-container-shape-end-start: var(--_text-field-container-shape-end-start);--md-filled-field-container-shape-start-end: var(--_text-field-container-shape-start-end);--md-filled-field-container-shape-start-start: var(--_text-field-container-shape-start-start);--md-filled-field-content-color: var(--_text-field-input-text-color);--md-filled-field-content-font: var(--_text-field-input-text-font);--md-filled-field-content-line-height: var(--_text-field-input-text-line-height);--md-filled-field-content-size: var(--_text-field-input-text-size);--md-filled-field-content-weight: var(--_text-field-input-text-weight);--md-filled-field-disabled-active-indicator-color: var(--_text-field-disabled-active-indicator-color);--md-filled-field-disabled-active-indicator-height: var(--_text-field-disabled-active-indicator-height);--md-filled-field-disabled-active-indicator-opacity: var(--_text-field-disabled-active-indicator-opacity);--md-filled-field-disabled-container-color: var(--_text-field-disabled-container-color);--md-filled-field-disabled-container-opacity: var(--_text-field-disabled-container-opacity);--md-filled-field-disabled-content-color: var(--_text-field-disabled-input-text-color);--md-filled-field-disabled-content-opacity: var(--_text-field-disabled-input-text-opacity);--md-filled-field-disabled-label-text-color: var(--_text-field-disabled-label-text-color);--md-filled-field-disabled-label-text-opacity: var(--_text-field-disabled-label-text-opacity);--md-filled-field-disabled-leading-content-color: var(--_text-field-disabled-leading-icon-color);--md-filled-field-disabled-leading-content-opacity: var(--_text-field-disabled-leading-icon-opacity);--md-filled-field-disabled-supporting-text-color: var(--_text-field-disabled-supporting-text-color);--md-filled-field-disabled-supporting-text-opacity: var(--_text-field-disabled-supporting-text-opacity);--md-filled-field-disabled-trailing-content-color: var(--_text-field-disabled-trailing-icon-color);--md-filled-field-disabled-trailing-content-opacity: var(--_text-field-disabled-trailing-icon-opacity);--md-filled-field-error-active-indicator-color: var(--_text-field-error-active-indicator-color);--md-filled-field-error-content-color: var(--_text-field-error-input-text-color);--md-filled-field-error-focus-active-indicator-color: var(--_text-field-error-focus-active-indicator-color);--md-filled-field-error-focus-content-color: var(--_text-field-error-focus-input-text-color);--md-filled-field-error-focus-label-text-color: var(--_text-field-error-focus-label-text-color);--md-filled-field-error-focus-leading-content-color: var(--_text-field-error-focus-leading-icon-color);--md-filled-field-error-focus-supporting-text-color: var(--_text-field-error-focus-supporting-text-color);--md-filled-field-error-focus-trailing-content-color: var(--_text-field-error-focus-trailing-icon-color);--md-filled-field-error-hover-active-indicator-color: var(--_text-field-error-hover-active-indicator-color);--md-filled-field-error-hover-content-color: var(--_text-field-error-hover-input-text-color);--md-filled-field-error-hover-label-text-color: var(--_text-field-error-hover-label-text-color);--md-filled-field-error-hover-leading-content-color: var(--_text-field-error-hover-leading-icon-color);--md-filled-field-error-hover-state-layer-color: var(--_text-field-error-hover-state-layer-color);--md-filled-field-error-hover-state-layer-opacity: var(--_text-field-error-hover-state-layer-opacity);--md-filled-field-error-hover-supporting-text-color: var(--_text-field-error-hover-supporting-text-color);--md-filled-field-error-hover-trailing-content-color: var(--_text-field-error-hover-trailing-icon-color);--md-filled-field-error-label-text-color: var(--_text-field-error-label-text-color);--md-filled-field-error-leading-content-color: var(--_text-field-error-leading-icon-color);--md-filled-field-error-supporting-text-color: var(--_text-field-error-supporting-text-color);--md-filled-field-error-trailing-content-color: var(--_text-field-error-trailing-icon-color);--md-filled-field-focus-active-indicator-color: var(--_text-field-focus-active-indicator-color);--md-filled-field-focus-active-indicator-height: var(--_text-field-focus-active-indicator-height);--md-filled-field-focus-content-color: var(--_text-field-focus-input-text-color);--md-filled-field-focus-label-text-color: var(--_text-field-focus-label-text-color);--md-filled-field-focus-leading-content-color: var(--_text-field-focus-leading-icon-color);--md-filled-field-focus-supporting-text-color: var(--_text-field-focus-supporting-text-color);--md-filled-field-focus-trailing-content-color: var(--_text-field-focus-trailing-icon-color);--md-filled-field-hover-active-indicator-color: var(--_text-field-hover-active-indicator-color);--md-filled-field-hover-active-indicator-height: var(--_text-field-hover-active-indicator-height);--md-filled-field-hover-content-color: var(--_text-field-hover-input-text-color);--md-filled-field-hover-label-text-color: var(--_text-field-hover-label-text-color);--md-filled-field-hover-leading-content-color: var(--_text-field-hover-leading-icon-color);--md-filled-field-hover-state-layer-color: var(--_text-field-hover-state-layer-color);--md-filled-field-hover-state-layer-opacity: var(--_text-field-hover-state-layer-opacity);--md-filled-field-hover-supporting-text-color: var(--_text-field-hover-supporting-text-color);--md-filled-field-hover-trailing-content-color: var(--_text-field-hover-trailing-icon-color);--md-filled-field-label-text-color: var(--_text-field-label-text-color);--md-filled-field-label-text-font: var(--_text-field-label-text-font);--md-filled-field-label-text-line-height: var(--_text-field-label-text-line-height);--md-filled-field-label-text-populated-line-height: var(--_text-field-label-text-populated-line-height);--md-filled-field-label-text-populated-size: var(--_text-field-label-text-populated-size);--md-filled-field-label-text-size: var(--_text-field-label-text-size);--md-filled-field-label-text-weight: var(--_text-field-label-text-weight);--md-filled-field-leading-content-color: var(--_text-field-leading-icon-color);--md-filled-field-supporting-text-color: var(--_text-field-supporting-text-color);--md-filled-field-supporting-text-font: var(--_text-field-supporting-text-font);--md-filled-field-supporting-text-line-height: var(--_text-field-supporting-text-line-height);--md-filled-field-supporting-text-size: var(--_text-field-supporting-text-size);--md-filled-field-supporting-text-weight: var(--_text-field-supporting-text-weight);--md-filled-field-trailing-content-color: var(--_text-field-trailing-icon-color)}[has-start] .icon.leading{font-size:var(--_text-field-leading-icon-size);height:var(--_text-field-leading-icon-size);width:var(--_text-field-leading-icon-size)}.icon.trailing{font-size:var(--_text-field-trailing-icon-size);height:var(--_text-field-trailing-icon-size);width:var(--_text-field-trailing-icon-size)}
`;go.styleSheet;const mo=a`:host{color:unset;min-width:210px;display:flex}.field{cursor:default;outline:none}.select{position:relative;flex-direction:column}.icon.trailing svg,.icon ::slotted(*){fill:currentColor}.icon ::slotted(*){width:inherit;height:inherit;font-size:inherit}.icon slot{display:flex;height:100%;width:100%;align-items:center;justify-content:center}.icon.trailing :is(.up,.down){opacity:0;transition:opacity 75ms linear 75ms}.select:not(.open) .down,.select.open .up{opacity:1}.field,.select,md-menu{min-width:inherit;width:inherit;max-width:inherit;display:flex}md-menu{min-width:var(--__menu-min-width);max-width:var(--__menu-max-width, inherit)}.menu-wrapper{width:0px;height:0px;max-width:inherit}md-menu ::slotted(:not[disabled]){cursor:pointer}.field,.select{width:100%}:host{display:inline-flex}:host([disabled]){pointer-events:none}
`;mo.styleSheet;class vo extends Eo{}vo.styles=[mo,go],customElements.define("ew-filled-select",vo);const So=a`:host{display:flex;gap:16px;--md-ripple-hover-color: var(--md-menu-item-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-hover-opacity: var(--md-menu-item-hover-state-layer-opacity, 0.08);--md-ripple-pressed-color: var(--md-menu-item-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-pressed-opacity: var(--md-menu-item-pressed-state-layer-opacity, 0.12)}:host([disabled]){opacity:var(--md-menu-item-disabled-opacity, 0.3);pointer-events:none}md-focus-ring{z-index:1;--md-focus-ring-shape: 8px}a,button,li{background:none;border:none;padding:0;margin:0;text-align:unset;text-decoration:none}.list-item{border-radius:inherit;display:flex;flex:1;gap:inherit;max-width:inherit;min-width:inherit;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.list-item:not(.disabled){cursor:pointer}[slot=container]{pointer-events:none}md-ripple{border-radius:inherit}md-item{border-radius:inherit;flex:1;color:var(--md-menu-item-label-text-color, var(--md-sys-color-on-surface, #1d1b20));font-family:var(--md-menu-item-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));line-height:var(--md-menu-item-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));font-weight:var(--md-menu-item-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));min-height:var(--md-menu-item-one-line-container-height, 56px);padding-top:var(--md-menu-item-top-space, 12px);padding-bottom:var(--md-menu-item-bottom-space, 12px);padding-inline-start:var(--md-menu-item-leading-space, 16px);padding-inline-end:var(--md-menu-item-trailing-space, 16px);gap:inherit}md-item[multiline]{min-height:var(--md-menu-item-two-line-container-height, 72px)}[slot=supporting-text]{color:var(--md-menu-item-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-menu-item-supporting-text-font, var(--md-sys-typescale-body-medium-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-supporting-text-size, var(--md-sys-typescale-body-medium-size, 0.875rem));line-height:var(--md-menu-item-supporting-text-line-height, var(--md-sys-typescale-body-medium-line-height, 1.25rem));font-weight:var(--md-menu-item-supporting-text-weight, var(--md-sys-typescale-body-medium-weight, var(--md-ref-typeface-weight-regular, 400)))}[slot=trailing-supporting-text]{color:var(--md-menu-item-trailing-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-menu-item-trailing-supporting-text-font, var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-trailing-supporting-text-size, var(--md-sys-typescale-label-small-size, 0.6875rem));line-height:var(--md-menu-item-trailing-supporting-text-line-height, var(--md-sys-typescale-label-small-line-height, 1rem));font-weight:var(--md-menu-item-trailing-supporting-text-weight, var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500)))}:is([slot=start],[slot=end])::slotted(*){fill:currentColor}[slot=start]{color:var(--md-menu-item-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}[slot=end]{color:var(--md-menu-item-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}.list-item{background-color:var(--md-menu-item-container-color, transparent)}.list-item.selected{background-color:var(--md-menu-item-selected-container-color, var(--md-sys-color-secondary-container, #e8def8))}.selected:not(.disabled) ::slotted(*){color:var(--md-menu-item-selected-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b))}@media(forced-colors: active){:host([disabled]),:host([disabled]) slot{color:GrayText;opacity:1}.list-item{position:relative}.list-item.selected::before{content:"";position:absolute;inset:0;box-sizing:border-box;border-radius:inherit;pointer-events:none;border:3px double CanvasText}}
`;So.styleSheet;class yo{constructor(t,e){this.host=t,this.internalTypeaheadText=null,this.onClick=()=>{this.host.keepOpen||this.host.dispatchEvent($a(this.host,{kind:Ha}))},this.onKeydown=t=>{if(this.host.href&&"Enter"===t.code){const t=this.getInteractiveElement();t instanceof HTMLAnchorElement&&t.click()}if(t.defaultPrevented)return;const e=t.code;this.host.keepOpen&&"Escape"!==e||Va(e)&&(t.preventDefault(),this.host.dispatchEvent($a(this.host,{kind:za,key:e})))},this.getHeadlineElements=e.getHeadlineElements,this.getSupportingTextElements=e.getSupportingTextElements,this.getDefaultElements=e.getDefaultElements,this.getInteractiveElement=e.getInteractiveElement,this.host.addController(this)}get typeaheadText(){if(null!==this.internalTypeaheadText)return this.internalTypeaheadText;const t=this.getHeadlineElements(),e=[];return t.forEach((t=>{t.textContent&&t.textContent.trim()&&e.push(t.textContent.trim())})),0===e.length&&this.getDefaultElements().forEach((t=>{t.textContent&&t.textContent.trim()&&e.push(t.textContent.trim())})),0===e.length&&this.getSupportingTextElements().forEach((t=>{t.textContent&&t.textContent.trim()&&e.push(t.textContent.trim())})),e.join(" ")}get tagName(){switch(this.host.type){case"link":return"a";case"button":return"button";default:return"li"}}get role(){return"option"===this.host.type?"option":"menuitem"}hostConnected(){this.host.toggleAttribute("md-menu-item",!0)}hostUpdate(){this.host.href&&(this.host.type="link")}setTypeaheadText(t){this.internalTypeaheadText=t}}class bo{get role(){return this.menuItemController.role}get typeaheadText(){return this.menuItemController.typeaheadText}setTypeaheadText(t){this.menuItemController.setTypeaheadText(t)}get displayText(){return null!==this.internalDisplayText?this.internalDisplayText:this.menuItemController.typeaheadText}setDisplayText(t){this.internalDisplayText=t}constructor(t,e){this.host=t,this.internalDisplayText=null,this.firstUpdate=!0,this.onClick=()=>{this.menuItemController.onClick()},this.onKeydown=t=>{this.menuItemController.onKeydown(t)},this.lastSelected=this.host.selected,this.menuItemController=new yo(t,e),t.addController(this)}hostUpdate(){this.lastSelected!==this.host.selected&&(this.host.ariaSelected=this.host.selected?"true":"false")}hostUpdated(){this.lastSelected===this.host.selected||this.firstUpdate||(this.host.selected?this.host.dispatchEvent(new Event("request-selection",{bubbles:!0,composed:!0})):this.host.dispatchEvent(new Event("request-deselection",{bubbles:!0,composed:!0}))),this.lastSelected=this.host.selected,this.firstUpdate=!1}}const wo=l(s);class Ro extends wo{constructor(){super(...arguments),this.disabled=!1,this.isMenuItem=!0,this.selected=!1,this.value="",this.type="option",this.selectOptionController=new bo(this,{getHeadlineElements:()=>this.headlineElements,getSupportingTextElements:()=>this.supportingTextElements,getDefaultElements:()=>this.defaultElements,getInteractiveElement:()=>this.listItemRoot})}get typeaheadText(){return this.selectOptionController.typeaheadText}set typeaheadText(t){this.selectOptionController.setTypeaheadText(t)}get displayText(){return this.selectOptionController.displayText}set displayText(t){this.selectOptionController.setDisplayText(t)}render(){return this.renderListItem(r`
      <md-item>
        <div slot="container">
          ${this.renderRipple()} ${this.renderFocusRing()}
        </div>
        <slot name="start" slot="start"></slot>
        <slot name="end" slot="end"></slot>
        ${this.renderBody()}
      </md-item>
    `)}renderListItem(t){return r`
      <li
        id="item"
        tabindex=${this.disabled?-1:0}
        role=${this.selectOptionController.role}
        aria-label=${this.ariaLabel||c}
        aria-selected=${this.ariaSelected||c}
        aria-checked=${this.ariaChecked||c}
        aria-expanded=${this.ariaExpanded||c}
        aria-haspopup=${this.ariaHasPopup||c}
        class="list-item ${h(this.getRenderClasses())}"
        @click=${this.selectOptionController.onClick}
        @keydown=${this.selectOptionController.onKeydown}
        >${t}</li
      >
    `}renderRipple(){return r` <md-ripple
      part="ripple"
      for="item"
      ?disabled=${this.disabled}></md-ripple>`}renderFocusRing(){return r` <md-focus-ring
      part="focus-ring"
      for="item"
      inward></md-focus-ring>`}getRenderClasses(){return{disabled:this.disabled,selected:this.selected}}renderBody(){return r`
      <slot></slot>
      <slot name="overline" slot="overline"></slot>
      <slot name="headline" slot="headline"></slot>
      <slot name="supporting-text" slot="supporting-text"></slot>
      <slot
        name="trailing-supporting-text"
        slot="trailing-supporting-text"></slot>
    `}focus(){var t;null===(t=this.listItemRoot)||void 0===t||t.focus()}}Ro.shadowRootOptions={...s.shadowRootOptions,delegatesFocus:!0},e([o({type:Boolean,reflect:!0})],Ro.prototype,"disabled",void 0),e([o({type:Boolean,attribute:"md-menu-item",reflect:!0})],Ro.prototype,"isMenuItem",void 0),e([o({type:Boolean})],Ro.prototype,"selected",void 0),e([o()],Ro.prototype,"value",void 0),e([d(".list-item")],Ro.prototype,"listItemRoot",void 0),e([i({slot:"headline"})],Ro.prototype,"headlineElements",void 0),e([i({slot:"supporting-text"})],Ro.prototype,"supportingTextElements",void 0),e([function(e){return(i,s)=>{const{slot:r}=e??{},a="slot"+(r?`[name=${r}]`:":not([name])");return t(i,s,{get(){var t;const i=null===(t=this.renderRoot)||void 0===t?void 0:t.querySelector(a);return(null==i?void 0:i.assignedNodes(e))??[]}})}}({slot:""})],Ro.prototype,"defaultElements",void 0),e([o({attribute:"typeahead-text"})],Ro.prototype,"typeaheadText",null),e([o({attribute:"display-text"})],Ro.prototype,"displayText",null);class Ao extends Ro{}Ao.styles=[So],customElements.define("ew-select-option",Ao);const xo=l(s);class To extends xo{constructor(){super(...arguments),this.value=0,this.max=1,this.indeterminate=!1,this.fourColor=!1}render(){const{ariaLabel:t}=this;return r`
      <div
        class="progress ${h(this.getRenderClasses())}"
        role="progressbar"
        aria-label="${t||c}"
        aria-valuemin="0"
        aria-valuemax=${this.max}
        aria-valuenow=${this.indeterminate?c:this.value}
        >${this.renderIndicator()}</div
      >
    `}getRenderClasses(){return{indeterminate:this.indeterminate,"four-color":this.fourColor}}}e([o({type:Number})],To.prototype,"value",void 0),e([o({type:Number})],To.prototype,"max",void 0),e([o({type:Boolean})],To.prototype,"indeterminate",void 0),e([o({type:Boolean,attribute:"four-color"})],To.prototype,"fourColor",void 0);class Co extends To{renderIndicator(){return this.indeterminate?this.renderIndeterminateContainer():this.renderDeterminateContainer()}renderDeterminateContainer(){const t=100*(1-this.value/this.max);return r`
      <svg viewBox="0 0 4800 4800">
        <circle class="track" pathLength="100"></circle>
        <circle
          class="active-track"
          pathLength="100"
          stroke-dashoffset=${t}></circle>
      </svg>
    `}renderIndeterminateContainer(){return r` <div class="spinner">
      <div class="left">
        <div class="circle"></div>
      </div>
      <div class="right">
        <div class="circle"></div>
      </div>
    </div>`}}const Io=a`:host{--_active-indicator-color: var(--md-circular-progress-active-indicator-color, var(--md-sys-color-primary, #6750a4));--_active-indicator-width: var(--md-circular-progress-active-indicator-width, 10);--_four-color-active-indicator-four-color: var(--md-circular-progress-four-color-active-indicator-four-color, var(--md-sys-color-tertiary-container, #ffd8e4));--_four-color-active-indicator-one-color: var(--md-circular-progress-four-color-active-indicator-one-color, var(--md-sys-color-primary, #6750a4));--_four-color-active-indicator-three-color: var(--md-circular-progress-four-color-active-indicator-three-color, var(--md-sys-color-tertiary, #7d5260));--_four-color-active-indicator-two-color: var(--md-circular-progress-four-color-active-indicator-two-color, var(--md-sys-color-primary-container, #eaddff));--_size: var(--md-circular-progress-size, 48px);display:inline-flex;vertical-align:middle;width:var(--_size);height:var(--_size);position:relative;align-items:center;justify-content:center;contain:strict;content-visibility:auto}.progress{flex:1;align-self:stretch;margin:4px}.progress,.spinner,.left,.right,.circle,svg,.track,.active-track{position:absolute;inset:0}svg{transform:rotate(-90deg)}circle{cx:50%;cy:50%;r:calc(50%*(1 - var(--_active-indicator-width)/100));stroke-width:calc(var(--_active-indicator-width)*1%);stroke-dasharray:100;fill:rgba(0,0,0,0)}.active-track{transition:stroke-dashoffset 500ms cubic-bezier(0, 0, 0.2, 1);stroke:var(--_active-indicator-color)}.track{stroke:rgba(0,0,0,0)}.progress.indeterminate{animation:linear infinite linear-rotate;animation-duration:1568.2352941176ms}.spinner{animation:infinite both rotate-arc;animation-duration:5332ms;animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.left{overflow:hidden;inset:0 50% 0 0}.right{overflow:hidden;inset:0 0 0 50%}.circle{box-sizing:border-box;border-radius:50%;border:solid calc(var(--_active-indicator-width)/100*(var(--_size) - 8px));border-color:var(--_active-indicator-color) var(--_active-indicator-color) rgba(0,0,0,0) rgba(0,0,0,0);animation:expand-arc;animation-iteration-count:infinite;animation-fill-mode:both;animation-duration:1333ms,5332ms;animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.four-color .circle{animation-name:expand-arc,four-color}.left .circle{rotate:135deg;inset:0 -100% 0 0}.right .circle{rotate:100deg;inset:0 0 0 -100%;animation-delay:-666.5ms,0ms}@media(forced-colors: active){.active-track{stroke:CanvasText}.circle{border-color:CanvasText CanvasText Canvas Canvas}}@keyframes expand-arc{0%{transform:rotate(265deg)}50%{transform:rotate(130deg)}100%{transform:rotate(265deg)}}@keyframes rotate-arc{12.5%{transform:rotate(135deg)}25%{transform:rotate(270deg)}37.5%{transform:rotate(405deg)}50%{transform:rotate(540deg)}62.5%{transform:rotate(675deg)}75%{transform:rotate(810deg)}87.5%{transform:rotate(945deg)}100%{transform:rotate(1080deg)}}@keyframes linear-rotate{to{transform:rotate(360deg)}}@keyframes four-color{0%{border-top-color:var(--_four-color-active-indicator-one-color);border-right-color:var(--_four-color-active-indicator-one-color)}15%{border-top-color:var(--_four-color-active-indicator-one-color);border-right-color:var(--_four-color-active-indicator-one-color)}25%{border-top-color:var(--_four-color-active-indicator-two-color);border-right-color:var(--_four-color-active-indicator-two-color)}40%{border-top-color:var(--_four-color-active-indicator-two-color);border-right-color:var(--_four-color-active-indicator-two-color)}50%{border-top-color:var(--_four-color-active-indicator-three-color);border-right-color:var(--_four-color-active-indicator-three-color)}65%{border-top-color:var(--_four-color-active-indicator-three-color);border-right-color:var(--_four-color-active-indicator-three-color)}75%{border-top-color:var(--_four-color-active-indicator-four-color);border-right-color:var(--_four-color-active-indicator-four-color)}90%{border-top-color:var(--_four-color-active-indicator-four-color);border-right-color:var(--_four-color-active-indicator-four-color)}100%{border-top-color:var(--_four-color-active-indicator-one-color);border-right-color:var(--_four-color-active-indicator-one-color)}}
`;Io.styleSheet;class Po extends Co{}Po.styles=[Io],customElements.define("ew-circular-progress",Po);class Oo extends s{render(){return r`
      <div>
        <ew-circular-progress
          active
          ?indeterminate=${void 0===this.progress}
          .value=${void 0!==this.progress?this.progress/100:void 0}
        ></ew-circular-progress>
        ${void 0!==this.progress?r`<div>${this.progress}%</div>`:""}
      </div>
      ${this.label}
    `}}Oo.styles=a`
    :host {
      display: flex;
      flex-direction: column;
      text-align: center;
    }
    ew-circular-progress {
      margin-bottom: 16px;
    }
  `,e([o()],Oo.prototype,"label",void 0),e([o()],Oo.prototype,"progress",void 0),customElements.define("ewt-page-progress",Oo);class Uo extends s{render(){return r`
      <div class="icon">${this.icon}</div>
      ${this.label}
    `}}Uo.styles=a`
    :host {
      display: flex;
      flex-direction: column;
      text-align: center;
    }
    .icon {
      font-size: 50px;
      line-height: 80px;
      color: black;
    }
  `,e([o()],Uo.prototype,"icon",void 0),e([o()],Uo.prototype,"label",void 0),customElements.define("ewt-page-message",Uo);const Fo=F`
  <svg width="24" height="24" viewBox="0 0 24 24">
    <path
      fill="currentColor"
      d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"
    />
  </svg>
`,Do=F`
  <svg viewBox="0 -960 960 960">
    <path
      fill="currentColor"
      d="M480-120 0-600q95-97 219.5-148.5T480-800q137 0 261 51t219 149L480-120ZM174-540q67-48 145-74t161-26q83 0 161 26t145 74l58-58q-79-60-172-91t-192-31q-99 0-192 31t-172 91l58 58Z"
    />
  </svg>
`,Mo=F`
  <svg viewBox="0 -960 960 960">
    <path
      fill="currentColor"
      d="M480-120 0-600q96-98 220-149t260-51q137 0 261 51t219 149L480-120ZM232-482q53-38 116-59.5T480-563q69 0 132 21.5T728-482l116-116q-78-59-170.5-90.5T480-720q-101 0-193.5 31.5T116-598l116 116Z"
    />
  </svg>
`,ko=F`
  <svg viewBox="0 -960 960 960">
    <path
      fill="currentColor"
      d="M480-120 0-600q96-98 220-149t260-51q137 0 261 51t219 149L480-120ZM299-415q38-28 84-43.5t97-15.5q51 0 97 15.5t84 43.5l183-183q-78-59-170.5-90.5T480-720q-101 0-193.5 31.5T116-598l183 183Z"
    />
  </svg>
`,Lo=F`
  <svg viewBox="0 -960 960 960">
    <path
      fill="currentColor"
      d="M480-120 0-600q96-98 220-149t260-51q137 0 261 51t219 149L480-120ZM361-353q25-18 55.5-28t63.5-10q33 0 63.5 10t55.5 28l245-245q-78-59-170.5-90.5T480-720q-101 0-193.5 31.5T116-598l245 245Z"
    />
  </svg>
`,Bo=F`
  <svg viewBox="0 -960 960 960">
    <path
      fill="currentColor"
      d="M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80ZM240-160v-400 400Z"
    />
  </svg>
`,No=F`
  <svg viewBox="0 -960 960 960">
    <path
      fill="currentColor"
      d="M240-160h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM240-160v-400 400Zm0 80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h280v-80q0-83 58.5-141.5T720-920q83 0 141.5 58.5T920-720h-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80h120q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Z"
    />
  </svg>
`,Go=F`
  <svg slot="start" viewBox="0 0 24 24">
    <path d="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z" />
  </svg>
`,$o=F`
  <svg slot="start" viewBox="0 0 24 24">
    <path d="M12,21L15.6,16.2C14.6,15.45 13.35,15 12,15C10.65,15 9.4,15.45 8.4,16.2L12,21M12,3C7.95,3 4.21,4.34 1.2,6.6L3,9C5.5,7.12 8.62,6 12,6C15.38,6 18.5,7.12 21,9L22.8,6.6C19.79,4.34 16.05,3 12,3M12,9C9.3,9 6.81,9.89 4.8,11.4L6.6,13.8C8.1,12.67 9.97,12 12,12C14.03,12 15.9,12.67 17.4,13.8L19.2,11.4C17.19,9.89 14.7,9 12,9Z" />
  </svg>
`,Ko=F`
  <svg slot="start" viewBox="0 0 24 24">
    <path d="M20,19V7H4V19H20M20,3A2,2 0 0,1 22,5V19A2,2 0 0,1 20,21H4A2,2 0 0,1 2,19V5C2,3.89 2.9,3 4,3H20M13,17V15H18V17H13M9.58,13L5.57,9H8.4L11.7,12.3C12.09,12.69 12.09,13.33 11.7,13.72L8.42,17H5.59L9.58,13Z" />
  </svg>
`,Ho=F`
  <svg slot="start" viewBox="0 0 24 24">
  <path d="M16.36,14C16.44,13.34 16.5,12.68 16.5,12C16.5,11.32 16.44,10.66 16.36,10H19.74C19.9,10.64 20,11.31 20,12C20,12.69 19.9,13.36 19.74,14M14.59,19.56C15.19,18.45 15.65,17.25 15.97,16H18.92C17.96,17.65 16.43,18.93 14.59,19.56M14.34,14H9.66C9.56,13.34 9.5,12.68 9.5,12C9.5,11.32 9.56,10.65 9.66,10H14.34C14.43,10.65 14.5,11.32 14.5,12C14.5,12.68 14.43,13.34 14.34,14M12,19.96C11.17,18.76 10.5,17.43 10.09,16H13.91C13.5,17.43 12.83,18.76 12,19.96M8,8H5.08C6.03,6.34 7.57,5.06 9.4,4.44C8.8,5.55 8.35,6.75 8,8M5.08,16H8C8.35,17.25 8.8,18.45 9.4,19.56C7.57,18.93 6.03,17.65 5.08,16M4.26,14C4.1,13.36 4,12.69 4,12C4,11.31 4.1,10.64 4.26,10H7.64C7.56,10.66 7.5,11.32 7.5,12C7.5,12.68 7.56,13.34 7.64,14M12,4.03C12.83,5.23 13.5,6.57 13.91,8H10.09C10.5,6.57 11.17,5.23 12,4.03M18.92,8H15.97C15.65,6.75 15.19,5.55 14.59,4.44C16.43,5.07 17.96,6.34 18.92,8M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
  </svg>
`,zo=F`
  <svg slot="start" viewBox="0 0 24 24">
    <path d="m12.151 1.5882c-.3262 0-.6523.1291-.8996.3867l-8.3848 8.7354c-.0619.0644-.1223.1368-.1807.2154-.0588.0789-.1151.1638-.1688.2534-.2593.4325-.4552.9749-.5232 1.4555-.0026.018-.0076.0369-.0094.0548-.0121.0987-.0184.1944-.0184.2857v8.0124a1.2731 1.2731 0 001.2731 1.2731h7.8313l-3.4484-3.593a1.7399 1.7399 0 111.0803-1.125l2.6847 2.7972v-10.248a1.7399 1.7399 0 111.5276-0v7.187l2.6702-2.782a1.7399 1.7399 0 111.0566 1.1505l-3.7269 3.8831v2.7299h8.174a1.2471 1.2471 0 001.2471-1.2471v-8.0375c0-.0912-.0059-.1868-.0184-.2855-.0603-.4935-.2636-1.0617-.5326-1.5105-.0537-.0896-.1101-.1745-.1684-.253-.0588-.079-.1191-.1513-.181-.2158l-8.3848-8.7363c-.2473-.2577-.5735-.3866-.8995-.3864" />
  </svg>
`,Yo=F`
  <svg slot="start" viewBox="0 0 24 24">
    <path d="M15,14C17.67,14 23,15.33 23,18V20H7V18C7,15.33 12.33,14 15,14M15,12A4,4 0 0,1 11,8A4,4 0 0,1 15,4A4,4 0 0,1 19,8A4,4 0 0,1 15,12M5,9.59L7.12,7.46L8.54,8.88L6.41,11L8.54,13.12L7.12,14.54L5,12.41L2.88,14.54L1.46,13.12L3.59,11L1.46,8.88L2.88,7.46L5,9.59Z" />
  </svg>
`,Vo=F`
  <svg slot="start" viewBox="0 0 24 24">
    <path d="M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z" />
  </svg>
`,Wo=["I".charCodeAt(0),"M".charCodeAt(0),"P".charCodeAt(0),"R".charCodeAt(0),"O".charCodeAt(0),"V".charCodeAt(0),1];var qo,Zo;!function(t){t[t.CURRENT_STATE=1]="CURRENT_STATE",t[t.ERROR_STATE=2]="ERROR_STATE",t[t.RPC=3]="RPC",t[t.RPC_RESULT=4]="RPC_RESULT"}(qo||(qo={})),function(t){t[t.STOPPED=0]="STOPPED",t[t.READY=2]="READY",t[t.PROVISIONING=3]="PROVISIONING",t[t.PROVISIONED=4]="PROVISIONED"}(Zo||(Zo={}));const Xo={0:"NO_ERROR",1:"INVALID_RPC_PACKET",2:"UNKNOWN_RPC_COMMAND",3:"UNABLE_TO_CONNECT",5:"BAD_HOSTNAME",254:"TIMEOUT",255:"UNKNOWN_ERROR"};class jo extends Error{constructor(){super("Port is not ready")}}const Jo=t=>"["+t.map((t=>((t,e=2)=>{let i=t.toString(16).toUpperCase();return i.startsWith("-")?"-0x"+i.substring(1).padStart(e,"0"):"0x"+i.padStart(e,"0")})(t))).join(", ")+"]",Qo=t=>t.sort(((t,e)=>t.name.toLocaleLowerCase().localeCompare(e.name.toLocaleLowerCase()))),tn=(t,e)=>{const i=new Map;for(const e of t)i.set(e.name,e);for(const t of e)i.set(t.name,t);return Qo(Array.from(i.values()))},en=(t,e)=>t.length!==e.length||t.some(((t,i)=>t.name!==e[i].name||t.rssi!==e[i].rssi||t.secured!==e[i].secured));class sn extends EventTarget{get error(){return this._error}set error(t){this._error=t,this.dispatchEvent(new CustomEvent("error-changed",{detail:this._error}))}get networkState(){return this._networkState}constructor(t,e){if(super(),this.port=t,this.logger=e,this._error=0,this._rpcLock=Promise.resolve(),null===t.readable)throw new Error("Port is not readable");if(null===t.writable)throw new Error("Port is not writable")}async initialize(t=1e3){if(this.logger.log("Initializing Improv Serial"),this._processInput(),void 0===this._reader)throw new jo;let e;try{await new Promise((async(i,s)=>{setTimeout((()=>s(new Error("Improv Wi-Fi Serial not detected"))),t),e=setInterval((()=>this._sendRPC(2,[])),1e3),await this.requestCurrentState(),i(void 0)})),clearInterval(e),await this.requestInfo()}catch(t){throw await this.close(),t}finally{clearInterval(e)}return this.info}async close(){this.stopNetworkStatePolling(),this._reader&&await new Promise((t=>{this._reader.cancel(),this.addEventListener("disconnect",t,{once:!0})}))}async requestCurrentState(t){var e;const i=new AbortController;let s;try{await new Promise(((e,r)=>{this.addEventListener("state-changed",(()=>{var t;2===(null===(t=this._rpcFeedback)||void 0===t?void 0:t.command)&&e()}),{signal:i.signal}),s=this._sendRPCWithResponse(2,[],t),s.catch(r)}))}catch(t){throw new Error(`Error fetching current state: ${t}`)}finally{i.abort()}this.state===Zo.PROVISIONED?this.nextUrl=(await s)[0]:null===(e=this._rpcFeedback)||void 0===e||e.resolve([])}async requestInfo(t){const e=await this._sendRPCWithResponse(3,[],t);this.info={firmware:e[0],version:e[1],name:e[3],chipFamily:e[2],osName:e.length>4?e[4]:null,osVersion:e.length>5?e[5]:null}}async provision(t,e,i){const s=new TextEncoder,r=s.encode(t),a=s.encode(e),o=[r.length,...r,a.length,...a],n=await this._sendRPCWithResponse(1,o,i);this.nextUrl=n[0]}async scan(t){const e=(await this._sendRPCWithMultipleResponses(4,[],t)).map((([t,e,i])=>({name:t,rssi:parseInt(e),secured:"NO"!==i})));return Qo(e)}subscribeSSIDs(t){let e,i,s=!0;const r=(async()=>{for(;s;){let r;try{r=await this.scan(3e4)}catch(i){this.logger.error("Error while scanning for Wi-Fi networks",i),s&&void 0===e&&t(null);break}if(!s)break;const a=void 0===e?r:tn(e,r);(void 0===e||en(e,a))&&(e=a,t(a)),await new Promise((t=>{i=t,setTimeout(t,3e3)}))}})();return()=>(s=!1,null==i||i(),r)}async getHostname(t){return(await this._sendRPCWithResponse(5,[],t))[0]}async setHostname(t,e){const i=new TextEncoder;return(await this._sendRPCWithResponse(5,[...i.encode(t)],e))[0]}async getDeviceName(t){return(await this._sendRPCWithResponse(6,[],t))[0]}async setDeviceName(t,e){const i=new TextEncoder,s=await this._sendRPCWithResponse(6,[...i.encode(t)],e);return this.info&&(this.info.name=s[0]),s[0]}requestNetworkState(t){return this._requestNetworkState(t,!1)}startNetworkStatePolling(t=2500,e=500){if(this._stopNetworkStatePolling||null===this.networkState||!this._reader)return;let i,s=!0;this._stopNetworkStatePolling=()=>{s=!1,null==i||i()},(async()=>{for(;s;){try{await this._requestNetworkState(e,!0)}catch(t){if(null===this.networkState)break;this.logger.debug(`Failed to fetch network state: ${t}`)}if(!s)break;await new Promise((e=>{i=e,setTimeout(e,t)}))}s&&(this._stopNetworkStatePolling=void 0)})()}stopNetworkStatePolling(){var t;null===(t=this._stopNetworkStatePolling)||void 0===t||t.call(this),this._stopNetworkStatePolling=void 0}async _requestNetworkState(t,e){let i;try{i=await this._sendRPCWithResponse(7,[],t,e)}catch(t){throw t===Xo[2]&&this._setNetworkState(null),t}const s=parseInt(i[0]),r={online:0!=(1&s),supportsWifi:0!=(2&s),supportsEthernet:0!=(4&s),supportsThread:0!=(8&s),supportsModem:0!=(16&s),urls:i.slice(1)};return this._setNetworkState(r),r}_setNetworkState(t){const e=this._networkState;this._networkState=t,e===t||null!=e&&null!=t&&((t,e)=>t.online===e.online&&t.supportsWifi===e.supportsWifi&&t.supportsEthernet===e.supportsEthernet&&t.supportsThread===e.supportsThread&&t.supportsModem===e.supportsModem&&t.urls.length===e.urls.length&&t.urls.every(((t,i)=>t===e.urls[i])))(e,t)||this.dispatchEvent(new CustomEvent("network-state-changed",{detail:t}))}_sendRPC(t,e){this.writePacketToStream(qo.RPC,[t,e.length,...e])}_enqueueRPC(t,e){const i=()=>this._awaitRPCResultWithTimeout(t(),e).finally((()=>{this._rpcFeedback=void 0})),s=this._rpcLock.then(i,i);return this._rpcLock=s.catch((()=>{})),s}_sendRPCWithResponse(t,e,i=3e4,s=!1){return this._enqueueRPC((()=>new Promise(((i,r)=>{this._rpcFeedback={command:t,resolve:i,reject:r,quiet:s},this._sendRPC(t,e)}))),i)}_sendRPCWithMultipleResponses(t,e,i=3e4){return this._enqueueRPC((()=>new Promise(((i,s)=>{this._rpcFeedback={command:t,resolve:i,reject:s,receivedData:[]},this._sendRPC(t,e)}))),i)}async _awaitRPCResultWithTimeout(t,e){if(!e)return await t;const i=setTimeout((()=>this._setError(254)),e);try{return await t}finally{clearTimeout(i)}}async _processInput(){this.logger.debug("Starting read loop"),this._reader=this.port.readable.getReader();try{let t,e=[],i=0;for(;;){const{value:s,done:r}=await this._reader.read();if(r)break;if(s&&0!==s.length)for(const r of s){if(!1===t){10===r&&(t=void 0);continue}if(!0===t){e.push(r),e.length===i&&(this._handleIncomingPacket(e),t=void 0,e=[]);continue}if(10===r){e=[];continue}if(e.push(r),9!==e.length)continue;if(t="IMPROV"===String.fromCharCode(...e.slice(0,6)),!t){e=[];continue}i=9+e[8]+1}}}catch(t){this.logger.error("Error while reading serial port",t)}finally{this._reader.releaseLock(),this._reader=void 0}this.logger.debug("Finished read loop"),this.stopNetworkStatePolling(),this.dispatchEvent(new Event("disconnect"))}_handleIncomingPacket(t){const e=t.slice(6),i=e[0],s=e[1],r=e[2],a=e.slice(3,3+r);if(this.logger.debug("PROCESS",{version:i,packetType:s,packetLength:r,data:Jo(a)}),1!==i)return void this.logger.error("Received unsupported version",i);let o=e[3+r],n=0;for(let e=0;e<t.length-1;e++)n+=t[e];if(n&=255,n===o)if(s===qo.CURRENT_STATE)this.state=a[0],this.state!==Zo.PROVISIONED&&(this.nextUrl=void 0),this.dispatchEvent(new CustomEvent("state-changed",{detail:this.state}));else if(s===qo.ERROR_STATE)this._setError(a[0]);else if(s===qo.RPC_RESULT){if(!this._rpcFeedback)return void this.logger.error("Received result while not waiting for one");const t=a[0];if(t!==this._rpcFeedback.command)return void this.logger.error(`Received result for command ${t} but expected ${this._rpcFeedback.command}`);const e=[],i=a[1],s=new TextDecoder("utf-8");let r=2;for(;r<2+i;)e.push(s.decode(new Uint8Array(a.slice(r+1,r+a[r]+1)))),r+=a[r]+1;"receivedData"in this._rpcFeedback?e.length>0?this._rpcFeedback.receivedData.push(e):this._rpcFeedback.resolve(this._rpcFeedback.receivedData):this._rpcFeedback.resolve(e)}else this.logger.error("Unable to handle packet",e);else this.logger.error(`Received invalid checksum ${o}. Expected ${n}`)}async writePacketToStream(t,e){const i=new Uint8Array([...Wo,t,e.length,...e,0,0]);i[i.length-2]=255&i.reduce(((t,e)=>t+e),0),i[i.length-1]=10,this.logger.debug("Writing to stream:",Jo(new Array(...i)));const s=this.port.writable.getWriter();await s.write(i);try{s.releaseLock()}catch(t){console.error("Ignoring release lock error",t)}}_setError(t){t>0&&this._rpcFeedback&&(this._rpcFeedback.reject(Xo[t]||`UNKNOWN_ERROR (${t})`),this._rpcFeedback.quiet)||(this.error=t)}}const rn=async(t,e)=>{await t.setRTS(!0),await wt(100),await e.after()};class an{constructor(){this._wanted=!1,this._handleVisibility=()=>{"visible"===document.visibilityState&&this._request()}}async acquire(){this._wanted||(this._wanted=!0,document.addEventListener("visibilitychange",this._handleVisibility),await this._request())}async release(){if(!this._wanted)return;this._wanted=!1,document.removeEventListener("visibilitychange",this._handleVisibility);const t=this._sentinel;this._sentinel=void 0;try{await(null==t?void 0:t.release())}catch(t){console.warn("Failed to release screen wake lock",t)}}async _request(){if("wakeLock"in navigator&&!this._sentinel)try{const t=await navigator.wakeLock.request("screen");if(!this._wanted)return void await t.release();this._sentinel=t,t.addEventListener("release",(()=>{this._sentinel===t&&(this._sentinel=void 0)}))}catch(t){console.warn("Failed to acquire screen wake lock",t)}}}const on=(t,e="")=>{const i=new Blob([t],{type:"text/plain"}),s=URL.createObjectURL(i);((t,e="")=>{const i=document.createElement("a");i.target="_blank",i.href=t,i.download=e,document.body.appendChild(i),i.dispatchEvent(new MouseEvent("click")),document.body.removeChild(i)})(s,e),setTimeout((()=>URL.revokeObjectURL(s)),0)};console.log("ESP Web Tools 10.5.2 by Open Home Foundation; https://esphome.github.io/esp-web-tools/");const nn="⚠️";class ln extends s{constructor(){super(...arguments),this.logger=console,this._state="DASHBOARD",this._installErase=!1,this._installConfirmed=!1,this._provisionForce=!1,this._wasProvisioned=!1,this._busy=!1,this._selectedSsid=null,this._manualSsid="",this._bodyOverflow=null,this._viewportListening=!1,this._wakeLock=new an,this._handleDisconnect=()=>{this._state="ERROR",this._error="Disconnected"},this._updateViewportVars=()=>{const t=window.visualViewport;this.style.setProperty("--ewt-vv-height",`${t.height}px`),this.style.setProperty("--ewt-vv-top",`${t.offsetTop}px`)}}render(){if(!this.port)return r``;let t,e,i=!1;return void 0===this._client&&"INSTALL"!==this._state&&"LOGS"!==this._state?this._error?[t,e]=this._renderError(this._error):e=this._renderProgress("Connecting"):"INSTALL"===this._state?[t,e,i]=this._renderInstall():"ASK_ERASE"===this._state?[t,e]=this._renderAskErase():"ERROR"===this._state?[t,e]=this._renderError(this._error):"DASHBOARD"===this._state?[t,e,i]=this._client?this._renderDashboard():this._renderDashboardNoImprov():"PROVISION"===this._state?[t,e]=this._renderProvision():"LOGS"===this._state&&([t,e]=this._renderLogs()),r`
      <ew-dialog
        open
        .heading=${t}
        @cancel=${this._preventDefault}
        @closed=${this._handleClose}
      >
        ${t?r`<div slot="headline">${t}</div>`:""}
        ${i?r`
                <ew-icon-button slot="headline" @click=${this._closeDialog}>
                  ${Fo}
                </ew-icon-button>
              `:""}
        ${e}
      </ew-dialog>
    `}_renderProgress(t,e){return r`
      <ewt-page-progress
        slot="content"
        .label=${t}
        .progress=${e}
      ></ewt-page-progress>
    `}_renderError(t){return["Error",r`
      <ewt-page-message
        slot="content"
        .icon=${nn}
        .label=${t}
      ></ewt-page-message>
      <div slot="actions">
        <ew-text-button @click=${this._closeDialog}>Close</ew-text-button>
      </div>
    `]}_renderDashboard(){const t=this._manifest.name;let e;return e=r`
      <div slot="content">
        <ew-list>
          <ew-list-item>
            <div slot="headline">Connected to ${this._info.name}</div>
            <div slot="supporting-text">
              ${this._info.firmware}&nbsp;${this._info.version}
              (${this._info.chipFamily})
            </div>
          </ew-list-item>
          ${this._isSameVersion?"":r`
                  <ew-list-item
                    type="button"
                    @click=${()=>{this._isSameFirmware?this._startInstall(!1):this._manifest.new_install_prompt_erase?this._state="ASK_ERASE":this._startInstall(!0)}}
                  >
                    ${Go}
                    <div slot="headline">
                      ${this._isSameFirmware?`Update ${this._manifest.name}`:`Install ${this._manifest.name}`}
                    </div>
                  </ew-list-item>
                `}
          ${void 0===this._deviceUrl?"":r`
                  <ew-list-item
                    type="link"
                    href=${this._deviceUrl}
                    target="_blank"
                  >
                    ${Ho}
                    <div slot="headline">Visit Device</div>
                  </ew-list-item>
                `}
          ${this._manifest.home_assistant_domain&&this._isOnline?r`
                  <ew-list-item
                    type="link"
                    href=${`https://my.home-assistant.io/redirect/config_flow_start/?domain=${this._manifest.home_assistant_domain}`}
                    target="_blank"
                  >
                    ${zo}
                    <div slot="headline">Add to Home Assistant</div>
                  </ew-list-item>
                `:""}
          <ew-list-item
            type="button"
            @click=${()=>{this._state="PROVISION",this._client.state===Zo.PROVISIONED&&(this._provisionForce=!0)}}
          >
            ${$o}
            <div slot="headline">
              ${this._client.state===Zo.PROVISIONED?"Change Wi-Fi":"Connect to Wi-Fi"}
            </div>
          </ew-list-item>
          <ew-list-item
            type="button"
            @click=${async()=>{const t=this._client;t&&(await this._closeClientWithoutEvents(t),await wt(100)),this._client=void 0,this._state="LOGS"}}
          >
            ${Ko}
            <div slot="headline">Logs & Console</div>
          </ew-list-item>
          ${this._isSameFirmware&&this._manifest.funding_url?r`
                  <ew-list-item
                    type="link"
                    href=${this._manifest.funding_url}
                    target="_blank"
                  >
                    ${Vo}
                    <div slot="headline">Fund Development</div>
                  </ew-list-item>
                `:""}
          ${this._isSameVersion?r`
                  <ew-list-item
                    type="button"
                    class="danger"
                    @click=${()=>this._startInstall(!0)}
                  >
                    ${Yo}
                    <div slot="headline">Erase User Data</div>
                  </ew-list-item>
                `:""}
        </ew-list>
      </div>
    `,[t,e,!0]}_renderDashboardNoImprov(){const t=this._manifest.name;let e;return e=r`
      <div slot="content">
        <ew-list>
          <ew-list-item
            type="button"
            @click=${()=>{this._manifest.new_install_prompt_erase?this._state="ASK_ERASE":this._startInstall(!0)}}
          >
            ${Go}
            <div slot="headline">${`Install ${this._manifest.name}`}</div>
          </ew-list-item>
          <ew-list-item
            type="button"
            @click=${async()=>{this._client=void 0,this._state="LOGS"}}
          >
            ${Ko}
            <div slot="headline">Logs & Console</div>
          </ew-list-item>
        </ew-list>
      </div>
    `,[t,e,!0]}_renderProvision(){var t;let e,i="Configure Wi-Fi";if(this._busy)return[i,this._renderProgress("Trying to connect")];if(this._client.state===Zo.STOPPED)i=void 0,e=r`
        <div slot="content">
          <ewt-page-message
            .icon=${nn}
            .label=${r`The connected device has Wi-Fi turned off, so it can't
              be configured right now.<br />Enable the device's Wi-Fi, then try
              again.`}
          ></ewt-page-message>
        </div>
        <div slot="actions">
          <ew-text-button
            @click=${()=>{this._state="DASHBOARD"}}
          >
            Back
          </ew-text-button>
        </div>
      `;else if(this._provisionForce||this._client.state!==Zo.PROVISIONED)if(void 0===this._ssids)e=this._renderProgress("Scanning for networks");else{let i;switch(this._client.error){case 3:i="Unable to connect";break;case 254:i="Timeout";break;case 0:case 2:break;default:i=`Unknown error (${this._client.error})`}const s=null===(t=this._ssids)||void 0===t?void 0:t.find((t=>t.name===this._selectedSsid));e=r`
        <div slot="content">
          <div>Connect your device to the network to start using it.</div>
          ${i?r`<p class="error">${i}</p>`:""}
          ${null!==this._ssids?r`
                  <ew-filled-select
                    menu-positioning="fixed"
                    label="Network"
                    @change=${t=>{const e=t.target.selectedIndex;this._selectedSsid=e===this._ssids.length?null:this._ssids[e].name,this._manualSsid=""}}
                  >
                    ${this._ssids.map((t=>{const e=(i=t.rssi)>=-50?{icon:Do,class:"signal-excellent"}:i>=-60?{icon:Mo,class:"signal-good"}:i>=-70?{icon:ko,class:"signal-fair"}:{icon:Lo,class:"signal-weak"};var i;return r`
                        <ew-select-option
                          .selected=${s===t}
                          .value=${t.name}
                        >
                          <span slot="start" class=${e.class}>
                            ${e.icon}
                          </span>
                          <span slot="headline">${t.name}</span>
                          <span slot="end" class="network-details">
                            <span class="signal-strength">${t.rssi}dB</span>
                            <span
                              class=${t.secured?"lock-secured":"lock-unsecured"}
                            >
                              ${t.secured?Bo:No}
                            </span>
                          </span>
                        </ew-select-option>
                      `}))}
                    <ew-divider></ew-divider>
                    <ew-select-option .selected=${!s}>
                      Join other…
                    </ew-select-option>
                  </ew-filled-select>
                `:""}
          ${s?"":r`
                  <ew-filled-text-field
                    label="Network Name"
                    name="ssid"
                    .value=${this._manualSsid}
                  ></ew-filled-text-field>
                `}
          ${!s||s.secured?r`
                  <ew-filled-text-field
                    label="Password"
                    name="password"
                    type="password"
                    @keydown=${t=>{"Enter"===t.key&&this._doProvision()}}
                  ></ew-filled-text-field>
                `:""}
        </div>
        <div slot="actions">
          <ew-text-button
            @click=${()=>{this._state="DASHBOARD"}}
          >
            ${this._installState&&this._installErase?"Skip":"Back"}
          </ew-text-button>
          <ew-text-button @click=${this._doProvision}>Connect</ew-text-button>
        </div>
      `}else{i=void 0;const t=!this._wasProvisioned&&(void 0!==this._client.nextUrl||"home_assistant_domain"in this._manifest);e=r`
        <div slot="content">
          <ewt-page-message
            .icon=${"🎉"}
            label="Device connected to the network!"
          ></ewt-page-message>
          ${t?r`
                  <ew-list>
                    ${void 0===this._client.nextUrl?"":r`
                            <ew-list-item
                              type="link"
                              href=${this._client.nextUrl}
                              target="_blank"
                              @click=${()=>{this._state="DASHBOARD"}}
                            >
                              ${Ho}
                              <div slot="headline">Visit Device</div>
                            </ew-list-item>
                          `}
                    ${this._manifest.home_assistant_domain?r`
                            <ew-list-item
                              type="link"
                              href=${`https://my.home-assistant.io/redirect/config_flow_start/?domain=${this._manifest.home_assistant_domain}`}
                              target="_blank"
                              @click=${()=>{this._state="DASHBOARD"}}
                            >
                              ${zo}
                              <div slot="headline">Add to Home Assistant</div>
                            </ew-list-item>
                          `:""}
                    <ew-list-item
                      type="button"
                      @click=${()=>{this._state="DASHBOARD"}}
                    >
                      <div slot="start" class="fake-icon"></div>
                      <div slot="headline">Skip</div>
                    </ew-list-item>
                  </ew-list>
                `:""}
        </div>

        ${t?"":r`
                <div slot="actions">
                  <ew-text-button
                    @click=${()=>{this._state="DASHBOARD"}}
                  >
                    Continue
                  </ew-text-button>
                </div>
              `}
      `}return[i,e]}_renderAskErase(){return["Erase device",r`
      <div slot="content">
        <div>
          Do you want to erase the device before installing
          ${this._manifest.name}? All data on the device will be lost.
        </div>
        <label class="formfield">
          <ew-checkbox touch-target="wrapper" class="danger"></ew-checkbox>
          Erase device
        </label>
      </div>
      <div slot="actions">
        <ew-text-button
          @click=${()=>{this._state="DASHBOARD"}}
        >
          Back
        </ew-text-button>
        <ew-text-button
          @click=${()=>{const t=this.shadowRoot.querySelector("ew-checkbox");this._startInstall(t.checked)}}
        >
          Next
        </ew-text-button>
      </div>
    `]}_renderInstall(){let t,e;const i=!this._installErase&&this._isSameFirmware;if(!this._installConfirmed&&this._isSameVersion)t="Erase User Data",e=r`
        <div slot="content">
          Do you want to reset your device and erase all user data from your
          device?
        </div>
        <div slot="actions">
          <ew-text-button class="danger" @click=${this._confirmInstall}>
            Erase User Data
          </ew-text-button>
        </div>
      `;else if(this._installConfirmed)if(this._installState&&"initializing"!==this._installState.state&&"preparing"!==this._installState.state)if("erasing"===this._installState.state)t="Installing",e=this._renderProgress("Erasing");else if("writing"===this._installState.state||"finished"===this._installState.state&&void 0===this._client){let i,s;t="Installing","finished"===this._installState.state?s="Wrapping up":this._installState.details.percentage<4?s="Installing":i=this._installState.details.percentage,e=this._renderProgress(r`
          ${s?r`${s}<br />`:""}
          <br />
          This will take
          ${"ESP8266"===this._installState.chipFamily?"a minute":"2 minutes"}.<br />
          Keep this page visible for fastest installation.
        `,i)}else if("finished"===this._installState.state){t=void 0;const i=null!==this._client;e=r`
        <ewt-page-message
          slot="content"
          .icon=${"🎉"}
          label="Installation complete!"
        ></ewt-page-message>

        <div slot="actions">
          <ew-text-button
            @click=${()=>{this._state=i&&this._installErase?"PROVISION":"DASHBOARD"}}
          >
            Next
          </ew-text-button>
        </div>
      `}else"error"===this._installState.state&&(t="Installation failed",e=r`
        <ewt-page-message
          slot="content"
          .icon=${nn}
          .label=${this._installState.message}
        ></ewt-page-message>
        <div slot="actions">
          <ew-text-button
            @click=${async()=>{this._initialize(),this._state="DASHBOARD"}}
          >
            Back
          </ew-text-button>
        </div>
      `);else t="Installing",e=this._renderProgress("Preparing installation");else{t="Confirm Installation";const s=i?"update to":"install";e=r`
        <div slot="content">
          ${i?r`Your device is running
                  ${this._info.firmware}&nbsp;${this._info.version}.<br /><br />`:""}
          Do you want to ${s}
          ${this._manifest.name}&nbsp;${this._manifest.version}?
          ${this._installErase?r`<br /><br />All data on the device will be erased.`:""}
        </div>
        <div slot="actions">
          <ew-text-button
            @click=${()=>{this._state="DASHBOARD"}}
          >
            Back
          </ew-text-button>
          <ew-text-button @click=${this._confirmInstall}>
            Install
          </ew-text-button>
        </div>
      `}return[t,e,!1]}_renderLogs(){let t;return t=r`
      <div slot="content">
        <ewt-console .port=${this.port} .logger=${this.logger}></ewt-console>
      </div>
      <div slot="actions">
        <ew-text-button
          @click=${async()=>{await this.shadowRoot.querySelector("ewt-console").reset()}}
        >
          Reset Device
        </ew-text-button>
        <ew-text-button
          @click=${()=>{on(this.shadowRoot.querySelector("ewt-console").logs(),"esp-web-tools-logs.txt"),this.shadowRoot.querySelector("ewt-console").reset()}}
        >
          Download Logs
        </ew-text-button>
        <ew-text-button
          @click=${async()=>{await this.shadowRoot.querySelector("ewt-console").disconnect(),this._state="DASHBOARD",this._initialize()}}
        >
          Back
        </ew-text-button>
      </div>
    `,["Logs",t]}willUpdate(t){t.has("_state")&&("ERROR"!==this._state&&(this._error=void 0),"PROVISION"===this._state?(this._ssids=void 0,this._client&&(this._client.error=0)):this._provisionForce=!1,"INSTALL"===this._state&&(this._installConfirmed=!1,this._installState=void 0))}get _isOnline(){var t,e,i;return(null===(t=this._client)||void 0===t?void 0:t.state)===Zo.PROVISIONED||!0===(null===(i=null===(e=this._client)||void 0===e?void 0:e.networkState)||void 0===i?void 0:i.online)}get _deviceUrl(){var t,e,i,s;return null!==(s=null===(t=this._client)||void 0===t?void 0:t.nextUrl)&&void 0!==s?s:null===(i=null===(e=this._client)||void 0===e?void 0:e.networkState)||void 0===i?void 0:i.urls[0]}get _showsProvisionForm(){var t;const e=null===(t=this._client)||void 0===t?void 0:t.state;return void 0!==e&&e!==Zo.STOPPED&&(this._provisionForce||e!==Zo.PROVISIONED)}_syncScanning(){const t="PROVISION"===this._state&&!this._busy&&this._showsProvisionForm;t!==!!this._unsubSSIDs&&(t?(this._scanGraceTimeout=setTimeout((()=>{this._scanGraceTimeout=void 0,void 0===this._ssids&&"PROVISION"===this._state&&(this._ssids=[],this._selectedSsid=null)}),9100),this._unsubSSIDs=this._client.subscribeSSIDs((t=>{void 0===this._ssids&&0===(null==t?void 0:t.length)&&this._scanGraceTimeout||null===t&&this._ssids||(void 0===this._ssids?this._selectedSsid=null===t?null:(t=>t.length?t.reduce(((t,e)=>e.rssi>t.rssi?e:t)).name:null)(t):null===this._selectedSsid||(null==t?void 0:t.some((t=>t.name===this._selectedSsid)))||(this._manualSsid=this._selectedSsid,this._selectedSsid=null),this._ssids=t)}))):this._stopScanning())}async _stopScanning(){clearTimeout(this._scanGraceTimeout),this._scanGraceTimeout=void 0;const t=this._unsubSSIDs;t&&(this._unsubSSIDs=void 0,await t())}firstUpdated(t){super.firstUpdated(t),this._bodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this._initialize()}updated(t){var e,i;super.updated(t),t.has("_state")&&(this.setAttribute("state",this._state),this._syncViewportTracking()),this._syncScanning(),"DASHBOARD"===this._state?null===(e=this._client)||void 0===e||e.startNetworkStatePolling():null===(i=this._client)||void 0===i||i.stopNetworkStatePolling(),"PROVISION"===this._state&&(t.has("_selectedSsid")&&null===this._selectedSsid?this._focusFormElement("ew-filled-text-field[name=ssid]"):t.has("_ssids")&&void 0===t.get("_ssids")&&this._focusFormElement())}_focusFormElement(t="ew-filled-text-field, ew-filled-select"){const e=this.shadowRoot.querySelector(t);e&&e.updateComplete.then((()=>setTimeout((()=>e.focus()),100)))}async _initialize(t=!1){if(null===this.port.readable||null===this.port.writable)return this._state="ERROR",void(this._error="Serial port is not readable/writable. Close any other application using it and try again.");try{this._manifest=await(async t=>{const e=new URL(t,location.toString()).toString(),i=await fetch(e),s=await i.json();return"new_install_skip_erase"in s&&(console.warn('Manifest option "new_install_skip_erase" is deprecated. Use "new_install_prompt_erase" instead.'),s.new_install_skip_erase&&(s.new_install_prompt_erase=!0)),s})(this.manifestPath)}catch(t){return this._state="ERROR",void(this._error="Failed to download manifest")}if(0===this._manifest.new_install_improv_wait_time)return void(this._client=null);const e=new sn(this.port,this.logger);e.addEventListener("state-changed",(()=>{this.requestUpdate()})),e.addEventListener("error-changed",(()=>this.requestUpdate())),e.addEventListener("network-state-changed",(()=>this.requestUpdate()));try{const i=t?void 0!==this._manifest.new_install_improv_wait_time?1e3*this._manifest.new_install_improv_wait_time:1e4:1500;this._info=await e.initialize(i),this._client=e,e.addEventListener("disconnect",this._handleDisconnect)}catch(t){this._info=void 0,t instanceof jo?(this._state="ERROR",this._error="Serial port is not ready. Close any other application using it and try again."):(this._client=null,this.logger.error("Improv initialization failed.",t))}}_startInstall(t){this._state="INSTALL",this._installErase=t,this._installConfirmed=!1}async _confirmInstall(){this._installConfirmed=!0,this._installState=void 0,this._client&&await this._closeClientWithoutEvents(this._client),this._client=void 0,await this.port.close(),this._wakeLock.acquire(),(async(t,e,i,s,r)=>{let a,o;const n=e=>t({...e,manifest:s,build:a,chipFamily:o}),l=new Zs(e),d=e.getInfo(),c=d&&12346===d.usbVendorId&&void 0!==d.usbProductId&&[4097,4098,4099,2,3].includes(d.usbProductId),h=new ra({transport:l,baudrate:115200,enableTracing:!1});window.esploader=h,n({state:"initializing",message:"Initializing...",details:{done:!1}});try{await h.main(),await h.flashId()}catch(t){return console.error(t),n({state:"error",message:"Failed to initialize. Try resetting your device or holding the BOOT button while clicking INSTALL.",details:{error:"failed_initialize",details:t}}),await rn(l,h),void await l.disconnect()}o=h.chip.CHIP_NAME,n({state:"initializing",message:`Initialized. Found ${o}`,details:{done:!0}});const _=c?"cdc":"uart";if(a=s.builds.find((t=>t.chipFamily===o&&t.serialType===_))||s.builds.find((t=>t.chipFamily===o&&void 0===t.serialType)),!a)return n({state:"error",message:`Your ${o} board is not supported.`,details:{error:"not_supported",details:o}}),await rn(l,h),void await l.disconnect();n({state:"preparing",message:"Preparing installation...",details:{done:!1}});const p=i.startsWith("blob:")||i.startsWith("data:")?location.toString():new URL(i,location.toString()).toString(),u=a.parts.map((async t=>{const e=new URL(t.path,p).toString(),i=await fetch(e);if(!i.ok)throw new Error(`Downloading firmware ${t.path} failed: ${i.status}`);const s=new FileReader,r=await i.blob();return new Promise((t=>{s.addEventListener("load",(()=>t(s.result))),s.readAsArrayBuffer(r)}))})),f=[];let E=0;for(let t=0;t<u.length;t++)try{const e=await u[t],i=new Uint8Array(e,0,e.byteLength);f.push({data:i,address:a.parts[t].offset}),E+=i.length}catch(t){return n({state:"error",message:t.message,details:{error:"failed_firmware_download",details:t.message}}),await rn(l,h),void await l.disconnect()}n({state:"preparing",message:"Installation prepared",details:{done:!0}}),r&&(n({state:"erasing",message:"Erasing device...",details:{done:!1}}),await h.eraseFlash(),n({state:"erasing",message:"Device erased",details:{done:!0}})),n({state:"writing",message:"Writing progress: 0%",details:{bytesTotal:E,bytesWritten:0,percentage:0}});let g=0;try{await h.writeFlash({fileArray:f,flashSize:"keep",flashMode:"keep",flashFreq:"keep",eraseAll:!1,compress:!0,reportProgress:(t,e,i)=>{const s=e/i*f[t].data.length,r=Math.floor((g+s)/E*100);e!==i?n({state:"writing",message:`Writing progress: ${r}%`,details:{bytesTotal:E,bytesWritten:g+e,percentage:r}}):g+=s}})}catch(t){return n({state:"error",message:t.message,details:{error:"write_failed",details:t}}),await rn(l,h),void await l.disconnect()}n({state:"writing",message:"Writing complete",details:{bytesTotal:E,bytesWritten:g,percentage:100}}),await rn(l,h),console.log("DISCONNECT"),await l.disconnect(),n({state:"finished",message:"All done!"})})((t=>{this._installState=t,"finished"===t.state?wt(100).then((()=>this.port.open({baudRate:115200,bufferSize:8192}))).then((()=>this._initialize(!0))).then((()=>this.requestUpdate())):"error"===t.state&&wt(100).then((()=>this.port.open({baudRate:115200,bufferSize:8192})))}),this.port,this.manifestPath,this._manifest,this._installErase).finally((()=>this._wakeLock.release()))}async _doProvision(){var t;const e=null===this._selectedSsid?this.shadowRoot.querySelector("ew-filled-text-field[name=ssid]").value:this._selectedSsid,i=(null===(t=this.shadowRoot.querySelector("ew-filled-text-field[name=password]"))||void 0===t?void 0:t.value)||"";this._busy=!0,this._wasProvisioned=this._client.state===Zo.PROVISIONED,await this._stopScanning();try{await this._client.provision(e,i,45e3)}catch(t){return}finally{this._busy=!1,this._provisionForce=!1}}_closeDialog(){this.shadowRoot.querySelector("ew-dialog").close()}async _handleClose(){this._client&&await this._closeClientWithoutEvents(this._client),((t,e,i,s)=>{s=s||{};const r=new CustomEvent(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed,detail:i});t.dispatchEvent(r)})(this,"closed"),document.body.style.overflow=this._bodyOverflow,this.parentNode.removeChild(this)}get _isSameFirmware(){var t;return!!this._info&&((null===(t=this.overrides)||void 0===t?void 0:t.checkSameFirmware)?this.overrides.checkSameFirmware(this._manifest,this._info):this._info.firmware===this._manifest.name)}get _isSameVersion(){return this._isSameFirmware&&this._info.version===this._manifest.version}async _closeClientWithoutEvents(t){await this._stopScanning(),t.removeEventListener("disconnect",this._handleDisconnect),await t.close()}disconnectedCallback(){super.disconnectedCallback(),this._wakeLock.release(),this._syncViewportTracking()}_syncViewportTracking(){const t=window.visualViewport,e=this.isConnected&&"LOGS"===this._state&&!!t;e!==this._viewportListening&&(this._viewportListening=e,e?(t.addEventListener("resize",this._updateViewportVars),t.addEventListener("scroll",this._updateViewportVars),this._updateViewportVars()):(null==t||t.removeEventListener("resize",this._updateViewportVars),null==t||t.removeEventListener("scroll",this._updateViewportVars),this.style.removeProperty("--ewt-vv-height"),this.style.removeProperty("--ewt-vv-top")))}_preventDefault(t){t.preventDefault()}}ln.styles=[D,a`
      :host {
        --mdc-dialog-max-width: 390px;
      }
      div[slot="headline"] {
        padding-right: 48px;
      }
      ew-icon-button[slot="headline"] {
        position: absolute;
        right: 4px;
        top: 8px;
      }
      ew-icon-button[slot="headline"] svg {
        padding: 8px;
        color: var(--text-color);
      }
      .dialog-nav svg {
        color: var(--text-color);
      }
      .table-row {
        display: flex;
      }
      .table-row.last {
        margin-bottom: 16px;
      }
      .table-row svg {
        width: 20px;
        margin-right: 8px;
      }
      ew-filled-text-field,
      ew-filled-select {
        display: block;
        margin-top: 16px;
      }
      ew-select-option svg {
        width: 24px;
        height: 24px;
        display: block;
      }
      .network-details {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-left: 16px;
        color: var(--text-color);
        font-size: 12px;
      }
      .signal-excellent,
      .signal-good,
      .lock-secured {
        color: #34a853;
      }
      .signal-fair {
        color: #fbbc04;
      }
      .signal-weak,
      .lock-unsecured {
        color: var(--danger-color);
      }
      label.formfield {
        display: inline-flex;
        align-items: center;
        padding-right: 8px;
      }
      ew-list {
        margin: 0 -24px;
        padding: 0;
      }
      ew-list-item svg {
        height: 24px;
      }
      ewt-page-message + ew-list {
        padding-top: 16px;
      }
      .fake-icon {
        width: 24px;
      }
      .error {
        color: var(--danger-color);
      }
      .danger {
        --mdc-theme-primary: var(--danger-color);
        --mdc-theme-secondary: var(--danger-color);
        --md-sys-color-primary: var(--danger-color);
        --md-sys-color-on-surface: var(--danger-color);
      }
      button.link {
        background: none;
        color: inherit;
        border: none;
        padding: 0;
        font: inherit;
        text-align: left;
        text-decoration: underline;
        cursor: pointer;
      }
      :host([state="LOGS"]) ew-dialog {
        max-width: 90vw;
        max-height: 90vh;
      }
      ewt-console {
        width: calc(80vw - 48px);
        height: calc(90vh - 168px);
      }
      /* On phones the logs view takes the whole screen */
      @media (max-width: 600px) {
        :host([state="LOGS"]) ew-dialog {
          width: 100dvw;
          height: var(--ewt-vv-height, 100dvh);
          max-width: 100dvw;
          max-height: var(--ewt-vv-height, 100dvh);
          margin: var(--ewt-vv-top, 0px) 0 0;
        }
        :host([state="LOGS"]) div[slot="headline"] {
          padding: 12px 16px 0;
        }
        :host([state="LOGS"]) div[slot="content"] {
          padding: 8px 0 0;
        }
        :host([state="LOGS"]) div[slot="actions"] {
          padding: 8px;
        }
        :host([state="LOGS"]) ewt-console {
          width: 100%;
          /* headline + content padding + actions */
          height: calc(var(--ewt-vv-height, 100dvh) - 112px);
        }
      }
    `],e([g()],ln.prototype,"_client",void 0),e([g()],ln.prototype,"_state",void 0),e([g()],ln.prototype,"_installErase",void 0),e([g()],ln.prototype,"_installConfirmed",void 0),e([g()],ln.prototype,"_installState",void 0),e([g()],ln.prototype,"_provisionForce",void 0),e([g()],ln.prototype,"_error",void 0),e([g()],ln.prototype,"_busy",void 0),e([g()],ln.prototype,"_ssids",void 0),e([g()],ln.prototype,"_selectedSsid",void 0),customElements.define("ewt-install-dialog",ln);export{ln as EwtInstallDialog};