vendor: 14 bytes, lines 1-2
1(() => { 2 //
2../../vendor/larajax/larajax/resources/src/util/index.js 3 function dispatch(eventName, { target = document, detail = {}, bubbles = true, cancelable = true } = {}) { 4 const event = new CustomEvent(eventName, { detail, bubbles, cancelable }); 5 target.dispatchEvent(event); 6 return event; 7 } 8 function defer(callback) { 9 setTimeout(callback, 1); 10 } 11 function unindent(strings, ...values) { 12 const lines = trimLeft(interpolate(strings, values)).split("\n"); 13 const match = lines[0].match(/^\s+/); 14 const indent = match ? match[0].length : 0; 15 return lines.map((line) => line.slice(indent)).join("\n"); 16 } 17 function trimLeft(string) { 18 return string.replace(/^\n/, ""); 19 } 20 function interpolate(strings, values) { 21 return strings.reduce((result, string, i) => { 22 const value = values[i] == void 0 ? "" : values[i]; 23 return result + string + value; 24 }, ""); 25 } 26 function array(values) { 27 return Array.prototype.slice.call(values); 28 } 29 function uuid() { 30 return Array.apply(null, { length: 36 }).map((_, i) => { 31 if (i == 8 || i == 13 || i == 18 || i == 23) { 32 return "-"; 33 } else if (i == 14) { 34 return "4"; 35 } else if (i == 19) { 36 return (Math.floor(Math.random() * 4) + 8).toString(16); 37 } else { 38 return Math.floor(Math.random() * 15).toString(16); 39 } 40 }).join(""); 41 } 42 43
43// ../../vendor/larajax/larajax/resources/src/util/events.js 44 var namespaceRegex = /[^.]*(?=\..*)\.|.*/; 45 var stripNameRegex = /\..*/; 46 var stripUidRegex = /::\d+$/; 47 var eventRegistry = {}; 48 var uidEvent = 1; 49 var customEvents = { 50 mouseenter: "mouseover", 51 mouseleave: "mouseout" 52 }; 53 var nativeEvents = /* @__PURE__ */ new Set([ 54 "click", 55 "dblclick", 56 "mouseup", 57 "mousedown", 58 "contextmenu", 59 "mousewheel", 60 "DOMMouseScroll", 61 "mouseover", 62 "mouseout", 63 "mousemove", 64 "selectstart", 65 "selectend", 66 "keydown", 67 "keypress", 68 "keyup", 69 "orientationchange", 70 "touchstart", 71 "touchmove", 72 "touchend", 73 "touchcancel", 74 "pointerdown", 75 "pointermove", 76 "pointerup", 77 "pointerleave", 78 "pointercancel", 79 "gesturestart", 80 "gesturechange", 81 "gestureend", 82 "focus", 83 "blur", 84 "change", 85 "reset", 86 "select", 87 "submit", 88 "focusin", 89 "focusout", 90 "load", 91 "unload", 92 "beforeunload", 93 "resize", 94 "move", 95 "DOMContentLoaded", 96 "readystatechange", 97 "error", 98 "abort", 99 "scroll" 100 ]); 101 var Events = class { 102 static on(element, event, handler, delegationFunction, options) { 103 addHandler(element, event, handler, delegationFunction, options, false); 104 } 105 static one(element, event, handler, delegationFunction, options) { 106 addHandler(element, event, handler, delegationFunction, options, true); 107 } 108 static off(element, originalTypeEvent, handler, delegationFunction, options) { 109 if (typeof originalTypeEvent !== "string" || !element) { 110 return; 111 } 112 const [isDelegated, callable, typeEvent, opts] = normalizeParameters(originalTypeEvent, handler, delegationFunction, options); 113 const inNamespace = typeEvent !== originalTypeEvent; 114 const events = getElementEvents(element); 115 const storeElementEvent = events[typeEvent] || {}; 116 const isNamespace = originalTypeEvent.startsWith("."); 117 if (typeof callable !== "undefined") { 118 if (!storeElementEvent) { 119 return; 120 } 121 removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null, opts); 122 return; 123 } 124 if (isNamespace) { 125 for (const elementEvent of Object.keys(events)) { 126 removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1)); 127 } 128 } 129 for (const keyHandlers of Object.keys(storeElementEvent)) { 130 const handlerKey = keyHandlers.replace(stripUidRegex, ""); 131 if (!inNamespace || originalTypeEvent.includes(handlerKey)) { 132 const event = storeElementEvent[keyHandlers]; 133 removeHandler(element, events, typeEvent, event.callable, event.delegationSelector, opts); 134 } 135 } 136 } 137 static dispatch(eventName, { target = document, detail = {}, bubbles = true, cancelable = true } = {}) { 138 return dispatch(eventName, { target, detail, bubbles, cancelable }); 139 } 140 static trigger(target, eventName, { detail = {}, bubbles = true, cancelable = true } = {}) { 141 return dispatch(eventName, { target, detail, bubbles, cancelable }); 142 } 143 }; 144 function makeEventUid(element, uid) { 145 return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++; 146 } 147 function getElementEvents(element) { 148 const uid = makeEventUid(element); 149 element.uidEvent = uid; 150 eventRegistry[uid] = eventRegistry[uid] || {}; 151 return eventRegistry[uid]; 152 } 153 function findHandler(events, callable, delegationSelector = null) { 154 return Object.values(events).find((event) => event.callable === callable && event.delegationSelector === delegationSelector); 155 } 156 function normalizeParameters(originalTypeEvent, handler, delegationFunction, options) { 157 const isDelegated = typeof handler === "string"; 158 const callable = isDelegated ? delegationFunction : handler; 159 const opts = isDelegated ? options : delegationFunction; 160 let typeEvent = getTypeEvent(originalTypeEvent); 161 if (!nativeEvents.has(typeEvent)) { 162 typeEvent = originalTypeEvent; 163 } 164 return [isDelegated, callable, typeEvent, opts]; 165 } 166 function addHandler(element, originalTypeEvent, handler, delegationFunction, options, oneOff) { 167 if (typeof originalTypeEvent !== "string" || !element) { 168 return; 169 } 170 let [isDelegated, callable, typeEvent, opts] = normalizeParameters(originalTypeEvent, handler, delegationFunction, options); 171 if (originalTypeEvent in customEvents) { 172 const wrapFunction = (fn2) => { 173 return function(event) { 174 if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) { 175 return fn2.call(this, event); 176 } 177 }; 178 }; 179 callable = wrapFunction(callable); 180 } 181 const events = getElementEvents(element); 182 const handlers = events[typeEvent] || (events[typeEvent] = {}); 183 const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null); 184 if (previousFunction) { 185 previousFunction.oneOff = previousFunction.oneOff && oneOff; 186 return; 187 } 188 const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, "")); 189 const fn = isDelegated ? internalDelegationHandler(element, handler, callable) : internalHandler(element, callable); 190 fn.delegationSelector = isDelegated ? handler : null; 191 fn.callable = callable; 192 fn.oneOff = oneOff; 193 fn.uidEvent = uid; 194 handlers[uid] = fn; 195 element.addEventListener(typeEvent, fn, opts); 196 } 197 function removeHandler(element, events, typeEvent, handler, delegationSelector, options) { 198 const fn = findHandler(events[typeEvent], handler, delegationSelector); 199 if (!fn) { 200 return; 201 } 202 element.removeEventListener(typeEvent, fn, options); 203 delete events[typeEvent][fn.uidEvent]; 204 } 205 function internalHandler(element, fn) { 206 return function handler(event) { 207 event.delegateTarget = element; 208 if (handler.oneOff) { 209 Events.off(element, event.type, fn); 210 } 211 return fn.apply(element, [event]); 212 }; 213 } 214 function internalDelegationHandler(element, selector, fn) { 215 return function handler(event) { 216 const domElements = element.querySelectorAll(selector); 217 for (let { target } = event; target && target !== this; target = target.parentNode) { 218 for (const domElement of domElements) { 219 if (domElement !== target) { 220 continue; 221 } 222 event.delegateTarget = target; 223 if (handler.oneOff) { 224 Events.off(element, event.type, selector, fn); 225 } 226 return fn.apply(target, [event]); 227 } 228 } 229 }; 230 } 231 function removeNamespacedHandlers(element, events, typeEvent, namespace) { 232 const storeElementEvent = events[typeEvent] || {}; 233 for (const handlerKey of Object.keys(storeElementEvent)) { 234 if (handlerKey.includes(namespace)) { 235 const event = storeElementEvent[handlerKey]; 236 removeHandler(element, events, typeEvent, event.callable, event.delegationSelector); 237 } 238 } 239 } 240 function getTypeEvent(event) { 241 event = event.replace(stripNameRegex, ""); 242 return customEvents[event] || event; 243 } 244 245
245// ../../vendor/larajax/larajax/resources/src/request/envelope.js 246 var Envelope = class { 247 constructor(response = {}, status = 200) { 248 const { 249 __ajax: body, 250 ...data 251 } = response; 252 this.ok = !!body.ok; 253 this.severity = body.severity || "info"; 254 this.message = body.message ?? null; 255 this.data = data || {}; 256 this.invalid = body.invalid || {}; 257 this.ops = Array.isArray(body.ops) ? body.ops : []; 258 this.redirect = null; 259 this.status = status; 260 } 261 isFatal() { 262 return this.severity === "fatal" || this.status >= 500 && this.status <= 599; 263 } 264 isError() { 265 return this.severity === "error" || this.isFatal() || this.ok === false; 266 } 267 getMessage() { 268 return this.message; 269 } 270 getInvalid() { 271 return this.invalid || {}; 272 } 273 getData() { 274 return this.data || {}; 275 } 276 getStatus() { 277 return this.status; 278 } 279 getSeverity() { 280 return this.severity; 281 } 282 getOps(type) { 283 if (!type) { 284 return this.ops; 285 } 286 return this.ops.filter((o) => o?.op === type); 287 } 288 getFlash() { 289 return this.getOps("flash").map(({ level = "info", text = "" }) => ({ level, text })); 290 } 291 getBrowserEvents() { 292 return this.getOps("dispatch").map(({ selector = null, event, detail, async }) => ({ 293 selector, 294 event, 295 detail, 296 async 297 })); 298 } 299 getDomPatches() { 300 return this.getOps("patchDom").map(({ selector, html = "", swap = "update" }) => ({ 301 selector, 302 html, 303 swap 304 })); 305 } 306 getPartials() { 307 return this.getOps("partial").map(({ name, html = "" }) => ({ name, html })); 308 } 309 getAssets() { 310 const out = { js: [], css: [], img: [] }; 311 const seen = { js: /* @__PURE__ */ new Set(), css: /* @__PURE__ */ new Set(), img: /* @__PURE__ */ new Set() }; 312 for (const { type, assets = [] } of this.getOps("loadAssets")) { 313 if (!out[type]) { 314 continue; 315 } 316 for (const asset of assets) { 317 if (asset.inline) { 318 out[type].push(asset); 319 continue; 320 } 321 const url = typeof asset === "string" ? asset : asset.url; 322 if (!seen[type].has(url)) { 323 seen[type].add(url); 324 out[type].push(typeof asset === "string" ? { url: asset } : asset); 325 } 326 } 327 } 328 return out; 329 } 330 getRedirectUrl() { 331 const op = this.getOps("redirect")[0]; 332 return op?.url || this.redirect || null; 333 } 334 getReload() { 335 return this.getOps("reload")[0] || null; 336 } 337 }; 338 339
339// ../../vendor/larajax/larajax/resources/src/request/options.js 340 var Options = class { 341 constructor(handler, options) { 342 if (!handler) { 343 throw new Error("The request handler name is not specified."); 344 } 345 if (!handler.match(/^(?:\w+\:{2})?on*/)) { 346 throw new Error('Invalid handler name. The correct handler name format is: "onEvent".'); 347 } 348 if (typeof FormData === "undefined") { 349 throw new Error("The browser does not support the FormData interface."); 350 } 351 this.options = options; 352 this.handler = handler; 353 } 354 static fetch(handler, options) { 355 return new this(handler, options).getRequestOptions(); 356 } 357 // Public 358 getRequestOptions() { 359 return { 360 method: "POST", 361 url: this.options.url ? this.options.url : window.location.href, 362 headers: this.buildHeaders() 363 }; 364 } 365 // Private 366 buildHeaders() { 367 const { handler, options } = this; 368 const headers = { 369 "X-Requested-With": "XMLHttpRequest", 370 "X-AJAX-HANDLER": handler 371 }; 372 if (!options.files) { 373 headers["Content-Type"] = options.bulk ? "application/json" : "application/x-www-form-urlencoded"; 374 } 375 if (options.flash) { 376 headers["X-AJAX-FLASH"] = 1; 377 } 378 if (options.partial) { 379 headers["X-AJAX-PARTIAL"] = options.partial; 380 } 381 var partials = this.extractPartials(options.update, options.partial); 382 if (partials) { 383 headers["X-AJAX-PARTIALS"] = partials; 384 } 385 var xsrfToken = this.getXSRFToken(); 386 if (xsrfToken) { 387 headers["X-XSRF-TOKEN"] = xsrfToken; 388 } 389 var csrfToken = this.getCSRFToken(); 390 if (csrfToken) { 391 headers["X-CSRF-TOKEN"] = csrfToken; 392 } 393 if (options.headers && options.headers.constructor === {}.constructor) { 394 Object.assign(headers, options.headers); 395 } 396 return headers; 397 } 398 extractPartials(update = {}, selfPartial) { 399 var result = []; 400 if (update) { 401 if (typeof update !== "object") { 402 throw new Error("Invalid update value. The correct format is an object ({...})"); 403 } 404 for (var partial in update) { 405 if (partial === "_self" && selfPartial) { 406 result.push(selfPartial); 407 } else { 408 result.push(partial); 409 } 410 } 411 } 412 return result.join("&"); 413 } 414 getCSRFToken() { 415 var tag = document.querySelector('meta[name="csrf-token"]'); 416 return tag ? tag.getAttribute("content") : null; 417 } 418 getXSRFToken() { 419 var cookieValue = null; 420 if (document.cookie && document.cookie != "") { 421 var cookies = document.cookie.split(";"); 422 for (var i = 0; i < cookies.length; i++) { 423 var cookie = cookies[i].replace(/^([\s]*)|([\s]*)$/g, ""); 424 if (cookie.substring(0, 11) == "XSRF-TOKEN=") { 425 cookieValue = decodeURIComponent(cookie.substring(11)); 426 break; 427 } 428 } 429 } 430 return cookieValue; 431 } 432 }; 433 434
434// ../../vendor/larajax/larajax/resources/src/request/asset-manager.js 435 var AssetManager = class _AssetManager { 436 /** 437 * Load a collection of assets. 438 * @param {{js?: Array<string|{url: string, attributes?: object}>, css?: Array<string|{url: string, attributes?: object}>, img?: Array<string|{url: string, attributes?: object}>}} collection 439 * @param {(err?: Error) => void} [callback] // optional; called on success or with error 440 * @returns {Promise<void>} 441 */ 442 static load(collection = {}, callback) { 443 const manager = new _AssetManager(), promise = manager.loadCollection(collection); 444 if (typeof callback === "function") { 445 promise.then(() => callback()); 446 } 447 return promise; 448 } 449 async loadCollection(collection = {}) { 450 const jsList = (collection.js ?? []).map(normalizeAsset).filter((asset) => asset.inline || !jsInDom(asset.url)); 451 const cssList = (collection.css ?? []).map(normalizeAsset).filter((asset) => !cssInDom(asset.url)); 452 const imgList = (collection.img ?? []).map(normalizeAsset); 453 if (!jsList.length && !cssList.length && !imgList.length) { 454 return; 455 } 456 await Promise.all([ 457 this.loadJavaScript(jsList), 458 Promise.all(cssList.map((asset) => this.loadStyleSheet(asset))), 459 this.loadImages(imgList) 460 ]); 461 } 462 loadStyleSheet(asset) { 463 const { url, attributes = {} } = asset; 464 return new Promise((resolve, reject) => { 465 if (cssInDom(url)) { 466 resolve(null); 467 return; 468 } 469 const el = document.createElement("link"); 470 el.rel = "stylesheet"; 471 el.type = "text/css"; 472 el.href = url; 473 for (const [key, value] of Object.entries(attributes)) { 474 if (value === true) { 475 el.setAttribute(key, ""); 476 } else if (value !== false && value != null) { 477 el.setAttribute(key, value); 478 } 479 } 480 el.onload = () => resolve(el); 481 el.onerror = () => reject(new Error(`Failed to load CSS: ${url}`)); 482 document.head.appendChild(el); 483 }); 484 } 485 // Sequential loading (safer for dependencies) 486 loadJavaScript(list) { 487 return list.reduce((p, asset) => { 488 if (asset.inline) { 489 return p.then(() => new Promise((resolve, reject) => { 490 const el = document.createElement("script"); 491 const attributes2 = asset.attributes || {}; 492 if (attributes2.type) { 493 el.type = attributes2.type; 494 } 495 for (const [key, value] of Object.entries(attributes2)) { 496 if (key === "type") continue; 497 if (value === true) el.setAttribute(key, ""); 498 else if (value !== false && value != null) el.setAttribute(key, value); 499 } 500 if (el.type === "module") { 501 const id = "_lj" + ++inlineModuleId; 502 window[id] = () => { 503 delete window[id]; 504 resolve(el); 505 }; 506 el.textContent = asset.inline + ` 507window['${id}']();`; 508 } else { 509 el.textContent = asset.inline; 510 } 511 document.head.appendChild(el); 512 if (el.type !== "module") { 513 resolve(el); 514 } 515 })); 516 } 517 const { url, attributes = {} } = asset; 518 return p.then(() => new Promise((resolve, reject) => { 519 if (jsInDom(url)) { 520 resolve(null); 521 return; 522 } 523 const el = document.createElement("script"); 524 if (attributes.type) { 525 el.type = attributes.type; 526 } else { 527 el.type = "text/javascript"; 528 } 529 el.src = url; 530 for (const [key, value] of Object.entries(attributes)) { 531 if (key === "type") continue; 532 if (value === true) { 533 el.setAttribute(key, ""); 534 } else if (value !== false && value != null) { 535 el.setAttribute(key, value); 536 } 537 } 538 el.onload = () => resolve(el); 539 el.onerror = () => reject(new Error(`Failed to load JS: ${url}`)); 540 document.head.appendChild(el); 541 })); 542 }, Promise.resolve()); 543 } 544 loadImages(list) { 545 if (!list.length) return Promise.resolve(); 546 return Promise.all(list.map((asset) => new Promise((resolve, reject) => { 547 const { url } = asset; 548 const img = new Image(); 549 img.onload = () => resolve(url); 550 img.onerror = () => reject(new Error(`Failed to load image: ${url}`)); 551 img.src = url; 552 }))); 553 } 554 }; 555 var inlineModuleId = 0; 556 function jsInDom(url) { 557 return !!document.querySelector(`head script[src="${htmlEscape(url)}"]`); 558 } 559 function cssInDom(url) { 560 return !!document.querySelector(`head link[href="${htmlEscape(url)}"]`); 561 } 562 function normalizeAsset(asset) { 563 return typeof asset === "string" ? { url: asset } : asset; 564 } 565 function htmlEscape(value) { 566 return String(value).replace(/"/g, '\\"'); 567 } 568 569
569// ../../vendor/larajax/larajax/resources/src/request/dom-patcher.js 570 var DomUpdateMode = { 571 replace: "replace", 572 prepend: "prepend", 573 append: "append", 574 update: "update" 575 }; 576 var DomPatcher = class { 577 constructor(envelope, partialMap, options = {}) { 578 this.options = options; 579 this.envelope = envelope; 580 this.partialMap = partialMap; 581 this.afterUpdateCallback = null; 582 } 583 apply() { 584 this.applyPartialUpdates(); 585 this.applyDomUpdates(); 586 } 587 afterUpdate(callback) { 588 this.afterUpdateCallback = callback; 589 } 590 // Should patch the dom using the envelope.getPartials() 591 // which is expected to be { name: partialName, html: contents } 592 applyPartialUpdates() { 593 const partials = this.envelope.getPartials(); 594 partials.forEach((partial) => { 595 let selector = this.partialMap[partial.name]; 596 let selectedEl = []; 597 if (this.partialMap["_self"] && partial.name == this.options.partial && this.options.partialEl) { 598 selector = this.partialMap["_self"]; 599 selectedEl = [this.options.partialEl]; 600 } else if (selector) { 601 selectedEl = resolveSelectorResponse(selector, '[data-ajax-partial="' + partial.name + '"]'); 602 } 603 selectedEl.forEach((el) => { 604 this.patchDom( 605 el, 606 partial.html, 607 getSelectorUpdateMode(selector, el) 608 ); 609 }); 610 }); 611 } 612 // Should patch the dom using the envelope.getDomPatches() 613 applyDomUpdates() { 614 const updates = this.envelope.getDomPatches(); 615 updates.forEach((update) => { 616 document.querySelectorAll(update.selector).forEach((el) => { 617 this.patchDom(el, update.html, update.swap); 618 }); 619 }); 620 } 621 patchDom(element, content, swapType) { 622 const parentEl = element.parentNode; 623 switch (swapType) { 624 case "append": 625 case "beforeend": 626 element.insertAdjacentHTML("beforeend", content); 627 runScriptsOnFragment(element, content); 628 break; 629 case "after": 630 case "afterend": 631 element.insertAdjacentHTML("afterend", content); 632 runScriptsOnFragment(element, content); 633 break; 634 case "before": 635 case "beforebegin": 636 element.insertAdjacentHTML("beforebegin", content); 637 runScriptsOnFragment(element, content); 638 break; 639 case "prepend": 640 case "afterbegin": 641 element.insertAdjacentHTML("afterbegin", content); 642 runScriptsOnFragment(element, content); 643 break; 644 case "replace": 645 case "outerHTML": 646 element.outerHTML = content; 647 runScriptsOnFragment(parentEl, content); 648 break; 649 default: 650 case "update": 651 case "innerHTML": 652 element.innerHTML = content; 653 runScriptsOnElement(element); 654 break; 655 } 656 if (this.afterUpdateCallback) { 657 this.afterUpdateCallback(element); 658 } 659 } 660 }; 661 function resolveSelectorResponse(selector, partialSelector) { 662 if (selector === true) { 663 return document.querySelectorAll(partialSelector); 664 } 665 if (typeof selector !== "string") { 666 return [selector]; 667 } 668 if (["#", ".", "@", "^", "!", "="].indexOf(selector.charAt(0)) === -1) { 669 return []; 670 } 671 if (["@", "^", "!", "="].indexOf(selector.charAt(0)) !== -1) { 672 selector = selector.substring(1); 673 } 674 if (!selector) { 675 selector = partialSelector; 676 } 677 return document.querySelectorAll(selector); 678 } 679 function getSelectorUpdateMode(selector, el) { 680 if (typeof selector === "string") { 681 if (selector.charAt(0) === "!") { 682 return DomUpdateMode.replace; 683 } 684 if (selector.charAt(0) === "@") { 685 return DomUpdateMode.append; 686 } 687 if (selector.charAt(0) === "^") { 688 return DomUpdateMode.prepend; 689 } 690 } 691 if (el.dataset.ajaxUpdateMode !== void 0) { 692 return el.dataset.ajaxUpdateMode; 693 } 694 return DomUpdateMode.update; 695 } 696 function runScriptsOnElement(el) {
697 Array.from(el.querySelectorAll("script")).forEach((oldScript) => { 698 const newScript = document.createElement("script"); 699 Array.from(oldScript.attributes).forEach((attr) => newScript.setAttribute(attr.name, attr.value)); 700 newScript.appendChild(document.createTextNode(oldScript.innerHTML)); 701 oldScript.parentNode.replaceChild(newScript, oldScript); 702 }); 703 } 704 function runScriptsOnFragment(container, html) { 705 const div = document.createElement("div"); 706 div.innerHTML = html; 707 Array.from(div.querySelectorAll("script")).forEach((oldScript) => { 708 const newScript = document.createElement("script"); 709 Array.from(oldScript.attributes).forEach((attr) => newScript.setAttribute(attr.name, attr.value)); 710 newScript.appendChild(document.createTextNode(oldScript.innerHTML)); 711 container.appendChild(newScript); 712 container.removeChild(newScript); 713 }); 714 } 715 716
716// ../../vendor/larajax/larajax/resources/src/util/turbo.js 717 var _turboProvider = null; 718 function registerTurbo(turbo) { 719 _turboProvider = turbo; 720 } 721 function isTurboEnabled() { 722 return _turboProvider?.isEnabled() ?? false; 723 } 724 function turboVisit(url, options) { 725 if (_turboProvider) { 726 _turboProvider.visit(url, options); 727 return true; 728 } 729 return false; 730 } 731 function getTurboController() { 732 return _turboProvider?.controller ?? null; 733 } 734 function turboPageReady() { 735 return _turboProvider?.pageReady() ?? null; 736 } 737 738
738// ../../vendor/larajax/larajax/resources/src/util/referrer.js 739 function getReferrerUrl() { 740 const url = isTurboEnabled() ? getTurboController().getLastVisitUrl() : getReferrerFromSameOrigin(); 741 if (!url || isSameBaseUrl(url)) { 742 return null; 743 } 744 return url; 745 } 746 function getReferrerFromSameOrigin() { 747 if (!document.referrer) { 748 return null; 749 } 750 try { 751 const referrer = new URL(document.referrer); 752 if (referrer.origin !== location.origin) { 753 return null; 754 } 755 const pushReferrer = localStorage.getItem("ocPushStateReferrer"); 756 if (pushReferrer && pushReferrer.indexOf(referrer.pathname) === 0) { 757 return pushReferrer; 758 } 759 return document.referrer; 760 } catch (e) { 761 } 762 } 763 function isSameBaseUrl(url) { 764 const givenUrl = new URL(url, window.location.origin), currentUrl = new URL(window.location.href); 765 return givenUrl.origin === currentUrl.origin && givenUrl.pathname === currentUrl.pathname; 766 } 767 768
768// ../../vendor/larajax/larajax/resources/src/util/promise.js 769 function decoratePromiseProxy(fn, ctx = null) { 770 return (...args) => { 771 const p = Promise.resolve().then(() => fn.apply(ctx, args)); 772 return decoratePromise(p); 773 }; 774 } 775 function decoratePromise(promise) { 776 return Object.assign(promise, { 777 done(fn) { 778 promise.then(fn); 779 return this; 780 }, 781 fail(fn) { 782 promise.catch(fn); 783 return this; 784 }, 785 always(fn) { 786 promise.finally(fn); 787 return this; 788 } 789 }); 790 } 791 function cancellablePromise(executor) { 792 if (!executor) { 793 executor = () => { 794 }; 795 } 796 let hasCanceled = false; 797 let cancelHandler = () => { 798 }; 799 let resolveFn, rejectFn; 800 const promise = new Promise((resolve, reject) => { 801 resolveFn = resolve; 802 rejectFn = reject; 803 executor( 804 (value) => { 805 if (!hasCanceled) resolve(value); 806 }, 807 (error) => { 808 if (!hasCanceled) reject(error); 809 }, 810 (onCancel) => { 811 cancelHandler = onCancel; 812 } 813 ); 814 }); 815 promise.abort = () => { 816 hasCanceled = true; 817 cancelHandler(); 818 }; 819 promise.cancel = promise.abort; 820 promise.onCancel = (fn) => { 821 cancelHandler = typeof fn === "function" ? fn : cancelHandler; 822 return promise; 823 }; 824 promise.resolve = (value) => { 825 if (!hasCanceled) { 826 resolveFn(value); 827 } 828 }; 829 promise.reject = (error) => { 830 if (!hasCanceled) { 831 rejectFn(error); 832 } 833 }; 834 return decoratePromise(promise); 835 } 836 837
837// ../../vendor/larajax/larajax/resources/src/request/actions.js 838 var Actions = class { 839 constructor(delegate, context, options) { 840 this.el = delegate.el; 841 this.delegate = delegate; 842 this.context = context; 843 this.options = options; 844 this.context.start = this.start.bind(this); 845 this.context.success = decoratePromiseProxy(this.success, this); 846 this.context.error = decoratePromiseProxy(this.error, this); 847 this.context.complete = decoratePromiseProxy(this.complete, this); 848 this.context.cancel = this.cancel.bind(this); 849 this.context.handleErrorMessage = this.handleErrorMessage.bind(this); 850 } 851 // Options can override all public methods in this class 852 invoke(method, args = []) { 853 if (this.options[method]) { 854 return this.options[method].apply(this.context, args); 855 } 856 if (this[method]) { 857 return this[method](...args); 858 } 859 } 860 // Options can also specify a non-interference "func" method, typically 861 // used by eval-based data attributes that takes minimal arguments 862 invokeFunc(method, data = null) { 863 if (this.options[method]) { 864 return this.options[method](this.el, this.context, data); 865 } 866 } 867 // Public 868 start(xhr) { 869 this.invoke("markAsUpdating", [true]); 870 if (this.delegate.options.message) { 871 this.invoke("handleProgressMessage", [this.delegate.options.message, false]); 872 } 873 } 874 async success(data, responseCode, xhr) { 875 if (this.invoke("beforeUpdate", [data, responseCode, xhr]) === false) { 876 return; 877 } 878 if (this.invokeFunc("beforeUpdateFunc", data) === false) { 879 return; 880 } 881 if (!this.delegate.applicationAllowsUpdate(data, responseCode, xhr)) { 882 return; 883 } 884 if (data instanceof Blob) { 885 this.invoke("handleFileDownload", [data, xhr]); 886 this.delegate.notifyApplicationRequestSuccess(data, responseCode, xhr); 887 this.invokeFunc("successFunc", data); 888 return; 889 } 890 if (!data.$env?.isFatal()) { 891 await this.invoke("handleUpdateOperations", [data, responseCode, xhr]); 892 await this.invoke("handleUpdateResponse", [data, responseCode, xhr]); 893 } 894 this.delegate.notifyApplicationRequestSuccess(data, responseCode, xhr); 895 this.invokeFunc("successFunc", data); 896 } 897 async error(data, responseCode, xhr) { 898 let errorMsg = data.$env?.getMessage(); 899 if (window.jaxUnloading !== void 0 && window.jaxUnloading) { 900 return; 901 } 902 this.delegate.toggleRedirect(false); 903 if (!data.$env?.isFatal()) { 904 await this.invoke("handleUpdateOperations", [data, responseCode, xhr]); 905 await this.invoke("handleUpdateResponse", [data, responseCode, xhr]); 906 } else if (!errorMsg) { 907 if (data.constructor === {}.constructor) { 908 if (data.message) { 909 errorMsg = data.message; 910 } else { 911 errorMsg = "Something went wrong! Check the browser console."; 912 console.warn(data); 913 } 914 } else { 915 errorMsg = data; 916 } 917 } 918 if (this.el !== document) { 919 this.el.setAttribute("data-error-message", errorMsg); 920 } 921 if (!this.delegate.applicationAllowsError(data, responseCode, xhr)) { 922 return; 923 } 924 if (this.invokeFunc("errorFunc", data) === false) { 925 return; 926 } 927 this.invoke("handleErrorMessage", [errorMsg, data.$env?.getSeverity()]); 928 } 929 async complete(data, responseCode, xhr) { 930 this.delegate.notifyApplicationRequestComplete(data, responseCode, xhr); 931 this.invokeFunc("completeFunc", data); 932 this.invoke("markAsUpdating", [false]); 933 if (this.delegate.options.message) { 934 this.invoke("handleProgressMessage", [null, true]); 935 } 936 } 937 cancel() { 938 this.invokeFunc("cancelFunc"); 939 this.delegate.notifyApplicationRequestCancel(); 940 } 941 // Custom function, requests confirmation from the user 942 handleConfirmMessage(message) { 943 let resolveFn, rejectFn; 944 const promise = new Promise((resolve, reject) => { 945 resolveFn = resolve; 946 rejectFn = reject; 947 }); 948 promise.then(() => { 949 this.delegate.sendInternal(); 950 }).catch(() => { 951 this.invoke("cancel", []); 952 }); 953 const event = this.delegate.notifyApplicationConfirmMessage(message, { 954 resolve: resolveFn, 955 reject: rejectFn 956 }); 957 if (event.defaultPrevented) { 958 return false;
959 } 960 if (message) { 961 const result = confirm(message); 962 if (!result) { 963 this.invoke("cancel", []); 964 } 965 return result; 966 } 967 } 968 // Custom function, display a progress message to the user 969 handleProgressMessage(message, isDone) { 970 } 971 // Custom function, display a flash message to the user 972 handleFlashMessage(message, type) { 973 } 974 // Custom function, display an error message to the user 975 handleErrorMessage(message, severity) { 976 const event = this.delegate.notifyApplicationErrorMessage(message); 977 if (event.defaultPrevented) { 978 return; 979 } 980 if (message) { 981 alert(message); 982 } 983 } 984 // Custom function, focus fields with errors 985 handleValidationMessage(message, fields) { 986 this.delegate.notifyApplicationBeforeValidate(message, fields); 987 if (!this.delegate.formEl) { 988 return; 989 } 990 var isFirstInvalidField = true; 991 for (var fieldName in fields) { 992 var fieldCheck, fieldNameOptions = []; 993 fieldCheck = fieldName.replace(/\.(\w+)/g, "[$1]"); 994 fieldNameOptions.push('[name="' + fieldCheck + '"]:not([disabled])'); 995 fieldNameOptions.push('[name="' + fieldCheck + '[]"]:not([disabled])'); 996 fieldCheck = ("." + fieldName).replace(/\.(\w+)/g, "[$1]"); 997 fieldNameOptions.push('[name$="' + fieldCheck + '"]:not([disabled])'); 998 fieldNameOptions.push('[name$="' + fieldCheck + '[]"]:not([disabled])'); 999 var fieldEmpty = fieldName.replace(/\.[0-9]+$/g, ""); 1000 if (fieldName !== fieldEmpty) { 1001 fieldCheck = fieldEmpty.replace(/\.(\w+)/g, "[$1]"); 1002 fieldNameOptions.push('[name="' + fieldCheck + '[]"]:not([disabled])'); 1003 fieldCheck = ("." + fieldEmpty).replace(/\.(\w+)/g, "[$1]"); 1004 fieldNameOptions.push('[name$="' + fieldCheck + '[]"]:not([disabled])'); 1005 } 1006 var fieldElement = this.delegate.formEl.querySelector(fieldNameOptions.join(", ")); 1007 if (fieldElement) { 1008 let event = this.delegate.notifyApplicationFieldInvalid(fieldElement, fieldName, fields[fieldName], isFirstInvalidField); 1009 if (isFirstInvalidField) { 1010 if (!event.defaultPrevented) { 1011 fieldElement.focus(); 1012 } 1013 isFirstInvalidField = false; 1014 } 1015 } 1016 } 1017 } 1018 // Custom function: handle browser events coming from the server 1019 async handleBrowserEvents(events = []) { 1020 if (!events.length) { 1021 return false; 1022 } 1023 let defaultPrevented = false; 1024 for (const dispatched of events) { 1025 const isAsync = dispatched?.async === true; 1026 if (isAsync) { 1027 await new Promise((outerResolve, outerReject) => { 1028 let settled = false; 1029 const resolve = (v) => { 1030 if (!settled) { 1031 settled = true; 1032 outerResolve(v); 1033 } 1034 }; 1035 const reject = (e) => { 1036 if (!settled) { 1037 settled = true; 1038 outerReject(e); 1039 } 1040 }; 1041 const event = this.delegate.notifyApplicationCustomEvent(dispatched.event, { 1042 ...dispatched.detail || {}, 1043 context: this.context, 1044 promise: { resolve, reject } 1045 }); 1046 if (event?.defaultPrevented) { 1047 defaultPrevented = true; 1048 } 1049 }); 1050 } else { 1051 const event = this.delegate.notifyApplicationCustomEvent(dispatched.event, { 1052 ...dispatched.detail || {}, 1053 context: this.context 1054 }); 1055 if (event?.defaultPrevented) defaultPrevented = true; 1056 } 1057 } 1058 return defaultPrevented; 1059 } 1060 // Custom function, redirect the browser to another location 1061 handleRedirectResponse(href) { 1062 const event = this.delegate.notifyApplicationBeforeRedirect(); 1063 if (event.defaultPrevented) { 1064 return; 1065 } 1066 if (this.options.browserRedirectBack) { 1067 href = getReferrerUrl() || href; 1068 } 1069 if (isTurboEnabled()) { 1070 turboVisit(href); 1071 } else { 1072 this.delegate.markNavigating(); 1073 location.assign(href); 1074 } 1075 } 1076 // Custom function, reload the browser 1077 handleReloadResponse() { 1078 this.delegate.markNavigating(); 1079 location.reload(); 1080 } 1081 // Mark known elements as being updated 1082 markAsUpdating(isUpdating) { 1083 var updateOptions = this.options.update || {}; 1084 for (var partial in updateOptions) { 1085 let selector = updateOptions[partial]; 1086 let selectedEl = []; 1087 if (updateOptions["_self"] && partial == this.options.partial && this.delegate.partialEl) { 1088 selector = updateOptions["_self"]; 1089 selectedEl = [this.delegate.partialEl]; 1090 } else { 1091 selectedEl = resolveSelectorResponse(selector, '[data-ajax-partial="' + partial + '"]'); 1092 } 1093 selectedEl.forEach(function(el) { 1094 if (isUpdating) { 1095 el.setAttribute("data-ajax-updating", ""); 1096 } else { 1097 el.removeAttribute("data-ajax-updating"); 1098 } 1099 }); 1100 } 1101 } 1102 async handleUpdateResponse(data, responseCode, xhr) { 1103 if (!data.$env) { 1104 return; 1105 } 1106 const updateOptions = this.options.update || {}, domPatcher = new DomPatcher(data.$env, updateOptions, { 1107 partial: this.options.partial, 1108 partialEl: this.delegate.partialEl 1109 }); 1110 domPatcher.afterUpdate((el) => { 1111 this.delegate.notifyApplicationAjaxUpdate(el, data, responseCode, xhr); 1112 }); 1113 domPatcher.apply(); 1114 setTimeout(() => { 1115 this.delegate.notifyApplicationUpdateComplete(data, responseCode, xhr); 1116 this.invoke("afterUpdate", [data, responseCode, xhr]); 1117 this.invokeFunc("afterUpdateFunc", data); 1118 }, 0); 1119 } 1120 async handleUpdateOperations(data, responseCode, xhr) { 1121 const flashMessages = this.delegate.options.flash ? data.$env?.getFlash() : null; 1122 if (flashMessages) { 1123 for (const flashMessage of flashMessages) { 1124 this.invoke("handleFlashMessage", [flashMessage.text, flashMessage.level]); 1125 } 1126 } 1127 const browserEvents = data.$env?.getBrowserEvents(); 1128 if (browserEvents && await this.invoke("handleBrowserEvents", [browserEvents])) { 1129 return; 1130 } 1131 const redirectUrl = data.$env?.getRedirectUrl(); 1132 if (redirectUrl) { 1133 this.delegate.toggleRedirect(redirectUrl); 1134 } 1135 if (this.delegate.isRedirect) { 1136 this.invoke("handleRedirectResponse", [this.delegate.options.redirect]); 1137 } 1138 if (data.$env?.getReload()) { 1139 this.invoke("handleReloadResponse"); 1140 } 1141 const invalidFields = data.$env?.getInvalid(); 1142 if (invalidFields) { 1143 this.invoke("handleValidationMessage", [data.$env?.getMessage(), invalidFields]); 1144 } 1145 const loadAssets = data.$env?.getAssets(); 1146 if (loadAssets) { 1147 await AssetManager.load(loadAssets); 1148 } 1149 } 1150 // Custom function, download a file response from the server 1151 handleFileDownload(data, xhr) { 1152 if (this.options.browserTarget) { 1153 window.open(window.URL.createObjectURL(data), this.options.browserTarget); 1154 return; 1155 } 1156 const fileName = getFilenameFromHttpResponse(xhr); 1157 if (!fileName) { 1158 return; 1159 } 1160 const anchor = document.createElement("a"); 1161 anchor.href = window.URL.createObjectURL(data); 1162 anchor.download = fileName; 1163 anchor.target = "_blank"; 1164 anchor.click(); 1165 window.URL.revokeObjectURL(anchor.href); 1166 } 1167 // Custom function, adds query data to the current URL 1168 applyQueryToUrl(queryData) { 1169 const searchParams = new URLSearchParams(window.location.search); 1170 for (const key of Object.keys(queryData)) { 1171 const value = queryData[key]; 1172 if (Array.isArray(value)) { 1173 searchParams.delete(key); 1174 searchParams.delete(`${key}[]`); 1175 value.forEach((val) => searchParams.append(`${key}[]`, val)); 1176 } else if (value === null) { 1177 searchParams.delete(key); 1178 searchParams.delete(`${key}[]`); 1179 } else { 1180 searchParams.set(key, value); 1181 } 1182 } 1183 var newUrl = window.location.pathname, queryStr = searchParams.toString(); 1184 if (queryStr) { 1185 newUrl += "?" + queryStr.replaceAll("%5B%5D=", "[]="); 1186 } 1187 if (isTurboEnabled()) { 1188 turboVisit(newUrl, { action: "swap", scroll: false }); 1189 } else { 1190 history.replaceState(null, "", newUrl); 1191 localStorage.setItem("ocPushStateReferrer", newUrl); 1192 } 1193 } 1194 }; 1195 function getFilenameFromHttpResponse(xhr) { 1196 const contentDisposition = xhr.getResponseHeader("Content-Disposition"); 1197 if (!contentDisposition) { 1198 return null; 1199 } 1200 const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g; 1201 let match = null; 1202 let tmpMatch = null; 1203 while ((tmpMatch = filenameRegex.exec(contentDisposition)) !== null) { 1204 match = tmpMatch; 1205 } 1206 if (match !== null && match[1]) { 1207 return /filename[^;*=\n]*\*=[^']*''/.exec(match[0]) === null ? match[1].replace(/['"]/g, "") : decodeURIComponent(match[1].substring(match[1].indexOf("''") + 2)); 1208 } 1209 return null; 1210 } 1211 1212
1212// ../../vendor/larajax/larajax/resources/src/util/form-serializer.js 1213 var FormSerializer = class _FormSerializer { 1214 // Public 1215 static assignToObj(obj, name, value) { 1216 new _FormSerializer().assignObjectInternal(obj, name, value); 1217 } 1218 static serializeAsJSON(element) { 1219 if (typeof element === "string") { 1220 element = document.querySelector(element); 1221 } 1222 return new _FormSerializer().parseContainer(element); 1223 } 1224 // Private 1225 parseContainer(element) { 1226 let jsonData = {}; 1227 element.querySelectorAll("input, textarea, select").forEach((field) => { 1228 if (!field.name || field.disabled || ["file", "reset", "submit", "button"].indexOf(field.type) > -1) { 1229 return; 1230 } 1231 if (["checkbox", "radio"].indexOf(field.type) > -1 && !field.checked) { 1232 return; 1233 } 1234 if (field.type === "select-multiple") { 1235 var arr = []; 1236 Array.from(field.options).forEach(function(option) { 1237 if (option.selected) { 1238 arr.push({ 1239 name: field.name, 1240 value: option.value 1241 }); 1242 } 1243 }); 1244 this.assignObjectInternal(jsonData, field.name, arr); 1245 return; 1246 } 1247 this.assignObjectInternal(jsonData, field.name, field.value); 1248 }); 1249 return jsonData; 1250 } 1251 assignObjectInternal(obj, fieldName, fieldValue) { 1252 this.assignObjectNested( 1253 obj, 1254 this.nameToArray(fieldName), 1255 fieldValue, 1256 fieldName.endsWith("[]") 1257 ); 1258 } 1259 assignObjectNested(obj, fieldArr, fieldValue, isArray) { 1260 var currentTarget = obj, lastIndex = fieldArr.length - 1; 1261 fieldArr.forEach(function(prop, index) { 1262 if (isArray && index === lastIndex) { 1263 if (!Array.isArray(currentTarget[prop])) { 1264 currentTarget[prop] = []; 1265 } 1266 if (Array.isArray(fieldValue)) { 1267 currentTarget[prop].push(...fieldValue); 1268 } else { 1269 currentTarget[prop].push(fieldValue); 1270 } 1271 } else { 1272 if (currentTarget[prop] === void 0 || currentTarget[prop].constructor !== {}.constructor) { 1273 currentTarget[prop] = {}; 1274 } 1275 if (index === lastIndex) { 1276 currentTarget[prop] = fieldValue; 1277 } 1278 currentTarget = currentTarget[prop]; 1279 } 1280 }); 1281 } 1282 nameToArray(fieldName) { 1283 var expression = /([^\]\[]+)/g, elements = [], searchResult; 1284 while (searchResult = expression.exec(fieldName)) { 1285 elements.push(searchResult[0]); 1286 } 1287 return elements; 1288 } 1289 }; 1290 1291
1291// ../../vendor/larajax/larajax/resources/src/request/data.js 1292 var Data = class { 1293 constructor(userData, targetEl, formEl) { 1294 this.userData = userData || {}; 1295 this.targetEl = targetEl; 1296 this.formEl = formEl; 1297 } 1298 // Public 1299 getRequestData() { 1300 let requestData; 1301 if (this.formEl) { 1302 requestData = new FormData(this.formEl); 1303 } else { 1304 requestData = new FormData(); 1305 } 1306 this.appendSingleInputElement(requestData); 1307 return requestData; 1308 } 1309 getAsFormData() { 1310 return this.appendJsonToFormData( 1311 this.getRequestData(), 1312 this.userData 1313 ); 1314 } 1315 getAsQueryString() { 1316 return this.convertFormDataToQuery( 1317 this.getAsFormData() 1318 ); 1319 } 1320 getAsJsonData() { 1321 return JSON.stringify( 1322 this.convertFormDataToJson( 1323 this.getAsFormData() 1324 ) 1325 ); 1326 } 1327 // Private 1328 appendSingleInputElement(requestData) { 1329 if (this.formEl || !this.targetEl || !isElementInput(this.targetEl)) { 1330 return; 1331 } 1332 const inputName = this.targetEl.name; 1333 if (!inputName || this.userData[inputName] !== void 0) { 1334 return; 1335 } 1336 if (this.targetEl.type === "file") { 1337 this.targetEl.files.forEach(function(value) { 1338 requestData.append(inputName, value); 1339 }); 1340 } else { 1341 requestData.append(inputName, this.targetEl.value); 1342 } 1343 } 1344 appendJsonToFormData(formData, useJson, parentKey) { 1345 var self = this; 1346 for (var key in useJson) { 1347 var fieldKey = key; 1348 if (parentKey) { 1349 fieldKey = parentKey + "[" + key + "]"; 1350 } 1351 var value = useJson[key]; 1352 if (value && value.constructor === {}.constructor) { 1353 this.appendJsonToFormData(formData, value, fieldKey); 1354 } else if (value && value.constructor === [].constructor) { 1355 value.forEach(function(v, i) { 1356 if (v.constructor === {}.constructor || v.constructor === [].constructor) { 1357 self.appendJsonToFormData(formData, v, fieldKey + "[" + i + "]"); 1358 } else { 1359 formData.append(fieldKey + "[]", self.castJsonToFormData(v)); 1360 } 1361 }); 1362 } else { 1363 formData.append(fieldKey, this.castJsonToFormData(value)); 1364 } 1365 } 1366 return formData; 1367 } 1368 convertFormDataToQuery(formData) { 1369 let flatData = this.formDataToArray(formData); 1370 return Object.keys(flatData).map(function(key) { 1371 if (key.endsWith("[]")) { 1372 return flatData[key].map(function(val) { 1373 return encodeURIComponent(key) + "=" + encodeURIComponent(val); 1374 }).join("&"); 1375 } else { 1376 return encodeURIComponent(key) + "=" + encodeURIComponent(flatData[key]); 1377 } 1378 }).join("&"); 1379 } 1380 convertFormDataToJson(formData) { 1381 let flatData = this.formDataToArray(formData); 1382 let jsonData = {}; 1383 for (var key in flatData) { 1384 FormSerializer.assignToObj(jsonData, key, flatData[key]); 1385 } 1386 return jsonData; 1387 } 1388 formDataToArray(formData) { 1389 return Object.fromEntries( 1390 Array.from(formData.keys()).map((key) => [ 1391 key,
1392 key.endsWith("[]") ? formData.getAll(key) : formData.getAll(key).pop() 1393 ]) 1394 ); 1395 } 1396 castJsonToFormData(val) { 1397 if (val === null || val === void 0) { 1398 return ""; 1399 } 1400 if (val === true) { 1401 return "1"; 1402 } 1403 if (val === false) { 1404 return "0"; 1405 } 1406 return val; 1407 } 1408 }; 1409 function isElementInput(el) { 1410 return ["input", "select", "textarea"].includes((el.tagName || "").toLowerCase()); 1411 } 1412 1413
1413// ../../vendor/larajax/larajax/resources/src/util/http-request.js 1414 var SystemStatusCode = { 1415 networkFailure: 0, 1416 timeoutFailure: -1, 1417 contentTypeMismatch: -2, 1418 userAborted: -3 1419 }; 1420 var HttpRequest = class { 1421 constructor(delegate, url, options) { 1422 this.failed = false; 1423 this.progress = 0; 1424 this.sent = false; 1425 this.aborted = false; 1426 this.timedOut = false; 1427 this.delegate = delegate; 1428 this.url = url; 1429 this.options = options; 1430 this.headers = options.headers || {}; 1431 this.method = options.method || "GET"; 1432 this.data = options.data; 1433 this.timeout = options.timeout || 0; 1434 this.controller = new AbortController(); 1435 this.timeoutId = null; 1436 this.xhr = this.createXhrWrapper(); 1437 } 1438 send() { 1439 if (this.sent) { 1440 return; 1441 } 1442 this.sent = true; 1443 this.notifyApplicationBeforeRequestStart(); 1444 this.setProgress(0); 1445 this.delegate.requestStarted(); 1446 if (this.timeout > 0) { 1447 this.timeoutId = setTimeout(() => { 1448 this.timedOut = true; 1449 this.controller.abort(); 1450 }, this.timeout * 1e3); 1451 } 1452 this.performFetch(); 1453 } 1454 async performFetch() { 1455 try { 1456 const response = await fetch(this.url, { 1457 method: this.method, 1458 headers: this.headers, 1459 body: this.data || null, 1460 signal: this.controller.signal 1461 }); 1462 this.clearTimeout(); 1463 this.updateXhrWrapper(response); 1464 await this.handleResponse(response); 1465 } catch (error) { 1466 this.clearTimeout(); 1467 if (error.name === "AbortError") { 1468 if (this.timedOut) { 1469 this.handleTimeout(); 1470 } else { 1471 this.handleAbort(); 1472 } 1473 } else { 1474 this.handleNetworkError(); 1475 } 1476 } 1477 } 1478 async handleResponse(response) { 1479 const contentType = response.headers.get("Content-Type"); 1480 const contentDisposition = response.headers.get("Content-Disposition") || ""; 1481 if (this.options.htmlOnly && !contentTypeIsHTML(contentType)) { 1482 this.failed = true; 1483 this.notifyApplicationAfterRequestEnd(); 1484 await this.settleWithDelegate( 1485 () => this.delegate.requestFailedWithStatusCode(SystemStatusCode.contentTypeMismatch) 1486 ); 1487 return; 1488 } 1489 let responseData; 1490 if (contentDisposition.startsWith("attachment") || contentDisposition.startsWith("inline")) { 1491 responseData = await response.blob(); 1492 } else if (contentTypeIsJSON(contentType)) { 1493 responseData = await response.json(); 1494 } else { 1495 responseData = await response.text(); 1496 } 1497 if (response.status >= 200 && response.status < 300) { 1498 this.notifyApplicationAfterRequestEnd(); 1499 await this.settleWithDelegate( 1500 () => this.delegate.requestCompletedWithResponse( 1501 responseData, 1502 response.status, 1503 this.getRedirectLocation(response) 1504 ) 1505 ); 1506 } else { 1507 this.failed = true; 1508 this.notifyApplicationAfterRequestEnd(); 1509 await this.settleWithDelegate( 1510 () => this.delegate.requestFailedWithStatusCode(response.status, responseData) 1511 ); 1512 } 1513 } 1514 async settleWithDelegate(callback) { 1515 try { 1516 await callback(); 1517 } catch (error) { 1518 Promise.reject(error); 1519 } finally { 1520 this.destroy(); 1521 } 1522 } 1523 getRedirectLocation(response) { 1524 const ajaxLocation = response.headers.get("X-AJAX-LOCATION"); 1525 if (ajaxLocation) { 1526 return ajaxLocation; 1527 } 1528 var anchorMatch = this.url.match(/^(.*)#/), wantUrl = anchorMatch ? anchorMatch[1] : this.url; 1529 return wantUrl !== response.url ? response.url : null; 1530 } 1531 handleTimeout() { 1532 this.failed = true; 1533 this.notifyApplicationAfterRequestEnd(); 1534 this.delegate.requestFailedWithStatusCode(SystemStatusCode.timeoutFailure); 1535 this.destroy(); 1536 } 1537 handleAbort() { 1538 if (this.options.trackAbort) { 1539 this.failed = true; 1540 this.notifyApplicationAfterRequestEnd(); 1541 this.delegate.requestFailedWithStatusCode(SystemStatusCode.userAborted); 1542 } else { 1543 this.notifyApplicationAfterRequestEnd(); 1544 } 1545 this.destroy(); 1546 } 1547 handleNetworkError() { 1548 this.failed = true; 1549 this.notifyApplicationAfterRequestEnd(); 1550 this.delegate.requestFailedWithStatusCode(SystemStatusCode.networkFailure); 1551 this.destroy(); 1552 } 1553 abort() { 1554 if (this.sent && !this.aborted) { 1555 this.aborted = true; 1556 this.controller.abort(); 1557 } 1558 } 1559 clearTimeout() { 1560 if (this.timeoutId) { 1561 clearTimeout(this.timeoutId); 1562 this.timeoutId = null; 1563 } 1564 } 1565 // Application events 1566 notifyApplicationBeforeRequestStart() { 1567 Events.dispatch("ajax:request-start", { detail: { url: this.url, xhr: this.xhr }, cancelable: false }); 1568 } 1569 notifyApplicationAfterRequestEnd() { 1570 Events.dispatch("ajax:request-end", { detail: { url: this.url, xhr: this.xhr }, cancelable: false }); 1571 } 1572 // XHR compatibility wrapper 1573 createXhrWrapper() { 1574 return { 1575 status: 0, 1576 statusText: "", 1577 responseURL: this.url, 1578 getResponseHeader: (name) => null, 1579 getAllResponseHeaders: () => "" 1580 }; 1581 } 1582 updateXhrWrapper(response) { 1583 this.xhr = { 1584 status: response.status, 1585 statusText: response.statusText, 1586 responseURL: response.url, 1587 getResponseHeader: (name) => response.headers.get(name), 1588 getAllResponseHeaders: () => [...response.headers].map(([k, v]) => `${k}: ${v}`).join("\r\n") 1589 }; 1590 } 1591 setProgress(progress) { 1592 this.progress = progress; 1593 this.delegate.requestProgressed(progress); 1594 } 1595 destroy() { 1596 this.setProgress(1); 1597 this.delegate.requestFinished(); 1598 } 1599 }; 1600 function contentTypeIsHTML(contentType) {
1601 return (contentType || "").match(/^text\/html|^application\/xhtml\+xml/); 1602 } 1603 function contentTypeIsJSON(contentType) { 1604 return (contentType || "").includes("application/json"); 1605 } 1606 1607
1607// ../../vendor/larajax/larajax/resources/src/extras/progress-bar.js 1608 var ProgressBar = class _ProgressBar { 1609 static instance = null; 1610 static stylesheetReady = false; 1611 static animationDuration = 300; 1612 constructor() { 1613 this.stylesheetElement = this.createStylesheetElement(); 1614 this.progressElement = this.createProgressElement(); 1615 this.hiding = false; 1616 this.value = 0; 1617 this.visible = false; 1618 this.trickle = () => { 1619 this.setValue(this.value + Math.random() / 100); 1620 }; 1621 } 1622 static get defaultCSS() { 1623 return unindent` 1624 .jax-progress-bar { 1625 position: fixed; 1626 display: block; 1627 top: 0; 1628 left: 0; 1629 height: 3px; 1630 background: #0076ff; 1631 z-index: 9999; 1632 transition: 1633 width ${_ProgressBar.animationDuration}ms ease-out, 1634 opacity ${_ProgressBar.animationDuration / 2}ms ${_ProgressBar.animationDuration / 2}ms ease-in; 1635 transform: translate3d(0, 0, 0); 1636 } 1637 `; 1638 } 1639 static get progressBar() { 1640 return { 1641 show: function() { 1642 const instance = getOrCreateInstance(); 1643 instance.setValue(0); 1644 instance.show(); 1645 }, 1646 hide: function() { 1647 const instance = getOrCreateInstance(); 1648 instance.setValue(100); 1649 instance.hide(); 1650 } 1651 }; 1652 } 1653 show(options = {}) { 1654 if (options.cssClass) { 1655 this.progressElement.classList.add(options.cssClass); 1656 } 1657 if (!this.visible) { 1658 this.visible = true; 1659 this.installStylesheetElement(); 1660 this.installProgressElement(); 1661 this.startTrickling(); 1662 } 1663 } 1664 hide() { 1665 if (this.visible && !this.hiding) { 1666 this.hiding = true; 1667 this.fadeProgressElement(() => { 1668 this.uninstallProgressElement(); 1669 this.stopTrickling(); 1670 this.visible = false; 1671 this.hiding = false; 1672 }); 1673 } 1674 } 1675 setValue(value) { 1676 this.value = value; 1677 this.refresh(); 1678 } 1679 // Private 1680 installStylesheetElement() { 1681 if (!_ProgressBar.stylesheetReady) { 1682 document.head.insertBefore(this.stylesheetElement, document.head.firstChild); 1683 _ProgressBar.stylesheetReady = true; 1684 } 1685 } 1686 installProgressElement() { 1687 this.progressElement.style.width = "0"; 1688 this.progressElement.style.opacity = "1"; 1689 document.documentElement.insertBefore(this.progressElement, document.body); 1690 this.refresh(); 1691 } 1692 fadeProgressElement(callback) { 1693 this.progressElement.style.opacity = "0"; 1694 setTimeout(callback, _ProgressBar.animationDuration * 1.5); 1695 } 1696 uninstallProgressElement() { 1697 if (this.progressElement.parentNode) { 1698 document.documentElement.removeChild(this.progressElement); 1699 } 1700 } 1701 startTrickling() { 1702 if (!this.trickleInterval) { 1703 this.trickleInterval = setInterval(this.trickle, _ProgressBar.animationDuration); 1704 } 1705 } 1706 stopTrickling() { 1707 clearInterval(this.trickleInterval); 1708 delete this.trickleInterval; 1709 } 1710 refresh() { 1711 requestAnimationFrame(() => { 1712 this.progressElement.style.width = `${10 + this.value * 90}%`; 1713 }); 1714 } 1715 createStylesheetElement() { 1716 const element = document.createElement("style"); 1717 element.textContent = _ProgressBar.defaultCSS; 1718 return element; 1719 } 1720 createProgressElement() { 1721 const element = document.createElement("div"); 1722 element.className = "jax-progress-bar"; 1723 return element; 1724 } 1725 }; 1726 function getOrCreateInstance() { 1727 if (!ProgressBar.instance) { 1728 ProgressBar.instance = new ProgressBar(); 1729 } 1730 return ProgressBar.instance; 1731 } 1732 1733
1733// ../../vendor/larajax/larajax/resources/src/request/request.js 1734 var appNavigating = false; 1735 var Request = class _Request { 1736 constructor(element, handler, options) { 1737 this.el = element; 1738 this.handler = handler; 1739 this.options = { ...this.constructor.DEFAULTS, ...options || {} }; 1740 this.context = { el: element, handler, options: this.options }; 1741 this.progressBar = new ProgressBar(); 1742 this.showProgressBar = () => { 1743 this.progressBar.show({ cssClass: "is-ajax" }); 1744 }; 1745 } 1746 static get DEFAULTS() { 1747 return { 1748 handler: null, 1749 update: {}, 1750 files: false, 1751 bulk: false, 1752 browserTarget: null, 1753 browserValidate: false, 1754 browserRedirectBack: false, 1755 progressBarDelay: 500, 1756 progressBar: null 1757 }; 1758 } 1759 start() { 1760 this.promise = cancellablePromise(); 1761 if (!this.applicationAllowsSetup()) { 1762 return this.promise; 1763 } 1764 this.initOtherElements(); 1765 this.preprocessOptions(); 1766 this.actions = new Actions(this, this.context, this.options); 1767 if (this.actions.invokeFunc("beforeSendFunc") === false) { 1768 return this.promise; 1769 } 1770 if (!this.validateClientSideForm() || !this.applicationAllowsRequest()) { 1771 return this.promise; 1772 } 1773 if (this.options.confirm && !this.actions.invoke("handleConfirmMessage", [this.options.confirm])) { 1774 return this.promise; 1775 } 1776 this.sendInternal(); 1777 return this.promise; 1778 } 1779 sendInternal() { 1780 const dataObj = new Data(this.options.data, this.el, this.formEl); 1781 let data; 1782 if (this.options.files) { 1783 data = dataObj.getAsFormData(); 1784 } else if (this.options.bulk) { 1785 data = dataObj.getAsJsonData(); 1786 } else { 1787 data = dataObj.getAsQueryString(); 1788 } 1789 if (this.options.query) { 1790 this.actions.invoke("applyQueryToUrl", [ 1791 this.options.query !== true ? this.options.query : JSON.parse(dataObj.getAsJsonData()) 1792 ]); 1793 } 1794 const { url, headers, method } = Options.fetch(this.handler, this.options); 1795 this.request = new HttpRequest(this, url, { method, headers, data, trackAbort: true }); 1796 this.isRedirect = this.options.redirect && this.options.redirect.length > 0; 1797 this.notifyApplicationBeforeSend(); 1798 this.notifyApplicationAjaxPromise(); 1799 this.promise.onCancel(() => { 1800 this.request.abort(); 1801 }).then((data2) => { 1802 if (!this.isRedirect) { 1803 this.notifyApplicationAjaxDone(data2, data2.$status, data2.$xhr); 1804 this.notifyApplicationAjaxAlways(data2, data2.$status, data2.$xhr); 1805 this.notifyApplicationSendComplete(data2, data2.$status, data2.$xhr); 1806 } 1807 }).catch((data2) => { 1808 if (!this.isRedirect) { 1809 this.notifyApplicationAjaxFail(data2, data2.$status, data2.$xhr); 1810 this.notifyApplicationAjaxAlways(data2, data2.$status, data2.$xhr); 1811 this.notifyApplicationSendComplete(data2, data2.$status, data2.$xhr); 1812 } 1813 }); 1814 this.request.send(); 1815 } 1816 static send(handler, options) { 1817 return new _Request(document, handler, options).start(); 1818 } 1819 static sendElement(element, handler, options) { 1820 if (typeof element === "string") { 1821 element = document.querySelector(element); 1822 } 1823 return new _Request(element, handler, options).start(); 1824 } 1825 static markNavigating() { 1826 appNavigating = true; 1827 } 1828 markNavigating() { 1829 appNavigating = true; 1830 } 1831 toggleRedirect(redirectUrl) { 1832 if (!redirectUrl) { 1833 this.options.redirect = null; 1834 this.isRedirect = false; 1835 } else { 1836 this.options.redirect = redirectUrl; 1837 this.isRedirect = true; 1838 } 1839 } 1840 applicationAllowsSetup() { 1841 const event = this.notifyApplicationAjaxSetup(); 1842 return !event.defaultPrevented; 1843 } 1844 applicationAllowsRequest() { 1845 const event = this.notifyApplicationBeforeRequest(); 1846 return !event.defaultPrevented; 1847 } 1848 applicationAllowsUpdate(data, responseCode, xhr) { 1849 const event = this.notifyApplicationBeforeUpdate(data, responseCode, xhr); 1850 return !event.defaultPrevented; 1851 } 1852 applicationAllowsError(message, responseCode, xhr) { 1853 const event = this.notifyApplicationRequestError(message, responseCode, xhr); 1854 return !event.defaultPrevented; 1855 } 1856 // Application events 1857 notifyApplicationAjaxSetup() {
1858 return dispatch("ajax:setup", { target: this.el, detail: { context: this.context } }); 1859 } 1860 notifyApplicationAjaxPromise() { 1861 return dispatch("ajax:promise", { target: this.el, detail: { context: this.context } }); 1862 } 1863 notifyApplicationAjaxFail(data, responseCode, xhr) { 1864 return dispatch("ajax:fail", { target: this.el, detail: { context: this.context, data, responseCode, xhr } }); 1865 } 1866 notifyApplicationAjaxDone(data, responseCode, xhr) { 1867 return dispatch("ajax:done", { target: this.el, detail: { context: this.context, data, responseCode, xhr } }); 1868 } 1869 notifyApplicationAjaxAlways(data, responseCode, xhr) { 1870 return dispatch("ajax:always", { target: this.el, detail: { context: this.context, data, responseCode, xhr } }); 1871 } 1872 notifyApplicationAjaxUpdate(target, data, responseCode, xhr) { 1873 return dispatch("ajax:update", { target, detail: { context: this.context, data, responseCode, xhr } }); 1874 } 1875 notifyApplicationBeforeRedirect() { 1876 return dispatch("ajax:before-redirect", { target: this.el }); 1877 } 1878 // Container-based events 1879 notifyApplicationBeforeRequest() { 1880 return dispatch("ajax:before-request", { target: this.triggerEl, detail: { context: this.context } }); 1881 } 1882 notifyApplicationBeforeUpdate(data, responseCode, xhr) { 1883 return dispatch("ajax:before-update", { target: this.triggerEl, detail: { context: this.context, data, responseCode, xhr } }); 1884 } 1885 notifyApplicationRequestSuccess(data, responseCode, xhr) { 1886 return dispatch("ajax:request-success", { target: this.triggerEl, detail: { context: this.context, data, responseCode, xhr } }); 1887 } 1888 notifyApplicationRequestError(message, responseCode, xhr) { 1889 return dispatch("ajax:request-error", { target: this.triggerEl, detail: { context: this.context, message, responseCode, xhr } }); 1890 } 1891 notifyApplicationRequestComplete(data, responseCode, xhr) { 1892 return dispatch("ajax:request-complete", { target: this.triggerEl, detail: { context: this.context, data, responseCode, xhr } }); 1893 } 1894 notifyApplicationRequestCancel() { 1895 return dispatch("ajax:request-cancel", { target: this.triggerEl, detail: { context: this.context } }); 1896 } 1897 notifyApplicationBeforeValidate(message, fields) { 1898 return dispatch("ajax:before-validate", { target: this.triggerEl, detail: { context: this.context, message, fields } }); 1899 } 1900 notifyApplicationBeforeReplace(target) { 1901 return dispatch("ajax:before-replace", { target }); 1902 } 1903 // Window-based events 1904 notifyApplicationBeforeSend() { 1905 return dispatch("ajax:before-send", { target: window, detail: { context: this.context } }); 1906 } 1907 notifyApplicationUpdateComplete(data, responseCode, xhr) { 1908 return dispatch("ajax:update-complete", { target: window, detail: { context: this.context, data, responseCode, xhr } }); 1909 } 1910 notifyApplicationSendComplete(data, responseCode, xhr) { 1911 return dispatch("ajax:send-complete", { target: window, detail: { context: this.context, data, responseCode, xhr } }); 1912 } 1913 notifyApplicationFieldInvalid(element, fieldName, errorMsg, isFirst) { 1914 return dispatch("ajax:invalid-field", { target: window, detail: { element, fieldName, errorMsg, isFirst } }); 1915 } 1916 notifyApplicationConfirmMessage(message, promise) { 1917 return dispatch("ajax:confirm-message", { target: window, detail: { message, promise } }); 1918 } 1919 notifyApplicationErrorMessage(message) { 1920 return dispatch("ajax:error-message", { target: window, detail: { message } }); 1921 } 1922 notifyApplicationCustomEvent(name, data) { 1923 const target = this.el instanceof Node && document.contains(this.el) ? this.el : document; 1924 return dispatch(name, { target, detail: data }); 1925 } 1926 // HTTP request delegate 1927 requestStarted() { 1928 this.markAsProgress(true); 1929 this.toggleLoadingElement(true); 1930 if (this.options.progressBar) { 1931 this.showProgressBarAfterDelay(); 1932 } 1933 this.actions.invoke("start", [this.request.xhr]); 1934 } 1935 requestProgressed(progress) { 1936 } 1937 async requestCompletedWithResponse(response, statusCode) { 1938 const data = decorateResponse(response, statusCode, this.request.xhr); 1939 await this.actions.invoke("success", [data, statusCode, this.request.xhr]); 1940 await this.actions.invoke("complete", [data, statusCode, this.request.xhr]); 1941 this.promise.resolve(data); 1942 } 1943 async requestFailedWithStatusCode(statusCode, response) { 1944 const data = decorateResponse(response, statusCode, this.request.xhr); 1945 if (statusCode == SystemStatusCode.userAborted) { 1946 await this.actions.invoke("cancel", []); 1947 } else { 1948 await this.actions.invoke("error", [data, statusCode, this.request.xhr]); 1949 } 1950 await this.actions.invoke("complete", [data, statusCode, this.request.xhr]); 1951 this.promise.reject(data); 1952 } 1953 requestFinished() { 1954 if (appNavigating) { 1955 window.addEventListener("pageshow", () => { 1956 appNavigating = false;
1957 this.requestFinished(); 1958 }, { once: true }); 1959 return; 1960 } 1961 this.markAsProgress(false); 1962 this.toggleLoadingElement(false); 1963 if (this.options.progressBar) { 1964 this.hideProgressBar(); 1965 } 1966 } 1967 // Private 1968 initOtherElements() { 1969 if (typeof this.options.form === "string") { 1970 this.formEl = document.querySelector(this.options.form); 1971 } else if (this.options.form) { 1972 this.formEl = this.options.form; 1973 } else { 1974 this.formEl = this.el && this.el !== document ? this.el.closest("form") : null; 1975 } 1976 this.triggerEl = this.formEl || this.el !== document && this.el.closest("[data-request-scope]") || document.body; 1977 this.partialEl = this.el && this.el !== document ? this.el.closest("[data-ajax-partial]") : null; 1978 this.loadingEl = typeof this.options.loading === "string" ? document.querySelector(this.options.loading) : this.options.loading; 1979 } 1980 preprocessOptions() { 1981 if (this.options.partial === void 0 && this.partialEl && this.partialEl.dataset.ajaxPartial !== void 0) { 1982 this.options.partial = this.partialEl.dataset.ajaxPartial || true; 1983 } 1984 } 1985 validateClientSideForm() { 1986 if (this.options.browserValidate && typeof document.createElement("input").reportValidity === "function" && this.formEl && !this.formEl.checkValidity()) { 1987 this.formEl.reportValidity(); 1988 return false; 1989 } 1990 return true; 1991 } 1992 toggleLoadingElement(isLoading) { 1993 if (!this.loadingEl) { 1994 return; 1995 } 1996 if (typeof this.loadingEl.show !== "function" || typeof this.loadingEl.hide !== "function") { 1997 this.loadingEl.style.display = isLoading ? "block" : "none"; 1998 return; 1999 } 2000 if (isLoading) { 2001 this.loadingEl.show(); 2002 } else { 2003 this.loadingEl.hide(); 2004 } 2005 } 2006 showProgressBarAfterDelay() { 2007 this.progressBar.setValue(0); 2008 this.progressBarTimeout = window.setTimeout(this.showProgressBar, this.options.progressBarDelay); 2009 } 2010 hideProgressBar() { 2011 this.progressBar.setValue(100); 2012 this.progressBar.hide(); 2013 if (this.progressBarTimeout != null) { 2014 window.clearTimeout(this.progressBarTimeout); 2015 delete this.progressBarTimeout; 2016 } 2017 } 2018 markAsProgress(isLoading) { 2019 if (isLoading) { 2020 document.documentElement.setAttribute("data-ajax-progress", ""); 2021 if (this.formEl) { 2022 this.formEl.setAttribute("data-ajax-progress", this.handler); 2023 } 2024 } else { 2025 document.documentElement.removeAttribute("data-ajax-progress"); 2026 if (this.formEl) { 2027 this.formEl.removeAttribute("data-ajax-progress"); 2028 } 2029 } 2030 } 2031 }; 2032 function decorateResponse(response, statusCode, xhr) { 2033 if (!response || response.constructor !== {}.constructor || !response.__ajax) { 2034 return response || {}; 2035 } 2036 const { __ajax, ...data } = response, envelope = new Envelope(response, statusCode), meta = { 2037 env: envelope, 2038 status: statusCode, 2039 xhr 2040 }; 2041 for (const [key, value] of Object.entries(meta)) { 2042 Object.defineProperty(data, `$${key}`, { 2043 value, 2044 enumerable: false, 2045 writable: false, 2046 configurable: true 2047 }); 2048 } 2049 return data; 2050 } 2051 2052
2052// ../../vendor/larajax/larajax/resources/src/request/namespace.js 2053 var namespace_default = Request; 2054 2055
2055// ../../vendor/larajax/larajax/resources/src/util/json-parser.js 2056 var JsonParser = class _JsonParser { 2057 // Public 2058 static paramToObj(name, value) { 2059 if (value === void 0) { 2060 value = ""; 2061 } 2062 if (typeof value === "object") { 2063 return value; 2064 } 2065 if (value.charAt(0) !== "{") { 2066 value = "{" + value + "}"; 2067 } 2068 try { 2069 return this.parseJSON(value); 2070 } catch (e) { 2071 throw new Error("Error parsing the " + name + " attribute value. " + e); 2072 } 2073 } 2074 static parseJSON(json) { 2075 return JSON.parse(new _JsonParser().parseString(json)); 2076 } 2077 // Private 2078 parseString(str) { 2079 str = str.trim(); 2080 if (!str.length) { 2081 throw new Error("Broken JSON object."); 2082 } 2083 var result = ""; 2084 while (str && str[0] === ",") { 2085 str = str.substr(1); 2086 } 2087 if (str[0] === '"' || str[0] === "'") { 2088 if (str[str.length - 1] !== str[0]) { 2089 throw new Error("Invalid string JSON object."); 2090 } 2091 var body = '"'; 2092 for (var i = 1; i < str.length; i++) { 2093 if (str[i] === "\\") { 2094 if (str[i + 1] === "'") { 2095 body += str[i + 1]; 2096 } else { 2097 body += str[i]; 2098 body += str[i + 1]; 2099 } 2100 i++; 2101 } else if (str[i] === str[0]) { 2102 body += '"'; 2103 return body; 2104 } else if (str[i] === '"') { 2105 body += '\\"'; 2106 } else body += str[i]; 2107 } 2108 throw new Error("Invalid string JSON object."); 2109 } 2110 if (str === "true" || str === "false") { 2111 return str; 2112 } 2113 if (str === "null") { 2114 return "null"; 2115 } 2116 var num = parseFloat(str); 2117 if (!isNaN(num)) { 2118 return num.toString(); 2119 } 2120 if (str[0] === "{") { 2121 var type = "needKey"; 2122 var result = "{"; 2123 for (var i = 1; i < str.length; i++) { 2124 if (this.isBlankChar(str[i])) { 2125 continue; 2126 } else if (type === "needKey" && (str[i] === '"' || str[i] === "'")) { 2127 var key = this.parseKey(str, i + 1, str[i]); 2128 result += '"' + key + '"'; 2129 i += key.length; 2130 i += 1; 2131 type = "afterKey"; 2132 } else if (type === "needKey" && this.canBeKeyHead(str[i])) { 2133 var key = this.parseKey(str, i); 2134 result += '"'; 2135 result += key; 2136 result += '"'; 2137 i += key.length - 1; 2138 type = "afterKey"; 2139 } else if (type === "afterKey" && str[i] === ":") { 2140 result += ":"; 2141 type = ":"; 2142 } else if (type === ":") { 2143 var body = this.getBody(str, i); 2144 i = i + body.originLength - 1; 2145 result += this.parseString(body.body); 2146 type = "afterBody"; 2147 } else if (type === "afterBody" || type === "needKey") { 2148 var last = i; 2149 while (str[last] === "," || this.isBlankChar(str[last])) { 2150 last++; 2151 } 2152 if (str[last] === "}" && last === str.length - 1) { 2153 while (result[result.length - 1] === ",") { 2154 result = result.substr(0, result.length - 1); 2155 } 2156 result += "}"; 2157 return result; 2158 } else if (last !== i && result !== "{") { 2159 result += ","; 2160 type = "needKey"; 2161 i = last - 1; 2162 } 2163 } 2164 } 2165 throw new Error("Broken JSON object near " + result); 2166 } 2167 if (str[0] === "[") { 2168 var result = "["; 2169 var type = "needBody"; 2170 for (var i = 1; i < str.length; i++) { 2171 if (" " === str[i] || "\n" === str[i] || " " === str[i]) { 2172 continue; 2173 } else if (type === "needBody") { 2174 if (str[i] === ",") { 2175 result += "null,"; 2176 continue; 2177 } 2178 if (str[i] === "]" && i === str.length - 1) { 2179 if (result[result.length - 1] === ",") result = result.substr(0, result.length - 1); 2180 result += "]"; 2181 return result; 2182 } 2183 var body = this.getBody(str, i); 2184 i = i + body.originLength - 1; 2185 result += this.parseString(body.body); 2186 type = "afterBody"; 2187 } else if (type === "afterBody") { 2188 if (str[i] === ",") { 2189 result += ","; 2190 type = "needBody"; 2191 while (str[i + 1] === "," || this.isBlankChar(str[i + 1])) { 2192 if (str[i + 1] === ",") result += "null,"; 2193 i++; 2194 } 2195 } else if (str[i] === "]" && i === str.length - 1) { 2196 result += "]"; 2197 return result; 2198 } 2199 } 2200 } 2201 throw new Error("Broken JSON array near " + result); 2202 } 2203 } 2204 parseKey(str, pos, quote) { 2205 var key = ""; 2206 for (var i = pos; i < str.length; i++) { 2207 if (quote && quote === str[i]) { 2208 return key; 2209 } else if (!quote && (str[i] === " " || str[i] === ":")) { 2210 return key; 2211 } 2212 key += str[i]; 2213 if (str[i] === "\\" && i + 1 < str.length) { 2214 key += str[i + 1]; 2215 i++; 2216 } 2217 } 2218 throw new Error("Broken JSON syntax near " + key); 2219 } 2220 getBody(str, pos) { 2221 if (str[pos] === '"' || str[pos] === "'") { 2222 var body = str[pos]; 2223 for (var i = pos + 1; i < str.length; i++) { 2224 if (str[i] === "\\") { 2225 body += str[i]; 2226 if (i + 1 < str.length) body += str[i + 1]; 2227 i++; 2228 } else if (str[i] === str[pos]) { 2229 body += str[pos]; 2230 return { 2231 originLength: body.length, 2232 body 2233 }; 2234 } else body += str[i]; 2235 } 2236 throw new Error("Broken JSON string body near " + body); 2237 } 2238 if (str[pos] === "t") { 2239 if (str.indexOf("true", pos) === pos) { 2240 return { 2241 originLength: "true".length, 2242 body: "true" 2243 }; 2244 } 2245 throw new Error("Broken JSON boolean body near " + str.substr(0, pos + 10)); 2246 } 2247 if (str[pos] === "f") { 2248 if (str.indexOf("f", pos) === pos) { 2249 return {
2250 originLength: "false".length, 2251 body: "false" 2252 }; 2253 } 2254 throw new Error("Broken JSON boolean body near " + str.substr(0, pos + 10)); 2255 } 2256 if (str[pos] === "n") { 2257 if (str.indexOf("null", pos) === pos) { 2258 return { 2259 originLength: "null".length, 2260 body: "null" 2261 }; 2262 } 2263 throw new Error("Broken JSON boolean body near " + str.substr(0, pos + 10)); 2264 } 2265 if (str[pos] === "-" || str[pos] === "+" || str[pos] === "." || str[pos] >= "0" && str[pos] <= "9") { 2266 var body = ""; 2267 for (var i = pos; i < str.length; i++) { 2268 if (str[i] === "-" || str[i] === "+" || str[i] === "." || str[i] >= "0" && str[i] <= "9") { 2269 body += str[i]; 2270 } else { 2271 return { 2272 originLength: body.length, 2273 body 2274 }; 2275 } 2276 } 2277 throw new Error("Broken JSON number body near " + body); 2278 } 2279 if (str[pos] === "{" || str[pos] === "[") { 2280 var stack = [str[pos]]; 2281 var body = str[pos]; 2282 for (var i = pos + 1; i < str.length; i++) { 2283 body += str[i]; 2284 if (str[i] === "\\") { 2285 if (i + 1 < str.length) body += str[i + 1]; 2286 i++; 2287 } else if (str[i] === '"') { 2288 if (stack[stack.length - 1] === '"') { 2289 stack.pop(); 2290 } else if (stack[stack.length - 1] !== "'") { 2291 stack.push(str[i]); 2292 } 2293 } else if (str[i] === "'") { 2294 if (stack[stack.length - 1] === "'") { 2295 stack.pop(); 2296 } else if (stack[stack.length - 1] !== '"') { 2297 stack.push(str[i]); 2298 } 2299 } else if (stack[stack.length - 1] !== '"' && stack[stack.length - 1] !== "'") { 2300 if (str[i] === "{") { 2301 stack.push("{"); 2302 } else if (str[i] === "}") { 2303 if (stack[stack.length - 1] === "{") { 2304 stack.pop(); 2305 } else { 2306 throw new Error("Broken JSON " + (str[pos] === "{" ? "object" : "array") + " body near " + body); 2307 } 2308 } else if (str[i] === "[") { 2309 stack.push("["); 2310 } else if (str[i] === "]") { 2311 if (stack[stack.length - 1] === "[") { 2312 stack.pop(); 2313 } else { 2314 throw new Error("Broken JSON " + (str[pos] === "{" ? "object" : "array") + " body near " + body); 2315 } 2316 } 2317 } 2318 if (!stack.length) { 2319 return { 2320 originLength: i - pos, 2321 body 2322 }; 2323 } 2324 } 2325 throw new Error("Broken JSON " + (str[pos] === "{" ? "object" : "array") + " body near " + body); 2326 } 2327 throw new Error("Broken JSON body near " + str.substr(pos - 5 >= 0 ? pos - 5 : 0, 50)); 2328 } 2329 canBeKeyHead(ch) { 2330 if (ch[0] === "\\") return false; 2331 if (ch[0] >= "a" && ch[0] <= "z" || ch[0] >= "A" && ch[0] <= "Z" || ch[0] === "_") return true; 2332 if (ch[0] >= "0" && ch[0] <= "9") return true; 2333 if (ch[0] === "$") return true; 2334 if (ch.charCodeAt(0) > 255) return true; 2335 return false; 2336 } 2337 isBlankChar(ch) { 2338 return ch === " " || ch === "\n" || ch === " "; 2339 } 2340 }; 2341 2342
2342// ../../vendor/larajax/larajax/resources/src/core/request-builder.js 2343 var RequestBuilder = class _RequestBuilder { 2344 constructor(element, handler, options) { 2345 this.options = options || {}; 2346 this.ogElement = element; 2347 this.element = this.findElement(element); 2348 if (!this.element) { 2349 return namespace_default.send( 2350 this.normalizeHandler(handler), 2351 this.options 2352 ); 2353 } 2354 this.assignAsEval("beforeSendFunc", "requestBeforeSend"); 2355 this.assignAsEval("beforeUpdateFunc", "requestBeforeUpdate"); 2356 this.assignAsEval("afterUpdateFunc", "requestAfterUpdate"); 2357 this.assignAsEval("successFunc", "requestSuccess"); 2358 this.assignAsEval("errorFunc", "requestError"); 2359 this.assignAsEval("cancelFunc", "requestCancel"); 2360 this.assignAsEval("completeFunc", "requestComplete"); 2361 this.assignAsData("progressBar", "requestProgressBar"); 2362 this.assignAsData("message", "requestMessage"); 2363 this.assignAsData("confirm", "requestConfirm"); 2364 this.assignAsData("redirect", "requestRedirect"); 2365 this.assignAsData("loading", "requestLoading"); 2366 this.assignAsData("form", "requestForm"); 2367 this.assignAsData("url", "requestUrl"); 2368 this.assignAsData("bulk", "requestBulk", { emptyAsTrue: true }); 2369 this.assignAsData("files", "requestFiles", { emptyAsTrue: true }); 2370 this.assignAsData("flash", "requestFlash", { emptyAsTrue: true }); 2371 this.assignAsData("update", "requestUpdate", { parseJson: true }); 2372 this.assignAsData("query", "requestQuery", { emptyAsTrue: true, parseJson: true }); 2373 this.assignAsData("browserTarget", "browserTarget"); 2374 this.assignAsData("browserValidate", "browserValidate", { emptyAsTrue: true }); 2375 this.assignAsData("browserRedirectBack", "browserRedirectBack", { emptyAsTrue: true }); 2376 this.assignAsMetaData("update", "ajaxRequestUpdate", { parseJson: true, mergeValue: true }); 2377 this.assignRequestData(); 2378 if (!handler) { 2379 handler = this.getHandlerName(); 2380 } 2381 return namespace_default.sendElement( 2382 this.element, 2383 this.normalizeHandler(handler), 2384 this.options 2385 ); 2386 } 2387 static fromElement(element, handler, options) { 2388 if (typeof element === "string") { 2389 element = document.querySelector(element); 2390 } 2391 return new _RequestBuilder(element, handler, options); 2392 } 2393 // Event target may some random node inside the data-request container 2394 // so it should bubble up but also capture the ogElement in case it is 2395 // a button that contains data-request-data. 2396 findElement(element) { 2397 if (!element || element === document) { 2398 return null; 2399 } 2400 if (element.matches("[data-request]")) { 2401 return element; 2402 } 2403 var parentEl = element.closest("[data-request]"); 2404 if (parentEl) { 2405 return parentEl; 2406 } 2407 return element; 2408 } 2409 getHandlerName() { 2410 if (this.element.dataset.dataRequest) { 2411 return this.element.dataset.dataRequest; 2412 } 2413 return this.element.getAttribute("data-request"); 2414 } 2415 normalizeHandler(handler) { 2416 if (handler && !isValidHandler(handler)) { 2417 if (this.options.url === void 0) { 2418 this.options.url = handler; 2419 } 2420 return "onAjax"; 2421 } 2422 return handler; 2423 } 2424 assignAsEval(optionName, name) { 2425 if (this.options[optionName] !== void 0) { 2426 return; 2427 } 2428 var attrVal; 2429 if (this.element.dataset[name]) { 2430 attrVal = this.element.dataset[name]; 2431 } else { 2432 attrVal = this.element.getAttribute("data-" + normalizeDataKey(name)); 2433 } 2434 if (!attrVal) { 2435 return; 2436 } 2437 this.options[optionName] = function(element, context, data) { 2438 return new Function("context", "data", attrVal).apply(element, [context, data]); 2439 }; 2440 } 2441 assignAsData(optionName, name, { parseJson = false, emptyAsTrue = false } = {}) { 2442 if (this.options[optionName] !== void 0) { 2443 return; 2444 } 2445 var attrVal; 2446 if (this.element.dataset[name]) { 2447 attrVal = this.element.dataset[name]; 2448 } else { 2449 attrVal = this.element.getAttribute("data-" + normalizeDataKey(name)); 2450 } 2451 if (attrVal === null) { 2452 return; 2453 } 2454 attrVal = this.castAttrToOption(attrVal, emptyAsTrue); 2455 if (parseJson && typeof attrVal === "string") { 2456 attrVal = JsonParser.paramToObj( 2457 "data-" + normalizeDataKey(name), 2458 attrVal 2459 ); 2460 } 2461 this.options[optionName] = attrVal; 2462 } 2463 assignAsMetaData(optionName, name, { mergeValue = true, parseJson = false, emptyAsTrue = false } = {}) { 2464 const meta = document.documentElement.querySelector('head meta[name="' + normalizeDataKey(name) + '"]'); 2465 if (!meta) { 2466 return; 2467 } 2468 var attrVal = meta.getAttribute("content"); 2469 if (parseJson) { 2470 attrVal = JsonParser.paramToObj(normalizeDataKey(name), attrVal); 2471 } else { 2472 attrVal = this.castAttrToOption(attrVal, emptyAsTrue); 2473 } 2474 if (mergeValue) { 2475 this.options[optionName] = { 2476 ...this.options[optionName] || {}, 2477 ...attrVal 2478 }; 2479 } else { 2480 this.options[optionName] = attrVal; 2481 } 2482 } 2483 castAttrToOption(val, emptyAsTrue) { 2484 if (emptyAsTrue && val === "") { 2485 return true; 2486 } 2487 if (val === "true" || val === "1") { 2488 return true; 2489 }
2490 if (val === "false" || val === "0") { 2491 return false; 2492 } 2493 return val; 2494 } 2495 assignRequestData() { 2496 const data = {}; 2497 elementParents(this.ogElement, "[data-request-data]").forEach(function(el) { 2498 Object.assign(data, JsonParser.paramToObj( 2499 "data-request-data", 2500 el.getAttribute("data-request-data") 2501 )); 2502 }); 2503 const attr = this.ogElement.getAttribute("data-request-data"); 2504 if (attr) { 2505 Object.assign(data, JsonParser.paramToObj("data-request-data", attr)); 2506 } 2507 if (this.options.data) { 2508 Object.assign(data, this.options.data); 2509 } 2510 this.options.data = data; 2511 } 2512 }; 2513 function elementParents(element, selector) { 2514 const parents = []; 2515 if (!element.parentNode) { 2516 return parents; 2517 } 2518 let ancestor = element.parentNode.closest(selector); 2519 while (ancestor) { 2520 parents.push(ancestor); 2521 ancestor = ancestor.parentNode.closest(selector); 2522 } 2523 return parents; 2524 } 2525 function normalizeDataKey(key) { 2526 return key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`); 2527 } 2528 function isValidHandler(str) { 2529 return /^(?:\w+\:{2})?on[A-Z]{1}[\w+]*$/.test(str); 2530 } 2531 2532
2532// ../../vendor/larajax/larajax/resources/src/core/trigger.js 2533 var Trigger = class { 2534 constructor(element) { 2535 this.element = element; 2536 this.config = this.parse(); 2537 this.timer = null; 2538 this.throttleTimer = null; 2539 this.lastValue = null; 2540 this.fired = false; 2541 this.throttled = false; 2542 this.lastRequest = null; 2543 } 2544 /** 2545 * Parse trigger configuration from element attributes 2546 */ 2547 parse() { 2548 let trigger = this.element.dataset.requestTrigger; 2549 let poll = this.element.dataset.requestPoll; 2550 if (!trigger && this.element.dataset.trackInput !== void 0) { 2551 const delay = this.element.dataset.trackInput || 300; 2552 trigger = `input changed delay:${delay}`; 2553 } 2554 if (!trigger && this.element.dataset.autoSubmit !== void 0) { 2555 const delay = this.element.dataset.autoSubmit || 0; 2556 trigger = delay > 0 ? `load delay:${delay}` : "load"; 2557 } 2558 if (!trigger) { 2559 trigger = this.getDefaultTrigger(); 2560 } 2561 const config = this.parseString(trigger); 2562 if (poll) { 2563 config.poll = this.parseTime(poll); 2564 } 2565 return config; 2566 } 2567 /** 2568 * Parse trigger string into config object 2569 * Format: "event modifier modifier:value" 2570 * Example: "input changed delay:500" 2571 */ 2572 parseString(str) { 2573 const parts = str.trim().split(/\s+/); 2574 const config = { 2575 event: parts[0] || "click", 2576 delay: 0, 2577 throttle: 0, 2578 once: false, 2579 changed: false, 2580 poll: 0 2581 }; 2582 for (let i = 1; i < parts.length; i++) { 2583 const part = parts[i]; 2584 if (part === "once") { 2585 config.once = true; 2586 } else if (part === "changed") { 2587 config.changed = true; 2588 } else if (part.startsWith("delay:")) { 2589 config.delay = this.parseTime(part.slice(6)); 2590 } else if (part.startsWith("throttle:")) { 2591 config.throttle = this.parseTime(part.slice(9)); 2592 } 2593 } 2594 return config; 2595 } 2596 /** 2597 * Parse time value to milliseconds 2598 * Supports: 500, 500ms, 1s, 1.5s 2599 */ 2600 parseTime(value) { 2601 if (typeof value === "number") { 2602 return value; 2603 } 2604 value = String(value).trim(); 2605 if (value.endsWith("ms")) { 2606 return parseFloat(value); 2607 } 2608 if (value.endsWith("s")) { 2609 return parseFloat(value) * 1e3; 2610 } 2611 return parseInt(value, 10) || 0; 2612 } 2613 /** 2614 * Get default trigger based on element type 2615 */ 2616 getDefaultTrigger() { 2617 const el = this.element; 2618 const tag = el.tagName.toLowerCase(); 2619 const type = el.getAttribute("type")?.toLowerCase(); 2620 if (tag === "form") return "submit"; 2621 if (tag === "a") return "click"; 2622 if (tag === "button") return "click"; 2623 if (tag === "select") return "change"; 2624 if (type === "checkbox" || type === "radio" || type === "file") return "change"; 2625 if (type === "date" || type === "datetime-local" || type === "time" || type === "month" || type === "week" || type === "color" || type === "range") return "change"; 2626 if (tag === "input" && (type === "submit" || type === "button")) return "click"; 2627 if (tag === "input") return "click"; 2628 return "click"; 2629 } 2630 /** 2631 * Check if element is still connected to DOM 2632 */ 2633 isConnected() { 2634 return this.element.isConnected; 2635 } 2636 /** 2637 * Bind event listeners for invented events only. 2638 * Standard DOM events (click, submit, change, input) are handled 2639 * via document-level delegation in Controller. 2640 */ 2641 bind() { 2642 const { event } = this.config; 2643 if (event === "load") { 2644 dispatch("ajax:trigger", { target: this.element }); 2645 } else if (event === "revealed" || event === "intersect") { 2646 this.observeVisibility(); 2647 } 2648 } 2649 /** 2650 * Handle the trigger event 2651 */ 2652 handleEvent(event) { 2653 if (!this.isConnected()) { 2654 return; 2655 } 2656 if (event && (this.config.event === "submit" || this.config.event === "click")) { 2657 event.preventDefault(); 2658 } 2659 const { delay, throttle, once, changed } = this.config; 2660 if (once && this.fired) { 2661 return; 2662 } 2663 if (changed && !this.hasChanged()) { 2664 return; 2665 } 2666 if (this.timer) { 2667 clearTimeout(this.timer); 2668 this.timer = null; 2669 } 2670 if (throttle > 0 && this.throttled) { 2671 return; 2672 } 2673 if (delay > 0) { 2674 this.timer = setTimeout(() => this.fire(), delay); 2675 } else { 2676 this.fire(); 2677 } 2678 } 2679 /** 2680 * Check if the element value has changed 2681 */ 2682 hasChanged() { 2683 const value = this.element.value; 2684 if (this.lastValue === value) { 2685 return false;
2686 } 2687 this.lastValue = value; 2688 return true; 2689 } 2690 /** 2691 * Fire the actual request 2692 */ 2693 fire() { 2694 if (!this.isConnected()) { 2695 return; 2696 } 2697 if (this.lastRequest && this.lastRequest.abort) { 2698 this.lastRequest.abort(); 2699 } 2700 this.fired = true; 2701 this.lastRequest = RequestBuilder.fromElement(this.element); 2702 if (this.config.throttle > 0) { 2703 this.throttled = true; 2704 this.throttleTimer = setTimeout(() => { 2705 this.throttled = false; 2706 }, this.config.throttle); 2707 } 2708 } 2709 /** 2710 * Observe element visibility for revealed/intersect events 2711 */ 2712 observeVisibility() { 2713 const observer = new IntersectionObserver((entries) => { 2714 entries.forEach((entry) => { 2715 if (!this.isConnected()) { 2716 observer.disconnect(); 2717 return; 2718 } 2719 if (entry.isIntersecting) { 2720 dispatch("ajax:trigger", { target: this.element }); 2721 if (this.config.once || this.config.event === "intersect") { 2722 observer.disconnect(); 2723 } 2724 } 2725 }); 2726 }, { 2727 threshold: 0.1 2728 }); 2729 observer.observe(this.element); 2730 } 2731 /** 2732 * Start polling interval 2733 */ 2734 startPolling() { 2735 const intervalId = setInterval(() => { 2736 if (!this.isConnected()) { 2737 clearInterval(intervalId); 2738 return; 2739 } 2740 if (!document.hidden) { 2741 dispatch("ajax:trigger", { target: this.element }); 2742 } 2743 }, this.config.poll); 2744 } 2745 }; 2746 2747
2747// ../../vendor/larajax/larajax/resources/src/util/wait.js 2748 function waitFor(predicate, timeout) { 2749 return new Promise((resolve, reject) => { 2750 const check = () => { 2751 if (!predicate()) { 2752 return; 2753 } 2754 clearInterval(interval); 2755 resolve(); 2756 }; 2757 const interval = setInterval(check, 100); 2758 check(); 2759 if (!timeout) { 2760 return; 2761 } 2762 setTimeout(() => { 2763 clearInterval(interval); 2764 reject(); 2765 }, timeout); 2766 }); 2767 } 2768 function domReady() { 2769 return new Promise((resolve) => { 2770 if (document.readyState === "loading") { 2771 document.addEventListener("DOMContentLoaded", () => resolve()); 2772 } else { 2773 resolve(); 2774 } 2775 }); 2776 } 2777 2778
2778// ../../vendor/larajax/larajax/resources/src/core/controller.js 2779 var Controller = class { 2780 constructor() { 2781 this.started = false; 2782 this.triggers = /* @__PURE__ */ new WeakMap(); 2783 } 2784 start() { 2785 if (!this.started) { 2786 addEventListener("beforeunload", this.documentOnBeforeUnload); 2787 Events.on(document, "click", "[data-request]", this.onTriggerEvent); 2788 Events.on(document, "submit", "[data-request]", this.onTriggerEvent); 2789 Events.on(document, "change", "[data-request]", this.onTriggerEvent); 2790 Events.on(document, "input", "[data-request]", this.onTriggerEvent); 2791 Events.on(document, "ajax:trigger", "[data-request]", this.onTriggerEvent); 2792 addEventListener("DOMContentLoaded", this.onRender); 2793 addEventListener("page:updated", this.onRender); 2794 addEventListener("ajax:update-complete", this.onRender); 2795 this.started = true; 2796 } 2797 } 2798 stop() { 2799 if (this.started) { 2800 removeEventListener("beforeunload", this.documentOnBeforeUnload); 2801 Events.off(document, "click", "[data-request]", this.onTriggerEvent); 2802 Events.off(document, "submit", "[data-request]", this.onTriggerEvent); 2803 Events.off(document, "change", "[data-request]", this.onTriggerEvent); 2804 Events.off(document, "input", "[data-request]", this.onTriggerEvent); 2805 Events.off(document, "ajax:trigger", "[data-request]", this.onTriggerEvent); 2806 removeEventListener("DOMContentLoaded", this.onRender); 2807 removeEventListener("page:updated", this.onRender); 2808 removeEventListener("ajax:update-complete", this.onRender); 2809 this.started = false; 2810 } 2811 } 2812 onRender = () => { 2813 this.render(); 2814 }; 2815 render() { 2816 Events.dispatch("before-render"); 2817 Events.dispatch("render"); 2818 dispatchEvent(new Event("resize")); 2819 this.bindCustomTriggers(); 2820 } 2821 /** 2822 * Initialize triggers for custom events (load, revealed, intersect) 2823 * Native events (click, submit, change, input) are handled by document delegation 2824 */ 2825 bindCustomTriggers() { 2826 document.querySelectorAll("[data-request]:not([data-trigger-bound])").forEach((el) => { 2827 const trigger = this.getTrigger(el); 2828 const eventType = trigger.config.event; 2829 if (eventType === "load" || eventType === "revealed" || eventType === "intersect") { 2830 el.setAttribute("data-trigger-bound", ""); 2831 trigger.bind(); 2832 } 2833 if (trigger.config.poll > 0) { 2834 el.setAttribute("data-trigger-bound", ""); 2835 trigger.startPolling(); 2836 } 2837 }); 2838 } 2839 /** 2840 * Get or create a Trigger instance for an element 2841 */ 2842 getTrigger(el) { 2843 let trigger = this.triggers.get(el); 2844 if (!trigger) { 2845 trigger = new Trigger(el); 2846 this.triggers.set(el, trigger); 2847 } 2848 return trigger; 2849 } 2850 /** 2851 * Handle delegated trigger events 2852 */ 2853 onTriggerEvent = (event) => { 2854 const el = event.delegateTarget; 2855 const trigger = this.getTrigger(el); 2856 const configEvent = trigger.config.event; 2857 if (event.type === "ajax:trigger") { 2858 trigger.handleEvent(event); 2859 return; 2860 } 2861 if (event.type === configEvent) { 2862 trigger.handleEvent(event); 2863 } 2864 }; 2865 documentOnBeforeUnload(event) { 2866 window.jaxUnloading = true; 2867 } 2868 /** 2869 * Wait for the page to be ready. 2870 * Uses Turbo's pageReady if available, otherwise falls back to domReady. 2871 */ 2872 pageReady() { 2873 return turboPageReady() ?? domReady(); 2874 } 2875 }; 2876 2877
2877// ../../vendor/larajax/larajax/resources/src/core/namespace.js 2878 var controller = new Controller(); 2879 var namespace_default2 = { 2880 controller, 2881 parseJSON: JsonParser.parseJSON, 2882 serializeAsJSON: FormSerializer.serializeAsJSON, 2883 requestElement: RequestBuilder.fromElement, 2884 pageReady() { 2885 return controller.pageReady(); 2886 }, 2887 start() { 2888 controller.start(); 2889 }, 2890 stop() { 2891 controller.stop(); 2892 } 2893 }; 2894 2895
2895// ../../vendor/larajax/larajax/resources/src/extras/validator.js 2896 var Validator = class { 2897 submit(el) { 2898 var form = el.closest("form"); 2899 if (!form) { 2900 return; 2901 } 2902 form.querySelectorAll("[data-validate-for]").forEach(function(el2) { 2903 el2.classList.remove("jax-visible"); 2904 }); 2905 form.querySelectorAll("[data-validate-error]").forEach(function(el2) { 2906 el2.classList.remove("jax-visible"); 2907 }); 2908 } 2909 validate(el, fields, errorMsg, allowDefault) { 2910 var form = el.closest("form"), messages = []; 2911 if (!form) { 2912 return; 2913 } 2914 for (var fieldName in fields) { 2915 var fieldMessages = fields[fieldName]; 2916 messages = [...messages, ...fieldMessages]; 2917 var field = form.querySelector('[data-validate-for="' + fieldName + '"]'); 2918 if (field) { 2919 if (!field.innerHTML || field.dataset.emptyMode) { 2920 field.dataset.emptyMode = true; 2921 field.innerHTML = fieldMessages.join(", "); 2922 } 2923 field.classList.add("jax-visible"); 2924 } 2925 } 2926 var container = form.querySelector("[data-validate-error]"); 2927 if (container) { 2928 container.classList.add("jax-visible"); 2929 var oldMessages = container.querySelectorAll("[data-message]"); 2930 if (oldMessages.length > 0) { 2931 var clone = oldMessages[0]; 2932 messages.forEach(function(message) { 2933 var newNode = clone.cloneNode(true); 2934 newNode.innerHTML = message; 2935 clone.parentNode.insertBefore(newNode, clone.nextSibling); 2936 }); 2937 oldMessages.forEach(function(el2) { 2938 el2.remove(); 2939 }); 2940 } else { 2941 container.innerHTML = errorMsg; 2942 } 2943 } 2944 if (allowDefault) { 2945 return; 2946 } 2947 Events.one(form, "ajax:request-error", function(event) { 2948 event.preventDefault(); 2949 }); 2950 } 2951 }; 2952 2953
2953// ../../vendor/larajax/larajax/resources/src/extras/attach-loader.js 2954 var AttachLoader = class _AttachLoader { 2955 static stylesheetReady = false; 2956 constructor() { 2957 this.stylesheetElement = this.createStylesheetElement(); 2958 } 2959 static get defaultCSS() { 2960 return unindent` 2961 .jax-attach-loader:after { 2962 content: ''; 2963 display: inline-block; 2964 vertical-align: middle; 2965 margin-left: .4em; 2966 height: 1em; 2967 width: 1em; 2968 animation: jax-rotate-loader 0.8s infinite linear; 2969 border: .2em solid currentColor; 2970 border-right-color: transparent; 2971 border-radius: 50%; 2972 opacity: .5; 2973 } 2974 @keyframes jax-rotate-loader { 2975 0% { transform: rotate(0deg); } 2976 100% { transform: rotate(360deg); } 2977 } 2978 `; 2979 } 2980 static get attachLoader() { 2981 return { 2982 show: function(el) { 2983 new _AttachLoader().show(resolveElement(el)); 2984 }, 2985 hide: function(el) { 2986 new _AttachLoader().hide(resolveElement(el)); 2987 }, 2988 hideAll: function() { 2989 new _AttachLoader().hideAll(); 2990 } 2991 }; 2992 } 2993 // Public 2994 show(el) { 2995 this.installStylesheetElement(); 2996 if (isElementInput2(el)) { 2997 const loadEl = document.createElement("span"); 2998 loadEl.className = "jax-attach-loader is-inline"; 2999 el.parentNode.insertBefore(loadEl, el.nextSibling); 3000 } else { 3001 el.classList.add("jax-attach-loader"); 3002 el.disabled = true; 3003 } 3004 } 3005 hide(el) { 3006 if (isElementInput2(el)) { 3007 if (el.nextElementSibling && el.nextElementSibling.classList.contains("jax-attach-loader")) { 3008 el.nextElementSibling.remove(); 3009 } 3010 } else { 3011 el.classList.remove("jax-attach-loader"); 3012 el.disabled = false; 3013 } 3014 } 3015 hideAll() { 3016 document.querySelectorAll(".jax-attach-loader.is-inline").forEach((el) => { 3017 el.remove(); 3018 }); 3019 document.querySelectorAll(".jax-attach-loader").forEach((el) => { 3020 el.classList.remove("jax-attach-loader"); 3021 el.disabled = false; 3022 }); 3023 } 3024 showForm(el) { 3025 if (el.dataset.attachLoading !== void 0) { 3026 this.show(el); 3027 } 3028 if (el.matches("form")) { 3029 var self = this; 3030 el.querySelectorAll("[data-attach-loading][type=submit]").forEach(function(otherEl) { 3031 if (!isElementInput2(otherEl)) { 3032 self.show(otherEl); 3033 } 3034 }); 3035 } 3036 } 3037 hideForm(el) { 3038 if (el.dataset.attachLoading !== void 0) { 3039 this.hide(el); 3040 } 3041 if (el.matches("form")) { 3042 var self = this; 3043 el.querySelectorAll("[data-attach-loading]").forEach(function(otherEl) { 3044 if (!isElementInput2(otherEl)) { 3045 self.hide(otherEl); 3046 } 3047 }); 3048 } 3049 } 3050 // Private 3051 installStylesheetElement() { 3052 if (!_AttachLoader.stylesheetReady) { 3053 document.head.insertBefore(this.stylesheetElement, document.head.firstChild); 3054 _AttachLoader.stylesheetReady = true; 3055 } 3056 } 3057 createStylesheetElement() { 3058 const element = document.createElement("style"); 3059 element.textContent = _AttachLoader.defaultCSS; 3060 return element; 3061 } 3062 }; 3063 function isElementInput2(el) { 3064 return ["input", "select", "textarea"].includes((el.tagName || "").toLowerCase()); 3065 } 3066 function resolveElement(el) { 3067 if (typeof el === "string") { 3068 el = document.querySelector(el); 3069 } 3070 if (!el) { 3071 throw new Error("Invalid element for attach loader."); 3072 } 3073 return el; 3074 } 3075 3076
3076// ../../vendor/larajax/larajax/resources/src/extras/flash-message.js 3077 var FlashMessage = class _FlashMessage { 3078 static instance = null; 3079 static stylesheetReady = false; 3080 constructor() { 3081 this.queue = []; 3082 this.lastUniqueId = 0; 3083 this.displayedMessage = null; 3084 this.stylesheetElement = this.createStylesheetElement(); 3085 } 3086 static get defaultCSS() { 3087 return unindent` 3088 .jax-flash-message { 3089 display: flex; 3090 position: fixed; 3091 z-index: 10300; 3092 width: 500px; 3093 left: 50%; 3094 top: 50px; 3095 margin-left: -250px; 3096 color: #fff; 3097 font-size: 1rem; 3098 padding: 10px 15px; 3099 border-radius: 5px; 3100 opacity: 0; 3101 transition: all 0.5s, width 0s; 3102 transform: scale(0.9); 3103 } 3104 @media (max-width: 768px) { 3105 .jax-flash-message { 3106 left: 1rem; 3107 right: 1rem; 3108 top: 1rem; 3109 margin-left: 0; 3110 width: auto; 3111 } 3112 } 3113 .jax-flash-message.flash-show { 3114 opacity: 1; 3115 transform: scale(1); 3116 } 3117 .jax-flash-message.loading { 3118 transition: opacity 0.2s; 3119 transform: scale(1); 3120 } 3121 .jax-flash-message.success { 3122 background: #86cb43; 3123 } 3124 .jax-flash-message.error { 3125 background: #cc3300; 3126 } 3127 .jax-flash-message.warning { 3128 background: #f0ad4e; 3129 } 3130 .jax-flash-message.info, .jax-flash-message.loading { 3131 background: #5fb6f5; 3132 } 3133 .jax-flash-message span.flash-message { 3134 flex-grow: 1; 3135 } 3136 .jax-flash-message a.flash-close { 3137 box-sizing: content-box; 3138 width: 1em; 3139 height: 1em; 3140 padding: .25em .25em; 3141 background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23FFF'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat; 3142 border: 0; 3143 border-radius: .25rem; 3144 opacity: .5; 3145 text-decoration: none; 3146 cursor: pointer; 3147 } 3148 .jax-flash-message a.flash-close:hover, 3149 .jax-flash-message a.flash-close:focus { 3150 opacity: 1; 3151 } 3152 .jax-flash-message.loading a.flash-close { 3153 display: none; 3154 } 3155 .jax-flash-message span.flash-loader { 3156 margin-right: 1em; 3157 } 3158 .jax-flash-message span.flash-loader:after { 3159 position: relative; 3160 top: 2px; 3161 content: ''; 3162 display: inline-block; 3163 height: 1.2em; 3164 width: 1.2em; 3165 animation: jax-flash-loader 0.8s infinite linear; 3166 border: .2em solid currentColor; 3167 border-right-color: transparent; 3168 border-radius: 50%; 3169 opacity: .5; 3170 } 3171 @keyframes jax-flash-loader { 3172 0% { transform: rotate(0deg); } 3173 100% { transform: rotate(360deg); } 3174 } 3175 `; 3176 } 3177 static flashMsg(options) { 3178 return getOrCreateInstance2().show(options); 3179 } 3180 runQueue() { 3181 if (this.displayedMessage) { 3182 return; 3183 } 3184 var options = this.queue.shift(); 3185 if (options === void 0) { 3186 return; 3187 } 3188 this.buildFlashMessage(options); 3189 } 3190 clearQueue() { 3191 this.queue = []; 3192 if (this.displayedMessage && this.displayedMessage.uniqueId) { 3193 this.hide(this.displayedMessage.uniqueId, true); 3194 } 3195 } 3196 removeFromQueue(uniqueId) { 3197 for (var index = 0; index < this.queue.length; index++) { 3198 if (this.queue[index].uniqueId == uniqueId) { 3199 this.queue.splice(index, 1); 3200 return; 3201 } 3202 } 3203 } 3204 show(options = {}) { 3205 this.installStylesheetElement(); 3206 let { 3207 message = "", 3208 type = "info", 3209 replace = null, 3210 hideAll = false 3211 } = options; 3212 if (options.text) message = options.text; 3213 if (options.class) type = options.class; 3214 if (hideAll || type === "error" || type === "loading") { 3215 this.clearQueue(); 3216 } 3217 if (replace) { 3218 if (this.displayedMessage && replace === this.displayedMessage.uniqueId) { 3219 this.hide(replace, true); 3220 } else { 3221 this.removeFromQueue(replace); 3222 } 3223 } 3224 if (!message) { 3225 return; 3226 } 3227 var uniqueId = this.makeUniqueId(); 3228 this.queue.push({ 3229 ...options, 3230 uniqueId 3231 }); 3232 this.runQueue(); 3233 return uniqueId; 3234 } 3235 makeUniqueId() { 3236 return ++this.lastUniqueId; 3237 } 3238 buildFlashMessage(options = {}) { 3239 let { 3240 message = "", 3241 type = "info", 3242 target = null, 3243 interval = 3 3244 } = options; 3245 if (options.text) message = options.text; 3246 if (options.class) type = options.class; 3247 if (target) { 3248 target.removeAttribute("data-control"); 3249 } 3250 var flashElement = this.createFlashElement(message, type); 3251 this.createMessagesElement().appendChild(flashElement); 3252 this.displayedMessage = { 3253 uniqueId: options.uniqueId, 3254 element: flashElement, 3255 options 3256 }; 3257 var remove = (event) => { 3258 clearInterval(timer); 3259 flashElement.removeEventListener("click", pause); 3260 flashElement.removeEventListener("extras:flash-remove", remove); 3261 flashElement.querySelector(".flash-close").removeEventListener("click", remove); 3262 flashElement.classList.remove("flash-show"); 3263 if (event && event.detail.isReplace) { 3264 flashElement.remove(); 3265 this.displayedMessage = null; 3266 this.runQueue(); 3267 } else { 3268 setTimeout(() => { 3269 flashElement.remove(); 3270 this.displayedMessage = null; 3271 this.runQueue(); 3272 }, 600); 3273 } 3274 }; 3275 var pause = () => { 3276 clearInterval(timer); 3277 }; 3278 flashElement.addEventListener("click", pause, { once: true }); 3279 flashElement.addEventListener("extras:flash-remove", remove, { once: true }); 3280 flashElement.querySelector(".flash-close").addEventListener("click", remove, { once: true }); 3281 var timer; 3282 if (interval && interval !== 0) { 3283 timer = setTimeout(remove, interval * 1e3); 3284 } 3285 setTimeout(() => { 3286 flashElement.classList.add("flash-show"); 3287 }, 20); 3288 } 3289 render() {
3290 document.querySelectorAll("[data-control=flash-message]").forEach((el) => { 3291 this.show({ ...el.dataset, target: el, message: el.innerHTML }); 3292 el.remove(); 3293 }); 3294 } 3295 hide(uniqueId, isReplace) { 3296 if (this.displayedMessage && uniqueId === this.displayedMessage.uniqueId) { 3297 this.displayedMessage.element.dispatchEvent(new CustomEvent("extras:flash-remove", { 3298 detail: { isReplace } 3299 })); 3300 } 3301 } 3302 hideAll() { 3303 this.clearQueue(); 3304 this.displayedMessage = null; 3305 document.querySelectorAll(".jax-flash-message, [data-control=flash-message]").forEach((el) => { 3306 el.remove(); 3307 }); 3308 } 3309 createFlashElement(message, type) { 3310 const element = document.createElement("div"); 3311 const loadingHtml = type === "loading" ? '<span class="flash-loader"></span>' : ""; 3312 const closeHtml = '<a class="flash-close"></a>'; 3313 element.className = "jax-flash-message " + type; 3314 element.innerHTML = loadingHtml + '<span class="flash-message">' + message + "</span>" + closeHtml; 3315 return element; 3316 } 3317 // Private 3318 installStylesheetElement() { 3319 if (!_FlashMessage.stylesheetReady) { 3320 document.head.insertBefore(this.stylesheetElement, document.head.firstChild); 3321 _FlashMessage.stylesheetReady = true; 3322 } 3323 } 3324 createStylesheetElement() { 3325 const element = document.createElement("style"); 3326 element.textContent = _FlashMessage.defaultCSS; 3327 return element; 3328 } 3329 createMessagesElement() { 3330 const found = document.querySelector(".jax-flash-messages"); 3331 if (found) { 3332 return found; 3333 } 3334 const element = document.createElement("div"); 3335 element.className = "jax-flash-messages"; 3336 document.body.appendChild(element); 3337 return element; 3338 } 3339 }; 3340 function getOrCreateInstance2() { 3341 if (!FlashMessage.instance) { 3342 FlashMessage.instance = new FlashMessage(); 3343 } 3344 return FlashMessage.instance; 3345 } 3346 3347
3347// ../../vendor/larajax/larajax/resources/src/extras/controller.js 3348 var Controller2 = class { 3349 constructor() { 3350 this.started = false; 3351 this.enableProgressBar = function(event) { 3352 const { options } = event.detail.context; 3353 if (options.progressBar === null) { 3354 options.progressBar = true; 3355 } 3356 }; 3357 this.showAttachLoader = (event) => { 3358 this.attachLoader.showForm(event.target); 3359 }; 3360 this.hideAttachLoader = (event) => { 3361 this.attachLoader.hideForm(event.target); 3362 }; 3363 this.handlePageRestore = (event) => { 3364 if (event.persisted) { 3365 this.attachLoader.hideAll(); 3366 } 3367 }; 3368 this.validatorSubmit = (event) => { 3369 this.validator.submit(event.target); 3370 }; 3371 this.validatorValidate = (event) => { 3372 this.validator.validate( 3373 event.target, 3374 event.detail.fields, 3375 event.detail.message, 3376 shouldShowFlashMessage(event.detail.context.options.flash, "validate") 3377 ); 3378 }; 3379 this.flashMessageBind = (event) => { 3380 const { options } = event.detail.context; 3381 const requestContext = event.detail.context; 3382 if (options.flash) { 3383 options.handleErrorMessage = (message, severity) => { 3384 if (severity === "fatal") { 3385 return requestContext.handleErrorMessage(message, severity); 3386 } 3387 if (message && (shouldShowFlashMessage(options.flash, "error") || shouldShowFlashMessage(options.flash, "validate"))) { 3388 this.flashMessage.show({ message, type: "error" }); 3389 } 3390 }; 3391 options.handleFlashMessage = (message, type) => { 3392 if (message && shouldShowFlashMessage(options.flash, type)) { 3393 this.flashMessage.show({ message, type }); 3394 } 3395 }; 3396 } 3397 var context = event.detail; 3398 options.handleProgressMessage = (message, isDone) => { 3399 if (!isDone) { 3400 context.progressMessageId = this.flashMessage.show({ message, type: "loading", interval: 10 }); 3401 } else { 3402 this.flashMessage.show(context.progressMessageId ? { replace: context.progressMessageId } : { hideAll: true }); 3403 context = null; 3404 } 3405 }; 3406 }; 3407 this.flashMessageRender = (event) => { 3408 this.flashMessage.render(); 3409 }; 3410 this.hideAllFlashMessages = (event) => { 3411 this.flashMessage.hideAll(); 3412 }; 3413 this.handleBrowserRedirect = function(event) { 3414 if (event.defaultPrevented) { 3415 return; 3416 } 3417 const href = getReferrerUrl(); 3418 if (!href) { 3419 return; 3420 } 3421 event.preventDefault(); 3422 if (isTurboEnabled()) { 3423 turboVisit(href); 3424 } else { 3425 location.assign(href); 3426 } 3427 }; 3428 } 3429 start() { 3430 if (!this.started) { 3431 addEventListener("ajax:setup", this.enableProgressBar); 3432 this.attachLoader = new AttachLoader(); 3433 Events.on(document, "ajax:promise", "form, [data-attach-loading]", this.showAttachLoader); 3434 Events.on(document, "ajax:fail", "form, [data-attach-loading]", this.hideAttachLoader); 3435 Events.on(document, "ajax:done", "form, [data-attach-loading]", this.hideAttachLoader); 3436 addEventListener("pageshow", this.handlePageRestore); 3437 this.validator = new Validator(); 3438 Events.on(document, "ajax:before-validate", "[data-request-validate]", this.validatorValidate); 3439 Events.on(document, "ajax:promise", "[data-request-validate]", this.validatorSubmit); 3440 this.flashMessage = FlashMessage.instance ?? (FlashMessage.instance = new FlashMessage()); 3441 addEventListener("render", this.flashMessageRender); 3442 addEventListener("ajax:setup", this.flashMessageBind); 3443 Events.on(document, "click", "[data-browser-redirect-back]", this.handleBrowserRedirect); 3444 this.started = true; 3445 } 3446 } 3447 stop() { 3448 if (this.started) { 3449 removeEventListener("ajax:setup", this.enableProgressBar); 3450 this.attachLoader = null; 3451 Events.off(document, "ajax:promise", "form, [data-attach-loading]", this.showAttachLoader); 3452 Events.off(document, "ajax:fail", "form, [data-attach-loading]", this.hideAttachLoader); 3453 Events.off(document, "ajax:done", "form, [data-attach-loading]", this.hideAttachLoader); 3454 removeEventListener("pageshow", this.handlePageRestore); 3455 this.validator = null; 3456 Events.off(document, "ajax:before-validate", "[data-request-validate]", this.validatorValidate); 3457 Events.off(document, "ajax:promise", "[data-request-validate]", this.validatorSubmit); 3458 this.flashMessage = null; 3459 removeEventListener("render", this.flashMessageRender); 3460 removeEventListener("ajax:setup", this.flashMessageBind); 3461 Events.off(document, "click", "[data-browser-redirect-back]", this.handleBrowserRedirect); 3462 this.started = false;
3463 } 3464 } 3465 }; 3466 function shouldShowFlashMessage(value, type) { 3467 if (value === true) { 3468 return true; 3469 } 3470 if (typeof value !== "string") { 3471 return false; 3472 } 3473 const parts = value.split(",").map((p) => p.trim()); 3474 const hasNegation = parts.some((p) => p.startsWith("-")); 3475 const explicitExclude = parts.includes("-" + type); 3476 const explicitInclude = parts.includes(type); 3477 if (hasNegation) { 3478 return !explicitExclude; 3479 } 3480 return explicitInclude; 3481 } 3482 3483
3483// ../../vendor/larajax/larajax/resources/src/extras/namespace.js 3484 var controller2 = new Controller2(); 3485 var namespace_default3 = { 3486 controller: controller2, 3487 flashMsg: FlashMessage.flashMsg, 3488 progressBar: ProgressBar.progressBar, 3489 attachLoader: AttachLoader.attachLoader, 3490 start() { 3491 controller2.start(); 3492 }, 3493 stop() { 3494 controller2.stop(); 3495 } 3496 }; 3497 3498
3498// ../../vendor/larajax/larajax/resources/src/observe/event-listener.js 3499 var EventListener = class { 3500 constructor(eventTarget, eventName, eventOptions) { 3501 this.eventTarget = eventTarget; 3502 this.eventName = eventName; 3503 this.eventOptions = eventOptions; 3504 this.unorderedBindings = /* @__PURE__ */ new Set(); 3505 } 3506 connect() { 3507 this.eventTarget.addEventListener(this.eventName, this, this.eventOptions); 3508 } 3509 disconnect() { 3510 this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions); 3511 } 3512 // Binding observer delegate 3513 bindingConnected(binding) { 3514 this.unorderedBindings.add(binding); 3515 } 3516 bindingDisconnected(binding) { 3517 this.unorderedBindings.delete(binding); 3518 } 3519 handleEvent(event) { 3520 const extendedEvent = extendEvent(event); 3521 for (const binding of this.bindings) { 3522 if (extendedEvent.immediatePropagationStopped) { 3523 break; 3524 } else { 3525 binding.handleEvent(extendedEvent); 3526 } 3527 } 3528 } 3529 hasBindings() { 3530 return this.unorderedBindings.size > 0; 3531 } 3532 get bindings() { 3533 return Array.from(this.unorderedBindings).sort((left, right) => { 3534 const leftIndex = left.index, rightIndex = right.index; 3535 return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0; 3536 }); 3537 } 3538 }; 3539 function extendEvent(event) { 3540 if ("immediatePropagationStopped" in event) { 3541 return event; 3542 } else { 3543 const { stopImmediatePropagation } = event; 3544 return Object.assign(event, { 3545 immediatePropagationStopped: false, 3546 stopImmediatePropagation() { 3547 this.immediatePropagationStopped = true; 3548 stopImmediatePropagation.call(this); 3549 } 3550 }); 3551 } 3552 } 3553 3554
vendor: 3,438 bytes, lines 3554-3643
3554// ../../vendor/larajax/larajax/resources/src/observe/dispatcher.js 3555 var Dispatcher = class { 3556 constructor(application2) { 3557 this.application = application2; 3558 this.eventListenerMaps = /* @__PURE__ */ new Map(); 3559 this.started = false; 3560 } 3561 start() { 3562 if (!this.started) { 3563 this.started = true; 3564 this.eventListeners.forEach((eventListener) => eventListener.connect()); 3565 } 3566 } 3567 stop() { 3568 if (this.started) { 3569 this.started = false; 3570 this.eventListeners.forEach((eventListener) => eventListener.disconnect()); 3571 } 3572 } 3573 get eventListeners() { 3574 return Array.from(this.eventListenerMaps.values()).reduce((listeners, map) => listeners.concat(Array.from(map.values())), []); 3575 } 3576 // Binding observer delegate 3577 bindingConnected(binding) { 3578 this.fetchEventListenerForBinding(binding).bindingConnected(binding); 3579 } 3580 bindingDisconnected(binding, clearEventListeners = false) { 3581 this.fetchEventListenerForBinding(binding).bindingDisconnected(binding); 3582 if (clearEventListeners) 3583 this.clearEventListenersForBinding(binding); 3584 } 3585 // Error handling 3586 handleError(error, message, detail = {}) { 3587 this.application.handleError(error, `Error ${message}`, detail); 3588 } 3589 clearEventListenersForBinding(binding) { 3590 const eventListener = this.fetchEventListenerForBinding(binding); 3591 if (!eventListener.hasBindings()) { 3592 eventListener.disconnect(); 3593 this.removeMappedEventListenerFor(binding); 3594 } 3595 } 3596 removeMappedEventListenerFor(binding) { 3597 const { eventTarget, eventName, eventOptions } = binding; 3598 const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); 3599 const cacheKey = this.cacheKey(eventName, eventOptions); 3600 eventListenerMap.delete(cacheKey); 3601 if (eventListenerMap.size == 0) { 3602 this.eventListenerMaps.delete(eventTarget); 3603 } 3604 } 3605 fetchEventListenerForBinding(binding) { 3606 const { eventTarget, eventName, eventOptions } = binding; 3607 return this.fetchEventListener(eventTarget, eventName, eventOptions); 3608 } 3609 fetchEventListener(eventTarget, eventName, eventOptions) { 3610 const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); 3611 const cacheKey = this.cacheKey(eventName, eventOptions); 3612 let eventListener = eventListenerMap.get(cacheKey); 3613 if (!eventListener) { 3614 eventListener = this.createEventListener(eventTarget, eventName, eventOptions); 3615 eventListenerMap.set(cacheKey, eventListener); 3616 } 3617 return eventListener; 3618 } 3619 createEventListener(eventTarget, eventName, eventOptions) { 3620 const eventListener = new EventListener(eventTarget, eventName, eventOptions); 3621 if (this.started) { 3622 eventListener.connect(); 3623 } 3624 return eventListener; 3625 } 3626 fetchEventListenerMapForEventTarget(eventTarget) { 3627 let eventListenerMap = this.eventListenerMaps.get(eventTarget); 3628 if (!eventListenerMap) { 3629 eventListenerMap = /* @__PURE__ */ new Map(); 3630 this.eventListenerMaps.set(eventTarget, eventListenerMap); 3631 } 3632 return eventListenerMap; 3633 } 3634 cacheKey(eventName, eventOptions) { 3635 const parts = [eventName]; 3636 Object.keys(eventOptions).sort().forEach((key) => { 3637 parts.push(`${eventOptions[key] ? "" : "!"}${key}`); 3638 }); 3639 return parts.join(":"); 3640 } 3641 }; 3642 3643
3643// ../../vendor/larajax/larajax/resources/src/observe/context.js 3644 var Context = class { 3645 constructor(module, scope) { 3646 this.module = module; 3647 this.scope = scope; 3648 this.control = new module.controlConstructor(this); 3649 try { 3650 this.control.initBefore(); 3651 this.control.init(); 3652 this.control.initAfter(); 3653 } catch (error) { 3654 this.handleError(error, "initializing control"); 3655 } 3656 } 3657 connect() { 3658 try { 3659 this.control.connectBefore(); 3660 this.control.connect(); 3661 this.control.connectAfter(); 3662 } catch (error) { 3663 this.handleError(error, "connecting control"); 3664 } 3665 } 3666 refresh() { 3667 } 3668 disconnect() { 3669 try { 3670 this.control.disconnectBefore(); 3671 this.control.disconnect(); 3672 this.control.disconnectAfter(); 3673 } catch (error) { 3674 this.handleError(error, "disconnecting control"); 3675 } 3676 } 3677 get application() { 3678 return this.module.application; 3679 } 3680 get identifier() { 3681 return this.module.identifier; 3682 } 3683 get dispatcher() { 3684 return this.application.dispatcher; 3685 } 3686 get element() { 3687 return this.scope.element; 3688 } 3689 get parentElement() { 3690 return this.element.parentElement; 3691 } 3692 // Error handling 3693 handleError(error, message, detail = {}) { 3694 const { identifier, control, element } = this; 3695 detail = Object.assign({ identifier, control, element }, detail); 3696 this.application.handleError(error, `Error ${message}`, detail); 3697 } 3698 }; 3699 3700
3700// ../../vendor/larajax/larajax/resources/src/observe/module.js 3701 var Module = class { 3702 constructor(application2, definition) { 3703 this.application = application2; 3704 this.definition = blessDefinition(definition); 3705 this.contextsByScope = /* @__PURE__ */ new WeakMap(); 3706 this.connectedContexts = /* @__PURE__ */ new Set(); 3707 } 3708 get identifier() { 3709 return this.definition.identifier; 3710 } 3711 get controlConstructor() { 3712 return this.definition.controlConstructor; 3713 } 3714 get contexts() { 3715 return Array.from(this.connectedContexts); 3716 } 3717 connectContextForScope(scope) { 3718 const context = this.fetchContextForScope(scope); 3719 this.connectedContexts.add(context); 3720 context.connect(); 3721 } 3722 disconnectContextForScope(scope) { 3723 const context = this.contextsByScope.get(scope); 3724 if (context) { 3725 this.connectedContexts.delete(context); 3726 context.disconnect(); 3727 } 3728 } 3729 fetchContextForScope(scope) { 3730 let context = this.contextsByScope.get(scope); 3731 if (!context) { 3732 context = new Context(this, scope); 3733 this.contextsByScope.set(scope, context); 3734 } 3735 return context; 3736 } 3737 }; 3738 function blessDefinition(definition) { 3739 return { 3740 identifier: definition.identifier, 3741 controlConstructor: definition.controlConstructor 3742 }; 3743 } 3744 3745
3745// ../../vendor/larajax/larajax/resources/src/observe/scope.js 3746 var Scope = class _Scope { 3747 constructor(element, identifier) { 3748 this.element = element; 3749 this.identifier = identifier; 3750 this.containsElement = (element2) => { 3751 return element2.closest(this.controlSelector) === this.element; 3752 }; 3753 } 3754 findElement(selector) { 3755 return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement); 3756 } 3757 findAllElements(selector) { 3758 return [ 3759 ...this.element.matches(selector) ? [this.element] : [], 3760 ...this.queryElements(selector).filter(this.containsElement) 3761 ]; 3762 } 3763 queryElements(selector) { 3764 return Array.from(this.element.querySelectorAll(selector)); 3765 } 3766 get controlSelector() { 3767 return attributeValueContainsToken("data-control", this.identifier); 3768 } 3769 get isDocumentScope() { 3770 return this.element === document.documentElement; 3771 } 3772 get documentScope() { 3773 return this.isDocumentScope ? this : new _Scope(document.documentElement, this.identifier); 3774 } 3775 }; 3776 function attributeValueContainsToken(attributeName, token) { 3777 return `[${attributeName}~="${token}"]`; 3778 } 3779 3780
vendor: 4,169 bytes, lines 3780-3916
3780// ../../vendor/larajax/larajax/resources/src/observe/mutation/element-observer.js 3781 var ElementObserver = class { 3782 constructor(element, delegate) { 3783 this.mutationObserverInit = { attributes: true, childList: true, subtree: true }; 3784 this.element = element; 3785 this.started = false; 3786 this.delegate = delegate; 3787 this.elements = /* @__PURE__ */ new Set(); 3788 this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations)); 3789 } 3790 start() { 3791 if (!this.started) { 3792 this.started = true; 3793 this.mutationObserver.observe(this.element, this.mutationObserverInit); 3794 this.refresh(); 3795 } 3796 } 3797 pause(callback) { 3798 if (this.started) { 3799 this.mutationObserver.disconnect(); 3800 this.started = false; 3801 } 3802 callback(); 3803 if (!this.started) { 3804 this.mutationObserver.observe(this.element, this.mutationObserverInit); 3805 this.started = true; 3806 } 3807 } 3808 stop() { 3809 if (this.started) { 3810 this.mutationObserver.takeRecords(); 3811 this.mutationObserver.disconnect(); 3812 this.started = false; 3813 } 3814 } 3815 refresh() { 3816 if (this.started) { 3817 const matches = new Set(this.matchElementsInTree()); 3818 for (const element of Array.from(this.elements)) { 3819 if (!matches.has(element)) { 3820 this.removeElement(element); 3821 } 3822 } 3823 for (const element of Array.from(matches)) { 3824 this.addElement(element); 3825 } 3826 } 3827 } 3828 // Mutation record processing 3829 processMutations(mutations) { 3830 if (this.started) { 3831 for (const mutation of mutations) { 3832 this.processMutation(mutation); 3833 } 3834 } 3835 } 3836 processMutation(mutation) { 3837 if (mutation.type == "attributes") { 3838 this.processAttributeChange(mutation.target, mutation.attributeName); 3839 } else if (mutation.type == "childList") { 3840 this.processRemovedNodes(mutation.removedNodes); 3841 this.processAddedNodes(mutation.addedNodes); 3842 } 3843 } 3844 processAttributeChange(element, attributeName) { 3845 if (this.elements.has(element)) { 3846 if (this.delegate.elementAttributeChanged && this.matchElement(element)) { 3847 this.delegate.elementAttributeChanged(element, attributeName); 3848 } else { 3849 this.removeElement(element); 3850 } 3851 } else if (this.matchElement(element)) { 3852 this.addElement(element); 3853 } 3854 } 3855 processRemovedNodes(nodes) { 3856 for (const node of Array.from(nodes)) { 3857 const element = this.elementFromNode(node); 3858 if (element) { 3859 this.processTree(element, this.removeElement); 3860 } 3861 } 3862 } 3863 processAddedNodes(nodes) { 3864 for (const node of Array.from(nodes)) { 3865 const element = this.elementFromNode(node); 3866 if (element && this.elementIsActive(element)) { 3867 this.processTree(element, this.addElement); 3868 } 3869 } 3870 } 3871 // Element matching 3872 matchElement(element) { 3873 return this.delegate.matchElement(element); 3874 } 3875 matchElementsInTree(tree = this.element) { 3876 return this.delegate.matchElementsInTree(tree); 3877 } 3878 processTree(tree, processor) { 3879 for (const element of this.matchElementsInTree(tree)) { 3880 processor.call(this, element); 3881 } 3882 } 3883 elementFromNode(node) { 3884 if (node.nodeType == Node.ELEMENT_NODE) { 3885 return node; 3886 } 3887 } 3888 elementIsActive(element) { 3889 if (element.isConnected != this.element.isConnected) { 3890 return false; 3891 } else { 3892 return this.element.contains(element); 3893 } 3894 } 3895 // Element tracking 3896 addElement(element) { 3897 if (!this.elements.has(element)) { 3898 if (this.elementIsActive(element)) { 3899 this.elements.add(element); 3900 if (this.delegate.elementMatched) { 3901 this.delegate.elementMatched(element); 3902 } 3903 } 3904 } 3905 } 3906 removeElement(element) { 3907 if (this.elements.has(element)) { 3908 this.elements.delete(element); 3909 if (this.delegate.elementUnmatched) { 3910 this.delegate.elementUnmatched(element); 3911 } 3912 } 3913 } 3914 }; 3915 3916
3916// ../../vendor/larajax/larajax/resources/src/observe/mutation/attribute-observer.js 3917 var AttributeObserver = class { 3918 constructor(element, attributeName, delegate) { 3919 this.delegate = delegate; 3920 this.attributeName = attributeName; 3921 this.elementObserver = new ElementObserver(element, this); 3922 } 3923 get element() { 3924 return this.elementObserver.element; 3925 } 3926 get selector() { 3927 return `[${this.attributeName}]`; 3928 } 3929 start() { 3930 this.elementObserver.start(); 3931 } 3932 pause(callback) { 3933 this.elementObserver.pause(callback); 3934 } 3935 stop() { 3936 this.elementObserver.stop(); 3937 } 3938 refresh() { 3939 this.elementObserver.refresh(); 3940 } 3941 get started() { 3942 return this.elementObserver.started; 3943 } 3944 // Element observer delegate 3945 matchElement(element) { 3946 return element.hasAttribute(this.attributeName); 3947 } 3948 matchElementsInTree(tree) { 3949 const match = this.matchElement(tree) ? [tree] : []; 3950 const matches = Array.from(tree.querySelectorAll(this.selector)); 3951 return match.concat(matches); 3952 } 3953 elementMatched(element) { 3954 if (this.delegate.elementMatchedAttribute) { 3955 this.delegate.elementMatchedAttribute(element, this.attributeName); 3956 } 3957 } 3958 elementUnmatched(element) { 3959 if (this.delegate.elementUnmatchedAttribute) { 3960 this.delegate.elementUnmatchedAttribute(element, this.attributeName); 3961 } 3962 } 3963 elementAttributeChanged(element, attributeName) { 3964 if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) { 3965 this.delegate.elementAttributeValueChanged(element, attributeName); 3966 } 3967 } 3968 }; 3969 3970
3970// ../../vendor/larajax/larajax/resources/src/observe/util/set-operations.js 3971 function add(map, key, value) { 3972 fetch2(map, key).add(value); 3973 } 3974 function del(map, key, value) { 3975 fetch2(map, key).delete(value); 3976 prune(map, key); 3977 } 3978 function fetch2(map, key) { 3979 let values = map.get(key); 3980 if (!values) { 3981 values = /* @__PURE__ */ new Set(); 3982 map.set(key, values); 3983 } 3984 return values; 3985 } 3986 function prune(map, key) { 3987 const values = map.get(key); 3988 if (values != null && values.size == 0) { 3989 map.delete(key); 3990 } 3991 } 3992 3993
3993// ../../vendor/larajax/larajax/resources/src/observe/util/multimap.js 3994 var Multimap = class { 3995 constructor() { 3996 this.valuesByKey = /* @__PURE__ */ new Map(); 3997 } 3998 get keys() { 3999 return Array.from(this.valuesByKey.keys()); 4000 } 4001 get values() { 4002 const sets = Array.from(this.valuesByKey.values()); 4003 return sets.reduce((values, set) => values.concat(Array.from(set)), React.createElement(V, null), [] > []); 4004 } 4005 get size() { 4006 const sets = Array.from(this.valuesByKey.values()); 4007 return sets.reduce((size, set) => size + set.size, 0); 4008 } 4009 add(key, value) { 4010 add(this.valuesByKey, key, value); 4011 } 4012 delete(key, value) { 4013 del(this.valuesByKey, key, value); 4014 } 4015 has(key, value) { 4016 const values = this.valuesByKey.get(key); 4017 return values != null && values.has(value); 4018 } 4019 hasKey(key) { 4020 return this.valuesByKey.has(key); 4021 } 4022 hasValue(value) { 4023 const sets = Array.from(this.valuesByKey.values()); 4024 return sets.some((set) => set.has(value)); 4025 } 4026 getValuesForKey(key) { 4027 const values = this.valuesByKey.get(key); 4028 return values ? Array.from(values) : []; 4029 } 4030 getKeysForValue(value) { 4031 return Array.from(this.valuesByKey).filter(([_key, values]) => values.has(value)).map(([key, _values]) => key); 4032 } 4033 }; 4034 4035
vendor: 5,199 bytes, lines 4035-4184
4035// ../../vendor/larajax/larajax/resources/src/observe/mutation/token-list-observer.js 4036 var TokenListObserver = class { 4037 constructor(element, attributeName, delegate) { 4038 this.delegate = delegate; 4039 this.attributeObserver = new AttributeObserver(element, attributeName, this); 4040 this.tokensByElement = new Multimap(); 4041 } 4042 get started() { 4043 return this.attributeObserver.started; 4044 } 4045 start() { 4046 this.attributeObserver.start(); 4047 } 4048 pause(callback) { 4049 this.attributeObserver.pause(callback); 4050 } 4051 stop() { 4052 this.attributeObserver.stop(); 4053 } 4054 refresh() { 4055 this.attributeObserver.refresh(); 4056 } 4057 get element() { 4058 return this.attributeObserver.element; 4059 } 4060 get attributeName() { 4061 return this.attributeObserver.attributeName; 4062 } 4063 // Attribute observer delegate 4064 elementMatchedAttribute(element) { 4065 this.tokensMatched(this.readTokensForElement(element)); 4066 } 4067 elementAttributeValueChanged(element) { 4068 const [unmatchedTokens, matchedTokens] = this.refreshTokensForElement(element); 4069 this.tokensUnmatched(unmatchedTokens); 4070 this.tokensMatched(matchedTokens); 4071 } 4072 elementUnmatchedAttribute(element) { 4073 this.tokensUnmatched(this.tokensByElement.getValuesForKey(element)); 4074 } 4075 tokensMatched(tokens) { 4076 tokens.forEach((token) => this.tokenMatched(token)); 4077 } 4078 tokensUnmatched(tokens) { 4079 tokens.forEach((token) => this.tokenUnmatched(token)); 4080 } 4081 tokenMatched(token) { 4082 this.delegate.tokenMatched(token); 4083 this.tokensByElement.add(token.element, token); 4084 } 4085 tokenUnmatched(token) { 4086 this.delegate.tokenUnmatched(token); 4087 this.tokensByElement.delete(token.element, token); 4088 } 4089 refreshTokensForElement(element) { 4090 const previousTokens = this.tokensByElement.getValuesForKey(element); 4091 const currentTokens = this.readTokensForElement(element); 4092 const firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(([previousToken, currentToken]) => !tokensAreEqual(previousToken, currentToken)); 4093 if (firstDifferingIndex == -1) { 4094 return [[], []]; 4095 } else { 4096 return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)]; 4097 } 4098 } 4099 readTokensForElement(element) { 4100 const attributeName = this.attributeName; 4101 const tokenString = element.getAttribute(attributeName) || ""; 4102 return parseTokenString(tokenString, element, attributeName); 4103 } 4104 }; 4105 function parseTokenString(tokenString, element, attributeName) { 4106 return tokenString.trim().split(/\s+/).filter((content) => content.length).map((content, index) => ({ element, attributeName, content, index })); 4107 } 4108 function zip(left, right) { 4109 const length = Math.max(left.length, right.length); 4110 return Array.from({ length }, (_, index) => [left[index], right[index]]); 4111 } 4112 function tokensAreEqual(left, right) { 4113 return left && right && left.index == right.index && left.content == right.content; 4114 } 4115 4116 // ../../vendor/larajax/larajax/resources/src/observe/mutation/value-list-observer.js 4117 var ValueListObserver = class { 4118 constructor(element, attributeName, delegate) { 4119 this.tokenListObserver = new TokenListObserver(element, attributeName, this); 4120 this.delegate = delegate; 4121 this.parseResultsByToken = /* @__PURE__ */ new WeakMap(); 4122 this.valuesByTokenByElement = /* @__PURE__ */ new WeakMap(); 4123 } 4124 get started() { 4125 return this.tokenListObserver.started; 4126 } 4127 start() { 4128 this.tokenListObserver.start(); 4129 } 4130 stop() { 4131 this.tokenListObserver.stop(); 4132 } 4133 refresh() { 4134 this.tokenListObserver.refresh(); 4135 } 4136 get element() { 4137 return this.tokenListObserver.element; 4138 } 4139 get attributeName() { 4140 return this.tokenListObserver.attributeName; 4141 } 4142 tokenMatched(token) { 4143 const { element } = token; 4144 const { value } = this.fetchParseResultForToken(token); 4145 if (value) { 4146 this.fetchValuesByTokenForElement(element).set(token, value); 4147 this.delegate.elementMatchedValue(element, value); 4148 } 4149 } 4150 tokenUnmatched(token) { 4151 const { element } = token; 4152 const { value } = this.fetchParseResultForToken(token); 4153 if (value) { 4154 this.fetchValuesByTokenForElement(element).delete(token); 4155 this.delegate.elementUnmatchedValue(element, value); 4156 } 4157 } 4158 fetchParseResultForToken(token) { 4159 let parseResult = this.parseResultsByToken.get(token); 4160 if (!parseResult) { 4161 parseResult = this.parseToken(token); 4162 this.parseResultsByToken.set(token, parseResult); 4163 } 4164 return parseResult; 4165 } 4166 fetchValuesByTokenForElement(element) { 4167 let valuesByToken = this.valuesByTokenByElement.get(element); 4168 if (!valuesByToken) { 4169 valuesByToken = /* @__PURE__ */ new Map(); 4170 this.valuesByTokenByElement.set(element, valuesByToken); 4171 } 4172 return valuesByToken; 4173 } 4174 parseToken(token) { 4175 try { 4176 const value = this.delegate.parseValueForToken(token); 4177 return { value }; 4178 } catch (error) { 4179 return { error }; 4180 } 4181 } 4182 }; 4183 4184
4184// ../../vendor/larajax/larajax/resources/src/observe/scope-observer.js 4185 var ScopeObserver = class { 4186 constructor(element, delegate) { 4187 this.element = element; 4188 this.delegate = delegate; 4189 this.valueListObserver = new ValueListObserver(this.element, this.controlAttribute, this); 4190 this.scopesByIdentifierByElement = /* @__PURE__ */ new WeakMap(); 4191 this.scopeReferenceCounts = /* @__PURE__ */ new WeakMap(); 4192 } 4193 start() { 4194 this.valueListObserver.start(); 4195 } 4196 stop() { 4197 this.valueListObserver.stop(); 4198 } 4199 get controlAttribute() { 4200 return "data-control"; 4201 } 4202 // Value observer delegate 4203 parseValueForToken(token) { 4204 const { element, content: identifier } = token; 4205 const scopesByIdentifier = this.fetchScopesByIdentifierForElement(element); 4206 let scope = scopesByIdentifier.get(identifier); 4207 if (!scope) { 4208 scope = this.delegate.createScopeForElementAndIdentifier(element, identifier); 4209 scopesByIdentifier.set(identifier, scope); 4210 } 4211 return scope; 4212 } 4213 elementMatchedValue(element, value) { 4214 const referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1; 4215 this.scopeReferenceCounts.set(value, referenceCount); 4216 if (referenceCount == 1) { 4217 this.delegate.scopeConnected(value); 4218 } 4219 } 4220 elementUnmatchedValue(element, value) { 4221 const referenceCount = this.scopeReferenceCounts.get(value); 4222 if (referenceCount) { 4223 this.scopeReferenceCounts.set(value, referenceCount - 1); 4224 if (referenceCount == 1) { 4225 this.delegate.scopeDisconnected(value); 4226 } 4227 } 4228 } 4229 fetchScopesByIdentifierForElement(element) { 4230 let scopesByIdentifier = this.scopesByIdentifierByElement.get(element); 4231 if (!scopesByIdentifier) { 4232 scopesByIdentifier = /* @__PURE__ */ new Map(); 4233 this.scopesByIdentifierByElement.set(element, scopesByIdentifier); 4234 } 4235 return scopesByIdentifier; 4236 } 4237 }; 4238 4239
vendor: 2,898 bytes, lines 4239-4321
4239// ../../vendor/larajax/larajax/resources/src/observe/container.js 4240 var Container = class { 4241 constructor(application2) { 4242 this.application = application2; 4243 this.scopeObserver = new ScopeObserver(this.element, this); 4244 this.scopesByIdentifier = new Multimap(); 4245 this.modulesByIdentifier = /* @__PURE__ */ new Map(); 4246 } 4247 get element() { 4248 return this.application.element; 4249 } 4250 get modules() { 4251 return Array.from(this.modulesByIdentifier.values()); 4252 } 4253 get contexts() { 4254 return this.modules.reduce((contexts, module) => contexts.concat(module.contexts), []); 4255 } 4256 start() { 4257 this.scopeObserver.start(); 4258 } 4259 stop() { 4260 this.scopeObserver.stop(); 4261 } 4262 loadDefinition(definition) { 4263 this.unloadIdentifier(definition.identifier); 4264 const module = new Module(this.application, definition); 4265 this.connectModule(module); 4266 const afterLoad = definition.controlConstructor.afterLoad; 4267 if (afterLoad) { 4268 afterLoad.call(definition.controlConstructor, definition.identifier, this.application); 4269 } 4270 } 4271 unloadIdentifier(identifier) { 4272 const module = this.modulesByIdentifier.get(identifier); 4273 if (module) { 4274 this.disconnectModule(module); 4275 } 4276 } 4277 getModuleForIdentifier(identifier) { 4278 return this.modulesByIdentifier.get(identifier); 4279 } 4280 getContextForElementAndIdentifier(element, identifier) { 4281 const module = this.modulesByIdentifier.get(identifier); 4282 if (module) { 4283 return module.contexts.find((context) => context.element == element); 4284 } 4285 } 4286 // Error handler delegate 4287 handleError(error, message, detail) { 4288 this.application.handleError(error, message, detail); 4289 } 4290 // Scope observer delegate 4291 createScopeForElementAndIdentifier(element, identifier) { 4292 return new Scope(element, identifier); 4293 } 4294 scopeConnected(scope) { 4295 this.scopesByIdentifier.add(scope.identifier, scope); 4296 const module = this.modulesByIdentifier.get(scope.identifier); 4297 if (module) { 4298 module.connectContextForScope(scope); 4299 } 4300 } 4301 scopeDisconnected(scope) { 4302 this.scopesByIdentifier.delete(scope.identifier, scope); 4303 const module = this.modulesByIdentifier.get(scope.identifier); 4304 if (module) { 4305 module.disconnectContextForScope(scope); 4306 } 4307 } 4308 // Modules 4309 connectModule(module) { 4310 this.modulesByIdentifier.set(module.identifier, module); 4311 const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); 4312 scopes.forEach((scope) => module.connectContextForScope(scope)); 4313 } 4314 disconnectModule(module) { 4315 this.modulesByIdentifier.delete(module.identifier); 4316 const scopes = this.scopesByIdentifier.getValuesForKey(module.identifier); 4317 scopes.forEach((scope) => module.disconnectContextForScope(scope)); 4318 } 4319 }; 4320 4321
4321// ../../vendor/larajax/larajax/resources/src/observe/application.js 4322 var Application = class { 4323 constructor() { 4324 this.started = false; 4325 this.element = document.documentElement; 4326 this.dispatcher = new Dispatcher(this); 4327 this.container = new Container(this); 4328 } 4329 startAsync() { 4330 domReady().then(() => { 4331 this.start(); 4332 }); 4333 } 4334 start() { 4335 if (!this.started) { 4336 this.started = true; 4337 this.dispatcher.start(); 4338 this.container.start(); 4339 } 4340 } 4341 stop() { 4342 if (this.started) { 4343 this.dispatcher.stop(); 4344 this.container.stop(); 4345 this.started = false; 4346 } 4347 } 4348 register(identifier, controlConstructor) { 4349 this.load({ identifier, controlConstructor }); 4350 } 4351 observe(element, identifier) { 4352 const observer = this.container.scopeObserver; 4353 observer.elementMatchedValue(element, observer.parseValueForToken({ 4354 element, 4355 content: identifier 4356 })); 4357 const foundControl = this.getControlForElementAndIdentifier(element, identifier); 4358 if (!element.matches(`[data-control~="${identifier}"]`)) { 4359 element.dataset.control = ((element.dataset.control || "") + " " + identifier).trim(); 4360 } 4361 return foundControl; 4362 } 4363 import(identifier) { 4364 const module = this.container.getModuleForIdentifier(identifier); 4365 if (!module) { 4366 throw new Error(`Control is not registered [${identifier}]`); 4367 } 4368 return module.controlConstructor; 4369 } 4370 fetch(element, identifier) { 4371 if (typeof element === "string") { 4372 element = document.querySelector(element); 4373 } 4374 if (!identifier) { 4375 identifier = element.dataset.control; 4376 } 4377 return element ? this.getControlForElementAndIdentifier(element, identifier) : null; 4378 } 4379 fetchAll(elements, identifier) { 4380 if (typeof elements === "string") { 4381 elements = document.querySelectorAll(elements); 4382 } 4383 const result = []; 4384 elements.forEach((element) => { 4385 const control = this.fetch(element, identifier); 4386 if (control) { 4387 result.push(control); 4388 } 4389 }); 4390 return result; 4391 } 4392 load(head, ...rest) { 4393 const definitions = Array.isArray(head) ? head : [head, ...rest]; 4394 definitions.forEach((definition) => { 4395 if (definition.controlConstructor.shouldLoad) { 4396 this.container.loadDefinition(definition); 4397 } 4398 }); 4399 } 4400 unload(head, ...rest) { 4401 const identifiers = Array.isArray(head) ? head : [head, ...rest]; 4402 identifiers.forEach((identifier) => this.container.unloadIdentifier(identifier)); 4403 } 4404 // Controls 4405 get controls() { 4406 return this.container.contexts.map((context) => context.control); 4407 } 4408 getControlForElementAndIdentifier(element, identifier) { 4409 const context = this.container.getContextForElementAndIdentifier(element, identifier); 4410 return context ? context.control : null; 4411 } 4412 // Error handling 4413 handleError(error, message, detail) { 4414 var _a; 4415 console.error(`%s 4416 4417%o 4418 4419%o`, message, error, detail); 4420 (_a = window.onerror) === null || _a === void 0 ? void 0 : _a.call(window, message, "", 0, 0, error); 4421 } 4422 }; 4423 4424
4424// ../../vendor/larajax/larajax/resources/src/observe/namespace.js 4425 var application = new Application(); 4426 var namespace_default4 = { 4427 application, 4428 registerControl(id, control) { 4429 return application.register(id, control); 4430 }, 4431 importControl(id) { 4432 return application.import(id); 4433 }, 4434 observeControl(element, id) { 4435 return application.observe(element, id); 4436 }, 4437 fetchControl(element, identifier) { 4438 return application.fetch(element, identifier); 4439 }, 4440 fetchControls(elements, identifier) { 4441 return application.fetchAll(elements, identifier); 4442 }, 4443 start() { 4444 application.startAsync(); 4445 }, 4446 stop() { 4447 application.stop(); 4448 } 4449 }; 4450 4451
4451// ../../vendor/larajax/larajax/resources/src/turbo/browser-adapter.js 4452 var BrowserAdapter = class { 4453 constructor(controller4) { 4454 this.progressBar = new ProgressBar(); 4455 this.showProgressBar = () => { 4456 this.progressBar.show({ cssClass: "is-turbo" }); 4457 }; 4458 this.controller = controller4; 4459 } 4460 visitProposedToLocationWithAction(location2, action) { 4461 const restorationIdentifier = uuid(); 4462 this.controller.startVisitToLocationWithAction(location2, action, restorationIdentifier); 4463 } 4464 visitStarted(visit) { 4465 visit.issueRequest(); 4466 visit.changeHistory(); 4467 visit.goToSamePageAnchor(); 4468 } 4469 visitRequestStarted(visit) { 4470 this.progressBar.setValue(0); 4471 this.showProgressBarAfterDelay(); 4472 } 4473 visitRequestProgressed(visit) { 4474 this.progressBar.setValue(visit.progress); 4475 } 4476 visitRequestCompleted(visit) { 4477 visit.loadResponse(); 4478 } 4479 visitRequestFailedWithStatusCode(visit, statusCode) { 4480 switch (statusCode) { 4481 case SystemStatusCode.networkFailure: 4482 case SystemStatusCode.timeoutFailure: 4483 case SystemStatusCode.contentTypeMismatch: 4484 case SystemStatusCode.userAborted: 4485 return this.reload(); 4486 default: 4487 return visit.loadResponse(); 4488 } 4489 } 4490 visitRequestFinished(visit) { 4491 this.hideProgressBar(); 4492 } 4493 visitCompleted(visit) { 4494 visit.followRedirect(); 4495 } 4496 pageInvalidated() { 4497 this.reload(); 4498 } 4499 visitFailed(visit) { 4500 } 4501 visitRendered(visit) { 4502 } 4503 // Private 4504 showProgressBarAfterDelay() { 4505 if (this.controller.progressBarVisible) { 4506 this.progressBarTimeout = window.setTimeout(this.showProgressBar, this.controller.progressBarDelay); 4507 } 4508 } 4509 hideProgressBar() { 4510 if (this.controller.progressBarVisible) { 4511 this.progressBar.hide(); 4512 if (this.progressBarTimeout !== null) { 4513 window.clearTimeout(this.progressBarTimeout); 4514 delete this.progressBarTimeout; 4515 } 4516 } 4517 } 4518 reload() { 4519 window.location.reload(); 4520 } 4521 }; 4522 4523
4523// ../../vendor/larajax/larajax/resources/src/turbo/location.js 4524 var Location = class _Location { 4525 constructor(url) { 4526 const linkWithAnchor = document.createElement("a"); 4527 linkWithAnchor.href = url; 4528 this.absoluteURL = linkWithAnchor.href; 4529 const anchorLength = linkWithAnchor.hash.length; 4530 if (anchorLength < 2) { 4531 this.requestURL = this.absoluteURL; 4532 } else { 4533 this.requestURL = this.absoluteURL.slice(0, -anchorLength); 4534 this.anchor = linkWithAnchor.hash.slice(1); 4535 } 4536 } 4537 static get currentLocation() { 4538 return this.wrap(window.location.toString()); 4539 } 4540 static wrap(locatable) { 4541 if (typeof locatable == "string") { 4542 return new _Location(locatable); 4543 } else if (locatable != null) { 4544 return locatable; 4545 } 4546 } 4547 getOrigin() { 4548 return this.absoluteURL.split("/", 3).join("/"); 4549 } 4550 getPath() { 4551 return (this.requestURL.match(/\/\/[^/]*(\/[^?;]*)/) || [])[1] || "/"; 4552 } 4553 getPathComponents() { 4554 return this.getPath().split("/").slice(1); 4555 } 4556 getLastPathComponent() { 4557 return this.getPathComponents().slice(-1)[0]; 4558 } 4559 getExtension() { 4560 return (this.getLastPathComponent().match(/\.[^.]*$/) || [])[0] || ""; 4561 } 4562 isHTML() { 4563 return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/); 4564 } 4565 isPrefixedBy(location2) { 4566 const prefixURL = getPrefixURL(location2); 4567 return this.isEqualTo(location2) || stringStartsWith(this.absoluteURL, prefixURL); 4568 } 4569 isEqualTo(location2) { 4570 return location2 && this.absoluteURL === location2.absoluteURL; 4571 } 4572 toJSON() { 4573 return this.absoluteURL; 4574 } 4575 toString() { 4576 return this.absoluteURL; 4577 } 4578 valueOf() { 4579 return this.absoluteURL; 4580 } 4581 }; 4582 function getPrefixURL(location2) { 4583 return addTrailingSlash(location2.getOrigin() + location2.getPath()); 4584 } 4585 function addTrailingSlash(url) { 4586 return stringEndsWith(url, "/") ? url : url + "/"; 4587 } 4588 function stringStartsWith(string, prefix) { 4589 return string.slice(0, prefix.length) === prefix; 4590 } 4591 function stringEndsWith(string, suffix) { 4592 return string.slice(-suffix.length) === suffix; 4593 } 4594 4595
4595// ../../vendor/larajax/larajax/resources/src/turbo/history.js 4596 var History = class { 4597 constructor(delegate) { 4598 this.started = false; 4599 this.pageLoaded = false; 4600 this.currentPosition = 0; 4601 this.onPopState = (event) => { 4602 if (!this.shouldHandlePopState()) { 4603 return; 4604 } 4605 if (!event.state || !event.state.ajaxTurbo) { 4606 return; 4607 } 4608 const { ajaxTurbo } = event.state; 4609 const location2 = Location.currentLocation; 4610 const { restorationIdentifier, position } = ajaxTurbo; 4611 const direction = typeof position === "number" && position > this.currentPosition ? "forward" : "back"; 4612 this.currentPosition = typeof position === "number" ? position : this.currentPosition; 4613 this.delegate.historyPoppedToLocationWithRestorationIdentifier(location2, restorationIdentifier, direction); 4614 }; 4615 this.onPageLoad = (event) => { 4616 defer(() => { 4617 this.pageLoaded = true; 4618 }); 4619 }; 4620 this.delegate = delegate; 4621 } 4622 start() { 4623 if (!this.started) { 4624 addEventListener("popstate", this.onPopState, false); 4625 addEventListener("load", this.onPageLoad, false); 4626 this.started = true; 4627 } 4628 } 4629 stop() { 4630 if (this.started) { 4631 removeEventListener("popstate", this.onPopState, false); 4632 removeEventListener("load", this.onPageLoad, false); 4633 this.started = false; 4634 } 4635 } 4636 push(location2, restorationIdentifier) { 4637 this.currentPosition++; 4638 this.update(history.pushState, location2, restorationIdentifier); 4639 } 4640 replace(location2, restorationIdentifier) { 4641 this.update(history.replaceState, location2, restorationIdentifier); 4642 } 4643 // Private 4644 shouldHandlePopState() { 4645 return this.pageIsLoaded(); 4646 } 4647 pageIsLoaded() { 4648 return this.pageLoaded || document.readyState == "complete"; 4649 } 4650 update(method, location2, restorationIdentifier) { 4651 const state = { ajaxTurbo: { restorationIdentifier, position: this.currentPosition } }; 4652 method.call(history, state, "", location2.absoluteURL); 4653 } 4654 }; 4655 4656
4656// ../../vendor/larajax/larajax/resources/src/turbo/scroll-manager.js 4657 var ScrollManager = class { 4658 constructor(delegate) { 4659 this.started = false; 4660 this.onScroll = () => { 4661 this.updatePosition({ x: window.pageXOffset, y: window.pageYOffset }); 4662 }; 4663 this.delegate = delegate; 4664 } 4665 start() { 4666 if (!this.started) { 4667 addEventListener("scroll", this.onScroll, false); 4668 this.onScroll(); 4669 this.started = true; 4670 } 4671 } 4672 stop() { 4673 if (this.started) { 4674 removeEventListener("scroll", this.onScroll, false); 4675 this.started = false; 4676 } 4677 } 4678 scrollToElement(element) { 4679 element.scrollIntoView(); 4680 } 4681 scrollToPosition({ x, y }) { 4682 window.scrollTo(x, y); 4683 } 4684 // Private 4685 updatePosition(position) { 4686 this.delegate.scrollPositionChanged(position); 4687 } 4688 }; 4689 4690
4690// ../../vendor/larajax/larajax/resources/src/turbo/renderer.js 4691 var Renderer = class { 4692 renderView(callback) { 4693 const renderInterception = () => { 4694 const completeRender = () => { 4695 callback(); 4696 this.delegate.viewRendered(this.newBody); 4697 }; 4698 if (this.willPerformViewTransition()) { 4699 const transition = document.startViewTransition(() => completeRender()); 4700 if (typeof this.delegate.setViewTransitionFinished === "function") { 4701 this.delegate.setViewTransitionFinished(transition.finished); 4702 } 4703 } else { 4704 completeRender(); 4705 } 4706 }; 4707 const options = { resume: renderInterception }; 4708 const immediateRender = this.delegate.viewAllowsImmediateRender(this.newBody, options); 4709 if (immediateRender) { 4710 renderInterception(); 4711 } 4712 } 4713 willPerformViewTransition() { 4714 return typeof document.startViewTransition === "function" && typeof this.delegate.viewTransitionEnabled === "function" && this.delegate.viewTransitionEnabled(); 4715 } 4716 invalidateView() { 4717 this.delegate.viewInvalidated(); 4718 } 4719 createScriptElement(element) { 4720 if (element.getAttribute("data-turbo-eval") === "false" || this.delegate.applicationHasSeenInlineScript(element)) { 4721 return element; 4722 } 4723 const createdScriptElement = document.createElement("script"); 4724 createdScriptElement.textContent = element.textContent; 4725 createdScriptElement.async = false; 4726 copyElementAttributes(createdScriptElement, element); 4727 return createdScriptElement; 4728 } 4729 }; 4730 function copyElementAttributes(destinationElement, sourceElement) { 4731 for (const { name, value } of array(sourceElement.attributes)) { 4732 destinationElement.setAttribute(name, value); 4733 } 4734 } 4735 4736
4736// ../../vendor/larajax/larajax/resources/src/turbo/error-renderer.js 4737 var ErrorRenderer = class extends Renderer { 4738 constructor(delegate, html) { 4739 super(); 4740 this.delegate = delegate; 4741 this.htmlElement = (() => { 4742 const htmlElement = document.createElement("html"); 4743 htmlElement.innerHTML = html; 4744 return htmlElement; 4745 })(); 4746 this.newHead = this.htmlElement.querySelector("head") || document.createElement("head"); 4747 this.newBody = this.htmlElement.querySelector("body") || document.createElement("body"); 4748 } 4749 static render(delegate, callback, html) { 4750 return new this(delegate, html).render(callback); 4751 } 4752 render(callback) { 4753 this.renderView(() => { 4754 this.replaceHeadAndBody(); 4755 this.activateBodyScriptElements(); 4756 callback(); 4757 }); 4758 } 4759 replaceHeadAndBody() { 4760 const { documentElement, head, body } = document; 4761 documentElement.replaceChild(this.newHead, head); 4762 documentElement.replaceChild(this.newBody, body); 4763 } 4764 activateBodyScriptElements() { 4765 for (const replaceableElement of this.getScriptElements()) { 4766 const parentNode = replaceableElement.parentNode; 4767 if (parentNode) { 4768 const element = this.createScriptElement(replaceableElement); 4769 parentNode.replaceChild(element, replaceableElement); 4770 } 4771 } 4772 } 4773 getScriptElements() { 4774 return array(document.documentElement.querySelectorAll("script")); 4775 } 4776 }; 4777 4778
4778// ../../vendor/larajax/larajax/resources/src/turbo/head-details.js 4779 var HeadDetails = class { 4780 constructor(children) { 4781 this.detailsByOuterHTML = children.reduce((result, element) => { 4782 const { outerHTML } = element; 4783 const details = outerHTML in result ? result[outerHTML] : { 4784 type: elementType(element), 4785 tracked: elementIsTracked(element), 4786 elements: [] 4787 }; 4788 return Object.assign(Object.assign({}, result), { [outerHTML]: Object.assign(Object.assign({}, details), { elements: [...details.elements, element] }) }); 4789 }, {}); 4790 } 4791 static fromHeadElement(headElement) { 4792 const children = headElement ? array(headElement.children) : []; 4793 return new this(children); 4794 } 4795 getTrackedElementSignature() { 4796 return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => this.detailsByOuterHTML[outerHTML].tracked).join(""); 4797 } 4798 getScriptElementsNotInDetails(headDetails) { 4799 return this.getElementsMatchingTypeNotInDetails("script", headDetails); 4800 } 4801 getStylesheetElementsNotInDetails(headDetails) { 4802 return this.getElementsMatchingTypeNotInDetails("stylesheet", headDetails); 4803 } 4804 getElementsMatchingTypeNotInDetails(matchedType, headDetails) { 4805 return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => !(outerHTML in headDetails.detailsByOuterHTML)).map((outerHTML) => this.detailsByOuterHTML[outerHTML]).filter(({ type }) => type == matchedType).map(({ elements: [element] }) => element); 4806 } 4807 getProvisionalElements() { 4808 return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => { 4809 const { type, tracked, elements } = this.detailsByOuterHTML[outerHTML]; 4810 if (type == null && !tracked) { 4811 return [...result, ...elements]; 4812 } else if (elements.length > 1) { 4813 return [...result, ...elements.slice(1)]; 4814 } else { 4815 return result; 4816 } 4817 }, []); 4818 } 4819 getMetaValue(name) { 4820 const element = this.findMetaElementByName(name); 4821 return element ? element.getAttribute("content") : null; 4822 } 4823 findMetaElementByName(name) { 4824 return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => { 4825 const { elements: [element] } = this.detailsByOuterHTML[outerHTML]; 4826 return elementIsMetaElementWithName(element, name) ? element : result; 4827 }, void 0); 4828 } 4829 }; 4830 function elementType(element) { 4831 if (elementIsScript(element)) { 4832 return "script"; 4833 } else if (elementIsStylesheet(element)) { 4834 return "stylesheet"; 4835 } 4836 } 4837 function elementIsTracked(element) { 4838 return element.getAttribute("data-turbo-track") == "reload"; 4839 } 4840 function elementIsScript(element) { 4841 const tagName = element.tagName.toLowerCase(); 4842 return tagName == "script"; 4843 } 4844 function elementIsStylesheet(element) { 4845 const tagName = element.tagName.toLowerCase(); 4846 return tagName == "style" || tagName == "link" && element.getAttribute("rel") == "stylesheet"; 4847 } 4848 function elementIsMetaElementWithName(element, name) { 4849 const tagName = element.tagName.toLowerCase(); 4850 return tagName == "meta" && element.getAttribute("name") == name; 4851 } 4852 4853
4853// ../../vendor/larajax/larajax/resources/src/turbo/page.js 4854 var Page = class { 4855 constructor(headDetails, bodyElement) { 4856 this.headDetails = headDetails; 4857 this.bodyElement = bodyElement; 4858 } 4859 static fromHTMLString(html) { 4860 const element = document.createElement("html"); 4861 element.innerHTML = html; 4862 return this.fromHTMLElement(element); 4863 } 4864 static fromHTMLElement(htmlElement) { 4865 const headElement = htmlElement.querySelector("head"); 4866 const bodyElement = htmlElement.querySelector("body") || document.createElement("body"); 4867 const headDetails = HeadDetails.fromHeadElement(headElement); 4868 return new this(headDetails, bodyElement); 4869 } 4870 getRootLocation() { 4871 const root = this.getSetting("root", "/"); 4872 return new Location(root); 4873 } 4874 getElementForAnchor(anchor) { 4875 try { 4876 return this.bodyElement.querySelector(`[id='${anchor}'], a[name='${anchor}']`); 4877 } catch (e) { 4878 return null; 4879 } 4880 } 4881 getPermanentElements() { 4882 return array(this.bodyElement.querySelectorAll("[id][data-turbo-permanent]")); 4883 } 4884 getPermanentElementById(id) { 4885 return this.bodyElement.querySelector(`#${id}[data-turbo-permanent]`); 4886 } 4887 getPermanentElementsPresentInPage(page) { 4888 return this.getPermanentElements().filter(({ id }) => page.getPermanentElementById(id)); 4889 } 4890 findFirstAutofocusableElement() { 4891 return this.bodyElement.querySelector("[autofocus]"); 4892 } 4893 isNativeError() { 4894 return this.getSetting("visit-control", false) != false; 4895 } 4896 isEnabled() { 4897 return this.getSetting("visit-control") != "disable"; 4898 } 4899 isVisitable() {
4900 return this.isEnabled() && this.getSetting("visit-control") != "reload"; 4901 } 4902 isViewTransitionEnabled() { 4903 return this.getSetting("view-transition") === "same-origin"; 4904 } 4905 getSetting(name, defaultValue) { 4906 const value = this.headDetails.getMetaValue(`turbo-${name}`); 4907 return value == null ? defaultValue : value; 4908 } 4909 }; 4910 4911
4911// ../../vendor/larajax/larajax/resources/src/turbo/page-renderer.js 4912 var PageRenderer = class extends Renderer { 4913 constructor(delegate, currentPage, newPage) { 4914 super(); 4915 this.delegate = delegate; 4916 this.currentPage = currentPage; 4917 this.currentHeadDetails = currentPage.headDetails; 4918 this.newPage = newPage; 4919 this.newHeadDetails = newPage.headDetails; 4920 this.newBody = newPage.bodyElement; 4921 } 4922 static render(delegate, callback, currentPage, newPage) { 4923 return new this(delegate, currentPage, newPage).render(callback); 4924 } 4925 render(callback) { 4926 if (this.shouldRender()) { 4927 this.delegate.pageIsReady = false; 4928 this.countNewBodyModuleScripts(); 4929 this.mergeHead(); 4930 this.renderView(() => { 4931 this.replaceBody(); 4932 this.focusFirstAutofocusableElement(); 4933 callback(); 4934 }); 4935 } else { 4936 this.invalidateView(); 4937 } 4938 } 4939 mergeHead() { 4940 this.copyNewHeadStylesheetElements(); 4941 this.copyNewHeadScriptElements(); 4942 this.removeCurrentHeadProvisionalElements(); 4943 this.copyNewHeadProvisionalElements(); 4944 } 4945 replaceBody() { 4946 const placeholders = this.relocateCurrentBodyPermanentElements(); 4947 this.activateNewBodyScriptElements(); 4948 this.assignNewBody(); 4949 this.replacePlaceholderElementsWithClonedPermanentElements(placeholders); 4950 } 4951 shouldRender() { 4952 return this.currentPage.isEnabled() && this.newPage.isVisitable() && this.trackedElementsAreIdentical(); 4953 } 4954 trackedElementsAreIdentical() { 4955 return this.currentHeadDetails.getTrackedElementSignature() == this.newHeadDetails.getTrackedElementSignature(); 4956 } 4957 copyNewHeadStylesheetElements() { 4958 for (const element of this.getNewHeadStylesheetElements()) { 4959 document.head.appendChild(element); 4960 } 4961 } 4962 copyNewHeadScriptElements() { 4963 for (const element of this.getNewHeadScriptElements()) { 4964 document.head.appendChild( 4965 this.bindPendingAssetLoadedEventOnce( 4966 this.createScriptElement(element) 4967 ) 4968 ); 4969 } 4970 } 4971 bindPendingAssetLoadedEventOnce(element) { 4972 if (!element.hasAttribute("src")) { 4973 return element; 4974 } 4975 var self = this, loadEvent = function() { 4976 self.delegate.decrementPendingAsset(); 4977 element.removeEventListener("load", loadEvent); 4978 }; 4979 element.addEventListener("load", loadEvent); 4980 this.delegate.incrementPendingAsset(); 4981 return element; 4982 } 4983 removeCurrentHeadProvisionalElements() { 4984 for (const element of this.getCurrentHeadProvisionalElements()) { 4985 document.head.removeChild(element); 4986 } 4987 } 4988 copyNewHeadProvisionalElements() { 4989 for (const element of this.getNewHeadProvisionalElements()) { 4990 document.head.appendChild(element); 4991 } 4992 } 4993 relocateCurrentBodyPermanentElements() { 4994 return this.getCurrentBodyPermanentElements().reduce((placeholders, permanentElement) => { 4995 const newElement = this.newPage.getPermanentElementById(permanentElement.id); 4996 if (newElement) { 4997 const placeholder = createPlaceholderForPermanentElement(permanentElement); 4998 replaceElementWithElement(permanentElement, placeholder.element); 4999 replaceElementWithElement(newElement, permanentElement); 5000 return [...placeholders, placeholder]; 5001 } else { 5002 return placeholders; 5003 } 5004 }, []); 5005 } 5006 replacePlaceholderElementsWithClonedPermanentElements(placeholders) { 5007 for (const { element, permanentElement } of placeholders) { 5008 const clonedElement = permanentElement.cloneNode(true); 5009 replaceElementWithElement(element, clonedElement); 5010 } 5011 } 5012 activateNewBodyScriptElements() { 5013 for (const inertScriptElement of this.getNewBodyScriptElements()) { 5014 const activatedScriptElement = this.createScriptElement(inertScriptElement); 5015 if (activatedScriptElement.getAttribute("type") === "module") { 5016 activatedScriptElement.textContent += "\ndispatchEvent(new CustomEvent('turbo:module-loaded'));"; 5017 } 5018 replaceElementWithElement(inertScriptElement, activatedScriptElement); 5019 } 5020 }
5021 countNewBodyModuleScripts() { 5022 for (const element of this.getNewBodyScriptElements()) { 5023 if (element.getAttribute("type") === "module") { 5024 this.delegate.incrementPendingAsset(); 5025 } 5026 } 5027 } 5028 assignNewBody() { 5029 replaceElementWithElement(document.body, this.newBody); 5030 } 5031 focusFirstAutofocusableElement() { 5032 const element = this.newPage.findFirstAutofocusableElement(); 5033 if (elementIsFocusable(element)) { 5034 element.focus(); 5035 } 5036 } 5037 getNewHeadStylesheetElements() { 5038 return this.newHeadDetails.getStylesheetElementsNotInDetails(this.currentHeadDetails); 5039 } 5040 getNewHeadScriptElements() { 5041 return this.newHeadDetails.getScriptElementsNotInDetails(this.currentHeadDetails); 5042 } 5043 getCurrentHeadProvisionalElements() { 5044 return this.currentHeadDetails.getProvisionalElements(); 5045 } 5046 getNewHeadProvisionalElements() { 5047 return this.newHeadDetails.getProvisionalElements(); 5048 } 5049 getCurrentBodyPermanentElements() { 5050 return this.currentPage.getPermanentElementsPresentInPage(this.newPage); 5051 } 5052 getNewBodyScriptElements() { 5053 return array(this.newBody.querySelectorAll("script")); 5054 } 5055 }; 5056 function createPlaceholderForPermanentElement(permanentElement) { 5057 const element = document.createElement("meta"); 5058 element.setAttribute("name", "turbo-permanent-placeholder"); 5059 element.setAttribute("content", permanentElement.id); 5060 return { element, permanentElement }; 5061 } 5062 function replaceElementWithElement(fromElement, toElement) { 5063 const parentElement = fromElement.parentElement; 5064 if (parentElement) { 5065 return parentElement.replaceChild(toElement, fromElement); 5066 } 5067 } 5068 function elementIsFocusable(element) { 5069 return element && typeof element.focus == "function"; 5070 } 5071 5072
5072// ../../vendor/larajax/larajax/resources/src/turbo/view.js 5073 var View = class { 5074 constructor(delegate) { 5075 this.htmlElement = document.documentElement; 5076 this.delegate = delegate; 5077 } 5078 getRootLocation() { 5079 return this.getPage().getRootLocation(); 5080 } 5081 getElementForAnchor(anchor) { 5082 return this.getPage().getElementForAnchor(anchor); 5083 } 5084 getPage() { 5085 return Page.fromHTMLElement(this.htmlElement); 5086 } 5087 render({ page, error }, callback) { 5088 if (page) { 5089 this.renderPage(page, callback); 5090 } else { 5091 this.renderError(error, callback); 5092 } 5093 } 5094 // Private 5095 renderPage(page, callback) { 5096 PageRenderer.render(this.delegate, callback, this.getPage(), page); 5097 } 5098 renderError(error, callback) { 5099 ErrorRenderer.render(this.delegate, callback, error || ""); 5100 } 5101 }; 5102 5103
5103// ../../vendor/larajax/larajax/resources/src/turbo/visit.js 5104 var TimingMetric = { 5105 visitStart: "visitStart", 5106 requestStart: "requestStart", 5107 requestEnd: "requestEnd", 5108 visitEnd: "visitEnd" 5109 }; 5110 var VisitState = { 5111 initialized: "initialized", 5112 started: "started", 5113 canceled: "canceled", 5114 failed: "failed", 5115 completed: "completed" 5116 }; 5117 var Visit = class { 5118 constructor(controller4, location2, action, restorationIdentifier = uuid()) { 5119 this.identifier = uuid(); 5120 this.timingMetrics = {}; 5121 this.followedRedirect = false; 5122 this.historyChanged = false; 5123 this.progress = 0; 5124 this.scrolled = false; 5125 this.state = VisitState.initialized; 5126 this.performScroll = () => { 5127 if (!this.scrolled) { 5128 if (this.action == "restore") { 5129 this.scrollToRestoredPosition() || this.scrollToTop(); 5130 } else { 5131 this.scrollToAnchor() || this.scrollToTop(); 5132 } 5133 this.scrolled = true; 5134 } 5135 }; 5136 this.controller = controller4; 5137 this.location = location2; 5138 this.action = action; 5139 this.adapter = controller4.adapter; 5140 this.restorationIdentifier = restorationIdentifier; 5141 this.isSamePage = this.locationChangeIsSamePage(); 5142 } 5143 start() { 5144 if (this.state == VisitState.initialized) { 5145 this.recordTimingMetric(TimingMetric.visitStart); 5146 this.state = VisitState.started; 5147 this.adapter.visitStarted(this); 5148 } 5149 } 5150 cancel() { 5151 if (this.state == VisitState.started) { 5152 if (this.request) { 5153 this.request.abort(); 5154 } 5155 this.cancelRender(); 5156 this.state = VisitState.canceled; 5157 } 5158 } 5159 complete() { 5160 if (this.state == VisitState.started) { 5161 this.recordTimingMetric(TimingMetric.visitEnd); 5162 this.state = VisitState.completed; 5163 this.adapter.visitCompleted(this); 5164 this.controller.visitCompleted(this); 5165 } 5166 } 5167 fail() { 5168 if (this.state == VisitState.started) { 5169 this.state = VisitState.failed; 5170 this.adapter.visitFailed(this); 5171 } 5172 } 5173 changeHistory() { 5174 if (!this.historyChanged) { 5175 const actionForHistory = this.location.isEqualTo(this.referrer) ? "replace" : this.action; 5176 const method = this.getHistoryMethodForAction(actionForHistory); 5177 method.call(this.controller, this.location, this.restorationIdentifier); 5178 this.historyChanged = true; 5179 } 5180 } 5181 issueRequest() { 5182 if (this.shouldIssueRequest() && !this.request) { 5183 const url = Location.wrap(this.location).absoluteURL; 5184 const options = { 5185 method: "GET", 5186 headers: {}, 5187 htmlOnly: true, 5188 timeout: 240 5189 }; 5190 options.headers["Accept"] = "text/html, application/xhtml+xml"; 5191 options.headers["X-PJAX"] = 1; 5192 if (this.referrer) { 5193 options.headers["X-PJAX-REFERRER"] = Location.wrap(this.referrer).absoluteURL; 5194 } 5195 this.progress = 0; 5196 this.request = new HttpRequest(this, url, options); 5197 this.request.send(); 5198 } 5199 } 5200 loadResponse() { 5201 const { request, response } = this; 5202 if (request && response) { 5203 this.render(() => { 5204 const page = Page.fromHTMLString(response); 5205 if (request.failed && !page.isNativeError()) { 5206 this.controller.render({ error: response }, this.performScroll); 5207 this.adapter.visitRendered(this); 5208 this.fail(); 5209 } else { 5210 this.controller.render({ page }, this.performScroll); 5211 this.adapter.visitRendered(this); 5212 this.complete(); 5213 } 5214 }); 5215 } 5216 } 5217 followRedirect() { 5218 if (this.redirectedToLocation && !this.followedRedirect) { 5219 this.location = this.redirectedToLocation; 5220 this.controller.replaceHistoryWithLocationAndRestorationIdentifier(this.redirectedToLocation, this.restorationIdentifier); 5221 this.followedRedirect = true; 5222 } 5223 } 5224 goToSamePageAnchor() { 5225 if (this.isSamePage) { 5226 this.render(() => { 5227 this.performScroll(); 5228 this.adapter.visitRendered(this); 5229 }); 5230 } 5231 } 5232 // HTTP request delegate 5233 requestStarted() { 5234 this.recordTimingMetric(TimingMetric.requestStart); 5235 this.adapter.visitRequestStarted(this); 5236 } 5237 requestProgressed(progress) { 5238 this.progress = progress; 5239 if (this.adapter.visitRequestProgressed) { 5240 this.adapter.visitRequestProgressed(this); 5241 } 5242 } 5243 requestCompletedWithResponse(response, statusCode, redirectedToLocation) { 5244 this.response = response; 5245 this.redirectedToLocation = Location.wrap(redirectedToLocation); 5246 this.adapter.visitRequestCompleted(this); 5247 } 5248 requestFailedWithStatusCode(statusCode, response) { 5249 this.response = response; 5250 this.adapter.visitRequestFailedWithStatusCode(this, statusCode); 5251 } 5252 requestFinished() { 5253 this.recordTimingMetric(TimingMetric.requestEnd); 5254 this.adapter.visitRequestFinished(this); 5255 } 5256 scrollToRestoredPosition() { 5257 const position = this.restorationData ? this.restorationData.scrollPosition : void 0; 5258 if (position) { 5259 this.controller.scrollToPosition(position); 5260 return true; 5261 } 5262 } 5263 scrollToAnchor() { 5264 if (this.location.anchor != null) { 5265 this.controller.scrollToAnchor(this.location.anchor); 5266 return true; 5267 } 5268 } 5269 scrollToTop() { 5270 this.controller.scrollToPosition({ x: 0, y: 0 }); 5271 } 5272 // Instrumentation 5273 recordTimingMetric(metric) { 5274 this.timingMetrics[metric] = (/* @__PURE__ */ new Date()).getTime(); 5275 } 5276 getTimingMetrics() { 5277 return Object.assign({}, this.timingMetrics); 5278 } 5279 // Private 5280 getHistoryMethodForAction(action) { 5281 switch (action) { 5282 case "swap": 5283 case "replace": 5284 return this.controller.replaceHistoryWithLocationAndRestorationIdentifier; 5285 case "advance": 5286 case "restore": 5287 return this.controller.pushHistoryWithLocationAndRestorationIdentifier; 5288 } 5289 } 5290 shouldIssueRequest() { 5291 return !this.isSamePage; 5292 } 5293 locationChangeIsSamePage() { 5294 if (this.action == "swap") { 5295 return true; 5296 } 5297 const lastLocation = this.action == "restore" && this.controller.lastRenderedLocation; 5298 return this.controller.locationIsSamePageAnchor(lastLocation || this.location); 5299 } 5300 render(callback) { 5301 this.cancelRender(); 5302 this.frame = requestAnimationFrame(() => { 5303 delete this.frame; 5304 callback.call(this); 5305 }); 5306 } 5307 cancelRender() { 5308 if (this.frame) { 5309 cancelAnimationFrame(this.frame); 5310 delete this.frame; 5311 } 5312 } 5313 }; 5314 5315
5315// ../../vendor/larajax/larajax/resources/src/turbo/controller.js 5316 var Controller3 = class _Controller { 5317 constructor() { 5318 this.adapter = new BrowserAdapter(this); 5319 this.history = new History(this); 5320 this.restorationData = {}; 5321 this.restorationDataKeys = []; 5322 this.restorationDataLimit = 20; 5323 this.scrollManager = new ScrollManager(this); 5324 this.useScroll = true; 5325 this.view = new View(this); 5326 this.enabled = true; 5327 this.pendingAssets = 0; 5328 this.progressBarDelay = 500; 5329 this.progressBarVisible = true; 5330 this.started = false; 5331 this.uniqueInlineScripts = /* @__PURE__ */ new Set(); 5332 this.uniqueInlineScriptsLimit = 100; 5333 this.currentVisit = null; 5334 this.historyVisit = null; 5335 this.pageIsReady = false; 5336 this.viewTransitionFinished = null; 5337 this.pageLoaded = () => { 5338 this.pageIsReady = true; 5339 this.lastRenderedLocation = this.location; 5340 this.notifyApplicationAfterPageLoad(); 5341 this.notifyApplicationAfterPageAndScriptsLoad(); 5342 this.observeInlineScripts(); 5343 }; 5344 this.moduleLoaded = () => { 5345 this.decrementPendingAsset(); 5346 }; 5347 this.clickCaptured = () => { 5348 removeEventListener("click", this.clickBubbled, false); 5349 addEventListener("click", this.clickBubbled, false); 5350 }; 5351 this.clickBubbled = (event) => { 5352 if (this.enabled && this.clickEventIsSignificant(event)) { 5353 const link = this.getVisitableLinkForTarget(event.target); 5354 if (link) { 5355 const location2 = this.getVisitableLocationForLink(link); 5356 if (location2 && this.applicationAllowsFollowingLinkToLocation(link, location2)) { 5357 event.preventDefault(); 5358 const action = this.getActionForLink(link); 5359 const scroll = this.useScrollForLink(link); 5360 this.visit(location2, { action, scroll }); 5361 } 5362 } 5363 } 5364 }; 5365 } 5366 start() { 5367 if (_Controller.supported && !this.started) { 5368 addEventListener("click", this.clickCaptured, true); 5369 addEventListener("DOMContentLoaded", this.pageLoaded, false); 5370 addEventListener("turbo:module-loaded", this.moduleLoaded, false); 5371 this.startHistory(); 5372 this.scrollManager.start(); 5373 this.started = true; 5374 this.enabled = this.documentIsEnabled(); 5375 } 5376 } 5377 // Defer taking over scrollRestoration until the first SPA visit, so that 5378 // a plain reload of the initial page still restores native scroll position. 5379 takeOverScrollRestoration() { 5380 if ("scrollRestoration" in history && !this.scrollRestorationTakenOver) { 5381 this.previousScrollRestoration = history.scrollRestoration; 5382 history.scrollRestoration = "manual"; 5383 this.scrollRestorationTakenOver = true; 5384 } 5385 } 5386 disable() { 5387 this.enabled = false; 5388 } 5389 stop() { 5390 if (this.started) { 5391 removeEventListener("click", this.clickCaptured, true); 5392 removeEventListener("DOMContentLoaded", this.pageLoaded, false); 5393 removeEventListener("turbo:module-loaded", this.moduleLoaded, false); 5394 this.scrollManager.stop(); 5395 this.stopHistory(); 5396 this.started = false; 5397 if ("scrollRestoration" in history && this.scrollRestorationTakenOver && this.previousScrollRestoration) { 5398 history.scrollRestoration = this.previousScrollRestoration; 5399 this.scrollRestorationTakenOver = false; 5400 } 5401 } 5402 } 5403 isEnabled() { 5404 return this.started && this.enabled; 5405 } 5406 pageReady() { 5407 return new Promise((resolve) => { 5408 if (this.pageIsReady) { 5409 resolve(); 5410 } else { 5411 addEventListener("render", () => resolve(), { once: true }); 5412 } 5413 }); 5414 } 5415 visit(location2, options = {}) { 5416 location2 = Location.wrap(location2); 5417 const action = options.action || "advance"; 5418 if (this.applicationAllowsVisitingLocation(location2, action)) { 5419 if (this.locationIsVisitable(location2)) { 5420 this.useScroll = options.scroll !== false; 5421 this.takeOverScrollRestoration(); 5422 this.adapter.visitProposedToLocationWithAction(location2, action); 5423 } else { 5424 window.location.href = location2.toString(); 5425 } 5426 } 5427 } 5428 startVisitToLocationWithAction(location2, action, restorationIdentifier) { 5429 if (_Controller.supported) { 5430 const restorationData = this.getRestorationDataForIdentifier(restorationIdentifier); 5431 this.startVisit(Location.wrap(location2), action, { restorationData }); 5432 } else { 5433 window.location.href = location2.toString(); 5434 } 5435 } 5436 setProgressBarVisible(value) { 5437 this.progressBarVisible = value; 5438 } 5439 setProgressBarDelay(delay) { 5440 this.progressBarDelay = delay; 5441 } 5442 // History 5443 startHistory() { 5444 this.location = Location.currentLocation; 5445 this.restorationIdentifier = uuid(); 5446 this.history.start(); 5447 this.history.replace(this.location, this.restorationIdentifier); 5448 } 5449 stopHistory() { 5450 this.history.stop(); 5451 } 5452 getLastVisitUrl() { 5453 if (this.historyVisit) { 5454 return this.historyVisit.referrer.absoluteURL; 5455 } 5456 } 5457 pushHistoryWithLocationAndRestorationIdentifier(locatable, restorationIdentifier) { 5458 this.historyVisit = this.currentVisit; 5459 this.location = Location.wrap(locatable); 5460 this.restorationIdentifier = restorationIdentifier; 5461 this.history.push(this.location, this.restorationIdentifier); 5462 } 5463 replaceHistoryWithLocationAndRestorationIdentifier(locatable, restorationIdentifier) { 5464 this.location = Location.wrap(locatable); 5465 this.restorationIdentifier = restorationIdentifier; 5466 this.history.replace(this.location, this.restorationIdentifier); 5467 } 5468 // History delegate 5469 historyPoppedToLocationWithRestorationIdentifier(location2, restorationIdentifier, direction) { 5470 if (this.enabled) { 5471 this.location = location2; 5472 this.restorationIdentifier = restorationIdentifier; 5473 this.takeOverScrollRestoration(); 5474 const restorationData = this.getRestorationDataForIdentifier(restorationIdentifier); 5475 this.startVisit(location2, "restore", { restorationIdentifier, restorationData, historyChanged: true, direction }); 5476 } else { 5477 this.adapter.pageInvalidated(); 5478 } 5479 } 5480 // Scrolling
5481 scrollToAnchor(anchor) { 5482 const element = this.view.getElementForAnchor(anchor); 5483 if (element) { 5484 this.scrollToElement(element); 5485 } else { 5486 this.scrollToPosition({ x: 0, y: 0 }); 5487 } 5488 } 5489 scrollToElement(element) { 5490 this.scrollManager.scrollToElement(element); 5491 } 5492 scrollToPosition(position) { 5493 this.scrollManager.scrollToPosition(position); 5494 } 5495 // Scroll manager delegate 5496 scrollPositionChanged(position) { 5497 const restorationData = this.getCurrentRestorationData(); 5498 restorationData.scrollPosition = position; 5499 } 5500 // Pending asset management 5501 incrementPendingAsset() { 5502 this.pendingAssets++; 5503 } 5504 decrementPendingAsset() { 5505 this.pendingAssets--; 5506 if (this.pendingAssets === 0) { 5507 this.pageIsReady = true; 5508 this.notifyApplicationAfterPageAndScriptsLoad(); 5509 this.notifyApplicationAfterLoadScripts(); 5510 } 5511 } 5512 // View 5513 render(options, callback) { 5514 this.view.render(options, callback); 5515 } 5516 viewInvalidated() { 5517 this.adapter.pageInvalidated(); 5518 } 5519 viewAllowsImmediateRender(newBody, options) { 5520 this.pageIsReady = false; 5521 this.notifyApplicationUnload(); 5522 const event = this.notifyApplicationBeforeRender(newBody, options); 5523 return !event.defaultPrevented; 5524 } 5525 viewRendered() { 5526 this.lastRenderedLocation = this.currentVisit.location; 5527 this.notifyApplicationAfterRender(); 5528 } 5529 setViewTransitionFinished(promise) { 5530 this.viewTransitionFinished = promise; 5531 } 5532 viewTransitionEnabled() { 5533 return this.view.getPage().isViewTransitionEnabled(); 5534 } 5535 markVisitDirection(action, direction) { 5536 if (!direction) { 5537 direction = { advance: "forward", restore: "back" }[action] || "none"; 5538 } 5539 document.documentElement.setAttribute("data-turbo-visit-direction", direction); 5540 } 5541 unmarkVisitDirection() { 5542 document.documentElement.removeAttribute("data-turbo-visit-direction"); 5543 } 5544 // Inline script monitoring 5545 observeInlineScripts() { 5546 document.documentElement.querySelectorAll("script[data-turbo-eval-once]").forEach((el) => this.applicationHasSeenInlineScript(el)); 5547 } 5548 applicationHasSeenInlineScript(element) { 5549 const uid = element.getAttribute("data-turbo-eval-once"); 5550 if (!uid) { 5551 return false; 5552 } 5553 const hasSeen = this.uniqueInlineScripts.has(uid); 5554 if (!hasSeen) { 5555 if (this.uniqueInlineScripts.size >= this.uniqueInlineScriptsLimit) { 5556 const iterator = this.uniqueInlineScripts.values(); 5557 this.uniqueInlineScripts.delete(iterator.next().value); 5558 } 5559 this.uniqueInlineScripts.add(uid); 5560 } 5561 return hasSeen; 5562 } 5563 // Application events 5564 applicationAllowsFollowingLinkToLocation(link, location2) { 5565 const event = this.notifyApplicationAfterClickingLinkToLocation(link, location2); 5566 return !event.defaultPrevented; 5567 } 5568 applicationAllowsVisitingLocation(location2, action) { 5569 const event = this.notifyApplicationBeforeVisitingLocation(location2, action); 5570 return !event.defaultPrevented; 5571 } 5572 notifyApplicationAfterClickingLinkToLocation(link, location2) { 5573 return dispatch("page:click", { target: link, detail: { url: location2.absoluteURL } }); 5574 } 5575 notifyApplicationBeforeVisitingLocation(location2, action) { 5576 return dispatch("page:before-visit", { detail: { url: location2.absoluteURL, action } }); 5577 } 5578 notifyApplicationAfterVisitingLocation(location2) { 5579 return dispatch("page:visit", { detail: { url: location2.absoluteURL }, cancelable: false }); 5580 } 5581 notifyApplicationBeforeRender(newBody, options) { 5582 return dispatch("page:before-render", { detail: { newBody, ...options } }); 5583 } 5584 notifyApplicationAfterRender() { 5585 return dispatch("page:render", { cancelable: false }); 5586 } 5587 notifyApplicationAfterPageLoad(timing = {}) { 5588 return dispatch("page:load", { detail: { url: this.location.absoluteURL, timing }, cancelable: false }); 5589 } 5590 notifyApplicationAfterPageAndScriptsLoad() {
5591 return dispatch("page:loaded", { cancelable: false }); 5592 } 5593 notifyApplicationAfterLoadScripts() { 5594 return dispatch("page:updated", { cancelable: false }); 5595 } 5596 notifyApplicationUnload() { 5597 return dispatch("page:unload", { cancelable: false }); 5598 } 5599 // Private 5600 startVisit(location2, action, properties) { 5601 if (this.currentVisit) { 5602 this.currentVisit.cancel(); 5603 } 5604 this.currentVisit = this.createVisit(location2, action, properties); 5605 this.currentVisit.scrolled = !this.useScroll; 5606 this.markVisitDirection(action, properties.direction); 5607 this.currentVisit.start(); 5608 this.notifyApplicationAfterVisitingLocation(location2); 5609 } 5610 createVisit(location2, action, properties) { 5611 const visit = new Visit(this, location2, action, properties.restorationIdentifier); 5612 visit.restorationData = Object.assign({}, properties.restorationData || {}); 5613 visit.historyChanged = !!properties.historyChanged; 5614 visit.referrer = this.location; 5615 return visit; 5616 } 5617 visitCompleted(visit) { 5618 if (this.viewTransitionFinished) { 5619 this.viewTransitionFinished.then(() => { 5620 this.unmarkVisitDirection(); 5621 }).catch(() => { 5622 this.unmarkVisitDirection(); 5623 }); 5624 this.viewTransitionFinished = null; 5625 } else { 5626 this.unmarkVisitDirection(); 5627 } 5628 this.notifyApplicationAfterPageLoad(visit.getTimingMetrics()); 5629 if (this.pendingAssets === 0) { 5630 this.pageIsReady = true; 5631 this.notifyApplicationAfterPageAndScriptsLoad(); 5632 this.notifyApplicationAfterLoadScripts(); 5633 } 5634 } 5635 clickEventIsSignificant(event) { 5636 return !(event.target && event.target.isContentEditable || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey); 5637 } 5638 getVisitableLinkForTarget(target) { 5639 if (target instanceof Element && this.elementIsVisitable(target)) { 5640 var container = target.closest("a[href]:not([download])"); 5641 if (container && container.getAttribute("target") && container.getAttribute("target") != "_self") { 5642 return null; 5643 } 5644 return container; 5645 } 5646 } 5647 getVisitableLocationForLink(link) { 5648 const location2 = new Location(link.getAttribute("href") || ""); 5649 if (this.locationIsVisitable(location2)) { 5650 return location2; 5651 } 5652 } 5653 getActionForLink(link) { 5654 const action = link.getAttribute("data-turbo-action"); 5655 return this.isAction(action) ? action : "advance"; 5656 } 5657 useScrollForLink(link) { 5658 return link.getAttribute("data-turbo-no-scroll") === null; 5659 } 5660 isAction(action) { 5661 return action == "advance" || action == "replace" || action == "restore" || action == "swap"; 5662 } 5663 documentIsEnabled() { 5664 const meta = document.documentElement.querySelector('head meta[name="turbo-visit-control"]'); 5665 if (meta) { 5666 const value = meta.getAttribute("content"); 5667 return value == "enable"; 5668 } 5669 return false; 5670 } 5671 elementIsVisitable(element) { 5672 const container = element.closest("[data-turbo]"); 5673 if (container) { 5674 return container.getAttribute("data-turbo") != "false"; 5675 } else { 5676 return true; 5677 } 5678 } 5679 locationIsVisitable(location2) { 5680 return location2.isPrefixedBy(this.view.getRootLocation()) && location2.isHTML(); 5681 } 5682 locationIsSamePageAnchor(location2) { 5683 return typeof location2.anchor != "undefined" && location2.requestURL == this.location.requestURL; 5684 } 5685 getCurrentRestorationData() { 5686 return this.getRestorationDataForIdentifier(this.restorationIdentifier); 5687 } 5688 getRestorationDataForIdentifier(identifier) { 5689 if (!(identifier in this.restorationData)) { 5690 this.restorationData[identifier] = {}; 5691 this.restorationDataKeys.push(identifier); 5692 this.trimRestorationData(); 5693 } 5694 return this.restorationData[identifier]; 5695 } 5696 trimRestorationData() { 5697 while (this.restorationDataKeys.length > this.restorationDataLimit) { 5698 const oldestKey = this.restorationDataKeys.shift(); 5699 delete this.restorationData[oldestKey]; 5700 } 5701 } 5702 }; 5703 Controller3.supported = !!(window.history.pushState && window.requestAnimationFrame && window.addEventListener); 5704 5705
5705// ../../vendor/larajax/larajax/resources/src/turbo/namespace.js 5706 var controller3 = new Controller3(); 5707 var namespace_default5 = { 5708 get supported() { 5709 return Controller3.supported; 5710 }, 5711 controller: controller3, 5712 visit(location2, options) { 5713 if (controller3.isEnabled()) { 5714 controller3.visit(location2, options); 5715 } else { 5716 window.location.assign(location2); 5717 } 5718 }, 5719 setProgressBarVisible(value) { 5720 controller3.setProgressBarVisible(value); 5721 }, 5722 setProgressBarDelay(delay) { 5723 controller3.setProgressBarDelay(delay); 5724 }, 5725 start() { 5726 controller3.start(); 5727 }, 5728 isEnabled() { 5729 return controller3.isEnabled(); 5730 }, 5731 pageReady() { 5732 return controller3.pageReady(); 5733 } 5734 }; 5735 5736
5736// ../../vendor/larajax/larajax/resources/src/observe/control-base.js 5737 var ControlBase = class _ControlBase { 5738 static proxyCounter = 0; 5739 static get shouldLoad() { 5740 return true; 5741 } 5742 static afterLoad(_identifier, _application) { 5743 return; 5744 } 5745 constructor(context) { 5746 this.context = context; 5747 this.config = this.parseDataset(context.scope.element.dataset || {}); 5748 } 5749 get application() { 5750 return this.context.application; 5751 } 5752 get scope() { 5753 return this.context.scope; 5754 } 5755 get element() { 5756 return this.scope.element; 5757 } 5758 get identifier() { 5759 return this.scope.identifier; 5760 } 5761 init() { 5762 } 5763 connect() { 5764 } 5765 disconnect() { 5766 } 5767 // Internal events avoid the need to call parent logic 5768 initBefore() { 5769 this.proxiedEvents = {}; 5770 this.proxiedMethods = {}; 5771 } 5772 initAfter() { 5773 } 5774 connectBefore() { 5775 } 5776 connectAfter() { 5777 } 5778 disconnectBefore() { 5779 } 5780 disconnectAfter() { 5781 for (const key in this.proxiedEvents) { 5782 this.forget(...this.proxiedEvents[key]); 5783 delete this.proxiedEvents[key]; 5784 } 5785 for (const key in this.proxiedMethods) { 5786 this.proxiedMethods[key] = void 0; 5787 } 5788 } 5789 // Events 5790 listen(eventName, targetOrHandler, handlerOrOptions, options) { 5791 if (typeof targetOrHandler === "string") { 5792 Events.on(this.element, eventName, targetOrHandler, this.proxy(handlerOrOptions), options); 5793 } else if (targetOrHandler instanceof Element) { 5794 Events.on(targetOrHandler, eventName, this.proxy(handlerOrOptions), options); 5795 } else { 5796 Events.on(this.element, eventName, this.proxy(targetOrHandler), handlerOrOptions); 5797 } 5798 _ControlBase.proxyCounter++; 5799 this.proxiedEvents[_ControlBase.proxyCounter] = arguments; 5800 } 5801 forget(eventName, targetOrHandler, handlerOrOptions, options) { 5802 if (typeof targetOrHandler === "string") { 5803 Events.off(this.element, eventName, targetOrHandler, this.proxy(handlerOrOptions), options); 5804 } else if (targetOrHandler instanceof Element) { 5805 Events.off(targetOrHandler, eventName, this.proxy(handlerOrOptions), options); 5806 } else { 5807 Events.off(this.element, eventName, this.proxy(targetOrHandler), handlerOrOptions); 5808 } 5809 const compareArrays = (a, b) => { 5810 if (a.length !== b.length) { 5811 return false; 5812 } 5813 for (var i = 0; i < a.length; i++) { 5814 if (a[i] !== b[i]) { 5815 return false; 5816 } 5817 } 5818 return true; 5819 }; 5820 for (const key in this.proxiedEvents) { 5821 if (compareArrays(arguments, this.proxiedEvents[key])) { 5822 delete this.proxiedEvents[key]; 5823 } 5824 } 5825 } 5826 dispatch(eventName, { target = this.element, detail = {}, prefix = this.identifier, bubbles = true, cancelable = true } = {}) { 5827 const type = prefix ? `${prefix}:${eventName}` : eventName; 5828 const event = new CustomEvent(type, { detail, bubbles, cancelable }); 5829 target.dispatchEvent(event); 5830 return event; 5831 } 5832 proxy(method) { 5833 if (method.ocProxyId === void 0) { 5834 _ControlBase.proxyCounter++; 5835 method.ocProxyId = _ControlBase.proxyCounter; 5836 } 5837 if (this.proxiedMethods[method.ocProxyId] !== void 0) { 5838 return this.proxiedMethods[method.ocProxyId]; 5839 } 5840 this.proxiedMethods[method.ocProxyId] = method.bind(this); 5841 return this.proxiedMethods[method.ocProxyId]; 5842 } 5843 parseDataset(dataset) { 5844 const result = {}; 5845 for (const [key, value] of Object.entries(dataset)) { 5846 result[key] = this.parseValue(value); 5847 } 5848 return result; 5849 } 5850 parseValue(value) { 5851 if (value === "true") return true; 5852 if (value === "false") return false; 5853 if (value === "null") return null; 5854 if (value === "undefined") return void 0; 5855 if (value !== "" && !isNaN(Number(value))) return Number(value); 5856 if (typeof value === "string") { 5857 const first = value.charAt(0), last = value.charAt(value.length - 1); 5858 if (first === "{" && last === "}" || first === "[" && last === "]") { 5859 try { 5860 return JSON.parse(value); 5861 } catch (e) { 5862 } 5863 } 5864 } 5865 return value; 5866 } 5867 }; 5868 5869
5869// ../../vendor/larajax/larajax/resources/src/util/jax-builder.js 5870 function buildJaxObject(modules) { 5871 const { 5872 AjaxFramework, 5873 AjaxRequest, 5874 AssetManager: AssetManager2, 5875 Events: Events2, 5876 waitFor: waitFor2, 5877 visit, 5878 // Optional modules 5879 AjaxExtras, 5880 AjaxObserve, 5881 AjaxTurbo, 5882 ControlBase: ControlBase2 5883 } = modules; 5884 const jax = { 5885 // Request 5886 AjaxRequest, 5887 AssetManager: AssetManager2, 5888 ajax: AjaxRequest.send, 5889 markNavigating: AjaxRequest.markNavigating, 5890 // Core 5891 AjaxFramework, 5892 request: AjaxFramework.requestElement, 5893 parseJSON: AjaxFramework.parseJSON, 5894 values: AjaxFramework.serializeAsJSON, 5895 pageReady: AjaxFramework.pageReady, 5896 // Util 5897 Events: Events2, 5898 dispatch: Events2.dispatch, 5899 trigger: Events2.trigger, 5900 on: Events2.on, 5901 off: Events2.off, 5902 one: Events2.one, 5903 waitFor: waitFor2, 5904 visit 5905 }; 5906 if (AjaxExtras) { 5907 jax.AjaxExtras = AjaxExtras; 5908 jax.flashMsg = AjaxExtras.flashMsg; 5909 jax.progressBar = AjaxExtras.progressBar; 5910 jax.attachLoader = AjaxExtras.attachLoader; 5911 } 5912 if (AjaxObserve) { 5913 jax.AjaxObserve = AjaxObserve; 5914 jax.registerControl = AjaxObserve.registerControl; 5915 jax.importControl = AjaxObserve.importControl; 5916 jax.observeControl = AjaxObserve.observeControl; 5917 jax.fetchControl = AjaxObserve.fetchControl; 5918 jax.fetchControls = AjaxObserve.fetchControls; 5919 } 5920 if (ControlBase2) { 5921 jax.ControlBase = ControlBase2; 5922 } 5923 if (AjaxTurbo) { 5924 registerTurbo(AjaxTurbo); 5925 jax.AjaxTurbo = AjaxTurbo; 5926 jax.useTurbo = AjaxTurbo.isEnabled; 5927 } 5928 return jax; 5929 } 5930 5931
5931// ../../vendor/larajax/larajax/resources/src/framework-bundle.js 5932 if (!window.jax) { 5933 window.jax = {}; 5934 } 5935 Object.assign(window.jax, buildJaxObject({ 5936 AjaxFramework: namespace_default2, 5937 AjaxRequest: namespace_default, 5938 AssetManager, 5939 Events, 5940 waitFor, 5941 visit: namespace_default5.visit, 5942 AjaxExtras: namespace_default3, 5943 AjaxObserve: namespace_default4, 5944 AjaxTurbo: namespace_default5, 5945 ControlBase 5946 })); 5947 namespace_default2.start(); 5948 namespace_default3.start(); 5949 namespace_default4.start(); 5950 namespace_default5.start(); 5951 5952
5952// assets/vendor/larajax/migrate.js 5953 window.oc = window.jax; 5954 window.oc.serializeJSON = window.oc.values; 5955 (function() { 5956 var $ = window["jQuery"]; 5957 if ($ === void 0) { 5958 return; 5959 } 5960 bindRequestFunc(); 5961 bindRenderFunc(); 5962 bindjQueryEvents(); 5963 bindOcNamespace(); 5964 function bindRequestFunc() { 5965 var old = $.fn.request; 5966 $.fn.request = function(handler, option) { 5967 var options = typeof option === "object" ? option : {}; 5968 return oc.request(this.get(0), handler, options); 5969 }; 5970 $.fn.request.Constructor = oc.request; 5971 $.request = function(handler, option) { 5972 return $(document).request(handler, option); 5973 }; 5974 $.fn.request.noConflict = function() { 5975 $.fn.request = old; 5976 return this; 5977 }; 5978 } 5979 function bindRenderFunc() { 5980 $.fn.render = function(callback) { 5981 $(document).on("render", callback); 5982 }; 5983 } 5984 function bindOcNamespace() { 5985 if ($.oc === void 0) { 5986 $.oc = {}; 5987 } 5988 $.oc.flashMsg = window.jax.flashMsg; 5989 $.oc.stripeLoadIndicator = window.jax.progressBar; 5990 } 5991 function bindjQueryEvents() { 5992 migratejQueryEvent(document, "ajax:setup", "ajaxSetup", ["context"]); 5993 migratejQueryEvent(document, "ajax:promise", "ajaxPromise", ["context"]); 5994 migratejQueryEvent(document, "ajax:fail", "ajaxFail", ["context", "data", "responseCode", "xhr"]); 5995 migratejQueryEvent(document, "ajax:done", "ajaxDone", ["context", "data", "responseCode", "xhr"]); 5996 migratejQueryEvent(document, "ajax:always", "ajaxAlways", ["context", "data", "responseCode", "xhr"]); 5997 migratejQueryEvent(document, "ajax:before-redirect", "ajaxRedirect"); 5998 migratejQueryEvent(document, "ajax:update", "ajaxUpdate", ["context", "data", "responseCode", "xhr"]); 5999 migratejQueryEvent(document, "ajax:before-replace", "ajaxBeforeReplace"); 6000 migratejQueryEvent(document, "ajax:before-request", "oc.beforeRequest", ["context"]); 6001 migratejQueryEvent(document, "ajax:before-update", "ajaxBeforeUpdate", ["context", "data", "responseCode", "xhr"]); 6002 migratejQueryEvent(document, "ajax:request-success", "ajaxSuccess", ["context", "data", "responseCode", "xhr"]); 6003 migratejQueryEvent(document, "ajax:request-complete", "ajaxComplete", ["context", "data", "responseCode", "xhr"]); 6004 migratejQueryEvent(document, "ajax:request-error", "ajaxError", ["context", "message", "responseCode", "xhr"]); 6005 migratejQueryEvent(document, "ajax:before-validate", "ajaxValidation", ["context", "message", "fields"]); 6006 migratejQueryEvent(window, "ajax:before-send", "ajaxBeforeSend", ["context"]); 6007 migratejQueryEvent(window, "ajax:update-complete", "ajaxUpdateComplete", ["context", "data", "responseCode", "xhr"]); 6008 migratejQueryEvent(window, "ajax:invalid-field", "ajaxInvalidField", ["element", "fieldName", "errorMsg", "isFirst"]); 6009 migratejQueryEvent(window, "ajax:confirm-message", "ajaxConfirmMessage", ["message", "promise"]); 6010 migratejQueryEvent(window, "ajax:error-message", "ajaxErrorMessage", ["message"]); 6011 migratejQueryAttachData(document, "ajax:setup", "a[data-request], button[data-request], form[data-request], a[data-handler], button[data-handler]"); 6012 } 6013 function migratejQueryEvent(target, jsName, jqName, detailNames) { 6014 detailNames = detailNames || []; 6015 $(target).on(jsName, function(ev) { 6016 triggerjQueryEvent(ev.originalEvent, jqName, detailNames); 6017 }); 6018 } 6019 function triggerjQueryEvent(ev, eventName, detailNames) { 6020 detailNames = detailNames || []; 6021 var jQueryEvent = $.Event(eventName), args = buildDetailArgs(ev, detailNames); 6022 $(ev.target).trigger(jQueryEvent, args); 6023 if (jQueryEvent.isDefaultPrevented()) { 6024 ev.preventDefault(); 6025 } 6026 } 6027 function buildDetailArgs(ev, detailNames) { 6028 var args = []; 6029 detailNames.forEach(function(name) { 6030 args.push(ev.detail[name]); 6031 }); 6032 return args; 6033 } 6034 function migratejQueryAttachData(target, eventName, selector) { 6035 $(target).on(eventName, selector, function(event) { 6036 var dataObj = $(this).data("request-data"); 6037 if (!dataObj) { 6038 return; 6039 } 6040 var options = event.detail.context.options; 6041 if (dataObj.constructor === {}.constructor) { 6042 Object.assign(options.data, dataObj); 6043 } else if (typeof dataObj === "string") { 6044 Object.assign(options.data, paramToObj("request-data", dataObj)); 6045 } 6046 }); 6047 } 6048 function paramToObj(name, value) { 6049 if (value === void 0) { 6050 value = ""; 6051 } 6052 if (typeof value === "object") { 6053 return value; 6054 } 6055 if (value.charAt(0) !== "{") { 6056 value = "{" + value + "}"; 6057 }
6058 try { 6059 return oc.parseJSON(value); 6060 } catch (e) { 6061 throw new Error("Error parsing the " + name + " attribute value. " + e); 6062 } 6063 } 6064 })(); 6065})();
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.