1import s from"./custom-html-element-Cddc4xm8.js";import{c as n}from"./exports-NHIMKJG4.js";import"./logger-pamvzmAu.js";import"./event-zU-Y6ZHH.js";class i extends s{constructor(){super(),this.storageId=this.getAttribute("storage-id"),this.form=this.querySelector("form")}connectedCallback(){this.ensureGlobalState()&&(this.loadStateIntoForm(),this.form.addEventListener("input",()=>this.updateStateFromForm()),document.addEventListener("state:change",t=>{t.detail.id===this.storageId&&this.loadStateIntoForm()}))}ensureGlobalState(){return!("WATERDROP"in window)||typeof window.WATERDROP.globalState!="object"?(n(new Error("Global state is not defined on window.WATERDROP.")),!1):!0}loadStateIntoForm(){if(!this.storageId){n(new Error("Storage ID is required."));return}const t=window.WATERDROP.globalState.getState(this.storageId);if(t){for(const[e,o]of Object.entries(t)){const a=this.form.querySelector(`[name="${e}"]`);if(a)a.value=o;else{const r=document.createElement("input");r.name=e,r.value=o,r.type=typeof o=="number"?"number":"text",this.form.appendChild(r)}}this.form.querySelectorAll("input").forEach(e=>{e.name in t||e.remove()})}}updateStateFromForm(){if(!this.storageId){n(new Error("Storage ID is required."));return}const t={};this.form.querySelectorAll("input").forEach(e=>{t[e.name]=e.type==="number"?Number(e.value):e.value}),window.WATERDROP.globalState.setState(this.storageId,t)}}customElements.get("form-sync")||customElements.define("form-sync",i);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.