1import { a as e, d as t, i as n, l as r, n as i, o as a, r as o, t as s, u as c } from "./decorate-HDQkEE-3.js"; 2import { t as l } from "./constants-CNLCsQ16.js"; 3//#region src/collapsible-element.ts 4var u = class extends a { 5 constructor(...e) { 6 super(...e), this.isCollapsed = !1; 7 } 8 connectedCallback() { 9 this.querySelector("[slot=title]")?.addEventListener("click", () => { 10 this.isCollapsed = !this.isCollapsed; 11 }), super.connectedCallback(); 12 } 13 render() { 14 return r` 15 <slot name="title"></slot> 16 ${this.isCollapsed ? "" : r`<slot name="content"></slot>`} 17 `; 18 } 19}; 20s([n({ 21 type: Boolean, 22 attribute: "is-collapsed", 23 reflect: !0 24})], u.prototype, "isCollapsed", void 0), u = s([e(t.CollapsibleElement)], u); 25//#endregion 26//#region src/admin/data-loader.ts 27var d = class { 28 constructor() { 29 this.body = document.querySelector("body"), this.initialHref = document.location.href; 30 } 31 async fetchHtml(e, t) { 32 try { 33 let n = await fetch(e, { cache: t ? "no-store" : "default" }); 34 if (n.ok || n.status === 410) return n.text(); 35 } catch (e) { 36 console.log(e); 37 } 38 } 39 async loadDataFromUrl(e) { 40 let t = await this.fetchHtml(e ?? document.location.href, document.location.href === this.initialHref); 41 t && window.postMessage({ 42 action: "replace-html", 43 html: t 44 }), this.body?.classList.remove(l); 45 } 46}, f, p = class extends a { 47 static { 48 f = this; 49 } 50 static { 51 this.KEY_UP_DELAY_BEFORE_SEARCH = 750; 52 } 53 connectedCallback() { 54 super.connectedCallback(); 55 let e = this.querySelector("form"), n = this.querySelector("input"), r = e?.getAttribute("data-target"); 56 if (!e || !n || !r) throw Error(`A form with input and target ID is required for the ${t.AdminSearchForm}`); 57 this.form = e, this.input = n, this.target = document.getElementById(r), this.form.addEventListener("submit", (e) => this.onSubmit(e)), this.input.addEventListener("keyup", () => this.onKeyUp()), this.resetEvents(); 58 } 59 constructor() { 60 super(), this.dataLoader = new d(), this.isFetching = !1, window.addEventListener("message", (e) => { 61 e.data.action === "replace-html" && (this.setHtml(e.data.html), this.resetEvents()); 62 }); 63 } 64 render() { 65 return r`<slot></slot>`; 66 } 67 async onSubmit(e) { 68 e.preventDefault(), await this.search(); 69 } 70 onKeyUp() { 71 clearTimeout(this.keyUpTimer), this.keyUpTimer = setTimeout(() => this.search(), f.KEY_UP_DELAY_BEFORE_SEARCH); 72 } 73 async search() { 74 if (!this.input) return; 75 let e = this.input.value.trim(); 76 if (e !== this.lastSearch && !this.isFetching && (this.isFetching = !0, this.lastSearch = e, this.form)) { 77 let t = new URL(this.form.action); 78 e === "" ? t.searchParams.delete("search") : t.searchParams.set("search", e), this.toggleMainLoading(), await this.loadData(t.href), this.isFetching = !1; 79 } 80 } 81 async loadData(e) { 82 try { 83 await this.dataLoader.loadDataFromUrl(e); 84 } catch (e) { 85 console.error(e); 86 } 87 } 88 toggleMainLoading(e = !0) { 89 return document.querySelector("body")?.classList.toggle(l, e); 90 } 91 setHtml(e) { 92 this.target && (this.target.innerHTML = e); 93 } 94 resetEvents() { 95 this.target?.querySelectorAll("[data-result]").forEach((e) => { 96 e.addEventListener("click", () => { 97 let t = e.querySelector("[data-result-value]"); 98 t && this.onClickResult(e.getAttribute("data-result"), t.dataset.resultValue, t.dataset.resultLabel); 99 }); 100 }), document.querySelector("[data-cancel-tag-selection]")?.addEventListener("click", (e) => { 101 e.preventDefault(), this.setTag(null, ""); 102 }); 103 } 104 onClickResult(e, t, n) { 105 if (t) if (e === "log") { 106 let e = document.getElementById("alias"); 107 if (e) { 108 let n = e.value; 109 e.value = `${n}${n === "" ? "" : "\r\n"}${t}`; 110 } 111 } else e === "tag" && n && this.setTag(n, t); 112 } 113 setTag(e, t) { 114 let n = document.getElementById("tag"), r = document.querySelector("[data-selected-tag]"); 115 n.value = t, r.innerText = e ?? "---"; 116 } 117}; 118p = f = s([e(t.AdminSearchForm)], p); 119//#endregion 120//#region src/admin/json-validated-input.ts 121var m = class extends a { 122 constructor(...e) { 123 super(...e), this.jsonInput = "", this.error = "", this.successMessage = "", this.internals = this.attachInternals(), this.name = ""; 124 } 125 static { 126 this.formAssociated = !0; 127 } 128 static { 129 this.styles = c` 130 :host { 131 display:block; 132 position: relative; 133 } 134 135 textarea { 136 width: 100%; 137 height: 600px; 138 background: transparent; 139 border: none; 140 resize: none; 141 color: inherit; 142 font-family: monospace; 143 outline: none; 144 145 background: #414040; 146 color:white; 147 box-shadow:inset 0px 0px 0px 1px rgb(103, 102, 102); 148 border-radius:5px; 149 150 } 151 152 .error { 153 color: #ff6b6bc4; 154 } 155 156 .success {
157 color: var(--primary-color, #ee107e); 158 } 159 160 .buttons { 161 position: absolute; 162 top: 0; 163 right: 0; 164 } 165 button { 166 margin-top: 1rem; 167 margin-right: 0.5rem; 168 padding: 0.5rem 1rem; 169 border: none; 170 border-radius: var(--border-radius, 0.5rem); 171 background-color: var(--primary-color, #ee107e); 172 color: var(--text-on-primary-color, #fff); 173 font-weight: bold; 174 cursor: pointer; 175 } 176 177 button:hover { 178 background-color: var(--light-primary-color, #f13894); 179 } 180 `; 181 } 182 render() { 183 return r` 184 <textarea 185 @input=${this.handleInput} 186 @change=${this.handleChange} 187 .value=${this.jsonInput} 188 placeholder="Enter JSON here" 189 ></textarea> 190 <div class="error">${this.error}</div> 191 <div class="success">${this.successMessage}</div> 192 <div class="buttons"> 193 <button type="button" @click=${this.formatJson}>Format JSON</button> 194 <button type="button" @click=${this.validateJson}>Validate</button> 195 </div> 196 `; 197 } 198 handleInput(e) { 199 e.target instanceof HTMLTextAreaElement && (this.jsonInput = e.target.value, this.internals.setFormValue(this.jsonInput), this.error = "", this.successMessage = ""); 200 } 201 handleChange(e) { 202 this.internals.setValidity({ customError: !0 }, "validating...."), this.checkValidity(); 203 } 204 formatJson() { 205 try { 206 let e = JSON.parse(this.jsonInput); 207 return this.jsonInput = JSON.stringify(e, null, 2), this.internals.setFormValue(this.jsonInput), this.error = "", !0; 208 } catch (e) { 209 return this.error = `Invalid JSON - ${e.message}`, !1; 210 } 211 } 212 async validateJson() { 213 if (!this.formatJson()) return; 214 let e; 215 try { 216 e = JSON.parse(this.jsonInput); 217 } catch { 218 this.error = "Invalid JSON."; 219 return; 220 } 221 if (this.validation) try { 222 let t = await fetch(this.validation, { 223 method: "POST", 224 headers: { "Content-Type": "application/json" }, 225 body: JSON.stringify(e) 226 }), n = await t.json(); 227 return t.ok ? (this.successMessage = "Validation successful â", this.error = "", !0) : (this.error = n?.errors?.map((e) => `${e.property}: ${Object.values(e.constraints).join(", ")}`).join("\n") || n.message || `Error ${t.status}`, this.successMessage = "", !1); 228 } catch (e) { 229 return this.error = "Remote validation failed: " + e.message, this.successMessage = "", !1; 230 } 231 } 232 connectedCallback() { 233 if (super.connectedCallback(), !this.jsonInput && this.textContent) { 234 let e = this.textContent.trim(); 235 this.jsonInput = e, this.internals.setFormValue(e), this.textContent = "", this.checkValidity(); 236 } 237 } 238 reportValidity() { 239 return this.internals.reportValidity(); 240 } 241 async checkValidity() { 242 return await this.validateJson() ? (this.internals.setValidity({}), !0) : (this.internals.setValidity({ customError: !0 }, this.error), !1); 243 } 244}; 245s([n({ type: String })], m.prototype, "validation", void 0), s([o()], m.prototype, "jsonInput", void 0), s([o()], m.prototype, "error", void 0), s([o()], m.prototype, "successMessage", void 0), s([n({ type: String })], m.prototype, "name", void 0), m = s([e(t.JsonValidatedInput)], m); 246//#endregion 247//#region src/input-datetime-utc.ts 248var h = class extends a { 249 static get formAssociated() { 250 return !0; 251 } 252 get required() { 253 return this._required; 254 } 255 set required(e) { 256 this._required = e, this.internals.ariaRequired = e ? "true" : "false"; 257 } 258 get value() { 259 return new Date(this.inputValue).toISOString().substring(0, 16); 260 } 261 set value(e) { 262 this.inputValue = this.convertDate(e), this.internals.setFormValue(this.inputValue); 263 } 264 constructor() { 265 super(), this.inputClassname = "", this.inputValue = "", this.internals = this.attachInternals(); 266 } 267 connectedCallback() { 268 super.connectedCallback(), this.inputClassname = this.className, this.className = "", this.inputValue = this.convertDate(this.initialValue); 269 } 270 firstUpdated(e) { 271 super.firstUpdated(e), this.inputValue = this.convertDate(this.initialValue), this.internals.setFormValue(this.initialValue); 272 } 273 _onInput() { 274 this.internals.setFormValue(new Date(this.input.value).toISOString().substring(0, 16)); 275 } 276 render() { 277 return r` <input 278 type="datetime-local" 279 class="${this.inputClassname}" 280 .value="${this.inputValue}" 281 ?required="${this.required}"
282 @input="${this._onInput}" 283 novalidate 284 />`; 285 } 286 createRenderRoot() { 287 return this; 288 } 289 convertDate(e) { 290 let t = new Date(e); 291 return `${t.getFullYear()}-${this.ten(t.getMonth() + 1)}-${this.ten(t.getDate())}T${this.ten(t.getHours())}:${this.ten(t.getMinutes())}:${this.ten(t.getSeconds())}`; 292 } 293 ten(e) { 294 return `${e < 10 ? "0" : ""}${e}`; 295 } 296}; 297s([n({ 298 type: String, 299 attribute: "name", 300 reflect: !0 301})], h.prototype, "name", void 0), s([n({ 302 type: Boolean, 303 attribute: "required", 304 reflect: !0 305})], h.prototype, "_required", void 0), s([n({ 306 type: String, 307 attribute: "value" 308})], h.prototype, "initialValue", void 0), s([i("input")], h.prototype, "input", void 0), h = s([e(t.InputDatetimeUTC)], h); 309//#endregion 310export { p as AdminSearchForm, u as CollapsibleElement, h as InputDatetimeUTC, m as JsonValidatedInput };
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.