1(() => { 2 var __create = Object.create; 3 var __defProp = Object.defineProperty; 4 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 5 var __getOwnPropNames = Object.getOwnPropertyNames; 6 var __getProtoOf = Object.getPrototypeOf; 7 var __hasOwnProp = Object.prototype.hasOwnProperty; 8 var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 9 var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); 10 var __esm = (fn2, res) => function __init() { 11 return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 0)), res; 12 }; 13 var __commonJS = (cb, mod) => function __require() { 14 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 15 }; 16 var __export = (target, all) => { 17 for (var name in all) 18 __defProp(target, name, { get: all[name], enumerable: true }); 19 }; 20 var __reExport = (target, module5, copyDefault, desc) => { 21 if (module5 && typeof module5 === "object" || typeof module5 === "function") { 22 for (let key of __getOwnPropNames(module5)) 23 if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) 24 __defProp(target, key, { get: () => module5[key], enumerable: !(desc = __getOwnPropDesc(module5, key)) || desc.enumerable }); 25 } 26 return target; 27 }; 28 var __toESM = (module5, isNodeMode) => { 29 return __reExport(__markAsModule(__defProp(module5 != null ? __create(__getProtoOf(module5)) : {}, "default", !isNodeMode && module5 && module5.__esModule ? { get: () => module5.default, enumerable: true } : { value: module5, enumerable: true })), module5); 30 }; 31 var __publicField = (obj, key, value) => { 32 __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); 33 return value; 34 }; 35 36
vendor: 32,593 bytes, lines 36-710
36// ../../node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js 37 var require_rails_ujs = __commonJS({ 38 "../../node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js"(exports2, module5) { 39 (function() { 40 var context = this; 41 (function() { 42 (function() { 43 this.Rails = { 44 linkClickSelector: "a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]", 45 buttonClickSelector: { 46 selector: "button[data-remote]:not([form]), button[data-confirm]:not([form])", 47 exclude: "form button" 48 }, 49 inputChangeSelector: "select[data-remote], input[data-remote], textarea[data-remote]", 50 formSubmitSelector: "form:not([data-turbo=true])", 51 formInputClickSelector: "form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])", 52 formDisableSelector: "input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled", 53 formEnableSelector: "input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled", 54 fileInputSelector: "input[name][type=file]:not([disabled])", 55 linkDisableSelector: "a[data-disable-with], a[data-disable]", 56 buttonDisableSelector: "button[data-remote][data-disable-with], button[data-remote][data-disable]" 57 }; 58 }).call(this); 59 }).call(context); 60 var Rails4 = context.Rails; 61 (function() { 62 (function() { 63 var nonce; 64 nonce = null; 65 Rails4.loadCSPNonce = function() { 66 var ref; 67 return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0; 68 }; 69 Rails4.cspNonce = function() { 70 return nonce != null ? nonce : Rails4.loadCSPNonce(); 71 }; 72 }).call(this); 73 (function() { 74 var expando, m; 75 m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector; 76 Rails4.matches = function(element, selector) { 77 if (selector.exclude != null) { 78 return m.call(element, selector.selector) && !m.call(element, selector.exclude); 79 } else { 80 return m.call(element, selector); 81 } 82 }; 83 expando = "_ujsData"; 84 Rails4.getData = function(element, key) { 85 var ref; 86 return (ref = element[expando]) != null ? ref[key] : void 0; 87 }; 88 Rails4.setData = function(element, key, value) { 89 if (element[expando] == null) { 90 element[expando] = {}; 91 } 92 return element[expando][key] = value; 93 }; 94 Rails4.$ = function(selector) { 95 return Array.prototype.slice.call(document.querySelectorAll(selector)); 96 }; 97 }).call(this); 98 (function() { 99 var $, csrfParam, csrfToken; 100 $ = Rails4.$; 101 csrfToken = Rails4.csrfToken = function() { 102 var meta; 103 meta = document.querySelector("meta[name=csrf-token]"); 104 return meta && meta.content; 105 }; 106 csrfParam = Rails4.csrfParam = function() { 107 var meta; 108 meta = document.querySelector("meta[name=csrf-param]"); 109 return meta && meta.content; 110 }; 111 Rails4.CSRFProtection = function(xhr) { 112 var token; 113 token = csrfToken(); 114 if (token != null) { 115 return xhr.setRequestHeader("X-CSRF-Token", token); 116 } 117 }; 118 Rails4.refreshCSRFTokens = function() { 119 var param, token; 120 token = csrfToken(); 121 param = csrfParam(); 122 if (token != null && param != null) { 123 return $('form input[name="' + param + '"]').forEach(function(input) { 124 return input.value = token; 125 }); 126 } 127 }; 128 }).call(this); 129 (function() { 130 var CustomEvent2, fire, matches, preventDefault; 131 matches = Rails4.matches; 132 CustomEvent2 = window.CustomEvent; 133 if (typeof CustomEvent2 !== "function") { 134 CustomEvent2 = function(event, params) { 135 var evt; 136 evt = document.createEvent("CustomEvent"); 137 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 138 return evt; 139 }; 140 CustomEvent2.prototype = window.Event.prototype; 141 preventDefault = CustomEvent2.prototype.preventDefault; 142 CustomEvent2.prototype.preventDefault = function() { 143 var result; 144 result = preventDefault.call(this); 145 if (this.cancelable && !this.defaultPrevented) { 146 Object.defineProperty(this, "defaultPrevented", { 147 get: function() { 148 return true; 149 } 150 }); 151 } 152 return result; 153 }; 154 } 155 fire = Rails4.fire = function(obj, name, data) { 156 var event; 157 event = new CustomEvent2(name, { 158 bubbles: true, 159 cancelable: true, 160 detail: data 161 }); 162 obj.dispatchEvent(event); 163 return !event.defaultPrevented; 164 }; 165 Rails4.stopEverything = function(e2) { 166 fire(e2.target, "ujs:everythingStopped"); 167 e2.preventDefault(); 168 e2.stopPropagation(); 169 return e2.stopImmediatePropagation(); 170 }; 171 Rails4.delegate = function(element, selector, eventType, handler) { 172 return element.addEventListener(eventType, function(e2) { 173 var target; 174 target = e2.target; 175 while (!(!(target instanceof Element) || matches(target, selector))) { 176 target = target.parentNode; 177 } 178 if (target instanceof Element && handler.call(target, e2) === false) { 179 e2.preventDefault(); 180 return e2.stopPropagation(); 181 } 182 }); 183 }; 184 }).call(this); 185 (function() { 186 var AcceptHeaders, CSRFProtection, createXHR, cspNonce, fire, prepareOptions, processResponse; 187 cspNonce = Rails4.cspNonce, CSRFProtection = Rails4.CSRFProtection, fire = Rails4.fire; 188 AcceptHeaders = { 189 "*": "*/*", 190 text: "text/plain", 191 html: "text/html", 192 xml: "application/xml, text/xml", 193 json: "application/json, text/javascript", 194 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" 195 }; 196 Rails4.ajax = function(options2) { 197 var xhr; 198 options2 = prepareOptions(options2); 199 xhr = createXHR(options2, function() { 200 var ref, response; 201 response = processResponse((ref = xhr.response) != null ? ref : xhr.responseText, xhr.getResponseHeader("Content-Type")); 202 if (Math.floor(xhr.status / 100) === 2) { 203 if (typeof options2.success === "function") { 204 options2.success(response, xhr.statusText, xhr); 205 } 206 } else { 207 if (typeof options2.error === "function") { 208 options2.error(response, xhr.statusText, xhr); 209 } 210 } 211 return typeof options2.complete === "function" ? options2.complete(xhr, xhr.statusText) : void 0; 212 }); 213 if (options2.beforeSend != null && !options2.beforeSend(xhr, options2)) { 214 return false; 215 } 216 if (xhr.readyState === XMLHttpRequest.OPENED) { 217 return xhr.send(options2.data); 218 } 219 }; 220 prepareOptions = function(options2) { 221 options2.url = options2.url || location.href; 222 options2.type = options2.type.toUpperCase(); 223 if (options2.type === "GET" && options2.data) { 224 if (options2.url.indexOf("?") < 0) { 225 options2.url += "?" + options2.data; 226 } else { 227 options2.url += "&" + options2.data; 228 } 229 } 230 if (AcceptHeaders[options2.dataType] == null) { 231 options2.dataType = "*"; 232 } 233 options2.accept = AcceptHeaders[options2.dataType]; 234 if (options2.dataType !== "*") { 235 options2.accept += ", */*; q=0.01"; 236 } 237 return options2; 238 }; 239 createXHR = function(options2, done) { 240 var xhr; 241 xhr = new XMLHttpRequest(); 242 xhr.open(options2.type, options2.url, true); 243 xhr.setRequestHeader("Accept", options2.accept); 244 if (typeof options2.data === "string") { 245 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 246 } 247 if (!options2.crossDomain) { 248 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 249 CSRFProtection(xhr); 250 } 251 xhr.withCredentials = !!options2.withCredentials; 252 xhr.onreadystatechange = function() { 253 if (xhr.readyState === XMLHttpRequest.DONE) { 254 return done(xhr); 255 } 256 }; 257 return xhr; 258 }; 259 processResponse = function(response, type) { 260 var parser, script; 261 if (typeof response === "string" && typeof type === "string") { 262 if (type.match(/\bjson\b/)) { 263 try { 264 response = JSON.parse(response); 265 } catch (error2) { 266 } 267 } else if (type.match(/\b(?:java|ecma)script\b/)) { 268 script = document.createElement("script"); 269 script.setAttribute("nonce", cspNonce()); 270 script.text = response; 271 document.head.appendChild(script).parentNode.removeChild(script); 272 } else if (type.match(/\b(xml|html|svg)\b/)) { 273 parser = new DOMParser(); 274 type = type.replace(/;.+/, ""); 275 try { 276 response = parser.parseFromString(response, type); 277 } catch (error2) { 278 } 279 } 280 } 281 return response; 282 }; 283 Rails4.href = function(element) { 284 return element.href; 285 }; 286 Rails4.isCrossDomain = function(url) { 287 var e2, originAnchor, urlAnchor; 288 originAnchor = document.createElement("a"); 289 originAnchor.href = location.href; 290 urlAnchor = document.createElement("a"); 291 try { 292 urlAnchor.href = url; 293 return !((!urlAnchor.protocol || urlAnchor.protocol === ":") && !urlAnchor.host || originAnchor.protocol + "//" + originAnchor.host === urlAnchor.protocol + "//" + urlAnchor.host); 294 } catch (error2) { 295 e2 = error2; 296 return true; 297 } 298 }; 299 }).call(this); 300 (function() { 301 var matches, toArray; 302 matches = Rails4.matches; 303 toArray = function(e2) { 304 return Array.prototype.slice.call(e2); 305 }; 306 Rails4.serializeElement = function(element, additionalParam) { 307 var inputs, params; 308 inputs = [element]; 309 if (matches(element, "form")) { 310 inputs = toArray(element.elements); 311 } 312 params = []; 313 inputs.forEach(function(input) { 314 if (!input.name || input.disabled) { 315 return; 316 } 317 if (matches(input, "fieldset[disabled] *")) { 318 return; 319 } 320 if (matches(input, "select")) { 321 return toArray(input.options).forEach(function(option) { 322 if (option.selected) { 323 return params.push({ 324 name: input.name, 325 value: option.value 326 }); 327 } 328 }); 329 } else if (input.checked || ["radio", "checkbox", "submit"].indexOf(input.type) === -1) { 330 return params.push({ 331 name: input.name, 332 value: input.value 333 }); 334 } 335 }); 336 if (additionalParam) { 337 params.push(additionalParam); 338 } 339 return params.map(function(param) { 340 if (param.name != null) { 341 return encodeURIComponent(param.name) + "=" + encodeURIComponent(param.value); 342 } else { 343 return param; 344 } 345 }).join("&"); 346 }; 347 Rails4.formElements = function(form, selector) { 348 if (matches(form, "form")) { 349 return toArray(form.elements).filter(function(el) { 350 return matches(el, selector); 351 }); 352 } else { 353 return toArray(form.querySelectorAll(selector)); 354 } 355 }; 356 }).call(this); 357 (function() { 358 var allowAction, fire, stopEverything; 359 fire = Rails4.fire, stopEverything = Rails4.stopEverything; 360 Rails4.handleConfirm = function(e2) { 361 if (!allowAction(this)) { 362 return stopEverything(e2); 363 } 364 }; 365 Rails4.confirm = function(message, element) { 366 return confirm(message); 367 }; 368 allowAction = function(element) { 369 var answer, callback, message; 370 message = element.getAttribute("data-confirm"); 371 if (!message) { 372 return true; 373 } 374 answer = false; 375 if (fire(element, "confirm")) { 376 try { 377 answer = Rails4.confirm(message, element); 378 } catch (error2) { 379 } 380 callback = fire(element, "confirm:complete", [answer]); 381 } 382 return answer && callback; 383 }; 384 }).call(this); 385 (function() { 386 var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, isXhrRedirect, matches, setData, stopEverything; 387 matches = Rails4.matches, getData = Rails4.getData, setData = Rails4.setData, stopEverything = Rails4.stopEverything, formElements = Rails4.formElements; 388 Rails4.handleDisabledElement = function(e2) { 389 var element; 390 element = this; 391 if (element.disabled) { 392 return stopEverything(e2); 393 } 394 }; 395 Rails4.enableElement = function(e2) { 396 var element; 397 if (e2 instanceof Event) { 398 if (isXhrRedirect(e2)) { 399 return; 400 } 401 element = e2.target; 402 } else { 403 element = e2; 404 } 405 if (matches(element, Rails4.linkDisableSelector)) { 406 return enableLinkElement(element); 407 } else if (matches(element, Rails4.buttonDisableSelector) || matches(element, Rails4.formEnableSelector)) { 408 return enableFormElement(element); 409 } else if (matches(element, Rails4.formSubmitSelector)) { 410 return enableFormElements(element); 411 } 412 }; 413 Rails4.disableElement = function(e2) { 414 var element; 415 element = e2 instanceof Event ? e2.target : e2; 416 if (matches(element, Rails4.linkDisableSelector)) { 417 return disableLinkElement(element); 418 } else if (matches(element, Rails4.buttonDisableSelector) || matches(element, Rails4.formDisableSelector)) { 419 return disableFormElement(element); 420 } else if (matches(element, Rails4.formSubmitSelector)) { 421 return disableFormElements(element); 422 } 423 }; 424 disableLinkElement = function(element) { 425 var replacement; 426 if (getData(element, "ujs:disabled")) { 427 return; 428 } 429 replacement = element.getAttribute("data-disable-with"); 430 if (replacement != null) { 431 setData(element, "ujs:enable-with", element.innerHTML); 432 element.innerHTML = replacement; 433 } 434 element.addEventListener("click", stopEverything); 435 return setData(element, "ujs:disabled", true); 436 }; 437 enableLinkElement = function(element) { 438 var originalText; 439 originalText = getData(element, "ujs:enable-with"); 440 if (originalText != null) { 441 element.innerHTML = originalText; 442 setData(element, "ujs:enable-with", null); 443 } 444 element.removeEventListener("click", stopEverything); 445 return setData(element, "ujs:disabled", null); 446 }; 447 disableFormElements = function(form) { 448 return formElements(form, Rails4.formDisableSelector).forEach(disableFormElement); 449 }; 450 disableFormElement = function(element) { 451 var replacement; 452 if (getData(element, "ujs:disabled")) { 453 return; 454 } 455 replacement = element.getAttribute("data-disable-with"); 456 if (replacement != null) { 457 if (matches(element, "button")) { 458 setData(element, "ujs:enable-with", element.innerHTML); 459 element.innerHTML = replacement; 460 } else { 461 setData(element, "ujs:enable-with", element.value); 462 element.value = replacement; 463 } 464 } 465 element.disabled = true; 466 return setData(element, "ujs:disabled", true); 467 }; 468 enableFormElements = function(form) { 469 return formElements(form, Rails4.formEnableSelector).forEach(enableFormElement); 470 }; 471 enableFormElement = function(element) { 472 var originalText; 473 originalText = getData(element, "ujs:enable-with"); 474 if (originalText != null) { 475 if (matches(element, "button")) { 476 element.innerHTML = originalText; 477 } else { 478 element.value = originalText; 479 } 480 setData(element, "ujs:enable-with", null); 481 } 482 element.disabled = false; 483 return setData(element, "ujs:disabled", null); 484 }; 485 isXhrRedirect = function(event) { 486 var ref, xhr; 487 xhr = (ref = event.detail) != null ? ref[0] : void 0; 488 return (xhr != null ? xhr.getResponseHeader("X-Xhr-Redirect") : void 0) != null; 489 }; 490 }).call(this); 491 (function() { 492 var stopEverything; 493 stopEverything = Rails4.stopEverything; 494 Rails4.handleMethod = function(e2) { 495 var csrfParam, csrfToken, form, formContent, href, link, method; 496 link = this; 497 method = link.getAttribute("data-method"); 498 if (!method) { 499 return; 500 } 501 href = Rails4.href(link); 502 csrfToken = Rails4.csrfToken(); 503 csrfParam = Rails4.csrfParam(); 504 form = document.createElement("form"); 505 formContent = "<input name='_method' value='" + method + "' type='hidden' />"; 506 if (csrfParam != null && csrfToken != null && !Rails4.isCrossDomain(href)) { 507 formContent += "<input name='" + csrfParam + "' value='" + csrfToken + "' type='hidden' />"; 508 } 509 formContent += '<input type="submit" />'; 510 form.method = "post"; 511 form.action = href; 512 form.target = link.target; 513 form.innerHTML = formContent; 514 form.style.display = "none"; 515 document.body.appendChild(form); 516 form.querySelector('[type="submit"]').click(); 517 return stopEverything(e2); 518 }; 519 }).call(this); 520 (function() { 521 var ajax, fire, getData, isCrossDomain, isRemote, matches, serializeElement, setData, stopEverything, slice = [].slice; 522 matches = Rails4.matches, getData = Rails4.getData, setData = Rails4.setData, fire = Rails4.fire, stopEverything = Rails4.stopEverything, ajax = Rails4.ajax, isCrossDomain = Rails4.isCrossDomain, serializeElement = Rails4.serializeElement; 523 isRemote = function(element) { 524 var value; 525 value = element.getAttribute("data-remote"); 526 return value != null && value !== "false"; 527 }; 528 Rails4.handleRemote = function(e2) { 529 var button, data, dataType, element, method, url, withCredentials; 530 element = this; 531 if (!isRemote(element)) { 532 return true; 533 } 534 if (!fire(element, "ajax:before")) { 535 fire(element, "ajax:stopped"); 536 return false; 537 } 538 withCredentials = element.getAttribute("data-with-credentials"); 539 dataType = element.getAttribute("data-type") || "script"; 540 if (matches(element, Rails4.formSubmitSelector)) { 541 button = getData(element, "ujs:submit-button"); 542 method = getData(element, "ujs:submit-button-formmethod") || element.method; 543 url = getData(element, "ujs:submit-button-formaction") || element.getAttribute("action") || location.href; 544 if (method.toUpperCase() === "GET") { 545 url = url.replace(/\?.*$/, ""); 546 } 547 if (element.enctype === "multipart/form-data") { 548 data = new FormData(element); 549 if (button != null) { 550 data.append(button.name, button.value); 551 } 552 } else { 553 data = serializeElement(element, button); 554 } 555 setData(element, "ujs:submit-button", null); 556 setData(element, "ujs:submit-button-formmethod", null); 557 setData(element, "ujs:submit-button-formaction", null); 558 } else if (matches(element, Rails4.buttonClickSelector) || matches(element, Rails4.inputChangeSelector)) { 559 method = element.getAttribute("data-method"); 560 url = element.getAttribute("data-url"); 561 data = serializeElement(element, element.getAttribute("data-params")); 562 } else { 563 method = element.getAttribute("data-method"); 564 url = Rails4.href(element); 565 data = element.getAttribute("data-params"); 566 } 567 ajax({ 568 type: method || "GET", 569 url, 570 data, 571 dataType, 572 beforeSend: function(xhr, options2) { 573 if (fire(element, "ajax:beforeSend", [xhr, options2])) { 574 return fire(element, "ajax:send", [xhr]); 575 } else { 576 fire(element, "ajax:stopped"); 577 return false; 578 } 579 }, 580 success: function() { 581 var args; 582 args = 1 <= arguments.length ? slice.call(arguments, 0) : []; 583 return fire(element, "ajax:success", args); 584 }, 585 error: function() { 586 var args; 587 args = 1 <= arguments.length ? slice.call(arguments, 0) : []; 588 return fire(element, "ajax:error", args); 589 }, 590 complete: function() { 591 var args; 592 args = 1 <= arguments.length ? slice.call(arguments, 0) : []; 593 return fire(element, "ajax:complete", args); 594 }, 595 crossDomain: isCrossDomain(url), 596 withCredentials: withCredentials != null && withCredentials !== "false" 597 }); 598 return stopEverything(e2); 599 }; 600 Rails4.formSubmitButtonClick = function(e2) { 601 var button, form; 602 button = this; 603 form = button.form; 604 if (!form) { 605 return; 606 } 607 if (button.name) { 608 setData(form, "ujs:submit-button", { 609 name: button.name, 610 value: button.value 611 }); 612 } 613 setData(form, "ujs:formnovalidate-button", button.formNoValidate); 614 setData(form, "ujs:submit-button-formaction", button.getAttribute("formaction")); 615 return setData(form, "ujs:submit-button-formmethod", button.getAttribute("formmethod")); 616 }; 617 Rails4.preventInsignificantClick = function(e2) { 618 var data, insignificantMetaClick, link, metaClick, method, nonPrimaryMouseClick; 619 link = this; 620 method = (link.getAttribute("data-method") || "GET").toUpperCase(); 621 data = link.getAttribute("data-params"); 622 metaClick = e2.metaKey || e2.ctrlKey; 623 insignificantMetaClick = metaClick && method === "GET" && !data; 624 nonPrimaryMouseClick = e2.button != null && e2.button !== 0; 625 if (nonPrimaryMouseClick || insignificantMetaClick) { 626 return e2.stopImmediatePropagation(); 627 } 628 }; 629 }).call(this); 630 (function() { 631 var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm2, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens; 632 fire = Rails4.fire, delegate = Rails4.delegate, getData = Rails4.getData, $ = Rails4.$, refreshCSRFTokens = Rails4.refreshCSRFTokens, CSRFProtection = Rails4.CSRFProtection, loadCSPNonce = Rails4.loadCSPNonce, enableElement = Rails4.enableElement, disableElement = Rails4.disableElement, handleDisabledElement = Rails4.handleDisabledElement, handleConfirm2 = Rails4.handleConfirm, preventInsignificantClick = Rails4.preventInsignificantClick, handleRemote = Rails4.handleRemote, formSubmitButtonClick = Rails4.formSubmitButtonClick, handleMethod = Rails4.handleMethod; 633 if (typeof jQuery !== "undefined" && jQuery !== null && jQuery.ajax != null) { 634 if (jQuery.rails) { 635 throw new Error("If you load both jquery_ujs and rails-ujs, use rails-ujs only."); 636 } 637 jQuery.rails = Rails4; 638 jQuery.ajaxPrefilter(function(options2, originalOptions, xhr) { 639 if (!options2.crossDomain) { 640 return CSRFProtection(xhr); 641 } 642 }); 643 } 644 Rails4.start = function() { 645 if (window._rails_loaded) { 646 throw new Error("rails-ujs has already been loaded!"); 647 } 648 window.addEventListener("pageshow", function() { 649 $(Rails4.formEnableSelector).forEach(function(el) { 650 if (getData(el, "ujs:disabled")) { 651 return enableElement(el); 652 } 653 }); 654 return $(Rails4.linkDisableSelector).forEach(function(el) { 655 if (getData(el, "ujs:disabled")) { 656 return enableElement(el); 657 } 658 }); 659 }); 660 delegate(document, Rails4.linkDisableSelector, "ajax:complete", enableElement); 661 delegate(document, Rails4.linkDisableSelector, "ajax:stopped", enableElement); 662 delegate(document, Rails4.buttonDisableSelector, "ajax:complete", enableElement); 663 delegate(document, Rails4.buttonDisableSelector, "ajax:stopped", enableElement); 664 delegate(document, Rails4.linkClickSelector, "click", preventInsignificantClick); 665 delegate(document, Rails4.linkClickSelector, "click", handleDisabledElement); 666 delegate(document, Rails4.linkClickSelector, "click", handleConfirm2); 667 delegate(document, Rails4.linkClickSelector, "click", disableElement); 668 delegate(document, Rails4.linkClickSelector, "click", handleRemote); 669 delegate(document, Rails4.linkClickSelector, "click", handleMethod); 670 delegate(document, Rails4.buttonClickSelector, "click", preventInsignificantClick); 671 delegate(document, Rails4.buttonClickSelector, "click", handleDisabledElement); 672 delegate(document, Rails4.buttonClickSelector, "click", handleConfirm2); 673 delegate(document, Rails4.buttonClickSelector, "click", disableElement); 674 delegate(document, Rails4.buttonClickSelector, "click", handleRemote); 675 delegate(document, Rails4.inputChangeSelector, "change", handleDisabledElement); 676 delegate(document, Rails4.inputChangeSelector, "change", handleConfirm2); 677 delegate(document, Rails4.inputChangeSelector, "change", handleRemote); 678 delegate(document, Rails4.formSubmitSelector, "submit", handleDisabledElement); 679 delegate(document, Rails4.formSubmitSelector, "submit", handleConfirm2); 680 delegate(document, Rails4.formSubmitSelector, "submit", handleRemote); 681 delegate(document, Rails4.formSubmitSelector, "submit", function(e2) { 682 return setTimeout(function() { 683 return disableElement(e2); 684 }, 13); 685 }); 686 delegate(document, Rails4.formSubmitSelector, "ajax:send", disableElement); 687 delegate(document, Rails4.formSubmitSelector, "ajax:complete", enableElement); 688 delegate(document, Rails4.formInputClickSelector, "click", preventInsignificantClick); 689 delegate(document, Rails4.formInputClickSelector, "click", handleDisabledElement); 690 delegate(document, Rails4.formInputClickSelector, "click", handleConfirm2); 691 delegate(document, Rails4.formInputClickSelector, "click", formSubmitButtonClick); 692 document.addEventListener("DOMContentLoaded", refreshCSRFTokens); 693 document.addEventListener("DOMContentLoaded", loadCSPNonce); 694 return window._rails_loaded = true; 695 }; 696 if (window.Rails === Rails4 && fire(document, "rails:attachBindings")) { 697 Rails4.start(); 698 } 699 }).call(this); 700 }).call(this); 701 if (typeof module5 === "object" && module5.exports) { 702 module5.exports = Rails4; 703 } else if (typeof define === "function" && define.amd) { 704 define(Rails4); 705 } 706 }).call(exports2); 707 } 708 }); 709 710
vendor: 290 bytes, lines 710-721
710// ../../node_modules/@rails/actioncable/src/adapters.js 711 var adapters_default; 712 var init_adapters = __esm({ 713 "../../node_modules/@rails/actioncable/src/adapters.js"() { 714 adapters_default = { 715 logger: self.console, 716 WebSocket: self.WebSocket 717 }; 718 } 719 }); 720 721
vendor: 428 bytes, lines 721-737
721// ../../node_modules/@rails/actioncable/src/logger.js 722 var logger_default; 723 var init_logger = __esm({ 724 "../../node_modules/@rails/actioncable/src/logger.js"() { 725 init_adapters(); 726 logger_default = { 727 log(...messages) { 728 if (this.enabled) { 729 messages.push(Date.now()); 730 adapters_default.logger.log("[ActionCable]", ...messages); 731 } 732 } 733 }; 734 } 735 }); 736 737
vendor: 4,226 bytes, lines 737-841
737// ../../node_modules/@rails/actioncable/src/connection_monitor.js 738 var now, secondsSince, ConnectionMonitor, connection_monitor_default; 739 var init_connection_monitor = __esm({ 740 "../../node_modules/@rails/actioncable/src/connection_monitor.js"() { 741 init_logger(); 742 now = () => new Date().getTime(); 743 secondsSince = (time) => (now() - time) / 1e3; 744 ConnectionMonitor = class { 745 constructor(connection) { 746 this.visibilityDidChange = this.visibilityDidChange.bind(this); 747 this.connection = connection; 748 this.reconnectAttempts = 0; 749 } 750 start() { 751 if (!this.isRunning()) { 752 this.startedAt = now(); 753 delete this.stoppedAt; 754 this.startPolling(); 755 addEventListener("visibilitychange", this.visibilityDidChange); 756 logger_default.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`); 757 } 758 } 759 stop() { 760 if (this.isRunning()) { 761 this.stoppedAt = now(); 762 this.stopPolling(); 763 removeEventListener("visibilitychange", this.visibilityDidChange); 764 logger_default.log("ConnectionMonitor stopped"); 765 } 766 } 767 isRunning() { 768 return this.startedAt && !this.stoppedAt; 769 } 770 recordPing() { 771 this.pingedAt = now(); 772 } 773 recordConnect() { 774 this.reconnectAttempts = 0; 775 this.recordPing(); 776 delete this.disconnectedAt; 777 logger_default.log("ConnectionMonitor recorded connect"); 778 } 779 recordDisconnect() { 780 this.disconnectedAt = now(); 781 logger_default.log("ConnectionMonitor recorded disconnect"); 782 } 783 startPolling() { 784 this.stopPolling(); 785 this.poll(); 786 } 787 stopPolling() { 788 clearTimeout(this.pollTimeout); 789 } 790 poll() { 791 this.pollTimeout = setTimeout(() => { 792 this.reconnectIfStale(); 793 this.poll(); 794 }, this.getPollInterval()); 795 } 796 getPollInterval() { 797 const { staleThreshold, reconnectionBackoffRate } = this.constructor; 798 const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10)); 799 const jitterMax = this.reconnectAttempts === 0 ? 1 : reconnectionBackoffRate; 800 const jitter = jitterMax * Math.random(); 801 return staleThreshold * 1e3 * backoff * (1 + jitter); 802 } 803 reconnectIfStale() { 804 if (this.connectionIsStale()) { 805 logger_default.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`); 806 this.reconnectAttempts++; 807 if (this.disconnectedRecently()) { 808 logger_default.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(this.disconnectedAt)} s`); 809 } else { 810 logger_default.log("ConnectionMonitor reopening"); 811 this.connection.reopen(); 812 } 813 } 814 } 815 get refreshedAt() { 816 return this.pingedAt ? this.pingedAt : this.startedAt; 817 } 818 connectionIsStale() { 819 return secondsSince(this.refreshedAt) > this.constructor.staleThreshold; 820 } 821 disconnectedRecently() { 822 return this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold; 823 } 824 visibilityDidChange() { 825 if (document.visibilityState === "visible") { 826 setTimeout(() => { 827 if (this.connectionIsStale() || !this.connection.isOpen()) { 828 logger_default.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`); 829 this.connection.reopen(); 830 } 831 }, 200); 832 } 833 } 834 }; 835 ConnectionMonitor.staleThreshold = 6; 836 ConnectionMonitor.reconnectionBackoffRate = 0.15; 837 connection_monitor_default = ConnectionMonitor; 838 } 839 }); 840 841
vendor: 775 bytes, lines 841-867
841// ../../node_modules/@rails/actioncable/src/internal.js 842 var internal_default; 843 var init_internal = __esm({ 844 "../../node_modules/@rails/actioncable/src/internal.js"() { 845 internal_default = { 846 "message_types": { 847 "welcome": "welcome", 848 "disconnect": "disconnect", 849 "ping": "ping", 850 "confirmation": "confirm_subscription", 851 "rejection": "reject_subscription" 852 }, 853 "disconnect_reasons": { 854 "unauthorized": "unauthorized", 855 "invalid_request": "invalid_request", 856 "server_restart": "server_restart" 857 }, 858 "default_mount_path": "/cable", 859 "protocols": [ 860 "actioncable-v1-json", 861 "actioncable-unsupported" 862 ] 863 }; 864 } 865 }); 866 867
vendor: 5,640 bytes, lines 867-1022
867// ../../node_modules/@rails/actioncable/src/connection.js 868 var message_types, protocols, supportedProtocols, indexOf, Connection, connection_default; 869 var init_connection = __esm({ 870 "../../node_modules/@rails/actioncable/src/connection.js"() { 871 init_adapters(); 872 init_connection_monitor(); 873 init_internal(); 874 init_logger(); 875 ({ message_types, protocols } = internal_default); 876 supportedProtocols = protocols.slice(0, protocols.length - 1); 877 indexOf = [].indexOf; 878 Connection = class { 879 constructor(consumer2) { 880 this.open = this.open.bind(this); 881 this.consumer = consumer2; 882 this.subscriptions = this.consumer.subscriptions; 883 this.monitor = new connection_monitor_default(this); 884 this.disconnected = true; 885 } 886 send(data) { 887 if (this.isOpen()) { 888 this.webSocket.send(JSON.stringify(data)); 889 return true; 890 } else { 891 return false; 892 } 893 } 894 open() { 895 if (this.isActive()) { 896 logger_default.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`); 897 return false; 898 } else { 899 logger_default.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${protocols}`); 900 if (this.webSocket) { 901 this.uninstallEventHandlers(); 902 } 903 this.webSocket = new adapters_default.WebSocket(this.consumer.url, protocols); 904 this.installEventHandlers(); 905 this.monitor.start(); 906 return true; 907 } 908 } 909 close({ allowReconnect } = { allowReconnect: true }) { 910 if (!allowReconnect) { 911 this.monitor.stop(); 912 } 913 if (this.isActive()) { 914 return this.webSocket.close(); 915 } 916 } 917 reopen() { 918 logger_default.log(`Reopening WebSocket, current state is ${this.getState()}`); 919 if (this.isActive()) { 920 try { 921 return this.close(); 922 } catch (error2) { 923 logger_default.log("Failed to reopen WebSocket", error2); 924 } finally { 925 logger_default.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`); 926 setTimeout(this.open, this.constructor.reopenDelay); 927 } 928 } else { 929 return this.open(); 930 } 931 } 932 getProtocol() { 933 if (this.webSocket) { 934 return this.webSocket.protocol; 935 } 936 } 937 isOpen() { 938 return this.isState("open"); 939 } 940 isActive() { 941 return this.isState("open", "connecting"); 942 } 943 isProtocolSupported() { 944 return indexOf.call(supportedProtocols, this.getProtocol()) >= 0; 945 } 946 isState(...states) { 947 return indexOf.call(states, this.getState()) >= 0; 948 } 949 getState() { 950 if (this.webSocket) { 951 for (let state in adapters_default.WebSocket) { 952 if (adapters_default.WebSocket[state] === this.webSocket.readyState) { 953 return state.toLowerCase(); 954 } 955 } 956 } 957 return null; 958 } 959 installEventHandlers() { 960 for (let eventName in this.events) { 961 const handler = this.events[eventName].bind(this); 962 this.webSocket[`on${eventName}`] = handler; 963 } 964 } 965 uninstallEventHandlers() { 966 for (let eventName in this.events) { 967 this.webSocket[`on${eventName}`] = function() { 968 }; 969 } 970 } 971 }; 972 Connection.reopenDelay = 500; 973 Connection.prototype.events = { 974 message(event) { 975 if (!this.isProtocolSupported()) { 976 return; 977 } 978 const { identifier, message, reason, reconnect, type } = JSON.parse(event.data); 979 switch (type) { 980 case message_types.welcome: 981 this.monitor.recordConnect(); 982 return this.subscriptions.reload(); 983 case message_types.disconnect: 984 logger_default.log(`Disconnecting. Reason: ${reason}`); 985 return this.close({ allowReconnect: reconnect }); 986 case message_types.ping: 987 return this.monitor.recordPing(); 988 case message_types.confirmation: 989 this.subscriptions.confirmSubscription(identifier); 990 return this.subscriptions.notify(identifier, "connected"); 991 case message_types.rejection: 992 return this.subscriptions.reject(identifier); 993 default: 994 return this.subscriptions.notify(identifier, "received", message); 995 } 996 }, 997 open() { 998 logger_default.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`); 999 this.disconnected = false; 1000 if (!this.isProtocolSupported()) { 1001 logger_default.log("Protocol is unsupported. Stopping monitor and disconnecting."); 1002 return this.close({ allowReconnect: false }); 1003 } 1004 }, 1005 close(event) { 1006 logger_default.log("WebSocket onclose event"); 1007 if (this.disconnected) { 1008 return; 1009 } 1010 this.disconnected = true; 1011 this.monitor.recordDisconnect(); 1012 return this.subscriptions.notifyAll("disconnected", { willAttemptReconnect: this.monitor.isRunning() }); 1013 }, 1014 error() { 1015 logger_default.log("WebSocket onerror event"); 1016 } 1017 }; 1018 connection_default = Connection; 1019 } 1020 }); 1021 1022
vendor: 1,032 bytes, lines 1022-1055
1022// ../../node_modules/@rails/actioncable/src/subscription.js 1023 var extend, Subscription; 1024 var init_subscription = __esm({ 1025 "../../node_modules/@rails/actioncable/src/subscription.js"() { 1026 extend = function(object, properties) { 1027 if (properties != null) { 1028 for (let key in properties) { 1029 const value = properties[key]; 1030 object[key] = value; 1031 } 1032 } 1033 return object; 1034 }; 1035 Subscription = class { 1036 constructor(consumer2, params = {}, mixin) { 1037 this.consumer = consumer2; 1038 this.identifier = JSON.stringify(params); 1039 extend(this, mixin); 1040 } 1041 perform(action, data = {}) { 1042 data.action = action; 1043 return this.send(data); 1044 } 1045 send(data) { 1046 return this.consumer.send({ command: "message", identifier: this.identifier, data: JSON.stringify(data) }); 1047 } 1048 unsubscribe() { 1049 return this.consumer.subscriptions.remove(this); 1050 } 1051 }; 1052 } 1053 }); 1054 1055
vendor: 1,860 bytes, lines 1055-1100
1055// ../../node_modules/@rails/actioncable/src/subscription_guarantor.js 1056 var SubscriptionGuarantor, subscription_guarantor_default; 1057 var init_subscription_guarantor = __esm({ 1058 "../../node_modules/@rails/actioncable/src/subscription_guarantor.js"() { 1059 init_logger(); 1060 SubscriptionGuarantor = class { 1061 constructor(subscriptions) { 1062 this.subscriptions = subscriptions; 1063 this.pendingSubscriptions = []; 1064 } 1065 guarantee(subscription) { 1066 if (this.pendingSubscriptions.indexOf(subscription) == -1) { 1067 logger_default.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`); 1068 this.pendingSubscriptions.push(subscription); 1069 } else { 1070 logger_default.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`); 1071 } 1072 this.startGuaranteeing(); 1073 } 1074 forget(subscription) { 1075 logger_default.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`); 1076 this.pendingSubscriptions = this.pendingSubscriptions.filter((s2) => s2 !== subscription); 1077 } 1078 startGuaranteeing() { 1079 this.stopGuaranteeing(); 1080 this.retrySubscribing(); 1081 } 1082 stopGuaranteeing() { 1083 clearTimeout(this.retryTimeout); 1084 } 1085 retrySubscribing() { 1086 this.retryTimeout = setTimeout(() => { 1087 if (this.subscriptions && typeof this.subscriptions.subscribe === "function") { 1088 this.pendingSubscriptions.map((subscription) => { 1089 logger_default.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`); 1090 this.subscriptions.subscribe(subscription); 1091 }); 1092 } 1093 }, 500); 1094 } 1095 }; 1096 subscription_guarantor_default = SubscriptionGuarantor; 1097 } 1098 }); 1099 1100
vendor: 3,125 bytes, lines 1100-1180
1100// ../../node_modules/@rails/actioncable/src/subscriptions.js 1101 var Subscriptions; 1102 var init_subscriptions = __esm({ 1103 "../../node_modules/@rails/actioncable/src/subscriptions.js"() { 1104 init_subscription(); 1105 init_subscription_guarantor(); 1106 init_logger(); 1107 Subscriptions = class { 1108 constructor(consumer2) { 1109 this.consumer = consumer2; 1110 this.guarantor = new subscription_guarantor_default(this); 1111 this.subscriptions = []; 1112 } 1113 create(channelName, mixin) { 1114 const channel = channelName; 1115 const params = typeof channel === "object" ? channel : { channel }; 1116 const subscription = new Subscription(this.consumer, params, mixin); 1117 return this.add(subscription); 1118 } 1119 add(subscription) { 1120 this.subscriptions.push(subscription); 1121 this.consumer.ensureActiveConnection(); 1122 this.notify(subscription, "initialized"); 1123 this.subscribe(subscription); 1124 return subscription; 1125 } 1126 remove(subscription) { 1127 this.forget(subscription); 1128 if (!this.findAll(subscription.identifier).length) { 1129 this.sendCommand(subscription, "unsubscribe"); 1130 } 1131 return subscription; 1132 } 1133 reject(identifier) { 1134 return this.findAll(identifier).map((subscription) => { 1135 this.forget(subscription); 1136 this.notify(subscription, "rejected"); 1137 return subscription; 1138 }); 1139 } 1140 forget(subscription) { 1141 this.guarantor.forget(subscription); 1142 this.subscriptions = this.subscriptions.filter((s2) => s2 !== subscription); 1143 return subscription; 1144 } 1145 findAll(identifier) { 1146 return this.subscriptions.filter((s2) => s2.identifier === identifier); 1147 } 1148 reload() { 1149 return this.subscriptions.map((subscription) => this.subscribe(subscription)); 1150 } 1151 notifyAll(callbackName, ...args) { 1152 return this.subscriptions.map((subscription) => this.notify(subscription, callbackName, ...args)); 1153 } 1154 notify(subscription, callbackName, ...args) { 1155 let subscriptions; 1156 if (typeof subscription === "string") { 1157 subscriptions = this.findAll(subscription); 1158 } else { 1159 subscriptions = [subscription]; 1160 } 1161 return subscriptions.map((subscription2) => typeof subscription2[callbackName] === "function" ? subscription2[callbackName](...args) : void 0); 1162 } 1163 subscribe(subscription) { 1164 if (this.sendCommand(subscription, "subscribe")) { 1165 this.guarantor.guarantee(subscription); 1166 } 1167 } 1168 confirmSubscription(identifier) { 1169 logger_default.log(`Subscription confirmed ${identifier}`); 1170 this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription)); 1171 } 1172 sendCommand(subscription, command) { 1173 const { identifier } = subscription; 1174 return this.consumer.send({ command, identifier }); 1175 } 1176 }; 1177 } 1178 }); 1179 1180
vendor: 1,265 bytes, lines 1180-1227
1180// ../../node_modules/@rails/actioncable/src/consumer.js 1181 function createWebSocketURL(url) { 1182 if (typeof url === "function") { 1183 url = url(); 1184 } 1185 if (url && !/^wss?:/i.test(url)) { 1186 const a2 = document.createElement("a"); 1187 a2.href = url; 1188 a2.href = a2.href; 1189 a2.protocol = a2.protocol.replace("http", "ws"); 1190 return a2.href; 1191 } else { 1192 return url; 1193 } 1194 } 1195 var Consumer; 1196 var init_consumer = __esm({ 1197 "../../node_modules/@rails/actioncable/src/consumer.js"() { 1198 init_connection(); 1199 init_subscriptions(); 1200 Consumer = class { 1201 constructor(url) { 1202 this._url = url; 1203 this.subscriptions = new Subscriptions(this); 1204 this.connection = new connection_default(this); 1205 } 1206 get url() { 1207 return createWebSocketURL(this._url); 1208 } 1209 send(data) { 1210 return this.connection.send(data); 1211 } 1212 connect() { 1213 return this.connection.open(); 1214 } 1215 disconnect() { 1216 return this.connection.close({ allowReconnect: false }); 1217 } 1218 ensureActiveConnection() { 1219 if (!this.connection.isActive()) { 1220 return this.connection.open(); 1221 } 1222 } 1223 }; 1224 } 1225 }); 1226 1227
vendor: 1,271 bytes, lines 1227-1266
1227// ../../node_modules/@rails/actioncable/src/index.js 1228 var src_exports = {}; 1229 __export(src_exports, { 1230 Connection: () => connection_default, 1231 ConnectionMonitor: () => connection_monitor_default, 1232 Consumer: () => Consumer, 1233 INTERNAL: () => internal_default, 1234 Subscription: () => Subscription, 1235 SubscriptionGuarantor: () => subscription_guarantor_default, 1236 Subscriptions: () => Subscriptions, 1237 adapters: () => adapters_default, 1238 createConsumer: () => createConsumer, 1239 createWebSocketURL: () => createWebSocketURL, 1240 getConfig: () => getConfig, 1241 logger: () => logger_default 1242 }); 1243 function createConsumer(url = getConfig("url") || internal_default.default_mount_path) { 1244 return new Consumer(url); 1245 } 1246 function getConfig(name) { 1247 const element = document.head.querySelector(`meta[name='action-cable-${name}']`); 1248 if (element) { 1249 return element.getAttribute("content"); 1250 } 1251 } 1252 var init_src = __esm({ 1253 "../../node_modules/@rails/actioncable/src/index.js"() { 1254 init_connection(); 1255 init_connection_monitor(); 1256 init_consumer(); 1257 init_internal(); 1258 init_subscription(); 1259 init_subscriptions(); 1260 init_subscription_guarantor(); 1261 init_adapters(); 1262 init_logger(); 1263 } 1264 }); 1265 1266
vendor: 34,430 bytes, lines 1266-2095
1266// ../../node_modules/@rails/activestorage/app/assets/javascripts/activestorage.js 1267 var require_activestorage = __commonJS({ 1268 "../../node_modules/@rails/activestorage/app/assets/javascripts/activestorage.js"(exports2, module5) { 1269 (function(global, factory) { 1270 typeof exports2 === "object" && typeof module5 !== "undefined" ? factory(exports2) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.ActiveStorage = {})); 1271 })(exports2, function(exports3) { 1272 "use strict"; 1273 var sparkMd5 = { 1274 exports: {} 1275 }; 1276 (function(module6, exports4) { 1277 (function(factory) { 1278 { 1279 module6.exports = factory(); 1280 } 1281 })(function(undefined$1) { 1282 var hex_chr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; 1283 function md5cycle(x, k) { 1284 var a2 = x[0], b = x[1], c = x[2], d = x[3]; 1285 a2 += (b & c | ~b & d) + k[0] - 680876936 | 0; 1286 a2 = (a2 << 7 | a2 >>> 25) + b | 0; 1287 d += (a2 & b | ~a2 & c) + k[1] - 389564586 | 0; 1288 d = (d << 12 | d >>> 20) + a2 | 0; 1289 c += (d & a2 | ~d & b) + k[2] + 606105819 | 0; 1290 c = (c << 17 | c >>> 15) + d | 0; 1291 b += (c & d | ~c & a2) + k[3] - 1044525330 | 0; 1292 b = (b << 22 | b >>> 10) + c | 0; 1293 a2 += (b & c | ~b & d) + k[4] - 176418897 | 0; 1294 a2 = (a2 << 7 | a2 >>> 25) + b | 0; 1295 d += (a2 & b | ~a2 & c) + k[5] + 1200080426 | 0; 1296 d = (d << 12 | d >>> 20) + a2 | 0; 1297 c += (d & a2 | ~d & b) + k[6] - 1473231341 | 0; 1298 c = (c << 17 | c >>> 15) + d | 0; 1299 b += (c & d | ~c & a2) + k[7] - 45705983 | 0; 1300 b = (b << 22 | b >>> 10) + c | 0; 1301 a2 += (b & c | ~b & d) + k[8] + 1770035416 | 0; 1302 a2 = (a2 << 7 | a2 >>> 25) + b | 0; 1303 d += (a2 & b | ~a2 & c) + k[9] - 1958414417 | 0; 1304 d = (d << 12 | d >>> 20) + a2 | 0; 1305 c += (d & a2 | ~d & b) + k[10] - 42063 | 0; 1306 c = (c << 17 | c >>> 15) + d | 0; 1307 b += (c & d | ~c & a2) + k[11] - 1990404162 | 0; 1308 b = (b << 22 | b >>> 10) + c | 0; 1309 a2 += (b & c | ~b & d) + k[12] + 1804603682 | 0; 1310 a2 = (a2 << 7 | a2 >>> 25) + b | 0; 1311 d += (a2 & b | ~a2 & c) + k[13] - 40341101 | 0; 1312 d = (d << 12 | d >>> 20) + a2 | 0; 1313 c += (d & a2 | ~d & b) + k[14] - 1502002290 | 0; 1314 c = (c << 17 | c >>> 15) + d | 0; 1315 b += (c & d | ~c & a2) + k[15] + 1236535329 | 0; 1316 b = (b << 22 | b >>> 10) + c | 0; 1317 a2 += (b & d | c & ~d) + k[1] - 165796510 | 0; 1318 a2 = (a2 << 5 | a2 >>> 27) + b | 0; 1319 d += (a2 & c | b & ~c) + k[6] - 1069501632 | 0; 1320 d = (d << 9 | d >>> 23) + a2 | 0; 1321 c += (d & b | a2 & ~b) + k[11] + 643717713 | 0; 1322 c = (c << 14 | c >>> 18) + d | 0; 1323 b += (c & a2 | d & ~a2) + k[0] - 373897302 | 0; 1324 b = (b << 20 | b >>> 12) + c | 0; 1325 a2 += (b & d | c & ~d) + k[5] - 701558691 | 0; 1326 a2 = (a2 << 5 | a2 >>> 27) + b | 0; 1327 d += (a2 & c | b & ~c) + k[10] + 38016083 | 0; 1328 d = (d << 9 | d >>> 23) + a2 | 0; 1329 c += (d & b | a2 & ~b) + k[15] - 660478335 | 0; 1330 c = (c << 14 | c >>> 18) + d | 0; 1331 b += (c & a2 | d & ~a2) + k[4] - 405537848 | 0; 1332 b = (b << 20 | b >>> 12) + c | 0; 1333 a2 += (b & d | c & ~d) + k[9] + 568446438 | 0; 1334 a2 = (a2 << 5 | a2 >>> 27) + b | 0; 1335 d += (a2 & c | b & ~c) + k[14] - 1019803690 | 0; 1336 d = (d << 9 | d >>> 23) + a2 | 0; 1337 c += (d & b | a2 & ~b) + k[3] - 187363961 | 0; 1338 c = (c << 14 | c >>> 18) + d | 0; 1339 b += (c & a2 | d & ~a2) + k[8] + 1163531501 | 0; 1340 b = (b << 20 | b >>> 12) + c | 0; 1341 a2 += (b & d | c & ~d) + k[13] - 1444681467 | 0; 1342 a2 = (a2 << 5 | a2 >>> 27) + b | 0; 1343 d += (a2 & c | b & ~c) + k[2] - 51403784 | 0; 1344 d = (d << 9 | d >>> 23) + a2 | 0; 1345 c += (d & b | a2 & ~b) + k[7] + 1735328473 | 0; 1346 c = (c << 14 | c >>> 18) + d | 0; 1347 b += (c & a2 | d & ~a2) + k[12] - 1926607734 | 0; 1348 b = (b << 20 | b >>> 12) + c | 0; 1349 a2 += (b ^ c ^ d) + k[5] - 378558 | 0; 1350 a2 = (a2 << 4 | a2 >>> 28) + b | 0; 1351 d += (a2 ^ b ^ c) + k[8] - 2022574463 | 0; 1352 d = (d << 11 | d >>> 21) + a2 | 0; 1353 c += (d ^ a2 ^ b) + k[11] + 1839030562 | 0; 1354 c = (c << 16 | c >>> 16) + d | 0; 1355 b += (c ^ d ^ a2) + k[14] - 35309556 | 0; 1356 b = (b << 23 | b >>> 9) + c | 0; 1357 a2 += (b ^ c ^ d) + k[1] - 1530992060 | 0; 1358 a2 = (a2 << 4 | a2 >>> 28) + b | 0; 1359 d += (a2 ^ b ^ c) + k[4] + 1272893353 | 0; 1360 d = (d << 11 | d >>> 21) + a2 | 0; 1361 c += (d ^ a2 ^ b) + k[7] - 155497632 | 0; 1362 c = (c << 16 | c >>> 16) + d | 0; 1363 b += (c ^ d ^ a2) + k[10] - 1094730640 | 0; 1364 b = (b << 23 | b >>> 9) + c | 0; 1365 a2 += (b ^ c ^ d) + k[13] + 681279174 | 0; 1366 a2 = (a2 << 4 | a2 >>> 28) + b | 0; 1367 d += (a2 ^ b ^ c) + k[0] - 358537222 | 0; 1368 d = (d << 11 | d >>> 21) + a2 | 0; 1369 c += (d ^ a2 ^ b) + k[3] - 722521979 | 0; 1370 c = (c << 16 | c >>> 16) + d | 0; 1371 b += (c ^ d ^ a2) + k[6] + 76029189 | 0; 1372 b = (b << 23 | b >>> 9) + c | 0; 1373 a2 += (b ^ c ^ d) + k[9] - 640364487 | 0; 1374 a2 = (a2 << 4 | a2 >>> 28) + b | 0; 1375 d += (a2 ^ b ^ c) + k[12] - 421815835 | 0; 1376 d = (d << 11 | d >>> 21) + a2 | 0; 1377 c += (d ^ a2 ^ b) + k[15] + 530742520 | 0; 1378 c = (c << 16 | c >>> 16) + d | 0; 1379 b += (c ^ d ^ a2) + k[2] - 995338651 | 0; 1380 b = (b << 23 | b >>> 9) + c | 0; 1381 a2 += (c ^ (b | ~d)) + k[0] - 198630844 | 0; 1382 a2 = (a2 << 6 | a2 >>> 26) + b | 0; 1383 d += (b ^ (a2 | ~c)) + k[7] + 1126891415 | 0; 1384 d = (d << 10 | d >>> 22) + a2 | 0; 1385 c += (a2 ^ (d | ~b)) + k[14] - 1416354905 | 0; 1386 c = (c << 15 | c >>> 17) + d | 0; 1387 b += (d ^ (c | ~a2)) + k[5] - 57434055 | 0; 1388 b = (b << 21 | b >>> 11) + c | 0; 1389 a2 += (c ^ (b | ~d)) + k[12] + 1700485571 | 0; 1390 a2 = (a2 << 6 | a2 >>> 26) + b | 0; 1391 d += (b ^ (a2 | ~c)) + k[3] - 1894986606 | 0; 1392 d = (d << 10 | d >>> 22) + a2 | 0; 1393 c += (a2 ^ (d | ~b)) + k[10] - 1051523 | 0; 1394 c = (c << 15 | c >>> 17) + d | 0; 1395 b += (d ^ (c | ~a2)) + k[1] - 2054922799 | 0; 1396 b = (b << 21 | b >>> 11) + c | 0; 1397 a2 += (c ^ (b | ~d)) + k[8] + 1873313359 | 0; 1398 a2 = (a2 << 6 | a2 >>> 26) + b | 0; 1399 d += (b ^ (a2 | ~c)) + k[15] - 30611744 | 0; 1400 d = (d << 10 | d >>> 22) + a2 | 0; 1401 c += (a2 ^ (d | ~b)) + k[6] - 1560198380 | 0; 1402 c = (c << 15 | c >>> 17) + d | 0; 1403 b += (d ^ (c | ~a2)) + k[13] + 1309151649 | 0; 1404 b = (b << 21 | b >>> 11) + c | 0; 1405 a2 += (c ^ (b | ~d)) + k[4] - 145523070 | 0; 1406 a2 = (a2 << 6 | a2 >>> 26) + b | 0; 1407 d += (b ^ (a2 | ~c)) + k[11] - 1120210379 | 0; 1408 d = (d << 10 | d >>> 22) + a2 | 0; 1409 c += (a2 ^ (d | ~b)) + k[2] + 718787259 | 0; 1410 c = (c << 15 | c >>> 17) + d | 0; 1411 b += (d ^ (c | ~a2)) + k[9] - 343485551 | 0; 1412 b = (b << 21 | b >>> 11) + c | 0; 1413 x[0] = a2 + x[0] | 0; 1414 x[1] = b + x[1] | 0; 1415 x[2] = c + x[2] | 0; 1416 x[3] = d + x[3] | 0; 1417 } 1418 function md5blk(s2) { 1419 var md5blks = [], i2; 1420 for (i2 = 0; i2 < 64; i2 += 4) { 1421 md5blks[i2 >> 2] = s2.charCodeAt(i2) + (s2.charCodeAt(i2 + 1) << 8) + (s2.charCodeAt(i2 + 2) << 16) + (s2.charCodeAt(i2 + 3) << 24); 1422 } 1423 return md5blks; 1424 } 1425 function md5blk_array(a2) { 1426 var md5blks = [], i2; 1427 for (i2 = 0; i2 < 64; i2 += 4) { 1428 md5blks[i2 >> 2] = a2[i2] + (a2[i2 + 1] << 8) + (a2[i2 + 2] << 16) + (a2[i2 + 3] << 24); 1429 } 1430 return md5blks; 1431 } 1432 function md51(s2) { 1433 var n2 = s2.length, state = [1732584193, -271733879, -1732584194, 271733878], i2, length, tail, tmp, lo, hi; 1434 for (i2 = 64; i2 <= n2; i2 += 64) { 1435 md5cycle(state, md5blk(s2.substring(i2 - 64, i2))); 1436 } 1437 s2 = s2.substring(i2 - 64); 1438 length = s2.length; 1439 tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; 1440 for (i2 = 0; i2 < length; i2 += 1) { 1441 tail[i2 >> 2] |= s2.charCodeAt(i2) << (i2 % 4 << 3); 1442 } 1443 tail[i2 >> 2] |= 128 << (i2 % 4 << 3); 1444 if (i2 > 55) { 1445 md5cycle(state, tail); 1446 for (i2 = 0; i2 < 16; i2 += 1) { 1447 tail[i2] = 0; 1448 } 1449 } 1450 tmp = n2 * 8; 1451 tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/); 1452 lo = parseInt(tmp[2], 16); 1453 hi = parseInt(tmp[1], 16) || 0; 1454 tail[14] = lo; 1455 tail[15] = hi; 1456 md5cycle(state, tail); 1457 return state; 1458 } 1459 function md51_array(a2) { 1460 var n2 = a2.length, state = [1732584193, -271733879, -1732584194, 271733878], i2, length, tail, tmp, lo, hi; 1461 for (i2 = 64; i2 <= n2; i2 += 64) { 1462 md5cycle(state, md5blk_array(a2.subarray(i2 - 64, i2))); 1463 } 1464 a2 = i2 - 64 < n2 ? a2.subarray(i2 - 64) : new Uint8Array(0); 1465 length = a2.length; 1466 tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; 1467 for (i2 = 0; i2 < length; i2 += 1) { 1468 tail[i2 >> 2] |= a2[i2] << (i2 % 4 << 3); 1469 } 1470 tail[i2 >> 2] |= 128 << (i2 % 4 << 3); 1471 if (i2 > 55) { 1472 md5cycle(state, tail); 1473 for (i2 = 0; i2 < 16; i2 += 1) { 1474 tail[i2] = 0; 1475 } 1476 } 1477 tmp = n2 * 8; 1478 tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/); 1479 lo = parseInt(tmp[2], 16); 1480 hi = parseInt(tmp[1], 16) || 0; 1481 tail[14] = lo; 1482 tail[15] = hi; 1483 md5cycle(state, tail); 1484 return state; 1485 } 1486 function rhex(n2) { 1487 var s2 = "", j; 1488 for (j = 0; j < 4; j += 1) { 1489 s2 += hex_chr[n2 >> j * 8 + 4 & 15] + hex_chr[n2 >> j * 8 & 15]; 1490 } 1491 return s2; 1492 } 1493 function hex(x) { 1494 var i2; 1495 for (i2 = 0; i2 < x.length; i2 += 1) { 1496 x[i2] = rhex(x[i2]); 1497 } 1498 return x.join(""); 1499 } 1500 if (hex(md51("hello")) !== "5d41402abc4b2a76b9719d911017c592") 1501 ; 1502 if (typeof ArrayBuffer !== "undefined" && !ArrayBuffer.prototype.slice) { 1503 (function() { 1504 function clamp(val, length) { 1505 val = val | 0 || 0; 1506 if (val < 0) { 1507 return Math.max(val + length, 0); 1508 } 1509 return Math.min(val, length); 1510 } 1511 ArrayBuffer.prototype.slice = function(from, to) { 1512 var length = this.byteLength, begin = clamp(from, length), end2 = length, num, target, targetArray, sourceArray; 1513 if (to !== undefined$1) { 1514 end2 = clamp(to, length); 1515 } 1516 if (begin > end2) { 1517 return new ArrayBuffer(0); 1518 } 1519 num = end2 - begin; 1520 target = new ArrayBuffer(num); 1521 targetArray = new Uint8Array(target); 1522 sourceArray = new Uint8Array(this, begin, num); 1523 targetArray.set(sourceArray); 1524 return target; 1525 }; 1526 })(); 1527 } 1528 function toUtf8(str) { 1529 if (/[\u0080-\uFFFF]/.test(str)) { 1530 str = unescape(encodeURIComponent(str)); 1531 } 1532 return str; 1533 } 1534 function utf8Str2ArrayBuffer(str, returnUInt8Array) { 1535 var length = str.length, buff = new ArrayBuffer(length), arr = new Uint8Array(buff), i2; 1536 for (i2 = 0; i2 < length; i2 += 1) { 1537 arr[i2] = str.charCodeAt(i2); 1538 } 1539 return returnUInt8Array ? arr : buff; 1540 } 1541 function arrayBuffer2Utf8Str(buff) { 1542 return String.fromCharCode.apply(null, new Uint8Array(buff)); 1543 } 1544 function concatenateArrayBuffers(first, second, returnUInt8Array) { 1545 var result = new Uint8Array(first.byteLength + second.byteLength); 1546 result.set(new Uint8Array(first)); 1547 result.set(new Uint8Array(second), first.byteLength); 1548 return returnUInt8Array ? result : result.buffer; 1549 } 1550 function hexToBinaryString(hex2) { 1551 var bytes = [], length = hex2.length, x; 1552 for (x = 0; x < length - 1; x += 2) { 1553 bytes.push(parseInt(hex2.substr(x, 2), 16)); 1554 } 1555 return String.fromCharCode.apply(String, bytes); 1556 } 1557 function SparkMD52() { 1558 this.reset(); 1559 } 1560 SparkMD52.prototype.append = function(str) { 1561 this.appendBinary(toUtf8(str)); 1562 return this; 1563 }; 1564 SparkMD52.prototype.appendBinary = function(contents) { 1565 this._buff += contents; 1566 this._length += contents.length; 1567 var length = this._buff.length, i2; 1568 for (i2 = 64; i2 <= length; i2 += 64) { 1569 md5cycle(this._hash, md5blk(this._buff.substring(i2 - 64, i2))); 1570 } 1571 this._buff = this._buff.substring(i2 - 64); 1572 return this; 1573 }; 1574 SparkMD52.prototype.end = function(raw) { 1575 var buff = this._buff, length = buff.length, i2, tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ret; 1576 for (i2 = 0; i2 < length; i2 += 1) { 1577 tail[i2 >> 2] |= buff.charCodeAt(i2) << (i2 % 4 << 3); 1578 } 1579 this._finish(tail, length); 1580 ret = hex(this._hash); 1581 if (raw) { 1582 ret = hexToBinaryString(ret); 1583 } 1584 this.reset(); 1585 return ret; 1586 }; 1587 SparkMD52.prototype.reset = function() { 1588 this._buff = ""; 1589 this._length = 0; 1590 this._hash = [1732584193, -271733879, -1732584194, 271733878]; 1591 return this; 1592 }; 1593 SparkMD52.prototype.getState = function() { 1594 return { 1595 buff: this._buff, 1596 length: this._length, 1597 hash: this._hash.slice() 1598 }; 1599 }; 1600 SparkMD52.prototype.setState = function(state) { 1601 this._buff = state.buff; 1602 this._length = state.length; 1603 this._hash = state.hash; 1604 return this; 1605 }; 1606 SparkMD52.prototype.destroy = function() { 1607 delete this._hash; 1608 delete this._buff; 1609 delete this._length; 1610 }; 1611 SparkMD52.prototype._finish = function(tail, length) { 1612 var i2 = length, tmp, lo, hi; 1613 tail[i2 >> 2] |= 128 << (i2 % 4 << 3); 1614 if (i2 > 55) { 1615 md5cycle(this._hash, tail); 1616 for (i2 = 0; i2 < 16; i2 += 1) { 1617 tail[i2] = 0; 1618 } 1619 } 1620 tmp = this._length * 8; 1621 tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/); 1622 lo = parseInt(tmp[2], 16); 1623 hi = parseInt(tmp[1], 16) || 0; 1624 tail[14] = lo; 1625 tail[15] = hi; 1626 md5cycle(this._hash, tail); 1627 }; 1628 SparkMD52.hash = function(str, raw) { 1629 return SparkMD52.hashBinary(toUtf8(str), raw); 1630 }; 1631 SparkMD52.hashBinary = function(content, raw) { 1632 var hash3 = md51(content), ret = hex(hash3); 1633 return raw ? hexToBinaryString(ret) : ret; 1634 }; 1635 SparkMD52.ArrayBuffer = function() { 1636 this.reset(); 1637 }; 1638 SparkMD52.ArrayBuffer.prototype.append = function(arr) { 1639 var buff = concatenateArrayBuffers(this._buff.buffer, arr, true), length = buff.length, i2; 1640 this._length += arr.byteLength; 1641 for (i2 = 64; i2 <= length; i2 += 64) { 1642 md5cycle(this._hash, md5blk_array(buff.subarray(i2 - 64, i2))); 1643 } 1644 this._buff = i2 - 64 < length ? new Uint8Array(buff.buffer.slice(i2 - 64)) : new Uint8Array(0); 1645 return this; 1646 }; 1647 SparkMD52.ArrayBuffer.prototype.end = function(raw) { 1648 var buff = this._buff, length = buff.length, tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], i2, ret; 1649 for (i2 = 0; i2 < length; i2 += 1) { 1650 tail[i2 >> 2] |= buff[i2] << (i2 % 4 << 3); 1651 } 1652 this._finish(tail, length); 1653 ret = hex(this._hash); 1654 if (raw) { 1655 ret = hexToBinaryString(ret); 1656 } 1657 this.reset(); 1658 return ret; 1659 }; 1660 SparkMD52.ArrayBuffer.prototype.reset = function() { 1661 this._buff = new Uint8Array(0); 1662 this._length = 0; 1663 this._hash = [1732584193, -271733879, -1732584194, 271733878]; 1664 return this; 1665 }; 1666 SparkMD52.ArrayBuffer.prototype.getState = function() { 1667 var state = SparkMD52.prototype.getState.call(this); 1668 state.buff = arrayBuffer2Utf8Str(state.buff); 1669 return state; 1670 }; 1671 SparkMD52.ArrayBuffer.prototype.setState = function(state) { 1672 state.buff = utf8Str2ArrayBuffer(state.buff, true); 1673 return SparkMD52.prototype.setState.call(this, state); 1674 }; 1675 SparkMD52.ArrayBuffer.prototype.destroy = SparkMD52.prototype.destroy; 1676 SparkMD52.ArrayBuffer.prototype._finish = SparkMD52.prototype._finish; 1677 SparkMD52.ArrayBuffer.hash = function(arr, raw) { 1678 var hash3 = md51_array(new Uint8Array(arr)), ret = hex(hash3); 1679 return raw ? hexToBinaryString(ret) : ret; 1680 }; 1681 return SparkMD52; 1682 }); 1683 })(sparkMd5); 1684 var SparkMD5 = sparkMd5.exports; 1685 const fileSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice; 1686 class FileChecksum { 1687 static create(file, callback) { 1688 const instance = new FileChecksum(file); 1689 instance.create(callback); 1690 } 1691 constructor(file) { 1692 this.file = file; 1693 this.chunkSize = 2097152; 1694 this.chunkCount = Math.ceil(this.file.size / this.chunkSize); 1695 this.chunkIndex = 0; 1696 } 1697 create(callback) { 1698 this.callback = callback; 1699 this.md5Buffer = new SparkMD5.ArrayBuffer(); 1700 this.fileReader = new FileReader(); 1701 this.fileReader.addEventListener("load", (event) => this.fileReaderDidLoad(event)); 1702 this.fileReader.addEventListener("error", (event) => this.fileReaderDidError(event)); 1703 this.readNextChunk(); 1704 } 1705 fileReaderDidLoad(event) { 1706 this.md5Buffer.append(event.target.result); 1707 if (!this.readNextChunk()) { 1708 const binaryDigest = this.md5Buffer.end(true); 1709 const base64digest = btoa(binaryDigest); 1710 this.callback(null, base64digest); 1711 } 1712 } 1713 fileReaderDidError(event) { 1714 this.callback(`Error reading ${this.file.name}`); 1715 } 1716 readNextChunk() { 1717 if (this.chunkIndex < this.chunkCount || this.chunkIndex == 0 && this.chunkCount == 0) { 1718 const start4 = this.chunkIndex * this.chunkSize; 1719 const end2 = Math.min(start4 + this.chunkSize, this.file.size); 1720 const bytes = fileSlice.call(this.file, start4, end2); 1721 this.fileReader.readAsArrayBuffer(bytes); 1722 this.chunkIndex++; 1723 return true; 1724 } else { 1725 return false; 1726 } 1727 } 1728 } 1729 function getMetaValue(name) { 1730 const element = findElement(document.head, `meta[name="${name}"]`); 1731 if (element) { 1732 return element.getAttribute("content"); 1733 } 1734 } 1735 function findElements(root, selector) { 1736 if (typeof root == "string") { 1737 selector = root; 1738 root = document; 1739 } 1740 const elements3 = root.querySelectorAll(selector); 1741 return toArray(elements3); 1742 } 1743 function findElement(root, selector) { 1744 if (typeof root == "string") { 1745 selector = root; 1746 root = document; 1747 } 1748 return root.querySelector(selector); 1749 } 1750 function dispatchEvent2(element, type, eventInit = {}) { 1751 const { disabled } = element; 1752 const { bubbles, cancelable, detail } = eventInit; 1753 const event = document.createEvent("Event"); 1754 event.initEvent(type, bubbles || true, cancelable || true); 1755 event.detail = detail || {}; 1756 try { 1757 element.disabled = false; 1758 element.dispatchEvent(event); 1759 } finally { 1760 element.disabled = disabled; 1761 } 1762 return event; 1763 } 1764 function toArray(value) { 1765 if (Array.isArray(value)) { 1766 return value; 1767 } else if (Array.from) { 1768 return Array.from(value); 1769 } else { 1770 return [].slice.call(value); 1771 } 1772 } 1773 class BlobRecord { 1774 constructor(file, checksum, url) { 1775 this.file = file; 1776 this.attributes = { 1777 filename: file.name, 1778 content_type: file.type || "application/octet-stream", 1779 byte_size: file.size, 1780 checksum 1781 }; 1782 this.xhr = new XMLHttpRequest(); 1783 this.xhr.open("POST", url, true); 1784 this.xhr.responseType = "json"; 1785 this.xhr.setRequestHeader("Content-Type", "application/json"); 1786 this.xhr.setRequestHeader("Accept", "application/json"); 1787 this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 1788 const csrfToken = getMetaValue("csrf-token"); 1789 if (csrfToken != void 0) { 1790 this.xhr.setRequestHeader("X-CSRF-Token", csrfToken); 1791 } 1792 this.xhr.addEventListener("load", (event) => this.requestDidLoad(event)); 1793 this.xhr.addEventListener("error", (event) => this.requestDidError(event)); 1794 } 1795 get status() { 1796 return this.xhr.status; 1797 } 1798 get response() { 1799 const { responseType, response } = this.xhr; 1800 if (responseType == "json") { 1801 return response; 1802 } else { 1803 return JSON.parse(response); 1804 } 1805 } 1806 create(callback) { 1807 this.callback = callback; 1808 this.xhr.send(JSON.stringify({ 1809 blob: this.attributes 1810 })); 1811 } 1812 requestDidLoad(event) { 1813 if (this.status >= 200 && this.status < 300) { 1814 const { response } = this; 1815 const { direct_upload } = response; 1816 delete response.direct_upload; 1817 this.attributes = response; 1818 this.directUploadData = direct_upload; 1819 this.callback(null, this.toJSON()); 1820 } else { 1821 this.requestDidError(event); 1822 } 1823 } 1824 requestDidError(event) { 1825 this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`); 1826 } 1827 toJSON() { 1828 const result = {}; 1829 for (const key in this.attributes) { 1830 result[key] = this.attributes[key]; 1831 } 1832 return result; 1833 } 1834 } 1835 class BlobUpload { 1836 constructor(blob) { 1837 this.blob = blob; 1838 this.file = blob.file; 1839 const { url, headers } = blob.directUploadData; 1840 this.xhr = new XMLHttpRequest(); 1841 this.xhr.open("PUT", url, true); 1842 this.xhr.responseType = "text"; 1843 for (const key in headers) { 1844 this.xhr.setRequestHeader(key, headers[key]); 1845 } 1846 this.xhr.addEventListener("load", (event) => this.requestDidLoad(event)); 1847 this.xhr.addEventListener("error", (event) => this.requestDidError(event)); 1848 } 1849 create(callback) { 1850 this.callback = callback; 1851 this.xhr.send(this.file.slice()); 1852 } 1853 requestDidLoad(event) { 1854 const { status, response } = this.xhr; 1855 if (status >= 200 && status < 300) { 1856 this.callback(null, response); 1857 } else { 1858 this.requestDidError(event); 1859 } 1860 } 1861 requestDidError(event) { 1862 this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`); 1863 } 1864 } 1865 let id = 0; 1866 class DirectUpload2 { 1867 constructor(file, url, delegate) { 1868 this.id = ++id; 1869 this.file = file; 1870 this.url = url; 1871 this.delegate = delegate; 1872 } 1873 create(callback) { 1874 FileChecksum.create(this.file, (error2, checksum) => { 1875 if (error2) { 1876 callback(error2); 1877 return; 1878 } 1879 const blob = new BlobRecord(this.file, checksum, this.url); 1880 notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr); 1881 blob.create((error3) => { 1882 if (error3) { 1883 callback(error3); 1884 } else { 1885 const upload = new BlobUpload(blob); 1886 notify(this.delegate, "directUploadWillStoreFileWithXHR", upload.xhr); 1887 upload.create((error4) => { 1888 if (error4) { 1889 callback(error4); 1890 } else { 1891 callback(null, blob.toJSON()); 1892 } 1893 }); 1894 } 1895 }); 1896 }); 1897 } 1898 } 1899 function notify(object, methodName, ...messages) { 1900 if (object && typeof object[methodName] == "function") { 1901 return object[methodName](...messages); 1902 } 1903 } 1904 class DirectUploadController { 1905 constructor(input, file) { 1906 this.input = input; 1907 this.file = file; 1908 this.directUpload = new DirectUpload2(this.file, this.url, this); 1909 this.dispatch("initialize"); 1910 } 1911 start(callback) { 1912 const hiddenInput = document.createElement("input"); 1913 hiddenInput.type = "hidden"; 1914 hiddenInput.name = this.input.name; 1915 this.input.insertAdjacentElement("beforebegin", hiddenInput); 1916 this.dispatch("start"); 1917 this.directUpload.create((error2, attributes) => { 1918 if (error2) { 1919 hiddenInput.parentNode.removeChild(hiddenInput); 1920 this.dispatchError(error2); 1921 } else { 1922 hiddenInput.value = attributes.signed_id; 1923 } 1924 this.dispatch("end"); 1925 callback(error2); 1926 }); 1927 } 1928 uploadRequestDidProgress(event) { 1929 const progress = event.loaded / event.total * 100; 1930 if (progress) { 1931 this.dispatch("progress", { 1932 progress 1933 }); 1934 } 1935 } 1936 get url() { 1937 return this.input.getAttribute("data-direct-upload-url"); 1938 } 1939 dispatch(name, detail = {}) { 1940 detail.file = this.file; 1941 detail.id = this.directUpload.id; 1942 return dispatchEvent2(this.input, `direct-upload:${name}`, { 1943 detail 1944 }); 1945 } 1946 dispatchError(error2) { 1947 const event = this.dispatch("error", { 1948 error: error2 1949 }); 1950 if (!event.defaultPrevented) { 1951 alert(error2); 1952 } 1953 } 1954 directUploadWillCreateBlobWithXHR(xhr) { 1955 this.dispatch("before-blob-request", { 1956 xhr 1957 }); 1958 } 1959 directUploadWillStoreFileWithXHR(xhr) { 1960 this.dispatch("before-storage-request", { 1961 xhr 1962 }); 1963 xhr.upload.addEventListener("progress", (event) => this.uploadRequestDidProgress(event)); 1964 } 1965 } 1966 const inputSelector = "input[type=file][data-direct-upload-url]:not([disabled])"; 1967 class DirectUploadsController { 1968 constructor(form) { 1969 this.form = form; 1970 this.inputs = findElements(form, inputSelector).filter((input) => input.files.length); 1971 } 1972 start(callback) { 1973 const controllers = this.createDirectUploadControllers(); 1974 const startNextController = () => { 1975 const controller = controllers.shift(); 1976 if (controller) { 1977 controller.start((error2) => { 1978 if (error2) { 1979 callback(error2); 1980 this.dispatch("end"); 1981 } else { 1982 startNextController(); 1983 } 1984 }); 1985 } else { 1986 callback(); 1987 this.dispatch("end"); 1988 } 1989 }; 1990 this.dispatch("start"); 1991 startNextController(); 1992 } 1993 createDirectUploadControllers() { 1994 const controllers = []; 1995 this.inputs.forEach((input) => { 1996 toArray(input.files).forEach((file) => { 1997 const controller = new DirectUploadController(input, file); 1998 controllers.push(controller); 1999 }); 2000 }); 2001 return controllers; 2002 } 2003 dispatch(name, detail = {}) { 2004 return dispatchEvent2(this.form, `direct-uploads:${name}`, { 2005 detail 2006 }); 2007 } 2008 } 2009 const processingAttribute = "data-direct-uploads-processing"; 2010 const submitButtonsByForm = /* @__PURE__ */ new WeakMap(); 2011 let started = false; 2012 function start3() { 2013 if (!started) { 2014 started = true; 2015 document.addEventListener("click", didClick, true); 2016 document.addEventListener("submit", didSubmitForm, true); 2017 document.addEventListener("ajax:before", didSubmitRemoteElement); 2018 } 2019 } 2020 function didClick(event) { 2021 const { target } = event; 2022 if ((target.tagName == "INPUT" || target.tagName == "BUTTON") && target.type == "submit" && target.form) { 2023 submitButtonsByForm.set(target.form, target); 2024 } 2025 } 2026 function didSubmitForm(event) { 2027 handleFormSubmissionEvent(event); 2028 } 2029 function didSubmitRemoteElement(event) { 2030 if (event.target.tagName == "FORM") { 2031 handleFormSubmissionEvent(event); 2032 } 2033 } 2034 function handleFormSubmissionEvent(event) { 2035 const form = event.target; 2036 if (form.hasAttribute(processingAttribute)) { 2037 event.preventDefault(); 2038 return; 2039 } 2040 const controller = new DirectUploadsController(form); 2041 const { inputs } = controller; 2042 if (inputs.length) { 2043 event.preventDefault(); 2044 form.setAttribute(processingAttribute, ""); 2045 inputs.forEach(disable); 2046 controller.start((error2) => { 2047 form.removeAttribute(processingAttribute); 2048 if (error2) { 2049 inputs.forEach(enable); 2050 } else { 2051 submitForm(form); 2052 } 2053 }); 2054 } 2055 } 2056 function submitForm(form) { 2057 let button = submitButtonsByForm.get(form) || findElement(form, "input[type=submit], button[type=submit]"); 2058 if (button) { 2059 const { disabled } = button; 2060 button.disabled = false; 2061 button.focus(); 2062 button.click(); 2063 button.disabled = disabled; 2064 } else { 2065 button = document.createElement("input"); 2066 button.type = "submit"; 2067 button.style.display = "none"; 2068 form.appendChild(button); 2069 button.click(); 2070 form.removeChild(button); 2071 } 2072 submitButtonsByForm.delete(form); 2073 } 2074 function disable(input) { 2075 input.disabled = true; 2076 } 2077 function enable(input) { 2078 input.disabled = false; 2079 } 2080 function autostart() { 2081 if (window.ActiveStorage) { 2082 start3(); 2083 } 2084 } 2085 setTimeout(autostart, 1); 2086 exports3.DirectUpload = DirectUpload2; 2087 exports3.start = start3; 2088 Object.defineProperty(exports3, "__esModule", { 2089 value: true 2090 }); 2091 }); 2092 } 2093 }); 2094 2095
vendor: 26,027 bytes, lines 2095-2664
2095// ../../node_modules/clipboard/dist/clipboard.js 2096 var require_clipboard = __commonJS({ 2097 "../../node_modules/clipboard/dist/clipboard.js"(exports2, module5) { 2098 (function webpackUniversalModuleDefinition(root, factory) { 2099 if (typeof exports2 === "object" && typeof module5 === "object") 2100 module5.exports = factory(); 2101 else if (typeof define === "function" && define.amd) 2102 define([], factory); 2103 else if (typeof exports2 === "object") 2104 exports2["ClipboardJS"] = factory(); 2105 else 2106 root["ClipboardJS"] = factory(); 2107 })(exports2, function() { 2108 return function() { 2109 var __webpack_modules__ = { 2110 686: function(__unused_webpack_module, __webpack_exports__, __webpack_require__2) { 2111 "use strict"; 2112 __webpack_require__2.d(__webpack_exports__, { 2113 "default": function() { 2114 return clipboard; 2115 } 2116 }); 2117 var tiny_emitter = __webpack_require__2(279); 2118 var tiny_emitter_default = /* @__PURE__ */ __webpack_require__2.n(tiny_emitter); 2119 var listen = __webpack_require__2(370); 2120 var listen_default = /* @__PURE__ */ __webpack_require__2.n(listen); 2121 var src_select = __webpack_require__2(817); 2122 var select_default = /* @__PURE__ */ __webpack_require__2.n(src_select); 2123 ; 2124 function command(type) { 2125 try { 2126 return document.execCommand(type); 2127 } catch (err) { 2128 return false; 2129 } 2130 } 2131 ; 2132 var ClipboardActionCut = function ClipboardActionCut2(target) { 2133 var selectedText = select_default()(target); 2134 command("cut"); 2135 return selectedText; 2136 }; 2137 var actions_cut = ClipboardActionCut; 2138 ; 2139 function createFakeElement(value) { 2140 var isRTL = document.documentElement.getAttribute("dir") === "rtl"; 2141 var fakeElement = document.createElement("textarea"); 2142 fakeElement.style.fontSize = "12pt"; 2143 fakeElement.style.border = "0"; 2144 fakeElement.style.padding = "0"; 2145 fakeElement.style.margin = "0"; 2146 fakeElement.style.position = "absolute"; 2147 fakeElement.style[isRTL ? "right" : "left"] = "-9999px"; 2148 var yPosition = window.pageYOffset || document.documentElement.scrollTop; 2149 fakeElement.style.top = "".concat(yPosition, "px"); 2150 fakeElement.setAttribute("readonly", ""); 2151 fakeElement.value = value; 2152 return fakeElement; 2153 } 2154 ; 2155 var ClipboardActionCopy = function ClipboardActionCopy2(target) { 2156 var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { 2157 container: document.body 2158 }; 2159 var selectedText = ""; 2160 if (typeof target === "string") { 2161 var fakeElement = createFakeElement(target); 2162 options2.container.appendChild(fakeElement); 2163 selectedText = select_default()(fakeElement); 2164 command("copy"); 2165 fakeElement.remove(); 2166 } else { 2167 selectedText = select_default()(target); 2168 command("copy"); 2169 } 2170 return selectedText; 2171 }; 2172 var actions_copy = ClipboardActionCopy; 2173 ; 2174 function _typeof(obj) { 2175 "@babel/helpers - typeof"; 2176 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 2177 _typeof = function _typeof2(obj2) { 2178 return typeof obj2; 2179 }; 2180 } else { 2181 _typeof = function _typeof2(obj2) { 2182 return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; 2183 }; 2184 } 2185 return _typeof(obj); 2186 } 2187 var ClipboardActionDefault = function ClipboardActionDefault2() { 2188 var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; 2189 var _options$action = options2.action, action = _options$action === void 0 ? "copy" : _options$action, container = options2.container, target = options2.target, text = options2.text; 2190 if (action !== "copy" && action !== "cut") { 2191 throw new Error('Invalid "action" value, use either "copy" or "cut"'); 2192 } 2193 if (target !== void 0) { 2194 if (target && _typeof(target) === "object" && target.nodeType === 1) { 2195 if (action === "copy" && target.hasAttribute("disabled")) { 2196 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); 2197 } 2198 if (action === "cut" && (target.hasAttribute("readonly") || target.hasAttribute("disabled"))) { 2199 throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`); 2200 } 2201 } else { 2202 throw new Error('Invalid "target" value, use a valid Element'); 2203 } 2204 } 2205 if (text) { 2206 return actions_copy(text, { 2207 container 2208 }); 2209 } 2210 if (target) { 2211 return action === "cut" ? actions_cut(target) : actions_copy(target, { 2212 container 2213 }); 2214 } 2215 }; 2216 var actions_default = ClipboardActionDefault; 2217 ; 2218 function clipboard_typeof(obj) { 2219 "@babel/helpers - typeof"; 2220 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 2221 clipboard_typeof = function _typeof2(obj2) { 2222 return typeof obj2; 2223 }; 2224 } else { 2225 clipboard_typeof = function _typeof2(obj2) { 2226 return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; 2227 }; 2228 } 2229 return clipboard_typeof(obj); 2230 } 2231 function _classCallCheck2(instance, Constructor) { 2232 if (!(instance instanceof Constructor)) { 2233 throw new TypeError("Cannot call a class as a function"); 2234 } 2235 } 2236 function _defineProperties2(target, props) { 2237 for (var i2 = 0; i2 < props.length; i2++) { 2238 var descriptor = props[i2]; 2239 descriptor.enumerable = descriptor.enumerable || false; 2240 descriptor.configurable = true; 2241 if ("value" in descriptor) 2242 descriptor.writable = true; 2243 Object.defineProperty(target, descriptor.key, descriptor); 2244 } 2245 } 2246 function _createClass2(Constructor, protoProps, staticProps) { 2247 if (protoProps) 2248 _defineProperties2(Constructor.prototype, protoProps); 2249 if (staticProps) 2250 _defineProperties2(Constructor, staticProps); 2251 return Constructor; 2252 } 2253 function _inherits2(subClass, superClass) { 2254 if (typeof superClass !== "function" && superClass !== null) { 2255 throw new TypeError("Super expression must either be null or a function"); 2256 } 2257 subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); 2258 if (superClass) 2259 _setPrototypeOf2(subClass, superClass); 2260 } 2261 function _setPrototypeOf2(o2, p) { 2262 _setPrototypeOf2 = Object.setPrototypeOf || function _setPrototypeOf3(o3, p2) { 2263 o3.__proto__ = p2; 2264 return o3; 2265 }; 2266 return _setPrototypeOf2(o2, p); 2267 } 2268 function _createSuper2(Derived) { 2269 var hasNativeReflectConstruct = _isNativeReflectConstruct2(); 2270 return function _createSuperInternal() { 2271 var Super = _getPrototypeOf2(Derived), result; 2272 if (hasNativeReflectConstruct) { 2273 var NewTarget = _getPrototypeOf2(this).constructor; 2274 result = Reflect.construct(Super, arguments, NewTarget); 2275 } else { 2276 result = Super.apply(this, arguments); 2277 } 2278 return _possibleConstructorReturn2(this, result); 2279 }; 2280 } 2281 function _possibleConstructorReturn2(self2, call) { 2282 if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { 2283 return call; 2284 } 2285 return _assertThisInitialized2(self2); 2286 } 2287 function _assertThisInitialized2(self2) { 2288 if (self2 === void 0) { 2289 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 2290 } 2291 return self2; 2292 } 2293 function _isNativeReflectConstruct2() { 2294 if (typeof Reflect === "undefined" || !Reflect.construct) 2295 return false; 2296 if (Reflect.construct.sham) 2297 return false; 2298 if (typeof Proxy === "function") 2299 return true; 2300 try { 2301 Date.prototype.toString.call(Reflect.construct(Date, [], function() { 2302 })); 2303 return true; 2304 } catch (e2) { 2305 return false; 2306 } 2307 } 2308 function _getPrototypeOf2(o2) { 2309 _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf3(o3) { 2310 return o3.__proto__ || Object.getPrototypeOf(o3); 2311 }; 2312 return _getPrototypeOf2(o2); 2313 } 2314 function getAttributeValue(suffix, element) { 2315 var attribute = "data-clipboard-".concat(suffix); 2316 if (!element.hasAttribute(attribute)) { 2317 return; 2318 } 2319 return element.getAttribute(attribute); 2320 } 2321 var Clipboard = /* @__PURE__ */ function(_Emitter) { 2322 _inherits2(Clipboard2, _Emitter); 2323 var _super = _createSuper2(Clipboard2); 2324 function Clipboard2(trigger, options2) { 2325 var _this; 2326 _classCallCheck2(this, Clipboard2); 2327 _this = _super.call(this); 2328 _this.resolveOptions(options2); 2329 _this.listenClick(trigger); 2330 return _this; 2331 } 2332 _createClass2(Clipboard2, [{ 2333 key: "resolveOptions", 2334 value: function resolveOptions() { 2335 var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; 2336 this.action = typeof options2.action === "function" ? options2.action : this.defaultAction; 2337 this.target = typeof options2.target === "function" ? options2.target : this.defaultTarget; 2338 this.text = typeof options2.text === "function" ? options2.text : this.defaultText; 2339 this.container = clipboard_typeof(options2.container) === "object" ? options2.container : document.body; 2340 } 2341 }, { 2342 key: "listenClick", 2343 value: function listenClick(trigger) { 2344 var _this2 = this; 2345 this.listener = listen_default()(trigger, "click", function(e2) { 2346 return _this2.onClick(e2); 2347 }); 2348 } 2349 }, { 2350 key: "onClick", 2351 value: function onClick(e2) { 2352 var trigger = e2.delegateTarget || e2.currentTarget; 2353 var action = this.action(trigger) || "copy"; 2354 var text = actions_default({ 2355 action, 2356 container: this.container, 2357 target: this.target(trigger), 2358 text: this.text(trigger) 2359 }); 2360 this.emit(text ? "success" : "error", { 2361 action, 2362 text, 2363 trigger, 2364 clearSelection: function clearSelection() { 2365 if (trigger) { 2366 trigger.focus(); 2367 } 2368 document.activeElement.blur(); 2369 window.getSelection().removeAllRanges(); 2370 } 2371 }); 2372 } 2373 }, { 2374 key: "defaultAction", 2375 value: function defaultAction(trigger) { 2376 return getAttributeValue("action", trigger); 2377 } 2378 }, { 2379 key: "defaultTarget", 2380 value: function defaultTarget(trigger) { 2381 var selector = getAttributeValue("target", trigger); 2382 if (selector) { 2383 return document.querySelector(selector); 2384 } 2385 } 2386 }, { 2387 key: "defaultText", 2388 value: function defaultText(trigger) { 2389 return getAttributeValue("text", trigger); 2390 } 2391 }, { 2392 key: "destroy", 2393 value: function destroy2() { 2394 this.listener.destroy(); 2395 } 2396 }], [{ 2397 key: "copy", 2398 value: function copy(target) { 2399 var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { 2400 container: document.body 2401 }; 2402 return actions_copy(target, options2); 2403 } 2404 }, { 2405 key: "cut", 2406 value: function cut(target) { 2407 return actions_cut(target); 2408 } 2409 }, { 2410 key: "isSupported", 2411 value: function isSupported() { 2412 var action = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ["copy", "cut"]; 2413 var actions = typeof action === "string" ? [action] : action; 2414 var support = !!document.queryCommandSupported; 2415 actions.forEach(function(action2) { 2416 support = support && !!document.queryCommandSupported(action2); 2417 }); 2418 return support; 2419 } 2420 }]); 2421 return Clipboard2; 2422 }(tiny_emitter_default()); 2423 var clipboard = Clipboard; 2424 }, 2425 828: function(module6) { 2426 var DOCUMENT_NODE_TYPE = 9; 2427 if (typeof Element !== "undefined" && !Element.prototype.matches) { 2428 var proto = Element.prototype; 2429 proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; 2430 } 2431 function closest(element, selector) { 2432 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { 2433 if (typeof element.matches === "function" && element.matches(selector)) { 2434 return element; 2435 } 2436 element = element.parentNode; 2437 } 2438 } 2439 module6.exports = closest; 2440 }, 2441 438: function(module6, __unused_webpack_exports, __webpack_require__2) { 2442 var closest = __webpack_require__2(828); 2443 function _delegate(element, selector, type, callback, useCapture) { 2444 var listenerFn = listener.apply(this, arguments); 2445 element.addEventListener(type, listenerFn, useCapture); 2446 return { 2447 destroy: function() { 2448 element.removeEventListener(type, listenerFn, useCapture); 2449 } 2450 }; 2451 } 2452 function delegate(elements3, selector, type, callback, useCapture) { 2453 if (typeof elements3.addEventListener === "function") { 2454 return _delegate.apply(null, arguments); 2455 } 2456 if (typeof type === "function") { 2457 return _delegate.bind(null, document).apply(null, arguments); 2458 } 2459 if (typeof elements3 === "string") { 2460 elements3 = document.querySelectorAll(elements3); 2461 } 2462 return Array.prototype.map.call(elements3, function(element) { 2463 return _delegate(element, selector, type, callback, useCapture); 2464 }); 2465 } 2466 function listener(element, selector, type, callback) { 2467 return function(e2) { 2468 e2.delegateTarget = closest(e2.target, selector); 2469 if (e2.delegateTarget) { 2470 callback.call(element, e2); 2471 } 2472 }; 2473 } 2474 module6.exports = delegate; 2475 }, 2476 879: function(__unused_webpack_module, exports3) { 2477 exports3.node = function(value) { 2478 return value !== void 0 && value instanceof HTMLElement && value.nodeType === 1; 2479 }; 2480 exports3.nodeList = function(value) { 2481 var type = Object.prototype.toString.call(value); 2482 return value !== void 0 && (type === "[object NodeList]" || type === "[object HTMLCollection]") && "length" in value && (value.length === 0 || exports3.node(value[0])); 2483 }; 2484 exports3.string = function(value) { 2485 return typeof value === "string" || value instanceof String; 2486 }; 2487 exports3.fn = function(value) { 2488 var type = Object.prototype.toString.call(value); 2489 return type === "[object Function]"; 2490 }; 2491 }, 2492 370: function(module6, __unused_webpack_exports, __webpack_require__2) { 2493 var is = __webpack_require__2(879); 2494 var delegate = __webpack_require__2(438); 2495 function listen(target, type, callback) { 2496 if (!target && !type && !callback) { 2497 throw new Error("Missing required arguments"); 2498 } 2499 if (!is.string(type)) { 2500 throw new TypeError("Second argument must be a String"); 2501 } 2502 if (!is.fn(callback)) { 2503 throw new TypeError("Third argument must be a Function"); 2504 } 2505 if (is.node(target)) { 2506 return listenNode(target, type, callback); 2507 } else if (is.nodeList(target)) { 2508 return listenNodeList(target, type, callback); 2509 } else if (is.string(target)) { 2510 return listenSelector(target, type, callback); 2511 } else { 2512 throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList"); 2513 } 2514 } 2515 function listenNode(node, type, callback) { 2516 node.addEventListener(type, callback); 2517 return { 2518 destroy: function() { 2519 node.removeEventListener(type, callback); 2520 } 2521 }; 2522 } 2523 function listenNodeList(nodeList, type, callback) { 2524 Array.prototype.forEach.call(nodeList, function(node) { 2525 node.addEventListener(type, callback); 2526 }); 2527 return { 2528 destroy: function() { 2529 Array.prototype.forEach.call(nodeList, function(node) { 2530 node.removeEventListener(type, callback); 2531 }); 2532 } 2533 }; 2534 } 2535 function listenSelector(selector, type, callback) { 2536 return delegate(document.body, selector, type, callback); 2537 } 2538 module6.exports = listen; 2539 }, 2540 817: function(module6) { 2541 function select(element) { 2542 var selectedText; 2543 if (element.nodeName === "SELECT") { 2544 element.focus(); 2545 selectedText = element.value; 2546 } else if (element.nodeName === "INPUT" || element.nodeName === "TEXTAREA") { 2547 var isReadOnly = element.hasAttribute("readonly"); 2548 if (!isReadOnly) { 2549 element.setAttribute("readonly", ""); 2550 } 2551 element.select(); 2552 element.setSelectionRange(0, element.value.length); 2553 if (!isReadOnly) { 2554 element.removeAttribute("readonly"); 2555 } 2556 selectedText = element.value; 2557 } else { 2558 if (element.hasAttribute("contenteditable")) { 2559 element.focus(); 2560 } 2561 var selection = window.getSelection(); 2562 var range = document.createRange(); 2563 range.selectNodeContents(element); 2564 selection.removeAllRanges(); 2565 selection.addRange(range); 2566 selectedText = selection.toString(); 2567 } 2568 return selectedText; 2569 } 2570 module6.exports = select; 2571 }, 2572 279: function(module6) { 2573 function E() { 2574 } 2575 E.prototype = { 2576 on: function(name, callback, ctx) { 2577 var e2 = this.e || (this.e = {}); 2578 (e2[name] || (e2[name] = [])).push({ 2579 fn: callback, 2580 ctx 2581 }); 2582 return this; 2583 }, 2584 once: function(name, callback, ctx) { 2585 var self2 = this; 2586 function listener() { 2587 self2.off(name, listener); 2588 callback.apply(ctx, arguments); 2589 } 2590 ; 2591 listener._ = callback; 2592 return this.on(name, listener, ctx); 2593 }, 2594 emit: function(name) { 2595 var data = [].slice.call(arguments, 1); 2596 var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); 2597 var i2 = 0; 2598 var len = evtArr.length; 2599 for (i2; i2 < len; i2++) { 2600 evtArr[i2].fn.apply(evtArr[i2].ctx, data); 2601 } 2602 return this; 2603 }, 2604 off: function(name, callback) { 2605 var e2 = this.e || (this.e = {}); 2606 var evts = e2[name]; 2607 var liveEvents = []; 2608 if (evts && callback) { 2609 for (var i2 = 0, len = evts.length; i2 < len; i2++) { 2610 if (evts[i2].fn !== callback && evts[i2].fn._ !== callback) 2611 liveEvents.push(evts[i2]); 2612 } 2613 } 2614 liveEvents.length ? e2[name] = liveEvents : delete e2[name]; 2615 return this; 2616 } 2617 }; 2618 module6.exports = E; 2619 module6.exports.TinyEmitter = E; 2620 } 2621 }; 2622 var __webpack_module_cache__ = {}; 2623 function __webpack_require__(moduleId) { 2624 if (__webpack_module_cache__[moduleId]) { 2625 return __webpack_module_cache__[moduleId].exports; 2626 } 2627 var module6 = __webpack_module_cache__[moduleId] = { 2628 exports: {} 2629 }; 2630 __webpack_modules__[moduleId](module6, module6.exports, __webpack_require__); 2631 return module6.exports; 2632 } 2633 !function() { 2634 __webpack_require__.n = function(module6) { 2635 var getter = module6 && module6.__esModule ? function() { 2636 return module6["default"]; 2637 } : function() { 2638 return module6; 2639 }; 2640 __webpack_require__.d(getter, { a: getter }); 2641 return getter; 2642 }; 2643 }(); 2644 !function() { 2645 __webpack_require__.d = function(exports3, definition) { 2646 for (var key in definition) { 2647 if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports3, key)) { 2648 Object.defineProperty(exports3, key, { enumerable: true, get: definition[key] }); 2649 } 2650 } 2651 }; 2652 }(); 2653 !function() { 2654 __webpack_require__.o = function(obj, prop) { 2655 return Object.prototype.hasOwnProperty.call(obj, prop); 2656 }; 2657 }(); 2658 return __webpack_require__(686); 2659 }().default; 2660 }); 2661 } 2662 }); 2663 2664
vendor: 44,866 bytes, lines 2664-3273
2664// ../../node_modules/tributejs/dist/tribute.min.js 2665 var require_tribute_min = __commonJS({ 2666 "../../node_modules/tributejs/dist/tribute.min.js"(exports2, module5) { 2667 !function(e2, t) { 2668 typeof exports2 == "object" && typeof module5 != "undefined" ? module5.exports = t() : typeof define == "function" && define.amd ? define(t) : (e2 = e2 || self).Tribute = t(); 2669 }(exports2, function() { 2670 "use strict"; 2671 function e2(e3, t2) { 2672 if (!(e3 instanceof t2)) 2673 throw new TypeError("Cannot call a class as a function"); 2674 } 2675 function t(e3, t2) { 2676 for (var n3 = 0; n3 < t2.length; n3++) { 2677 var i3 = t2[n3]; 2678 i3.enumerable = i3.enumerable || false, i3.configurable = true, "value" in i3 && (i3.writable = true), Object.defineProperty(e3, i3.key, i3); 2679 } 2680 } 2681 function n2(e3, n3, i3) { 2682 return n3 && t(e3.prototype, n3), i3 && t(e3, i3), e3; 2683 } 2684 function i2(e3, t2) { 2685 return function(e4) { 2686 if (Array.isArray(e4)) 2687 return e4; 2688 }(e3) || function(e4, t3) { 2689 if (!(Symbol.iterator in Object(e4) || Object.prototype.toString.call(e4) === "[object Arguments]")) 2690 return; 2691 var n3 = [], i3 = true, r4 = false, o3 = void 0; 2692 try { 2693 for (var u2, l3 = e4[Symbol.iterator](); !(i3 = (u2 = l3.next()).done) && (n3.push(u2.value), !t3 || n3.length !== t3); i3 = true) 2694 ; 2695 } catch (e5) { 2696 r4 = true, o3 = e5; 2697 } finally { 2698 try { 2699 i3 || l3.return == null || l3.return(); 2700 } finally { 2701 if (r4) 2702 throw o3; 2703 } 2704 } 2705 return n3; 2706 }(e3, t2) || function() { 2707 throw new TypeError("Invalid attempt to destructure non-iterable instance"); 2708 }(); 2709 } 2710 if (Array.prototype.find || (Array.prototype.find = function(e3) { 2711 if (this === null) 2712 throw new TypeError("Array.prototype.find called on null or undefined"); 2713 if (typeof e3 != "function") 2714 throw new TypeError("predicate must be a function"); 2715 for (var t2, n3 = Object(this), i3 = n3.length >>> 0, r4 = arguments[1], o3 = 0; o3 < i3; o3++) 2716 if (t2 = n3[o3], e3.call(r4, t2, o3, n3)) 2717 return t2; 2718 }), window && typeof window.CustomEvent != "function") { 2719 var r3 = function(e3, t2) { 2720 t2 = t2 || { bubbles: false, cancelable: false, detail: void 0 }; 2721 var n3 = document.createEvent("CustomEvent"); 2722 return n3.initCustomEvent(e3, t2.bubbles, t2.cancelable, t2.detail), n3; 2723 }; 2724 window.Event !== void 0 && (r3.prototype = window.Event.prototype), window.CustomEvent = r3; 2725 } 2726 var o2 = function() { 2727 function t2(n3) { 2728 e2(this, t2), this.tribute = n3, this.tribute.events = this; 2729 } 2730 return n2(t2, [{ key: "bind", value: function(e3) { 2731 e3.boundKeydown = this.keydown.bind(e3, this), e3.boundKeyup = this.keyup.bind(e3, this), e3.boundInput = this.input.bind(e3, this), e3.addEventListener("keydown", e3.boundKeydown, false), e3.addEventListener("keyup", e3.boundKeyup, false), e3.addEventListener("input", e3.boundInput, false); 2732 } }, { key: "unbind", value: function(e3) { 2733 e3.removeEventListener("keydown", e3.boundKeydown, false), e3.removeEventListener("keyup", e3.boundKeyup, false), e3.removeEventListener("input", e3.boundInput, false), delete e3.boundKeydown, delete e3.boundKeyup, delete e3.boundInput; 2734 } }, { key: "keydown", value: function(e3, n3) { 2735 e3.shouldDeactivate(n3) && (e3.tribute.isActive = false, e3.tribute.hideMenu()); 2736 var i3 = this; 2737 e3.commandEvent = false, t2.keys().forEach(function(t3) { 2738 t3.key === n3.keyCode && (e3.commandEvent = true, e3.callbacks()[t3.value.toLowerCase()](n3, i3)); 2739 }); 2740 } }, { key: "input", value: function(e3, t3) { 2741 e3.inputEvent = true, e3.keyup.call(this, e3, t3); 2742 } }, { key: "click", value: function(e3, t3) { 2743 var n3 = e3.tribute; 2744 if (n3.menu && n3.menu.contains(t3.target)) { 2745 var i3 = t3.target; 2746 for (t3.preventDefault(), t3.stopPropagation(); i3.nodeName.toLowerCase() !== "li"; ) 2747 if (!(i3 = i3.parentNode) || i3 === n3.menu) 2748 throw new Error("cannot find the <li> container for the click"); 2749 n3.selectItemAtIndex(i3.getAttribute("data-index"), t3), n3.hideMenu(); 2750 } else 2751 n3.current.element && !n3.current.externalTrigger && (n3.current.externalTrigger = false, setTimeout(function() { 2752 return n3.hideMenu(); 2753 })); 2754 } }, { key: "keyup", value: function(e3, t3) { 2755 if (e3.inputEvent && (e3.inputEvent = false), e3.updateSelection(this), t3.keyCode !== 27) { 2756 if (!e3.tribute.allowSpaces && e3.tribute.hasTrailingSpace) 2757 return e3.tribute.hasTrailingSpace = false, e3.commandEvent = true, void e3.callbacks().space(t3, this); 2758 if (!e3.tribute.isActive) 2759 if (e3.tribute.autocompleteMode) 2760 e3.callbacks().triggerChar(t3, this, ""); 2761 else { 2762 var n3 = e3.getKeyCode(e3, this, t3); 2763 if (isNaN(n3) || !n3) 2764 return; 2765 var i3 = e3.tribute.triggers().find(function(e4) { 2766 return e4.charCodeAt(0) === n3; 2767 }); 2768 i3 !== void 0 && e3.callbacks().triggerChar(t3, this, i3); 2769 } 2770 e3.tribute.current.mentionText.length < e3.tribute.current.collection.menuShowMinLength || ((e3.tribute.current.trigger || e3.tribute.autocompleteMode) && e3.commandEvent === false || e3.tribute.isActive && t3.keyCode === 8) && e3.tribute.showMenuFor(this, true); 2771 } 2772 } }, { key: "shouldDeactivate", value: function(e3) { 2773 if (!this.tribute.isActive) 2774 return false; 2775 if (this.tribute.current.mentionText.length === 0) { 2776 var n3 = false; 2777 return t2.keys().forEach(function(t3) { 2778 e3.keyCode === t3.key && (n3 = true); 2779 }), !n3; 2780 } 2781 return false; 2782 } }, { key: "getKeyCode", value: function(e3, t3, n3) { 2783 var i3 = e3.tribute, r4 = i3.range.getTriggerInfo(false, i3.hasTrailingSpace, true, i3.allowSpaces, i3.autocompleteMode); 2784 return !!r4 && r4.mentionTriggerChar.charCodeAt(0); 2785 } }, { key: "updateSelection", value: function(e3) { 2786 this.tribute.current.element = e3; 2787 var t3 = this.tribute.range.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode); 2788 t3 && (this.tribute.current.selectedPath = t3.mentionSelectedPath, this.tribute.current.mentionText = t3.mentionText, this.tribute.current.selectedOffset = t3.mentionSelectedOffset); 2789 } }, { key: "callbacks", value: function() { 2790 var e3 = this; 2791 return { triggerChar: function(t3, n3, i3) { 2792 var r4 = e3.tribute; 2793 r4.current.trigger = i3; 2794 var o3 = r4.collection.find(function(e4) { 2795 return e4.trigger === i3; 2796 }); 2797 r4.current.collection = o3, r4.current.mentionText.length >= r4.current.collection.menuShowMinLength && r4.inputEvent && r4.showMenuFor(n3, true); 2798 }, enter: function(t3, n3) { 2799 e3.tribute.isActive && e3.tribute.current.filteredItems && (t3.preventDefault(), t3.stopPropagation(), setTimeout(function() { 2800 e3.tribute.selectItemAtIndex(e3.tribute.menuSelected, t3), e3.tribute.hideMenu(); 2801 }, 0)); 2802 }, escape: function(t3, n3) { 2803 e3.tribute.isActive && (t3.preventDefault(), t3.stopPropagation(), e3.tribute.isActive = false, e3.tribute.hideMenu()); 2804 }, tab: function(t3, n3) { 2805 e3.callbacks().enter(t3, n3); 2806 }, space: function(t3, n3) { 2807 e3.tribute.isActive && (e3.tribute.spaceSelectsMatch ? e3.callbacks().enter(t3, n3) : e3.tribute.allowSpaces || (t3.stopPropagation(), setTimeout(function() { 2808 e3.tribute.hideMenu(), e3.tribute.isActive = false; 2809 }, 0))); 2810 }, up: function(t3, n3) { 2811 if (e3.tribute.isActive && e3.tribute.current.filteredItems) { 2812 t3.preventDefault(), t3.stopPropagation(); 2813 var i3 = e3.tribute.current.filteredItems.length, r4 = e3.tribute.menuSelected; 2814 i3 > r4 && r4 > 0 ? (e3.tribute.menuSelected--, e3.setActiveLi()) : r4 === 0 && (e3.tribute.menuSelected = i3 - 1, e3.setActiveLi(), e3.tribute.menu.scrollTop = e3.tribute.menu.scrollHeight); 2815 } 2816 }, down: function(t3, n3) { 2817 if (e3.tribute.isActive && e3.tribute.current.filteredItems) { 2818 t3.preventDefault(), t3.stopPropagation(); 2819 var i3 = e3.tribute.current.filteredItems.length - 1, r4 = e3.tribute.menuSelected; 2820 i3 > r4 ? (e3.tribute.menuSelected++, e3.setActiveLi()) : i3 === r4 && (e3.tribute.menuSelected = 0, e3.setActiveLi(), e3.tribute.menu.scrollTop = 0); 2821 } 2822 }, delete: function(t3, n3) { 2823 e3.tribute.isActive && e3.tribute.current.mentionText.length < 1 ? e3.tribute.hideMenu() : e3.tribute.isActive && e3.tribute.showMenuFor(n3); 2824 } }; 2825 } }, { key: "setActiveLi", value: function(e3) { 2826 var t3 = this.tribute.menu.querySelectorAll("li"), n3 = t3.length >>> 0; 2827 e3 && (this.tribute.menuSelected = parseInt(e3)); 2828 for (var i3 = 0; i3 < n3; i3++) { 2829 var r4 = t3[i3]; 2830 if (i3 === this.tribute.menuSelected) { 2831 r4.classList.add(this.tribute.current.collection.selectClass); 2832 var o3 = r4.getBoundingClientRect(), u2 = this.tribute.menu.getBoundingClientRect(); 2833 if (o3.bottom > u2.bottom) { 2834 var l3 = o3.bottom - u2.bottom; 2835 this.tribute.menu.scrollTop += l3; 2836 } else if (o3.top < u2.top) { 2837 var s3 = u2.top - o3.top; 2838 this.tribute.menu.scrollTop -= s3; 2839 } 2840 } else 2841 r4.classList.remove(this.tribute.current.collection.selectClass); 2842 } 2843 } }, { key: "getFullHeight", value: function(e3, t3) { 2844 var n3 = e3.getBoundingClientRect().height; 2845 if (t3) { 2846 var i3 = e3.currentStyle || window.getComputedStyle(e3); 2847 return n3 + parseFloat(i3.marginTop) + parseFloat(i3.marginBottom); 2848 } 2849 return n3; 2850 } }], [{ key: "keys", value: function() { 2851 return [{ key: 9, value: "TAB" }, { key: 8, value: "DELETE" }, { key: 13, value: "ENTER" }, { key: 27, value: "ESCAPE" }, { key: 32, value: "SPACE" }, { key: 38, value: "UP" }, { key: 40, value: "DOWN" }]; 2852 } }]), t2; 2853 }(), u = function() { 2854 function t2(n3) { 2855 e2(this, t2), this.tribute = n3, this.tribute.menuEvents = this, this.menu = this.tribute.menu; 2856 } 2857 return n2(t2, [{ key: "bind", value: function(e3) { 2858 var t3 = this; 2859 this.menuClickEvent = this.tribute.events.click.bind(null, this), this.menuContainerScrollEvent = this.debounce(function() { 2860 t3.tribute.isActive && t3.tribute.showMenuFor(t3.tribute.current.element, false); 2861 }, 300, false), this.windowResizeEvent = this.debounce(function() { 2862 t3.tribute.isActive && t3.tribute.range.positionMenuAtCaret(true); 2863 }, 300, false), this.tribute.range.getDocument().addEventListener("MSPointerDown", this.menuClickEvent, false), this.tribute.range.getDocument().addEventListener("mousedown", this.menuClickEvent, false), window.addEventListener("resize", this.windowResizeEvent), this.menuContainer ? this.menuContainer.addEventListener("scroll", this.menuContainerScrollEvent, false) : window.addEventListener("scroll", this.menuContainerScrollEvent); 2864 } }, { key: "unbind", value: function(e3) { 2865 this.tribute.range.getDocument().removeEventListener("mousedown", this.menuClickEvent, false), this.tribute.range.getDocument().removeEventListener("MSPointerDown", this.menuClickEvent, false), window.removeEventListener("resize", this.windowResizeEvent), this.menuContainer ? this.menuContainer.removeEventListener("scroll", this.menuContainerScrollEvent, false) : window.removeEventListener("scroll", this.menuContainerScrollEvent); 2866 } }, { key: "debounce", value: function(e3, t3, n3) { 2867 var i3, r4 = arguments, o3 = this; 2868 return function() { 2869 var u2 = o3, l3 = r4, s3 = n3 && !i3; 2870 clearTimeout(i3), i3 = setTimeout(function() { 2871 i3 = null, n3 || e3.apply(u2, l3); 2872 }, t3), s3 && e3.apply(u2, l3); 2873 }; 2874 } }]), t2; 2875 }(), l2 = function() { 2876 function t2(n3) { 2877 e2(this, t2), this.tribute = n3, this.tribute.range = this; 2878 } 2879 return n2(t2, [{ key: "getDocument", value: function() { 2880 var e3; 2881 return this.tribute.current.collection && (e3 = this.tribute.current.collection.iframe), e3 ? e3.contentWindow.document : document; 2882 } }, { key: "positionMenuAtCaret", value: function(e3) { 2883 var t3, n3 = this, i3 = this.tribute.current, r4 = this.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode); 2884 if (r4 !== void 0) { 2885 if (!this.tribute.positionMenu) 2886 return void (this.tribute.menu.style.cssText = "display: block;"); 2887 t3 = this.isContentEditable(i3.element) ? this.getContentEditableCaretPosition(r4.mentionPosition) : this.getTextAreaOrInputUnderlinePosition(this.tribute.current.element, r4.mentionPosition), this.tribute.menu.style.cssText = "top: ".concat(t3.top, "px;\n left: ").concat(t3.left, "px;\n right: ").concat(t3.right, "px;\n bottom: ").concat(t3.bottom, "px;\n position: absolute;\n display: block;"), t3.left === "auto" && (this.tribute.menu.style.left = "auto"), t3.top === "auto" && (this.tribute.menu.style.top = "auto"), e3 && this.scrollIntoView(), window.setTimeout(function() { 2888 var i4 = { width: n3.tribute.menu.offsetWidth, height: n3.tribute.menu.offsetHeight }, r5 = n3.isMenuOffScreen(t3, i4), o3 = window.innerWidth > i4.width && (r5.left || r5.right), u2 = window.innerHeight > i4.height && (r5.top || r5.bottom); 2889 (o3 || u2) && (n3.tribute.menu.style.cssText = "display: none", n3.positionMenuAtCaret(e3)); 2890 }, 0); 2891 } else 2892 this.tribute.menu.style.cssText = "display: none"; 2893 } }, { key: "selectElement", value: function(e3, t3, n3) { 2894 var i3, r4 = e3; 2895 if (t3) 2896 for (var o3 = 0; o3 < t3.length; o3++) { 2897 if ((r4 = r4.childNodes[t3[o3]]) === void 0) 2898 return; 2899 for (; r4.length < n3; ) 2900 n3 -= r4.length, r4 = r4.nextSibling; 2901 r4.childNodes.length !== 0 || r4.length || (r4 = r4.previousSibling); 2902 } 2903 var u2 = this.getWindowSelection(); 2904 (i3 = this.getDocument().createRange()).setStart(r4, n3), i3.setEnd(r4, n3), i3.collapse(true); 2905 try { 2906 u2.removeAllRanges(); 2907 } catch (e4) { 2908 } 2909 u2.addRange(i3), e3.focus(); 2910 } }, { key: "replaceTriggerText", value: function(e3, t3, n3, i3, r4) { 2911 var o3 = this.getTriggerInfo(true, n3, t3, this.tribute.allowSpaces, this.tribute.autocompleteMode); 2912 if (o3 !== void 0) { 2913 var u2 = this.tribute.current, l3 = new CustomEvent("tribute-replaced", { detail: { item: r4, instance: u2, context: o3, event: i3 } }); 2914 if (this.isContentEditable(u2.element)) { 2915 e3 += typeof this.tribute.replaceTextSuffix == "string" ? this.tribute.replaceTextSuffix : "\xA0"; 2916 var s3 = o3.mentionPosition + o3.mentionText.length; 2917 this.tribute.autocompleteMode || (s3 += o3.mentionTriggerChar.length), this.pasteHtml(e3, o3.mentionPosition, s3); 2918 } else { 2919 var a2 = this.tribute.current.element, c = typeof this.tribute.replaceTextSuffix == "string" ? this.tribute.replaceTextSuffix : " "; 2920 e3 += c; 2921 var h2 = o3.mentionPosition, d = o3.mentionPosition + o3.mentionText.length + c.length; 2922 this.tribute.autocompleteMode || (d += o3.mentionTriggerChar.length - 1), a2.value = a2.value.substring(0, h2) + e3 + a2.value.substring(d, a2.value.length), a2.selectionStart = h2 + e3.length, a2.selectionEnd = h2 + e3.length; 2923 } 2924 u2.element.dispatchEvent(new CustomEvent("input", { bubbles: true })), u2.element.dispatchEvent(l3); 2925 } 2926 } }, { key: "pasteHtml", value: function(e3, t3, n3) { 2927 var i3, r4; 2928 r4 = this.getWindowSelection(), (i3 = this.getDocument().createRange()).setStart(r4.anchorNode, t3), i3.setEnd(r4.anchorNode, n3), i3.deleteContents(); 2929 var o3 = this.getDocument().createElement("div"); 2930 o3.innerHTML = e3; 2931 for (var u2, l3, s3 = this.getDocument().createDocumentFragment(); u2 = o3.firstChild; ) 2932 l3 = s3.appendChild(u2); 2933 i3.insertNode(s3), l3 && ((i3 = i3.cloneRange()).setStartAfter(l3), i3.collapse(true), r4.removeAllRanges(), r4.addRange(i3)); 2934 } }, { key: "getWindowSelection", value: function() { 2935 return this.tribute.collection.iframe ? this.tribute.collection.iframe.contentWindow.getSelection() : window.getSelection(); 2936 } }, { key: "getNodePositionInParent", value: function(e3) { 2937 if (e3.parentNode === null) 2938 return 0; 2939 for (var t3 = 0; t3 < e3.parentNode.childNodes.length; t3++) { 2940 if (e3.parentNode.childNodes[t3] === e3) 2941 return t3; 2942 } 2943 } }, { key: "getContentEditableSelectedPath", value: function(e3) { 2944 var t3 = this.getWindowSelection(), n3 = t3.anchorNode, i3 = []; 2945 if (n3 != null) { 2946 for (var r4, o3 = n3.contentEditable; n3 !== null && o3 !== "true"; ) 2947 r4 = this.getNodePositionInParent(n3), i3.push(r4), (n3 = n3.parentNode) !== null && (o3 = n3.contentEditable); 2948 return i3.reverse(), { selected: n3, path: i3, offset: t3.getRangeAt(0).startOffset }; 2949 } 2950 } }, { key: "getTextPrecedingCurrentSelection", value: function() { 2951 var e3 = this.tribute.current, t3 = ""; 2952 if (this.isContentEditable(e3.element)) { 2953 var n3 = this.getWindowSelection().anchorNode; 2954 if (n3 != null) { 2955 var i3 = n3.textContent, r4 = this.getWindowSelection().getRangeAt(0).startOffset; 2956 i3 && r4 >= 0 && (t3 = i3.substring(0, r4)); 2957 } 2958 } else { 2959 var o3 = this.tribute.current.element; 2960 if (o3) { 2961 var u2 = o3.selectionStart; 2962 o3.value && u2 >= 0 && (t3 = o3.value.substring(0, u2)); 2963 } 2964 } 2965 return t3; 2966 } }, { key: "getLastWordInText", value: function(e3) { 2967 var t3 = (e3 = e3.replace(/\u00A0/g, " ")).split(/\s+/); 2968 return t3[t3.length - 1].trim(); 2969 } }, { key: "getTriggerInfo", value: function(e3, t3, n3, i3, r4) { 2970 var o3, u2, l3, s3 = this, a2 = this.tribute.current; 2971 if (this.isContentEditable(a2.element)) { 2972 var c = this.getContentEditableSelectedPath(a2); 2973 c && (o3 = c.selected, u2 = c.path, l3 = c.offset); 2974 } else 2975 o3 = this.tribute.current.element; 2976 var h2 = this.getTextPrecedingCurrentSelection(), d = this.getLastWordInText(h2); 2977 if (r4) 2978 return { mentionPosition: h2.length - d.length, mentionText: d, mentionSelectedElement: o3, mentionSelectedPath: u2, mentionSelectedOffset: l3 }; 2979 if (h2 != null) { 2980 var f, m = -1; 2981 if (this.tribute.collection.forEach(function(e4) { 2982 var t4 = e4.trigger, i4 = e4.requireLeadingSpace ? s3.lastIndexWithLeadingSpace(h2, t4) : h2.lastIndexOf(t4); 2983 i4 > m && (m = i4, f = t4, n3 = e4.requireLeadingSpace); 2984 }), m >= 0 && (m === 0 || !n3 || /[\xA0\s]/g.test(h2.substring(m - 1, m)))) { 2985 var p = h2.substring(m + f.length, h2.length); 2986 f = h2.substring(m, m + f.length); 2987 var v = p.substring(0, 1), g = p.length > 0 && (v === " " || v === "\xA0"); 2988 t3 && (p = p.trim()); 2989 var b = i3 ? /[^\S ]/g : /[\xA0\s]/g; 2990 if (this.tribute.hasTrailingSpace = b.test(p), !g && (e3 || !b.test(p))) 2991 return { mentionPosition: m, mentionText: p, mentionSelectedElement: o3, mentionSelectedPath: u2, mentionSelectedOffset: l3, mentionTriggerChar: f }; 2992 } 2993 } 2994 } }, { key: "lastIndexWithLeadingSpace", value: function(e3, t3) { 2995 for (var n3 = e3.split("").reverse().join(""), i3 = -1, r4 = 0, o3 = e3.length; r4 < o3; r4++) { 2996 for (var u2 = r4 === e3.length - 1, l3 = /\s/.test(n3[r4 + 1]), s3 = true, a2 = t3.length - 1; a2 >= 0; a2--) 2997 if (t3[a2] !== n3[r4 - a2]) { 2998 s3 = false; 2999 break; 3000 } 3001 if (s3 && (u2 || l3)) { 3002 i3 = e3.length - 1 - r4; 3003 break; 3004 } 3005 } 3006 return i3; 3007 } }, { key: "isContentEditable", value: function(e3) { 3008 return e3.nodeName !== "INPUT" && e3.nodeName !== "TEXTAREA"; 3009 } }, { key: "isMenuOffScreen", value: function(e3, t3) { 3010 var n3 = window.innerWidth, i3 = window.innerHeight, r4 = document.documentElement, o3 = (window.pageXOffset || r4.scrollLeft) - (r4.clientLeft || 0), u2 = (window.pageYOffset || r4.scrollTop) - (r4.clientTop || 0), l3 = typeof e3.top == "number" ? e3.top : u2 + i3 - e3.bottom - t3.height, s3 = typeof e3.right == "number" ? e3.right : e3.left + t3.width, a2 = typeof e3.bottom == "number" ? e3.bottom : e3.top + t3.height, c = typeof e3.left == "number" ? e3.left : o3 + n3 - e3.right - t3.width; 3011 return { top: l3 < Math.floor(u2), right: s3 > Math.ceil(o3 + n3), bottom: a2 > Math.ceil(u2 + i3), left: c < Math.floor(o3) }; 3012 } }, { key: "getMenuDimensions", value: function() { 3013 var e3 = { width: null, height: null }; 3014 return this.tribute.menu.style.cssText = "top: 0px;\n left: 0px;\n position: fixed;\n display: block;\n visibility; hidden;", e3.width = this.tribute.menu.offsetWidth, e3.height = this.tribute.menu.offsetHeight, this.tribute.menu.style.cssText = "display: none;", e3; 3015 } }, { key: "getTextAreaOrInputUnderlinePosition", value: function(e3, t3, n3) { 3016 var i3 = window.mozInnerScreenX !== null, r4 = this.getDocument().createElement("div"); 3017 r4.id = "input-textarea-caret-position-mirror-div", this.getDocument().body.appendChild(r4); 3018 var o3 = r4.style, u2 = window.getComputedStyle ? getComputedStyle(e3) : e3.currentStyle; 3019 o3.whiteSpace = "pre-wrap", e3.nodeName !== "INPUT" && (o3.wordWrap = "break-word"), o3.position = "absolute", o3.visibility = "hidden", ["direction", "boxSizing", "width", "height", "overflowX", "overflowY", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "fontStyle", "fontVariant", "fontWeight", "fontStretch", "fontSize", "fontSizeAdjust", "lineHeight", "fontFamily", "textAlign", "textTransform", "textIndent", "textDecoration", "letterSpacing", "wordSpacing"].forEach(function(e4) { 3020 o3[e4] = u2[e4]; 3021 }), i3 ? (o3.width = "".concat(parseInt(u2.width) - 2, "px"), e3.scrollHeight > parseInt(u2.height) && (o3.overflowY = "scroll")) : o3.overflow = "hidden", r4.textContent = e3.value.substring(0, t3), e3.nodeName === "INPUT" && (r4.textContent = r4.textContent.replace(/\s/g, "\xA0")); 3022 var l3 = this.getDocument().createElement("span"); 3023 l3.textContent = e3.value.substring(t3) || ".", r4.appendChild(l3); 3024 var s3 = e3.getBoundingClientRect(), a2 = document.documentElement, c = (window.pageXOffset || a2.scrollLeft) - (a2.clientLeft || 0), h2 = (window.pageYOffset || a2.scrollTop) - (a2.clientTop || 0), d = 0, f = 0; 3025 this.menuContainerIsBody && (d = s3.top, f = s3.left); 3026 var m = { top: d + h2 + l3.offsetTop + parseInt(u2.borderTopWidth) + parseInt(u2.fontSize) - e3.scrollTop, left: f + c + l3.offsetLeft + parseInt(u2.borderLeftWidth) }, p = window.innerWidth, v = window.innerHeight, g = this.getMenuDimensions(), b = this.isMenuOffScreen(m, g); 3027 b.right && (m.right = p - m.left, m.left = "auto"); 3028 var y = this.tribute.menuContainer ? this.tribute.menuContainer.offsetHeight : this.getDocument().body.offsetHeight; 3029 if (b.bottom) { 3030 var w = y - (v - (this.tribute.menuContainer ? this.tribute.menuContainer.getBoundingClientRect() : this.getDocument().body.getBoundingClientRect()).top); 3031 m.bottom = w + (v - s3.top - l3.offsetTop), m.top = "auto"; 3032 } 3033 return (b = this.isMenuOffScreen(m, g)).left && (m.left = p > g.width ? c + p - g.width : c, delete m.right), b.top && (m.top = v > g.height ? h2 + v - g.height : h2, delete m.bottom), this.getDocument().body.removeChild(r4), m; 3034 } }, { key: "getContentEditableCaretPosition", value: function(e3) { 3035 var t3, n3 = this.getWindowSelection(); 3036 (t3 = this.getDocument().createRange()).setStart(n3.anchorNode, e3), t3.setEnd(n3.anchorNode, e3), t3.collapse(false); 3037 var i3 = t3.getBoundingClientRect(), r4 = document.documentElement, o3 = (window.pageXOffset || r4.scrollLeft) - (r4.clientLeft || 0), u2 = (window.pageYOffset || r4.scrollTop) - (r4.clientTop || 0), l3 = { left: i3.left + o3, top: i3.top + i3.height + u2 }, s3 = window.innerWidth, a2 = window.innerHeight, c = this.getMenuDimensions(), h2 = this.isMenuOffScreen(l3, c); 3038 h2.right && (l3.left = "auto", l3.right = s3 - i3.left - o3); 3039 var d = this.tribute.menuContainer ? this.tribute.menuContainer.offsetHeight : this.getDocument().body.offsetHeight; 3040 if (h2.bottom) { 3041 var f = d - (a2 - (this.tribute.menuContainer ? this.tribute.menuContainer.getBoundingClientRect() : this.getDocument().body.getBoundingClientRect()).top); 3042 l3.top = "auto", l3.bottom = f + (a2 - i3.top); 3043 } 3044 return (h2 = this.isMenuOffScreen(l3, c)).left && (l3.left = s3 > c.width ? o3 + s3 - c.width : o3, delete l3.right), h2.top && (l3.top = a2 > c.height ? u2 + a2 - c.height : u2, delete l3.bottom), this.menuContainerIsBody || (l3.left = l3.left ? l3.left - this.tribute.menuContainer.offsetLeft : l3.left, l3.top = l3.top ? l3.top - this.tribute.menuContainer.offsetTop : l3.top), l3; 3045 } }, { key: "scrollIntoView", value: function(e3) { 3046 var t3, n3 = this.menu; 3047 if (n3 !== void 0) { 3048 for (; t3 === void 0 || t3.height === 0; ) 3049 if ((t3 = n3.getBoundingClientRect()).height === 0 && ((n3 = n3.childNodes[0]) === void 0 || !n3.getBoundingClientRect)) 3050 return; 3051 var i3 = t3.top, r4 = i3 + t3.height; 3052 if (i3 < 0) 3053 window.scrollTo(0, window.pageYOffset + t3.top - 20); 3054 else if (r4 > window.innerHeight) { 3055 var o3 = window.pageYOffset + t3.top - 20; 3056 o3 - window.pageYOffset > 100 && (o3 = window.pageYOffset + 100); 3057 var u2 = window.pageYOffset - (window.innerHeight - r4); 3058 u2 > o3 && (u2 = o3), window.scrollTo(0, u2); 3059 } 3060 } 3061 } }, { key: "menuContainerIsBody", get: function() { 3062 return this.tribute.menuContainer === document.body || !this.tribute.menuContainer; 3063 } }]), t2; 3064 }(), s2 = function() { 3065 function t2(n3) { 3066 e2(this, t2), this.tribute = n3, this.tribute.search = this; 3067 } 3068 return n2(t2, [{ key: "simpleFilter", value: function(e3, t3) { 3069 var n3 = this; 3070 return t3.filter(function(t4) { 3071 return n3.test(e3, t4); 3072 }); 3073 } }, { key: "test", value: function(e3, t3) { 3074 return this.match(e3, t3) !== null; 3075 } }, { key: "match", value: function(e3, t3, n3) { 3076 n3 = n3 || {}; 3077 t3.length; 3078 var i3 = n3.pre || "", r4 = n3.post || "", o3 = n3.caseSensitive && t3 || t3.toLowerCase(); 3079 if (n3.skip) 3080 return { rendered: t3, score: 0 }; 3081 e3 = n3.caseSensitive && e3 || e3.toLowerCase(); 3082 var u2 = this.traverse(o3, e3, 0, 0, []); 3083 return u2 ? { rendered: this.render(t3, u2.cache, i3, r4), score: u2.score } : null; 3084 } }, { key: "traverse", value: function(e3, t3, n3, i3, r4) { 3085 if (t3.length === i3) 3086 return { score: this.calculateScore(r4), cache: r4.slice() }; 3087 if (!(e3.length === n3 || t3.length - i3 > e3.length - n3)) { 3088 for (var o3, u2, l3 = t3[i3], s3 = e3.indexOf(l3, n3); s3 > -1; ) { 3089 if (r4.push(s3), u2 = this.traverse(e3, t3, s3 + 1, i3 + 1, r4), r4.pop(), !u2) 3090 return o3; 3091 (!o3 || o3.score < u2.score) && (o3 = u2), s3 = e3.indexOf(l3, s3 + 1); 3092 } 3093 return o3; 3094 } 3095 } }, { key: "calculateScore", value: function(e3) { 3096 var t3 = 0, n3 = 1; 3097 return e3.forEach(function(i3, r4) { 3098 r4 > 0 && (e3[r4 - 1] + 1 === i3 ? n3 += n3 + 1 : n3 = 1), t3 += n3; 3099 }), t3; 3100 } }, { key: "render", value: function(e3, t3, n3, i3) { 3101 var r4 = e3.substring(0, t3[0]); 3102 return t3.forEach(function(o3, u2) { 3103 r4 += n3 + e3[o3] + i3 + e3.substring(o3 + 1, t3[u2 + 1] ? t3[u2 + 1] : e3.length); 3104 }), r4; 3105 } }, { key: "filter", value: function(e3, t3, n3) { 3106 var i3 = this; 3107 return n3 = n3 || {}, t3.reduce(function(t4, r4, o3, u2) { 3108 var l3 = r4; 3109 n3.extract && ((l3 = n3.extract(r4)) || (l3 = "")); 3110 var s3 = i3.match(e3, l3, n3); 3111 return s3 != null && (t4[t4.length] = { string: s3.rendered, score: s3.score, index: o3, original: r4 }), t4; 3112 }, []).sort(function(e4, t4) { 3113 var n4 = t4.score - e4.score; 3114 return n4 || e4.index - t4.index; 3115 }); 3116 } }]), t2; 3117 }(); 3118 return function() { 3119 function t2(n3) { 3120 var i3, r4 = this, a2 = n3.values, c = a2 === void 0 ? null : a2, h2 = n3.iframe, d = h2 === void 0 ? null : h2, f = n3.selectClass, m = f === void 0 ? "highlight" : f, p = n3.containerClass, v = p === void 0 ? "tribute-container" : p, g = n3.itemClass, b = g === void 0 ? "" : g, y = n3.trigger, w = y === void 0 ? "@" : y, T = n3.autocompleteMode, C = T !== void 0 && T, S = n3.selectTemplate, E = S === void 0 ? null : S, k = n3.menuItemTemplate, x = k === void 0 ? null : k, M = n3.lookup, A = M === void 0 ? "key" : M, L = n3.fillAttr, I = L === void 0 ? "value" : L, N = n3.collection, O = N === void 0 ? null : N, D = n3.menuContainer, P = D === void 0 ? null : D, R = n3.noMatchTemplate, W = R === void 0 ? null : R, H = n3.requireLeadingSpace, B = H === void 0 || H, F = n3.allowSpaces, _ = F !== void 0 && F, j = n3.replaceTextSuffix, Y = j === void 0 ? null : j, z = n3.positionMenu, K = z === void 0 || z, q = n3.spaceSelectsMatch, U = q !== void 0 && q, X = n3.searchOpts, Q = X === void 0 ? {} : X, V = n3.menuItemLimit, G = V === void 0 ? null : V, J = n3.menuShowMinLength, Z = J === void 0 ? 0 : J; 3121 if (e2(this, t2), this.autocompleteMode = C, this.menuSelected = 0, this.current = {}, this.inputEvent = false, this.isActive = false, this.menuContainer = P, this.allowSpaces = _, this.replaceTextSuffix = Y, this.positionMenu = K, this.hasTrailingSpace = false, this.spaceSelectsMatch = U, this.autocompleteMode && (w = "", _ = false), c) 3122 this.collection = [{ trigger: w, iframe: d, selectClass: m, containerClass: v, itemClass: b, selectTemplate: (E || t2.defaultSelectTemplate).bind(this), menuItemTemplate: (x || t2.defaultMenuItemTemplate).bind(this), noMatchTemplate: (i3 = W, typeof i3 == "string" ? i3.trim() === "" ? null : i3 : typeof i3 == "function" ? i3.bind(r4) : W || function() { 3123 return "<li>No Match Found!</li>"; 3124 }.bind(r4)), lookup: A, fillAttr: I, values: c, requireLeadingSpace: B, searchOpts: Q, menuItemLimit: G, menuShowMinLength: Z }]; 3125 else { 3126 if (!O) 3127 throw new Error("[Tribute] No collection specified."); 3128 this.autocompleteMode && console.warn("Tribute in autocomplete mode does not work for collections"), this.collection = O.map(function(e3) { 3129 return { trigger: e3.trigger || w, iframe: e3.iframe || d, selectClass: e3.selectClass || m, containerClass: e3.containerClass || v, itemClass: e3.itemClass || b, selectTemplate: (e3.selectTemplate || t2.defaultSelectTemplate).bind(r4), menuItemTemplate: (e3.menuItemTemplate || t2.defaultMenuItemTemplate).bind(r4), noMatchTemplate: function(e4) { 3130 return typeof e4 == "string" ? e4.trim() === "" ? null : e4 : typeof e4 == "function" ? e4.bind(r4) : W || function() { 3131 return "<li>No Match Found!</li>"; 3132 }.bind(r4); 3133 }(W), lookup: e3.lookup || A, fillAttr: e3.fillAttr || I, values: e3.values, requireLeadingSpace: e3.requireLeadingSpace, searchOpts: e3.searchOpts || Q, menuItemLimit: e3.menuItemLimit || G, menuShowMinLength: e3.menuShowMinLength || Z }; 3134 }); 3135 } 3136 new l2(this), new o2(this), new u(this), new s2(this); 3137 } 3138 return n2(t2, [{ key: "triggers", value: function() { 3139 return this.collection.map(function(e3) { 3140 return e3.trigger; 3141 }); 3142 } }, { key: "attach", value: function(e3) { 3143 if (!e3) 3144 throw new Error("[Tribute] Must pass in a DOM node or NodeList."); 3145 if (typeof jQuery != "undefined" && e3 instanceof jQuery && (e3 = e3.get()), e3.constructor === NodeList || e3.constructor === HTMLCollection || e3.constructor === Array) 3146 for (var t3 = e3.length, n3 = 0; n3 < t3; ++n3) 3147 this._attach(e3[n3]); 3148 else 3149 this._attach(e3); 3150 } }, { key: "_attach", value: function(e3) { 3151 e3.hasAttribute("data-tribute") && console.warn("Tribute was already bound to " + e3.nodeName), this.ensureEditable(e3), this.events.bind(e3), e3.setAttribute("data-tribute", true); 3152 } }, { key: "ensureEditable", value: function(e3) { 3153 if (t2.inputTypes().indexOf(e3.nodeName) === -1) { 3154 if (!e3.contentEditable) 3155 throw new Error("[Tribute] Cannot bind to " + e3.nodeName); 3156 e3.contentEditable = true; 3157 } 3158 } }, { key: "createMenu", value: function(e3) { 3159 var t3 = this.range.getDocument().createElement("div"), n3 = this.range.getDocument().createElement("ul"); 3160 return t3.className = e3, t3.appendChild(n3), this.menuContainer ? this.menuContainer.appendChild(t3) : this.range.getDocument().body.appendChild(t3); 3161 } }, { key: "showMenuFor", value: function(e3, t3) { 3162 var n3 = this; 3163 if (!this.isActive || this.current.element !== e3 || this.current.mentionText !== this.currentMentionTextSnapshot) { 3164 this.currentMentionTextSnapshot = this.current.mentionText, this.menu || (this.menu = this.createMenu(this.current.collection.containerClass), e3.tributeMenu = this.menu, this.menuEvents.bind(this.menu)), this.isActive = true, this.menuSelected = 0, this.current.mentionText || (this.current.mentionText = ""); 3165 var r4 = function(e4) { 3166 if (n3.isActive) { 3167 var r5 = n3.search.filter(n3.current.mentionText, e4, { pre: n3.current.collection.searchOpts.pre || "<span>", post: n3.current.collection.searchOpts.post || "</span>", skip: n3.current.collection.searchOpts.skip, extract: function(e5) { 3168 if (typeof n3.current.collection.lookup == "string") 3169 return e5[n3.current.collection.lookup]; 3170 if (typeof n3.current.collection.lookup == "function") 3171 return n3.current.collection.lookup(e5, n3.current.mentionText); 3172 throw new Error("Invalid lookup attribute, lookup must be string or function."); 3173 } }); 3174 n3.current.collection.menuItemLimit && (r5 = r5.slice(0, n3.current.collection.menuItemLimit)), n3.current.filteredItems = r5; 3175 var o3 = n3.menu.querySelector("ul"); 3176 if (n3.range.positionMenuAtCaret(t3), !r5.length) { 3177 var u2 = new CustomEvent("tribute-no-match", { detail: n3.menu }); 3178 return n3.current.element.dispatchEvent(u2), void (typeof n3.current.collection.noMatchTemplate == "function" && !n3.current.collection.noMatchTemplate() || !n3.current.collection.noMatchTemplate ? n3.hideMenu() : typeof n3.current.collection.noMatchTemplate == "function" ? o3.innerHTML = n3.current.collection.noMatchTemplate() : o3.innerHTML = n3.current.collection.noMatchTemplate); 3179 } 3180 o3.innerHTML = ""; 3181 var l3 = n3.range.getDocument().createDocumentFragment(); 3182 r5.forEach(function(e5, t4) { 3183 var r6 = n3.range.getDocument().createElement("li"); 3184 r6.setAttribute("data-index", t4), r6.className = n3.current.collection.itemClass, r6.addEventListener("mousemove", function(e6) { 3185 var t5 = i2(n3._findLiTarget(e6.target), 2), r7 = (t5[0], t5[1]); 3186 e6.movementY !== 0 && n3.events.setActiveLi(r7); 3187 }), n3.menuSelected === t4 && r6.classList.add(n3.current.collection.selectClass), r6.innerHTML = n3.current.collection.menuItemTemplate(e5), l3.appendChild(r6); 3188 }), o3.appendChild(l3); 3189 } 3190 }; 3191 typeof this.current.collection.values == "function" ? this.current.collection.values(this.current.mentionText, r4) : r4(this.current.collection.values); 3192 } 3193 } }, { key: "_findLiTarget", value: function(e3) { 3194 if (!e3) 3195 return []; 3196 var t3 = e3.getAttribute("data-index"); 3197 return t3 ? [e3, t3] : this._findLiTarget(e3.parentNode); 3198 } }, { key: "showMenuForCollection", value: function(e3, t3) { 3199 e3 !== document.activeElement && this.placeCaretAtEnd(e3), this.current.collection = this.collection[t3 || 0], this.current.externalTrigger = true, this.current.element = e3, e3.isContentEditable ? this.insertTextAtCursor(this.current.collection.trigger) : this.insertAtCaret(e3, this.current.collection.trigger), this.showMenuFor(e3); 3200 } }, { key: "placeCaretAtEnd", value: function(e3) { 3201 if (e3.focus(), window.getSelection !== void 0 && document.createRange !== void 0) { 3202 var t3 = document.createRange(); 3203 t3.selectNodeContents(e3), t3.collapse(false); 3204 var n3 = window.getSelection(); 3205 n3.removeAllRanges(), n3.addRange(t3); 3206 } else if (document.body.createTextRange !== void 0) { 3207 var i3 = document.body.createTextRange(); 3208 i3.moveToElementText(e3), i3.collapse(false), i3.select(); 3209 } 3210 } }, { key: "insertTextAtCursor", value: function(e3) { 3211 var t3, n3; 3212 (n3 = (t3 = window.getSelection()).getRangeAt(0)).deleteContents(); 3213 var i3 = document.createTextNode(e3); 3214 n3.insertNode(i3), n3.selectNodeContents(i3), n3.collapse(false), t3.removeAllRanges(), t3.addRange(n3); 3215 } }, { key: "insertAtCaret", value: function(e3, t3) { 3216 var n3 = e3.scrollTop, i3 = e3.selectionStart, r4 = e3.value.substring(0, i3), o3 = e3.value.substring(e3.selectionEnd, e3.value.length); 3217 e3.value = r4 + t3 + o3, i3 += t3.length, e3.selectionStart = i3, e3.selectionEnd = i3, e3.focus(), e3.scrollTop = n3; 3218 } }, { key: "hideMenu", value: function() { 3219 this.menu && (this.menu.style.cssText = "display: none;", this.isActive = false, this.menuSelected = 0, this.current = {}); 3220 } }, { key: "selectItemAtIndex", value: function(e3, t3) { 3221 if (typeof (e3 = parseInt(e3)) == "number" && !isNaN(e3)) { 3222 var n3 = this.current.filteredItems[e3], i3 = this.current.collection.selectTemplate(n3); 3223 i3 !== null && this.replaceText(i3, t3, n3); 3224 } 3225 } }, { key: "replaceText", value: function(e3, t3, n3) { 3226 this.range.replaceTriggerText(e3, true, true, t3, n3); 3227 } }, { key: "_append", value: function(e3, t3, n3) { 3228 if (typeof e3.values == "function") 3229 throw new Error("Unable to append to values, as it is a function."); 3230 e3.values = n3 ? t3 : e3.values.concat(t3); 3231 } }, { key: "append", value: function(e3, t3, n3) { 3232 var i3 = parseInt(e3); 3233 if (typeof i3 != "number") 3234 throw new Error("please provide an index for the collection to update."); 3235 var r4 = this.collection[i3]; 3236 this._append(r4, t3, n3); 3237 } }, { key: "appendCurrent", value: function(e3, t3) { 3238 if (!this.isActive) 3239 throw new Error("No active state. Please use append instead and pass an index."); 3240 this._append(this.current.collection, e3, t3); 3241 } }, { key: "detach", value: function(e3) { 3242 if (!e3) 3243 throw new Error("[Tribute] Must pass in a DOM node or NodeList."); 3244 if (typeof jQuery != "undefined" && e3 instanceof jQuery && (e3 = e3.get()), e3.constructor === NodeList || e3.constructor === HTMLCollection || e3.constructor === Array) 3245 for (var t3 = e3.length, n3 = 0; n3 < t3; ++n3) 3246 this._detach(e3[n3]); 3247 else 3248 this._detach(e3); 3249 } }, { key: "_detach", value: function(e3) { 3250 var t3 = this; 3251 this.events.unbind(e3), e3.tributeMenu && this.menuEvents.unbind(e3.tributeMenu), setTimeout(function() { 3252 e3.removeAttribute("data-tribute"), t3.isActive = false, e3.tributeMenu && e3.tributeMenu.remove(); 3253 }); 3254 } }, { key: "isActive", get: function() { 3255 return this._isActive; 3256 }, set: function(e3) { 3257 if (this._isActive != e3 && (this._isActive = e3, this.current.element)) { 3258 var t3 = new CustomEvent("tribute-active-".concat(e3)); 3259 this.current.element.dispatchEvent(t3); 3260 } 3261 } }], [{ key: "defaultSelectTemplate", value: function(e3) { 3262 return e3 === void 0 ? "".concat(this.current.collection.trigger).concat(this.current.mentionText) : this.range.isContentEditable(this.current.element) ? '<span class="tribute-mention">' + (this.current.collection.trigger + e3.original[this.current.collection.fillAttr]) + "</span>" : this.current.collection.trigger + e3.original[this.current.collection.fillAttr]; 3263 } }, { key: "defaultMenuItemTemplate", value: function(e3) { 3264 return e3.string; 3265 } }, { key: "inputTypes", value: function() { 3266 return ["TEXTAREA", "INPUT"]; 3267 } }]), t2; 3268 }(); 3269 }); 3270 } 3271 }); 3272 3273
vendor: 355,429 bytes, lines 3273-8537
3273// ../../node_modules/trix/dist/trix.js 3274 var require_trix = __commonJS({ 3275 "../../node_modules/trix/dist/trix.js"(exports2, module5) { 3276 (function() { 3277 }).call(exports2), function() { 3278 var t; 3279 window.Set == null && (window.Set = t = function() { 3280 function t2() { 3281 this.clear(); 3282 } 3283 return t2.prototype.clear = function() { 3284 return this.values = []; 3285 }, t2.prototype.has = function(t3) { 3286 return this.values.indexOf(t3) !== -1; 3287 }, t2.prototype.add = function(t3) { 3288 return this.has(t3) || this.values.push(t3), this; 3289 }, t2.prototype["delete"] = function(t3) { 3290 var e2; 3291 return (e2 = this.values.indexOf(t3)) === -1 ? false : (this.values.splice(e2, 1), true); 3292 }, t2.prototype.forEach = function() { 3293 var t3; 3294 return (t3 = this.values).forEach.apply(t3, arguments); 3295 }, t2; 3296 }()); 3297 }.call(exports2), function(t) { 3298 function e2() { 3299 } 3300 function n2(t2, e3) { 3301 return function() { 3302 t2.apply(e3, arguments); 3303 }; 3304 } 3305 function i2(t2) { 3306 if (typeof this != "object") 3307 throw new TypeError("Promises must be constructed via new"); 3308 if (typeof t2 != "function") 3309 throw new TypeError("not a function"); 3310 this._state = 0, this._handled = false, this._value = void 0, this._deferreds = [], c(t2, this); 3311 } 3312 function o2(t2, e3) { 3313 for (; t2._state === 3; ) 3314 t2 = t2._value; 3315 return t2._state === 0 ? void t2._deferreds.push(e3) : (t2._handled = true, void h2(function() { 3316 var n3 = t2._state === 1 ? e3.onFulfilled : e3.onRejected; 3317 if (n3 === null) 3318 return void (t2._state === 1 ? r3 : s2)(e3.promise, t2._value); 3319 var i3; 3320 try { 3321 i3 = n3(t2._value); 3322 } catch (o3) { 3323 return void s2(e3.promise, o3); 3324 } 3325 r3(e3.promise, i3); 3326 })); 3327 } 3328 function r3(t2, e3) { 3329 try { 3330 if (e3 === t2) 3331 throw new TypeError("A promise cannot be resolved with itself."); 3332 if (e3 && (typeof e3 == "object" || typeof e3 == "function")) { 3333 var o3 = e3.then; 3334 if (e3 instanceof i2) 3335 return t2._state = 3, t2._value = e3, void a2(t2); 3336 if (typeof o3 == "function") 3337 return void c(n2(o3, e3), t2); 3338 } 3339 t2._state = 1, t2._value = e3, a2(t2); 3340 } catch (r4) { 3341 s2(t2, r4); 3342 } 3343 } 3344 function s2(t2, e3) { 3345 t2._state = 2, t2._value = e3, a2(t2); 3346 } 3347 function a2(t2) { 3348 t2._state === 2 && t2._deferreds.length === 0 && setTimeout(function() { 3349 t2._handled || p(t2._value); 3350 }, 1); 3351 for (var e3 = 0, n3 = t2._deferreds.length; n3 > e3; e3++) 3352 o2(t2, t2._deferreds[e3]); 3353 t2._deferreds = null; 3354 } 3355 function u(t2, e3, n3) { 3356 this.onFulfilled = typeof t2 == "function" ? t2 : null, this.onRejected = typeof e3 == "function" ? e3 : null, this.promise = n3; 3357 } 3358 function c(t2, e3) { 3359 var n3 = false; 3360 try { 3361 t2(function(t3) { 3362 n3 || (n3 = true, r3(e3, t3)); 3363 }, function(t3) { 3364 n3 || (n3 = true, s2(e3, t3)); 3365 }); 3366 } catch (i3) { 3367 if (n3) 3368 return; 3369 n3 = true, s2(e3, i3); 3370 } 3371 } 3372 var l2 = setTimeout, h2 = typeof setImmediate == "function" && setImmediate || function(t2) { 3373 l2(t2, 1); 3374 }, p = function(t2) { 3375 typeof console != "undefined" && console && console.warn("Possible Unhandled Promise Rejection:", t2); 3376 }; 3377 i2.prototype["catch"] = function(t2) { 3378 return this.then(null, t2); 3379 }, i2.prototype.then = function(t2, n3) { 3380 var r4 = new i2(e2); 3381 return o2(this, new u(t2, n3, r4)), r4; 3382 }, i2.all = function(t2) { 3383 var e3 = Array.prototype.slice.call(t2); 3384 return new i2(function(t3, n3) { 3385 function i3(r5, s3) { 3386 try { 3387 if (s3 && (typeof s3 == "object" || typeof s3 == "function")) { 3388 var a3 = s3.then; 3389 if (typeof a3 == "function") 3390 return void a3.call(s3, function(t4) { 3391 i3(r5, t4); 3392 }, n3); 3393 } 3394 e3[r5] = s3, --o3 === 0 && t3(e3); 3395 } catch (u2) { 3396 n3(u2); 3397 } 3398 } 3399 if (e3.length === 0) 3400 return t3([]); 3401 for (var o3 = e3.length, r4 = 0; r4 < e3.length; r4++) 3402 i3(r4, e3[r4]); 3403 }); 3404 }, i2.resolve = function(t2) { 3405 return t2 && typeof t2 == "object" && t2.constructor === i2 ? t2 : new i2(function(e3) { 3406 e3(t2); 3407 }); 3408 }, i2.reject = function(t2) { 3409 return new i2(function(e3, n3) { 3410 n3(t2); 3411 }); 3412 }, i2.race = function(t2) { 3413 return new i2(function(e3, n3) { 3414 for (var i3 = 0, o3 = t2.length; o3 > i3; i3++) 3415 t2[i3].then(e3, n3); 3416 }); 3417 }, i2._setImmediateFn = function(t2) { 3418 h2 = t2; 3419 }, i2._setUnhandledRejectionFn = function(t2) { 3420 p = t2; 3421 }, typeof module5 != "undefined" && module5.exports ? module5.exports = i2 : t.Promise || (t.Promise = i2); 3422 }(exports2), function() { 3423 var t = typeof window.customElements == "object", e2 = typeof document.registerElement == "function", n2 = t || e2; 3424 n2 || (typeof WeakMap == "undefined" && !function() { 3425 var t2 = Object.defineProperty, e3 = Date.now() % 1e9, n3 = function() { 3426 this.name = "__st" + (1e9 * Math.random() >>> 0) + (e3++ + "__"); 3427 }; 3428 n3.prototype = { set: function(e4, n4) { 3429 var i2 = e4[this.name]; 3430 return i2 && i2[0] === e4 ? i2[1] = n4 : t2(e4, this.name, { value: [e4, n4], writable: true }), this; 3431 }, get: function(t3) { 3432 var e4; 3433 return (e4 = t3[this.name]) && e4[0] === t3 ? e4[1] : void 0; 3434 }, "delete": function(t3) { 3435 var e4 = t3[this.name]; 3436 return e4 && e4[0] === t3 ? (e4[0] = e4[1] = void 0, true) : false; 3437 }, has: function(t3) { 3438 var e4 = t3[this.name]; 3439 return e4 ? e4[0] === t3 : false; 3440 } }, window.WeakMap = n3; 3441 }(), function(t2) { 3442 function e3(t3) { 3443 A.push(t3), b || (b = true, g(i2)); 3444 } 3445 function n3(t3) { 3446 return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(t3) || t3; 3447 } 3448 function i2() { 3449 b = false; 3450 var t3 = A; 3451 A = [], t3.sort(function(t4, e5) { 3452 return t4.uid_ - e5.uid_; 3453 }); 3454 var e4 = false; 3455 t3.forEach(function(t4) { 3456 var n4 = t4.takeRecords(); 3457 o2(t4), n4.length && (t4.callback_(n4, t4), e4 = true); 3458 }), e4 && i2(); 3459 } 3460 function o2(t3) { 3461 t3.nodes_.forEach(function(e4) { 3462 var n4 = m.get(e4); 3463 n4 && n4.forEach(function(e5) { 3464 e5.observer === t3 && e5.removeTransientObservers(); 3465 }); 3466 }); 3467 } 3468 function r3(t3, e4) { 3469 for (var n4 = t3; n4; n4 = n4.parentNode) { 3470 var i3 = m.get(n4); 3471 if (i3) 3472 for (var o3 = 0; o3 < i3.length; o3++) { 3473 var r4 = i3[o3], s3 = r4.options; 3474 if (n4 === t3 || s3.subtree) { 3475 var a3 = e4(s3); 3476 a3 && r4.enqueue(a3); 3477 } 3478 } 3479 } 3480 } 3481 function s2(t3) { 3482 this.callback_ = t3, this.nodes_ = [], this.records_ = [], this.uid_ = ++C; 3483 } 3484 function a2(t3, e4) { 3485 this.type = t3, this.target = e4, this.addedNodes = [], this.removedNodes = [], this.previousSibling = null, this.nextSibling = null, this.attributeName = null, this.attributeNamespace = null, this.oldValue = null; 3486 } 3487 function u(t3) { 3488 var e4 = new a2(t3.type, t3.target); 3489 return e4.addedNodes = t3.addedNodes.slice(), e4.removedNodes = t3.removedNodes.slice(), e4.previousSibling = t3.previousSibling, e4.nextSibling = t3.nextSibling, e4.attributeName = t3.attributeName, e4.attributeNamespace = t3.attributeNamespace, e4.oldValue = t3.oldValue, e4; 3490 } 3491 function c(t3, e4) { 3492 return x = new a2(t3, e4); 3493 } 3494 function l2(t3) { 3495 return w ? w : (w = u(x), w.oldValue = t3, w); 3496 } 3497 function h2() { 3498 x = w = void 0; 3499 } 3500 function p(t3) { 3501 return t3 === w || t3 === x; 3502 } 3503 function d(t3, e4) { 3504 return t3 === e4 ? t3 : w && p(t3) ? w : null; 3505 } 3506 function f(t3, e4, n4) { 3507 this.observer = t3, this.target = e4, this.options = n4, this.transientObservedNodes = []; 3508 } 3509 if (!t2.JsMutationObserver) { 3510 var g, m = /* @__PURE__ */ new WeakMap(); 3511 if (/Trident|Edge/.test(navigator.userAgent)) 3512 g = setTimeout; 3513 else if (window.setImmediate) 3514 g = window.setImmediate; 3515 else { 3516 var v = [], y = String(Math.random()); 3517 window.addEventListener("message", function(t3) { 3518 if (t3.data === y) { 3519 var e4 = v; 3520 v = [], e4.forEach(function(t4) { 3521 t4(); 3522 }); 3523 } 3524 }), g = function(t3) { 3525 v.push(t3), window.postMessage(y, "*"); 3526 }; 3527 } 3528 var b = false, A = [], C = 0; 3529 s2.prototype = { observe: function(t3, e4) { 3530 if (t3 = n3(t3), !e4.childList && !e4.attributes && !e4.characterData || e4.attributeOldValue && !e4.attributes || e4.attributeFilter && e4.attributeFilter.length && !e4.attributes || e4.characterDataOldValue && !e4.characterData) 3531 throw new SyntaxError(); 3532 var i3 = m.get(t3); 3533 i3 || m.set(t3, i3 = []); 3534 for (var o3, r4 = 0; r4 < i3.length; r4++) 3535 if (i3[r4].observer === this) { 3536 o3 = i3[r4], o3.removeListeners(), o3.options = e4; 3537 break; 3538 } 3539 o3 || (o3 = new f(this, t3, e4), i3.push(o3), this.nodes_.push(t3)), o3.addListeners(); 3540 }, disconnect: function() { 3541 this.nodes_.forEach(function(t3) { 3542 for (var e4 = m.get(t3), n4 = 0; n4 < e4.length; n4++) { 3543 var i3 = e4[n4]; 3544 if (i3.observer === this) { 3545 i3.removeListeners(), e4.splice(n4, 1); 3546 break; 3547 } 3548 } 3549 }, this), this.records_ = []; 3550 }, takeRecords: function() { 3551 var t3 = this.records_; 3552 return this.records_ = [], t3; 3553 } }; 3554 var x, w; 3555 f.prototype = { enqueue: function(t3) { 3556 var n4 = this.observer.records_, i3 = n4.length; 3557 if (n4.length > 0) { 3558 var o3 = n4[i3 - 1], r4 = d(o3, t3); 3559 if (r4) 3560 return void (n4[i3 - 1] = r4); 3561 } else 3562 e3(this.observer); 3563 n4[i3] = t3; 3564 }, addListeners: function() { 3565 this.addListeners_(this.target); 3566 }, addListeners_: function(t3) { 3567 var e4 = this.options; 3568 e4.attributes && t3.addEventListener("DOMAttrModified", this, true), e4.characterData && t3.addEventListener("DOMCharacterDataModified", this, true), e4.childList && t3.addEventListener("DOMNodeInserted", this, true), (e4.childList || e4.subtree) && t3.addEventListener("DOMNodeRemoved", this, true); 3569 }, removeListeners: function() { 3570 this.removeListeners_(this.target); 3571 }, removeListeners_: function(t3) { 3572 var e4 = this.options; 3573 e4.attributes && t3.removeEventListener("DOMAttrModified", this, true), e4.characterData && t3.removeEventListener("DOMCharacterDataModified", this, true), e4.childList && t3.removeEventListener("DOMNodeInserted", this, true), (e4.childList || e4.subtree) && t3.removeEventListener("DOMNodeRemoved", this, true); 3574 }, addTransientObserver: function(t3) { 3575 if (t3 !== this.target) { 3576 this.addListeners_(t3), this.transientObservedNodes.push(t3); 3577 var e4 = m.get(t3); 3578 e4 || m.set(t3, e4 = []), e4.push(this); 3579 } 3580 }, removeTransientObservers: function() { 3581 var t3 = this.transientObservedNodes; 3582 this.transientObservedNodes = [], t3.forEach(function(t4) { 3583 this.removeListeners_(t4); 3584 for (var e4 = m.get(t4), n4 = 0; n4 < e4.length; n4++) 3585 if (e4[n4] === this) { 3586 e4.splice(n4, 1); 3587 break; 3588 } 3589 }, this); 3590 }, handleEvent: function(t3) { 3591 switch (t3.stopImmediatePropagation(), t3.type) { 3592 case "DOMAttrModified": 3593 var e4 = t3.attrName, n4 = t3.relatedNode.namespaceURI, i3 = t3.target, o3 = new c("attributes", i3); 3594 o3.attributeName = e4, o3.attributeNamespace = n4; 3595 var s3 = t3.attrChange === MutationEvent.ADDITION ? null : t3.prevValue; 3596 r3(i3, function(t4) { 3597 return !t4.attributes || t4.attributeFilter && t4.attributeFilter.length && t4.attributeFilter.indexOf(e4) === -1 && t4.attributeFilter.indexOf(n4) === -1 ? void 0 : t4.attributeOldValue ? l2(s3) : o3; 3598 }); 3599 break; 3600 case "DOMCharacterDataModified": 3601 var i3 = t3.target, o3 = c("characterData", i3), s3 = t3.prevValue; 3602 r3(i3, function(t4) { 3603 return t4.characterData ? t4.characterDataOldValue ? l2(s3) : o3 : void 0; 3604 }); 3605 break; 3606 case "DOMNodeRemoved": 3607 this.addTransientObserver(t3.target); 3608 case "DOMNodeInserted": 3609 var a3, u2, p2 = t3.target; 3610 t3.type === "DOMNodeInserted" ? (a3 = [p2], u2 = []) : (a3 = [], u2 = [p2]); 3611 var d2 = p2.previousSibling, f2 = p2.nextSibling, o3 = c("childList", t3.target.parentNode); 3612 o3.addedNodes = a3, o3.removedNodes = u2, o3.previousSibling = d2, o3.nextSibling = f2, r3(t3.relatedNode, function(t4) { 3613 return t4.childList ? o3 : void 0; 3614 }); 3615 } 3616 h2(); 3617 } }, t2.JsMutationObserver = s2, t2.MutationObserver || (t2.MutationObserver = s2, s2._isPolyfilled = true); 3618 } 3619 }(self), function() { 3620 "use strict"; 3621 if (!window.performance || !window.performance.now) { 3622 var t2 = Date.now(); 3623 window.performance = { now: function() { 3624 return Date.now() - t2; 3625 } }; 3626 } 3627 window.requestAnimationFrame || (window.requestAnimationFrame = function() { 3628 var t3 = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame; 3629 return t3 ? function(e4) { 3630 return t3(function() { 3631 e4(performance.now()); 3632 }); 3633 } : function(t4) { 3634 return window.setTimeout(t4, 1e3 / 60); 3635 }; 3636 }()), window.cancelAnimationFrame || (window.cancelAnimationFrame = function() { 3637 return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(t3) { 3638 clearTimeout(t3); 3639 }; 3640 }()); 3641 var e3 = function() { 3642 var t3 = document.createEvent("Event"); 3643 return t3.initEvent("foo", true, true), t3.preventDefault(), t3.defaultPrevented; 3644 }(); 3645 if (!e3) { 3646 var n3 = Event.prototype.preventDefault; 3647 Event.prototype.preventDefault = function() { 3648 this.cancelable && (n3.call(this), Object.defineProperty(this, "defaultPrevented", { get: function() { 3649 return true; 3650 }, configurable: true })); 3651 }; 3652 } 3653 var i2 = /Trident/.test(navigator.userAgent); 3654 if ((!window.CustomEvent || i2 && typeof window.CustomEvent != "function") && (window.CustomEvent = function(t3, e4) { 3655 e4 = e4 || {}; 3656 var n4 = document.createEvent("CustomEvent"); 3657 return n4.initCustomEvent(t3, Boolean(e4.bubbles), Boolean(e4.cancelable), e4.detail), n4; 3658 }, window.CustomEvent.prototype = window.Event.prototype), !window.Event || i2 && typeof window.Event != "function") { 3659 var o2 = window.Event; 3660 window.Event = function(t3, e4) { 3661 e4 = e4 || {}; 3662 var n4 = document.createEvent("Event"); 3663 return n4.initEvent(t3, Boolean(e4.bubbles), Boolean(e4.cancelable)), n4; 3664 }, window.Event.prototype = o2.prototype; 3665 } 3666 }(window.WebComponents), window.CustomElements = window.CustomElements || { flags: {} }, function(t2) { 3667 var e3 = t2.flags, n3 = [], i2 = function(t3) { 3668 n3.push(t3); 3669 }, o2 = function() { 3670 n3.forEach(function(e4) { 3671 e4(t2); 3672 }); 3673 }; 3674 t2.addModule = i2, t2.initializeModules = o2, t2.hasNative = Boolean(document.registerElement), t2.isIE = /Trident/.test(navigator.userAgent), t2.useNative = !e3.register && t2.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative); 3675 }(window.CustomElements), window.CustomElements.addModule(function(t2) { 3676 function e3(t3, e4) { 3677 n3(t3, function(t4) { 3678 return e4(t4) ? true : void i2(t4, e4); 3679 }), i2(t3, e4); 3680 } 3681 function n3(t3, e4, i3) { 3682 var o3 = t3.firstElementChild; 3683 if (!o3) 3684 for (o3 = t3.firstChild; o3 && o3.nodeType !== Node.ELEMENT_NODE; ) 3685 o3 = o3.nextSibling; 3686 for (; o3; ) 3687 e4(o3, i3) !== true && n3(o3, e4, i3), o3 = o3.nextElementSibling; 3688 return null; 3689 } 3690 function i2(t3, n4) { 3691 for (var i3 = t3.shadowRoot; i3; ) 3692 e3(i3, n4), i3 = i3.olderShadowRoot; 3693 } 3694 function o2(t3, e4) { 3695 r3(t3, e4, []); 3696 } 3697 function r3(t3, e4, n4) { 3698 if (t3 = window.wrap(t3), !(n4.indexOf(t3) >= 0)) { 3699 n4.push(t3); 3700 for (var i3, o3 = t3.querySelectorAll("link[rel=" + s2 + "]"), a2 = 0, u = o3.length; u > a2 && (i3 = o3[a2]); a2++) 3701 i3.import && r3(i3.import, e4, n4); 3702 e4(t3); 3703 } 3704 } 3705 var s2 = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : "none"; 3706 t2.forDocumentTree = o2, t2.forSubtree = e3; 3707 }), window.CustomElements.addModule(function(t2) { 3708 function e3(t3, e4) { 3709 return n3(t3, e4) || i2(t3, e4); 3710 } 3711 function n3(e4, n4) { 3712 return t2.upgrade(e4, n4) ? true : void (n4 && s2(e4)); 3713 } 3714 function i2(t3, e4) { 3715 b(t3, function(t4) { 3716 return n3(t4, e4) ? true : void 0; 3717 }); 3718 } 3719 function o2(t3) { 3720 w.push(t3), x || (x = true, setTimeout(r3)); 3721 } 3722 function r3() { 3723 x = false; 3724 for (var t3, e4 = w, n4 = 0, i3 = e4.length; i3 > n4 && (t3 = e4[n4]); n4++) 3725 t3(); 3726 w = []; 3727 } 3728 function s2(t3) { 3729 C ? o2(function() { 3730 a2(t3); 3731 }) : a2(t3); 3732 } 3733 function a2(t3) { 3734 t3.__upgraded__ && !t3.__attached && (t3.__attached = true, t3.attachedCallback && t3.attachedCallback()); 3735 } 3736 function u(t3) { 3737 c(t3), b(t3, function(t4) { 3738 c(t4); 3739 }); 3740 } 3741 function c(t3) { 3742 C ? o2(function() { 3743 l2(t3); 3744 }) : l2(t3); 3745 } 3746 function l2(t3) { 3747 t3.__upgraded__ && t3.__attached && (t3.__attached = false, t3.detachedCallback && t3.detachedCallback()); 3748 } 3749 function h2(t3) { 3750 for (var e4 = t3, n4 = window.wrap(document); e4; ) { 3751 if (e4 == n4) 3752 return true; 3753 e4 = e4.parentNode || e4.nodeType === Node.DOCUMENT_FRAGMENT_NODE && e4.host; 3754 } 3755 } 3756 function p(t3) { 3757 if (t3.shadowRoot && !t3.shadowRoot.__watched) { 3758 y.dom && console.log("watching shadow-root for: ", t3.localName); 3759 for (var e4 = t3.shadowRoot; e4; ) 3760 g(e4), e4 = e4.olderShadowRoot; 3761 } 3762 } 3763 function d(t3, n4) { 3764 if (y.dom) { 3765 var i3 = n4[0]; 3766 if (i3 && i3.type === "childList" && i3.addedNodes && i3.addedNodes) { 3767 for (var o3 = i3.addedNodes[0]; o3 && o3 !== document && !o3.host; ) 3768 o3 = o3.parentNode; 3769 var r4 = o3 && (o3.URL || o3._URL || o3.host && o3.host.localName) || ""; 3770 r4 = r4.split("/?").shift().split("/").pop(); 3771 } 3772 console.group("mutations (%d) [%s]", n4.length, r4 || ""); 3773 } 3774 var s3 = h2(t3); 3775 n4.forEach(function(t4) { 3776 t4.type === "childList" && (E(t4.addedNodes, function(t5) { 3777 t5.localName && e3(t5, s3); 3778 }), E(t4.removedNodes, function(t5) { 3779 t5.localName && u(t5); 3780 })); 3781 }), y.dom && console.groupEnd(); 3782 } 3783 function f(t3) { 3784 for (t3 = window.wrap(t3), t3 || (t3 = window.wrap(document)); t3.parentNode; ) 3785 t3 = t3.parentNode; 3786 var e4 = t3.__observer; 3787 e4 && (d(t3, e4.takeRecords()), r3()); 3788 } 3789 function g(t3) { 3790 if (!t3.__observer) { 3791 var e4 = new MutationObserver(d.bind(this, t3)); 3792 e4.observe(t3, { childList: true, subtree: true }), t3.__observer = e4; 3793 } 3794 } 3795 function m(t3) { 3796 t3 = window.wrap(t3), y.dom && console.group("upgradeDocument: ", t3.baseURI.split("/").pop()); 3797 var n4 = t3 === window.wrap(document); 3798 e3(t3, n4), g(t3), y.dom && console.groupEnd(); 3799 } 3800 function v(t3) { 3801 A(t3, m); 3802 } 3803 var y = t2.flags, b = t2.forSubtree, A = t2.forDocumentTree, C = window.MutationObserver._isPolyfilled && y["throttle-attached"]; 3804 t2.hasPolyfillMutations = C, t2.hasThrottledAttached = C; 3805 var x = false, w = [], E = Array.prototype.forEach.call.bind(Array.prototype.forEach), S = Element.prototype.createShadowRoot; 3806 S && (Element.prototype.createShadowRoot = function() { 3807 var t3 = S.call(this); 3808 return window.CustomElements.watchShadow(this), t3; 3809 }), t2.watchShadow = p, t2.upgradeDocumentTree = v, t2.upgradeDocument = m, t2.upgradeSubtree = i2, t2.upgradeAll = e3, t2.attached = s2, t2.takeRecords = f; 3810 }), window.CustomElements.addModule(function(t2) { 3811 function e3(e4, i3) { 3812 if (e4.localName === "template" && window.HTMLTemplateElement && HTMLTemplateElement.decorate && HTMLTemplateElement.decorate(e4), !e4.__upgraded__ && e4.nodeType === Node.ELEMENT_NODE) { 3813 var o3 = e4.getAttribute("is"), r4 = t2.getRegisteredDefinition(e4.localName) || t2.getRegisteredDefinition(o3); 3814 if (r4 && (o3 && r4.tag == e4.localName || !o3 && !r4.extends)) 3815 return n3(e4, r4, i3); 3816 } 3817 } 3818 function n3(e4, n4, o3) { 3819 return s2.upgrade && console.group("upgrade:", e4.localName), n4.is && e4.setAttribute("is", n4.is), i2(e4, n4), e4.__upgraded__ = true, r3(e4), o3 && t2.attached(e4), t2.upgradeSubtree(e4, o3), s2.upgrade && console.groupEnd(), e4; 3820 } 3821 function i2(t3, e4) { 3822 Object.__proto__ ? t3.__proto__ = e4.prototype : (o2(t3, e4.prototype, e4.native), t3.__proto__ = e4.prototype); 3823 } 3824 function o2(t3, e4, n4) { 3825 for (var i3 = {}, o3 = e4; o3 !== n4 && o3 !== HTMLElement.prototype; ) { 3826 for (var r4, s3 = Object.getOwnPropertyNames(o3), a2 = 0; r4 = s3[a2]; a2++) 3827 i3[r4] || (Object.defineProperty(t3, r4, Object.getOwnPropertyDescriptor(o3, r4)), i3[r4] = 1); 3828 o3 = Object.getPrototypeOf(o3); 3829 } 3830 } 3831 function r3(t3) { 3832 t3.createdCallback && t3.createdCallback(); 3833 } 3834 var s2 = t2.flags; 3835 t2.upgrade = e3, t2.upgradeWithDefinition = n3, t2.implementPrototype = i2; 3836 }), window.CustomElements.addModule(function(t2) { 3837 function e3(e4, i3) { 3838 var u2 = i3 || {}; 3839 if (!e4) 3840 throw new Error("document.registerElement: first argument `name` must not be empty"); 3841 if (e4.indexOf("-") < 0) 3842 throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(e4) + "'."); 3843 if (o2(e4)) 3844 throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '" + String(e4) + "'. The type name is invalid."); 3845 if (c(e4)) 3846 throw new Error("DuplicateDefinitionError: a type with name '" + String(e4) + "' is already registered"); 3847 return u2.prototype || (u2.prototype = Object.create(HTMLElement.prototype)), u2.__name = e4.toLowerCase(), u2.extends && (u2.extends = u2.extends.toLowerCase()), u2.lifecycle = u2.lifecycle || {}, u2.ancestry = r3(u2.extends), s2(u2), a2(u2), n3(u2.prototype), l2(u2.__name, u2), u2.ctor = h2(u2), u2.ctor.prototype = u2.prototype, u2.prototype.constructor = u2.ctor, t2.ready && m(document), u2.ctor; 3848 } 3849 function n3(t3) { 3850 if (!t3.setAttribute._polyfilled) { 3851 var e4 = t3.setAttribute; 3852 t3.setAttribute = function(t4, n5) { 3853 i2.call(this, t4, n5, e4); 3854 }; 3855 var n4 = t3.removeAttribute; 3856 t3.removeAttribute = function(t4) { 3857 i2.call(this, t4, null, n4); 3858 }, t3.setAttribute._polyfilled = true; 3859 } 3860 } 3861 function i2(t3, e4, n4) { 3862 t3 = t3.toLowerCase(); 3863 var i3 = this.getAttribute(t3); 3864 n4.apply(this, arguments); 3865 var o3 = this.getAttribute(t3); 3866 this.attributeChangedCallback && o3 !== i3 && this.attributeChangedCallback(t3, i3, o3); 3867 } 3868 function o2(t3) { 3869 for (var e4 = 0; e4 < C.length; e4++) 3870 if (t3 === C[e4]) 3871 return true; 3872 } 3873 function r3(t3) { 3874 var e4 = c(t3); 3875 return e4 ? r3(e4.extends).concat([e4]) : []; 3876 } 3877 function s2(t3) { 3878 for (var e4, n4 = t3.extends, i3 = 0; e4 = t3.ancestry[i3]; i3++) 3879 n4 = e4.is && e4.tag; 3880 t3.tag = n4 || t3.__name, n4 && (t3.is = t3.__name); 3881 } 3882 function a2(t3) { 3883 if (!Object.__proto__) { 3884 var e4 = HTMLElement.prototype; 3885 if (t3.is) { 3886 var n4 = document.createElement(t3.tag); 3887 e4 = Object.getPrototypeOf(n4); 3888 } 3889 for (var i3, o3 = t3.prototype, r4 = false; o3; ) 3890 o3 == e4 && (r4 = true), i3 = Object.getPrototypeOf(o3), i3 && (o3.__proto__ = i3), o3 = i3; 3891 r4 || console.warn(t3.tag + " prototype not found in prototype chain for " + t3.is), t3.native = e4; 3892 } 3893 } 3894 function u(t3) { 3895 return y(E(t3.tag), t3); 3896 } 3897 function c(t3) { 3898 return t3 ? x[t3.toLowerCase()] : void 0; 3899 } 3900 function l2(t3, e4) { 3901 x[t3] = e4; 3902 } 3903 function h2(t3) { 3904 return function() { 3905 return u(t3); 3906 }; 3907 } 3908 function p(t3, e4, n4) { 3909 return t3 === w ? d(e4, n4) : S(t3, e4); 3910 } 3911 function d(t3, e4) { 3912 t3 && (t3 = t3.toLowerCase()), e4 && (e4 = e4.toLowerCase()); 3913 var n4 = c(e4 || t3); 3914 if (n4) { 3915 if (t3 == n4.tag && e4 == n4.is) 3916 return new n4.ctor(); 3917 if (!e4 && !n4.is) 3918 return new n4.ctor(); 3919 } 3920 var i3; 3921 return e4 ? (i3 = d(t3), i3.setAttribute("is", e4), i3) : (i3 = E(t3), t3.indexOf("-") >= 0 && b(i3, HTMLElement), i3); 3922 } 3923 function f(t3, e4) { 3924 var n4 = t3[e4]; 3925 t3[e4] = function() { 3926 var t4 = n4.apply(this, arguments); 3927 return v(t4), t4; 3928 }; 3929 } 3930 var g, m = (t2.isIE, t2.upgradeDocumentTree), v = t2.upgradeAll, y = t2.upgradeWithDefinition, b = t2.implementPrototype, A = t2.useNative, C = ["annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph"], x = {}, w = "http://www.w3.org/1999/xhtml", E = document.createElement.bind(document), S = document.createElementNS.bind(document); 3931 g = Object.__proto__ || A ? function(t3, e4) { 3932 return t3 instanceof e4; 3933 } : function(t3, e4) { 3934 if (t3 instanceof e4) 3935 return true; 3936 for (var n4 = t3; n4; ) { 3937 if (n4 === e4.prototype) 3938 return true; 3939 n4 = n4.__proto__; 3940 } 3941 return false; 3942 }, f(Node.prototype, "cloneNode"), f(document, "importNode"), document.registerElement = e3, document.createElement = d, document.createElementNS = p, t2.registry = x, t2.instanceof = g, t2.reservedTagList = C, t2.getRegisteredDefinition = c, document.register = document.registerElement; 3943 }), function(t2) { 3944 function e3() { 3945 r3(window.wrap(document)), window.CustomElements.ready = true; 3946 var t3 = window.requestAnimationFrame || function(t4) { 3947 setTimeout(t4, 16); 3948 }; 3949 t3(function() { 3950 setTimeout(function() { 3951 window.CustomElements.readyTime = Date.now(), window.HTMLImports && (window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime), document.dispatchEvent(new CustomEvent("WebComponentsReady", { bubbles: true })); 3952 }); 3953 }); 3954 } 3955 var n3 = t2.useNative, i2 = t2.initializeModules; 3956 if (t2.isIE, n3) { 3957 var o2 = function() { 3958 }; 3959 t2.watchShadow = o2, t2.upgrade = o2, t2.upgradeAll = o2, t2.upgradeDocumentTree = o2, t2.upgradeSubtree = o2, t2.takeRecords = o2, t2.instanceof = function(t3, e4) { 3960 return t3 instanceof e4; 3961 }; 3962 } else 3963 i2(); 3964 var r3 = t2.upgradeDocumentTree, s2 = t2.upgradeDocument; 3965 if (window.wrap || (window.ShadowDOMPolyfill ? (window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded, window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded) : window.wrap = window.unwrap = function(t3) { 3966 return t3; 3967 }), window.HTMLImports && (window.HTMLImports.__importsParsingHook = function(t3) { 3968 t3.import && s2(wrap(t3.import)); 3969 }), document.readyState === "complete" || t2.flags.eager) 3970 e3(); 3971 else if (document.readyState !== "interactive" || window.attachEvent || window.HTMLImports && !window.HTMLImports.ready) { 3972 var a2 = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded"; 3973 window.addEventListener(a2, e3); 3974 } else 3975 e3(); 3976 }(window.CustomElements)); 3977 }.call(exports2), function() { 3978 }.call(exports2), function() { 3979 var t = this; 3980 (function() { 3981 (function() { 3982 this.Trix = { VERSION: "1.3.1", ZERO_WIDTH_SPACE: "\uFEFF", NON_BREAKING_SPACE: "\xA0", OBJECT_REPLACEMENT_CHARACTER: "\uFFFC", browser: { composesExistingText: /Android.*Chrome/.test(navigator.userAgent), forcesObjectResizing: /Trident.*rv:11/.test(navigator.userAgent), supportsInputEvents: function() { 3983 var t2, e3, n2, i2; 3984 if (typeof InputEvent == "undefined") 3985 return false; 3986 for (i2 = ["data", "getTargetRanges", "inputType"], t2 = 0, e3 = i2.length; e3 > t2; t2++) 3987 if (n2 = i2[t2], !(n2 in InputEvent.prototype)) 3988 return false; 3989 return true; 3990 }() }, config: {} }; 3991 }).call(this); 3992 }).call(t); 3993 var e2 = t.Trix; 3994 (function() { 3995 (function() { 3996 e2.BasicObject = function() { 3997 function t2() { 3998 } 3999 var e3, n2, i2; 4000 return t2.proxyMethod = function(t3) { 4001 var i3, o2, r3, s2, a2; 4002 return r3 = n2(t3), i3 = r3.name, s2 = r3.toMethod, a2 = r3.toProperty, o2 = r3.optional, this.prototype[i3] = function() { 4003 var t4, n3; 4004 return t4 = s2 != null ? o2 ? typeof this[s2] == "function" ? this[s2]() : void 0 : this[s2]() : a2 != null ? this[a2] : void 0, o2 ? (n3 = t4 != null ? t4[i3] : void 0, n3 != null ? e3.call(n3, t4, arguments) : void 0) : (n3 = t4[i3], e3.call(n3, t4, arguments)); 4005 }; 4006 }, n2 = function(t3) { 4007 var e4, n3; 4008 if (!(n3 = t3.match(i2))) 4009 throw new Error("can't parse @proxyMethod expression: " + t3); 4010 return e4 = { name: n3[4] }, n3[2] != null ? e4.toMethod = n3[1] : e4.toProperty = n3[1], n3[3] != null && (e4.optional = true), e4; 4011 }, e3 = Function.prototype.apply, i2 = /^(.+?)(\(\))?(\?)?\.(.+?)$/, t2; 4012 }(); 4013 }).call(this), function() { 4014 var t2 = function(t3, e3) { 4015 function i2() { 4016 this.constructor = t3; 4017 } 4018 for (var o2 in e3) 4019 n2.call(e3, o2) && (t3[o2] = e3[o2]); 4020 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 4021 }, n2 = {}.hasOwnProperty; 4022 e2.Object = function(n3) { 4023 function i2() { 4024 this.id = ++o2; 4025 } 4026 var o2; 4027 return t2(i2, n3), o2 = 0, i2.fromJSONString = function(t3) { 4028 return this.fromJSON(JSON.parse(t3)); 4029 }, i2.prototype.hasSameConstructorAs = function(t3) { 4030 return this.constructor === (t3 != null ? t3.constructor : void 0); 4031 }, i2.prototype.isEqualTo = function(t3) { 4032 return this === t3; 4033 }, i2.prototype.inspect = function() { 4034 var t3, e3, n4; 4035 return t3 = function() { 4036 var t4, i3, o3; 4037 i3 = (t4 = this.contentsForInspection()) != null ? t4 : {}, o3 = []; 4038 for (e3 in i3) 4039 n4 = i3[e3], o3.push(e3 + "=" + n4); 4040 return o3; 4041 }.call(this), "#<" + this.constructor.name + ":" + this.id + (t3.length ? " " + t3.join(", ") : "") + ">"; 4042 }, i2.prototype.contentsForInspection = function() { 4043 }, i2.prototype.toJSONString = function() { 4044 return JSON.stringify(this); 4045 }, i2.prototype.toUTF16String = function() { 4046 return e2.UTF16String.box(this); 4047 }, i2.prototype.getCacheKey = function() { 4048 return this.id.toString(); 4049 }, i2; 4050 }(e2.BasicObject); 4051 }.call(this), function() { 4052 e2.extend = function(t2) { 4053 var e3, n2; 4054 for (e3 in t2) 4055 n2 = t2[e3], this[e3] = n2; 4056 return this; 4057 }; 4058 }.call(this), function() { 4059 e2.extend({ defer: function(t2) { 4060 return setTimeout(t2, 1); 4061 } }); 4062 }.call(this), function() { 4063 var t2, n2; 4064 e2.extend({ normalizeSpaces: function(t3) { 4065 return t3.replace(RegExp("" + e2.ZERO_WIDTH_SPACE, "g"), "").replace(RegExp("" + e2.NON_BREAKING_SPACE, "g"), " "); 4066 }, normalizeNewlines: function(t3) { 4067 return t3.replace(/\r\n/g, "\n"); 4068 }, breakableWhitespacePattern: RegExp("[^\\S" + e2.NON_BREAKING_SPACE + "]"), squishBreakableWhitespace: function(t3) { 4069 return t3.replace(RegExp("" + e2.breakableWhitespacePattern.source, "g"), " ").replace(/\ {2,}/g, " "); 4070 }, summarizeStringChange: function(t3, i2) { 4071 var o2, r3, s2, a2; 4072 return t3 = e2.UTF16String.box(t3), i2 = e2.UTF16String.box(i2), i2.length < t3.length ? (r3 = n2(t3, i2), a2 = r3[0], o2 = r3[1]) : (s2 = n2(i2, t3), o2 = s2[0], a2 = s2[1]), { added: o2, removed: a2 }; 4073 } }), n2 = function(n3, i2) { 4074 var o2, r3, s2, a2, u; 4075 return n3.isEqualTo(i2) ? ["", ""] : (r3 = t2(n3, i2), a2 = r3.utf16String.length, s2 = a2 ? (u = r3.offset, r3, o2 = n3.codepoints.slice(0, u).concat(n3.codepoints.slice(u + a2)), t2(i2, e2.UTF16String.fromCodepoints(o2))) : t2(i2, n3), [r3.utf16String.toString(), s2.utf16String.toString()]); 4076 }, t2 = function(t3, e3) { 4077 var n3, i2, o2; 4078 for (n3 = 0, i2 = t3.length, o2 = e3.length; i2 > n3 && t3.charAt(n3).isEqualTo(e3.charAt(n3)); ) 4079 n3++; 4080 for (; i2 > n3 + 1 && t3.charAt(i2 - 1).isEqualTo(e3.charAt(o2 - 1)); ) 4081 i2--, o2--; 4082 return { utf16String: t3.slice(n3, i2), offset: n3 }; 4083 }; 4084 }.call(this), function() { 4085 e2.extend({ copyObject: function(t2) { 4086 var e3, n2, i2; 4087 t2 == null && (t2 = {}), n2 = {}; 4088 for (e3 in t2) 4089 i2 = t2[e3], n2[e3] = i2; 4090 return n2; 4091 }, objectsAreEqual: function(t2, e3) { 4092 var n2, i2; 4093 if (t2 == null && (t2 = {}), e3 == null && (e3 = {}), Object.keys(t2).length !== Object.keys(e3).length) 4094 return false; 4095 for (n2 in t2) 4096 if (i2 = t2[n2], i2 !== e3[n2]) 4097 return false; 4098 return true; 4099 } }); 4100 }.call(this), function() { 4101 var t2 = [].slice; 4102 e2.extend({ arraysAreEqual: function(t3, e3) { 4103 var n2, i2, o2, r3; 4104 if (t3 == null && (t3 = []), e3 == null && (e3 = []), t3.length !== e3.length) 4105 return false; 4106 for (i2 = n2 = 0, o2 = t3.length; o2 > n2; i2 = ++n2) 4107 if (r3 = t3[i2], r3 !== e3[i2]) 4108 return false; 4109 return true; 4110 }, arrayStartsWith: function(t3, n2) { 4111 return t3 == null && (t3 = []), n2 == null && (n2 = []), e2.arraysAreEqual(t3.slice(0, n2.length), n2); 4112 }, spliceArray: function() { 4113 var e3, n2, i2; 4114 return n2 = arguments[0], e3 = 2 <= arguments.length ? t2.call(arguments, 1) : [], i2 = n2.slice(0), i2.splice.apply(i2, e3), i2; 4115 }, summarizeArrayChange: function(t3, e3) { 4116 var n2, i2, o2, r3, s2, a2, u, c, l2, h2, p; 4117 for (t3 == null && (t3 = []), e3 == null && (e3 = []), n2 = [], h2 = [], o2 = /* @__PURE__ */ new Set(), r3 = 0, u = t3.length; u > r3; r3++) 4118 p = t3[r3], o2.add(p); 4119 for (i2 = /* @__PURE__ */ new Set(), s2 = 0, c = e3.length; c > s2; s2++) 4120 p = e3[s2], i2.add(p), o2.has(p) || n2.push(p); 4121 for (a2 = 0, l2 = t3.length; l2 > a2; a2++) 4122 p = t3[a2], i2.has(p) || h2.push(p); 4123 return { added: n2, removed: h2 }; 4124 } }); 4125 }.call(this), function() { 4126 var t2, n2, i2, o2; 4127 t2 = null, n2 = null, o2 = null, i2 = null, e2.extend({ getAllAttributeNames: function() { 4128 return t2 != null ? t2 : t2 = e2.getTextAttributeNames().concat(e2.getBlockAttributeNames()); 4129 }, getBlockConfig: function(t3) { 4130 return e2.config.blockAttributes[t3]; 4131 }, getBlockAttributeNames: function() { 4132 return n2 != null ? n2 : n2 = Object.keys(e2.config.blockAttributes); 4133 }, getTextConfig: function(t3) { 4134 return e2.config.textAttributes[t3]; 4135 }, getTextAttributeNames: function() { 4136 return o2 != null ? o2 : o2 = Object.keys(e2.config.textAttributes); 4137 }, getListAttributeNames: function() { 4138 var t3, n3; 4139 return i2 != null ? i2 : i2 = function() { 4140 var i3, o3; 4141 i3 = e2.config.blockAttributes, o3 = []; 4142 for (t3 in i3) 4143 n3 = i3[t3].listAttribute, n3 != null && o3.push(n3); 4144 return o3; 4145 }(); 4146 } }); 4147 }.call(this), function() { 4148 var t2, n2, i2, o2, r3, s2 = [].indexOf || function(t3) { 4149 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 4150 if (e3 in this && this[e3] === t3) 4151 return e3; 4152 return -1; 4153 }; 4154 t2 = document.documentElement, n2 = (i2 = (o2 = (r3 = t2.matchesSelector) != null ? r3 : t2.webkitMatchesSelector) != null ? o2 : t2.msMatchesSelector) != null ? i2 : t2.mozMatchesSelector, e2.extend({ handleEvent: function(n3, i3) { 4155 var o3, r4, s3, a2, u, c, l2, h2, p, d, f, g; 4156 return h2 = i3 != null ? i3 : {}, c = h2.onElement, u = h2.matchingSelector, g = h2.withCallback, a2 = h2.inPhase, l2 = h2.preventDefault, d = h2.times, r4 = c != null ? c : t2, p = u, o3 = g, f = a2 === "capturing", s3 = function(t3) { 4157 var n4; 4158 return d != null && --d === 0 && s3.destroy(), n4 = e2.findClosestElementFromNode(t3.target, { matchingSelector: p }), n4 != null && (g != null && g.call(n4, t3, n4), l2) ? t3.preventDefault() : void 0; 4159 }, s3.destroy = function() { 4160 return r4.removeEventListener(n3, s3, f); 4161 }, r4.addEventListener(n3, s3, f), s3; 4162 }, handleEventOnce: function(t3, n3) { 4163 return n3 == null && (n3 = {}), n3.times = 1, e2.handleEvent(t3, n3); 4164 }, triggerEvent: function(n3, i3) { 4165 var o3, r4, s3, a2, u, c, l2; 4166 return l2 = i3 != null ? i3 : {}, c = l2.onElement, r4 = l2.bubbles, s3 = l2.cancelable, o3 = l2.attributes, a2 = c != null ? c : t2, r4 = r4 !== false, s3 = s3 !== false, u = document.createEvent("Events"), u.initEvent(n3, r4, s3), o3 != null && e2.extend.call(u, o3), a2.dispatchEvent(u); 4167 }, elementMatchesSelector: function(t3, e3) { 4168 return (t3 != null ? t3.nodeType : void 0) === 1 ? n2.call(t3, e3) : void 0; 4169 }, findClosestElementFromNode: function(t3, n3) { 4170 var i3, o3, r4; 4171 for (o3 = n3 != null ? n3 : {}, i3 = o3.matchingSelector, r4 = o3.untilNode; t3 != null && t3.nodeType !== Node.ELEMENT_NODE; ) 4172 t3 = t3.parentNode; 4173 if (t3 != null) { 4174 if (i3 == null) 4175 return t3; 4176 if (t3.closest && r4 == null) 4177 return t3.closest(i3); 4178 for (; t3 && t3 !== r4; ) { 4179 if (e2.elementMatchesSelector(t3, i3)) 4180 return t3; 4181 t3 = t3.parentNode; 4182 } 4183 } 4184 }, findInnerElement: function(t3) { 4185 for (; t3 != null ? t3.firstElementChild : void 0; ) 4186 t3 = t3.firstElementChild; 4187 return t3; 4188 }, innerElementIsActive: function(t3) { 4189 return document.activeElement !== t3 && e2.elementContainsNode(t3, document.activeElement); 4190 }, elementContainsNode: function(t3, e3) { 4191 if (t3 && e3) 4192 for (; e3; ) { 4193 if (e3 === t3) 4194 return true; 4195 e3 = e3.parentNode; 4196 } 4197 }, findNodeFromContainerAndOffset: function(t3, e3) { 4198 var n3; 4199 if (t3) 4200 return t3.nodeType === Node.TEXT_NODE ? t3 : e3 === 0 ? (n3 = t3.firstChild) != null ? n3 : t3 : t3.childNodes.item(e3 - 1); 4201 }, findElementFromContainerAndOffset: function(t3, n3) { 4202 var i3; 4203 return i3 = e2.findNodeFromContainerAndOffset(t3, n3), e2.findClosestElementFromNode(i3); 4204 }, findChildIndexOfNode: function(t3) { 4205 var e3; 4206 if (t3 != null ? t3.parentNode : void 0) { 4207 for (e3 = 0; t3 = t3.previousSibling; ) 4208 e3++; 4209 return e3; 4210 } 4211 }, removeNode: function(t3) { 4212 var e3; 4213 return t3 != null && (e3 = t3.parentNode) != null ? e3.removeChild(t3) : void 0; 4214 }, walkTree: function(t3, e3) { 4215 var n3, i3, o3, r4, s3; 4216 return o3 = e3 != null ? e3 : {}, i3 = o3.onlyNodesOfType, r4 = o3.usingFilter, n3 = o3.expandEntityReferences, s3 = function() { 4217 switch (i3) { 4218 case "element": 4219 return NodeFilter.SHOW_ELEMENT; 4220 case "text": 4221 return NodeFilter.SHOW_TEXT; 4222 case "comment": 4223 return NodeFilter.SHOW_COMMENT; 4224 default: 4225 return NodeFilter.SHOW_ALL; 4226 } 4227 }(), document.createTreeWalker(t3, s3, r4 != null ? r4 : null, n3 === true); 4228 }, tagName: function(t3) { 4229 var e3; 4230 return t3 != null && (e3 = t3.tagName) != null ? e3.toLowerCase() : void 0; 4231 }, makeElement: function(t3, e3) { 4232 var n3, i3, o3, r4, s3, a2, u, c, l2, h2, p, d, f, g; 4233 if (e3 == null && (e3 = {}), typeof t3 == "object" ? (e3 = t3, t3 = e3.tagName) : e3 = { attributes: e3 }, o3 = document.createElement(t3), e3.editable != null && (e3.attributes == null && (e3.attributes = {}), e3.attributes.contenteditable = e3.editable), e3.attributes) { 4234 l2 = e3.attributes; 4235 for (a2 in l2) 4236 g = l2[a2], o3.setAttribute(a2, g); 4237 } 4238 if (e3.style) { 4239 h2 = e3.style; 4240 for (a2 in h2) 4241 g = h2[a2], o3.style[a2] = g; 4242 } 4243 if (e3.data) { 4244 p = e3.data; 4245 for (a2 in p) 4246 g = p[a2], o3.dataset[a2] = g; 4247 } 4248 if (e3.className) 4249 for (d = e3.className.split(" "), r4 = 0, u = d.length; u > r4; r4++) 4250 i3 = d[r4], o3.classList.add(i3); 4251 if (e3.textContent && (o3.textContent = e3.textContent), e3.childNodes) 4252 for (f = [].concat(e3.childNodes), s3 = 0, c = f.length; c > s3; s3++) 4253 n3 = f[s3], o3.appendChild(n3); 4254 return o3; 4255 }, getBlockTagNames: function() { 4256 var t3, n3; 4257 return e2.blockTagNames != null ? e2.blockTagNames : e2.blockTagNames = function() { 4258 var i3, o3; 4259 i3 = e2.config.blockAttributes, o3 = []; 4260 for (t3 in i3) 4261 n3 = i3[t3].tagName, n3 && o3.push(n3); 4262 return o3; 4263 }(); 4264 }, nodeIsBlockContainer: function(t3) { 4265 return e2.nodeIsBlockStartComment(t3 != null ? t3.firstChild : void 0); 4266 }, nodeProbablyIsBlockContainer: function(t3) { 4267 var n3, i3; 4268 return n3 = e2.tagName(t3), s2.call(e2.getBlockTagNames(), n3) >= 0 && (i3 = e2.tagName(t3.firstChild), s2.call(e2.getBlockTagNames(), i3) < 0); 4269 }, nodeIsBlockStart: function(t3, n3) { 4270 var i3; 4271 return i3 = (n3 != null ? n3 : { strict: true }).strict, i3 ? e2.nodeIsBlockStartComment(t3) : e2.nodeIsBlockStartComment(t3) || !e2.nodeIsBlockStartComment(t3.firstChild) && e2.nodeProbablyIsBlockContainer(t3); 4272 }, nodeIsBlockStartComment: function(t3) { 4273 return e2.nodeIsCommentNode(t3) && (t3 != null ? t3.data : void 0) === "block"; 4274 }, nodeIsCommentNode: function(t3) { 4275 return (t3 != null ? t3.nodeType : void 0) === Node.COMMENT_NODE; 4276 }, nodeIsCursorTarget: function(t3, n3) { 4277 var i3; 4278 return i3 = (n3 != null ? n3 : {}).name, t3 ? e2.nodeIsTextNode(t3) ? t3.data === e2.ZERO_WIDTH_SPACE ? i3 ? t3.parentNode.dataset.trixCursorTarget === i3 : true : void 0 : e2.nodeIsCursorTarget(t3.firstChild) : void 0; 4279 }, nodeIsAttachmentElement: function(t3) { 4280 return e2.elementMatchesSelector(t3, e2.AttachmentView.attachmentSelector); 4281 }, nodeIsEmptyTextNode: function(t3) { 4282 return e2.nodeIsTextNode(t3) && (t3 != null ? t3.data : void 0) === ""; 4283 }, nodeIsTextNode: function(t3) { 4284 return (t3 != null ? t3.nodeType : void 0) === Node.TEXT_NODE; 4285 } }); 4286 }.call(this), function() { 4287 var t2, n2, i2, o2, r3; 4288 t2 = e2.copyObject, o2 = e2.objectsAreEqual, e2.extend({ normalizeRange: i2 = function(t3) { 4289 var e3; 4290 if (t3 != null) 4291 return Array.isArray(t3) || (t3 = [t3, t3]), [n2(t3[0]), n2((e3 = t3[1]) != null ? e3 : t3[0])]; 4292 }, rangeIsCollapsed: function(t3) { 4293 var e3, n3, o3; 4294 if (t3 != null) 4295 return n3 = i2(t3), o3 = n3[0], e3 = n3[1], r3(o3, e3); 4296 }, rangesAreEqual: function(t3, e3) { 4297 var n3, o3, s2, a2, u, c; 4298 if (t3 != null && e3 != null) 4299 return s2 = i2(t3), o3 = s2[0], n3 = s2[1], a2 = i2(e3), c = a2[0], u = a2[1], r3(o3, c) && r3(n3, u); 4300 } }), n2 = function(e3) { 4301 return typeof e3 == "number" ? e3 : t2(e3); 4302 }, r3 = function(t3, e3) { 4303 return typeof t3 == "number" ? t3 === e3 : o2(t3, e3); 4304 }; 4305 }.call(this), function() { 4306 var t2, n2, i2, o2, r3, s2, a2; 4307 e2.registerElement = function(t3, e3) { 4308 var n3, i3; 4309 return e3 == null && (e3 = {}), t3 = t3.toLowerCase(), e3 = a2(e3), i3 = s2(e3), (n3 = i3.defaultCSS) && (delete i3.defaultCSS, o2(n3, t3)), r3(t3, i3); 4310 }, o2 = function(t3, e3) { 4311 var n3; 4312 return n3 = i2(e3), n3.textContent = t3.replace(/%t/g, e3); 4313 }, i2 = function(e3) { 4314 var n3, i3; 4315 return n3 = document.createElement("style"), n3.setAttribute("type", "text/css"), n3.setAttribute("data-tag-name", e3.toLowerCase()), (i3 = t2()) && n3.setAttribute("nonce", i3), document.head.insertBefore(n3, document.head.firstChild), n3; 4316 }, t2 = function() { 4317 var t3; 4318 return (t3 = n2("trix-csp-nonce") || n2("csp-nonce")) ? t3.getAttribute("content") : void 0; 4319 }, n2 = function(t3) { 4320 return document.head.querySelector("meta[name=" + t3 + "]"); 4321 }, s2 = function(t3) { 4322 var e3, n3, i3; 4323 n3 = {}; 4324 for (e3 in t3) 4325 i3 = t3[e3], n3[e3] = typeof i3 == "function" ? { value: i3 } : i3; 4326 return n3; 4327 }, a2 = function() { 4328 var t3; 4329 return t3 = function(t4) { 4330 var e3, n3, i3, o3, r4; 4331 for (e3 = {}, r4 = ["initialize", "connect", "disconnect"], n3 = 0, o3 = r4.length; o3 > n3; n3++) 4332 i3 = r4[n3], e3[i3] = t4[i3], delete t4[i3]; 4333 return e3; 4334 }, window.customElements ? function(e3) { 4335 var n3, i3, o3, r4, s3; 4336 return s3 = t3(e3), o3 = s3.initialize, n3 = s3.connect, i3 = s3.disconnect, o3 && (r4 = n3, n3 = function() { 4337 return this.initialized || (this.initialized = true, o3.call(this)), r4 != null ? r4.call(this) : void 0; 4338 }), n3 && (e3.connectedCallback = n3), i3 && (e3.disconnectedCallback = i3), e3; 4339 } : function(e3) { 4340 var n3, i3, o3, r4; 4341 return r4 = t3(e3), o3 = r4.initialize, n3 = r4.connect, i3 = r4.disconnect, o3 && (e3.createdCallback = o3), n3 && (e3.attachedCallback = n3), i3 && (e3.detachedCallback = i3), e3; 4342 }; 4343 }(), r3 = function() { 4344 return window.customElements ? function(t3, e3) { 4345 var n3; 4346 return n3 = function() { 4347 return typeof Reflect == "object" ? Reflect.construct(HTMLElement, [], n3) : HTMLElement.apply(this); 4348 }, Object.setPrototypeOf(n3.prototype, HTMLElement.prototype), Object.setPrototypeOf(n3, HTMLElement), Object.defineProperties(n3.prototype, e3), window.customElements.define(t3, n3), n3; 4349 } : function(t3, e3) { 4350 var n3, i3; 4351 return i3 = Object.create(HTMLElement.prototype, e3), n3 = document.registerElement(t3, { prototype: i3 }), Object.defineProperty(i3, "constructor", { value: n3 }), n3; 4352 }; 4353 }(); 4354 }.call(this), function() { 4355 var t2, n2; 4356 e2.extend({ getDOMSelection: function() { 4357 var t3; 4358 return t3 = window.getSelection(), t3.rangeCount > 0 ? t3 : void 0; 4359 }, getDOMRange: function() { 4360 var n3, i2; 4361 return (n3 = (i2 = e2.getDOMSelection()) != null ? i2.getRangeAt(0) : void 0) && !t2(n3) ? n3 : void 0; 4362 }, setDOMRange: function(t3) { 4363 var n3; 4364 return n3 = window.getSelection(), n3.removeAllRanges(), n3.addRange(t3), e2.selectionChangeObserver.update(); 4365 } }), t2 = function(t3) { 4366 return n2(t3.startContainer) || n2(t3.endContainer); 4367 }, n2 = function(t3) { 4368 return !Object.getPrototypeOf(t3); 4369 }; 4370 }.call(this), function() { 4371 var t2; 4372 t2 = { "application/x-trix-feature-detection": "test" }, e2.extend({ dataTransferIsPlainText: function(t3) { 4373 var e3, n2, i2; 4374 return i2 = t3.getData("text/plain"), n2 = t3.getData("text/html"), i2 && n2 ? (e3 = new DOMParser().parseFromString(n2, "text/html").body, e3.textContent === i2 ? !e3.querySelector("*") : void 0) : i2 != null ? i2.length : void 0; 4375 }, dataTransferIsWritable: function(e3) { 4376 var n2, i2; 4377 if ((e3 != null ? e3.setData : void 0) != null) { 4378 for (n2 in t2) 4379 if (i2 = t2[n2], !function() { 4380 try { 4381 return e3.setData(n2, i2), e3.getData(n2) === i2; 4382 } catch (t3) { 4383 } 4384 }()) 4385 return; 4386 return true; 4387 } 4388 }, keyEventIsKeyboardCommand: function() { 4389 return /Mac|^iP/.test(navigator.platform) ? function(t3) { 4390 return t3.metaKey; 4391 } : function(t3) { 4392 return t3.ctrlKey; 4393 }; 4394 }() }); 4395 }.call(this), function() { 4396 e2.extend({ RTL_PATTERN: /[\u05BE\u05C0\u05C3\u05D0-\u05EA\u05F0-\u05F4\u061B\u061F\u0621-\u063A\u0640-\u064A\u066D\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D5\u06E5\u06E6\u200F\u202B\u202E\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE72\uFE74\uFE76-\uFEFC]/, getDirection: function() { 4397 var t2, n2, i2, o2; 4398 return n2 = e2.makeElement("input", { dir: "auto", name: "x", dirName: "x.dir" }), t2 = e2.makeElement("form"), t2.appendChild(n2), i2 = function() { 4399 try { 4400 return new FormData(t2).has(n2.dirName); 4401 } catch (e3) { 4402 } 4403 }(), o2 = function() { 4404 try { 4405 return n2.matches(":dir(ltr),:dir(rtl)"); 4406 } catch (t3) { 4407 } 4408 }(), i2 ? function(e3) { 4409 return n2.value = e3, new FormData(t2).get(n2.dirName); 4410 } : o2 ? function(t3) { 4411 return n2.value = t3, n2.matches(":dir(rtl)") ? "rtl" : "ltr"; 4412 } : function(t3) { 4413 var n3; 4414 return n3 = t3.trim().charAt(0), e2.RTL_PATTERN.test(n3) ? "rtl" : "ltr"; 4415 }; 4416 }() }); 4417 }.call(this), function() { 4418 }.call(this), function() { 4419 var t2, n2 = function(t3, e3) { 4420 function n3() { 4421 this.constructor = t3; 4422 } 4423 for (var o2 in e3) 4424 i2.call(e3, o2) && (t3[o2] = e3[o2]); 4425 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 4426 }, i2 = {}.hasOwnProperty; 4427 t2 = e2.arraysAreEqual, e2.Hash = function(i3) { 4428 function o2(t3) { 4429 t3 == null && (t3 = {}), this.values = s2(t3), o2.__super__.constructor.apply(this, arguments); 4430 } 4431 var r3, s2, a2, u, c; 4432 return n2(o2, i3), o2.fromCommonAttributesOfObjects = function(t3) { 4433 var e3, n3, i4, o3, s3, a3; 4434 if (t3 == null && (t3 = []), !t3.length) 4435 return new this(); 4436 for (e3 = r3(t3[0]), i4 = e3.getKeys(), a3 = t3.slice(1), n3 = 0, o3 = a3.length; o3 > n3; n3++) 4437 s3 = a3[n3], i4 = e3.getKeysCommonToHash(r3(s3)), e3 = e3.slice(i4); 4438 return e3; 4439 }, o2.box = function(t3) { 4440 return r3(t3); 4441 }, o2.prototype.add = function(t3, e3) { 4442 return this.merge(u(t3, e3)); 4443 }, o2.prototype.remove = function(t3) { 4444 return new e2.Hash(s2(this.values, t3)); 4445 }, o2.prototype.get = function(t3) { 4446 return this.values[t3]; 4447 }, o2.prototype.has = function(t3) { 4448 return t3 in this.values; 4449 }, o2.prototype.merge = function(t3) { 4450 return new e2.Hash(a2(this.values, c(t3))); 4451 }, o2.prototype.slice = function(t3) { 4452 var n3, i4, o3, r4; 4453 for (r4 = {}, n3 = 0, o3 = t3.length; o3 > n3; n3++) 4454 i4 = t3[n3], this.has(i4) && (r4[i4] = this.values[i4]); 4455 return new e2.Hash(r4); 4456 }, o2.prototype.getKeys = function() { 4457 return Object.keys(this.values); 4458 }, o2.prototype.getKeysCommonToHash = function(t3) { 4459 var e3, n3, i4, o3, s3; 4460 for (t3 = r3(t3), o3 = this.getKeys(), s3 = [], e3 = 0, i4 = o3.length; i4 > e3; e3++) 4461 n3 = o3[e3], this.values[n3] === t3.values[n3] && s3.push(n3); 4462 return s3; 4463 }, o2.prototype.isEqualTo = function(e3) { 4464 return t2(this.toArray(), r3(e3).toArray()); 4465 }, o2.prototype.isEmpty = function() { 4466 return this.getKeys().length === 0; 4467 }, o2.prototype.toArray = function() { 4468 var t3, e3, n3; 4469 return (this.array != null ? this.array : this.array = function() { 4470 var i4; 4471 e3 = [], i4 = this.values; 4472 for (t3 in i4) 4473 n3 = i4[t3], e3.push(t3, n3); 4474 return e3; 4475 }.call(this)).slice(0); 4476 }, o2.prototype.toObject = function() { 4477 return s2(this.values); 4478 }, o2.prototype.toJSON = function() { 4479 return this.toObject(); 4480 }, o2.prototype.contentsForInspection = function() { 4481 return { values: JSON.stringify(this.values) }; 4482 }, u = function(t3, e3) { 4483 var n3; 4484 return n3 = {}, n3[t3] = e3, n3; 4485 }, a2 = function(t3, e3) { 4486 var n3, i4, o3; 4487 i4 = s2(t3); 4488 for (n3 in e3) 4489 o3 = e3[n3], i4[n3] = o3; 4490 return i4; 4491 }, s2 = function(t3, e3) { 4492 var n3, i4, o3, r4, s3; 4493 for (r4 = {}, s3 = Object.keys(t3).sort(), n3 = 0, o3 = s3.length; o3 > n3; n3++) 4494 i4 = s3[n3], i4 !== e3 && (r4[i4] = t3[i4]); 4495 return r4; 4496 }, r3 = function(t3) { 4497 return t3 instanceof e2.Hash ? t3 : new e2.Hash(t3); 4498 }, c = function(t3) { 4499 return t3 instanceof e2.Hash ? t3.values : t3; 4500 }, o2; 4501 }(e2.Object); 4502 }.call(this), function() { 4503 e2.ObjectGroup = function() { 4504 function t2(t3, e3) { 4505 var n2, i2; 4506 this.objects = t3 != null ? t3 : [], i2 = e3.depth, n2 = e3.asTree, n2 && (this.depth = i2, this.objects = this.constructor.groupObjects(this.objects, { asTree: n2, depth: this.depth + 1 })); 4507 } 4508 return t2.groupObjects = function(t3, e3) { 4509 var n2, i2, o2, r3, s2, a2, u, c, l2; 4510 for (t3 == null && (t3 = []), l2 = e3 != null ? e3 : {}, o2 = l2.depth, n2 = l2.asTree, n2 && o2 == null && (o2 = 0), c = [], s2 = 0, a2 = t3.length; a2 > s2; s2++) { 4511 if (u = t3[s2], r3) { 4512 if ((typeof u.canBeGrouped == "function" ? u.canBeGrouped(o2) : void 0) && (typeof (i2 = r3[r3.length - 1]).canBeGroupedWith == "function" ? i2.canBeGroupedWith(u, o2) : void 0)) { 4513 r3.push(u); 4514 continue; 4515 } 4516 c.push(new this(r3, { depth: o2, asTree: n2 })), r3 = null; 4517 } 4518 (typeof u.canBeGrouped == "function" ? u.canBeGrouped(o2) : void 0) ? r3 = [u] : c.push(u); 4519 } 4520 return r3 && c.push(new this(r3, { depth: o2, asTree: n2 })), c; 4521 }, t2.prototype.getObjects = function() { 4522 return this.objects; 4523 }, t2.prototype.getDepth = function() { 4524 return this.depth; 4525 }, t2.prototype.getCacheKey = function() { 4526 var t3, e3, n2, i2, o2; 4527 for (e3 = ["objectGroup"], o2 = this.getObjects(), t3 = 0, n2 = o2.length; n2 > t3; t3++) 4528 i2 = o2[t3], e3.push(i2.getCacheKey()); 4529 return e3.join("/"); 4530 }, t2; 4531 }(); 4532 }.call(this), function() { 4533 var t2 = function(t3, e3) { 4534 function i2() { 4535 this.constructor = t3; 4536 } 4537 for (var o2 in e3) 4538 n2.call(e3, o2) && (t3[o2] = e3[o2]); 4539 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 4540 }, n2 = {}.hasOwnProperty; 4541 e2.ObjectMap = function(e3) { 4542 function n3(t3) { 4543 var e4, n4, i2, o2, r3; 4544 for (t3 == null && (t3 = []), this.objects = {}, i2 = 0, o2 = t3.length; o2 > i2; i2++) 4545 r3 = t3[i2], n4 = JSON.stringify(r3), (e4 = this.objects)[n4] == null && (e4[n4] = r3); 4546 } 4547 return t2(n3, e3), n3.prototype.find = function(t3) { 4548 var e4; 4549 return e4 = JSON.stringify(t3), this.objects[e4]; 4550 }, n3; 4551 }(e2.BasicObject); 4552 }.call(this), function() { 4553 e2.ElementStore = function() { 4554 function t2(t3) { 4555 this.reset(t3); 4556 } 4557 var e3; 4558 return t2.prototype.add = function(t3) { 4559 var n2; 4560 return n2 = e3(t3), this.elements[n2] = t3; 4561 }, t2.prototype.remove = function(t3) { 4562 var n2, i2; 4563 return n2 = e3(t3), (i2 = this.elements[n2]) ? (delete this.elements[n2], i2) : void 0; 4564 }, t2.prototype.reset = function(t3) { 4565 var e4, n2, i2; 4566 for (t3 == null && (t3 = []), this.elements = {}, n2 = 0, i2 = t3.length; i2 > n2; n2++) 4567 e4 = t3[n2], this.add(e4); 4568 return t3; 4569 }, e3 = function(t3) { 4570 return t3.dataset.trixStoreKey; 4571 }, t2; 4572 }(); 4573 }.call(this), function() { 4574 }.call(this), function() { 4575 var t2 = function(t3, e3) { 4576 function i2() { 4577 this.constructor = t3; 4578 } 4579 for (var o2 in e3) 4580 n2.call(e3, o2) && (t3[o2] = e3[o2]); 4581 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 4582 }, n2 = {}.hasOwnProperty; 4583 e2.Operation = function(e3) { 4584 function n3() { 4585 return n3.__super__.constructor.apply(this, arguments); 4586 } 4587 return t2(n3, e3), n3.prototype.isPerforming = function() { 4588 return this.performing === true; 4589 }, n3.prototype.hasPerformed = function() { 4590 return this.performed === true; 4591 }, n3.prototype.hasSucceeded = function() { 4592 return this.performed && this.succeeded; 4593 }, n3.prototype.hasFailed = function() { 4594 return this.performed && !this.succeeded; 4595 }, n3.prototype.getPromise = function() { 4596 return this.promise != null ? this.promise : this.promise = new Promise(function(t3) { 4597 return function(e4, n4) { 4598 return t3.performing = true, t3.perform(function(i2, o2) { 4599 return t3.succeeded = i2, t3.performing = false, t3.performed = true, t3.succeeded ? e4(o2) : n4(o2); 4600 }); 4601 }; 4602 }(this)); 4603 }, n3.prototype.perform = function(t3) { 4604 return t3(false); 4605 }, n3.prototype.release = function() { 4606 var t3; 4607 return (t3 = this.promise) != null && typeof t3.cancel == "function" && t3.cancel(), this.promise = null, this.performing = null, this.performed = null, this.succeeded = null; 4608 }, n3.proxyMethod("getPromise().then"), n3.proxyMethod("getPromise().catch"), n3; 4609 }(e2.BasicObject); 4610 }.call(this), function() { 4611 var t2, n2, i2, o2, r3, s2 = function(t3, e3) { 4612 function n3() { 4613 this.constructor = t3; 4614 } 4615 for (var i3 in e3) 4616 a2.call(e3, i3) && (t3[i3] = e3[i3]); 4617 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 4618 }, a2 = {}.hasOwnProperty; 4619 e2.UTF16String = function(t3) { 4620 function e3(t4, e4) { 4621 this.ucs2String = t4, this.codepoints = e4, this.length = this.codepoints.length, this.ucs2Length = this.ucs2String.length; 4622 } 4623 return s2(e3, t3), e3.box = function(t4) { 4624 return t4 == null && (t4 = ""), t4 instanceof this ? t4 : this.fromUCS2String(t4 != null ? t4.toString() : void 0); 4625 }, e3.fromUCS2String = function(t4) { 4626 return new this(t4, o2(t4)); 4627 }, e3.fromCodepoints = function(t4) { 4628 return new this(r3(t4), t4); 4629 }, e3.prototype.offsetToUCS2Offset = function(t4) { 4630 return r3(this.codepoints.slice(0, Math.max(0, t4))).length; 4631 }, e3.prototype.offsetFromUCS2Offset = function(t4) { 4632 return o2(this.ucs2String.slice(0, Math.max(0, t4))).length; 4633 }, e3.prototype.slice = function() { 4634 var t4; 4635 return this.constructor.fromCodepoints((t4 = this.codepoints).slice.apply(t4, arguments)); 4636 }, e3.prototype.charAt = function(t4) { 4637 return this.slice(t4, t4 + 1); 4638 }, e3.prototype.isEqualTo = function(t4) { 4639 return this.constructor.box(t4).ucs2String === this.ucs2String; 4640 }, e3.prototype.toJSON = function() { 4641 return this.ucs2String; 4642 }, e3.prototype.getCacheKey = function() { 4643 return this.ucs2String; 4644 }, e3.prototype.toString = function() { 4645 return this.ucs2String; 4646 }, e3; 4647 }(e2.BasicObject), t2 = (typeof Array.from == "function" ? Array.from("\u{1F47C}").length : void 0) === 1, n2 = (typeof " ".codePointAt == "function" ? " ".codePointAt(0) : void 0) != null, i2 = (typeof String.fromCodePoint == "function" ? String.fromCodePoint(32, 128124) : void 0) === " \u{1F47C}", o2 = t2 && n2 ? function(t3) { 4648 return Array.from(t3).map(function(t4) { 4649 return t4.codePointAt(0); 4650 }); 4651 } : function(t3) { 4652 var e3, n3, i3, o3, r4; 4653 for (o3 = [], e3 = 0, i3 = t3.length; i3 > e3; ) 4654 r4 = t3.charCodeAt(e3++), r4 >= 55296 && 56319 >= r4 && i3 > e3 && (n3 = t3.charCodeAt(e3++), (64512 & n3) === 56320 ? r4 = ((1023 & r4) << 10) + (1023 & n3) + 65536 : e3--), o3.push(r4); 4655 return o3; 4656 }, r3 = i2 ? function(t3) { 4657 return String.fromCodePoint.apply(String, t3); 4658 } : function(t3) { 4659 var e3, n3, i3; 4660 return e3 = function() { 4661 var e4, o3, r4; 4662 for (r4 = [], e4 = 0, o3 = t3.length; o3 > e4; e4++) 4663 i3 = t3[e4], n3 = "", i3 > 65535 && (i3 -= 65536, n3 += String.fromCharCode(i3 >>> 10 & 1023 | 55296), i3 = 56320 | 1023 & i3), r4.push(n3 + String.fromCharCode(i3)); 4664 return r4; 4665 }(), e3.join(""); 4666 }; 4667 }.call(this), function() { 4668 }.call(this), function() { 4669 }.call(this), function() { 4670 e2.config.lang = { attachFiles: "Attach Files", bold: "Bold", bullets: "Bullets", "byte": "Byte", bytes: "Bytes", captionPlaceholder: "Add a caption\u2026", code: "Code", heading1: "Heading", indent: "Increase Level", italic: "Italic", link: "Link", numbers: "Numbers", outdent: "Decrease Level", quote: "Quote", redo: "Redo", remove: "Remove", strike: "Strikethrough", undo: "Undo", unlink: "Unlink", url: "URL", urlPlaceholder: "Enter a URL\u2026", GB: "GB", KB: "KB", MB: "MB", PB: "PB", TB: "TB" }; 4671 }.call(this), function() { 4672 e2.config.css = { attachment: "attachment", attachmentCaption: "attachment__caption", attachmentCaptionEditor: "attachment__caption-editor", attachmentMetadata: "attachment__metadata", attachmentMetadataContainer: "attachment__metadata-container", attachmentName: "attachment__name", attachmentProgress: "attachment__progress", attachmentSize: "attachment__size", attachmentToolbar: "attachment__toolbar", attachmentGallery: "attachment-gallery" }; 4673 }.call(this), function() { 4674 var t2; 4675 e2.config.blockAttributes = t2 = { "default": { tagName: "div", parse: false }, quote: { tagName: "blockquote", nestable: true }, heading1: { tagName: "h1", terminal: true, breakOnReturn: true, group: false }, code: { tagName: "pre", terminal: true, text: { plaintext: true } }, bulletList: { tagName: "ul", parse: false }, bullet: { tagName: "li", listAttribute: "bulletList", group: false, nestable: true, test: function(n2) { 4676 return e2.tagName(n2.parentNode) === t2[this.listAttribute].tagName; 4677 } }, numberList: { tagName: "ol", parse: false }, number: { tagName: "li", listAttribute: "numberList", group: false, nestable: true, test: function(n2) { 4678 return e2.tagName(n2.parentNode) === t2[this.listAttribute].tagName; 4679 } }, attachmentGallery: { tagName: "div", exclusive: true, terminal: true, parse: false, group: false } }; 4680 }.call(this), function() { 4681 var t2, n2; 4682 t2 = e2.config.lang, n2 = [t2.bytes, t2.KB, t2.MB, t2.GB, t2.TB, t2.PB], e2.config.fileSize = { prefix: "IEC", precision: 2, formatter: function(e3) { 4683 var i2, o2, r3, s2, a2; 4684 switch (e3) { 4685 case 0: 4686 return "0 " + t2.bytes; 4687 case 1: 4688 return "1 " + t2.byte; 4689 default: 4690 return i2 = function() { 4691 switch (this.prefix) { 4692 case "SI": 4693 return 1e3; 4694 case "IEC": 4695 return 1024; 4696 } 4697 }.call(this), o2 = Math.floor(Math.log(e3) / Math.log(i2)), r3 = e3 / Math.pow(i2, o2), s2 = r3.toFixed(this.precision), a2 = s2.replace(/0*$/, "").replace(/\.$/, ""), a2 + " " + n2[o2]; 4698 } 4699 } }; 4700 }.call(this), function() { 4701 e2.config.textAttributes = { bold: { tagName: "strong", inheritable: true, parser: function(t2) { 4702 var e3; 4703 return e3 = window.getComputedStyle(t2), e3.fontWeight === "bold" || e3.fontWeight >= 600; 4704 } }, italic: { tagName: "em", inheritable: true, parser: function(t2) { 4705 var e3; 4706 return e3 = window.getComputedStyle(t2), e3.fontStyle === "italic"; 4707 } }, href: { groupTagName: "a", parser: function(t2) { 4708 var n2, i2, o2; 4709 return n2 = e2.AttachmentView.attachmentSelector, o2 = "a:not(" + n2 + ")", (i2 = e2.findClosestElementFromNode(t2, { matchingSelector: o2 })) ? i2.getAttribute("href") : void 0; 4710 } }, strike: { tagName: "del", inheritable: true }, frozen: { style: { backgroundColor: "highlight" } } }; 4711 }.call(this), function() { 4712 var t2, n2, i2, o2, r3; 4713 r3 = "[data-trix-serialize=false]", o2 = ["contenteditable", "data-trix-id", "data-trix-store-key", "data-trix-mutable", "data-trix-placeholder", "tabindex"], n2 = "data-trix-serialized-attributes", i2 = "[" + n2 + "]", t2 = new RegExp("<!--block-->", "g"), e2.extend({ serializers: { "application/json": function(t3) { 4714 var n3; 4715 if (t3 instanceof e2.Document) 4716 n3 = t3; 4717 else { 4718 if (!(t3 instanceof HTMLElement)) 4719 throw new Error("unserializable object"); 4720 n3 = e2.Document.fromHTML(t3.innerHTML); 4721 } 4722 return n3.toSerializableDocument().toJSONString(); 4723 }, "text/html": function(s2) { 4724 var a2, u, c, l2, h2, p, d, f, g, m, v, y, b, A, C, x, w; 4725 if (s2 instanceof e2.Document) 4726 l2 = e2.DocumentView.render(s2); 4727 else { 4728 if (!(s2 instanceof HTMLElement)) 4729 throw new Error("unserializable object"); 4730 l2 = s2.cloneNode(true); 4731 } 4732 for (A = l2.querySelectorAll(r3), h2 = 0, g = A.length; g > h2; h2++) 4733 c = A[h2], e2.removeNode(c); 4734 for (p = 0, m = o2.length; m > p; p++) 4735 for (a2 = o2[p], C = l2.querySelectorAll("[" + a2 + "]"), d = 0, v = C.length; v > d; d++) 4736 c = C[d], c.removeAttribute(a2); 4737 for (x = l2.querySelectorAll(i2), f = 0, y = x.length; y > f; f++) { 4738 c = x[f]; 4739 try { 4740 u = JSON.parse(c.getAttribute(n2)), c.removeAttribute(n2); 4741 for (b in u) 4742 w = u[b], c.setAttribute(b, w); 4743 } catch (E) { 4744 } 4745 } 4746 return l2.innerHTML.replace(t2, ""); 4747 } }, deserializers: { "application/json": function(t3) { 4748 return e2.Document.fromJSONString(t3); 4749 }, "text/html": function(t3) { 4750 return e2.Document.fromHTML(t3); 4751 } }, serializeToContentType: function(t3, n3) { 4752 var i3; 4753 if (i3 = e2.serializers[n3]) 4754 return i3(t3); 4755 throw new Error("unknown content type: " + n3); 4756 }, deserializeFromContentType: function(t3, n3) { 4757 var i3; 4758 if (i3 = e2.deserializers[n3]) 4759 return i3(t3); 4760 throw new Error("unknown content type: " + n3); 4761 } }); 4762 }.call(this), function() { 4763 var t2; 4764 t2 = e2.config.lang, e2.config.toolbar = { getDefaultHTML: function() { 4765 return '<div class="trix-button-row">\n <span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="' + t2.bold + '" tabindex="-1">' + t2.bold + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="' + t2.italic + '" tabindex="-1">' + t2.italic + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-strike" data-trix-attribute="strike" title="' + t2.strike + '" tabindex="-1">' + t2.strike + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-link" data-trix-attribute="href" data-trix-action="link" data-trix-key="k" title="' + t2.link + '" tabindex="-1">' + t2.link + '</button>\n </span>\n\n <span class="trix-button-group trix-button-group--block-tools" data-trix-button-group="block-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-heading-1" data-trix-attribute="heading1" title="' + t2.heading1 + '" tabindex="-1">' + t2.heading1 + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-quote" data-trix-attribute="quote" title="' + t2.quote + '" tabindex="-1">' + t2.quote + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-code" data-trix-attribute="code" title="' + t2.code + '" tabindex="-1">' + t2.code + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-bullet-list" data-trix-attribute="bullet" title="' + t2.bullets + '" tabindex="-1">' + t2.bullets + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-number-list" data-trix-attribute="number" title="' + t2.numbers + '" tabindex="-1">' + t2.numbers + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-decrease-nesting-level" data-trix-action="decreaseNestingLevel" title="' + t2.outdent + '" tabindex="-1">' + t2.outdent + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-increase-nesting-level" data-trix-action="increaseNestingLevel" title="' + t2.indent + '" tabindex="-1">' + t2.indent + '</button>\n </span>\n\n <span class="trix-button-group trix-button-group--file-tools" data-trix-button-group="file-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-attach" data-trix-action="attachFiles" title="' + t2.attachFiles + '" tabindex="-1">' + t2.attachFiles + '</button>\n </span>\n\n <span class="trix-button-group-spacer"></span>\n\n <span class="trix-button-group trix-button-group--history-tools" data-trix-button-group="history-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-undo" data-trix-action="undo" data-trix-key="z" title="' + t2.undo + '" tabindex="-1">' + t2.undo + '</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-redo" data-trix-action="redo" data-trix-key="shift+z" title="' + t2.redo + '" tabindex="-1">' + t2.redo + '</button>\n </span>\n</div>\n\n<div class="trix-dialogs" data-trix-dialogs>\n <div class="trix-dialog trix-dialog--link" data-trix-dialog="href" data-trix-dialog-attribute="href">\n <div class="trix-dialog__link-fields">\n <input type="url" name="href" class="trix-input trix-input--dialog" placeholder="' + t2.urlPlaceholder + '" aria-label="' + t2.url + '" required data-trix-input>\n <div class="trix-button-group">\n <input type="button" class="trix-button trix-button--dialog" value="' + t2.link + '" data-trix-method="setAttribute">\n <input type="button" class="trix-button trix-button--dialog" value="' + t2.unlink + '" data-trix-method="removeAttribute">\n </div>\n </div>\n </div>\n</div>'; 4766 } }; 4767 }.call(this), function() { 4768 e2.config.undoInterval = 5e3; 4769 }.call(this), function() { 4770 e2.config.attachments = { preview: { presentation: "gallery", caption: { name: true, size: true } }, file: { caption: { size: true } } }; 4771 }.call(this), function() { 4772 e2.config.keyNames = { 8: "backspace", 9: "tab", 13: "return", 27: "escape", 37: "left", 39: "right", 46: "delete", 68: "d", 72: "h", 79: "o" }; 4773 }.call(this), function() { 4774 e2.config.input = { level2Enabled: true, getLevel: function() { 4775 return this.level2Enabled && e2.browser.supportsInputEvents ? 2 : 0; 4776 }, pickFiles: function(t2) { 4777 var n2; 4778 return n2 = e2.makeElement("input", { type: "file", multiple: true, hidden: true, id: this.fileInputId }), n2.addEventListener("change", function() { 4779 return t2(n2.files), e2.removeNode(n2); 4780 }), e2.removeNode(document.getElementById(this.fileInputId)), document.body.appendChild(n2), n2.click(); 4781 }, fileInputId: "trix-file-input-" + Date.now().toString(16) }; 4782 }.call(this), function() { 4783 }.call(this), function() { 4784 e2.registerElement("trix-toolbar", { defaultCSS: "%t {\n display: block;\n}\n\n%t {\n white-space: nowrap;\n}\n\n%t [data-trix-dialog] {\n display: none;\n}\n\n%t [data-trix-dialog][data-trix-active] {\n display: block;\n}\n\n%t [data-trix-dialog] [data-trix-validate]:invalid {\n background-color: #ffdddd;\n}", initialize: function() { 4785 return this.innerHTML === "" ? this.innerHTML = e2.config.toolbar.getDefaultHTML() : void 0; 4786 } }); 4787 }.call(this), function() { 4788 var t2 = function(t3, e3) { 4789 function i3() { 4790 this.constructor = t3; 4791 } 4792 for (var o2 in e3) 4793 n2.call(e3, o2) && (t3[o2] = e3[o2]); 4794 return i3.prototype = e3.prototype, t3.prototype = new i3(), t3.__super__ = e3.prototype, t3; 4795 }, n2 = {}.hasOwnProperty, i2 = [].indexOf || function(t3) { 4796 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 4797 if (e3 in this && this[e3] === t3) 4798 return e3; 4799 return -1; 4800 }; 4801 e2.ObjectView = function(n3) { 4802 function o2(t3, e3) { 4803 this.object = t3, this.options = e3 != null ? e3 : {}, this.childViews = [], this.rootView = this; 4804 } 4805 return t2(o2, n3), o2.prototype.getNodes = function() { 4806 var t3, e3, n4, i3, o3; 4807 for (this.nodes == null && (this.nodes = this.createNodes()), i3 = this.nodes, o3 = [], t3 = 0, e3 = i3.length; e3 > t3; t3++) 4808 n4 = i3[t3], o3.push(n4.cloneNode(true)); 4809 return o3; 4810 }, o2.prototype.invalidate = function() { 4811 var t3; 4812 return this.nodes = null, this.childViews = [], (t3 = this.parentView) != null ? t3.invalidate() : void 0; 4813 }, o2.prototype.invalidateViewForObject = function(t3) { 4814 var e3; 4815 return (e3 = this.findViewForObject(t3)) != null ? e3.invalidate() : void 0; 4816 }, o2.prototype.findOrCreateCachedChildView = function(t3, e3) { 4817 var n4; 4818 return (n4 = this.getCachedViewForObject(e3)) ? this.recordChildView(n4) : (n4 = this.createChildView.apply(this, arguments), this.cacheViewForObject(n4, e3)), n4; 4819 }, o2.prototype.createChildView = function(t3, n4, i3) { 4820 var o3; 4821 return i3 == null && (i3 = {}), n4 instanceof e2.ObjectGroup && (i3.viewClass = t3, t3 = e2.ObjectGroupView), o3 = new t3(n4, i3), this.recordChildView(o3); 4822 }, o2.prototype.recordChildView = function(t3) { 4823 return t3.parentView = this, t3.rootView = this.rootView, this.childViews.push(t3), t3; 4824 }, o2.prototype.getAllChildViews = function() { 4825 var t3, e3, n4, i3, o3; 4826 for (o3 = [], i3 = this.childViews, e3 = 0, n4 = i3.length; n4 > e3; e3++) 4827 t3 = i3[e3], o3.push(t3), o3 = o3.concat(t3.getAllChildViews()); 4828 return o3; 4829 }, o2.prototype.findElement = function() { 4830 return this.findElementForObject(this.object); 4831 }, o2.prototype.findElementForObject = function(t3) { 4832 var e3; 4833 return (e3 = t3 != null ? t3.id : void 0) ? this.rootView.element.querySelector("[data-trix-id='" + e3 + "']") : void 0; 4834 }, o2.prototype.findViewForObject = function(t3) { 4835 var e3, n4, i3, o3; 4836 for (i3 = this.getAllChildViews(), e3 = 0, n4 = i3.length; n4 > e3; e3++) 4837 if (o3 = i3[e3], o3.object === t3) 4838 return o3; 4839 }, o2.prototype.getViewCache = function() { 4840 return this.rootView !== this ? this.rootView.getViewCache() : this.isViewCachingEnabled() ? this.viewCache != null ? this.viewCache : this.viewCache = {} : void 0; 4841 }, o2.prototype.isViewCachingEnabled = function() { 4842 return this.shouldCacheViews !== false; 4843 }, o2.prototype.enableViewCaching = function() { 4844 return this.shouldCacheViews = true; 4845 }, o2.prototype.disableViewCaching = function() { 4846 return this.shouldCacheViews = false; 4847 }, o2.prototype.getCachedViewForObject = function(t3) { 4848 var e3; 4849 return (e3 = this.getViewCache()) != null ? e3[t3.getCacheKey()] : void 0; 4850 }, o2.prototype.cacheViewForObject = function(t3, e3) { 4851 var n4; 4852 return (n4 = this.getViewCache()) != null ? n4[e3.getCacheKey()] = t3 : void 0; 4853 }, o2.prototype.garbageCollectCachedViews = function() { 4854 var t3, e3, n4, o3, r3, s2; 4855 if (t3 = this.getViewCache()) { 4856 s2 = this.getAllChildViews().concat(this), n4 = function() { 4857 var t4, e4, n5; 4858 for (n5 = [], t4 = 0, e4 = s2.length; e4 > t4; t4++) 4859 r3 = s2[t4], n5.push(r3.object.getCacheKey()); 4860 return n5; 4861 }(), o3 = []; 4862 for (e3 in t3) 4863 i2.call(n4, e3) < 0 && o3.push(delete t3[e3]); 4864 return o3; 4865 } 4866 }, o2; 4867 }(e2.BasicObject); 4868 }.call(this), function() { 4869 var t2 = function(t3, e3) { 4870 function i2() { 4871 this.constructor = t3; 4872 } 4873 for (var o2 in e3) 4874 n2.call(e3, o2) && (t3[o2] = e3[o2]); 4875 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 4876 }, n2 = {}.hasOwnProperty; 4877 e2.ObjectGroupView = function(e3) { 4878 function n3() { 4879 n3.__super__.constructor.apply(this, arguments), this.objectGroup = this.object, this.viewClass = this.options.viewClass, delete this.options.viewClass; 4880 } 4881 return t2(n3, e3), n3.prototype.getChildViews = function() { 4882 var t3, e4, n4, i2; 4883 if (!this.childViews.length) 4884 for (i2 = this.objectGroup.getObjects(), t3 = 0, e4 = i2.length; e4 > t3; t3++) 4885 n4 = i2[t3], this.findOrCreateCachedChildView(this.viewClass, n4, this.options); 4886 return this.childViews; 4887 }, n3.prototype.createNodes = function() { 4888 var t3, e4, n4, i2, o2, r3, s2, a2, u; 4889 for (t3 = this.createContainerElement(), s2 = this.getChildViews(), e4 = 0, i2 = s2.length; i2 > e4; e4++) 4890 for (u = s2[e4], a2 = u.getNodes(), n4 = 0, o2 = a2.length; o2 > n4; n4++) 4891 r3 = a2[n4], t3.appendChild(r3); 4892 return [t3]; 4893 }, n3.prototype.createContainerElement = function(t3) { 4894 return t3 == null && (t3 = this.objectGroup.getDepth()), this.getChildViews()[0].createContainerElement(t3); 4895 }, n3; 4896 }(e2.ObjectView); 4897 }.call(this), function() { 4898 var t2 = function(t3, e3) { 4899 function i2() { 4900 this.constructor = t3; 4901 } 4902 for (var o2 in e3) 4903 n2.call(e3, o2) && (t3[o2] = e3[o2]); 4904 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 4905 }, n2 = {}.hasOwnProperty; 4906 e2.Controller = function(e3) { 4907 function n3() { 4908 return n3.__super__.constructor.apply(this, arguments); 4909 } 4910 return t2(n3, e3), n3; 4911 }(e2.BasicObject); 4912 }.call(this), function() { 4913 var t2, n2, i2, o2, r3, s2, a2 = function(t3, e3) { 4914 return function() { 4915 return t3.apply(e3, arguments); 4916 }; 4917 }, u = function(t3, e3) { 4918 function n3() { 4919 this.constructor = t3; 4920 } 4921 for (var i3 in e3) 4922 c.call(e3, i3) && (t3[i3] = e3[i3]); 4923 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 4924 }, c = {}.hasOwnProperty, l2 = [].indexOf || function(t3) { 4925 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 4926 if (e3 in this && this[e3] === t3) 4927 return e3; 4928 return -1; 4929 }; 4930 t2 = e2.findClosestElementFromNode, i2 = e2.nodeIsEmptyTextNode, n2 = e2.nodeIsBlockStartComment, o2 = e2.normalizeSpaces, r3 = e2.summarizeStringChange, s2 = e2.tagName, e2.MutationObserver = function(e3) { 4931 function c2(t3) { 4932 this.element = t3, this.didMutate = a2(this.didMutate, this), this.observer = new window.MutationObserver(this.didMutate), this.start(); 4933 } 4934 var h2, p, d, f; 4935 return u(c2, e3), p = "data-trix-mutable", d = "[" + p + "]", f = { attributes: true, childList: true, characterData: true, characterDataOldValue: true, subtree: true }, c2.prototype.start = function() { 4936 return this.reset(), this.observer.observe(this.element, f); 4937 }, c2.prototype.stop = function() { 4938 return this.observer.disconnect(); 4939 }, c2.prototype.didMutate = function(t3) { 4940 var e4, n3; 4941 return (e4 = this.mutations).push.apply(e4, this.findSignificantMutations(t3)), this.mutations.length ? ((n3 = this.delegate) != null && typeof n3.elementDidMutate == "function" && n3.elementDidMutate(this.getMutationSummary()), this.reset()) : void 0; 4942 }, c2.prototype.reset = function() { 4943 return this.mutations = []; 4944 }, c2.prototype.findSignificantMutations = function(t3) { 4945 var e4, n3, i3, o3; 4946 for (o3 = [], e4 = 0, n3 = t3.length; n3 > e4; e4++) 4947 i3 = t3[e4], this.mutationIsSignificant(i3) && o3.push(i3); 4948 return o3; 4949 }, c2.prototype.mutationIsSignificant = function(t3) { 4950 var e4, n3, i3, o3; 4951 if (this.nodeIsMutable(t3.target)) 4952 return false; 4953 for (o3 = this.nodesModifiedByMutation(t3), e4 = 0, n3 = o3.length; n3 > e4; e4++) 4954 if (i3 = o3[e4], this.nodeIsSignificant(i3)) 4955 return true; 4956 return false; 4957 }, c2.prototype.nodeIsSignificant = function(t3) { 4958 return t3 !== this.element && !this.nodeIsMutable(t3) && !i2(t3); 4959 }, c2.prototype.nodeIsMutable = function(e4) { 4960 return t2(e4, { matchingSelector: d }); 4961 }, c2.prototype.nodesModifiedByMutation = function(t3) { 4962 var e4; 4963 switch (e4 = [], t3.type) { 4964 case "attributes": 4965 t3.attributeName !== p && e4.push(t3.target); 4966 break; 4967 case "characterData": 4968 e4.push(t3.target.parentNode), e4.push(t3.target); 4969 break; 4970 case "childList": 4971 e4.push.apply(e4, t3.addedNodes), e4.push.apply(e4, t3.removedNodes); 4972 } 4973 return e4; 4974 }, c2.prototype.getMutationSummary = function() { 4975 return this.getTextMutationSummary(); 4976 }, c2.prototype.getTextMutationSummary = function() { 4977 var t3, e4, n3, i3, o3, r4, s3, a3, u2, c3, h3; 4978 for (a3 = this.getTextChangesFromCharacterData(), n3 = a3.additions, o3 = a3.deletions, h3 = this.getTextChangesFromChildList(), u2 = h3.additions, r4 = 0, s3 = u2.length; s3 > r4; r4++) 4979 e4 = u2[r4], l2.call(n3, e4) < 0 && n3.push(e4); 4980 return o3.push.apply(o3, h3.deletions), c3 = {}, (t3 = n3.join("")) && (c3.textAdded = t3), (i3 = o3.join("")) && (c3.textDeleted = i3), c3; 4981 }, c2.prototype.getMutationsByType = function(t3) { 4982 var e4, n3, i3, o3, r4; 4983 for (o3 = this.mutations, r4 = [], e4 = 0, n3 = o3.length; n3 > e4; e4++) 4984 i3 = o3[e4], i3.type === t3 && r4.push(i3); 4985 return r4; 4986 }, c2.prototype.getTextChangesFromChildList = function() { 4987 var t3, e4, i3, r4, s3, a3, u2, c3, l3, p2, d2; 4988 for (t3 = [], u2 = [], a3 = this.getMutationsByType("childList"), e4 = 0, r4 = a3.length; r4 > e4; e4++) 4989 s3 = a3[e4], t3.push.apply(t3, s3.addedNodes), u2.push.apply(u2, s3.removedNodes); 4990 return c3 = t3.length === 0 && u2.length === 1 && n2(u2[0]), c3 ? (p2 = [], d2 = ["\n"]) : (p2 = h2(t3), d2 = h2(u2)), { additions: function() { 4991 var t4, e5, n3; 4992 for (n3 = [], i3 = t4 = 0, e5 = p2.length; e5 > t4; i3 = ++t4) 4993 l3 = p2[i3], l3 !== d2[i3] && n3.push(o2(l3)); 4994 return n3; 4995 }(), deletions: function() { 4996 var t4, e5, n3; 4997 for (n3 = [], i3 = t4 = 0, e5 = d2.length; e5 > t4; i3 = ++t4) 4998 l3 = d2[i3], l3 !== p2[i3] && n3.push(o2(l3)); 4999 return n3; 5000 }() }; 5001 }, c2.prototype.getTextChangesFromCharacterData = function() { 5002 var t3, e4, n3, i3, s3, a3, u2, c3; 5003 return e4 = this.getMutationsByType("characterData"), e4.length && (c3 = e4[0], n3 = e4[e4.length - 1], s3 = o2(c3.oldValue), i3 = o2(n3.target.data), a3 = r3(s3, i3), t3 = a3.added, u2 = a3.removed), { additions: t3 ? [t3] : [], deletions: u2 ? [u2] : [] }; 5004 }, h2 = function(t3) { 5005 var e4, n3, i3, o3; 5006 for (t3 == null && (t3 = []), o3 = [], e4 = 0, n3 = t3.length; n3 > e4; e4++) 5007 switch (i3 = t3[e4], i3.nodeType) { 5008 case Node.TEXT_NODE: 5009 o3.push(i3.data); 5010 break; 5011 case Node.ELEMENT_NODE: 5012 s2(i3) === "br" ? o3.push("\n") : o3.push.apply(o3, h2(i3.childNodes)); 5013 } 5014 return o3; 5015 }, c2; 5016 }(e2.BasicObject); 5017 }.call(this), function() { 5018 var t2 = function(t3, e3) { 5019 function i2() { 5020 this.constructor = t3; 5021 } 5022 for (var o2 in e3) 5023 n2.call(e3, o2) && (t3[o2] = e3[o2]); 5024 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 5025 }, n2 = {}.hasOwnProperty; 5026 e2.FileVerificationOperation = function(e3) { 5027 function n3(t3) { 5028 this.file = t3; 5029 } 5030 return t2(n3, e3), n3.prototype.perform = function(t3) { 5031 var e4; 5032 return e4 = new FileReader(), e4.onerror = function() { 5033 return t3(false); 5034 }, e4.onload = function(n4) { 5035 return function() { 5036 e4.onerror = null; 5037 try { 5038 e4.abort(); 5039 } catch (i2) { 5040 } 5041 return t3(true, n4.file); 5042 }; 5043 }(this), e4.readAsArrayBuffer(this.file); 5044 }, n3; 5045 }(e2.Operation); 5046 }.call(this), function() { 5047 var t2, n2, i2 = function(t3, e3) { 5048 function n3() { 5049 this.constructor = t3; 5050 } 5051 for (var i3 in e3) 5052 o2.call(e3, i3) && (t3[i3] = e3[i3]); 5053 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5054 }, o2 = {}.hasOwnProperty; 5055 t2 = e2.handleEvent, n2 = e2.innerElementIsActive, e2.InputController = function(o3) { 5056 function r3(n3) { 5057 var i3; 5058 this.element = n3, this.mutationObserver = new e2.MutationObserver(this.element), this.mutationObserver.delegate = this; 5059 for (i3 in this.events) 5060 t2(i3, { onElement: this.element, withCallback: this.handlerFor(i3) }); 5061 } 5062 return i2(r3, o3), r3.prototype.events = {}, r3.prototype.elementDidMutate = function() { 5063 }, r3.prototype.editorWillSyncDocumentView = function() { 5064 return this.mutationObserver.stop(); 5065 }, r3.prototype.editorDidSyncDocumentView = function() { 5066 return this.mutationObserver.start(); 5067 }, r3.prototype.requestRender = function() { 5068 var t3; 5069 return (t3 = this.delegate) != null && typeof t3.inputControllerDidRequestRender == "function" ? t3.inputControllerDidRequestRender() : void 0; 5070 }, r3.prototype.requestReparse = function() { 5071 var t3; 5072 return (t3 = this.delegate) != null && typeof t3.inputControllerDidRequestReparse == "function" && t3.inputControllerDidRequestReparse(), this.requestRender(); 5073 }, r3.prototype.attachFiles = function(t3) { 5074 var n3, i3; 5075 return i3 = function() { 5076 var i4, o4, r4; 5077 for (r4 = [], i4 = 0, o4 = t3.length; o4 > i4; i4++) 5078 n3 = t3[i4], r4.push(new e2.FileVerificationOperation(n3)); 5079 return r4; 5080 }(), Promise.all(i3).then(function(t4) { 5081 return function(e3) { 5082 return t4.handleInput(function() { 5083 var t5, n4; 5084 return (t5 = this.delegate) != null && t5.inputControllerWillAttachFiles(), (n4 = this.responder) != null && n4.insertFiles(e3), this.requestRender(); 5085 }); 5086 }; 5087 }(this)); 5088 }, r3.prototype.handlerFor = function(t3) { 5089 return function(e3) { 5090 return function(i3) { 5091 return i3.defaultPrevented ? void 0 : e3.handleInput(function() { 5092 return n2(this.element) ? void 0 : (this.eventName = t3, this.events[t3].call(this, i3)); 5093 }); 5094 }; 5095 }(this); 5096 }, r3.prototype.handleInput = function(t3) { 5097 var e3, n3; 5098 try { 5099 return (e3 = this.delegate) != null && e3.inputControllerWillHandleInput(), t3.call(this); 5100 } finally { 5101 (n3 = this.delegate) != null && n3.inputControllerDidHandleInput(); 5102 } 5103 }, r3.prototype.createLinkHTML = function(t3, e3) { 5104 var n3; 5105 return n3 = document.createElement("a"), n3.href = t3, n3.textContent = e3 != null ? e3 : t3, n3.outerHTML; 5106 }, r3; 5107 }(e2.BasicObject); 5108 }.call(this), function() { 5109 var t2, n2, i2, o2, r3, s2, a2, u, c, l2, h2, p, d, f = function(t3, e3) { 5110 function n3() { 5111 this.constructor = t3; 5112 } 5113 for (var i3 in e3) 5114 g.call(e3, i3) && (t3[i3] = e3[i3]); 5115 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5116 }, g = {}.hasOwnProperty, m = [].indexOf || function(t3) { 5117 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 5118 if (e3 in this && this[e3] === t3) 5119 return e3; 5120 return -1; 5121 }; 5122 c = e2.makeElement, l2 = e2.objectsAreEqual, d = e2.tagName, n2 = e2.browser, a2 = e2.keyEventIsKeyboardCommand, o2 = e2.dataTransferIsWritable, i2 = e2.dataTransferIsPlainText, u = e2.config.keyNames, e2.Level0InputController = function(n3) { 5123 function s3() { 5124 s3.__super__.constructor.apply(this, arguments), this.resetInputSummary(); 5125 } 5126 var d2; 5127 return f(s3, n3), d2 = 0, s3.prototype.setInputSummary = function(t3) { 5128 var e3, n4; 5129 t3 == null && (t3 = {}), this.inputSummary.eventName = this.eventName; 5130 for (e3 in t3) 5131 n4 = t3[e3], this.inputSummary[e3] = n4; 5132 return this.inputSummary; 5133 }, s3.prototype.resetInputSummary = function() { 5134 return this.inputSummary = {}; 5135 }, s3.prototype.reset = function() { 5136 return this.resetInputSummary(), e2.selectionChangeObserver.reset(); 5137 }, s3.prototype.elementDidMutate = function(t3) { 5138 var e3; 5139 return this.isComposing() ? (e3 = this.delegate) != null && typeof e3.inputControllerDidAllowUnhandledInput == "function" ? e3.inputControllerDidAllowUnhandledInput() : void 0 : this.handleInput(function() { 5140 return this.mutationIsSignificant(t3) && (this.mutationIsExpected(t3) ? this.requestRender() : this.requestReparse()), this.reset(); 5141 }); 5142 }, s3.prototype.mutationIsExpected = function(t3) { 5143 var e3, n4, i3, o3, r4, s4, a3, u2, c2, l3; 5144 return a3 = t3.textAdded, u2 = t3.textDeleted, this.inputSummary.preferDocument ? true : (e3 = a3 != null ? a3 === this.inputSummary.textAdded : !this.inputSummary.textAdded, n4 = u2 != null ? this.inputSummary.didDelete : !this.inputSummary.didDelete, c2 = (a3 === "\n" || a3 === " \n") && !e3, l3 = u2 === "\n" && !n4, s4 = c2 && !l3 || l3 && !c2, s4 && (o3 = this.getSelectedRange()) && (i3 = c2 ? a3.replace(/\n$/, "").length || -1 : (a3 != null ? a3.length : void 0) || 1, (r4 = this.responder) != null ? r4.positionIsBlockBreak(o3[1] + i3) : void 0) ? true : e3 && n4); 5145 }, s3.prototype.mutationIsSignificant = function(t3) { 5146 var e3, n4, i3; 5147 return i3 = Object.keys(t3).length > 0, e3 = ((n4 = this.compositionInput) != null ? n4.getEndData() : void 0) === "", i3 || !e3; 5148 }, s3.prototype.events = { keydown: function(t3) { 5149 var n4, i3, o3, r4, s4, c2, l3, h3, p2; 5150 if (this.isComposing() || this.resetInputSummary(), this.inputSummary.didInput = true, r4 = u[t3.keyCode]) { 5151 for (i3 = this.keys, h3 = ["ctrl", "alt", "shift", "meta"], o3 = 0, c2 = h3.length; c2 > o3; o3++) 5152 l3 = h3[o3], t3[l3 + "Key"] && (l3 === "ctrl" && (l3 = "control"), i3 = i3 != null ? i3[l3] : void 0); 5153 (i3 != null ? i3[r4] : void 0) != null && (this.setInputSummary({ keyName: r4 }), e2.selectionChangeObserver.reset(), i3[r4].call(this, t3)); 5154 } 5155 return a2(t3) && (n4 = String.fromCharCode(t3.keyCode).toLowerCase()) && (s4 = function() { 5156 var e3, n5, i4, o4; 5157 for (i4 = ["alt", "shift"], o4 = [], e3 = 0, n5 = i4.length; n5 > e3; e3++) 5158 l3 = i4[e3], t3[l3 + "Key"] && o4.push(l3); 5159 return o4; 5160 }(), s4.push(n4), (p2 = this.delegate) != null ? p2.inputControllerDidReceiveKeyboardCommand(s4) : void 0) ? t3.preventDefault() : void 0; 5161 }, keypress: function(t3) { 5162 var e3, n4, i3; 5163 if (this.inputSummary.eventName == null && !t3.metaKey && (!t3.ctrlKey || t3.altKey)) 5164 return (i3 = p(t3)) ? ((e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), (n4 = this.responder) != null && n4.insertString(i3), this.setInputSummary({ textAdded: i3, didDelete: this.selectionIsExpanded() })) : void 0; 5165 }, textInput: function(t3) { 5166 var e3, n4, i3, o3; 5167 return e3 = t3.data, o3 = this.inputSummary.textAdded, o3 && o3 !== e3 && o3.toUpperCase() === e3 ? (n4 = this.getSelectedRange(), this.setSelectedRange([n4[0], n4[1] + o3.length]), (i3 = this.responder) != null && i3.insertString(e3), this.setInputSummary({ textAdded: e3 }), this.setSelectedRange(n4)) : void 0; 5168 }, dragenter: function(t3) { 5169 return t3.preventDefault(); 5170 }, dragstart: function(t3) { 5171 var e3, n4; 5172 return n4 = t3.target, this.serializeSelectionToDataTransfer(t3.dataTransfer), this.draggedRange = this.getSelectedRange(), (e3 = this.delegate) != null && typeof e3.inputControllerDidStartDrag == "function" ? e3.inputControllerDidStartDrag() : void 0; 5173 }, dragover: function(t3) { 5174 var e3, n4; 5175 return !this.draggedRange && !this.canAcceptDataTransfer(t3.dataTransfer) || (t3.preventDefault(), e3 = { x: t3.clientX, y: t3.clientY }, l2(e3, this.draggingPoint)) ? void 0 : (this.draggingPoint = e3, (n4 = this.delegate) != null && typeof n4.inputControllerDidReceiveDragOverPoint == "function" ? n4.inputControllerDidReceiveDragOverPoint(this.draggingPoint) : void 0); 5176 }, dragend: function() { 5177 var t3; 5178 return (t3 = this.delegate) != null && typeof t3.inputControllerDidCancelDrag == "function" && t3.inputControllerDidCancelDrag(), this.draggedRange = null, this.draggingPoint = null; 5179 }, drop: function(t3) { 5180 var n4, i3, o3, r4, s4, a3, u2, c2, l3; 5181 return t3.preventDefault(), o3 = (s4 = t3.dataTransfer) != null ? s4.files : void 0, r4 = { x: t3.clientX, y: t3.clientY }, (a3 = this.responder) != null && a3.setLocationRangeFromPointRange(r4), (o3 != null ? o3.length : void 0) ? this.attachFiles(o3) : this.draggedRange ? ((u2 = this.delegate) != null && u2.inputControllerWillMoveText(), (c2 = this.responder) != null && c2.moveTextFromRange(this.draggedRange), this.draggedRange = null, this.requestRender()) : (i3 = t3.dataTransfer.getData("application/x-trix-document")) && (n4 = e2.Document.fromJSONString(i3), (l3 = this.responder) != null && l3.insertDocument(n4), this.requestRender()), this.draggedRange = null, this.draggingPoint = null; 5182 }, cut: function(t3) { 5183 var e3, n4; 5184 return ((e3 = this.responder) != null ? e3.selectionIsExpanded() : void 0) && (this.serializeSelectionToDataTransfer(t3.clipboardData) && t3.preventDefault(), (n4 = this.delegate) != null && n4.inputControllerWillCutText(), this.deleteInDirection("backward"), t3.defaultPrevented) ? this.requestRender() : void 0; 5185 }, copy: function(t3) { 5186 var e3; 5187 return ((e3 = this.responder) != null ? e3.selectionIsExpanded() : void 0) && this.serializeSelectionToDataTransfer(t3.clipboardData) ? t3.preventDefault() : void 0; 5188 }, paste: function(t3) { 5189 var n4, o3, s4, a3, u2, c2, l3, p2, f2, g2, v, y, b, A, C, x, w, E, S, R, k, D, L; 5190 return n4 = (p2 = t3.clipboardData) != null ? p2 : t3.testClipboardData, l3 = { clipboard: n4 }, n4 == null || h2(t3) ? void this.getPastedHTMLUsingHiddenElement(function(t4) { 5191 return function(e3) { 5192 var n5, i3, o4; 5193 return l3.type = "text/html", l3.html = e3, (n5 = t4.delegate) != null && n5.inputControllerWillPaste(l3), (i3 = t4.responder) != null && i3.insertHTML(l3.html), t4.requestRender(), (o4 = t4.delegate) != null ? o4.inputControllerDidPaste(l3) : void 0; 5194 }; 5195 }(this)) : ((a3 = n4.getData("URL")) ? (l3.type = "text/html", L = (c2 = n4.getData("public.url-name")) ? e2.squishBreakableWhitespace(c2).trim() : a3, l3.html = this.createLinkHTML(a3, L), (f2 = this.delegate) != null && f2.inputControllerWillPaste(l3), this.setInputSummary({ textAdded: L, didDelete: this.selectionIsExpanded() }), (C = this.responder) != null && C.insertHTML(l3.html), this.requestRender(), (x = this.delegate) != null && x.inputControllerDidPaste(l3)) : i2(n4) ? (l3.type = "text/plain", l3.string = n4.getData("text/plain"), (w = this.delegate) != null && w.inputControllerWillPaste(l3), this.setInputSummary({ textAdded: l3.string, didDelete: this.selectionIsExpanded() }), (E = this.responder) != null && E.insertString(l3.string), this.requestRender(), (S = this.delegate) != null && S.inputControllerDidPaste(l3)) : (u2 = n4.getData("text/html")) ? (l3.type = "text/html", l3.html = u2, (R = this.delegate) != null && R.inputControllerWillPaste(l3), (k = this.responder) != null && k.insertHTML(l3.html), this.requestRender(), (D = this.delegate) != null && D.inputControllerDidPaste(l3)) : m.call(n4.types, "Files") >= 0 && (s4 = (g2 = n4.items) != null && (v = g2[0]) != null && typeof v.getAsFile == "function" ? v.getAsFile() : void 0) && (!s4.name && (o3 = r3(s4)) && (s4.name = "pasted-file-" + ++d2 + "." + o3), l3.type = "File", l3.file = s4, (y = this.delegate) != null && y.inputControllerWillAttachFiles(), (b = this.responder) != null && b.insertFile(l3.file), this.requestRender(), (A = this.delegate) != null && A.inputControllerDidPaste(l3)), t3.preventDefault()); 5196 }, compositionstart: function(t3) { 5197 return this.getCompositionInput().start(t3.data); 5198 }, compositionupdate: function(t3) { 5199 return this.getCompositionInput().update(t3.data); 5200 }, compositionend: function(t3) { 5201 return this.getCompositionInput().end(t3.data); 5202 }, beforeinput: function() { 5203 return this.inputSummary.didInput = true; 5204 }, input: function(t3) { 5205 return this.inputSummary.didInput = true, t3.stopPropagation(); 5206 } }, s3.prototype.keys = { backspace: function(t3) { 5207 var e3; 5208 return (e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), this.deleteInDirection("backward", t3); 5209 }, "delete": function(t3) { 5210 var e3; 5211 return (e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), this.deleteInDirection("forward", t3); 5212 }, "return": function() { 5213 var t3, e3; 5214 return this.setInputSummary({ preferDocument: true }), (t3 = this.delegate) != null && t3.inputControllerWillPerformTyping(), (e3 = this.responder) != null ? e3.insertLineBreak() : void 0; 5215 }, tab: function(t3) { 5216 var e3, n4; 5217 return ((e3 = this.responder) != null ? e3.canIncreaseNestingLevel() : void 0) ? ((n4 = this.responder) != null && n4.increaseNestingLevel(), this.requestRender(), t3.preventDefault()) : void 0; 5218 }, left: function(t3) { 5219 var e3; 5220 return this.selectionIsInCursorTarget() ? (t3.preventDefault(), (e3 = this.responder) != null ? e3.moveCursorInDirection("backward") : void 0) : void 0; 5221 }, right: function(t3) { 5222 var e3; 5223 return this.selectionIsInCursorTarget() ? (t3.preventDefault(), (e3 = this.responder) != null ? e3.moveCursorInDirection("forward") : void 0) : void 0; 5224 }, control: { d: function(t3) { 5225 var e3; 5226 return (e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), this.deleteInDirection("forward", t3); 5227 }, h: function(t3) { 5228 var e3; 5229 return (e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), this.deleteInDirection("backward", t3); 5230 }, o: function(t3) { 5231 var e3, n4; 5232 return t3.preventDefault(), (e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), (n4 = this.responder) != null && n4.insertString("\n", { updatePosition: false }), this.requestRender(); 5233 } }, shift: { "return": function(t3) { 5234 var e3, n4; 5235 return (e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), (n4 = this.responder) != null && n4.insertString("\n"), this.requestRender(), t3.preventDefault(); 5236 }, tab: function(t3) { 5237 var e3, n4; 5238 return ((e3 = this.responder) != null ? e3.canDecreaseNestingLevel() : void 0) ? ((n4 = this.responder) != null && n4.decreaseNestingLevel(), this.requestRender(), t3.preventDefault()) : void 0; 5239 }, left: function(t3) { 5240 return this.selectionIsInCursorTarget() ? (t3.preventDefault(), this.expandSelectionInDirection("backward")) : void 0; 5241 }, right: function(t3) { 5242 return this.selectionIsInCursorTarget() ? (t3.preventDefault(), this.expandSelectionInDirection("forward")) : void 0; 5243 } }, alt: { backspace: function() { 5244 var t3; 5245 return this.setInputSummary({ preferDocument: false }), (t3 = this.delegate) != null ? t3.inputControllerWillPerformTyping() : void 0; 5246 } }, meta: { backspace: function() { 5247 var t3; 5248 return this.setInputSummary({ preferDocument: false }), (t3 = this.delegate) != null ? t3.inputControllerWillPerformTyping() : void 0; 5249 } } }, s3.prototype.getCompositionInput = function() { 5250 return this.isComposing() ? this.compositionInput : this.compositionInput = new t2(this); 5251 }, s3.prototype.isComposing = function() { 5252 return this.compositionInput != null && !this.compositionInput.isEnded(); 5253 }, s3.prototype.deleteInDirection = function(t3, e3) { 5254 var n4; 5255 return ((n4 = this.responder) != null ? n4.deleteInDirection(t3) : void 0) !== false ? this.setInputSummary({ didDelete: true }) : e3 ? (e3.preventDefault(), this.requestRender()) : void 0; 5256 }, s3.prototype.serializeSelectionToDataTransfer = function(t3) { 5257 var n4, i3; 5258 if (o2(t3)) 5259 return n4 = (i3 = this.responder) != null ? i3.getSelectedDocument().toSerializableDocument() : void 0, t3.setData("application/x-trix-document", JSON.stringify(n4)), t3.setData("text/html", e2.DocumentView.render(n4).innerHTML), t3.setData("text/plain", n4.toString().replace(/\n$/, "")), true; 5260 }, s3.prototype.canAcceptDataTransfer = function(t3) { 5261 var e3, n4, i3, o3, r4, s4; 5262 for (s4 = {}, o3 = (i3 = t3 != null ? t3.types : void 0) != null ? i3 : [], e3 = 0, n4 = o3.length; n4 > e3; e3++) 5263 r4 = o3[e3], s4[r4] = true; 5264 return s4.Files || s4["application/x-trix-document"] || s4["text/html"] || s4["text/plain"]; 5265 }, s3.prototype.getPastedHTMLUsingHiddenElement = function(t3) { 5266 var n4, i3, o3; 5267 return i3 = this.getSelectedRange(), o3 = { position: "absolute", left: window.pageXOffset + "px", top: window.pageYOffset + "px", opacity: 0 }, n4 = c({ style: o3, tagName: "div", editable: true }), document.body.appendChild(n4), n4.focus(), requestAnimationFrame(function(o4) { 5268 return function() { 5269 var r4; 5270 return r4 = n4.innerHTML, e2.removeNode(n4), o4.setSelectedRange(i3), t3(r4); 5271 }; 5272 }(this)); 5273 }, s3.proxyMethod("responder?.getSelectedRange"), s3.proxyMethod("responder?.setSelectedRange"), s3.proxyMethod("responder?.expandSelectionInDirection"), s3.proxyMethod("responder?.selectionIsInCursorTarget"), s3.proxyMethod("responder?.selectionIsExpanded"), s3; 5274 }(e2.InputController), r3 = function(t3) { 5275 var e3, n3; 5276 return (e3 = t3.type) != null && (n3 = e3.match(/\/(\w+)$/)) != null ? n3[1] : void 0; 5277 }, s2 = (typeof " ".codePointAt == "function" ? " ".codePointAt(0) : void 0) != null, p = function(t3) { 5278 var n3; 5279 return t3.key && s2 && t3.key.codePointAt(0) === t3.keyCode ? t3.key : (t3.which === null ? n3 = t3.keyCode : t3.which !== 0 && t3.charCode !== 0 && (n3 = t3.charCode), n3 != null && u[n3] !== "escape" ? e2.UTF16String.fromCodepoints([n3]).toString() : void 0); 5280 }, h2 = function(t3) { 5281 var e3, n3, i3, o3, r4, s3, a3, u2, c2, l3; 5282 if (u2 = t3.clipboardData) { 5283 if (m.call(u2.types, "text/html") >= 0) { 5284 for (c2 = u2.types, i3 = 0, s3 = c2.length; s3 > i3; i3++) 5285 if (l3 = c2[i3], e3 = /^CorePasteboardFlavorType/.test(l3), n3 = /^dyn\./.test(l3) && u2.getData(l3), a3 = e3 || n3) 5286 return true; 5287 return false; 5288 } 5289 return o3 = m.call(u2.types, "com.apple.webarchive") >= 0, r4 = m.call(u2.types, "com.apple.flat-rtfd") >= 0, o3 || r4; 5290 } 5291 }, t2 = function(t3) { 5292 function e3(t4) { 5293 var e4; 5294 this.inputController = t4, e4 = this.inputController, this.responder = e4.responder, this.delegate = e4.delegate, this.inputSummary = e4.inputSummary, this.data = {}; 5295 } 5296 return f(e3, t3), e3.prototype.start = function(t4) { 5297 var e4, n3; 5298 return this.data.start = t4, this.isSignificant() ? (this.inputSummary.eventName === "keypress" && this.inputSummary.textAdded && (e4 = this.responder) != null && e4.deleteInDirection("left"), this.selectionIsExpanded() || (this.insertPlaceholder(), this.requestRender()), this.range = (n3 = this.responder) != null ? n3.getSelectedRange() : void 0) : void 0; 5299 }, e3.prototype.update = function(t4) { 5300 var e4; 5301 return this.data.update = t4, this.isSignificant() && (e4 = this.selectPlaceholder()) ? (this.forgetPlaceholder(), this.range = e4) : void 0; 5302 }, e3.prototype.end = function(t4) { 5303 var e4, n3, i3, o3; 5304 return this.data.end = t4, this.isSignificant() ? (this.forgetPlaceholder(), this.canApplyToDocument() ? (this.setInputSummary({ preferDocument: true, didInput: false }), (e4 = this.delegate) != null && e4.inputControllerWillPerformTyping(), (n3 = this.responder) != null && n3.setSelectedRange(this.range), (i3 = this.responder) != null && i3.insertString(this.data.end), (o3 = this.responder) != null ? o3.setSelectedRange(this.range[0] + this.data.end.length) : void 0) : this.data.start != null || this.data.update != null ? (this.requestReparse(), this.inputController.reset()) : void 0) : this.inputController.reset(); 5305 }, e3.prototype.getEndData = function() { 5306 return this.data.end; 5307 }, e3.prototype.isEnded = function() { 5308 return this.getEndData() != null; 5309 }, e3.prototype.isSignificant = function() { 5310 return n2.composesExistingText ? this.inputSummary.didInput : true; 5311 }, e3.prototype.canApplyToDocument = function() { 5312 var t4, e4; 5313 return ((t4 = this.data.start) != null ? t4.length : void 0) === 0 && ((e4 = this.data.end) != null ? e4.length : void 0) > 0 && this.range != null; 5314 }, e3.proxyMethod("inputController.setInputSummary"), e3.proxyMethod("inputController.requestRender"), e3.proxyMethod("inputController.requestReparse"), e3.proxyMethod("responder?.selectionIsExpanded"), e3.proxyMethod("responder?.insertPlaceholder"), e3.proxyMethod("responder?.selectPlaceholder"), e3.proxyMethod("responder?.forgetPlaceholder"), e3; 5315 }(e2.BasicObject); 5316 }.call(this), function() { 5317 var t2, n2, i2, o2 = function(t3, e3) { 5318 return function() { 5319 return t3.apply(e3, arguments); 5320 }; 5321 }, r3 = function(t3, e3) { 5322 function n3() { 5323 this.constructor = t3; 5324 } 5325 for (var i3 in e3) 5326 s2.call(e3, i3) && (t3[i3] = e3[i3]); 5327 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5328 }, s2 = {}.hasOwnProperty, a2 = [].indexOf || function(t3) { 5329 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 5330 if (e3 in this && this[e3] === t3) 5331 return e3; 5332 return -1; 5333 }; 5334 t2 = e2.dataTransferIsPlainText, n2 = e2.keyEventIsKeyboardCommand, i2 = e2.objectsAreEqual, e2.Level2InputController = function(s3) { 5335 function u() { 5336 return this.render = o2(this.render, this), u.__super__.constructor.apply(this, arguments); 5337 } 5338 var c, l2, h2, p, d, f; 5339 return r3(u, s3), u.prototype.elementDidMutate = function() { 5340 var t3; 5341 return this.scheduledRender ? this.composing && (t3 = this.delegate) != null && typeof t3.inputControllerDidAllowUnhandledInput == "function" ? t3.inputControllerDidAllowUnhandledInput() : void 0 : this.reparse(); 5342 }, u.prototype.scheduleRender = function() { 5343 return this.scheduledRender != null ? this.scheduledRender : this.scheduledRender = requestAnimationFrame(this.render); 5344 }, u.prototype.render = function() { 5345 var t3; 5346 return cancelAnimationFrame(this.scheduledRender), this.scheduledRender = null, this.composing || (t3 = this.delegate) != null && t3.render(), typeof this.afterRender == "function" && this.afterRender(), this.afterRender = null; 5347 }, u.prototype.reparse = function() { 5348 var t3; 5349 return (t3 = this.delegate) != null ? t3.reparse() : void 0; 5350 }, u.prototype.events = { keydown: function(t3) { 5351 var e3, i3, o3, r4; 5352 if (n2(t3)) { 5353 if (e3 = l2(t3), (r4 = this.delegate) != null ? r4.inputControllerDidReceiveKeyboardCommand(e3) : void 0) 5354 return t3.preventDefault(); 5355 } else if (o3 = t3.key, t3.altKey && (o3 += "+Alt"), t3.shiftKey && (o3 += "+Shift"), i3 = this.keys[o3]) 5356 return this.withEvent(t3, i3); 5357 }, paste: function(t3) { 5358 var e3, n3, i3, o3, r4, s4, a3, u2, c2; 5359 return h2(t3) ? (t3.preventDefault(), this.attachFiles(t3.clipboardData.files)) : p(t3) ? (t3.preventDefault(), n3 = { type: "text/plain", string: t3.clipboardData.getData("text/plain") }, (i3 = this.delegate) != null && i3.inputControllerWillPaste(n3), (o3 = this.responder) != null && o3.insertString(n3.string), this.render(), (r4 = this.delegate) != null ? r4.inputControllerDidPaste(n3) : void 0) : (e3 = (s4 = t3.clipboardData) != null ? s4.getData("URL") : void 0) ? (t3.preventDefault(), n3 = { type: "text/html", html: this.createLinkHTML(e3) }, (a3 = this.delegate) != null && a3.inputControllerWillPaste(n3), (u2 = this.responder) != null && u2.insertHTML(n3.html), this.render(), (c2 = this.delegate) != null ? c2.inputControllerDidPaste(n3) : void 0) : void 0; 5360 }, beforeinput: function(t3) { 5361 var e3; 5362 return (e3 = this.inputTypes[t3.inputType]) ? (this.withEvent(t3, e3), this.scheduleRender()) : void 0; 5363 }, input: function() { 5364 return e2.selectionChangeObserver.reset(); 5365 }, dragstart: function(t3) { 5366 var e3, n3; 5367 return ((e3 = this.responder) != null ? e3.selectionContainsAttachments() : void 0) ? (t3.dataTransfer.setData("application/x-trix-dragging", true), this.dragging = { range: (n3 = this.responder) != null ? n3.getSelectedRange() : void 0, point: d(t3) }) : void 0; 5368 }, dragenter: function(t3) { 5369 return c(t3) ? t3.preventDefault() : void 0; 5370 }, dragover: function(t3) { 5371 var e3, n3; 5372 if (this.dragging) { 5373 if (t3.preventDefault(), e3 = d(t3), !i2(e3, this.dragging.point)) 5374 return this.dragging.point = e3, (n3 = this.responder) != null ? n3.setLocationRangeFromPointRange(e3) : void 0; 5375 } else if (c(t3)) 5376 return t3.preventDefault(); 5377 }, drop: function(t3) { 5378 var e3, n3, i3, o3; 5379 return this.dragging ? (t3.preventDefault(), (n3 = this.delegate) != null && n3.inputControllerWillMoveText(), (i3 = this.responder) != null && i3.moveTextFromRange(this.dragging.range), this.dragging = null, this.scheduleRender()) : c(t3) ? (t3.preventDefault(), e3 = d(t3), (o3 = this.responder) != null && o3.setLocationRangeFromPointRange(e3), this.attachFiles(t3.dataTransfer.files)) : void 0; 5380 }, dragend: function() { 5381 var t3; 5382 return this.dragging ? ((t3 = this.responder) != null && t3.setSelectedRange(this.dragging.range), this.dragging = null) : void 0; 5383 }, compositionend: function() { 5384 return this.composing ? (this.composing = false, this.scheduleRender()) : void 0; 5385 } }, u.prototype.keys = { ArrowLeft: function() { 5386 var t3, e3; 5387 return ((t3 = this.responder) != null ? t3.shouldManageMovingCursorInDirection("backward") : void 0) ? (this.event.preventDefault(), (e3 = this.responder) != null ? e3.moveCursorInDirection("backward") : void 0) : void 0; 5388 }, ArrowRight: function() { 5389 var t3, e3; 5390 return ((t3 = this.responder) != null ? t3.shouldManageMovingCursorInDirection("forward") : void 0) ? (this.event.preventDefault(), (e3 = this.responder) != null ? e3.moveCursorInDirection("forward") : void 0) : void 0; 5391 }, Backspace: function() { 5392 var t3, e3, n3; 5393 return ((t3 = this.responder) != null ? t3.shouldManageDeletingInDirection("backward") : void 0) ? (this.event.preventDefault(), (e3 = this.delegate) != null && e3.inputControllerWillPerformTyping(), (n3 = this.responder) != null && n3.deleteInDirection("backward"), this.render()) : void 0; 5394 }, Tab: function() { 5395 var t3, e3; 5396 return ((t3 = this.responder) != null ? t3.canIncreaseNestingLevel() : void 0) ? (this.event.preventDefault(), (e3 = this.responder) != null && e3.increaseNestingLevel(), this.render()) : void 0; 5397 }, "Tab+Shift": function() { 5398 var t3, e3; 5399 return ((t3 = this.responder) != null ? t3.canDecreaseNestingLevel() : void 0) ? (this.event.preventDefault(), (e3 = this.responder) != null && e3.decreaseNestingLevel(), this.render()) : void 0; 5400 } }, u.prototype.inputTypes = { deleteByComposition: function() { 5401 return this.deleteInDirection("backward", { recordUndoEntry: false }); 5402 }, deleteByCut: function() { 5403 return this.deleteInDirection("backward"); 5404 }, deleteByDrag: function() { 5405 return this.event.preventDefault(), this.withTargetDOMRange(function() { 5406 var t3; 5407 return this.deleteByDragRange = (t3 = this.responder) != null ? t3.getSelectedRange() : void 0; 5408 }); 5409 }, deleteCompositionText: function() { 5410 return this.deleteInDirection("backward", { recordUndoEntry: false }); 5411 }, deleteContent: function() { 5412 return this.deleteInDirection("backward"); 5413 }, deleteContentBackward: function() { 5414 return this.deleteInDirection("backward"); 5415 }, deleteContentForward: function() { 5416 return this.deleteInDirection("forward"); 5417 }, deleteEntireSoftLine: function() { 5418 return this.deleteInDirection("forward"); 5419 }, deleteHardLineBackward: function() { 5420 return this.deleteInDirection("backward"); 5421 }, deleteHardLineForward: function() { 5422 return this.deleteInDirection("forward"); 5423 }, deleteSoftLineBackward: function() { 5424 return this.deleteInDirection("backward"); 5425 }, deleteSoftLineForward: function() { 5426 return this.deleteInDirection("forward"); 5427 }, deleteWordBackward: function() { 5428 return this.deleteInDirection("backward"); 5429 }, deleteWordForward: function() { 5430 return this.deleteInDirection("forward"); 5431 }, formatBackColor: function() { 5432 return this.activateAttributeIfSupported("backgroundColor", this.event.data); 5433 }, formatBold: function() { 5434 return this.toggleAttributeIfSupported("bold"); 5435 }, formatFontColor: function() { 5436 return this.activateAttributeIfSupported("color", this.event.data); 5437 }, formatFontName: function() { 5438 return this.activateAttributeIfSupported("font", this.event.data); 5439 }, formatIndent: function() { 5440 var t3; 5441 return ((t3 = this.responder) != null ? t3.canIncreaseNestingLevel() : void 0) ? this.withTargetDOMRange(function() { 5442 var t4; 5443 return (t4 = this.responder) != null ? t4.increaseNestingLevel() : void 0; 5444 }) : void 0; 5445 }, formatItalic: function() { 5446 return this.toggleAttributeIfSupported("italic"); 5447 }, formatJustifyCenter: function() { 5448 return this.toggleAttributeIfSupported("justifyCenter"); 5449 }, formatJustifyFull: function() { 5450 return this.toggleAttributeIfSupported("justifyFull"); 5451 }, formatJustifyLeft: function() { 5452 return this.toggleAttributeIfSupported("justifyLeft"); 5453 }, formatJustifyRight: function() { 5454 return this.toggleAttributeIfSupported("justifyRight"); 5455 }, formatOutdent: function() { 5456 var t3; 5457 return ((t3 = this.responder) != null ? t3.canDecreaseNestingLevel() : void 0) ? this.withTargetDOMRange(function() { 5458 var t4; 5459 return (t4 = this.responder) != null ? t4.decreaseNestingLevel() : void 0; 5460 }) : void 0; 5461 }, formatRemove: function() { 5462 return this.withTargetDOMRange(function() { 5463 var t3, e3, n3, i3; 5464 i3 = []; 5465 for (t3 in (e3 = this.responder) != null ? e3.getCurrentAttributes() : void 0) 5466 i3.push((n3 = this.responder) != null ? n3.removeCurrentAttribute(t3) : void 0); 5467 return i3; 5468 }); 5469 }, formatSetBlockTextDirection: function() { 5470 return this.activateAttributeIfSupported("blockDir", this.event.data); 5471 }, formatSetInlineTextDirection: function() { 5472 return this.activateAttributeIfSupported("textDir", this.event.data); 5473 }, formatStrikeThrough: function() { 5474 return this.toggleAttributeIfSupported("strike"); 5475 }, formatSubscript: function() { 5476 return this.toggleAttributeIfSupported("sub"); 5477 }, formatSuperscript: function() { 5478 return this.toggleAttributeIfSupported("sup"); 5479 }, formatUnderline: function() { 5480 return this.toggleAttributeIfSupported("underline"); 5481 }, historyRedo: function() { 5482 var t3; 5483 return (t3 = this.delegate) != null ? t3.inputControllerWillPerformRedo() : void 0; 5484 }, historyUndo: function() { 5485 var t3; 5486 return (t3 = this.delegate) != null ? t3.inputControllerWillPerformUndo() : void 0; 5487 }, insertCompositionText: function() { 5488 return this.composing = true, this.insertString(this.event.data); 5489 }, insertFromComposition: function() { 5490 return this.composing = false, this.insertString(this.event.data); 5491 }, insertFromDrop: function() { 5492 var t3, e3; 5493 return (t3 = this.deleteByDragRange) ? (this.deleteByDragRange = null, (e3 = this.delegate) != null && e3.inputControllerWillMoveText(), this.withTargetDOMRange(function() { 5494 var e4; 5495 return (e4 = this.responder) != null ? e4.moveTextFromRange(t3) : void 0; 5496 })) : void 0; 5497 }, insertFromPaste: function() { 5498 var n3, i3, o3, r4, s4, a3, u2, c2, l3, h3, p2; 5499 return n3 = this.event.dataTransfer, s4 = { dataTransfer: n3 }, (i3 = n3.getData("URL")) ? (this.event.preventDefault(), s4.type = "text/html", p2 = (r4 = n3.getData("public.url-name")) ? e2.squishBreakableWhitespace(r4).trim() : i3, s4.html = this.createLinkHTML(i3, p2), (a3 = this.delegate) != null && a3.inputControllerWillPaste(s4), this.withTargetDOMRange(function() { 5500 var t3; 5501 return (t3 = this.responder) != null ? t3.insertHTML(s4.html) : void 0; 5502 }), this.afterRender = function(t3) { 5503 return function() { 5504 var e3; 5505 return (e3 = t3.delegate) != null ? e3.inputControllerDidPaste(s4) : void 0; 5506 }; 5507 }(this)) : t2(n3) ? (s4.type = "text/plain", s4.string = n3.getData("text/plain"), (u2 = this.delegate) != null && u2.inputControllerWillPaste(s4), this.withTargetDOMRange(function() { 5508 var t3; 5509 return (t3 = this.responder) != null ? t3.insertString(s4.string) : void 0; 5510 }), this.afterRender = function(t3) { 5511 return function() { 5512 var e3; 5513 return (e3 = t3.delegate) != null ? e3.inputControllerDidPaste(s4) : void 0; 5514 }; 5515 }(this)) : (o3 = n3.getData("text/html")) ? (this.event.preventDefault(), s4.type = "text/html", s4.html = o3, (c2 = this.delegate) != null && c2.inputControllerWillPaste(s4), this.withTargetDOMRange(function() { 5516 var t3; 5517 return (t3 = this.responder) != null ? t3.insertHTML(s4.html) : void 0; 5518 }), this.afterRender = function(t3) { 5519 return function() { 5520 var e3; 5521 return (e3 = t3.delegate) != null ? e3.inputControllerDidPaste(s4) : void 0; 5522 }; 5523 }(this)) : ((l3 = n3.files) != null ? l3.length : void 0) ? (s4.type = "File", s4.file = n3.files[0], (h3 = this.delegate) != null && h3.inputControllerWillPaste(s4), this.withTargetDOMRange(function() { 5524 var t3; 5525 return (t3 = this.responder) != null ? t3.insertFile(s4.file) : void 0; 5526 }), this.afterRender = function(t3) { 5527 return function() { 5528 var e3; 5529 return (e3 = t3.delegate) != null ? e3.inputControllerDidPaste(s4) : void 0; 5530 }; 5531 }(this)) : void 0; 5532 }, insertFromYank: function() { 5533 return this.insertString(this.event.data); 5534 }, insertLineBreak: function() { 5535 return this.insertString("\n"); 5536 }, insertLink: function() { 5537 return this.activateAttributeIfSupported("href", this.event.data); 5538 }, insertOrderedList: function() { 5539 return this.toggleAttributeIfSupported("number"); 5540 }, insertParagraph: function() { 5541 var t3; 5542 return (t3 = this.delegate) != null && t3.inputControllerWillPerformTyping(), this.withTargetDOMRange(function() { 5543 var t4; 5544 return (t4 = this.responder) != null ? t4.insertLineBreak() : void 0; 5545 }); 5546 }, insertReplacementText: function() { 5547 return this.insertString(this.event.dataTransfer.getData("text/plain"), { updatePosition: false }); 5548 }, insertText: function() { 5549 var t3, e3; 5550 return this.insertString((t3 = this.event.data) != null ? t3 : (e3 = this.event.dataTransfer) != null ? e3.getData("text/plain") : void 0); 5551 }, insertTranspose: function() { 5552 return this.insertString(this.event.data); 5553 }, insertUnorderedList: function() { 5554 return this.toggleAttributeIfSupported("bullet"); 5555 } }, u.prototype.insertString = function(t3, e3) { 5556 var n3; 5557 return t3 == null && (t3 = ""), (n3 = this.delegate) != null && n3.inputControllerWillPerformTyping(), this.withTargetDOMRange(function() { 5558 var n4; 5559 return (n4 = this.responder) != null ? n4.insertString(t3, e3) : void 0; 5560 }); 5561 }, u.prototype.toggleAttributeIfSupported = function(t3) { 5562 var n3; 5563 return a2.call(e2.getAllAttributeNames(), t3) >= 0 ? ((n3 = this.delegate) != null && n3.inputControllerWillPerformFormatting(t3), this.withTargetDOMRange(function() { 5564 var e3; 5565 return (e3 = this.responder) != null ? e3.toggleCurrentAttribute(t3) : void 0; 5566 })) : void 0; 5567 }, u.prototype.activateAttributeIfSupported = function(t3, n3) { 5568 var i3; 5569 return a2.call(e2.getAllAttributeNames(), t3) >= 0 ? ((i3 = this.delegate) != null && i3.inputControllerWillPerformFormatting(t3), this.withTargetDOMRange(function() { 5570 var e3; 5571 return (e3 = this.responder) != null ? e3.setCurrentAttribute(t3, n3) : void 0; 5572 })) : void 0; 5573 }, u.prototype.deleteInDirection = function(t3, e3) { 5574 var n3, i3, o3, r4; 5575 return o3 = (e3 != null ? e3 : { recordUndoEntry: true }).recordUndoEntry, o3 && (r4 = this.delegate) != null && r4.inputControllerWillPerformTyping(), i3 = function(e4) { 5576 return function() { 5577 var n4; 5578 return (n4 = e4.responder) != null ? n4.deleteInDirection(t3) : void 0; 5579 }; 5580 }(this), (n3 = this.getTargetDOMRange({ minLength: 2 })) ? this.withTargetDOMRange(n3, i3) : i3(); 5581 }, u.prototype.withTargetDOMRange = function(t3, n3) { 5582 var i3; 5583 return typeof t3 == "function" && (n3 = t3, t3 = this.getTargetDOMRange()), t3 ? (i3 = this.responder) != null ? i3.withTargetDOMRange(t3, n3.bind(this)) : void 0 : (e2.selectionChangeObserver.reset(), n3.call(this)); 5584 }, u.prototype.getTargetDOMRange = function(t3) { 5585 var e3, n3, i3, o3; 5586 return i3 = (t3 != null ? t3 : { minLength: 0 }).minLength, (o3 = typeof (e3 = this.event).getTargetRanges == "function" ? e3.getTargetRanges() : void 0) && o3.length && (n3 = f(o3[0]), i3 === 0 || n3.toString().length >= i3) ? n3 : void 0; 5587 }, f = function(t3) { 5588 var e3; 5589 return e3 = document.createRange(), e3.setStart(t3.startContainer, t3.startOffset), e3.setEnd(t3.endContainer, t3.endOffset), e3; 5590 }, u.prototype.withEvent = function(t3, e3) { 5591 var n3; 5592 this.event = t3; 5593 try { 5594 n3 = e3.call(this); 5595 } finally { 5596 this.event = null; 5597 } 5598 return n3; 5599 }, c = function(t3) { 5600 var e3, n3; 5601 return a2.call((e3 = (n3 = t3.dataTransfer) != null ? n3.types : void 0) != null ? e3 : [], "Files") >= 0; 5602 }, h2 = function(t3) { 5603 var e3; 5604 return (e3 = t3.clipboardData) ? a2.call(e3.types, "Files") >= 0 && e3.types.length === 1 && e3.files.length >= 1 : void 0; 5605 }, p = function(t3) { 5606 var e3; 5607 return (e3 = t3.clipboardData) ? a2.call(e3.types, "text/plain") >= 0 && e3.types.length === 1 : void 0; 5608 }, l2 = function(t3) { 5609 var e3; 5610 return e3 = [], t3.altKey && e3.push("alt"), t3.shiftKey && e3.push("shift"), e3.push(t3.key), e3; 5611 }, d = function(t3) { 5612 return { x: t3.clientX, y: t3.clientY }; 5613 }, u; 5614 }(e2.InputController); 5615 }.call(this), function() { 5616 var t2, n2, i2, o2, r3, s2, a2, u, c = function(t3, e3) { 5617 return function() { 5618 return t3.apply(e3, arguments); 5619 }; 5620 }, l2 = function(t3, e3) { 5621 function n3() { 5622 this.constructor = t3; 5623 } 5624 for (var i3 in e3) 5625 h2.call(e3, i3) && (t3[i3] = e3[i3]); 5626 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5627 }, h2 = {}.hasOwnProperty; 5628 n2 = e2.defer, i2 = e2.handleEvent, s2 = e2.makeElement, u = e2.tagName, a2 = e2.config, r3 = a2.lang, t2 = a2.css, o2 = a2.keyNames, e2.AttachmentEditorController = function(a3) { 5629 function h3(t3, e3, n3, i3) { 5630 this.attachmentPiece = t3, this.element = e3, this.container = n3, this.options = i3 != null ? i3 : {}, this.didBlurCaption = c(this.didBlurCaption, this), this.didChangeCaption = c(this.didChangeCaption, this), this.didInputCaption = c(this.didInputCaption, this), this.didKeyDownCaption = c(this.didKeyDownCaption, this), this.didClickActionButton = c(this.didClickActionButton, this), this.didClickToolbar = c(this.didClickToolbar, this), this.attachment = this.attachmentPiece.attachment, u(this.element) === "a" && (this.element = this.element.firstChild), this.install(); 5631 } 5632 var p; 5633 return l2(h3, a3), p = function(t3) { 5634 return function() { 5635 var e3; 5636 return e3 = t3.apply(this, arguments), e3["do"](), this.undos == null && (this.undos = []), this.undos.push(e3.undo); 5637 }; 5638 }, h3.prototype.install = function() { 5639 return this.makeElementMutable(), this.addToolbar(), this.attachment.isPreviewable() ? this.installCaptionEditor() : void 0; 5640 }, h3.prototype.uninstall = function() { 5641 var t3, e3; 5642 for (this.savePendingCaption(); e3 = this.undos.pop(); ) 5643 e3(); 5644 return (t3 = this.delegate) != null ? t3.didUninstallAttachmentEditor(this) : void 0; 5645 }, h3.prototype.savePendingCaption = function() { 5646 var t3, e3, n3; 5647 return this.pendingCaption != null ? (t3 = this.pendingCaption, this.pendingCaption = null, t3 ? (e3 = this.delegate) != null && typeof e3.attachmentEditorDidRequestUpdatingAttributesForAttachment == "function" ? e3.attachmentEditorDidRequestUpdatingAttributesForAttachment({ caption: t3 }, this.attachment) : void 0 : (n3 = this.delegate) != null && typeof n3.attachmentEditorDidRequestRemovingAttributeForAttachment == "function" ? n3.attachmentEditorDidRequestRemovingAttributeForAttachment("caption", this.attachment) : void 0) : void 0; 5648 }, h3.prototype.makeElementMutable = p(function() { 5649 return { "do": function(t3) { 5650 return function() { 5651 return t3.element.dataset.trixMutable = true; 5652 }; 5653 }(this), undo: function(t3) { 5654 return function() { 5655 return delete t3.element.dataset.trixMutable; 5656 }; 5657 }(this) }; 5658 }), h3.prototype.addToolbar = p(function() { 5659 var n3; 5660 return n3 = s2({ tagName: "div", className: t2.attachmentToolbar, data: { trixMutable: true }, childNodes: s2({ tagName: "div", className: "trix-button-row", childNodes: s2({ tagName: "span", className: "trix-button-group trix-button-group--actions", childNodes: s2({ tagName: "button", className: "trix-button trix-button--remove", textContent: r3.remove, attributes: { title: r3.remove }, data: { trixAction: "remove" } }) }) }) }), this.attachment.isPreviewable() && n3.appendChild(s2({ tagName: "div", className: t2.attachmentMetadataContainer, childNodes: s2({ tagName: "span", className: t2.attachmentMetadata, childNodes: [s2({ tagName: "span", className: t2.attachmentName, textContent: this.attachment.getFilename(), attributes: { title: this.attachment.getFilename() } }), s2({ tagName: "span", className: t2.attachmentSize, textContent: this.attachment.getFormattedFilesize() })] }) })), i2("click", { onElement: n3, withCallback: this.didClickToolbar }), i2("click", { onElement: n3, matchingSelector: "[data-trix-action]", withCallback: this.didClickActionButton }), { "do": function(t3) { 5661 return function() { 5662 return t3.element.appendChild(n3); 5663 }; 5664 }(this), undo: function() { 5665 return function() { 5666 return e2.removeNode(n3); 5667 }; 5668 }(this) }; 5669 }), h3.prototype.installCaptionEditor = p(function() { 5670 var o3, a4, u2, c2, l3; 5671 return c2 = s2({ tagName: "textarea", className: t2.attachmentCaptionEditor, attributes: { placeholder: r3.captionPlaceholder }, data: { trixMutable: true } }), c2.value = this.attachmentPiece.getCaption(), l3 = c2.cloneNode(), l3.classList.add("trix-autoresize-clone"), l3.tabIndex = -1, o3 = function() { 5672 return l3.value = c2.value, c2.style.height = l3.scrollHeight + "px"; 5673 }, i2("input", { onElement: c2, withCallback: o3 }), i2("input", { onElement: c2, withCallback: this.didInputCaption }), i2("keydown", { onElement: c2, withCallback: this.didKeyDownCaption }), i2("change", { onElement: c2, withCallback: this.didChangeCaption }), i2("blur", { onElement: c2, withCallback: this.didBlurCaption }), u2 = this.element.querySelector("figcaption"), a4 = u2.cloneNode(), { "do": function(e3) { 5674 return function() { 5675 return u2.style.display = "none", a4.appendChild(c2), a4.appendChild(l3), a4.classList.add(t2.attachmentCaption + "--editing"), u2.parentElement.insertBefore(a4, u2), o3(), e3.options.editCaption ? n2(function() { 5676 return c2.focus(); 5677 }) : void 0; 5678 }; 5679 }(this), undo: function() { 5680 return e2.removeNode(a4), u2.style.display = null; 5681 } }; 5682 }), h3.prototype.didClickToolbar = function(t3) { 5683 return t3.preventDefault(), t3.stopPropagation(); 5684 }, h3.prototype.didClickActionButton = function(t3) { 5685 var e3, n3; 5686 switch (e3 = t3.target.getAttribute("data-trix-action")) { 5687 case "remove": 5688 return (n3 = this.delegate) != null ? n3.attachmentEditorDidRequestRemovalOfAttachment(this.attachment) : void 0; 5689 } 5690 }, h3.prototype.didKeyDownCaption = function(t3) { 5691 var e3; 5692 return o2[t3.keyCode] === "return" ? (t3.preventDefault(), this.savePendingCaption(), (e3 = this.delegate) != null && typeof e3.attachmentEditorDidRequestDeselectingAttachment == "function" ? e3.attachmentEditorDidRequestDeselectingAttachment(this.attachment) : void 0) : void 0; 5693 }, h3.prototype.didInputCaption = function(t3) { 5694 return this.pendingCaption = t3.target.value.replace(/\s/g, " ").trim(); 5695 }, h3.prototype.didChangeCaption = function() { 5696 return this.savePendingCaption(); 5697 }, h3.prototype.didBlurCaption = function() { 5698 return this.savePendingCaption(); 5699 }, h3; 5700 }(e2.BasicObject); 5701 }.call(this), function() { 5702 var t2, n2, i2, o2 = function(t3, e3) { 5703 function n3() { 5704 this.constructor = t3; 5705 } 5706 for (var i3 in e3) 5707 r3.call(e3, i3) && (t3[i3] = e3[i3]); 5708 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5709 }, r3 = {}.hasOwnProperty; 5710 i2 = e2.makeElement, t2 = e2.config.css, e2.AttachmentView = function(r4) { 5711 function s2() { 5712 s2.__super__.constructor.apply(this, arguments), this.attachment = this.object, this.attachment.uploadProgressDelegate = this, this.attachmentPiece = this.options.piece; 5713 } 5714 var a2; 5715 return o2(s2, r4), s2.attachmentSelector = "[data-trix-attachment]", s2.prototype.createContentNodes = function() { 5716 return []; 5717 }, s2.prototype.createNodes = function() { 5718 var e3, n3, o3, r5, s3, u, c; 5719 if (e3 = r5 = i2({ tagName: "figure", className: this.getClassName(), data: this.getData(), editable: false }), (n3 = this.getHref()) && (r5 = i2({ tagName: "a", editable: false, attributes: { href: n3, tabindex: -1 } }), e3.appendChild(r5)), this.attachment.hasContent()) 5720 r5.innerHTML = this.attachment.getContent(); 5721 else 5722 for (c = this.createContentNodes(), o3 = 0, s3 = c.length; s3 > o3; o3++) 5723 u = c[o3], r5.appendChild(u); 5724 return r5.appendChild(this.createCaptionElement()), this.attachment.isPending() && (this.progressElement = i2({ tagName: "progress", attributes: { "class": t2.attachmentProgress, value: this.attachment.getUploadProgress(), max: 100 }, data: { trixMutable: true, trixStoreKey: ["progressElement", this.attachment.id].join("/") } }), e3.appendChild(this.progressElement)), [a2("left"), e3, a2("right")]; 5725 }, s2.prototype.createCaptionElement = function() { 5726 var e3, n3, o3, r5, s3, a3, u; 5727 return o3 = i2({ tagName: "figcaption", className: t2.attachmentCaption }), (e3 = this.attachmentPiece.getCaption()) ? (o3.classList.add(t2.attachmentCaption + "--edited"), o3.textContent = e3) : (n3 = this.getCaptionConfig(), n3.name && (r5 = this.attachment.getFilename()), n3.size && (a3 = this.attachment.getFormattedFilesize()), r5 && (s3 = i2({ tagName: "span", className: t2.attachmentName, textContent: r5 }), o3.appendChild(s3)), a3 && (r5 && o3.appendChild(document.createTextNode(" ")), u = i2({ tagName: "span", className: t2.attachmentSize, textContent: a3 }), o3.appendChild(u))), o3; 5728 }, s2.prototype.getClassName = function() { 5729 var e3, n3; 5730 return n3 = [t2.attachment, t2.attachment + "--" + this.attachment.getType()], (e3 = this.attachment.getExtension()) && n3.push(t2.attachment + "--" + e3), n3.join(" "); 5731 }, s2.prototype.getData = function() { 5732 var t3, e3; 5733 return e3 = { trixAttachment: JSON.stringify(this.attachment), trixContentType: this.attachment.getContentType(), trixId: this.attachment.id }, t3 = this.attachmentPiece.attributes, t3.isEmpty() || (e3.trixAttributes = JSON.stringify(t3)), this.attachment.isPending() && (e3.trixSerialize = false), e3; 5734 }, s2.prototype.getHref = function() { 5735 return n2(this.attachment.getContent(), "a") ? void 0 : this.attachment.getHref(); 5736 }, s2.prototype.getCaptionConfig = function() { 5737 var t3, n3, i3; 5738 return i3 = this.attachment.getType(), t3 = e2.copyObject((n3 = e2.config.attachments[i3]) != null ? n3.caption : void 0), i3 === "file" && (t3.name = true), t3; 5739 }, s2.prototype.findProgressElement = function() { 5740 var t3; 5741 return (t3 = this.findElement()) != null ? t3.querySelector("progress") : void 0; 5742 }, a2 = function(t3) { 5743 return i2({ tagName: "span", textContent: e2.ZERO_WIDTH_SPACE, data: { trixCursorTarget: t3, trixSerialize: false } }); 5744 }, s2.prototype.attachmentDidChangeUploadProgress = function() { 5745 var t3, e3; 5746 return e3 = this.attachment.getUploadProgress(), (t3 = this.findProgressElement()) != null ? t3.value = e3 : void 0; 5747 }, s2; 5748 }(e2.ObjectView), n2 = function(t3, e3) { 5749 var n3; 5750 return n3 = i2("div"), n3.innerHTML = t3 != null ? t3 : "", n3.querySelector(e3); 5751 }; 5752 }.call(this), function() { 5753 var t2, n2 = function(t3, e3) { 5754 function n3() { 5755 this.constructor = t3; 5756 } 5757 for (var o2 in e3) 5758 i2.call(e3, o2) && (t3[o2] = e3[o2]); 5759 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5760 }, i2 = {}.hasOwnProperty; 5761 t2 = e2.makeElement, e2.PreviewableAttachmentView = function(i3) { 5762 function o2() { 5763 o2.__super__.constructor.apply(this, arguments), this.attachment.previewDelegate = this; 5764 } 5765 return n2(o2, i3), o2.prototype.createContentNodes = function() { 5766 return this.image = t2({ tagName: "img", attributes: { src: "" }, data: { trixMutable: true } }), this.refresh(this.image), [this.image]; 5767 }, o2.prototype.createCaptionElement = function() { 5768 var t3; 5769 return t3 = o2.__super__.createCaptionElement.apply(this, arguments), t3.textContent || t3.setAttribute("data-trix-placeholder", e2.config.lang.captionPlaceholder), t3; 5770 }, o2.prototype.refresh = function(t3) { 5771 var e3; 5772 return t3 == null && (t3 = (e3 = this.findElement()) != null ? e3.querySelector("img") : void 0), t3 ? this.updateAttributesForImage(t3) : void 0; 5773 }, o2.prototype.updateAttributesForImage = function(t3) { 5774 var e3, n3, i4, o3, r3, s2; 5775 return r3 = this.attachment.getURL(), n3 = this.attachment.getPreviewURL(), t3.src = n3 || r3, n3 === r3 ? t3.removeAttribute("data-trix-serialized-attributes") : (i4 = JSON.stringify({ src: r3 }), t3.setAttribute("data-trix-serialized-attributes", i4)), s2 = this.attachment.getWidth(), e3 = this.attachment.getHeight(), s2 != null && (t3.width = s2), e3 != null && (t3.height = e3), o3 = ["imageElement", this.attachment.id, t3.src, t3.width, t3.height].join("/"), t3.dataset.trixStoreKey = o3; 5776 }, o2.prototype.attachmentDidChangeAttributes = function() { 5777 return this.refresh(this.image), this.refresh(); 5778 }, o2; 5779 }(e2.AttachmentView); 5780 }.call(this), function() { 5781 var t2, n2, i2, o2 = function(t3, e3) { 5782 function n3() { 5783 this.constructor = t3; 5784 } 5785 for (var i3 in e3) 5786 r3.call(e3, i3) && (t3[i3] = e3[i3]); 5787 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5788 }, r3 = {}.hasOwnProperty; 5789 i2 = e2.makeElement, t2 = e2.findInnerElement, n2 = e2.getTextConfig, e2.PieceView = function(r4) { 5790 function s2() { 5791 var t3; 5792 s2.__super__.constructor.apply(this, arguments), this.piece = this.object, this.attributes = this.piece.getAttributes(), t3 = this.options, this.textConfig = t3.textConfig, this.context = t3.context, this.piece.attachment ? this.attachment = this.piece.attachment : this.string = this.piece.toString(); 5793 } 5794 var a2; 5795 return o2(s2, r4), s2.prototype.createNodes = function() { 5796 var e3, n3, i3, o3, r5, s3; 5797 if (s3 = this.attachment ? this.createAttachmentNodes() : this.createStringNodes(), e3 = this.createElement()) { 5798 for (i3 = t2(e3), n3 = 0, o3 = s3.length; o3 > n3; n3++) 5799 r5 = s3[n3], i3.appendChild(r5); 5800 s3 = [e3]; 5801 } 5802 return s3; 5803 }, s2.prototype.createAttachmentNodes = function() { 5804 var t3, n3; 5805 return t3 = this.attachment.isPreviewable() ? e2.PreviewableAttachmentView : e2.AttachmentView, n3 = this.createChildView(t3, this.piece.attachment, { piece: this.piece }), n3.getNodes(); 5806 }, s2.prototype.createStringNodes = function() { 5807 var t3, e3, n3, o3, r5, s3, a3, u, c, l2; 5808 if ((u = this.textConfig) != null ? u.plaintext : void 0) 5809 return [document.createTextNode(this.string)]; 5810 for (a3 = [], c = this.string.split("\n"), n3 = e3 = 0, o3 = c.length; o3 > e3; n3 = ++e3) 5811 l2 = c[n3], n3 > 0 && (t3 = i2("br"), a3.push(t3)), (r5 = l2.length) && (s3 = document.createTextNode(this.preserveSpaces(l2)), a3.push(s3)); 5812 return a3; 5813 }, s2.prototype.createElement = function() { 5814 var t3, e3, o3, r5, s3, a3, u, c, l2; 5815 c = {}, a3 = this.attributes; 5816 for (r5 in a3) 5817 if (l2 = a3[r5], (t3 = n2(r5)) && (t3.tagName && (s3 = i2(t3.tagName), o3 ? (o3.appendChild(s3), o3 = s3) : e3 = o3 = s3), t3.styleProperty && (c[t3.styleProperty] = l2), t3.style)) { 5818 u = t3.style; 5819 for (r5 in u) 5820 l2 = u[r5], c[r5] = l2; 5821 } 5822 if (Object.keys(c).length) { 5823 e3 == null && (e3 = i2("span")); 5824 for (r5 in c) 5825 l2 = c[r5], e3.style[r5] = l2; 5826 } 5827 return e3; 5828 }, s2.prototype.createContainerElement = function() { 5829 var t3, e3, o3, r5, s3; 5830 r5 = this.attributes; 5831 for (o3 in r5) 5832 if (s3 = r5[o3], (e3 = n2(o3)) && e3.groupTagName) 5833 return t3 = {}, t3[o3] = s3, i2(e3.groupTagName, t3); 5834 }, a2 = e2.NON_BREAKING_SPACE, s2.prototype.preserveSpaces = function(t3) { 5835 return this.context.isLast && (t3 = t3.replace(/\ $/, a2)), t3 = t3.replace(/(\S)\ {3}(\S)/g, "$1 " + a2 + " $2").replace(/\ {2}/g, a2 + " ").replace(/\ {2}/g, " " + a2), (this.context.isFirst || this.context.followsWhitespace) && (t3 = t3.replace(/^\ /, a2)), t3; 5836 }, s2; 5837 }(e2.ObjectView); 5838 }.call(this), function() { 5839 var t2 = function(t3, e3) { 5840 function i2() { 5841 this.constructor = t3; 5842 } 5843 for (var o2 in e3) 5844 n2.call(e3, o2) && (t3[o2] = e3[o2]); 5845 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 5846 }, n2 = {}.hasOwnProperty; 5847 e2.TextView = function(n3) { 5848 function i2() { 5849 i2.__super__.constructor.apply(this, arguments), this.text = this.object, this.textConfig = this.options.textConfig; 5850 } 5851 var o2; 5852 return t2(i2, n3), i2.prototype.createNodes = function() { 5853 var t3, n4, i3, r3, s2, a2, u, c, l2, h2; 5854 for (a2 = [], c = e2.ObjectGroup.groupObjects(this.getPieces()), r3 = c.length - 1, i3 = n4 = 0, s2 = c.length; s2 > n4; i3 = ++n4) 5855 u = c[i3], t3 = {}, i3 === 0 && (t3.isFirst = true), i3 === r3 && (t3.isLast = true), o2(l2) && (t3.followsWhitespace = true), h2 = this.findOrCreateCachedChildView(e2.PieceView, u, { textConfig: this.textConfig, context: t3 }), a2.push.apply(a2, h2.getNodes()), l2 = u; 5856 return a2; 5857 }, i2.prototype.getPieces = function() { 5858 var t3, e3, n4, i3, o3; 5859 for (i3 = this.text.getPieces(), o3 = [], t3 = 0, e3 = i3.length; e3 > t3; t3++) 5860 n4 = i3[t3], n4.hasAttribute("blockBreak") || o3.push(n4); 5861 return o3; 5862 }, o2 = function(t3) { 5863 return /\s$/.test(t3 != null ? t3.toString() : void 0); 5864 }, i2; 5865 }(e2.ObjectView); 5866 }.call(this), function() { 5867 var t2, n2, i2, o2 = function(t3, e3) { 5868 function n3() { 5869 this.constructor = t3; 5870 } 5871 for (var i3 in e3) 5872 r3.call(e3, i3) && (t3[i3] = e3[i3]); 5873 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5874 }, r3 = {}.hasOwnProperty; 5875 i2 = e2.makeElement, n2 = e2.getBlockConfig, t2 = e2.config.css, e2.BlockView = function(r4) { 5876 function s2() { 5877 s2.__super__.constructor.apply(this, arguments), this.block = this.object, this.attributes = this.block.getAttributes(); 5878 } 5879 return o2(s2, r4), s2.prototype.createNodes = function() { 5880 var t3, o3, r5, s3, a2, u, c, l2, h2, p, d; 5881 if (o3 = document.createComment("block"), c = [o3], this.block.isEmpty() ? c.push(i2("br")) : (p = (l2 = n2(this.block.getLastAttribute())) != null ? l2.text : void 0, d = this.findOrCreateCachedChildView(e2.TextView, this.block.text, { textConfig: p }), c.push.apply(c, d.getNodes()), this.shouldAddExtraNewlineElement() && c.push(i2("br"))), this.attributes.length) 5882 return c; 5883 for (h2 = e2.config.blockAttributes["default"].tagName, this.block.isRTL() && (t3 = { dir: "rtl" }), r5 = i2({ tagName: h2, attributes: t3 }), s3 = 0, a2 = c.length; a2 > s3; s3++) 5884 u = c[s3], r5.appendChild(u); 5885 return [r5]; 5886 }, s2.prototype.createContainerElement = function(e3) { 5887 var o3, r5, s3, a2, u; 5888 return o3 = this.attributes[e3], u = n2(o3).tagName, e3 === 0 && this.block.isRTL() && (r5 = { dir: "rtl" }), o3 === "attachmentGallery" && (a2 = this.block.getBlockBreakPosition(), s3 = t2.attachmentGallery + " " + t2.attachmentGallery + "--" + a2), i2({ tagName: u, className: s3, attributes: r5 }); 5889 }, s2.prototype.shouldAddExtraNewlineElement = function() { 5890 return /\n\n$/.test(this.block.toString()); 5891 }, s2; 5892 }(e2.ObjectView); 5893 }.call(this), function() { 5894 var t2, n2, i2 = function(t3, e3) { 5895 function n3() { 5896 this.constructor = t3; 5897 } 5898 for (var i3 in e3) 5899 o2.call(e3, i3) && (t3[i3] = e3[i3]); 5900 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5901 }, o2 = {}.hasOwnProperty; 5902 t2 = e2.defer, n2 = e2.makeElement, e2.DocumentView = function(o3) { 5903 function r3() { 5904 r3.__super__.constructor.apply(this, arguments), this.element = this.options.element, this.elementStore = new e2.ElementStore(), this.setDocument(this.object); 5905 } 5906 var s2, a2, u; 5907 return i2(r3, o3), r3.render = function(t3) { 5908 var e3, i3; 5909 return e3 = n2("div"), i3 = new this(t3, { element: e3 }), i3.render(), i3.sync(), e3; 5910 }, r3.prototype.setDocument = function(t3) { 5911 return t3.isEqualTo(this.document) ? void 0 : this.document = this.object = t3; 5912 }, r3.prototype.render = function() { 5913 var t3, i3, o4, r4, s3, a3, u2; 5914 if (this.childViews = [], this.shadowElement = n2("div"), !this.document.isEmpty()) { 5915 for (s3 = e2.ObjectGroup.groupObjects(this.document.getBlocks(), { asTree: true }), a3 = [], t3 = 0, i3 = s3.length; i3 > t3; t3++) 5916 r4 = s3[t3], u2 = this.findOrCreateCachedChildView(e2.BlockView, r4), a3.push(function() { 5917 var t4, e3, n3, i4; 5918 for (n3 = u2.getNodes(), i4 = [], t4 = 0, e3 = n3.length; e3 > t4; t4++) 5919 o4 = n3[t4], i4.push(this.shadowElement.appendChild(o4)); 5920 return i4; 5921 }.call(this)); 5922 return a3; 5923 } 5924 }, r3.prototype.isSynced = function() { 5925 return s2(this.shadowElement, this.element); 5926 }, r3.prototype.sync = function() { 5927 var t3; 5928 for (t3 = this.createDocumentFragmentForSync(); this.element.lastChild; ) 5929 this.element.removeChild(this.element.lastChild); 5930 return this.element.appendChild(t3), this.didSync(); 5931 }, r3.prototype.didSync = function() { 5932 return this.elementStore.reset(a2(this.element)), t2(function(t3) { 5933 return function() { 5934 return t3.garbageCollectCachedViews(); 5935 }; 5936 }(this)); 5937 }, r3.prototype.createDocumentFragmentForSync = function() { 5938 var t3, e3, n3, i3, o4, r4, s3, u2, c, l2; 5939 for (e3 = document.createDocumentFragment(), u2 = this.shadowElement.childNodes, n3 = 0, o4 = u2.length; o4 > n3; n3++) 5940 s3 = u2[n3], e3.appendChild(s3.cloneNode(true)); 5941 for (c = a2(e3), i3 = 0, r4 = c.length; r4 > i3; i3++) 5942 t3 = c[i3], (l2 = this.elementStore.remove(t3)) && t3.parentNode.replaceChild(l2, t3); 5943 return e3; 5944 }, a2 = function(t3) { 5945 return t3.querySelectorAll("[data-trix-store-key]"); 5946 }, s2 = function(t3, e3) { 5947 return u(t3.innerHTML) === u(e3.innerHTML); 5948 }, u = function(t3) { 5949 return t3.replace(/ /g, " "); 5950 }, r3; 5951 }(e2.ObjectView); 5952 }.call(this), function() { 5953 var t2, n2, i2, o2, r3, s2 = function(t3, e3) { 5954 return function() { 5955 return t3.apply(e3, arguments); 5956 }; 5957 }, a2 = function(t3, e3) { 5958 function n3() { 5959 this.constructor = t3; 5960 } 5961 for (var i3 in e3) 5962 u.call(e3, i3) && (t3[i3] = e3[i3]); 5963 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 5964 }, u = {}.hasOwnProperty; 5965 i2 = e2.findClosestElementFromNode, o2 = e2.handleEvent, r3 = e2.innerElementIsActive, n2 = e2.defer, t2 = e2.AttachmentView.attachmentSelector, e2.CompositionController = function(u2) { 5966 function c(n3, i3) { 5967 this.element = n3, this.composition = i3, this.didClickAttachment = s2(this.didClickAttachment, this), this.didBlur = s2(this.didBlur, this), this.didFocus = s2(this.didFocus, this), this.documentView = new e2.DocumentView(this.composition.document, { element: this.element }), o2("focus", { onElement: this.element, withCallback: this.didFocus }), o2("blur", { onElement: this.element, withCallback: this.didBlur }), o2("click", { onElement: this.element, matchingSelector: "a[contenteditable=false]", preventDefault: true }), o2("mousedown", { onElement: this.element, matchingSelector: t2, withCallback: this.didClickAttachment }), o2("click", { onElement: this.element, matchingSelector: "a" + t2, preventDefault: true }); 5968 } 5969 return a2(c, u2), c.prototype.didFocus = function() { 5970 var t3, e3, n3; 5971 return t3 = function(t4) { 5972 return function() { 5973 var e4; 5974 return t4.focused ? void 0 : (t4.focused = true, (e4 = t4.delegate) != null && typeof e4.compositionControllerDidFocus == "function" ? e4.compositionControllerDidFocus() : void 0); 5975 }; 5976 }(this), (e3 = (n3 = this.blurPromise) != null ? n3.then(t3) : void 0) != null ? e3 : t3(); 5977 }, c.prototype.didBlur = function() { 5978 return this.blurPromise = new Promise(function(t3) { 5979 return function(e3) { 5980 return n2(function() { 5981 var n3; 5982 return r3(t3.element) || (t3.focused = null, (n3 = t3.delegate) != null && typeof n3.compositionControllerDidBlur == "function" && n3.compositionControllerDidBlur()), t3.blurPromise = null, e3(); 5983 }); 5984 }; 5985 }(this)); 5986 }, c.prototype.didClickAttachment = function(t3, e3) { 5987 var n3, o3, r4; 5988 return n3 = this.findAttachmentForElement(e3), o3 = i2(t3.target, { matchingSelector: "figcaption" }) != null, (r4 = this.delegate) != null && typeof r4.compositionControllerDidSelectAttachment == "function" ? r4.compositionControllerDidSelectAttachment(n3, { editCaption: o3 }) : void 0; 5989 }, c.prototype.getSerializableElement = function() { 5990 return this.isEditingAttachment() ? this.documentView.shadowElement : this.element; 5991 }, c.prototype.render = function() { 5992 var t3, e3, n3; 5993 return this.revision !== this.composition.revision && (this.documentView.setDocument(this.composition.document), this.documentView.render(), this.revision = this.composition.revision), this.canSyncDocumentView() && !this.documentView.isSynced() && ((t3 = this.delegate) != null && typeof t3.compositionControllerWillSyncDocumentView == "function" && t3.compositionControllerWillSyncDocumentView(), this.documentView.sync(), (e3 = this.delegate) != null && typeof e3.compositionControllerDidSyncDocumentView == "function" && e3.compositionControllerDidSyncDocumentView()), (n3 = this.delegate) != null && typeof n3.compositionControllerDidRender == "function" ? n3.compositionControllerDidRender() : void 0; 5994 }, c.prototype.rerenderViewForObject = function(t3) { 5995 return this.invalidateViewForObject(t3), this.render(); 5996 }, c.prototype.invalidateViewForObject = function(t3) { 5997 return this.documentView.invalidateViewForObject(t3); 5998 }, c.prototype.isViewCachingEnabled = function() { 5999 return this.documentView.isViewCachingEnabled(); 6000 }, c.prototype.enableViewCaching = function() { 6001 return this.documentView.enableViewCaching(); 6002 }, c.prototype.disableViewCaching = function() { 6003 return this.documentView.disableViewCaching(); 6004 }, c.prototype.refreshViewCache = function() { 6005 return this.documentView.garbageCollectCachedViews(); 6006 }, c.prototype.isEditingAttachment = function() { 6007 return this.attachmentEditor != null; 6008 }, c.prototype.installAttachmentEditorForAttachment = function(t3, n3) { 6009 var i3, o3, r4; 6010 if (((r4 = this.attachmentEditor) != null ? r4.attachment : void 0) !== t3 && (o3 = this.documentView.findElementForObject(t3))) 6011 return this.uninstallAttachmentEditor(), i3 = this.composition.document.getAttachmentPieceForAttachment(t3), this.attachmentEditor = new e2.AttachmentEditorController(i3, o3, this.element, n3), this.attachmentEditor.delegate = this; 6012 }, c.prototype.uninstallAttachmentEditor = function() { 6013 var t3; 6014 return (t3 = this.attachmentEditor) != null ? t3.uninstall() : void 0; 6015 }, c.prototype.didUninstallAttachmentEditor = function() { 6016 return this.attachmentEditor = null, this.render(); 6017 }, c.prototype.attachmentEditorDidRequestUpdatingAttributesForAttachment = function(t3, e3) { 6018 var n3; 6019 return (n3 = this.delegate) != null && typeof n3.compositionControllerWillUpdateAttachment == "function" && n3.compositionControllerWillUpdateAttachment(e3), this.composition.updateAttributesForAttachment(t3, e3); 6020 }, c.prototype.attachmentEditorDidRequestRemovingAttributeForAttachment = function(t3, e3) { 6021 var n3; 6022 return (n3 = this.delegate) != null && typeof n3.compositionControllerWillUpdateAttachment == "function" && n3.compositionControllerWillUpdateAttachment(e3), this.composition.removeAttributeForAttachment(t3, e3); 6023 }, c.prototype.attachmentEditorDidRequestRemovalOfAttachment = function(t3) { 6024 var e3; 6025 return (e3 = this.delegate) != null && typeof e3.compositionControllerDidRequestRemovalOfAttachment == "function" ? e3.compositionControllerDidRequestRemovalOfAttachment(t3) : void 0; 6026 }, c.prototype.attachmentEditorDidRequestDeselectingAttachment = function(t3) { 6027 var e3; 6028 return (e3 = this.delegate) != null && typeof e3.compositionControllerDidRequestDeselectingAttachment == "function" ? e3.compositionControllerDidRequestDeselectingAttachment(t3) : void 0; 6029 }, c.prototype.canSyncDocumentView = function() { 6030 return !this.isEditingAttachment(); 6031 }, c.prototype.findAttachmentForElement = function(t3) { 6032 return this.composition.document.getAttachmentById(parseInt(t3.dataset.trixId, 10)); 6033 }, c; 6034 }(e2.BasicObject); 6035 }.call(this), function() { 6036 var t2, n2, i2, o2 = function(t3, e3) { 6037 return function() { 6038 return t3.apply(e3, arguments); 6039 }; 6040 }, r3 = function(t3, e3) { 6041 function n3() { 6042 this.constructor = t3; 6043 } 6044 for (var i3 in e3) 6045 s2.call(e3, i3) && (t3[i3] = e3[i3]); 6046 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 6047 }, s2 = {}.hasOwnProperty; 6048 n2 = e2.handleEvent, i2 = e2.triggerEvent, t2 = e2.findClosestElementFromNode, e2.ToolbarController = function(e3) { 6049 function s3(t3) { 6050 this.element = t3, this.didKeyDownDialogInput = o2(this.didKeyDownDialogInput, this), this.didClickDialogButton = o2(this.didClickDialogButton, this), this.didClickAttributeButton = o2(this.didClickAttributeButton, this), this.didClickActionButton = o2(this.didClickActionButton, this), this.attributes = {}, this.actions = {}, this.resetDialogInputs(), n2("mousedown", { onElement: this.element, matchingSelector: a2, withCallback: this.didClickActionButton }), n2("mousedown", { onElement: this.element, matchingSelector: c, withCallback: this.didClickAttributeButton }), n2("click", { onElement: this.element, matchingSelector: v, preventDefault: true }), n2("click", { onElement: this.element, matchingSelector: l2, withCallback: this.didClickDialogButton }), n2("keydown", { onElement: this.element, matchingSelector: h2, withCallback: this.didKeyDownDialogInput }); 6051 } 6052 var a2, u, c, l2, h2, p, d, f, g, m, v; 6053 return r3(s3, e3), c = "[data-trix-attribute]", a2 = "[data-trix-action]", v = c + ", " + a2, p = "[data-trix-dialog]", u = p + "[data-trix-active]", l2 = p + " [data-trix-method]", h2 = p + " [data-trix-input]", s3.prototype.didClickActionButton = function(t3, e4) { 6054 var n3, i3, o3; 6055 return (i3 = this.delegate) != null && i3.toolbarDidClickButton(), t3.preventDefault(), n3 = d(e4), this.getDialog(n3) ? this.toggleDialog(n3) : (o3 = this.delegate) != null ? o3.toolbarDidInvokeAction(n3) : void 0; 6056 }, s3.prototype.didClickAttributeButton = function(t3, e4) { 6057 var n3, i3, o3; 6058 return (i3 = this.delegate) != null && i3.toolbarDidClickButton(), t3.preventDefault(), n3 = f(e4), this.getDialog(n3) ? this.toggleDialog(n3) : (o3 = this.delegate) != null && o3.toolbarDidToggleAttribute(n3), this.refreshAttributeButtons(); 6059 }, s3.prototype.didClickDialogButton = function(e4, n3) { 6060 var i3, o3; 6061 return i3 = t2(n3, { matchingSelector: p }), o3 = n3.getAttribute("data-trix-method"), this[o3].call(this, i3); 6062 }, s3.prototype.didKeyDownDialogInput = function(t3, e4) { 6063 var n3, i3; 6064 return t3.keyCode === 13 && (t3.preventDefault(), n3 = e4.getAttribute("name"), i3 = this.getDialog(n3), this.setAttribute(i3)), t3.keyCode === 27 ? (t3.preventDefault(), this.hideDialog()) : void 0; 6065 }, s3.prototype.updateActions = function(t3) { 6066 return this.actions = t3, this.refreshActionButtons(); 6067 }, s3.prototype.refreshActionButtons = function() { 6068 return this.eachActionButton(function(t3) { 6069 return function(e4, n3) { 6070 return e4.disabled = t3.actions[n3] === false; 6071 }; 6072 }(this)); 6073 }, s3.prototype.eachActionButton = function(t3) { 6074 var e4, n3, i3, o3, r4; 6075 for (o3 = this.element.querySelectorAll(a2), r4 = [], n3 = 0, i3 = o3.length; i3 > n3; n3++) 6076 e4 = o3[n3], r4.push(t3(e4, d(e4))); 6077 return r4; 6078 }, s3.prototype.updateAttributes = function(t3) { 6079 return this.attributes = t3, this.refreshAttributeButtons(); 6080 }, s3.prototype.refreshAttributeButtons = function() { 6081 return this.eachAttributeButton(function(t3) { 6082 return function(e4, n3) { 6083 return e4.disabled = t3.attributes[n3] === false, t3.attributes[n3] || t3.dialogIsVisible(n3) ? (e4.setAttribute("data-trix-active", ""), e4.classList.add("trix-active")) : (e4.removeAttribute("data-trix-active"), e4.classList.remove("trix-active")); 6084 }; 6085 }(this)); 6086 }, s3.prototype.eachAttributeButton = function(t3) { 6087 var e4, n3, i3, o3, r4; 6088 for (o3 = this.element.querySelectorAll(c), r4 = [], n3 = 0, i3 = o3.length; i3 > n3; n3++) 6089 e4 = o3[n3], r4.push(t3(e4, f(e4))); 6090 return r4; 6091 }, s3.prototype.applyKeyboardCommand = function(t3) { 6092 var e4, n3, o3, r4, s4, a3, u2; 6093 for (s4 = JSON.stringify(t3.sort()), u2 = this.element.querySelectorAll("[data-trix-key]"), r4 = 0, a3 = u2.length; a3 > r4; r4++) 6094 if (e4 = u2[r4], o3 = e4.getAttribute("data-trix-key").split("+"), n3 = JSON.stringify(o3.sort()), n3 === s4) 6095 return i2("mousedown", { onElement: e4 }), true; 6096 return false; 6097 }, s3.prototype.dialogIsVisible = function(t3) { 6098 var e4; 6099 return (e4 = this.getDialog(t3)) ? e4.hasAttribute("data-trix-active") : void 0; 6100 }, s3.prototype.toggleDialog = function(t3) { 6101 return this.dialogIsVisible(t3) ? this.hideDialog() : this.showDialog(t3); 6102 }, s3.prototype.showDialog = function(t3) { 6103 var e4, n3, i3, o3, r4, s4, a3, u2, c2, l3; 6104 for (this.hideDialog(), (a3 = this.delegate) != null && a3.toolbarWillShowDialog(), i3 = this.getDialog(t3), i3.setAttribute("data-trix-active", ""), i3.classList.add("trix-active"), u2 = i3.querySelectorAll("input[disabled]"), o3 = 0, s4 = u2.length; s4 > o3; o3++) 6105 n3 = u2[o3], n3.removeAttribute("disabled"); 6106 return (e4 = f(i3)) && (r4 = m(i3, t3)) && (r4.value = (c2 = this.attributes[e4]) != null ? c2 : "", r4.select()), (l3 = this.delegate) != null ? l3.toolbarDidShowDialog(t3) : void 0; 6107 }, s3.prototype.setAttribute = function(t3) { 6108 var e4, n3, i3; 6109 return e4 = f(t3), n3 = m(t3, e4), n3.willValidate && !n3.checkValidity() ? (n3.setAttribute("data-trix-validate", ""), n3.classList.add("trix-validate"), n3.focus()) : ((i3 = this.delegate) != null && i3.toolbarDidUpdateAttribute(e4, n3.value), this.hideDialog()); 6110 }, s3.prototype.removeAttribute = function(t3) { 6111 var e4, n3; 6112 return e4 = f(t3), (n3 = this.delegate) != null && n3.toolbarDidRemoveAttribute(e4), this.hideDialog(); 6113 }, s3.prototype.hideDialog = function() { 6114 var t3, e4; 6115 return (t3 = this.element.querySelector(u)) ? (t3.removeAttribute("data-trix-active"), t3.classList.remove("trix-active"), this.resetDialogInputs(), (e4 = this.delegate) != null ? e4.toolbarDidHideDialog(g(t3)) : void 0) : void 0; 6116 }, s3.prototype.resetDialogInputs = function() { 6117 var t3, e4, n3, i3, o3; 6118 for (i3 = this.element.querySelectorAll(h2), o3 = [], t3 = 0, n3 = i3.length; n3 > t3; t3++) 6119 e4 = i3[t3], e4.setAttribute("disabled", "disabled"), e4.removeAttribute("data-trix-validate"), o3.push(e4.classList.remove("trix-validate")); 6120 return o3; 6121 }, s3.prototype.getDialog = function(t3) { 6122 return this.element.querySelector("[data-trix-dialog=" + t3 + "]"); 6123 }, m = function(t3, e4) { 6124 return e4 == null && (e4 = f(t3)), t3.querySelector("[data-trix-input][name='" + e4 + "']"); 6125 }, d = function(t3) { 6126 return t3.getAttribute("data-trix-action"); 6127 }, f = function(t3) { 6128 var e4; 6129 return (e4 = t3.getAttribute("data-trix-attribute")) != null ? e4 : t3.getAttribute("data-trix-dialog-attribute"); 6130 }, g = function(t3) { 6131 return t3.getAttribute("data-trix-dialog"); 6132 }, s3; 6133 }(e2.BasicObject); 6134 }.call(this), function() { 6135 var t2 = function(t3, e3) { 6136 function i2() { 6137 this.constructor = t3; 6138 } 6139 for (var o2 in e3) 6140 n2.call(e3, o2) && (t3[o2] = e3[o2]); 6141 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 6142 }, n2 = {}.hasOwnProperty; 6143 e2.ImagePreloadOperation = function(e3) { 6144 function n3(t3) { 6145 this.url = t3; 6146 } 6147 return t2(n3, e3), n3.prototype.perform = function(t3) { 6148 var e4; 6149 return e4 = new Image(), e4.onload = function(n4) { 6150 return function() { 6151 return e4.width = n4.width = e4.naturalWidth, e4.height = n4.height = e4.naturalHeight, t3(true, e4); 6152 }; 6153 }(this), e4.onerror = function() { 6154 return t3(false); 6155 }, e4.src = this.url; 6156 }, n3; 6157 }(e2.Operation); 6158 }.call(this), function() { 6159 var t2 = function(t3, e3) { 6160 return function() { 6161 return t3.apply(e3, arguments); 6162 }; 6163 }, n2 = function(t3, e3) { 6164 function n3() { 6165 this.constructor = t3; 6166 } 6167 for (var o2 in e3) 6168 i2.call(e3, o2) && (t3[o2] = e3[o2]); 6169 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 6170 }, i2 = {}.hasOwnProperty; 6171 e2.Attachment = function(i3) { 6172 function o2(n3) { 6173 n3 == null && (n3 = {}), this.releaseFile = t2(this.releaseFile, this), o2.__super__.constructor.apply(this, arguments), this.attributes = e2.Hash.box(n3), this.didChangeAttributes(); 6174 } 6175 return n2(o2, i3), o2.previewablePattern = /^image(\/(gif|png|jpe?g)|$)/, o2.attachmentForFile = function(t3) { 6176 var e3, n3; 6177 return n3 = this.attributesForFile(t3), e3 = new this(n3), e3.setFile(t3), e3; 6178 }, o2.attributesForFile = function(t3) { 6179 return new e2.Hash({ filename: t3.name, filesize: t3.size, contentType: t3.type }); 6180 }, o2.fromJSON = function(t3) { 6181 return new this(t3); 6182 }, o2.prototype.getAttribute = function(t3) { 6183 return this.attributes.get(t3); 6184 }, o2.prototype.hasAttribute = function(t3) { 6185 return this.attributes.has(t3); 6186 }, o2.prototype.getAttributes = function() { 6187 return this.attributes.toObject(); 6188 }, o2.prototype.setAttributes = function(t3) { 6189 var e3, n3, i4; 6190 return t3 == null && (t3 = {}), e3 = this.attributes.merge(t3), this.attributes.isEqualTo(e3) ? void 0 : (this.attributes = e3, this.didChangeAttributes(), (n3 = this.previewDelegate) != null && typeof n3.attachmentDidChangeAttributes == "function" && n3.attachmentDidChangeAttributes(this), (i4 = this.delegate) != null && typeof i4.attachmentDidChangeAttributes == "function" ? i4.attachmentDidChangeAttributes(this) : void 0); 6191 }, o2.prototype.didChangeAttributes = function() { 6192 return this.isPreviewable() ? this.preloadURL() : void 0; 6193 }, o2.prototype.isPending = function() { 6194 return this.file != null && !(this.getURL() || this.getHref()); 6195 }, o2.prototype.isPreviewable = function() { 6196 return this.attributes.has("previewable") ? this.attributes.get("previewable") : this.constructor.previewablePattern.test(this.getContentType()); 6197 }, o2.prototype.getType = function() { 6198 return this.hasContent() ? "content" : this.isPreviewable() ? "preview" : "file"; 6199 }, o2.prototype.getURL = function() { 6200 return this.attributes.get("url"); 6201 }, o2.prototype.getHref = function() { 6202 return this.attributes.get("href"); 6203 }, o2.prototype.getFilename = function() { 6204 var t3; 6205 return (t3 = this.attributes.get("filename")) != null ? t3 : ""; 6206 }, o2.prototype.getFilesize = function() { 6207 return this.attributes.get("filesize"); 6208 }, o2.prototype.getFormattedFilesize = function() { 6209 var t3; 6210 return t3 = this.attributes.get("filesize"), typeof t3 == "number" ? e2.config.fileSize.formatter(t3) : ""; 6211 }, o2.prototype.getExtension = function() { 6212 var t3; 6213 return (t3 = this.getFilename().match(/\.(\w+)$/)) != null ? t3[1].toLowerCase() : void 0; 6214 }, o2.prototype.getContentType = function() { 6215 return this.attributes.get("contentType"); 6216 }, o2.prototype.hasContent = function() { 6217 return this.attributes.has("content"); 6218 }, o2.prototype.getContent = function() { 6219 return this.attributes.get("content"); 6220 }, o2.prototype.getWidth = function() { 6221 return this.attributes.get("width"); 6222 }, o2.prototype.getHeight = function() { 6223 return this.attributes.get("height"); 6224 }, o2.prototype.getFile = function() { 6225 return this.file; 6226 }, o2.prototype.setFile = function(t3) { 6227 return this.file = t3, this.isPreviewable() ? this.preloadFile() : void 0; 6228 }, o2.prototype.releaseFile = function() { 6229 return this.releasePreloadedFile(), this.file = null; 6230 }, o2.prototype.getUploadProgress = function() { 6231 var t3; 6232 return (t3 = this.uploadProgress) != null ? t3 : 0; 6233 }, o2.prototype.setUploadProgress = function(t3) { 6234 var e3; 6235 return this.uploadProgress !== t3 ? (this.uploadProgress = t3, (e3 = this.uploadProgressDelegate) != null && typeof e3.attachmentDidChangeUploadProgress == "function" ? e3.attachmentDidChangeUploadProgress(this) : void 0) : void 0; 6236 }, o2.prototype.toJSON = function() { 6237 return this.getAttributes(); 6238 }, o2.prototype.getCacheKey = function() { 6239 return [o2.__super__.getCacheKey.apply(this, arguments), this.attributes.getCacheKey(), this.getPreviewURL()].join("/"); 6240 }, o2.prototype.getPreviewURL = function() { 6241 return this.previewURL || this.preloadingURL; 6242 }, o2.prototype.setPreviewURL = function(t3) { 6243 var e3, n3; 6244 return t3 !== this.getPreviewURL() ? (this.previewURL = t3, (e3 = this.previewDelegate) != null && typeof e3.attachmentDidChangeAttributes == "function" && e3.attachmentDidChangeAttributes(this), (n3 = this.delegate) != null && typeof n3.attachmentDidChangePreviewURL == "function" ? n3.attachmentDidChangePreviewURL(this) : void 0) : void 0; 6245 }, o2.prototype.preloadURL = function() { 6246 return this.preload(this.getURL(), this.releaseFile); 6247 }, o2.prototype.preloadFile = function() { 6248 return this.file ? (this.fileObjectURL = URL.createObjectURL(this.file), this.preload(this.fileObjectURL)) : void 0; 6249 }, o2.prototype.releasePreloadedFile = function() { 6250 return this.fileObjectURL ? (URL.revokeObjectURL(this.fileObjectURL), this.fileObjectURL = null) : void 0; 6251 }, o2.prototype.preload = function(t3, n3) { 6252 var i4; 6253 return t3 && t3 !== this.getPreviewURL() ? (this.preloadingURL = t3, i4 = new e2.ImagePreloadOperation(t3), i4.then(function(e3) { 6254 return function(i5) { 6255 var o3, r3; 6256 return r3 = i5.width, o3 = i5.height, e3.getWidth() && e3.getHeight() || e3.setAttributes({ width: r3, height: o3 }), e3.preloadingURL = null, e3.setPreviewURL(t3), typeof n3 == "function" ? n3() : void 0; 6257 }; 6258 }(this))["catch"](function(t4) { 6259 return function() { 6260 return t4.preloadingURL = null, typeof n3 == "function" ? n3() : void 0; 6261 }; 6262 }(this))) : void 0; 6263 }, o2; 6264 }(e2.Object); 6265 }.call(this), function() { 6266 var t2 = function(t3, e3) { 6267 function i2() { 6268 this.constructor = t3; 6269 } 6270 for (var o2 in e3) 6271 n2.call(e3, o2) && (t3[o2] = e3[o2]); 6272 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 6273 }, n2 = {}.hasOwnProperty; 6274 e2.Piece = function(n3) { 6275 function i2(t3, n4) { 6276 n4 == null && (n4 = {}), i2.__super__.constructor.apply(this, arguments), this.attributes = e2.Hash.box(n4); 6277 } 6278 return t2(i2, n3), i2.types = {}, i2.registerType = function(t3, e3) { 6279 return e3.type = t3, this.types[t3] = e3; 6280 }, i2.fromJSON = function(t3) { 6281 var e3; 6282 return (e3 = this.types[t3.type]) ? e3.fromJSON(t3) : void 0; 6283 }, i2.prototype.copyWithAttributes = function(t3) { 6284 return new this.constructor(this.getValue(), t3); 6285 }, i2.prototype.copyWithAdditionalAttributes = function(t3) { 6286 return this.copyWithAttributes(this.attributes.merge(t3)); 6287 }, i2.prototype.copyWithoutAttribute = function(t3) { 6288 return this.copyWithAttributes(this.attributes.remove(t3)); 6289 }, i2.prototype.copy = function() { 6290 return this.copyWithAttributes(this.attributes); 6291 }, i2.prototype.getAttribute = function(t3) { 6292 return this.attributes.get(t3); 6293 }, i2.prototype.getAttributesHash = function() { 6294 return this.attributes; 6295 }, i2.prototype.getAttributes = function() { 6296 return this.attributes.toObject(); 6297 }, i2.prototype.getCommonAttributes = function() { 6298 var t3, e3, n4; 6299 return (n4 = pieceList.getPieceAtIndex(0)) ? (t3 = n4.attributes, e3 = t3.getKeys(), pieceList.eachPiece(function(n5) { 6300 return e3 = t3.getKeysCommonToHash(n5.attributes), t3 = t3.slice(e3); 6301 }), t3.toObject()) : {}; 6302 }, i2.prototype.hasAttribute = function(t3) { 6303 return this.attributes.has(t3); 6304 }, i2.prototype.hasSameStringValueAsPiece = function(t3) { 6305 return t3 != null && this.toString() === t3.toString(); 6306 }, i2.prototype.hasSameAttributesAsPiece = function(t3) { 6307 return t3 != null && (this.attributes === t3.attributes || this.attributes.isEqualTo(t3.attributes)); 6308 }, i2.prototype.isBlockBreak = function() { 6309 return false; 6310 }, i2.prototype.isEqualTo = function(t3) { 6311 return i2.__super__.isEqualTo.apply(this, arguments) || this.hasSameConstructorAs(t3) && this.hasSameStringValueAsPiece(t3) && this.hasSameAttributesAsPiece(t3); 6312 }, i2.prototype.isEmpty = function() { 6313 return this.length === 0; 6314 }, i2.prototype.isSerializable = function() { 6315 return true; 6316 }, i2.prototype.toJSON = function() { 6317 return { type: this.constructor.type, attributes: this.getAttributes() }; 6318 }, i2.prototype.contentsForInspection = function() { 6319 return { type: this.constructor.type, attributes: this.attributes.inspect() }; 6320 }, i2.prototype.canBeGrouped = function() { 6321 return this.hasAttribute("href"); 6322 }, i2.prototype.canBeGroupedWith = function(t3) { 6323 return this.getAttribute("href") === t3.getAttribute("href"); 6324 }, i2.prototype.getLength = function() { 6325 return this.length; 6326 }, i2.prototype.canBeConsolidatedWith = function() { 6327 return false; 6328 }, i2; 6329 }(e2.Object); 6330 }.call(this), function() { 6331 var t2 = function(t3, e3) { 6332 function i2() { 6333 this.constructor = t3; 6334 } 6335 for (var o2 in e3) 6336 n2.call(e3, o2) && (t3[o2] = e3[o2]); 6337 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 6338 }, n2 = {}.hasOwnProperty; 6339 e2.Piece.registerType("attachment", e2.AttachmentPiece = function(n3) { 6340 function i2(t3) { 6341 this.attachment = t3, i2.__super__.constructor.apply(this, arguments), this.length = 1, this.ensureAttachmentExclusivelyHasAttribute("href"), this.attachment.hasContent() || this.removeProhibitedAttributes(); 6342 } 6343 return t2(i2, n3), i2.fromJSON = function(t3) { 6344 return new this(e2.Attachment.fromJSON(t3.attachment), t3.attributes); 6345 }, i2.permittedAttributes = ["caption", "presentation"], i2.prototype.ensureAttachmentExclusivelyHasAttribute = function(t3) { 6346 return this.hasAttribute(t3) ? (this.attachment.hasAttribute(t3) || this.attachment.setAttributes(this.attributes.slice(t3)), this.attributes = this.attributes.remove(t3)) : void 0; 6347 }, i2.prototype.removeProhibitedAttributes = function() { 6348 var t3; 6349 return t3 = this.attributes.slice(this.constructor.permittedAttributes), t3.isEqualTo(this.attributes) ? void 0 : this.attributes = t3; 6350 }, i2.prototype.getValue = function() { 6351 return this.attachment; 6352 }, i2.prototype.isSerializable = function() { 6353 return !this.attachment.isPending(); 6354 }, i2.prototype.getCaption = function() { 6355 var t3; 6356 return (t3 = this.attributes.get("caption")) != null ? t3 : ""; 6357 }, i2.prototype.isEqualTo = function(t3) { 6358 var e3; 6359 return i2.__super__.isEqualTo.apply(this, arguments) && this.attachment.id === (t3 != null && (e3 = t3.attachment) != null ? e3.id : void 0); 6360 }, i2.prototype.toString = function() { 6361 return e2.OBJECT_REPLACEMENT_CHARACTER; 6362 }, i2.prototype.toJSON = function() { 6363 var t3; 6364 return t3 = i2.__super__.toJSON.apply(this, arguments), t3.attachment = this.attachment, t3; 6365 }, i2.prototype.getCacheKey = function() { 6366 return [i2.__super__.getCacheKey.apply(this, arguments), this.attachment.getCacheKey()].join("/"); 6367 }, i2.prototype.toConsole = function() { 6368 return JSON.stringify(this.toString()); 6369 }, i2; 6370 }(e2.Piece)); 6371 }.call(this), function() { 6372 var t2, n2 = function(t3, e3) { 6373 function n3() { 6374 this.constructor = t3; 6375 } 6376 for (var o2 in e3) 6377 i2.call(e3, o2) && (t3[o2] = e3[o2]); 6378 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 6379 }, i2 = {}.hasOwnProperty; 6380 t2 = e2.normalizeNewlines, e2.Piece.registerType("string", e2.StringPiece = function(e3) { 6381 function i3(e4) { 6382 i3.__super__.constructor.apply(this, arguments), this.string = t2(e4), this.length = this.string.length; 6383 } 6384 return n2(i3, e3), i3.fromJSON = function(t3) { 6385 return new this(t3.string, t3.attributes); 6386 }, i3.prototype.getValue = function() { 6387 return this.string; 6388 }, i3.prototype.toString = function() { 6389 return this.string.toString(); 6390 }, i3.prototype.isBlockBreak = function() { 6391 return this.toString() === "\n" && this.getAttribute("blockBreak") === true; 6392 }, i3.prototype.toJSON = function() { 6393 var t3; 6394 return t3 = i3.__super__.toJSON.apply(this, arguments), t3.string = this.string, t3; 6395 }, i3.prototype.canBeConsolidatedWith = function(t3) { 6396 return t3 != null && this.hasSameConstructorAs(t3) && this.hasSameAttributesAsPiece(t3); 6397 }, i3.prototype.consolidateWith = function(t3) { 6398 return new this.constructor(this.toString() + t3.toString(), this.attributes); 6399 }, i3.prototype.splitAtOffset = function(t3) { 6400 var e4, n3; 6401 return t3 === 0 ? (e4 = null, n3 = this) : t3 === this.length ? (e4 = this, n3 = null) : (e4 = new this.constructor(this.string.slice(0, t3), this.attributes), n3 = new this.constructor(this.string.slice(t3), this.attributes)), [e4, n3]; 6402 }, i3.prototype.toConsole = function() { 6403 var t3; 6404 return t3 = this.string, t3.length > 15 && (t3 = t3.slice(0, 14) + "\u2026"), JSON.stringify(t3.toString()); 6405 }, i3; 6406 }(e2.Piece)); 6407 }.call(this), function() { 6408 var t2, n2 = function(t3, e3) { 6409 function n3() { 6410 this.constructor = t3; 6411 } 6412 for (var o3 in e3) 6413 i2.call(e3, o3) && (t3[o3] = e3[o3]); 6414 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 6415 }, i2 = {}.hasOwnProperty, o2 = [].slice; 6416 t2 = e2.spliceArray, e2.SplittableList = function(e3) { 6417 function i3(t3) { 6418 t3 == null && (t3 = []), i3.__super__.constructor.apply(this, arguments), this.objects = t3.slice(0), this.length = this.objects.length; 6419 } 6420 var r3, s2, a2; 6421 return n2(i3, e3), i3.box = function(t3) { 6422 return t3 instanceof this ? t3 : new this(t3); 6423 }, i3.prototype.indexOf = function(t3) { 6424 return this.objects.indexOf(t3); 6425 }, i3.prototype.splice = function() { 6426 var e4; 6427 return e4 = 1 <= arguments.length ? o2.call(arguments, 0) : [], new this.constructor(t2.apply(null, [this.objects].concat(o2.call(e4)))); 6428 }, i3.prototype.eachObject = function(t3) { 6429 var e4, n3, i4, o3, r4, s3; 6430 for (r4 = this.objects, s3 = [], n3 = e4 = 0, i4 = r4.length; i4 > e4; n3 = ++e4) 6431 o3 = r4[n3], s3.push(t3(o3, n3)); 6432 return s3; 6433 }, i3.prototype.insertObjectAtIndex = function(t3, e4) { 6434 return this.splice(e4, 0, t3); 6435 }, i3.prototype.insertSplittableListAtIndex = function(t3, e4) { 6436 return this.splice.apply(this, [e4, 0].concat(o2.call(t3.objects))); 6437 }, i3.prototype.insertSplittableListAtPosition = function(t3, e4) { 6438 var n3, i4, o3; 6439 return o3 = this.splitObjectAtPosition(e4), i4 = o3[0], n3 = o3[1], new this.constructor(i4).insertSplittableListAtIndex(t3, n3); 6440 }, i3.prototype.editObjectAtIndex = function(t3, e4) { 6441 return this.replaceObjectAtIndex(e4(this.objects[t3]), t3); 6442 }, i3.prototype.replaceObjectAtIndex = function(t3, e4) { 6443 return this.splice(e4, 1, t3); 6444 }, i3.prototype.removeObjectAtIndex = function(t3) { 6445 return this.splice(t3, 1); 6446 }, i3.prototype.getObjectAtIndex = function(t3) { 6447 return this.objects[t3]; 6448 }, i3.prototype.getSplittableListInRange = function(t3) { 6449 var e4, n3, i4, o3; 6450 return i4 = this.splitObjectsAtRange(t3), n3 = i4[0], e4 = i4[1], o3 = i4[2], new this.constructor(n3.slice(e4, o3 + 1)); 6451 }, i3.prototype.selectSplittableList = function(t3) { 6452 var e4, n3; 6453 return n3 = function() { 6454 var n4, i4, o3, r4; 6455 for (o3 = this.objects, r4 = [], n4 = 0, i4 = o3.length; i4 > n4; n4++) 6456 e4 = o3[n4], t3(e4) && r4.push(e4); 6457 return r4; 6458 }.call(this), new this.constructor(n3); 6459 }, i3.prototype.removeObjectsInRange = function(t3) { 6460 var e4, n3, i4, o3; 6461 return i4 = this.splitObjectsAtRange(t3), n3 = i4[0], e4 = i4[1], o3 = i4[2], new this.constructor(n3).splice(e4, o3 - e4 + 1); 6462 }, i3.prototype.transformObjectsInRange = function(t3, e4) { 6463 var n3, i4, o3, r4, s3, a3, u; 6464 return s3 = this.splitObjectsAtRange(t3), r4 = s3[0], i4 = s3[1], a3 = s3[2], u = function() { 6465 var t4, s4, u2; 6466 for (u2 = [], n3 = t4 = 0, s4 = r4.length; s4 > t4; n3 = ++t4) 6467 o3 = r4[n3], u2.push(n3 >= i4 && a3 >= n3 ? e4(o3) : o3); 6468 return u2; 6469 }(), new this.constructor(u); 6470 }, i3.prototype.splitObjectsAtRange = function(t3) { 6471 var e4, n3, i4, o3, s3, u; 6472 return o3 = this.splitObjectAtPosition(a2(t3)), n3 = o3[0], e4 = o3[1], i4 = o3[2], s3 = new this.constructor(n3).splitObjectAtPosition(r3(t3) + i4), n3 = s3[0], u = s3[1], [n3, e4, u - 1]; 6473 }, i3.prototype.getObjectAtPosition = function(t3) { 6474 var e4, n3, i4; 6475 return i4 = this.findIndexAndOffsetAtPosition(t3), e4 = i4.index, n3 = i4.offset, this.objects[e4]; 6476 }, i3.prototype.splitObjectAtPosition = function(t3) { 6477 var e4, n3, i4, o3, r4, s3, a3, u, c, l2; 6478 return s3 = this.findIndexAndOffsetAtPosition(t3), e4 = s3.index, r4 = s3.offset, o3 = this.objects.slice(0), e4 != null ? r4 === 0 ? (c = e4, l2 = 0) : (i4 = this.getObjectAtIndex(e4), a3 = i4.splitAtOffset(r4), n3 = a3[0], u = a3[1], o3.splice(e4, 1, n3, u), c = e4 + 1, l2 = n3.getLength() - r4) : (c = o3.length, l2 = 0), [o3, c, l2]; 6479 }, i3.prototype.consolidate = function() { 6480 var t3, e4, n3, i4, o3, r4; 6481 for (i4 = [], o3 = this.objects[0], r4 = this.objects.slice(1), t3 = 0, e4 = r4.length; e4 > t3; t3++) 6482 n3 = r4[t3], (typeof o3.canBeConsolidatedWith == "function" ? o3.canBeConsolidatedWith(n3) : void 0) ? o3 = o3.consolidateWith(n3) : (i4.push(o3), o3 = n3); 6483 return o3 != null && i4.push(o3), new this.constructor(i4); 6484 }, i3.prototype.consolidateFromIndexToIndex = function(t3, e4) { 6485 var n3, i4, r4; 6486 return i4 = this.objects.slice(0), r4 = i4.slice(t3, e4 + 1), n3 = new this.constructor(r4).consolidate().toArray(), this.splice.apply(this, [t3, r4.length].concat(o2.call(n3))); 6487 }, i3.prototype.findIndexAndOffsetAtPosition = function(t3) { 6488 var e4, n3, i4, o3, r4, s3, a3; 6489 for (e4 = 0, a3 = this.objects, i4 = n3 = 0, o3 = a3.length; o3 > n3; i4 = ++n3) { 6490 if (s3 = a3[i4], r4 = e4 + s3.getLength(), t3 >= e4 && r4 > t3) 6491 return { index: i4, offset: t3 - e4 }; 6492 e4 = r4; 6493 } 6494 return { index: null, offset: null }; 6495 }, i3.prototype.findPositionAtIndexAndOffset = function(t3, e4) { 6496 var n3, i4, o3, r4, s3, a3; 6497 for (s3 = 0, a3 = this.objects, n3 = i4 = 0, o3 = a3.length; o3 > i4; n3 = ++i4) 6498 if (r4 = a3[n3], t3 > n3) 6499 s3 += r4.getLength(); 6500 else if (n3 === t3) { 6501 s3 += e4; 6502 break; 6503 } 6504 return s3; 6505 }, i3.prototype.getEndPosition = function() { 6506 var t3, e4; 6507 return this.endPosition != null ? this.endPosition : this.endPosition = function() { 6508 var n3, i4, o3; 6509 for (e4 = 0, o3 = this.objects, n3 = 0, i4 = o3.length; i4 > n3; n3++) 6510 t3 = o3[n3], e4 += t3.getLength(); 6511 return e4; 6512 }.call(this); 6513 }, i3.prototype.toString = function() { 6514 return this.objects.join(""); 6515 }, i3.prototype.toArray = function() { 6516 return this.objects.slice(0); 6517 }, i3.prototype.toJSON = function() { 6518 return this.toArray(); 6519 }, i3.prototype.isEqualTo = function(t3) { 6520 return i3.__super__.isEqualTo.apply(this, arguments) || s2(this.objects, t3 != null ? t3.objects : void 0); 6521 }, s2 = function(t3, e4) { 6522 var n3, i4, o3, r4, s3; 6523 if (e4 == null && (e4 = []), t3.length !== e4.length) 6524 return false; 6525 for (s3 = true, i4 = n3 = 0, o3 = t3.length; o3 > n3; i4 = ++n3) 6526 r4 = t3[i4], s3 && !r4.isEqualTo(e4[i4]) && (s3 = false); 6527 return s3; 6528 }, i3.prototype.contentsForInspection = function() { 6529 var t3; 6530 return { objects: "[" + function() { 6531 var e4, n3, i4, o3; 6532 for (i4 = this.objects, o3 = [], e4 = 0, n3 = i4.length; n3 > e4; e4++) 6533 t3 = i4[e4], o3.push(t3.inspect()); 6534 return o3; 6535 }.call(this).join(", ") + "]" }; 6536 }, a2 = function(t3) { 6537 return t3[0]; 6538 }, r3 = function(t3) { 6539 return t3[1]; 6540 }, i3; 6541 }(e2.Object); 6542 }.call(this), function() { 6543 var t2 = function(t3, e3) { 6544 function i2() { 6545 this.constructor = t3; 6546 } 6547 for (var o2 in e3) 6548 n2.call(e3, o2) && (t3[o2] = e3[o2]); 6549 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 6550 }, n2 = {}.hasOwnProperty; 6551 e2.Text = function(n3) { 6552 function i2(t3) { 6553 var n4; 6554 t3 == null && (t3 = []), i2.__super__.constructor.apply(this, arguments), this.pieceList = new e2.SplittableList(function() { 6555 var e3, i3, o2; 6556 for (o2 = [], e3 = 0, i3 = t3.length; i3 > e3; e3++) 6557 n4 = t3[e3], n4.isEmpty() || o2.push(n4); 6558 return o2; 6559 }()); 6560 } 6561 return t2(i2, n3), i2.textForAttachmentWithAttributes = function(t3, n4) { 6562 var i3; 6563 return i3 = new e2.AttachmentPiece(t3, n4), new this([i3]); 6564 }, i2.textForStringWithAttributes = function(t3, n4) { 6565 var i3; 6566 return i3 = new e2.StringPiece(t3, n4), new this([i3]); 6567 }, i2.fromJSON = function(t3) { 6568 var n4, i3; 6569 return i3 = function() { 6570 var i4, o2, r3; 6571 for (r3 = [], i4 = 0, o2 = t3.length; o2 > i4; i4++) 6572 n4 = t3[i4], r3.push(e2.Piece.fromJSON(n4)); 6573 return r3; 6574 }(), new this(i3); 6575 }, i2.prototype.copy = function() { 6576 return this.copyWithPieceList(this.pieceList); 6577 }, i2.prototype.copyWithPieceList = function(t3) { 6578 return new this.constructor(t3.consolidate().toArray()); 6579 }, i2.prototype.copyUsingObjectMap = function(t3) { 6580 var e3, n4; 6581 return n4 = function() { 6582 var n5, i3, o2, r3, s2; 6583 for (o2 = this.getPieces(), s2 = [], n5 = 0, i3 = o2.length; i3 > n5; n5++) 6584 e3 = o2[n5], s2.push((r3 = t3.find(e3)) != null ? r3 : e3); 6585 return s2; 6586 }.call(this), new this.constructor(n4); 6587 }, i2.prototype.appendText = function(t3) { 6588 return this.insertTextAtPosition(t3, this.getLength()); 6589 }, i2.prototype.insertTextAtPosition = function(t3, e3) { 6590 return this.copyWithPieceList(this.pieceList.insertSplittableListAtPosition(t3.pieceList, e3)); 6591 }, i2.prototype.removeTextAtRange = function(t3) { 6592 return this.copyWithPieceList(this.pieceList.removeObjectsInRange(t3)); 6593 }, i2.prototype.replaceTextAtRange = function(t3, e3) { 6594 return this.removeTextAtRange(e3).insertTextAtPosition(t3, e3[0]); 6595 }, i2.prototype.moveTextFromRangeToPosition = function(t3, e3) { 6596 var n4, i3; 6597 if (!(t3[0] <= e3 && e3 <= t3[1])) 6598 return i3 = this.getTextAtRange(t3), n4 = i3.getLength(), t3[0] < e3 && (e3 -= n4), this.removeTextAtRange(t3).insertTextAtPosition(i3, e3); 6599 }, i2.prototype.addAttributeAtRange = function(t3, e3, n4) { 6600 var i3; 6601 return i3 = {}, i3[t3] = e3, this.addAttributesAtRange(i3, n4); 6602 }, i2.prototype.addAttributesAtRange = function(t3, e3) { 6603 return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e3, function(e4) { 6604 return e4.copyWithAdditionalAttributes(t3); 6605 })); 6606 }, i2.prototype.removeAttributeAtRange = function(t3, e3) { 6607 return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e3, function(e4) { 6608 return e4.copyWithoutAttribute(t3); 6609 })); 6610 }, i2.prototype.setAttributesAtRange = function(t3, e3) { 6611 return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e3, function(e4) { 6612 return e4.copyWithAttributes(t3); 6613 })); 6614 }, i2.prototype.getAttributesAtPosition = function(t3) { 6615 var e3, n4; 6616 return (e3 = (n4 = this.pieceList.getObjectAtPosition(t3)) != null ? n4.getAttributes() : void 0) != null ? e3 : {}; 6617 }, i2.prototype.getCommonAttributes = function() { 6618 var t3, n4; 6619 return t3 = function() { 6620 var t4, e3, i3, o2; 6621 for (i3 = this.pieceList.toArray(), o2 = [], t4 = 0, e3 = i3.length; e3 > t4; t4++) 6622 n4 = i3[t4], o2.push(n4.getAttributes()); 6623 return o2; 6624 }.call(this), e2.Hash.fromCommonAttributesOfObjects(t3).toObject(); 6625 }, i2.prototype.getCommonAttributesAtRange = function(t3) { 6626 var e3; 6627 return (e3 = this.getTextAtRange(t3).getCommonAttributes()) != null ? e3 : {}; 6628 }, i2.prototype.getExpandedRangeForAttributeAtOffset = function(t3, e3) { 6629 var n4, i3, o2; 6630 for (n4 = o2 = e3, i3 = this.getLength(); n4 > 0 && this.getCommonAttributesAtRange([n4 - 1, o2])[t3]; ) 6631 n4--; 6632 for (; i3 > o2 && this.getCommonAttributesAtRange([e3, o2 + 1])[t3]; ) 6633 o2++; 6634 return [n4, o2]; 6635 }, i2.prototype.getTextAtRange = function(t3) { 6636 return this.copyWithPieceList(this.pieceList.getSplittableListInRange(t3)); 6637 }, i2.prototype.getStringAtRange = function(t3) { 6638 return this.pieceList.getSplittableListInRange(t3).toString(); 6639 }, i2.prototype.getStringAtPosition = function(t3) { 6640 return this.getStringAtRange([t3, t3 + 1]); 6641 }, i2.prototype.startsWithString = function(t3) { 6642 return this.getStringAtRange([0, t3.length]) === t3; 6643 }, i2.prototype.endsWithString = function(t3) { 6644 var e3; 6645 return e3 = this.getLength(), this.getStringAtRange([e3 - t3.length, e3]) === t3; 6646 }, i2.prototype.getAttachmentPieces = function() { 6647 var t3, e3, n4, i3, o2; 6648 for (i3 = this.pieceList.toArray(), o2 = [], t3 = 0, e3 = i3.length; e3 > t3; t3++) 6649 n4 = i3[t3], n4.attachment != null && o2.push(n4); 6650 return o2; 6651 }, i2.prototype.getAttachments = function() { 6652 var t3, e3, n4, i3, o2; 6653 for (i3 = this.getAttachmentPieces(), o2 = [], t3 = 0, e3 = i3.length; e3 > t3; t3++) 6654 n4 = i3[t3], o2.push(n4.attachment); 6655 return o2; 6656 }, i2.prototype.getAttachmentAndPositionById = function(t3) { 6657 var e3, n4, i3, o2, r3, s2; 6658 for (o2 = 0, r3 = this.pieceList.toArray(), e3 = 0, n4 = r3.length; n4 > e3; e3++) { 6659 if (i3 = r3[e3], ((s2 = i3.attachment) != null ? s2.id : void 0) === t3) 6660 return { attachment: i3.attachment, position: o2 }; 6661 o2 += i3.length; 6662 } 6663 return { attachment: null, position: null }; 6664 }, i2.prototype.getAttachmentById = function(t3) { 6665 var e3, n4, i3; 6666 return i3 = this.getAttachmentAndPositionById(t3), e3 = i3.attachment, n4 = i3.position, e3; 6667 }, i2.prototype.getRangeOfAttachment = function(t3) { 6668 var e3, n4; 6669 return n4 = this.getAttachmentAndPositionById(t3.id), t3 = n4.attachment, e3 = n4.position, t3 != null ? [e3, e3 + 1] : void 0; 6670 }, i2.prototype.updateAttributesForAttachment = function(t3, e3) { 6671 var n4; 6672 return (n4 = this.getRangeOfAttachment(e3)) ? this.addAttributesAtRange(t3, n4) : this; 6673 }, i2.prototype.getLength = function() { 6674 return this.pieceList.getEndPosition(); 6675 }, i2.prototype.isEmpty = function() { 6676 return this.getLength() === 0; 6677 }, i2.prototype.isEqualTo = function(t3) { 6678 var e3; 6679 return i2.__super__.isEqualTo.apply(this, arguments) || (t3 != null && (e3 = t3.pieceList) != null ? e3.isEqualTo(this.pieceList) : void 0); 6680 }, i2.prototype.isBlockBreak = function() { 6681 return this.getLength() === 1 && this.pieceList.getObjectAtIndex(0).isBlockBreak(); 6682 }, i2.prototype.eachPiece = function(t3) { 6683 return this.pieceList.eachObject(t3); 6684 }, i2.prototype.getPieces = function() { 6685 return this.pieceList.toArray(); 6686 }, i2.prototype.getPieceAtPosition = function(t3) { 6687 return this.pieceList.getObjectAtPosition(t3); 6688 }, i2.prototype.contentsForInspection = function() { 6689 return { pieceList: this.pieceList.inspect() }; 6690 }, i2.prototype.toSerializableText = function() { 6691 var t3; 6692 return t3 = this.pieceList.selectSplittableList(function(t4) { 6693 return t4.isSerializable(); 6694 }), this.copyWithPieceList(t3); 6695 }, i2.prototype.toString = function() { 6696 return this.pieceList.toString(); 6697 }, i2.prototype.toJSON = function() { 6698 return this.pieceList.toJSON(); 6699 }, i2.prototype.toConsole = function() { 6700 var t3; 6701 return JSON.stringify(function() { 6702 var e3, n4, i3, o2; 6703 for (i3 = this.pieceList.toArray(), o2 = [], e3 = 0, n4 = i3.length; n4 > e3; e3++) 6704 t3 = i3[e3], o2.push(JSON.parse(t3.toConsole())); 6705 return o2; 6706 }.call(this)); 6707 }, i2.prototype.getDirection = function() { 6708 return e2.getDirection(this.toString()); 6709 }, i2.prototype.isRTL = function() { 6710 return this.getDirection() === "rtl"; 6711 }, i2; 6712 }(e2.Object); 6713 }.call(this), function() { 6714 var t2, n2, i2, o2, r3, s2 = function(t3, e3) { 6715 function n3() { 6716 this.constructor = t3; 6717 } 6718 for (var i3 in e3) 6719 a2.call(e3, i3) && (t3[i3] = e3[i3]); 6720 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 6721 }, a2 = {}.hasOwnProperty, u = [].indexOf || function(t3) { 6722 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 6723 if (e3 in this && this[e3] === t3) 6724 return e3; 6725 return -1; 6726 }, c = [].slice; 6727 t2 = e2.arraysAreEqual, r3 = e2.spliceArray, i2 = e2.getBlockConfig, n2 = e2.getBlockAttributeNames, o2 = e2.getListAttributeNames, e2.Block = function(n3) { 6728 function a3(t3, n4) { 6729 t3 == null && (t3 = new e2.Text()), n4 == null && (n4 = []), a3.__super__.constructor.apply(this, arguments), this.text = h2(t3), this.attributes = n4; 6730 } 6731 var l2, h2, p, d, f, g, m, v, y; 6732 return s2(a3, n3), a3.fromJSON = function(t3) { 6733 var n4; 6734 return n4 = e2.Text.fromJSON(t3.text), new this(n4, t3.attributes); 6735 }, a3.prototype.isEmpty = function() { 6736 return this.text.isBlockBreak(); 6737 }, a3.prototype.isEqualTo = function(e3) { 6738 return a3.__super__.isEqualTo.apply(this, arguments) || this.text.isEqualTo(e3 != null ? e3.text : void 0) && t2(this.attributes, e3 != null ? e3.attributes : void 0); 6739 }, a3.prototype.copyWithText = function(t3) { 6740 return new this.constructor(t3, this.attributes); 6741 }, a3.prototype.copyWithoutText = function() { 6742 return this.copyWithText(null); 6743 }, a3.prototype.copyWithAttributes = function(t3) { 6744 return new this.constructor(this.text, t3); 6745 }, a3.prototype.copyWithoutAttributes = function() { 6746 return this.copyWithAttributes(null); 6747 }, a3.prototype.copyUsingObjectMap = function(t3) { 6748 var e3; 6749 return this.copyWithText((e3 = t3.find(this.text)) ? e3 : this.text.copyUsingObjectMap(t3)); 6750 }, a3.prototype.addAttribute = function(t3) { 6751 var e3; 6752 return e3 = this.attributes.concat(d(t3)), this.copyWithAttributes(e3); 6753 }, a3.prototype.removeAttribute = function(t3) { 6754 var e3, n4; 6755 return n4 = i2(t3).listAttribute, e3 = g(g(this.attributes, t3), n4), this.copyWithAttributes(e3); 6756 }, a3.prototype.removeLastAttribute = function() { 6757 return this.removeAttribute(this.getLastAttribute()); 6758 }, a3.prototype.getLastAttribute = function() { 6759 return f(this.attributes); 6760 }, a3.prototype.getAttributes = function() { 6761 return this.attributes.slice(0); 6762 }, a3.prototype.getAttributeLevel = function() { 6763 return this.attributes.length; 6764 }, a3.prototype.getAttributeAtLevel = function(t3) { 6765 return this.attributes[t3 - 1]; 6766 }, a3.prototype.hasAttribute = function(t3) { 6767 return u.call(this.attributes, t3) >= 0; 6768 }, a3.prototype.hasAttributes = function() { 6769 return this.getAttributeLevel() > 0; 6770 }, a3.prototype.getLastNestableAttribute = function() { 6771 return f(this.getNestableAttributes()); 6772 }, a3.prototype.getNestableAttributes = function() { 6773 var t3, e3, n4, o3, r4; 6774 for (o3 = this.attributes, r4 = [], e3 = 0, n4 = o3.length; n4 > e3; e3++) 6775 t3 = o3[e3], i2(t3).nestable && r4.push(t3); 6776 return r4; 6777 }, a3.prototype.getNestingLevel = function() { 6778 return this.getNestableAttributes().length; 6779 }, a3.prototype.decreaseNestingLevel = function() { 6780 var t3; 6781 return (t3 = this.getLastNestableAttribute()) ? this.removeAttribute(t3) : this; 6782 }, a3.prototype.increaseNestingLevel = function() { 6783 var t3, e3, n4; 6784 return (t3 = this.getLastNestableAttribute()) ? (n4 = this.attributes.lastIndexOf(t3), e3 = r3.apply(null, [this.attributes, n4 + 1, 0].concat(c.call(d(t3)))), this.copyWithAttributes(e3)) : this; 6785 }, a3.prototype.getListItemAttributes = function() { 6786 var t3, e3, n4, o3, r4; 6787 for (o3 = this.attributes, r4 = [], e3 = 0, n4 = o3.length; n4 > e3; e3++) 6788 t3 = o3[e3], i2(t3).listAttribute && r4.push(t3); 6789 return r4; 6790 }, a3.prototype.isListItem = function() { 6791 var t3; 6792 return (t3 = i2(this.getLastAttribute())) != null ? t3.listAttribute : void 0; 6793 }, a3.prototype.isTerminalBlock = function() { 6794 var t3; 6795 return (t3 = i2(this.getLastAttribute())) != null ? t3.terminal : void 0; 6796 }, a3.prototype.breaksOnReturn = function() { 6797 var t3; 6798 return (t3 = i2(this.getLastAttribute())) != null ? t3.breakOnReturn : void 0; 6799 }, a3.prototype.findLineBreakInDirectionFromPosition = function(t3, e3) { 6800 var n4, i3; 6801 return i3 = this.toString(), n4 = function() { 6802 switch (t3) { 6803 case "forward": 6804 return i3.indexOf("\n", e3); 6805 case "backward": 6806 return i3.slice(0, e3).lastIndexOf("\n"); 6807 } 6808 }(), n4 !== -1 ? n4 : void 0; 6809 }, a3.prototype.contentsForInspection = function() { 6810 return { text: this.text.inspect(), attributes: this.attributes }; 6811 }, a3.prototype.toString = function() { 6812 return this.text.toString(); 6813 }, a3.prototype.toJSON = function() { 6814 return { text: this.text, attributes: this.attributes }; 6815 }, a3.prototype.getDirection = function() { 6816 return this.text.getDirection(); 6817 }, a3.prototype.isRTL = function() { 6818 return this.text.isRTL(); 6819 }, a3.prototype.getLength = function() { 6820 return this.text.getLength(); 6821 }, a3.prototype.canBeConsolidatedWith = function(t3) { 6822 return !this.hasAttributes() && !t3.hasAttributes() && this.getDirection() === t3.getDirection(); 6823 }, a3.prototype.consolidateWith = function(t3) { 6824 var n4, i3; 6825 return n4 = e2.Text.textForStringWithAttributes("\n"), i3 = this.getTextWithoutBlockBreak().appendText(n4), this.copyWithText(i3.appendText(t3.text)); 6826 }, a3.prototype.splitAtOffset = function(t3) { 6827 var e3, n4; 6828 return t3 === 0 ? (e3 = null, n4 = this) : t3 === this.getLength() ? (e3 = this, n4 = null) : (e3 = this.copyWithText(this.text.getTextAtRange([0, t3])), n4 = this.copyWithText(this.text.getTextAtRange([t3, this.getLength()]))), [e3, n4]; 6829 }, a3.prototype.getBlockBreakPosition = function() { 6830 return this.text.getLength() - 1; 6831 }, a3.prototype.getTextWithoutBlockBreak = function() { 6832 return m(this.text) ? this.text.getTextAtRange([0, this.getBlockBreakPosition()]) : this.text.copy(); 6833 }, a3.prototype.canBeGrouped = function(t3) { 6834 return this.attributes[t3]; 6835 }, a3.prototype.canBeGroupedWith = function(t3, e3) { 6836 var n4, r4, s3, a4; 6837 return s3 = t3.getAttributes(), r4 = s3[e3], n4 = this.attributes[e3], !(n4 !== r4 || i2(n4).group === false && (a4 = s3[e3 + 1], u.call(o2(), a4) < 0) || this.getDirection() !== t3.getDirection() && !t3.isEmpty()); 6838 }, h2 = function(t3) { 6839 return t3 = y(t3), t3 = l2(t3); 6840 }, y = function(t3) { 6841 var n4, i3, o3, r4, s3, a4; 6842 return r4 = false, a4 = t3.getPieces(), i3 = 2 <= a4.length ? c.call(a4, 0, n4 = a4.length - 1) : (n4 = 0, []), o3 = a4[n4++], o3 == null ? t3 : (i3 = function() { 6843 var t4, e3, n5; 6844 for (n5 = [], t4 = 0, e3 = i3.length; e3 > t4; t4++) 6845 s3 = i3[t4], s3.isBlockBreak() ? (r4 = true, n5.push(v(s3))) : n5.push(s3); 6846 return n5; 6847 }(), r4 ? new e2.Text(c.call(i3).concat([o3])) : t3); 6848 }, p = e2.Text.textForStringWithAttributes("\n", { blockBreak: true }), l2 = function(t3) { 6849 return m(t3) ? t3 : t3.appendText(p); 6850 }, m = function(t3) { 6851 var e3, n4; 6852 return n4 = t3.getLength(), n4 === 0 ? false : (e3 = t3.getTextAtRange([n4 - 1, n4]), e3.isBlockBreak()); 6853 }, v = function(t3) { 6854 return t3.copyWithoutAttribute("blockBreak"); 6855 }, d = function(t3) { 6856 var e3; 6857 return e3 = i2(t3).listAttribute, e3 != null ? [e3, t3] : [t3]; 6858 }, f = function(t3) { 6859 return t3.slice(-1)[0]; 6860 }, g = function(t3, e3) { 6861 var n4; 6862 return n4 = t3.lastIndexOf(e3), n4 === -1 ? t3 : r3(t3, n4, 1); 6863 }, a3; 6864 }(e2.Object); 6865 }.call(this), function() { 6866 var t2, n2, i2, o2 = function(t3, e3) { 6867 function n3() { 6868 this.constructor = t3; 6869 } 6870 for (var i3 in e3) 6871 r3.call(e3, i3) && (t3[i3] = e3[i3]); 6872 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 6873 }, r3 = {}.hasOwnProperty, s2 = [].indexOf || function(t3) { 6874 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 6875 if (e3 in this && this[e3] === t3) 6876 return e3; 6877 return -1; 6878 }, a2 = [].slice; 6879 n2 = e2.tagName, i2 = e2.walkTree, t2 = e2.nodeIsAttachmentElement, e2.HTMLSanitizer = function(r4) { 6880 function u(t3, e3) { 6881 var n3; 6882 n3 = e3 != null ? e3 : {}, this.allowedAttributes = n3.allowedAttributes, this.forbiddenProtocols = n3.forbiddenProtocols, this.forbiddenElements = n3.forbiddenElements, this.allowedAttributes == null && (this.allowedAttributes = c), this.forbiddenProtocols == null && (this.forbiddenProtocols = h2), this.forbiddenElements == null && (this.forbiddenElements = l2), this.body = p(t3); 6883 } 6884 var c, l2, h2, p; 6885 return o2(u, r4), c = "style href src width height class".split(" "), h2 = "javascript:".split(" "), l2 = "script iframe".split(" "), u.sanitize = function(t3, e3) { 6886 var n3; 6887 return n3 = new this(t3, e3), n3.sanitize(), n3; 6888 }, u.prototype.sanitize = function() { 6889 return this.sanitizeElements(), this.normalizeListElementNesting(); 6890 }, u.prototype.getHTML = function() { 6891 return this.body.innerHTML; 6892 }, u.prototype.getBody = function() { 6893 return this.body; 6894 }, u.prototype.sanitizeElements = function() { 6895 var t3, n3, o3, r5, s3; 6896 for (s3 = i2(this.body), r5 = []; s3.nextNode(); ) 6897 switch (o3 = s3.currentNode, o3.nodeType) { 6898 case Node.ELEMENT_NODE: 6899 this.elementIsRemovable(o3) ? r5.push(o3) : this.sanitizeElement(o3); 6900 break; 6901 case Node.COMMENT_NODE: 6902 r5.push(o3); 6903 } 6904 for (t3 = 0, n3 = r5.length; n3 > t3; t3++) 6905 o3 = r5[t3], e2.removeNode(o3); 6906 return this.body; 6907 }, u.prototype.sanitizeElement = function(t3) { 6908 var e3, n3, i3, o3, r5; 6909 for (t3.hasAttribute("href") && (o3 = t3.protocol, s2.call(this.forbiddenProtocols, o3) >= 0 && t3.removeAttribute("href")), r5 = a2.call(t3.attributes), e3 = 0, n3 = r5.length; n3 > e3; e3++) 6910 i3 = r5[e3].name, s2.call(this.allowedAttributes, i3) >= 0 || i3.indexOf("data-trix") === 0 || t3.removeAttribute(i3); 6911 return t3; 6912 }, u.prototype.normalizeListElementNesting = function() { 6913 var t3, e3, i3, o3, r5; 6914 for (r5 = a2.call(this.body.querySelectorAll("ul,ol")), t3 = 0, e3 = r5.length; e3 > t3; t3++) 6915 i3 = r5[t3], (o3 = i3.previousElementSibling) && n2(o3) === "li" && o3.appendChild(i3); 6916 return this.body; 6917 }, u.prototype.elementIsRemovable = function(t3) { 6918 return (t3 != null ? t3.nodeType : void 0) === Node.ELEMENT_NODE ? this.elementIsForbidden(t3) || this.elementIsntSerializable(t3) : void 0; 6919 }, u.prototype.elementIsForbidden = function(t3) { 6920 var e3; 6921 return e3 = n2(t3), s2.call(this.forbiddenElements, e3) >= 0; 6922 }, u.prototype.elementIsntSerializable = function(e3) { 6923 return e3.getAttribute("data-trix-serialize") === "false" && !t2(e3); 6924 }, p = function(t3) { 6925 var e3, n3, i3, o3, r5; 6926 for (t3 == null && (t3 = ""), t3 = t3.replace(/<\/html[^>]*>[^]*$/i, "</html>"), e3 = document.implementation.createHTMLDocument(""), e3.documentElement.innerHTML = t3, r5 = e3.head.querySelectorAll("style"), i3 = 0, o3 = r5.length; o3 > i3; i3++) 6927 n3 = r5[i3], e3.body.appendChild(n3); 6928 return e3.body; 6929 }, u; 6930 }(e2.BasicObject); 6931 }.call(this), function() { 6932 var t2, n2, i2, o2, r3, s2, a2, u, c, l2, h2, p = function(t3, e3) { 6933 function n3() { 6934 this.constructor = t3; 6935 } 6936 for (var i3 in e3) 6937 d.call(e3, i3) && (t3[i3] = e3[i3]); 6938 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 6939 }, d = {}.hasOwnProperty, f = [].indexOf || function(t3) { 6940 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 6941 if (e3 in this && this[e3] === t3) 6942 return e3; 6943 return -1; 6944 }; 6945 t2 = e2.arraysAreEqual, s2 = e2.makeElement, l2 = e2.tagName, r3 = e2.getBlockTagNames, h2 = e2.walkTree, o2 = e2.findClosestElementFromNode, i2 = e2.elementContainsNode, a2 = e2.nodeIsAttachmentElement, u = e2.normalizeSpaces, n2 = e2.breakableWhitespacePattern, c = e2.squishBreakableWhitespace, e2.HTMLParser = function(d2) { 6946 function g(t3, e3) { 6947 this.html = t3, this.referenceElement = (e3 != null ? e3 : {}).referenceElement, this.blocks = [], this.blockElements = [], this.processedElements = []; 6948 } 6949 var m, v, y, b, A, C, x, w, E, S, R, k; 6950 return p(g, d2), g.parse = function(t3, e3) { 6951 var n3; 6952 return n3 = new this(t3, e3), n3.parse(), n3; 6953 }, g.prototype.getDocument = function() { 6954 return e2.Document.fromJSON(this.blocks); 6955 }, g.prototype.parse = function() { 6956 var t3, n3; 6957 try { 6958 for (this.createHiddenContainer(), t3 = e2.HTMLSanitizer.sanitize(this.html).getHTML(), this.containerElement.innerHTML = t3, n3 = h2(this.containerElement, { usingFilter: x }); n3.nextNode(); ) 6959 this.processNode(n3.currentNode); 6960 return this.translateBlockElementMarginsToNewlines(); 6961 } finally { 6962 this.removeHiddenContainer(); 6963 } 6964 }, g.prototype.createHiddenContainer = function() { 6965 return this.referenceElement ? (this.containerElement = this.referenceElement.cloneNode(false), this.containerElement.removeAttribute("id"), this.containerElement.setAttribute("data-trix-internal", ""), this.containerElement.style.display = "none", this.referenceElement.parentNode.insertBefore(this.containerElement, this.referenceElement.nextSibling)) : (this.containerElement = s2({ tagName: "div", style: { display: "none" } }), document.body.appendChild(this.containerElement)); 6966 }, g.prototype.removeHiddenContainer = function() { 6967 return e2.removeNode(this.containerElement); 6968 }, x = function(t3) { 6969 return l2(t3) === "style" ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; 6970 }, g.prototype.processNode = function(t3) { 6971 switch (t3.nodeType) { 6972 case Node.TEXT_NODE: 6973 if (!this.isInsignificantTextNode(t3)) 6974 return this.appendBlockForTextNode(t3), this.processTextNode(t3); 6975 break; 6976 case Node.ELEMENT_NODE: 6977 return this.appendBlockForElement(t3), this.processElement(t3); 6978 } 6979 }, g.prototype.appendBlockForTextNode = function(e3) { 6980 var n3, i3, o3; 6981 return i3 = e3.parentNode, i3 === this.currentBlockElement && this.isBlockElement(e3.previousSibling) ? this.appendStringWithAttributes("\n") : i3 !== this.containerElement && !this.isBlockElement(i3) || (n3 = this.getBlockAttributes(i3), t2(n3, (o3 = this.currentBlock) != null ? o3.attributes : void 0)) ? void 0 : (this.currentBlock = this.appendBlockForAttributesWithElement(n3, i3), this.currentBlockElement = i3); 6982 }, g.prototype.appendBlockForElement = function(e3) { 6983 var n3, o3, r4, s3; 6984 if (r4 = this.isBlockElement(e3), o3 = i2(this.currentBlockElement, e3), r4 && !this.isBlockElement(e3.firstChild)) { 6985 if ((!this.isInsignificantTextNode(e3.firstChild) || !this.isBlockElement(e3.firstElementChild)) && (n3 = this.getBlockAttributes(e3), e3.firstChild)) 6986 return o3 && t2(n3, this.currentBlock.attributes) ? this.appendStringWithAttributes("\n") : (this.currentBlock = this.appendBlockForAttributesWithElement(n3, e3), this.currentBlockElement = e3); 6987 } else if (this.currentBlockElement && !o3 && !r4) 6988 return (s3 = this.findParentBlockElement(e3)) ? this.appendBlockForElement(s3) : (this.currentBlock = this.appendEmptyBlock(), this.currentBlockElement = null); 6989 }, g.prototype.findParentBlockElement = function(t3) { 6990 var e3; 6991 for (e3 = t3.parentElement; e3 && e3 !== this.containerElement; ) { 6992 if (this.isBlockElement(e3) && f.call(this.blockElements, e3) >= 0) 6993 return e3; 6994 e3 = e3.parentElement; 6995 } 6996 return null; 6997 }, g.prototype.processTextNode = function(t3) { 6998 var e3, n3; 6999 return n3 = t3.data, v(t3.parentNode) || (n3 = c(n3), R((e3 = t3.previousSibling) != null ? e3.textContent : void 0) && (n3 = A(n3))), this.appendStringWithAttributes(n3, this.getTextAttributes(t3.parentNode)); 7000 }, g.prototype.processElement = function(t3) { 7001 var e3, n3, i3, o3, r4; 7002 if (a2(t3)) 7003 return e3 = w(t3, "attachment"), Object.keys(e3).length && (o3 = this.getTextAttributes(t3), this.appendAttachmentWithAttributes(e3, o3), t3.innerHTML = ""), this.processedElements.push(t3); 7004 switch (l2(t3)) { 7005 case "br": 7006 return this.isExtraBR(t3) || this.isBlockElement(t3.nextSibling) || this.appendStringWithAttributes("\n", this.getTextAttributes(t3)), this.processedElements.push(t3); 7007 case "img": 7008 e3 = { url: t3.getAttribute("src"), contentType: "image" }, i3 = b(t3); 7009 for (n3 in i3) 7010 r4 = i3[n3], e3[n3] = r4; 7011 return this.appendAttachmentWithAttributes(e3, this.getTextAttributes(t3)), this.processedElements.push(t3); 7012 case "tr": 7013 if (t3.parentNode.firstChild !== t3) 7014 return this.appendStringWithAttributes("\n"); 7015 break; 7016 case "td": 7017 if (t3.parentNode.firstChild !== t3) 7018 return this.appendStringWithAttributes(" | "); 7019 } 7020 }, g.prototype.appendBlockForAttributesWithElement = function(t3, e3) { 7021 var n3; 7022 return this.blockElements.push(e3), n3 = m(t3), this.blocks.push(n3), n3; 7023 }, g.prototype.appendEmptyBlock = function() { 7024 return this.appendBlockForAttributesWithElement([], null); 7025 }, g.prototype.appendStringWithAttributes = function(t3, e3) { 7026 return this.appendPiece(S(t3, e3)); 7027 }, g.prototype.appendAttachmentWithAttributes = function(t3, e3) { 7028 return this.appendPiece(E(t3, e3)); 7029 }, g.prototype.appendPiece = function(t3) { 7030 return this.blocks.length === 0 && this.appendEmptyBlock(), this.blocks[this.blocks.length - 1].text.push(t3); 7031 }, g.prototype.appendStringToTextAtIndex = function(t3, e3) { 7032 var n3, i3; 7033 return i3 = this.blocks[e3].text, n3 = i3[i3.length - 1], (n3 != null ? n3.type : void 0) === "string" ? n3.string += t3 : i3.push(S(t3)); 7034 }, g.prototype.prependStringToTextAtIndex = function(t3, e3) { 7035 var n3, i3; 7036 return i3 = this.blocks[e3].text, n3 = i3[0], (n3 != null ? n3.type : void 0) === "string" ? n3.string = t3 + n3.string : i3.unshift(S(t3)); 7037 }, S = function(t3, e3) { 7038 var n3; 7039 return e3 == null && (e3 = {}), n3 = "string", t3 = u(t3), { string: t3, attributes: e3, type: n3 }; 7040 }, E = function(t3, e3) { 7041 var n3; 7042 return e3 == null && (e3 = {}), n3 = "attachment", { attachment: t3, attributes: e3, type: n3 }; 7043 }, m = function(t3) { 7044 var e3; 7045 return t3 == null && (t3 = {}), e3 = [], { text: e3, attributes: t3 }; 7046 }, g.prototype.getTextAttributes = function(t3) { 7047 var n3, i3, r4, s3, u2, c2, l3, h3, p2, d3, f2, g2; 7048 r4 = {}, p2 = e2.config.textAttributes; 7049 for (n3 in p2) 7050 if (u2 = p2[n3], u2.tagName && o2(t3, { matchingSelector: u2.tagName, untilNode: this.containerElement })) 7051 r4[n3] = true; 7052 else if (u2.parser) { 7053 if (g2 = u2.parser(t3)) { 7054 for (i3 = false, d3 = this.findBlockElementAncestors(t3), c2 = 0, h3 = d3.length; h3 > c2; c2++) 7055 if (s3 = d3[c2], u2.parser(s3) === g2) { 7056 i3 = true; 7057 break; 7058 } 7059 i3 || (r4[n3] = g2); 7060 } 7061 } else 7062 u2.styleProperty && (g2 = t3.style[u2.styleProperty]) && (r4[n3] = g2); 7063 if (a2(t3)) { 7064 f2 = w(t3, "attributes"); 7065 for (l3 in f2) 7066 g2 = f2[l3], r4[l3] = g2; 7067 } 7068 return r4; 7069 }, g.prototype.getBlockAttributes = function(t3) { 7070 var n3, i3, o3, r4; 7071 for (i3 = []; t3 && t3 !== this.containerElement; ) { 7072 r4 = e2.config.blockAttributes; 7073 for (n3 in r4) 7074 o3 = r4[n3], o3.parse !== false && l2(t3) === o3.tagName && ((typeof o3.test == "function" ? o3.test(t3) : void 0) || !o3.test) && (i3.push(n3), o3.listAttribute && i3.push(o3.listAttribute)); 7075 t3 = t3.parentNode; 7076 } 7077 return i3.reverse(); 7078 }, g.prototype.findBlockElementAncestors = function(t3) { 7079 var e3, n3; 7080 for (e3 = []; t3 && t3 !== this.containerElement; ) 7081 n3 = l2(t3), f.call(r3(), n3) >= 0 && e3.push(t3), t3 = t3.parentNode; 7082 return e3; 7083 }, w = function(t3, e3) { 7084 try { 7085 return JSON.parse(t3.getAttribute("data-trix-" + e3)); 7086 } catch (n3) { 7087 return {}; 7088 } 7089 }, b = function(t3) { 7090 var e3, n3, i3; 7091 return i3 = t3.getAttribute("width"), n3 = t3.getAttribute("height"), e3 = {}, i3 && (e3.width = parseInt(i3, 10)), n3 && (e3.height = parseInt(n3, 10)), e3; 7092 }, g.prototype.isBlockElement = function(t3) { 7093 var e3; 7094 if ((t3 != null ? t3.nodeType : void 0) === Node.ELEMENT_NODE && !a2(t3) && !o2(t3, { matchingSelector: "td", untilNode: this.containerElement })) 7095 return e3 = l2(t3), f.call(r3(), e3) >= 0 || window.getComputedStyle(t3).display === "block"; 7096 }, g.prototype.isInsignificantTextNode = function(t3) { 7097 var e3, n3, i3; 7098 if ((t3 != null ? t3.nodeType : void 0) === Node.TEXT_NODE && k(t3.data) && (n3 = t3.parentNode, i3 = t3.previousSibling, e3 = t3.nextSibling, (!C(n3.previousSibling) || this.isBlockElement(n3.previousSibling)) && !v(n3))) 7099 return !i3 || this.isBlockElement(i3) || !e3 || this.isBlockElement(e3); 7100 }, g.prototype.isExtraBR = function(t3) { 7101 return l2(t3) === "br" && this.isBlockElement(t3.parentNode) && t3.parentNode.lastChild === t3; 7102 }, v = function(t3) { 7103 var e3; 7104 return e3 = window.getComputedStyle(t3).whiteSpace, e3 === "pre" || e3 === "pre-wrap" || e3 === "pre-line"; 7105 }, C = function(t3) { 7106 return t3 && !R(t3.textContent); 7107 }, g.prototype.translateBlockElementMarginsToNewlines = function() { 7108 var t3, e3, n3, i3, o3, r4, s3, a3; 7109 for (e3 = this.getMarginOfDefaultBlockElement(), s3 = this.blocks, a3 = [], i3 = n3 = 0, o3 = s3.length; o3 > n3; i3 = ++n3) 7110 t3 = s3[i3], (r4 = this.getMarginOfBlockElementAtIndex(i3)) && (r4.top > 2 * e3.top && this.prependStringToTextAtIndex("\n", i3), a3.push(r4.bottom > 2 * e3.bottom ? this.appendStringToTextAtIndex("\n", i3) : void 0)); 7111 return a3; 7112 }, g.prototype.getMarginOfBlockElementAtIndex = function(t3) { 7113 var e3, n3; 7114 return !(e3 = this.blockElements[t3]) || !e3.textContent || (n3 = l2(e3), f.call(r3(), n3) >= 0 || f.call(this.processedElements, e3) >= 0) ? void 0 : y(e3); 7115 }, g.prototype.getMarginOfDefaultBlockElement = function() { 7116 var t3; 7117 return t3 = s2(e2.config.blockAttributes["default"].tagName), this.containerElement.appendChild(t3), y(t3); 7118 }, y = function(t3) { 7119 var e3; 7120 return e3 = window.getComputedStyle(t3), e3.display === "block" ? { top: parseInt(e3.marginTop), bottom: parseInt(e3.marginBottom) } : void 0; 7121 }, A = function(t3) { 7122 return t3.replace(RegExp("^" + n2.source + "+"), ""); 7123 }, k = function(t3) { 7124 return RegExp("^" + n2.source + "*$").test(t3); 7125 }, R = function(t3) { 7126 return /\s$/.test(t3); 7127 }, g; 7128 }(e2.BasicObject); 7129 }.call(this), function() { 7130 var t2, n2, i2, o2, r3 = function(t3, e3) { 7131 function n3() { 7132 this.constructor = t3; 7133 } 7134 for (var i3 in e3) 7135 s2.call(e3, i3) && (t3[i3] = e3[i3]); 7136 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 7137 }, s2 = {}.hasOwnProperty, a2 = [].slice, u = [].indexOf || function(t3) { 7138 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 7139 if (e3 in this && this[e3] === t3) 7140 return e3; 7141 return -1; 7142 }; 7143 t2 = e2.arraysAreEqual, i2 = e2.normalizeRange, o2 = e2.rangeIsCollapsed, n2 = e2.getBlockConfig, e2.Document = function(s3) { 7144 function c(t3) { 7145 t3 == null && (t3 = []), c.__super__.constructor.apply(this, arguments), t3.length === 0 && (t3 = [new e2.Block()]), this.blockList = e2.SplittableList.box(t3); 7146 } 7147 var l2; 7148 return r3(c, s3), c.fromJSON = function(t3) { 7149 var n3, i3; 7150 return i3 = function() { 7151 var i4, o3, r4; 7152 for (r4 = [], i4 = 0, o3 = t3.length; o3 > i4; i4++) 7153 n3 = t3[i4], r4.push(e2.Block.fromJSON(n3)); 7154 return r4; 7155 }(), new this(i3); 7156 }, c.fromHTML = function(t3, n3) { 7157 return e2.HTMLParser.parse(t3, n3).getDocument(); 7158 }, c.fromString = function(t3, n3) { 7159 var i3; 7160 return i3 = e2.Text.textForStringWithAttributes(t3, n3), new this([new e2.Block(i3)]); 7161 }, c.prototype.isEmpty = function() { 7162 var t3; 7163 return this.blockList.length === 1 && (t3 = this.getBlockAtIndex(0), t3.isEmpty() && !t3.hasAttributes()); 7164 }, c.prototype.copy = function(t3) { 7165 var e3; 7166 return t3 == null && (t3 = {}), e3 = t3.consolidateBlocks ? this.blockList.consolidate().toArray() : this.blockList.toArray(), new this.constructor(e3); 7167 }, c.prototype.copyUsingObjectsFromDocument = function(t3) { 7168 var n3; 7169 return n3 = new e2.ObjectMap(t3.getObjects()), this.copyUsingObjectMap(n3); 7170 }, c.prototype.copyUsingObjectMap = function(t3) { 7171 var e3, n3, i3; 7172 return n3 = function() { 7173 var n4, o3, r4, s4; 7174 for (r4 = this.getBlocks(), s4 = [], n4 = 0, o3 = r4.length; o3 > n4; n4++) 7175 e3 = r4[n4], s4.push((i3 = t3.find(e3)) ? i3 : e3.copyUsingObjectMap(t3)); 7176 return s4; 7177 }.call(this), new this.constructor(n3); 7178 }, c.prototype.copyWithBaseBlockAttributes = function(t3) { 7179 var e3, n3, i3; 7180 return t3 == null && (t3 = []), i3 = function() { 7181 var i4, o3, r4, s4; 7182 for (r4 = this.getBlocks(), s4 = [], i4 = 0, o3 = r4.length; o3 > i4; i4++) 7183 n3 = r4[i4], e3 = t3.concat(n3.getAttributes()), s4.push(n3.copyWithAttributes(e3)); 7184 return s4; 7185 }.call(this), new this.constructor(i3); 7186 }, c.prototype.replaceBlock = function(t3, e3) { 7187 var n3; 7188 return n3 = this.blockList.indexOf(t3), n3 === -1 ? this : new this.constructor(this.blockList.replaceObjectAtIndex(e3, n3)); 7189 }, c.prototype.insertDocumentAtRange = function(t3, e3) { 7190 var n3, r4, s4, a3, u2, c2, l3; 7191 return r4 = t3.blockList, u2 = (e3 = i2(e3))[0], c2 = this.locationFromPosition(u2), s4 = c2.index, a3 = c2.offset, l3 = this, n3 = this.getBlockAtPosition(u2), o2(e3) && n3.isEmpty() && !n3.hasAttributes() ? l3 = new this.constructor(l3.blockList.removeObjectAtIndex(s4)) : n3.getBlockBreakPosition() === a3 && u2++, l3 = l3.removeTextAtRange(e3), new this.constructor(l3.blockList.insertSplittableListAtPosition(r4, u2)); 7192 }, c.prototype.mergeDocumentAtRange = function(e3, n3) { 7193 var o3, r4, s4, a3, u2, c2, l3, h2, p, d, f, g; 7194 return f = (n3 = i2(n3))[0], d = this.locationFromPosition(f), r4 = this.getBlockAtIndex(d.index).getAttributes(), o3 = e3.getBaseBlockAttributes(), g = r4.slice(-o3.length), t2(o3, g) ? (l3 = r4.slice(0, -o3.length), c2 = e3.copyWithBaseBlockAttributes(l3)) : c2 = e3.copy({ consolidateBlocks: true }).copyWithBaseBlockAttributes(r4), s4 = c2.getBlockCount(), a3 = c2.getBlockAtIndex(0), t2(r4, a3.getAttributes()) ? (u2 = a3.getTextWithoutBlockBreak(), p = this.insertTextAtRange(u2, n3), s4 > 1 && (c2 = new this.constructor(c2.getBlocks().slice(1)), h2 = f + u2.getLength(), p = p.insertDocumentAtRange(c2, h2))) : p = this.insertDocumentAtRange(c2, n3), p; 7195 }, c.prototype.insertTextAtRange = function(t3, e3) { 7196 var n3, o3, r4, s4, a3; 7197 return a3 = (e3 = i2(e3))[0], s4 = this.locationFromPosition(a3), o3 = s4.index, r4 = s4.offset, n3 = this.removeTextAtRange(e3), new this.constructor(n3.blockList.editObjectAtIndex(o3, function(e4) { 7198 return e4.copyWithText(e4.text.insertTextAtPosition(t3, r4)); 7199 })); 7200 }, c.prototype.removeTextAtRange = function(t3) { 7201 var e3, n3, r4, s4, a3, u2, c2, l3, h2, p, d, f, g, m, v, y, b, A, C, x, w; 7202 return p = t3 = i2(t3), l3 = p[0], A = p[1], o2(t3) ? this : (d = this.locationRangeFromRange(t3), u2 = d[0], y = d[1], a3 = u2.index, c2 = u2.offset, s4 = this.getBlockAtIndex(a3), v = y.index, b = y.offset, m = this.getBlockAtIndex(v), f = A - l3 === 1 && s4.getBlockBreakPosition() === c2 && m.getBlockBreakPosition() !== b && m.text.getStringAtPosition(b) === "\n", f ? r4 = this.blockList.editObjectAtIndex(v, function(t4) { 7203 return t4.copyWithText(t4.text.removeTextAtRange([b, b + 1])); 7204 }) : (h2 = s4.text.getTextAtRange([0, c2]), C = m.text.getTextAtRange([b, m.getLength()]), x = h2.appendText(C), g = a3 !== v && c2 === 0, w = g && s4.getAttributeLevel() >= m.getAttributeLevel(), n3 = w ? m.copyWithText(x) : s4.copyWithText(x), e3 = v + 1 - a3, r4 = this.blockList.splice(a3, e3, n3)), new this.constructor(r4)); 7205 }, c.prototype.moveTextFromRangeToPosition = function(t3, e3) { 7206 var n3, o3, r4, s4, u2, c2, l3, h2, p, d; 7207 return c2 = t3 = i2(t3), p = c2[0], r4 = c2[1], e3 >= p && r4 >= e3 ? this : (o3 = this.getDocumentAtRange(t3), h2 = this.removeTextAtRange(t3), u2 = e3 > p, u2 && (e3 -= o3.getLength()), l3 = o3.getBlocks(), s4 = l3[0], n3 = 2 <= l3.length ? a2.call(l3, 1) : [], n3.length === 0 ? (d = s4.getTextWithoutBlockBreak(), u2 && (e3 += 1)) : d = s4.text, h2 = h2.insertTextAtRange(d, e3), n3.length === 0 ? h2 : (o3 = new this.constructor(n3), e3 += d.getLength(), h2.insertDocumentAtRange(o3, e3))); 7208 }, c.prototype.addAttributeAtRange = function(t3, e3, i3) { 7209 var o3; 7210 return o3 = this.blockList, this.eachBlockAtRange(i3, function(i4, r4, s4) { 7211 return o3 = o3.editObjectAtIndex(s4, function() { 7212 return n2(t3) ? i4.addAttribute(t3, e3) : r4[0] === r4[1] ? i4 : i4.copyWithText(i4.text.addAttributeAtRange(t3, e3, r4)); 7213 }); 7214 }), new this.constructor(o3); 7215 }, c.prototype.addAttribute = function(t3, e3) { 7216 var n3; 7217 return n3 = this.blockList, this.eachBlock(function(i3, o3) { 7218 return n3 = n3.editObjectAtIndex(o3, function() { 7219 return i3.addAttribute(t3, e3); 7220 }); 7221 }), new this.constructor(n3); 7222 }, c.prototype.removeAttributeAtRange = function(t3, e3) { 7223 var i3; 7224 return i3 = this.blockList, this.eachBlockAtRange(e3, function(e4, o3, r4) { 7225 return n2(t3) ? i3 = i3.editObjectAtIndex(r4, function() { 7226 return e4.removeAttribute(t3); 7227 }) : o3[0] !== o3[1] ? i3 = i3.editObjectAtIndex(r4, function() { 7228 return e4.copyWithText(e4.text.removeAttributeAtRange(t3, o3)); 7229 }) : void 0; 7230 }), new this.constructor(i3); 7231 }, c.prototype.updateAttributesForAttachment = function(t3, e3) { 7232 var n3, i3, o3, r4; 7233 return o3 = (i3 = this.getRangeOfAttachment(e3))[0], n3 = this.locationFromPosition(o3).index, r4 = this.getTextAtIndex(n3), new this.constructor(this.blockList.editObjectAtIndex(n3, function(n4) { 7234 return n4.copyWithText(r4.updateAttributesForAttachment(t3, e3)); 7235 })); 7236 }, c.prototype.removeAttributeForAttachment = function(t3, e3) { 7237 var n3; 7238 return n3 = this.getRangeOfAttachment(e3), this.removeAttributeAtRange(t3, n3); 7239 }, c.prototype.insertBlockBreakAtRange = function(t3) { 7240 var n3, o3, r4, s4; 7241 return s4 = (t3 = i2(t3))[0], r4 = this.locationFromPosition(s4).offset, o3 = this.removeTextAtRange(t3), r4 === 0 && (n3 = [new e2.Block()]), new this.constructor(o3.blockList.insertSplittableListAtPosition(new e2.SplittableList(n3), s4)); 7242 }, c.prototype.applyBlockAttributeAtRange = function(t3, e3, i3) { 7243 var o3, r4, s4, a3; 7244 return s4 = this.expandRangeToLineBreaksAndSplitBlocks(i3), r4 = s4.document, i3 = s4.range, o3 = n2(t3), o3.listAttribute ? (r4 = r4.removeLastListAttributeAtRange(i3, { exceptAttributeName: t3 }), a3 = r4.convertLineBreaksToBlockBreaksInRange(i3), r4 = a3.document, i3 = a3.range) : r4 = o3.exclusive ? r4.removeBlockAttributesAtRange(i3) : o3.terminal ? r4.removeLastTerminalAttributeAtRange(i3) : r4.consolidateBlocksAtRange(i3), r4.addAttributeAtRange(t3, e3, i3); 7245 }, c.prototype.removeLastListAttributeAtRange = function(t3, e3) { 7246 var i3; 7247 return e3 == null && (e3 = {}), i3 = this.blockList, this.eachBlockAtRange(t3, function(t4, o3, r4) { 7248 var s4; 7249 if ((s4 = t4.getLastAttribute()) && n2(s4).listAttribute && s4 !== e3.exceptAttributeName) 7250 return i3 = i3.editObjectAtIndex(r4, function() { 7251 return t4.removeAttribute(s4); 7252 }); 7253 }), new this.constructor(i3); 7254 }, c.prototype.removeLastTerminalAttributeAtRange = function(t3) { 7255 var e3; 7256 return e3 = this.blockList, this.eachBlockAtRange(t3, function(t4, i3, o3) { 7257 var r4; 7258 if ((r4 = t4.getLastAttribute()) && n2(r4).terminal) 7259 return e3 = e3.editObjectAtIndex(o3, function() { 7260 return t4.removeAttribute(r4); 7261 }); 7262 }), new this.constructor(e3); 7263 }, c.prototype.removeBlockAttributesAtRange = function(t3) { 7264 var e3; 7265 return e3 = this.blockList, this.eachBlockAtRange(t3, function(t4, n3, i3) { 7266 return t4.hasAttributes() ? e3 = e3.editObjectAtIndex(i3, function() { 7267 return t4.copyWithoutAttributes(); 7268 }) : void 0; 7269 }), new this.constructor(e3); 7270 }, c.prototype.expandRangeToLineBreaksAndSplitBlocks = function(t3) { 7271 var e3, n3, o3, r4, s4, a3, u2, c2, l3; 7272 return a3 = t3 = i2(t3), l3 = a3[0], r4 = a3[1], c2 = this.locationFromPosition(l3), o3 = this.locationFromPosition(r4), e3 = this, u2 = e3.getBlockAtIndex(c2.index), (c2.offset = u2.findLineBreakInDirectionFromPosition("backward", c2.offset)) != null && (s4 = e3.positionFromLocation(c2), e3 = e3.insertBlockBreakAtRange([s4, s4 + 1]), o3.index += 1, o3.offset -= e3.getBlockAtIndex(c2.index).getLength(), c2.index += 1), c2.offset = 0, o3.offset === 0 && o3.index > c2.index ? (o3.index -= 1, o3.offset = e3.getBlockAtIndex(o3.index).getBlockBreakPosition()) : (n3 = e3.getBlockAtIndex(o3.index), n3.text.getStringAtRange([o3.offset - 1, o3.offset]) === "\n" ? o3.offset -= 1 : o3.offset = n3.findLineBreakInDirectionFromPosition("forward", o3.offset), o3.offset !== n3.getBlockBreakPosition() && (s4 = e3.positionFromLocation(o3), e3 = e3.insertBlockBreakAtRange([s4, s4 + 1]))), l3 = e3.positionFromLocation(c2), r4 = e3.positionFromLocation(o3), t3 = i2([l3, r4]), { document: e3, range: t3 }; 7273 }, c.prototype.convertLineBreaksToBlockBreaksInRange = function(t3) { 7274 var e3, n3, o3; 7275 return n3 = (t3 = i2(t3))[0], o3 = this.getStringAtRange(t3).slice(0, -1), e3 = this, o3.replace(/.*?\n/g, function(t4) { 7276 return n3 += t4.length, e3 = e3.insertBlockBreakAtRange([n3 - 1, n3]); 7277 }), { document: e3, range: t3 }; 7278 }, c.prototype.consolidateBlocksAtRange = function(t3) { 7279 var e3, n3, o3, r4, s4; 7280 return o3 = t3 = i2(t3), s4 = o3[0], n3 = o3[1], r4 = this.locationFromPosition(s4).index, e3 = this.locationFromPosition(n3).index, new this.constructor(this.blockList.consolidateFromIndexToIndex(r4, e3)); 7281 }, c.prototype.getDocumentAtRange = function(t3) { 7282 var e3; 7283 return t3 = i2(t3), e3 = this.blockList.getSplittableListInRange(t3).toArray(), new this.constructor(e3); 7284 }, c.prototype.getStringAtRange = function(t3) { 7285 var e3, n3, o3; 7286 return o3 = t3 = i2(t3), n3 = o3[o3.length - 1], n3 !== this.getLength() && (e3 = -1), this.getDocumentAtRange(t3).toString().slice(0, e3); 7287 }, c.prototype.getBlockAtIndex = function(t3) { 7288 return this.blockList.getObjectAtIndex(t3); 7289 }, c.prototype.getBlockAtPosition = function(t3) { 7290 var e3; 7291 return e3 = this.locationFromPosition(t3).index, this.getBlockAtIndex(e3); 7292 }, c.prototype.getTextAtIndex = function(t3) { 7293 var e3; 7294 return (e3 = this.getBlockAtIndex(t3)) != null ? e3.text : void 0; 7295 }, c.prototype.getTextAtPosition = function(t3) { 7296 var e3; 7297 return e3 = this.locationFromPosition(t3).index, this.getTextAtIndex(e3); 7298 }, c.prototype.getPieceAtPosition = function(t3) { 7299 var e3, n3, i3; 7300 return i3 = this.locationFromPosition(t3), e3 = i3.index, n3 = i3.offset, this.getTextAtIndex(e3).getPieceAtPosition(n3); 7301 }, c.prototype.getCharacterAtPosition = function(t3) { 7302 var e3, n3, i3; 7303 return i3 = this.locationFromPosition(t3), e3 = i3.index, n3 = i3.offset, this.getTextAtIndex(e3).getStringAtRange([n3, n3 + 1]); 7304 }, c.prototype.getLength = function() { 7305 return this.blockList.getEndPosition(); 7306 }, c.prototype.getBlocks = function() { 7307 return this.blockList.toArray(); 7308 }, c.prototype.getBlockCount = function() { 7309 return this.blockList.length; 7310 }, c.prototype.getEditCount = function() { 7311 return this.editCount; 7312 }, c.prototype.eachBlock = function(t3) { 7313 return this.blockList.eachObject(t3); 7314 }, c.prototype.eachBlockAtRange = function(t3, e3) { 7315 var n3, o3, r4, s4, a3, u2, c2, l3, h2, p, d, f; 7316 if (u2 = t3 = i2(t3), d = u2[0], r4 = u2[1], p = this.locationFromPosition(d), o3 = this.locationFromPosition(r4), p.index === o3.index) 7317 return n3 = this.getBlockAtIndex(p.index), f = [p.offset, o3.offset], e3(n3, f, p.index); 7318 for (h2 = [], a3 = s4 = c2 = p.index, l3 = o3.index; l3 >= c2 ? l3 >= s4 : s4 >= l3; a3 = l3 >= c2 ? ++s4 : --s4) 7319 (n3 = this.getBlockAtIndex(a3)) ? (f = function() { 7320 switch (a3) { 7321 case p.index: 7322 return [p.offset, n3.text.getLength()]; 7323 case o3.index: 7324 return [0, o3.offset]; 7325 default: 7326 return [0, n3.text.getLength()]; 7327 } 7328 }(), h2.push(e3(n3, f, a3))) : h2.push(void 0); 7329 return h2; 7330 }, c.prototype.getCommonAttributesAtRange = function(t3) { 7331 var n3, r4, s4; 7332 return r4 = (t3 = i2(t3))[0], o2(t3) ? this.getCommonAttributesAtPosition(r4) : (s4 = [], n3 = [], this.eachBlockAtRange(t3, function(t4, e3) { 7333 return e3[0] !== e3[1] ? (s4.push(t4.text.getCommonAttributesAtRange(e3)), n3.push(l2(t4))) : void 0; 7334 }), e2.Hash.fromCommonAttributesOfObjects(s4).merge(e2.Hash.fromCommonAttributesOfObjects(n3)).toObject()); 7335 }, c.prototype.getCommonAttributesAtPosition = function(t3) { 7336 var n3, i3, o3, r4, s4, a3, c2, h2, p, d; 7337 if (p = this.locationFromPosition(t3), s4 = p.index, h2 = p.offset, o3 = this.getBlockAtIndex(s4), !o3) 7338 return {}; 7339 r4 = l2(o3), n3 = o3.text.getAttributesAtPosition(h2), i3 = o3.text.getAttributesAtPosition(h2 - 1), a3 = function() { 7340 var t4, n4; 7341 t4 = e2.config.textAttributes, n4 = []; 7342 for (c2 in t4) 7343 d = t4[c2], d.inheritable && n4.push(c2); 7344 return n4; 7345 }(); 7346 for (c2 in i3) 7347 d = i3[c2], (d === n3[c2] || u.call(a3, c2) >= 0) && (r4[c2] = d); 7348 return r4; 7349 }, c.prototype.getRangeOfCommonAttributeAtPosition = function(t3, e3) { 7350 var n3, o3, r4, s4, a3, u2, c2, l3, h2; 7351 return a3 = this.locationFromPosition(e3), r4 = a3.index, s4 = a3.offset, h2 = this.getTextAtIndex(r4), u2 = h2.getExpandedRangeForAttributeAtOffset(t3, s4), l3 = u2[0], o3 = u2[1], c2 = this.positionFromLocation({ index: r4, offset: l3 }), n3 = this.positionFromLocation({ index: r4, offset: o3 }), i2([c2, n3]); 7352 }, c.prototype.getBaseBlockAttributes = function() { 7353 var t3, e3, n3, i3, o3, r4, s4; 7354 for (t3 = this.getBlockAtIndex(0).getAttributes(), n3 = i3 = 1, s4 = this.getBlockCount(); s4 >= 1 ? s4 > i3 : i3 > s4; n3 = s4 >= 1 ? ++i3 : --i3) 7355 e3 = this.getBlockAtIndex(n3).getAttributes(), r4 = Math.min(t3.length, e3.length), t3 = function() { 7356 var n4, i4, s5; 7357 for (s5 = [], o3 = n4 = 0, i4 = r4; (i4 >= 0 ? i4 > n4 : n4 > i4) && e3[o3] === t3[o3]; o3 = i4 >= 0 ? ++n4 : --n4) 7358 s5.push(e3[o3]); 7359 return s5; 7360 }(); 7361 return t3; 7362 }, l2 = function(t3) { 7363 var e3, n3; 7364 return n3 = {}, (e3 = t3.getLastAttribute()) && (n3[e3] = true), n3; 7365 }, c.prototype.getAttachmentById = function(t3) { 7366 var e3, n3, i3, o3; 7367 for (o3 = this.getAttachments(), n3 = 0, i3 = o3.length; i3 > n3; n3++) 7368 if (e3 = o3[n3], e3.id === t3) 7369 return e3; 7370 }, c.prototype.getAttachmentPieces = function() { 7371 var t3; 7372 return t3 = [], this.blockList.eachObject(function(e3) { 7373 var n3; 7374 return n3 = e3.text, t3 = t3.concat(n3.getAttachmentPieces()); 7375 }), t3; 7376 }, c.prototype.getAttachments = function() { 7377 var t3, e3, n3, i3, o3; 7378 for (i3 = this.getAttachmentPieces(), o3 = [], t3 = 0, e3 = i3.length; e3 > t3; t3++) 7379 n3 = i3[t3], o3.push(n3.attachment); 7380 return o3; 7381 }, c.prototype.getRangeOfAttachment = function(t3) { 7382 var e3, n3, o3, r4, s4, a3, u2; 7383 for (r4 = 0, s4 = this.blockList.toArray(), n3 = e3 = 0, o3 = s4.length; o3 > e3; n3 = ++e3) { 7384 if (a3 = s4[n3].text, u2 = a3.getRangeOfAttachment(t3)) 7385 return i2([r4 + u2[0], r4 + u2[1]]); 7386 r4 += a3.getLength(); 7387 } 7388 }, c.prototype.getLocationRangeOfAttachment = function(t3) { 7389 var e3; 7390 return e3 = this.getRangeOfAttachment(t3), this.locationRangeFromRange(e3); 7391 }, c.prototype.getAttachmentPieceForAttachment = function(t3) { 7392 var e3, n3, i3, o3; 7393 for (o3 = this.getAttachmentPieces(), e3 = 0, n3 = o3.length; n3 > e3; e3++) 7394 if (i3 = o3[e3], i3.attachment === t3) 7395 return i3; 7396 }, c.prototype.findRangesForBlockAttribute = function(t3) { 7397 var e3, n3, i3, o3, r4, s4, a3; 7398 for (r4 = 0, s4 = [], a3 = this.getBlocks(), n3 = 0, i3 = a3.length; i3 > n3; n3++) 7399 e3 = a3[n3], o3 = e3.getLength(), e3.hasAttribute(t3) && s4.push([r4, r4 + o3]), r4 += o3; 7400 return s4; 7401 }, c.prototype.findRangesForTextAttribute = function(t3, e3) { 7402 var n3, i3, o3, r4, s4, a3, u2, c2, l3, h2; 7403 for (h2 = (e3 != null ? e3 : {}).withValue, a3 = 0, u2 = [], c2 = [], r4 = function(e4) { 7404 return h2 != null ? e4.getAttribute(t3) === h2 : e4.hasAttribute(t3); 7405 }, l3 = this.getPieces(), n3 = 0, i3 = l3.length; i3 > n3; n3++) 7406 s4 = l3[n3], o3 = s4.getLength(), r4(s4) && (u2[1] === a3 ? u2[1] = a3 + o3 : c2.push(u2 = [a3, a3 + o3])), a3 += o3; 7407 return c2; 7408 }, c.prototype.locationFromPosition = function(t3) { 7409 var e3, n3; 7410 return n3 = this.blockList.findIndexAndOffsetAtPosition(Math.max(0, t3)), n3.index != null ? n3 : (e3 = this.getBlocks(), { index: e3.length - 1, offset: e3[e3.length - 1].getLength() }); 7411 }, c.prototype.positionFromLocation = function(t3) { 7412 return this.blockList.findPositionAtIndexAndOffset(t3.index, t3.offset); 7413 }, c.prototype.locationRangeFromPosition = function(t3) { 7414 return i2(this.locationFromPosition(t3)); 7415 }, c.prototype.locationRangeFromRange = function(t3) { 7416 var e3, n3, o3, r4; 7417 if (t3 = i2(t3)) 7418 return r4 = t3[0], n3 = t3[1], o3 = this.locationFromPosition(r4), e3 = this.locationFromPosition(n3), i2([o3, e3]); 7419 }, c.prototype.rangeFromLocationRange = function(t3) { 7420 var e3, n3; 7421 return t3 = i2(t3), e3 = this.positionFromLocation(t3[0]), o2(t3) || (n3 = this.positionFromLocation(t3[1])), i2([e3, n3]); 7422 }, c.prototype.isEqualTo = function(t3) { 7423 return this.blockList.isEqualTo(t3 != null ? t3.blockList : void 0); 7424 }, c.prototype.getTexts = function() { 7425 var t3, e3, n3, i3, o3; 7426 for (i3 = this.getBlocks(), o3 = [], e3 = 0, n3 = i3.length; n3 > e3; e3++) 7427 t3 = i3[e3], o3.push(t3.text); 7428 return o3; 7429 }, c.prototype.getPieces = function() { 7430 var t3, e3, n3, i3, o3; 7431 for (n3 = [], i3 = this.getTexts(), t3 = 0, e3 = i3.length; e3 > t3; t3++) 7432 o3 = i3[t3], n3.push.apply(n3, o3.getPieces()); 7433 return n3; 7434 }, c.prototype.getObjects = function() { 7435 return this.getBlocks().concat(this.getTexts()).concat(this.getPieces()); 7436 }, c.prototype.toSerializableDocument = function() { 7437 var t3; 7438 return t3 = [], this.blockList.eachObject(function(e3) { 7439 return t3.push(e3.copyWithText(e3.text.toSerializableText())); 7440 }), new this.constructor(t3); 7441 }, c.prototype.toString = function() { 7442 return this.blockList.toString(); 7443 }, c.prototype.toJSON = function() { 7444 return this.blockList.toJSON(); 7445 }, c.prototype.toConsole = function() { 7446 var t3; 7447 return JSON.stringify(function() { 7448 var e3, n3, i3, o3; 7449 for (i3 = this.blockList.toArray(), o3 = [], e3 = 0, n3 = i3.length; n3 > e3; e3++) 7450 t3 = i3[e3], o3.push(JSON.parse(t3.text.toConsole())); 7451 return o3; 7452 }.call(this)); 7453 }, c; 7454 }(e2.Object); 7455 }.call(this), function() { 7456 e2.LineBreakInsertion = function() { 7457 function t2(t3) { 7458 var e3; 7459 this.composition = t3, this.document = this.composition.document, e3 = this.composition.getSelectedRange(), this.startPosition = e3[0], this.endPosition = e3[1], this.startLocation = this.document.locationFromPosition(this.startPosition), this.endLocation = this.document.locationFromPosition(this.endPosition), this.block = this.document.getBlockAtIndex(this.endLocation.index), this.breaksOnReturn = this.block.breaksOnReturn(), this.previousCharacter = this.block.text.getStringAtPosition(this.endLocation.offset - 1), this.nextCharacter = this.block.text.getStringAtPosition(this.endLocation.offset); 7460 } 7461 return t2.prototype.shouldInsertBlockBreak = function() { 7462 return this.block.hasAttributes() && this.block.isListItem() && !this.block.isEmpty() ? this.startLocation.offset !== 0 : this.breaksOnReturn && this.nextCharacter !== "\n"; 7463 }, t2.prototype.shouldBreakFormattedBlock = function() { 7464 return this.block.hasAttributes() && !this.block.isListItem() && (this.breaksOnReturn && this.nextCharacter === "\n" || this.previousCharacter === "\n"); 7465 }, t2.prototype.shouldDecreaseListLevel = function() { 7466 return this.block.hasAttributes() && this.block.isListItem() && this.block.isEmpty(); 7467 }, t2.prototype.shouldPrependListItem = function() { 7468 return this.block.isListItem() && this.startLocation.offset === 0 && !this.block.isEmpty(); 7469 }, t2.prototype.shouldRemoveLastBlockAttribute = function() { 7470 return this.block.hasAttributes() && !this.block.isListItem() && this.block.isEmpty(); 7471 }, t2; 7472 }(); 7473 }.call(this), function() { 7474 var t2, n2, i2, o2, r3, s2, a2, u, c, l2, h2 = function(t3, e3) { 7475 function n3() { 7476 this.constructor = t3; 7477 } 7478 for (var i3 in e3) 7479 p.call(e3, i3) && (t3[i3] = e3[i3]); 7480 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 7481 }, p = {}.hasOwnProperty; 7482 s2 = e2.normalizeRange, c = e2.rangesAreEqual, u = e2.rangeIsCollapsed, a2 = e2.objectsAreEqual, t2 = e2.arrayStartsWith, l2 = e2.summarizeArrayChange, i2 = e2.getAllAttributeNames, o2 = e2.getBlockConfig, r3 = e2.getTextConfig, n2 = e2.extend, e2.Composition = function(p2) { 7483 function d() { 7484 this.document = new e2.Document(), this.attachments = [], this.currentAttributes = {}, this.revision = 0; 7485 } 7486 var f; 7487 return h2(d, p2), d.prototype.setDocument = function(t3) { 7488 var e3; 7489 return t3.isEqualTo(this.document) ? void 0 : (this.document = t3, this.refreshAttachments(), this.revision++, (e3 = this.delegate) != null && typeof e3.compositionDidChangeDocument == "function" ? e3.compositionDidChangeDocument(t3) : void 0); 7490 }, d.prototype.getSnapshot = function() { 7491 return { document: this.document, selectedRange: this.getSelectedRange() }; 7492 }, d.prototype.loadSnapshot = function(t3) { 7493 var n3, i3, o3, r4; 7494 return n3 = t3.document, r4 = t3.selectedRange, (i3 = this.delegate) != null && typeof i3.compositionWillLoadSnapshot == "function" && i3.compositionWillLoadSnapshot(), this.setDocument(n3 != null ? n3 : new e2.Document()), this.setSelection(r4 != null ? r4 : [0, 0]), (o3 = this.delegate) != null && typeof o3.compositionDidLoadSnapshot == "function" ? o3.compositionDidLoadSnapshot() : void 0; 7495 }, d.prototype.insertText = function(t3, e3) { 7496 var n3, i3, o3, r4; 7497 return r4 = (e3 != null ? e3 : { updatePosition: true }).updatePosition, i3 = this.getSelectedRange(), this.setDocument(this.document.insertTextAtRange(t3, i3)), o3 = i3[0], n3 = o3 + t3.getLength(), r4 && this.setSelection(n3), this.notifyDelegateOfInsertionAtRange([o3, n3]); 7498 }, d.prototype.insertBlock = function(t3) { 7499 var n3; 7500 return t3 == null && (t3 = new e2.Block()), n3 = new e2.Document([t3]), this.insertDocument(n3); 7501 }, d.prototype.insertDocument = function(t3) { 7502 var n3, i3, o3; 7503 return t3 == null && (t3 = new e2.Document()), i3 = this.getSelectedRange(), this.setDocument(this.document.insertDocumentAtRange(t3, i3)), o3 = i3[0], n3 = o3 + t3.getLength(), this.setSelection(n3), this.notifyDelegateOfInsertionAtRange([o3, n3]); 7504 }, d.prototype.insertString = function(t3, n3) { 7505 var i3, o3; 7506 return i3 = this.getCurrentTextAttributes(), o3 = e2.Text.textForStringWithAttributes(t3, i3), this.insertText(o3, n3); 7507 }, d.prototype.insertBlockBreak = function() { 7508 var t3, e3, n3; 7509 return e3 = this.getSelectedRange(), this.setDocument(this.document.insertBlockBreakAtRange(e3)), n3 = e3[0], t3 = n3 + 1, this.setSelection(t3), this.notifyDelegateOfInsertionAtRange([n3, t3]); 7510 }, d.prototype.insertLineBreak = function() { 7511 var t3, n3; 7512 return n3 = new e2.LineBreakInsertion(this), n3.shouldDecreaseListLevel() ? (this.decreaseListLevel(), this.setSelection(n3.startPosition)) : n3.shouldPrependListItem() ? (t3 = new e2.Document([n3.block.copyWithoutText()]), this.insertDocument(t3)) : n3.shouldInsertBlockBreak() ? this.insertBlockBreak() : n3.shouldRemoveLastBlockAttribute() ? this.removeLastBlockAttribute() : n3.shouldBreakFormattedBlock() ? this.breakFormattedBlock(n3) : this.insertString("\n"); 7513 }, d.prototype.insertHTML = function(t3) { 7514 var n3, i3, o3, r4; 7515 return n3 = e2.Document.fromHTML(t3), o3 = this.getSelectedRange(), this.setDocument(this.document.mergeDocumentAtRange(n3, o3)), r4 = o3[0], i3 = r4 + n3.getLength() - 1, this.setSelection(i3), this.notifyDelegateOfInsertionAtRange([r4, i3]); 7516 }, d.prototype.replaceHTML = function(t3) { 7517 var n3, i3, o3; 7518 return n3 = e2.Document.fromHTML(t3).copyUsingObjectsFromDocument(this.document), i3 = this.getLocationRange({ strict: false }), o3 = this.document.rangeFromLocationRange(i3), this.setDocument(n3), this.setSelection(o3); 7519 }, d.prototype.insertFile = function(t3) { 7520 return this.insertFiles([t3]); 7521 }, d.prototype.insertFiles = function(t3) { 7522 var n3, i3, o3, r4, s3, a3; 7523 for (i3 = [], r4 = 0, s3 = t3.length; s3 > r4; r4++) 7524 o3 = t3[r4], ((a3 = this.delegate) != null ? a3.compositionShouldAcceptFile(o3) : void 0) && (n3 = e2.Attachment.attachmentForFile(o3), i3.push(n3)); 7525 return this.insertAttachments(i3); 7526 }, d.prototype.insertAttachment = function(t3) { 7527 return this.insertAttachments([t3]); 7528 }, d.prototype.insertAttachments = function(t3) { 7529 var n3, i3, o3, r4, s3, a3, u2, c2, l3; 7530 for (c2 = new e2.Text(), r4 = 0, s3 = t3.length; s3 > r4; r4++) 7531 n3 = t3[r4], l3 = n3.getType(), a3 = (u2 = e2.config.attachments[l3]) != null ? u2.presentation : void 0, o3 = this.getCurrentTextAttributes(), a3 && (o3.presentation = a3), i3 = e2.Text.textForAttachmentWithAttributes(n3, o3), c2 = c2.appendText(i3); 7532 return this.insertText(c2); 7533 }, d.prototype.shouldManageDeletingInDirection = function(t3) { 7534 var e3; 7535 if (e3 = this.getLocationRange(), u(e3)) { 7536 if (t3 === "backward" && e3[0].offset === 0) 7537 return true; 7538 if (this.shouldManageMovingCursorInDirection(t3)) 7539 return true; 7540 } else if (e3[0].index !== e3[1].index) 7541 return true; 7542 return false; 7543 }, d.prototype.deleteInDirection = function(t3, e3) { 7544 var n3, i3, o3, r4, s3, a3, c2, l3; 7545 return r4 = (e3 != null ? e3 : {}).length, s3 = this.getLocationRange(), a3 = this.getSelectedRange(), c2 = u(a3), c2 ? o3 = t3 === "backward" && s3[0].offset === 0 : l3 = s3[0].index !== s3[1].index, o3 && this.canDecreaseBlockAttributeLevel() && (i3 = this.getBlock(), i3.isListItem() ? this.decreaseListLevel() : this.decreaseBlockAttributeLevel(), this.setSelection(a3[0]), i3.isEmpty()) ? false : (c2 && (a3 = this.getExpandedRangeInDirection(t3, { length: r4 }), t3 === "backward" && (n3 = this.getAttachmentAtRange(a3))), n3 ? (this.editAttachment(n3), false) : (this.setDocument(this.document.removeTextAtRange(a3)), this.setSelection(a3[0]), o3 || l3 ? false : void 0)); 7546 }, d.prototype.moveTextFromRange = function(t3) { 7547 var e3; 7548 return e3 = this.getSelectedRange()[0], this.setDocument(this.document.moveTextFromRangeToPosition(t3, e3)), this.setSelection(e3); 7549 }, d.prototype.removeAttachment = function(t3) { 7550 var e3; 7551 return (e3 = this.document.getRangeOfAttachment(t3)) ? (this.stopEditingAttachment(), this.setDocument(this.document.removeTextAtRange(e3)), this.setSelection(e3[0])) : void 0; 7552 }, d.prototype.removeLastBlockAttribute = function() { 7553 var t3, e3, n3, i3; 7554 return n3 = this.getSelectedRange(), i3 = n3[0], e3 = n3[1], t3 = this.document.getBlockAtPosition(e3), this.removeCurrentAttribute(t3.getLastAttribute()), this.setSelection(i3); 7555 }, f = " ", d.prototype.insertPlaceholder = function() { 7556 return this.placeholderPosition = this.getPosition(), this.insertString(f); 7557 }, d.prototype.selectPlaceholder = function() { 7558 return this.placeholderPosition != null ? (this.setSelectedRange([this.placeholderPosition, this.placeholderPosition + f.length]), this.getSelectedRange()) : void 0; 7559 }, d.prototype.forgetPlaceholder = function() { 7560 return this.placeholderPosition = null; 7561 }, d.prototype.hasCurrentAttribute = function(t3) { 7562 var e3; 7563 return e3 = this.currentAttributes[t3], e3 != null && e3 !== false; 7564 }, d.prototype.toggleCurrentAttribute = function(t3) { 7565 var e3; 7566 return (e3 = !this.currentAttributes[t3]) ? this.setCurrentAttribute(t3, e3) : this.removeCurrentAttribute(t3); 7567 }, d.prototype.canSetCurrentAttribute = function(t3) { 7568 return o2(t3) ? this.canSetCurrentBlockAttribute(t3) : this.canSetCurrentTextAttribute(t3); 7569 }, d.prototype.canSetCurrentTextAttribute = function() { 7570 var t3, e3, n3, i3, o3; 7571 if (e3 = this.getSelectedDocument()) { 7572 for (o3 = e3.getAttachments(), n3 = 0, i3 = o3.length; i3 > n3; n3++) 7573 if (t3 = o3[n3], !t3.hasContent()) 7574 return false; 7575 return true; 7576 } 7577 }, d.prototype.canSetCurrentBlockAttribute = function() { 7578 var t3; 7579 if (t3 = this.getBlock()) 7580 return !t3.isTerminalBlock(); 7581 }, d.prototype.setCurrentAttribute = function(t3, e3) { 7582 return o2(t3) ? this.setBlockAttribute(t3, e3) : (this.setTextAttribute(t3, e3), this.currentAttributes[t3] = e3, this.notifyDelegateOfCurrentAttributesChange()); 7583 }, d.prototype.setTextAttribute = function(t3, n3) { 7584 var i3, o3, r4, s3; 7585 if (o3 = this.getSelectedRange()) 7586 return r4 = o3[0], i3 = o3[1], r4 !== i3 ? this.setDocument(this.document.addAttributeAtRange(t3, n3, o3)) : t3 === "href" ? (s3 = e2.Text.textForStringWithAttributes(n3, { href: n3 }), this.insertText(s3)) : void 0; 7587 }, d.prototype.setBlockAttribute = function(t3, e3) { 7588 var n3, i3; 7589 if (i3 = this.getSelectedRange()) 7590 return this.canSetCurrentAttribute(t3) ? (n3 = this.getBlock(), this.setDocument(this.document.applyBlockAttributeAtRange(t3, e3, i3)), this.setSelection(i3)) : void 0; 7591 }, d.prototype.removeCurrentAttribute = function(t3) { 7592 return o2(t3) ? (this.removeBlockAttribute(t3), this.updateCurrentAttributes()) : (this.removeTextAttribute(t3), delete this.currentAttributes[t3], this.notifyDelegateOfCurrentAttributesChange()); 7593 }, d.prototype.removeTextAttribute = function(t3) { 7594 var e3; 7595 if (e3 = this.getSelectedRange()) 7596 return this.setDocument(this.document.removeAttributeAtRange(t3, e3)); 7597 }, d.prototype.removeBlockAttribute = function(t3) { 7598 var e3; 7599 if (e3 = this.getSelectedRange()) 7600 return this.setDocument(this.document.removeAttributeAtRange(t3, e3)); 7601 }, d.prototype.canDecreaseNestingLevel = function() { 7602 var t3; 7603 return ((t3 = this.getBlock()) != null ? t3.getNestingLevel() : void 0) > 0; 7604 }, d.prototype.canIncreaseNestingLevel = function() { 7605 var e3, n3, i3; 7606 if (e3 = this.getBlock()) 7607 return ((i3 = o2(e3.getLastNestableAttribute())) != null ? i3.listAttribute : 0) ? (n3 = this.getPreviousBlock()) ? t2(n3.getListItemAttributes(), e3.getListItemAttributes()) : void 0 : e3.getNestingLevel() > 0; 7608 }, d.prototype.decreaseNestingLevel = function() { 7609 var t3; 7610 if (t3 = this.getBlock()) 7611 return this.setDocument(this.document.replaceBlock(t3, t3.decreaseNestingLevel())); 7612 }, d.prototype.increaseNestingLevel = function() { 7613 var t3; 7614 if (t3 = this.getBlock()) 7615 return this.setDocument(this.document.replaceBlock(t3, t3.increaseNestingLevel())); 7616 }, d.prototype.canDecreaseBlockAttributeLevel = function() { 7617 var t3; 7618 return ((t3 = this.getBlock()) != null ? t3.getAttributeLevel() : void 0) > 0; 7619 }, d.prototype.decreaseBlockAttributeLevel = function() { 7620 var t3, e3; 7621 return (t3 = (e3 = this.getBlock()) != null ? e3.getLastAttribute() : void 0) ? this.removeCurrentAttribute(t3) : void 0; 7622 }, d.prototype.decreaseListLevel = function() { 7623 var t3, e3, n3, i3, o3, r4; 7624 for (r4 = this.getSelectedRange()[0], o3 = this.document.locationFromPosition(r4).index, n3 = o3, t3 = this.getBlock().getAttributeLevel(); (e3 = this.document.getBlockAtIndex(n3 + 1)) && e3.isListItem() && e3.getAttributeLevel() > t3; ) 7625 n3++; 7626 return r4 = this.document.positionFromLocation({ index: o3, offset: 0 }), i3 = this.document.positionFromLocation({ index: n3, offset: 0 }), this.setDocument(this.document.removeLastListAttributeAtRange([r4, i3])); 7627 }, d.prototype.updateCurrentAttributes = function() { 7628 var t3, e3, n3, o3, r4, s3; 7629 if (s3 = this.getSelectedRange({ ignoreLock: true })) { 7630 for (e3 = this.document.getCommonAttributesAtRange(s3), r4 = i2(), n3 = 0, o3 = r4.length; o3 > n3; n3++) 7631 t3 = r4[n3], e3[t3] || this.canSetCurrentAttribute(t3) || (e3[t3] = false); 7632 if (!a2(e3, this.currentAttributes)) 7633 return this.currentAttributes = e3, this.notifyDelegateOfCurrentAttributesChange(); 7634 } 7635 }, d.prototype.getCurrentAttributes = function() { 7636 return n2.call({}, this.currentAttributes); 7637 }, d.prototype.getCurrentTextAttributes = function() { 7638 var t3, e3, n3, i3; 7639 t3 = {}, n3 = this.currentAttributes; 7640 for (e3 in n3) 7641 i3 = n3[e3], i3 !== false && r3(e3) && (t3[e3] = i3); 7642 return t3; 7643 }, d.prototype.freezeSelection = function() { 7644 return this.setCurrentAttribute("frozen", true); 7645 }, d.prototype.thawSelection = function() { 7646 return this.removeCurrentAttribute("frozen"); 7647 }, d.prototype.hasFrozenSelection = function() { 7648 return this.hasCurrentAttribute("frozen"); 7649 }, d.proxyMethod("getSelectionManager().getPointRange"), d.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"), d.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"), d.proxyMethod("getSelectionManager().locationIsCursorTarget"), d.proxyMethod("getSelectionManager().selectionIsExpanded"), d.proxyMethod("delegate?.getSelectionManager"), d.prototype.setSelection = function(t3) { 7650 var e3, n3; 7651 return e3 = this.document.locationRangeFromRange(t3), (n3 = this.delegate) != null ? n3.compositionDidRequestChangingSelectionToLocationRange(e3) : void 0; 7652 }, d.prototype.getSelectedRange = function() { 7653 var t3; 7654 return (t3 = this.getLocationRange()) ? this.document.rangeFromLocationRange(t3) : void 0; 7655 }, d.prototype.setSelectedRange = function(t3) { 7656 var e3; 7657 return e3 = this.document.locationRangeFromRange(t3), this.getSelectionManager().setLocationRange(e3); 7658 }, d.prototype.getPosition = function() { 7659 var t3; 7660 return (t3 = this.getLocationRange()) ? this.document.positionFromLocation(t3[0]) : void 0; 7661 }, d.prototype.getLocationRange = function(t3) { 7662 var e3, n3; 7663 return (e3 = (n3 = this.targetLocationRange) != null ? n3 : this.getSelectionManager().getLocationRange(t3)) != null ? e3 : s2({ index: 0, offset: 0 }); 7664 }, d.prototype.withTargetLocationRange = function(t3, e3) { 7665 var n3; 7666 this.targetLocationRange = t3; 7667 try { 7668 n3 = e3(); 7669 } finally { 7670 this.targetLocationRange = null; 7671 } 7672 return n3; 7673 }, d.prototype.withTargetRange = function(t3, e3) { 7674 var n3; 7675 return n3 = this.document.locationRangeFromRange(t3), this.withTargetLocationRange(n3, e3); 7676 }, d.prototype.withTargetDOMRange = function(t3, e3) { 7677 var n3; 7678 return n3 = this.createLocationRangeFromDOMRange(t3, { strict: false }), this.withTargetLocationRange(n3, e3); 7679 }, d.prototype.getExpandedRangeInDirection = function(t3, e3) { 7680 var n3, i3, o3, r4; 7681 return i3 = (e3 != null ? e3 : {}).length, o3 = this.getSelectedRange(), r4 = o3[0], n3 = o3[1], t3 === "backward" ? i3 ? r4 -= i3 : r4 = this.translateUTF16PositionFromOffset(r4, -1) : i3 ? n3 += i3 : n3 = this.translateUTF16PositionFromOffset(n3, 1), s2([r4, n3]); 7682 }, d.prototype.shouldManageMovingCursorInDirection = function(t3) { 7683 var e3; 7684 return this.editingAttachment ? true : (e3 = this.getExpandedRangeInDirection(t3), this.getAttachmentAtRange(e3) != null); 7685 }, d.prototype.moveCursorInDirection = function(t3) { 7686 var e3, n3, i3, o3; 7687 return this.editingAttachment ? i3 = this.document.getRangeOfAttachment(this.editingAttachment) : (o3 = this.getSelectedRange(), i3 = this.getExpandedRangeInDirection(t3), n3 = !c(o3, i3)), this.setSelectedRange(t3 === "backward" ? i3[0] : i3[1]), n3 && (e3 = this.getAttachmentAtRange(i3)) ? this.editAttachment(e3) : void 0; 7688 }, d.prototype.expandSelectionInDirection = function(t3, e3) { 7689 var n3, i3; 7690 return n3 = (e3 != null ? e3 : {}).length, i3 = this.getExpandedRangeInDirection(t3, { length: n3 }), this.setSelectedRange(i3); 7691 }, d.prototype.expandSelectionForEditing = function() { 7692 return this.hasCurrentAttribute("href") ? this.expandSelectionAroundCommonAttribute("href") : void 0; 7693 }, d.prototype.expandSelectionAroundCommonAttribute = function(t3) { 7694 var e3, n3; 7695 return e3 = this.getPosition(), n3 = this.document.getRangeOfCommonAttributeAtPosition(t3, e3), this.setSelectedRange(n3); 7696 }, d.prototype.selectionContainsAttachments = function() { 7697 var t3; 7698 return ((t3 = this.getSelectedAttachments()) != null ? t3.length : void 0) > 0; 7699 }, d.prototype.selectionIsInCursorTarget = function() { 7700 return this.editingAttachment || this.positionIsCursorTarget(this.getPosition()); 7701 }, d.prototype.positionIsCursorTarget = function(t3) { 7702 var e3; 7703 return (e3 = this.document.locationFromPosition(t3)) ? this.locationIsCursorTarget(e3) : void 0; 7704 }, d.prototype.positionIsBlockBreak = function(t3) { 7705 var e3; 7706 return (e3 = this.document.getPieceAtPosition(t3)) != null ? e3.isBlockBreak() : void 0; 7707 }, d.prototype.getSelectedDocument = function() { 7708 var t3; 7709 return (t3 = this.getSelectedRange()) ? this.document.getDocumentAtRange(t3) : void 0; 7710 }, d.prototype.getSelectedAttachments = function() { 7711 var t3; 7712 return (t3 = this.getSelectedDocument()) != null ? t3.getAttachments() : void 0; 7713 }, d.prototype.getAttachments = function() { 7714 return this.attachments.slice(0); 7715 }, d.prototype.refreshAttachments = function() { 7716 var t3, e3, n3, i3, o3, r4, s3, a3, u2, c2, h3, p3; 7717 for (n3 = this.document.getAttachments(), a3 = l2(this.attachments, n3), t3 = a3.added, h3 = a3.removed, this.attachments = n3, i3 = 0, r4 = h3.length; r4 > i3; i3++) 7718 e3 = h3[i3], e3.delegate = null, (u2 = this.delegate) != null && typeof u2.compositionDidRemoveAttachment == "function" && u2.compositionDidRemoveAttachment(e3); 7719 for (p3 = [], o3 = 0, s3 = t3.length; s3 > o3; o3++) 7720 e3 = t3[o3], e3.delegate = this, p3.push((c2 = this.delegate) != null && typeof c2.compositionDidAddAttachment == "function" ? c2.compositionDidAddAttachment(e3) : void 0); 7721 return p3; 7722 }, d.prototype.attachmentDidChangeAttributes = function(t3) { 7723 var e3; 7724 return this.revision++, (e3 = this.delegate) != null && typeof e3.compositionDidEditAttachment == "function" ? e3.compositionDidEditAttachment(t3) : void 0; 7725 }, d.prototype.attachmentDidChangePreviewURL = function(t3) { 7726 var e3; 7727 return this.revision++, (e3 = this.delegate) != null && typeof e3.compositionDidChangeAttachmentPreviewURL == "function" ? e3.compositionDidChangeAttachmentPreviewURL(t3) : void 0; 7728 }, d.prototype.editAttachment = function(t3, e3) { 7729 var n3; 7730 if (t3 !== this.editingAttachment) 7731 return this.stopEditingAttachment(), this.editingAttachment = t3, (n3 = this.delegate) != null && typeof n3.compositionDidStartEditingAttachment == "function" ? n3.compositionDidStartEditingAttachment(this.editingAttachment, e3) : void 0; 7732 }, d.prototype.stopEditingAttachment = function() { 7733 var t3; 7734 if (this.editingAttachment) 7735 return (t3 = this.delegate) != null && typeof t3.compositionDidStopEditingAttachment == "function" && t3.compositionDidStopEditingAttachment(this.editingAttachment), this.editingAttachment = null; 7736 }, d.prototype.updateAttributesForAttachment = function(t3, e3) { 7737 return this.setDocument(this.document.updateAttributesForAttachment(t3, e3)); 7738 }, d.prototype.removeAttributeForAttachment = function(t3, e3) { 7739 return this.setDocument(this.document.removeAttributeForAttachment(t3, e3)); 7740 }, d.prototype.breakFormattedBlock = function(t3) { 7741 var n3, i3, o3, r4, s3; 7742 return i3 = t3.document, n3 = t3.block, r4 = t3.startPosition, s3 = [r4 - 1, r4], n3.getBlockBreakPosition() === t3.startLocation.offset ? (n3.breaksOnReturn() && t3.nextCharacter === "\n" ? r4 += 1 : i3 = i3.removeTextAtRange(s3), s3 = [r4, r4]) : t3.nextCharacter === "\n" ? t3.previousCharacter === "\n" ? s3 = [r4 - 1, r4 + 1] : (s3 = [r4, r4 + 1], r4 += 1) : t3.startLocation.offset - 1 !== 0 && (r4 += 1), o3 = new e2.Document([n3.removeLastAttribute().copyWithoutText()]), this.setDocument(i3.insertDocumentAtRange(o3, s3)), this.setSelection(r4); 7743 }, d.prototype.getPreviousBlock = function() { 7744 var t3, e3; 7745 return (e3 = this.getLocationRange()) && (t3 = e3[0].index, t3 > 0) ? this.document.getBlockAtIndex(t3 - 1) : void 0; 7746 }, d.prototype.getBlock = function() { 7747 var t3; 7748 return (t3 = this.getLocationRange()) ? this.document.getBlockAtIndex(t3[0].index) : void 0; 7749 }, d.prototype.getAttachmentAtRange = function(t3) { 7750 var n3; 7751 return n3 = this.document.getDocumentAtRange(t3), n3.toString() === e2.OBJECT_REPLACEMENT_CHARACTER + "\n" ? n3.getAttachments()[0] : void 0; 7752 }, d.prototype.notifyDelegateOfCurrentAttributesChange = function() { 7753 var t3; 7754 return (t3 = this.delegate) != null && typeof t3.compositionDidChangeCurrentAttributes == "function" ? t3.compositionDidChangeCurrentAttributes(this.currentAttributes) : void 0; 7755 }, d.prototype.notifyDelegateOfInsertionAtRange = function(t3) { 7756 var e3; 7757 return (e3 = this.delegate) != null && typeof e3.compositionDidPerformInsertionAtRange == "function" ? e3.compositionDidPerformInsertionAtRange(t3) : void 0; 7758 }, d.prototype.translateUTF16PositionFromOffset = function(t3, e3) { 7759 var n3, i3; 7760 return i3 = this.document.toUTF16String(), n3 = i3.offsetFromUCS2Offset(t3), i3.offsetToUCS2Offset(n3 + e3); 7761 }, d; 7762 }(e2.BasicObject); 7763 }.call(this), function() { 7764 var t2 = function(t3, e3) { 7765 function i2() { 7766 this.constructor = t3; 7767 } 7768 for (var o2 in e3) 7769 n2.call(e3, o2) && (t3[o2] = e3[o2]); 7770 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 7771 }, n2 = {}.hasOwnProperty; 7772 e2.UndoManager = function(e3) { 7773 function n3(t3) { 7774 this.composition = t3, this.undoEntries = [], this.redoEntries = []; 7775 } 7776 var i2; 7777 return t2(n3, e3), n3.prototype.recordUndoEntry = function(t3, e4) { 7778 var n4, o2, r3, s2, a2; 7779 return s2 = e4 != null ? e4 : {}, o2 = s2.context, n4 = s2.consolidatable, r3 = this.undoEntries.slice(-1)[0], n4 && i2(r3, t3, o2) ? void 0 : (a2 = this.createEntry({ description: t3, context: o2 }), this.undoEntries.push(a2), this.redoEntries = []); 7780 }, n3.prototype.undo = function() { 7781 var t3, e4; 7782 return (e4 = this.undoEntries.pop()) ? (t3 = this.createEntry(e4), this.redoEntries.push(t3), this.composition.loadSnapshot(e4.snapshot)) : void 0; 7783 }, n3.prototype.redo = function() { 7784 var t3, e4; 7785 return (t3 = this.redoEntries.pop()) ? (e4 = this.createEntry(t3), this.undoEntries.push(e4), this.composition.loadSnapshot(t3.snapshot)) : void 0; 7786 }, n3.prototype.canUndo = function() { 7787 return this.undoEntries.length > 0; 7788 }, n3.prototype.canRedo = function() { 7789 return this.redoEntries.length > 0; 7790 }, n3.prototype.createEntry = function(t3) { 7791 var e4, n4, i3; 7792 return i3 = t3 != null ? t3 : {}, n4 = i3.description, e4 = i3.context, { description: n4 != null ? n4.toString() : void 0, context: JSON.stringify(e4), snapshot: this.composition.getSnapshot() }; 7793 }, i2 = function(t3, e4, n4) { 7794 return (t3 != null ? t3.description : void 0) === (e4 != null ? e4.toString() : void 0) && (t3 != null ? t3.context : void 0) === JSON.stringify(n4); 7795 }, n3; 7796 }(e2.BasicObject); 7797 }.call(this), function() { 7798 var t2; 7799 e2.attachmentGalleryFilter = function(e3) { 7800 var n2; 7801 return n2 = new t2(e3), n2.perform(), n2.getSnapshot(); 7802 }, t2 = function() { 7803 function t3(t4) { 7804 this.document = t4.document, this.selectedRange = t4.selectedRange; 7805 } 7806 var e3, n2, i2; 7807 return e3 = "attachmentGallery", n2 = "presentation", i2 = "gallery", t3.prototype.perform = function() { 7808 return this.removeBlockAttribute(), this.applyBlockAttribute(); 7809 }, t3.prototype.getSnapshot = function() { 7810 return { document: this.document, selectedRange: this.selectedRange }; 7811 }, t3.prototype.removeBlockAttribute = function() { 7812 var t4, n3, i3, o2, r3; 7813 for (o2 = this.findRangesOfBlocks(), r3 = [], t4 = 0, n3 = o2.length; n3 > t4; t4++) 7814 i3 = o2[t4], r3.push(this.document = this.document.removeAttributeAtRange(e3, i3)); 7815 return r3; 7816 }, t3.prototype.applyBlockAttribute = function() { 7817 var t4, n3, i3, o2, r3, s2; 7818 for (i3 = 0, r3 = this.findRangesOfPieces(), s2 = [], t4 = 0, n3 = r3.length; n3 > t4; t4++) 7819 o2 = r3[t4], o2[1] - o2[0] > 1 && (o2[0] += i3, o2[1] += i3, this.document.getCharacterAtPosition(o2[1]) !== "\n" && (this.document = this.document.insertBlockBreakAtRange(o2[1]), o2[1] < this.selectedRange[1] && this.moveSelectedRangeForward(), o2[1]++, i3++), o2[0] !== 0 && this.document.getCharacterAtPosition(o2[0] - 1) !== "\n" && (this.document = this.document.insertBlockBreakAtRange(o2[0]), o2[0] < this.selectedRange[0] && this.moveSelectedRangeForward(), o2[0]++, i3++), s2.push(this.document = this.document.applyBlockAttributeAtRange(e3, true, o2))); 7820 return s2; 7821 }, t3.prototype.findRangesOfBlocks = function() { 7822 return this.document.findRangesForBlockAttribute(e3); 7823 }, t3.prototype.findRangesOfPieces = function() { 7824 return this.document.findRangesForTextAttribute(n2, { withValue: i2 }); 7825 }, t3.prototype.moveSelectedRangeForward = function() { 7826 return this.selectedRange[0] += 1, this.selectedRange[1] += 1; 7827 }, t3; 7828 }(); 7829 }.call(this), function() { 7830 var t2 = function(t3, e3) { 7831 return function() { 7832 return t3.apply(e3, arguments); 7833 }; 7834 }; 7835 e2.Editor = function() { 7836 function n2(n3, o2, r3) { 7837 this.composition = n3, this.selectionManager = o2, this.element = r3, this.insertFiles = t2(this.insertFiles, this), this.undoManager = new e2.UndoManager(this.composition), this.filters = i2.slice(0); 7838 } 7839 var i2; 7840 return i2 = [e2.attachmentGalleryFilter], n2.prototype.loadDocument = function(t3) { 7841 return this.loadSnapshot({ document: t3, selectedRange: [0, 0] }); 7842 }, n2.prototype.loadHTML = function(t3) { 7843 return t3 == null && (t3 = ""), this.loadDocument(e2.Document.fromHTML(t3, { referenceElement: this.element })); 7844 }, n2.prototype.loadJSON = function(t3) { 7845 var n3, i3; 7846 return n3 = t3.document, i3 = t3.selectedRange, n3 = e2.Document.fromJSON(n3), this.loadSnapshot({ document: n3, selectedRange: i3 }); 7847 }, n2.prototype.loadSnapshot = function(t3) { 7848 return this.undoManager = new e2.UndoManager(this.composition), this.composition.loadSnapshot(t3); 7849 }, n2.prototype.getDocument = function() { 7850 return this.composition.document; 7851 }, n2.prototype.getSelectedDocument = function() { 7852 return this.composition.getSelectedDocument(); 7853 }, n2.prototype.getSnapshot = function() { 7854 return this.composition.getSnapshot(); 7855 }, n2.prototype.toJSON = function() { 7856 return this.getSnapshot(); 7857 }, n2.prototype.deleteInDirection = function(t3) { 7858 return this.composition.deleteInDirection(t3); 7859 }, n2.prototype.insertAttachment = function(t3) { 7860 return this.composition.insertAttachment(t3); 7861 }, n2.prototype.insertAttachments = function(t3) { 7862 return this.composition.insertAttachments(t3); 7863 }, n2.prototype.insertDocument = function(t3) { 7864 return this.composition.insertDocument(t3); 7865 }, n2.prototype.insertFile = function(t3) { 7866 return this.composition.insertFile(t3); 7867 }, n2.prototype.insertFiles = function(t3) { 7868 return this.composition.insertFiles(t3); 7869 }, n2.prototype.insertHTML = function(t3) { 7870 return this.composition.insertHTML(t3); 7871 }, n2.prototype.insertString = function(t3) { 7872 return this.composition.insertString(t3); 7873 }, n2.prototype.insertText = function(t3) { 7874 return this.composition.insertText(t3); 7875 }, n2.prototype.insertLineBreak = function() { 7876 return this.composition.insertLineBreak(); 7877 }, n2.prototype.getSelectedRange = function() { 7878 return this.composition.getSelectedRange(); 7879 }, n2.prototype.getPosition = function() { 7880 return this.composition.getPosition(); 7881 }, n2.prototype.getClientRectAtPosition = function(t3) { 7882 var e3; 7883 return e3 = this.getDocument().locationRangeFromRange([t3, t3 + 1]), this.selectionManager.getClientRectAtLocationRange(e3); 7884 }, n2.prototype.expandSelectionInDirection = function(t3) { 7885 return this.composition.expandSelectionInDirection(t3); 7886 }, n2.prototype.moveCursorInDirection = function(t3) { 7887 return this.composition.moveCursorInDirection(t3); 7888 }, n2.prototype.setSelectedRange = function(t3) { 7889 return this.composition.setSelectedRange(t3); 7890 }, n2.prototype.activateAttribute = function(t3, e3) { 7891 return e3 == null && (e3 = true), this.composition.setCurrentAttribute(t3, e3); 7892 }, n2.prototype.attributeIsActive = function(t3) { 7893 return this.composition.hasCurrentAttribute(t3); 7894 }, n2.prototype.canActivateAttribute = function(t3) { 7895 return this.composition.canSetCurrentAttribute(t3); 7896 }, n2.prototype.deactivateAttribute = function(t3) { 7897 return this.composition.removeCurrentAttribute(t3); 7898 }, n2.prototype.canDecreaseNestingLevel = function() { 7899 return this.composition.canDecreaseNestingLevel(); 7900 }, n2.prototype.canIncreaseNestingLevel = function() { 7901 return this.composition.canIncreaseNestingLevel(); 7902 }, n2.prototype.decreaseNestingLevel = function() { 7903 return this.canDecreaseNestingLevel() ? this.composition.decreaseNestingLevel() : void 0; 7904 }, n2.prototype.increaseNestingLevel = function() { 7905 return this.canIncreaseNestingLevel() ? this.composition.increaseNestingLevel() : void 0; 7906 }, n2.prototype.canRedo = function() { 7907 return this.undoManager.canRedo(); 7908 }, n2.prototype.canUndo = function() { 7909 return this.undoManager.canUndo(); 7910 }, n2.prototype.recordUndoEntry = function(t3, e3) { 7911 var n3, i3, o2; 7912 return o2 = e3 != null ? e3 : {}, i3 = o2.context, n3 = o2.consolidatable, this.undoManager.recordUndoEntry(t3, { context: i3, consolidatable: n3 }); 7913 }, n2.prototype.redo = function() { 7914 return this.canRedo() ? this.undoManager.redo() : void 0; 7915 }, n2.prototype.undo = function() { 7916 return this.canUndo() ? this.undoManager.undo() : void 0; 7917 }, n2; 7918 }(); 7919 }.call(this), function() { 7920 var t2 = function(t3, e3) { 7921 function i2() { 7922 this.constructor = t3; 7923 } 7924 for (var o2 in e3) 7925 n2.call(e3, o2) && (t3[o2] = e3[o2]); 7926 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 7927 }, n2 = {}.hasOwnProperty; 7928 e2.ManagedAttachment = function(e3) { 7929 function n3(t3, e4) { 7930 var n4; 7931 this.attachmentManager = t3, this.attachment = e4, n4 = this.attachment, this.id = n4.id, this.file = n4.file; 7932 } 7933 return t2(n3, e3), n3.prototype.remove = function() { 7934 return this.attachmentManager.requestRemovalOfAttachment(this.attachment); 7935 }, n3.proxyMethod("attachment.getAttribute"), n3.proxyMethod("attachment.hasAttribute"), n3.proxyMethod("attachment.setAttribute"), n3.proxyMethod("attachment.getAttributes"), n3.proxyMethod("attachment.setAttributes"), n3.proxyMethod("attachment.isPending"), n3.proxyMethod("attachment.isPreviewable"), n3.proxyMethod("attachment.getURL"), n3.proxyMethod("attachment.getHref"), n3.proxyMethod("attachment.getFilename"), n3.proxyMethod("attachment.getFilesize"), n3.proxyMethod("attachment.getFormattedFilesize"), n3.proxyMethod("attachment.getExtension"), n3.proxyMethod("attachment.getContentType"), n3.proxyMethod("attachment.getFile"), n3.proxyMethod("attachment.setFile"), n3.proxyMethod("attachment.releaseFile"), n3.proxyMethod("attachment.getUploadProgress"), n3.proxyMethod("attachment.setUploadProgress"), n3; 7936 }(e2.BasicObject); 7937 }.call(this), function() { 7938 var t2 = function(t3, e3) { 7939 function i2() { 7940 this.constructor = t3; 7941 } 7942 for (var o2 in e3) 7943 n2.call(e3, o2) && (t3[o2] = e3[o2]); 7944 return i2.prototype = e3.prototype, t3.prototype = new i2(), t3.__super__ = e3.prototype, t3; 7945 }, n2 = {}.hasOwnProperty; 7946 e2.AttachmentManager = function(n3) { 7947 function i2(t3) { 7948 var e3, n4, i3; 7949 for (t3 == null && (t3 = []), this.managedAttachments = {}, n4 = 0, i3 = t3.length; i3 > n4; n4++) 7950 e3 = t3[n4], this.manageAttachment(e3); 7951 } 7952 return t2(i2, n3), i2.prototype.getAttachments = function() { 7953 var t3, e3, n4, i3; 7954 n4 = this.managedAttachments, i3 = []; 7955 for (e3 in n4) 7956 t3 = n4[e3], i3.push(t3); 7957 return i3; 7958 }, i2.prototype.manageAttachment = function(t3) { 7959 var n4, i3; 7960 return (n4 = this.managedAttachments)[i3 = t3.id] != null ? n4[i3] : n4[i3] = new e2.ManagedAttachment(this, t3); 7961 }, i2.prototype.attachmentIsManaged = function(t3) { 7962 return t3.id in this.managedAttachments; 7963 }, i2.prototype.requestRemovalOfAttachment = function(t3) { 7964 var e3; 7965 return this.attachmentIsManaged(t3) && (e3 = this.delegate) != null && typeof e3.attachmentManagerDidRequestRemovalOfAttachment == "function" ? e3.attachmentManagerDidRequestRemovalOfAttachment(t3) : void 0; 7966 }, i2.prototype.unmanageAttachment = function(t3) { 7967 var e3; 7968 return e3 = this.managedAttachments[t3.id], delete this.managedAttachments[t3.id], e3; 7969 }, i2; 7970 }(e2.BasicObject); 7971 }.call(this), function() { 7972 var t2, n2, i2, o2, r3, s2, a2, u, c, l2, h2; 7973 t2 = e2.elementContainsNode, n2 = e2.findChildIndexOfNode, r3 = e2.nodeIsBlockStart, s2 = e2.nodeIsBlockStartComment, o2 = e2.nodeIsBlockContainer, a2 = e2.nodeIsCursorTarget, u = e2.nodeIsEmptyTextNode, c = e2.nodeIsTextNode, i2 = e2.nodeIsAttachmentElement, l2 = e2.tagName, h2 = e2.walkTree, e2.LocationMapper = function() { 7974 function e3(t3) { 7975 this.element = t3; 7976 } 7977 var p, d, f, g; 7978 return e3.prototype.findLocationFromContainerAndOffset = function(e4, i3, o3) { 7979 var s3, u2, l3, p2, g2, m, v; 7980 for (m = (o3 != null ? o3 : { strict: true }).strict, u2 = 0, l3 = false, p2 = { index: 0, offset: 0 }, (s3 = this.findAttachmentElementParentForNode(e4)) && (e4 = s3.parentNode, i3 = n2(s3)), v = h2(this.element, { usingFilter: f }); v.nextNode(); ) { 7981 if (g2 = v.currentNode, g2 === e4 && c(e4)) { 7982 a2(g2) || (p2.offset += i3); 7983 break; 7984 } 7985 if (g2.parentNode === e4) { 7986 if (u2++ === i3) 7987 break; 7988 } else if (!t2(e4, g2) && u2 > 0) 7989 break; 7990 r3(g2, { strict: m }) ? (l3 && p2.index++, p2.offset = 0, l3 = true) : p2.offset += d(g2); 7991 } 7992 return p2; 7993 }, e3.prototype.findContainerAndOffsetFromLocation = function(t3) { 7994 var e4, i3, s3, u2, l3; 7995 if (t3.index === 0 && t3.offset === 0) { 7996 for (e4 = this.element, u2 = 0; e4.firstChild; ) 7997 if (e4 = e4.firstChild, o2(e4)) { 7998 u2 = 1; 7999 break; 8000 } 8001 return [e4, u2]; 8002 } 8003 if (l3 = this.findNodeAndOffsetFromLocation(t3), i3 = l3[0], s3 = l3[1], i3) { 8004 if (c(i3)) 8005 d(i3) === 0 ? (e4 = i3.parentNode.parentNode, u2 = n2(i3.parentNode), a2(i3, { name: "right" }) && u2++) : (e4 = i3, u2 = t3.offset - s3); 8006 else { 8007 if (e4 = i3.parentNode, !r3(i3.previousSibling) && !o2(e4)) 8008 for (; i3 === e4.lastChild && (i3 = e4, e4 = e4.parentNode, !o2(e4)); ) 8009 ; 8010 u2 = n2(i3), t3.offset !== 0 && u2++; 8011 } 8012 return [e4, u2]; 8013 } 8014 }, e3.prototype.findNodeAndOffsetFromLocation = function(t3) { 8015 var e4, n3, i3, o3, r4, s3, u2, l3; 8016 for (u2 = 0, l3 = this.getSignificantNodesForIndex(t3.index), n3 = 0, i3 = l3.length; i3 > n3; n3++) { 8017 if (e4 = l3[n3], o3 = d(e4), t3.offset <= u2 + o3) 8018 if (c(e4)) { 8019 if (r4 = e4, s3 = u2, t3.offset === s3 && a2(r4)) 8020 break; 8021 } else 8022 r4 || (r4 = e4, s3 = u2); 8023 if (u2 += o3, u2 > t3.offset) 8024 break; 8025 } 8026 return [r4, s3]; 8027 }, e3.prototype.findAttachmentElementParentForNode = function(t3) { 8028 for (; t3 && t3 !== this.element; ) { 8029 if (i2(t3)) 8030 return t3; 8031 t3 = t3.parentNode; 8032 } 8033 }, e3.prototype.getSignificantNodesForIndex = function(t3) { 8034 var e4, n3, i3, o3, r4; 8035 for (i3 = [], r4 = h2(this.element, { usingFilter: p }), o3 = false; r4.nextNode(); ) 8036 if (n3 = r4.currentNode, s2(n3)) { 8037 if (typeof e4 != "undefined" && e4 !== null ? e4++ : e4 = 0, e4 === t3) 8038 o3 = true; 8039 else if (o3) 8040 break; 8041 } else 8042 o3 && i3.push(n3); 8043 return i3; 8044 }, d = function(t3) { 8045 var e4; 8046 return t3.nodeType === Node.TEXT_NODE ? a2(t3) ? 0 : (e4 = t3.textContent, e4.length) : l2(t3) === "br" || i2(t3) ? 1 : 0; 8047 }, p = function(t3) { 8048 return g(t3) === NodeFilter.FILTER_ACCEPT ? f(t3) : NodeFilter.FILTER_REJECT; 8049 }, g = function(t3) { 8050 return u(t3) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; 8051 }, f = function(t3) { 8052 return i2(t3.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; 8053 }, e3; 8054 }(); 8055 }.call(this), function() { 8056 var t2, n2, i2 = [].slice; 8057 t2 = e2.getDOMRange, n2 = e2.setDOMRange, e2.PointMapper = function() { 8058 function e3() { 8059 } 8060 return e3.prototype.createDOMRangeFromPoint = function(e4) { 8061 var i3, o2, r3, s2, a2, u, c, l2; 8062 if (c = e4.x, l2 = e4.y, document.caretPositionFromPoint) 8063 return a2 = document.caretPositionFromPoint(c, l2), r3 = a2.offsetNode, o2 = a2.offset, i3 = document.createRange(), i3.setStart(r3, o2), i3; 8064 if (document.caretRangeFromPoint) 8065 return document.caretRangeFromPoint(c, l2); 8066 if (document.body.createTextRange) { 8067 s2 = t2(); 8068 try { 8069 u = document.body.createTextRange(), u.moveToPoint(c, l2), u.select(); 8070 } catch (h2) { 8071 } 8072 return i3 = t2(), n2(s2), i3; 8073 } 8074 }, e3.prototype.getClientRectsForDOMRange = function(t3) { 8075 var e4, n3, o2; 8076 return n3 = i2.call(t3.getClientRects()), o2 = n3[0], e4 = n3[n3.length - 1], [o2, e4]; 8077 }, e3; 8078 }(); 8079 }.call(this), function() { 8080 var t2, n2 = function(t3, e3) { 8081 return function() { 8082 return t3.apply(e3, arguments); 8083 }; 8084 }, i2 = function(t3, e3) { 8085 function n3() { 8086 this.constructor = t3; 8087 } 8088 for (var i3 in e3) 8089 o2.call(e3, i3) && (t3[i3] = e3[i3]); 8090 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 8091 }, o2 = {}.hasOwnProperty, r3 = [].indexOf || function(t3) { 8092 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 8093 if (e3 in this && this[e3] === t3) 8094 return e3; 8095 return -1; 8096 }; 8097 t2 = e2.getDOMRange, e2.SelectionChangeObserver = function(e3) { 8098 function o3() { 8099 this.run = n2(this.run, this), this.update = n2(this.update, this), this.selectionManagers = []; 8100 } 8101 var s2; 8102 return i2(o3, e3), o3.prototype.start = function() { 8103 return this.started ? void 0 : (this.started = true, "onselectionchange" in document ? document.addEventListener("selectionchange", this.update, true) : this.run()); 8104 }, o3.prototype.stop = function() { 8105 return this.started ? (this.started = false, document.removeEventListener("selectionchange", this.update, true)) : void 0; 8106 }, o3.prototype.registerSelectionManager = function(t3) { 8107 return r3.call(this.selectionManagers, t3) < 0 ? (this.selectionManagers.push(t3), this.start()) : void 0; 8108 }, o3.prototype.unregisterSelectionManager = function(t3) { 8109 var e4; 8110 return this.selectionManagers = function() { 8111 var n3, i3, o4, r4; 8112 for (o4 = this.selectionManagers, r4 = [], n3 = 0, i3 = o4.length; i3 > n3; n3++) 8113 e4 = o4[n3], e4 !== t3 && r4.push(e4); 8114 return r4; 8115 }.call(this), this.selectionManagers.length === 0 ? this.stop() : void 0; 8116 }, o3.prototype.notifySelectionManagersOfSelectionChange = function() { 8117 var t3, e4, n3, i3, o4; 8118 for (n3 = this.selectionManagers, i3 = [], t3 = 0, e4 = n3.length; e4 > t3; t3++) 8119 o4 = n3[t3], i3.push(o4.selectionDidChange()); 8120 return i3; 8121 }, o3.prototype.update = function() { 8122 var e4; 8123 return e4 = t2(), s2(e4, this.domRange) ? void 0 : (this.domRange = e4, this.notifySelectionManagersOfSelectionChange()); 8124 }, o3.prototype.reset = function() { 8125 return this.domRange = null, this.update(); 8126 }, o3.prototype.run = function() { 8127 return this.started ? (this.update(), requestAnimationFrame(this.run)) : void 0; 8128 }, s2 = function(t3, e4) { 8129 return (t3 != null ? t3.startContainer : void 0) === (e4 != null ? e4.startContainer : void 0) && (t3 != null ? t3.startOffset : void 0) === (e4 != null ? e4.startOffset : void 0) && (t3 != null ? t3.endContainer : void 0) === (e4 != null ? e4.endContainer : void 0) && (t3 != null ? t3.endOffset : void 0) === (e4 != null ? e4.endOffset : void 0); 8130 }, o3; 8131 }(e2.BasicObject), e2.selectionChangeObserver == null && (e2.selectionChangeObserver = new e2.SelectionChangeObserver()); 8132 }.call(this), function() { 8133 var t2, n2, i2, o2, r3, s2, a2, u, c, l2, h2 = function(t3, e3) { 8134 return function() { 8135 return t3.apply(e3, arguments); 8136 }; 8137 }, p = function(t3, e3) { 8138 function n3() { 8139 this.constructor = t3; 8140 } 8141 for (var i3 in e3) 8142 d.call(e3, i3) && (t3[i3] = e3[i3]); 8143 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 8144 }, d = {}.hasOwnProperty; 8145 i2 = e2.getDOMSelection, n2 = e2.getDOMRange, l2 = e2.setDOMRange, t2 = e2.elementContainsNode, s2 = e2.nodeIsCursorTarget, r3 = e2.innerElementIsActive, o2 = e2.handleEvent, a2 = e2.normalizeRange, u = e2.rangeIsCollapsed, c = e2.rangesAreEqual, e2.SelectionManager = function(d2) { 8146 function f(t3) { 8147 this.element = t3, this.selectionDidChange = h2(this.selectionDidChange, this), this.didMouseDown = h2(this.didMouseDown, this), this.locationMapper = new e2.LocationMapper(this.element), this.pointMapper = new e2.PointMapper(), this.lockCount = 0, o2("mousedown", { onElement: this.element, withCallback: this.didMouseDown }); 8148 } 8149 return p(f, d2), f.prototype.getLocationRange = function(t3) { 8150 var e3, i3; 8151 return t3 == null && (t3 = {}), e3 = t3.strict === false ? this.createLocationRangeFromDOMRange(n2(), { strict: false }) : t3.ignoreLock ? this.currentLocationRange : (i3 = this.lockedLocationRange) != null ? i3 : this.currentLocationRange; 8152 }, f.prototype.setLocationRange = function(t3) { 8153 var e3; 8154 if (!this.lockedLocationRange) 8155 return t3 = a2(t3), (e3 = this.createDOMRangeFromLocationRange(t3)) ? (l2(e3), this.updateCurrentLocationRange(t3)) : void 0; 8156 }, f.prototype.setLocationRangeFromPointRange = function(t3) { 8157 var e3, n3; 8158 return t3 = a2(t3), n3 = this.getLocationAtPoint(t3[0]), e3 = this.getLocationAtPoint(t3[1]), this.setLocationRange([n3, e3]); 8159 }, f.prototype.getClientRectAtLocationRange = function(t3) { 8160 var e3; 8161 return (e3 = this.createDOMRangeFromLocationRange(t3)) ? this.getClientRectsForDOMRange(e3)[1] : void 0; 8162 }, f.prototype.locationIsCursorTarget = function(t3) { 8163 var e3, n3, i3; 8164 return i3 = this.findNodeAndOffsetFromLocation(t3), e3 = i3[0], n3 = i3[1], s2(e3); 8165 }, f.prototype.lock = function() { 8166 return this.lockCount++ === 0 ? (this.updateCurrentLocationRange(), this.lockedLocationRange = this.getLocationRange()) : void 0; 8167 }, f.prototype.unlock = function() { 8168 var t3; 8169 return --this.lockCount === 0 && (t3 = this.lockedLocationRange, this.lockedLocationRange = null, t3 != null) ? this.setLocationRange(t3) : void 0; 8170 }, f.prototype.clearSelection = function() { 8171 var t3; 8172 return (t3 = i2()) != null ? t3.removeAllRanges() : void 0; 8173 }, f.prototype.selectionIsCollapsed = function() { 8174 var t3; 8175 return ((t3 = n2()) != null ? t3.collapsed : void 0) === true; 8176 }, f.prototype.selectionIsExpanded = function() { 8177 return !this.selectionIsCollapsed(); 8178 }, f.prototype.createLocationRangeFromDOMRange = function(t3, e3) { 8179 var n3, i3; 8180 if (t3 != null && this.domRangeWithinElement(t3) && (i3 = this.findLocationFromContainerAndOffset(t3.startContainer, t3.startOffset, e3))) 8181 return t3.collapsed || (n3 = this.findLocationFromContainerAndOffset(t3.endContainer, t3.endOffset, e3)), a2([i3, n3]); 8182 }, f.proxyMethod("locationMapper.findLocationFromContainerAndOffset"), f.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"), f.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"), f.proxyMethod("pointMapper.createDOMRangeFromPoint"), f.proxyMethod("pointMapper.getClientRectsForDOMRange"), f.prototype.didMouseDown = function() { 8183 return this.pauseTemporarily(); 8184 }, f.prototype.pauseTemporarily = function() { 8185 var e3, n3, i3, r4; 8186 return this.paused = true, n3 = function(e4) { 8187 return function() { 8188 var n4, o3, s3; 8189 for (e4.paused = false, clearTimeout(r4), o3 = 0, s3 = i3.length; s3 > o3; o3++) 8190 n4 = i3[o3], n4.destroy(); 8191 return t2(document, e4.element) ? e4.selectionDidChange() : void 0; 8192 }; 8193 }(this), r4 = setTimeout(n3, 200), i3 = function() { 8194 var t3, i4, r5, s3; 8195 for (r5 = ["mousemove", "keydown"], s3 = [], t3 = 0, i4 = r5.length; i4 > t3; t3++) 8196 e3 = r5[t3], s3.push(o2(e3, { onElement: document, withCallback: n3 })); 8197 return s3; 8198 }(); 8199 }, f.prototype.selectionDidChange = function() { 8200 return this.paused || r3(this.element) ? void 0 : this.updateCurrentLocationRange(); 8201 }, f.prototype.updateCurrentLocationRange = function(t3) { 8202 var e3; 8203 return (t3 != null ? t3 : t3 = this.createLocationRangeFromDOMRange(n2())) && !c(t3, this.currentLocationRange) ? (this.currentLocationRange = t3, (e3 = this.delegate) != null && typeof e3.locationRangeDidChange == "function" ? e3.locationRangeDidChange(this.currentLocationRange.slice(0)) : void 0) : void 0; 8204 }, f.prototype.createDOMRangeFromLocationRange = function(t3) { 8205 var e3, n3, i3, o3; 8206 return i3 = this.findContainerAndOffsetFromLocation(t3[0]), n3 = u(t3) ? i3 : (o3 = this.findContainerAndOffsetFromLocation(t3[1])) != null ? o3 : i3, i3 != null && n3 != null ? (e3 = document.createRange(), e3.setStart.apply(e3, i3), e3.setEnd.apply(e3, n3), e3) : void 0; 8207 }, f.prototype.getLocationAtPoint = function(t3) { 8208 var e3, n3; 8209 return (e3 = this.createDOMRangeFromPoint(t3)) && (n3 = this.createLocationRangeFromDOMRange(e3)) != null ? n3[0] : void 0; 8210 }, f.prototype.domRangeWithinElement = function(e3) { 8211 return e3.collapsed ? t2(this.element, e3.startContainer) : t2(this.element, e3.startContainer) && t2(this.element, e3.endContainer); 8212 }, f; 8213 }(e2.BasicObject); 8214 }.call(this), function() { 8215 var t2, n2, i2, o2, r3 = function(t3, e3) { 8216 function n3() { 8217 this.constructor = t3; 8218 } 8219 for (var i3 in e3) 8220 s2.call(e3, i3) && (t3[i3] = e3[i3]); 8221 return n3.prototype = e3.prototype, t3.prototype = new n3(), t3.__super__ = e3.prototype, t3; 8222 }, s2 = {}.hasOwnProperty, a2 = [].slice; 8223 i2 = e2.rangeIsCollapsed, o2 = e2.rangesAreEqual, n2 = e2.objectsAreEqual, t2 = e2.getBlockConfig, e2.EditorController = function(s3) { 8224 function u(t3) { 8225 var n3, i3; 8226 this.editorElement = t3.editorElement, n3 = t3.document, i3 = t3.html, this.selectionManager = new e2.SelectionManager(this.editorElement), this.selectionManager.delegate = this, this.composition = new e2.Composition(), this.composition.delegate = this, this.attachmentManager = new e2.AttachmentManager(this.composition.getAttachments()), this.attachmentManager.delegate = this, this.inputController = new e2["Level" + e2.config.input.getLevel() + "InputController"](this.editorElement), this.inputController.delegate = this, this.inputController.responder = this.composition, this.compositionController = new e2.CompositionController(this.editorElement, this.composition), this.compositionController.delegate = this, this.toolbarController = new e2.ToolbarController(this.editorElement.toolbarElement), this.toolbarController.delegate = this, this.editor = new e2.Editor(this.composition, this.selectionManager, this.editorElement), n3 != null ? this.editor.loadDocument(n3) : this.editor.loadHTML(i3); 8227 } 8228 var c; 8229 return r3(u, s3), u.prototype.registerSelectionManager = function() { 8230 return e2.selectionChangeObserver.registerSelectionManager(this.selectionManager); 8231 }, u.prototype.unregisterSelectionManager = function() { 8232 return e2.selectionChangeObserver.unregisterSelectionManager(this.selectionManager); 8233 }, u.prototype.render = function() { 8234 return this.compositionController.render(); 8235 }, u.prototype.reparse = function() { 8236 return this.composition.replaceHTML(this.editorElement.innerHTML); 8237 }, u.prototype.compositionDidChangeDocument = function() { 8238 return this.notifyEditorElement("document-change"), this.handlingInput ? void 0 : this.render(); 8239 }, u.prototype.compositionDidChangeCurrentAttributes = function(t3) { 8240 return this.currentAttributes = t3, this.toolbarController.updateAttributes(this.currentAttributes), this.updateCurrentActions(), this.notifyEditorElement("attributes-change", { attributes: this.currentAttributes }); 8241 }, u.prototype.compositionDidPerformInsertionAtRange = function(t3) { 8242 return this.pasting ? this.pastedRange = t3 : void 0; 8243 }, u.prototype.compositionShouldAcceptFile = function(t3) { 8244 return this.notifyEditorElement("file-accept", { file: t3 }); 8245 }, u.prototype.compositionDidAddAttachment = function(t3) { 8246 var e3; 8247 return e3 = this.attachmentManager.manageAttachment(t3), this.notifyEditorElement("attachment-add", { attachment: e3 }); 8248 }, u.prototype.compositionDidEditAttachment = function(t3) { 8249 var e3; 8250 return this.compositionController.rerenderViewForObject(t3), e3 = this.attachmentManager.manageAttachment(t3), this.notifyEditorElement("attachment-edit", { attachment: e3 }), this.notifyEditorElement("change"); 8251 }, u.prototype.compositionDidChangeAttachmentPreviewURL = function(t3) { 8252 return this.compositionController.invalidateViewForObject(t3), this.notifyEditorElement("change"); 8253 }, u.prototype.compositionDidRemoveAttachment = function(t3) { 8254 var e3; 8255 return e3 = this.attachmentManager.unmanageAttachment(t3), this.notifyEditorElement("attachment-remove", { attachment: e3 }); 8256 }, u.prototype.compositionDidStartEditingAttachment = function(t3, e3) { 8257 return this.attachmentLocationRange = this.composition.document.getLocationRangeOfAttachment(t3), this.compositionController.installAttachmentEditorForAttachment(t3, e3), this.selectionManager.setLocationRange(this.attachmentLocationRange); 8258 }, u.prototype.compositionDidStopEditingAttachment = function() { 8259 return this.compositionController.uninstallAttachmentEditor(), this.attachmentLocationRange = null; 8260 }, u.prototype.compositionDidRequestChangingSelectionToLocationRange = function(t3) { 8261 return !this.loadingSnapshot || this.isFocused() ? (this.requestedLocationRange = t3, this.compositionRevisionWhenLocationRangeRequested = this.composition.revision, this.handlingInput ? void 0 : this.render()) : void 0; 8262 }, u.prototype.compositionWillLoadSnapshot = function() { 8263 return this.loadingSnapshot = true; 8264 }, u.prototype.compositionDidLoadSnapshot = function() { 8265 return this.compositionController.refreshViewCache(), this.render(), this.loadingSnapshot = false; 8266 }, u.prototype.getSelectionManager = function() { 8267 return this.selectionManager; 8268 }, u.proxyMethod("getSelectionManager().setLocationRange"), u.proxyMethod("getSelectionManager().getLocationRange"), u.prototype.attachmentManagerDidRequestRemovalOfAttachment = function(t3) { 8269 return this.removeAttachment(t3); 8270 }, u.prototype.compositionControllerWillSyncDocumentView = function() { 8271 return this.inputController.editorWillSyncDocumentView(), this.selectionManager.lock(), this.selectionManager.clearSelection(); 8272 }, u.prototype.compositionControllerDidSyncDocumentView = function() { 8273 return this.inputController.editorDidSyncDocumentView(), this.selectionManager.unlock(), this.updateCurrentActions(), this.notifyEditorElement("sync"); 8274 }, u.prototype.compositionControllerDidRender = function() { 8275 return this.requestedLocationRange != null && (this.compositionRevisionWhenLocationRangeRequested === this.composition.revision && this.selectionManager.setLocationRange(this.requestedLocationRange), this.requestedLocationRange = null, this.compositionRevisionWhenLocationRangeRequested = null), this.renderedCompositionRevision !== this.composition.revision && (this.runEditorFilters(), this.composition.updateCurrentAttributes(), this.notifyEditorElement("render")), this.renderedCompositionRevision = this.composition.revision; 8276 }, u.prototype.compositionControllerDidFocus = function() { 8277 return this.isFocusedInvisibly() && this.setLocationRange({ index: 0, offset: 0 }), this.toolbarController.hideDialog(), this.notifyEditorElement("focus"); 8278 }, u.prototype.compositionControllerDidBlur = function() { 8279 return this.notifyEditorElement("blur"); 8280 }, u.prototype.compositionControllerDidSelectAttachment = function(t3, e3) { 8281 return this.toolbarController.hideDialog(), this.composition.editAttachment(t3, e3); 8282 }, u.prototype.compositionControllerDidRequestDeselectingAttachment = function(t3) { 8283 var e3, n3; 8284 return e3 = (n3 = this.attachmentLocationRange) != null ? n3 : this.composition.document.getLocationRangeOfAttachment(t3), this.selectionManager.setLocationRange(e3[1]); 8285 }, u.prototype.compositionControllerWillUpdateAttachment = function(t3) { 8286 return this.editor.recordUndoEntry("Edit Attachment", { context: t3.id, consolidatable: true }); 8287 }, u.prototype.compositionControllerDidRequestRemovalOfAttachment = function(t3) { 8288 return this.removeAttachment(t3); 8289 }, u.prototype.inputControllerWillHandleInput = function() { 8290 return this.handlingInput = true, this.requestedRender = false; 8291 }, u.prototype.inputControllerDidRequestRender = function() { 8292 return this.requestedRender = true; 8293 }, u.prototype.inputControllerDidHandleInput = function() { 8294 return this.handlingInput = false, this.requestedRender ? (this.requestedRender = false, this.render()) : void 0; 8295 }, u.prototype.inputControllerDidAllowUnhandledInput = function() { 8296 return this.notifyEditorElement("change"); 8297 }, u.prototype.inputControllerDidRequestReparse = function() { 8298 return this.reparse(); 8299 }, u.prototype.inputControllerWillPerformTyping = function() { 8300 return this.recordTypingUndoEntry(); 8301 }, u.prototype.inputControllerWillPerformFormatting = function(t3) { 8302 return this.recordFormattingUndoEntry(t3); 8303 }, u.prototype.inputControllerWillCutText = function() { 8304 return this.editor.recordUndoEntry("Cut"); 8305 }, u.prototype.inputControllerWillPaste = function(t3) { 8306 return this.editor.recordUndoEntry("Paste"), this.pasting = true, this.notifyEditorElement("before-paste", { paste: t3 }); 8307 }, u.prototype.inputControllerDidPaste = function(t3) { 8308 return t3.range = this.pastedRange, this.pastedRange = null, this.pasting = null, this.notifyEditorElement("paste", { paste: t3 }); 8309 }, u.prototype.inputControllerWillMoveText = function() { 8310 return this.editor.recordUndoEntry("Move"); 8311 }, u.prototype.inputControllerWillAttachFiles = function() { 8312 return this.editor.recordUndoEntry("Drop Files"); 8313 }, u.prototype.inputControllerWillPerformUndo = function() { 8314 return this.editor.undo(); 8315 }, u.prototype.inputControllerWillPerformRedo = function() { 8316 return this.editor.redo(); 8317 }, u.prototype.inputControllerDidReceiveKeyboardCommand = function(t3) { 8318 return this.toolbarController.applyKeyboardCommand(t3); 8319 }, u.prototype.inputControllerDidStartDrag = function() { 8320 return this.locationRangeBeforeDrag = this.selectionManager.getLocationRange(); 8321 }, u.prototype.inputControllerDidReceiveDragOverPoint = function(t3) { 8322 return this.selectionManager.setLocationRangeFromPointRange(t3); 8323 }, u.prototype.inputControllerDidCancelDrag = function() { 8324 return this.selectionManager.setLocationRange(this.locationRangeBeforeDrag), this.locationRangeBeforeDrag = null; 8325 }, u.prototype.locationRangeDidChange = function(t3) { 8326 return this.composition.updateCurrentAttributes(), this.updateCurrentActions(), this.attachmentLocationRange && !o2(this.attachmentLocationRange, t3) && this.composition.stopEditingAttachment(), this.notifyEditorElement("selection-change"); 8327 }, u.prototype.toolbarDidClickButton = function() { 8328 return this.getLocationRange() ? void 0 : this.setLocationRange({ index: 0, offset: 0 }); 8329 }, u.prototype.toolbarDidInvokeAction = function(t3) { 8330 return this.invokeAction(t3); 8331 }, u.prototype.toolbarDidToggleAttribute = function(t3) { 8332 return this.recordFormattingUndoEntry(t3), this.composition.toggleCurrentAttribute(t3), this.render(), this.selectionFrozen ? void 0 : this.editorElement.focus(); 8333 }, u.prototype.toolbarDidUpdateAttribute = function(t3, e3) { 8334 return this.recordFormattingUndoEntry(t3), this.composition.setCurrentAttribute(t3, e3), this.render(), this.selectionFrozen ? void 0 : this.editorElement.focus(); 8335 }, u.prototype.toolbarDidRemoveAttribute = function(t3) { 8336 return this.recordFormattingUndoEntry(t3), this.composition.removeCurrentAttribute(t3), this.render(), this.selectionFrozen ? void 0 : this.editorElement.focus(); 8337 }, u.prototype.toolbarWillShowDialog = function() { 8338 return this.composition.expandSelectionForEditing(), this.freezeSelection(); 8339 }, u.prototype.toolbarDidShowDialog = function(t3) { 8340 return this.notifyEditorElement("toolbar-dialog-show", { dialogName: t3 }); 8341 }, u.prototype.toolbarDidHideDialog = function(t3) { 8342 return this.thawSelection(), this.editorElement.focus(), this.notifyEditorElement("toolbar-dialog-hide", { dialogName: t3 }); 8343 }, u.prototype.freezeSelection = function() { 8344 return this.selectionFrozen ? void 0 : (this.selectionManager.lock(), this.composition.freezeSelection(), this.selectionFrozen = true, this.render()); 8345 }, u.prototype.thawSelection = function() { 8346 return this.selectionFrozen ? (this.composition.thawSelection(), this.selectionManager.unlock(), this.selectionFrozen = false, this.render()) : void 0; 8347 }, u.prototype.actions = { undo: { test: function() { 8348 return this.editor.canUndo(); 8349 }, perform: function() { 8350 return this.editor.undo(); 8351 } }, redo: { test: function() { 8352 return this.editor.canRedo(); 8353 }, perform: function() { 8354 return this.editor.redo(); 8355 } }, link: { test: function() { 8356 return this.editor.canActivateAttribute("href"); 8357 } }, increaseNestingLevel: { test: function() { 8358 return this.editor.canIncreaseNestingLevel(); 8359 }, perform: function() { 8360 return this.editor.increaseNestingLevel() && this.render(); 8361 } }, decreaseNestingLevel: { test: function() { 8362 return this.editor.canDecreaseNestingLevel(); 8363 }, perform: function() { 8364 return this.editor.decreaseNestingLevel() && this.render(); 8365 } }, attachFiles: { test: function() { 8366 return true; 8367 }, perform: function() { 8368 return e2.config.input.pickFiles(this.editor.insertFiles); 8369 } } }, u.prototype.canInvokeAction = function(t3) { 8370 var e3, n3; 8371 return this.actionIsExternal(t3) ? true : !!((e3 = this.actions[t3]) != null && (n3 = e3.test) != null ? n3.call(this) : void 0); 8372 }, u.prototype.invokeAction = function(t3) { 8373 var e3, n3; 8374 return this.actionIsExternal(t3) ? this.notifyEditorElement("action-invoke", { actionName: t3 }) : (e3 = this.actions[t3]) != null && (n3 = e3.perform) != null ? n3.call(this) : void 0; 8375 }, u.prototype.actionIsExternal = function(t3) { 8376 return /^x-./.test(t3); 8377 }, u.prototype.getCurrentActions = function() { 8378 var t3, e3; 8379 e3 = {}; 8380 for (t3 in this.actions) 8381 e3[t3] = this.canInvokeAction(t3); 8382 return e3; 8383 }, u.prototype.updateCurrentActions = function() { 8384 var t3; 8385 return t3 = this.getCurrentActions(), n2(t3, this.currentActions) ? void 0 : (this.currentActions = t3, this.toolbarController.updateActions(this.currentActions), this.notifyEditorElement("actions-change", { actions: this.currentActions })); 8386 }, u.prototype.runEditorFilters = function() { 8387 var t3, e3, n3, i3, o3, r4, s4, a3; 8388 for (a3 = this.composition.getSnapshot(), o3 = this.editor.filters, n3 = 0, i3 = o3.length; i3 > n3; n3++) 8389 e3 = o3[n3], t3 = a3.document, s4 = a3.selectedRange, a3 = (r4 = e3.call(this.editor, a3)) != null ? r4 : {}, a3.document == null && (a3.document = t3), a3.selectedRange == null && (a3.selectedRange = s4); 8390 return c(a3, this.composition.getSnapshot()) ? void 0 : this.composition.loadSnapshot(a3); 8391 }, c = function(t3, e3) { 8392 return o2(t3.selectedRange, e3.selectedRange) && t3.document.isEqualTo(e3.document); 8393 }, u.prototype.updateInputElement = function() { 8394 var t3, n3; 8395 return t3 = this.compositionController.getSerializableElement(), n3 = e2.serializeToContentType(t3, "text/html"), this.editorElement.setInputElementValue(n3); 8396 }, u.prototype.notifyEditorElement = function(t3, e3) { 8397 switch (t3) { 8398 case "document-change": 8399 this.documentChangedSinceLastRender = true; 8400 break; 8401 case "render": 8402 this.documentChangedSinceLastRender && (this.documentChangedSinceLastRender = false, this.notifyEditorElement("change")); 8403 break; 8404 case "change": 8405 case "attachment-add": 8406 case "attachment-edit": 8407 case "attachment-remove": 8408 this.updateInputElement(); 8409 } 8410 return this.editorElement.notify(t3, e3); 8411 }, u.prototype.removeAttachment = function(t3) { 8412 return this.editor.recordUndoEntry("Delete Attachment"), this.composition.removeAttachment(t3), this.render(); 8413 }, u.prototype.recordFormattingUndoEntry = function(e3) { 8414 var n3, o3; 8415 return n3 = t2(e3), o3 = this.selectionManager.getLocationRange(), n3 || !i2(o3) ? this.editor.recordUndoEntry("Formatting", { context: this.getUndoContext(), consolidatable: true }) : void 0; 8416 }, u.prototype.recordTypingUndoEntry = function() { 8417 return this.editor.recordUndoEntry("Typing", { context: this.getUndoContext(this.currentAttributes), consolidatable: true }); 8418 }, u.prototype.getUndoContext = function() { 8419 var t3; 8420 return t3 = 1 <= arguments.length ? a2.call(arguments, 0) : [], [this.getLocationContext(), this.getTimeContext()].concat(a2.call(t3)); 8421 }, u.prototype.getLocationContext = function() { 8422 var t3; 8423 return t3 = this.selectionManager.getLocationRange(), i2(t3) ? t3[0].index : t3; 8424 }, u.prototype.getTimeContext = function() { 8425 return e2.config.undoInterval > 0 ? Math.floor(new Date().getTime() / e2.config.undoInterval) : 0; 8426 }, u.prototype.isFocused = function() { 8427 var t3; 8428 return this.editorElement === ((t3 = this.editorElement.ownerDocument) != null ? t3.activeElement : void 0); 8429 }, u.prototype.isFocusedInvisibly = function() { 8430 return this.isFocused() && !this.getLocationRange(); 8431 }, u; 8432 }(e2.Controller); 8433 }.call(this), function() { 8434 var t2, n2, i2, o2, r3, s2, a2, u = [].indexOf || function(t3) { 8435 for (var e3 = 0, n3 = this.length; n3 > e3; e3++) 8436 if (e3 in this && this[e3] === t3) 8437 return e3; 8438 return -1; 8439 }; 8440 n2 = e2.browser, s2 = e2.makeElement, a2 = e2.triggerEvent, o2 = e2.handleEvent, r3 = e2.handleEventOnce, i2 = e2.findClosestElementFromNode, t2 = e2.AttachmentView.attachmentSelector, e2.registerElement("trix-editor", function() { 8441 var c, l2, h2, p, d, f, g, m, v; 8442 return g = 0, l2 = function(t3) { 8443 return !document.querySelector(":focus") && t3.hasAttribute("autofocus") && document.querySelector("[autofocus]") === t3 ? t3.focus() : void 0; 8444 }, m = function(t3) { 8445 return t3.hasAttribute("contenteditable") ? void 0 : (t3.setAttribute("contenteditable", ""), r3("focus", { onElement: t3, withCallback: function() { 8446 return h2(t3); 8447 } })); 8448 }, h2 = function(t3) { 8449 return d(t3), v(t3); 8450 }, d = function(t3) { 8451 return (typeof document.queryCommandSupported == "function" ? document.queryCommandSupported("enableObjectResizing") : void 0) ? (document.execCommand("enableObjectResizing", false, false), o2("mscontrolselect", { onElement: t3, preventDefault: true })) : void 0; 8452 }, v = function() { 8453 var t3; 8454 return (typeof document.queryCommandSupported == "function" ? document.queryCommandSupported("DefaultParagraphSeparator") : void 0) && (t3 = e2.config.blockAttributes["default"].tagName, t3 === "div" || t3 === "p") ? document.execCommand("DefaultParagraphSeparator", false, t3) : void 0; 8455 }, c = function(t3) { 8456 return t3.hasAttribute("role") ? void 0 : t3.setAttribute("role", "textbox"); 8457 }, f = function(t3) { 8458 var e3; 8459 if (!t3.hasAttribute("aria-label") && !t3.hasAttribute("aria-labelledby")) 8460 return (e3 = function() { 8461 var e4, n3, i3; 8462 return i3 = function() { 8463 var n4, i4, o3, r4; 8464 for (o3 = t3.labels, r4 = [], n4 = 0, i4 = o3.length; i4 > n4; n4++) 8465 e4 = o3[n4], e4.contains(t3) || r4.push(e4.textContent); 8466 return r4; 8467 }(), (n3 = i3.join(" ")) ? t3.setAttribute("aria-label", n3) : t3.removeAttribute("aria-label"); 8468 })(), o2("focus", { onElement: t3, withCallback: e3 }); 8469 }, p = function() { 8470 return n2.forcesObjectResizing ? { display: "inline", width: "auto" } : { display: "inline-block", width: "1px" }; 8471 }(), { defaultCSS: "%t {\n display: block;\n}\n\n%t:empty:not(:focus)::before {\n content: attr(placeholder);\n color: graytext;\n cursor: text;\n pointer-events: none;\n}\n\n%t a[contenteditable=false] {\n cursor: text;\n}\n\n%t img {\n max-width: 100%;\n height: auto;\n}\n\n%t " + t2 + " figcaption textarea {\n resize: none;\n}\n\n%t " + t2 + " figcaption textarea.trix-autoresize-clone {\n position: absolute;\n left: -9999px;\n max-height: 0px;\n}\n\n%t " + t2 + " figcaption[data-trix-placeholder]:empty::before {\n content: attr(data-trix-placeholder);\n color: graytext;\n}\n\n%t [data-trix-cursor-target] {\n display: " + p.display + " !important;\n width: " + p.width + " !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n}\n\n%t [data-trix-cursor-target=left] {\n vertical-align: top !important;\n margin-left: -1px !important;\n}\n\n%t [data-trix-cursor-target=right] {\n vertical-align: bottom !important;\n margin-right: -1px !important;\n}", trixId: { get: function() { 8472 return this.hasAttribute("trix-id") ? this.getAttribute("trix-id") : (this.setAttribute("trix-id", ++g), this.trixId); 8473 } }, labels: { get: function() { 8474 var t3, e3, n3; 8475 return e3 = [], this.id && this.ownerDocument && e3.push.apply(e3, this.ownerDocument.querySelectorAll("label[for='" + this.id + "']")), (t3 = i2(this, { matchingSelector: "label" })) && ((n3 = t3.control) === this || n3 === null) && e3.push(t3), e3; 8476 } }, toolbarElement: { get: function() { 8477 var t3, e3, n3; 8478 return this.hasAttribute("toolbar") ? (e3 = this.ownerDocument) != null ? e3.getElementById(this.getAttribute("toolbar")) : void 0 : this.parentNode ? (n3 = "trix-toolbar-" + this.trixId, this.setAttribute("toolbar", n3), t3 = s2("trix-toolbar", { id: n3 }), this.parentNode.insertBefore(t3, this), t3) : void 0; 8479 } }, inputElement: { get: function() { 8480 var t3, e3, n3; 8481 return this.hasAttribute("input") ? (n3 = this.ownerDocument) != null ? n3.getElementById(this.getAttribute("input")) : void 0 : this.parentNode ? (e3 = "trix-input-" + this.trixId, this.setAttribute("input", e3), t3 = s2("input", { type: "hidden", id: e3 }), this.parentNode.insertBefore(t3, this.nextElementSibling), t3) : void 0; 8482 } }, editor: { get: function() { 8483 var t3; 8484 return (t3 = this.editorController) != null ? t3.editor : void 0; 8485 } }, name: { get: function() { 8486 var t3; 8487 return (t3 = this.inputElement) != null ? t3.name : void 0; 8488 } }, value: { get: function() { 8489 var t3; 8490 return (t3 = this.inputElement) != null ? t3.value : void 0; 8491 }, set: function(t3) { 8492 var e3; 8493 return this.defaultValue = t3, (e3 = this.editor) != null ? e3.loadHTML(this.defaultValue) : void 0; 8494 } }, notify: function(t3, e3) { 8495 return this.editorController ? a2("trix-" + t3, { onElement: this, attributes: e3 }) : void 0; 8496 }, setInputElementValue: function(t3) { 8497 var e3; 8498 return (e3 = this.inputElement) != null ? e3.value = t3 : void 0; 8499 }, initialize: function() { 8500 return this.hasAttribute("data-trix-internal") ? void 0 : (m(this), c(this), f(this)); 8501 }, connect: function() { 8502 return this.hasAttribute("data-trix-internal") ? void 0 : (this.editorController || (a2("trix-before-initialize", { onElement: this }), this.editorController = new e2.EditorController({ editorElement: this, html: this.defaultValue = this.value }), requestAnimationFrame(function(t3) { 8503 return function() { 8504 return a2("trix-initialize", { onElement: t3 }); 8505 }; 8506 }(this))), this.editorController.registerSelectionManager(), this.registerResetListener(), this.registerClickListener(), l2(this)); 8507 }, disconnect: function() { 8508 var t3; 8509 return (t3 = this.editorController) != null && t3.unregisterSelectionManager(), this.unregisterResetListener(), this.unregisterClickListener(); 8510 }, registerResetListener: function() { 8511 return this.resetListener = this.resetBubbled.bind(this), window.addEventListener("reset", this.resetListener, false); 8512 }, unregisterResetListener: function() { 8513 return window.removeEventListener("reset", this.resetListener, false); 8514 }, registerClickListener: function() { 8515 return this.clickListener = this.clickBubbled.bind(this), window.addEventListener("click", this.clickListener, false); 8516 }, unregisterClickListener: function() { 8517 return window.removeEventListener("click", this.clickListener, false); 8518 }, resetBubbled: function(t3) { 8519 var e3; 8520 if (!t3.defaultPrevented && t3.target === ((e3 = this.inputElement) != null ? e3.form : void 0)) 8521 return this.reset(); 8522 }, clickBubbled: function(t3) { 8523 var e3; 8524 if (!(t3.defaultPrevented || this.contains(t3.target) || !(e3 = i2(t3.target, { matchingSelector: "label" })) || u.call(this.labels, e3) < 0)) 8525 return this.focus(); 8526 }, reset: function() { 8527 return this.value = this.defaultValue; 8528 } }; 8529 }()); 8530 }.call(this), function() { 8531 }.call(this); 8532 }).call(this), typeof module5 == "object" && module5.exports ? module5.exports = e2 : typeof define == "function" && define.amd && define(e2); 8533 }.call(exports2); 8534 } 8535 }); 8536 8537
8537// src/confirm_email_modal.js 8538 var require_confirm_email_modal = __commonJS({ 8539 "src/confirm_email_modal.js"() { 8540 var createConfirmEmailModal = () => { 8541 var id = "confirm-modal-" + String(Math.random()).slice(2, -1); 8542 const element = document.querySelector("a[data-confirm-email-modal]"); 8543 var content = ` 8544 <div id="${id}" class="z-50 animated fadeIn fixed top-0 left-0 w-full h-full table" style="background-color: rgba(0, 0, 0, 0.8);"> 8545 <div class="table-cell align-middle"> 8546 <div class="bg-white mx-auto rounded shadow p-8 max-w-sm modal-body"> 8547 <div class="flex justify-end mb-4"> 8548 <button data-behavior="close" aria-label="Close modal""> 8549 <svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24"> 8550 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path> 8551 </svg> 8552 </button> 8553 </div> 8554 8555 <p>A message with a confirmation link has been sent to your email address. Please follow the link to activate your account before signing in.</p> 8556 8557 <div class="flex justify-center items-center flex-wrap mt-6"> 8558 <a href="#" class="btn btn-danger focus:outline-none" data-behavior="close">Ok, got it!</a> 8559 </div> 8560 8561 <div class="flex justify-center items-center flex-wrap mt-4"> 8562 <p><a class="block text-sm font-semibold mt-2" href="/users/confirmation/new">Resend Confirmation Email?</a></p> 8563 </div> 8564 <img height="1" width="1" style="border-style:none;" alt="" src="https://insight.adsrvr.org/track/pxl/?adv=myzr1dn&ct=0:yr1vge7&fmt=3"/> 8565 </div> 8566 </div> 8567 </div> 8568 `; 8569 element.insertAdjacentHTML("afterend", content); 8570 var modal = element.nextElementSibling; 8571 element.dataset.confirmModal = `#${id}`; 8572 document.addEventListener("keyup", (event) => { 8573 if (event.key === "Escape") { 8574 event.preventDefault(); 8575 element.removeAttribute("data-confirm-modal"); 8576 modal.remove(); 8577 } 8578 }); 8579 modal.addEventListener("click", (event) => { 8580 if (!modal.querySelector(".modal-body").contains(event.target)) { 8581 event.preventDefault(); 8582 element.removeAttribute("data-confirm-modal"); 8583 modal.remove(); 8584 } 8585 }); 8586 modal.querySelectorAll("[data-behavior='close']").forEach((el) => el.addEventListener("click", (event) => { 8587 event.preventDefault(); 8588 element.removeAttribute("data-confirm-modal"); 8589 modal.remove(); 8590 })); 8591 return modal; 8592 }; 8593 document.addEventListener("turbo:load", () => { 8594 var params = new URLSearchParams(window.location.search); 8595 var flash = document.querySelector(".notice.notice-info"); 8596 if (flash && params.get("modal")) { 8597 createConfirmEmailModal(); 8598 return false; 8599 } 8600 }); 8601 } 8602 }); 8603 8604
8604// src/direct_uploads.js 8605 var require_direct_uploads = __commonJS({ 8606 "src/direct_uploads.js"() { 8607 addEventListener("direct-upload:initialize", (event) => { 8608 const { target, detail } = event; 8609 const { id, file } = detail; 8610 target.insertAdjacentHTML("beforebegin", ` 8611 <div id="direct-upload-${id}" class="direct-upload direct-upload--pending"> 8612 <div id="direct-upload-progress-${id}" class="direct-upload__progress" style="width: 0%"></div> 8613 <span class="direct-upload__filename">${file.name}</span> 8614 </div> 8615 `); 8616 }); 8617 addEventListener("direct-upload:start", (event) => { 8618 const { id } = event.detail; 8619 const element = document.getElementById(`direct-upload-${id}`); 8620 element.classList.remove("direct-upload--pending"); 8621 }); 8622 addEventListener("direct-upload:progress", (event) => { 8623 const { id, progress } = event.detail; 8624 const progressElement = document.getElementById(`direct-upload-progress-${id}`); 8625 progressElement.style.width = `${progress}%`; 8626 }); 8627 addEventListener("direct-upload:error", (event) => { 8628 event.preventDefault(); 8629 const { id, error: error2 } = event.detail; 8630 const element = document.getElementById(`direct-upload-${id}`); 8631 element.classList.add("direct-upload--error"); 8632 element.setAttribute("title", error2); 8633 }); 8634 addEventListener("direct-upload:end", (event) => { 8635 const { id } = event.detail; 8636 const element = document.getElementById(`direct-upload-${id}`); 8637 element.classList.add("direct-upload--complete"); 8638 }); 8639 } 8640 }); 8641 8642
8642// src/lazysrc.js 8643 var require_lazysrc = __commonJS({ 8644 "src/lazysrc.js"() { 8645 document.addEventListener("turbo:load", () => { 8646 document.querySelectorAll("[data-src]").forEach((element) => { 8647 element.setAttribute("src", element.getAttribute("data-src")); 8648 }); 8649 }); 8650 } 8651 }); 8652 8653
vendor: 37,340 bytes, lines 8653-9909
8653// ../../node_modules/jstz/dist/jstz.js 8654 var require_jstz = __commonJS({ 8655 "../../node_modules/jstz/dist/jstz.js"(exports2, module5) { 8656 (function(root) { 8657 var jstz2 = function() { 8658 "use strict"; 8659 var HEMISPHERE_SOUTH = "s", consts = { 8660 DAY: 864e5, 8661 HOUR: 36e5, 8662 MINUTE: 6e4, 8663 SECOND: 1e3, 8664 BASELINE_YEAR: 2014, 8665 MAX_SCORE: 864e6, 8666 AMBIGUITIES: { 8667 "America/Denver": ["America/Mazatlan"], 8668 "Europe/London": ["Africa/Casablanca"], 8669 "America/Chicago": ["America/Mexico_City"], 8670 "America/Asuncion": ["America/Campo_Grande", "America/Santiago"], 8671 "America/Montevideo": ["America/Sao_Paulo", "America/Santiago"], 8672 "Asia/Beirut": ["Asia/Amman", "Asia/Jerusalem", "Europe/Helsinki", "Asia/Damascus", "Africa/Cairo", "Asia/Gaza", "Europe/Minsk"], 8673 "Pacific/Auckland": ["Pacific/Fiji"], 8674 "America/Los_Angeles": ["America/Santa_Isabel"], 8675 "America/New_York": ["America/Havana"], 8676 "America/Halifax": ["America/Goose_Bay"], 8677 "America/Godthab": ["America/Miquelon"], 8678 "Asia/Dubai": ["Asia/Yerevan"], 8679 "Asia/Jakarta": ["Asia/Krasnoyarsk"], 8680 "Asia/Shanghai": ["Asia/Irkutsk", "Australia/Perth"], 8681 "Australia/Sydney": ["Australia/Lord_Howe"], 8682 "Asia/Tokyo": ["Asia/Yakutsk"], 8683 "Asia/Dhaka": ["Asia/Omsk"], 8684 "Asia/Baku": ["Asia/Yerevan"], 8685 "Australia/Brisbane": ["Asia/Vladivostok"], 8686 "Pacific/Noumea": ["Asia/Vladivostok"], 8687 "Pacific/Majuro": ["Asia/Kamchatka", "Pacific/Fiji"], 8688 "Pacific/Tongatapu": ["Pacific/Apia"], 8689 "Asia/Baghdad": ["Europe/Minsk", "Europe/Moscow"], 8690 "Asia/Karachi": ["Asia/Yekaterinburg"], 8691 "Africa/Johannesburg": ["Asia/Gaza", "Africa/Cairo"] 8692 } 8693 }, get_date_offset = function get_date_offset2(date) { 8694 var offset2 = -date.getTimezoneOffset(); 8695 return offset2 !== null ? offset2 : 0; 8696 }, lookup_key = function lookup_key2() { 8697 var january_offset = get_date_offset(new Date(consts.BASELINE_YEAR, 0, 2)), june_offset = get_date_offset(new Date(consts.BASELINE_YEAR, 5, 2)), diff = january_offset - june_offset; 8698 if (diff < 0) { 8699 return january_offset + ",1"; 8700 } else if (diff > 0) { 8701 return june_offset + ",1," + HEMISPHERE_SOUTH; 8702 } 8703 return january_offset + ",0"; 8704 }, get_from_internationalization_api = function get_from_internationalization_api2() { 8705 var format2, timezone; 8706 if (typeof Intl === "undefined" || typeof Intl.DateTimeFormat === "undefined") { 8707 return; 8708 } 8709 format2 = Intl.DateTimeFormat(); 8710 if (typeof format2 === "undefined" || typeof format2.resolvedOptions === "undefined") { 8711 return; 8712 } 8713 timezone = format2.resolvedOptions().timeZone; 8714 if (timezone && (timezone.indexOf("/") > -1 || timezone === "UTC") && timezone.indexOf("Etc") != 0) { 8715 return timezone; 8716 } 8717 }, dst_dates = function dst_dates2(year) { 8718 var yearstart = new Date(year, 0, 1, 0, 0, 1, 0).getTime(); 8719 var yearend = new Date(year, 12, 31, 23, 59, 59).getTime(); 8720 var current = yearstart; 8721 var offset2 = new Date(current).getTimezoneOffset(); 8722 var dst_start = null; 8723 var dst_end = null; 8724 while (current < yearend - 864e5) { 8725 var dateToCheck = new Date(current); 8726 var dateToCheckOffset = dateToCheck.getTimezoneOffset(); 8727 if (dateToCheckOffset !== offset2) { 8728 if (dateToCheckOffset < offset2) { 8729 dst_start = dateToCheck; 8730 } 8731 if (dateToCheckOffset > offset2) { 8732 dst_end = dateToCheck; 8733 } 8734 offset2 = dateToCheckOffset; 8735 } 8736 current += 864e5; 8737 } 8738 if (dst_start && dst_end) { 8739 return { 8740 s: find_dst_fold(dst_start).getTime(), 8741 e: find_dst_fold(dst_end).getTime() 8742 }; 8743 } 8744 return false; 8745 }, find_dst_fold = function find_dst_fold2(a_date, padding, iterator) { 8746 if (typeof padding === "undefined") { 8747 padding = consts.DAY; 8748 iterator = consts.HOUR; 8749 } 8750 var date_start = new Date(a_date.getTime() - padding).getTime(); 8751 var date_end = a_date.getTime() + padding; 8752 var offset2 = new Date(date_start).getTimezoneOffset(); 8753 var current = date_start; 8754 var dst_change = null; 8755 while (current < date_end - iterator) { 8756 var dateToCheck = new Date(current); 8757 var dateToCheckOffset = dateToCheck.getTimezoneOffset(); 8758 if (dateToCheckOffset !== offset2) { 8759 dst_change = dateToCheck; 8760 break; 8761 } 8762 current += iterator; 8763 } 8764 if (padding === consts.DAY) { 8765 return find_dst_fold2(dst_change, consts.HOUR, consts.MINUTE); 8766 } 8767 if (padding === consts.HOUR) { 8768 return find_dst_fold2(dst_change, consts.MINUTE, consts.SECOND); 8769 } 8770 return dst_change; 8771 }, windows7_adaptations = function windows7_adaptions(rule_list, preliminary_timezone, score, sample) { 8772 if (score !== "N/A") { 8773 return score; 8774 } 8775 if (preliminary_timezone === "Asia/Beirut") { 8776 if (sample.name === "Africa/Cairo") { 8777 if (rule_list[6].s === 13983768e5 && rule_list[6].e === 14116788e5) { 8778 return 0; 8779 } 8780 } 8781 if (sample.name === "Asia/Jerusalem") { 8782 if (rule_list[6].s === 13959648e5 && rule_list[6].e === 14118588e5) { 8783 return 0; 8784 } 8785 } 8786 } else if (preliminary_timezone === "America/Santiago") { 8787 if (sample.name === "America/Asuncion") { 8788 if (rule_list[6].s === 14124816e5 && rule_list[6].e === 1397358e6) { 8789 return 0; 8790 } 8791 } 8792 if (sample.name === "America/Campo_Grande") { 8793 if (rule_list[6].s === 14136912e5 && rule_list[6].e === 13925196e5) { 8794 return 0; 8795 } 8796 } 8797 } else if (preliminary_timezone === "America/Montevideo") { 8798 if (sample.name === "America/Sao_Paulo") { 8799 if (rule_list[6].s === 14136876e5 && rule_list[6].e === 1392516e6) { 8800 return 0; 8801 } 8802 } 8803 } else if (preliminary_timezone === "Pacific/Auckland") { 8804 if (sample.name === "Pacific/Fiji") { 8805 if (rule_list[6].s === 14142456e5 && rule_list[6].e === 13961016e5) { 8806 return 0; 8807 } 8808 } 8809 } 8810 return score; 8811 }, best_dst_match = function best_dst_match2(rule_list, preliminary_timezone) { 8812 var score_sample = function score_sample2(sample2) { 8813 var score2 = 0; 8814 for (var j2 = 0; j2 < rule_list.length; j2++) { 8815 if (!!sample2.rules[j2] && !!rule_list[j2]) { 8816 if (rule_list[j2].s >= sample2.rules[j2].s && rule_list[j2].e <= sample2.rules[j2].e) { 8817 score2 = 0; 8818 score2 += Math.abs(rule_list[j2].s - sample2.rules[j2].s); 8819 score2 += Math.abs(sample2.rules[j2].e - rule_list[j2].e); 8820 } else { 8821 score2 = "N/A"; 8822 break; 8823 } 8824 if (score2 > consts.MAX_SCORE) { 8825 score2 = "N/A"; 8826 break; 8827 } 8828 } 8829 } 8830 score2 = windows7_adaptations(rule_list, preliminary_timezone, score2, sample2); 8831 return score2; 8832 }; 8833 var scoreboard = {}; 8834 var dst_zones = jstz2.olson.dst_rules.zones; 8835 var dst_zones_length = dst_zones.length; 8836 var ambiguities = consts.AMBIGUITIES[preliminary_timezone]; 8837 for (var i2 = 0; i2 < dst_zones_length; i2++) { 8838 var sample = dst_zones[i2]; 8839 var score = score_sample(dst_zones[i2]); 8840 if (score !== "N/A") { 8841 scoreboard[sample.name] = score; 8842 } 8843 } 8844 for (var tz in scoreboard) { 8845 if (scoreboard.hasOwnProperty(tz)) { 8846 for (var j = 0; j < ambiguities.length; j++) { 8847 if (ambiguities[j] === tz) { 8848 return tz; 8849 } 8850 } 8851 } 8852 } 8853 return preliminary_timezone; 8854 }, get_by_dst = function get_by_dst2(preliminary_timezone) { 8855 var get_rules = function get_rules2() { 8856 var rule_list = []; 8857 for (var i2 = 0; i2 < jstz2.olson.dst_rules.years.length; i2++) { 8858 var year_rules = dst_dates(jstz2.olson.dst_rules.years[i2]); 8859 rule_list.push(year_rules); 8860 } 8861 return rule_list; 8862 }; 8863 var check_has_dst = function check_has_dst2(rules2) { 8864 for (var i2 = 0; i2 < rules2.length; i2++) { 8865 if (rules2[i2] !== false) { 8866 return true; 8867 } 8868 } 8869 return false; 8870 }; 8871 var rules = get_rules(); 8872 var has_dst = check_has_dst(rules); 8873 if (has_dst) { 8874 return best_dst_match(rules, preliminary_timezone); 8875 } 8876 return preliminary_timezone; 8877 }, determine = function determine2() { 8878 var preliminary_tz = get_from_internationalization_api(); 8879 if (!preliminary_tz) { 8880 preliminary_tz = jstz2.olson.timezones[lookup_key()]; 8881 if (typeof consts.AMBIGUITIES[preliminary_tz] !== "undefined") { 8882 preliminary_tz = get_by_dst(preliminary_tz); 8883 } 8884 } 8885 return { 8886 name: function() { 8887 return preliminary_tz; 8888 }, 8889 stdTimezoneOffset: function() { 8890 return -lookup_key().split(",")[0]; 8891 }, 8892 timezoneOffset: function() { 8893 return -get_date_offset(new Date()); 8894 } 8895 }; 8896 }; 8897 return { 8898 determine 8899 }; 8900 }(); 8901 jstz2.olson = jstz2.olson || {}; 8902 jstz2.olson.timezones = { 8903 "-720,0": "Etc/GMT+12", 8904 "-660,0": "Pacific/Pago_Pago", 8905 "-660,1,s": "Pacific/Apia", 8906 "-600,1": "America/Adak", 8907 "-600,0": "Pacific/Honolulu", 8908 "-570,0": "Pacific/Marquesas", 8909 "-540,0": "Pacific/Gambier", 8910 "-540,1": "America/Anchorage", 8911 "-480,1": "America/Los_Angeles", 8912 "-480,0": "Pacific/Pitcairn", 8913 "-420,0": "America/Phoenix", 8914 "-420,1": "America/Denver", 8915 "-360,0": "America/Guatemala", 8916 "-360,1": "America/Chicago", 8917 "-360,1,s": "Pacific/Easter", 8918 "-300,0": "America/Bogota", 8919 "-300,1": "America/New_York", 8920 "-270,0": "America/Caracas", 8921 "-240,1": "America/Halifax", 8922 "-240,0": "America/Santo_Domingo", 8923 "-240,1,s": "America/Asuncion", 8924 "-210,1": "America/St_Johns", 8925 "-180,1": "America/Godthab", 8926 "-180,0": "America/Argentina/Buenos_Aires", 8927 "-180,1,s": "America/Montevideo", 8928 "-120,0": "America/Noronha", 8929 "-120,1": "America/Noronha", 8930 "-60,1": "Atlantic/Azores", 8931 "-60,0": "Atlantic/Cape_Verde", 8932 "0,0": "UTC", 8933 "0,1": "Europe/London", 8934 "60,1": "Europe/Berlin", 8935 "60,0": "Africa/Lagos", 8936 "60,1,s": "Africa/Windhoek", 8937 "120,1": "Asia/Beirut", 8938 "120,0": "Africa/Johannesburg", 8939 "180,0": "Asia/Baghdad", 8940 "180,1": "Europe/Moscow", 8941 "210,1": "Asia/Tehran", 8942 "240,0": "Asia/Dubai", 8943 "240,1": "Asia/Baku", 8944 "270,0": "Asia/Kabul", 8945 "300,1": "Asia/Yekaterinburg", 8946 "300,0": "Asia/Karachi", 8947 "330,0": "Asia/Kolkata", 8948 "345,0": "Asia/Kathmandu", 8949 "360,0": "Asia/Dhaka", 8950 "360,1": "Asia/Omsk", 8951 "390,0": "Asia/Rangoon", 8952 "420,1": "Asia/Krasnoyarsk", 8953 "420,0": "Asia/Jakarta", 8954 "480,0": "Asia/Shanghai", 8955 "480,1": "Asia/Irkutsk", 8956 "525,0": "Australia/Eucla", 8957 "525,1,s": "Australia/Eucla", 8958 "540,1": "Asia/Yakutsk", 8959 "540,0": "Asia/Tokyo", 8960 "570,0": "Australia/Darwin", 8961 "570,1,s": "Australia/Adelaide", 8962 "600,0": "Australia/Brisbane", 8963 "600,1": "Asia/Vladivostok", 8964 "600,1,s": "Australia/Sydney", 8965 "630,1,s": "Australia/Lord_Howe", 8966 "660,1": "Asia/Kamchatka", 8967 "660,0": "Pacific/Noumea", 8968 "690,0": "Pacific/Norfolk", 8969 "720,1,s": "Pacific/Auckland", 8970 "720,0": "Pacific/Majuro", 8971 "765,1,s": "Pacific/Chatham", 8972 "780,0": "Pacific/Tongatapu", 8973 "780,1,s": "Pacific/Apia", 8974 "840,0": "Pacific/Kiritimati" 8975 }; 8976 jstz2.olson.dst_rules = { 8977 "years": [ 8978 2008, 8979 2009, 8980 2010, 8981 2011, 8982 2012, 8983 2013, 8984 2014 8985 ], 8986 "zones": [ 8987 { 8988 "name": "Africa/Cairo", 8989 "rules": [ 8990 { 8991 "e": 12199572e5, 8992 "s": 12090744e5 8993 }, 8994 { 8995 "e": 1250802e6, 8996 "s": 1240524e6 8997 }, 8998 { 8999 "e": 12858804e5, 9000 "s": 12840696e5 9001 }, 9002 false, 9003 false, 9004 false, 9005 { 9006 "e": 14116788e5, 9007 "s": 1406844e6 9008 } 9009 ] 9010 }, 9011 { 9012 "name": "Africa/Casablanca", 9013 "rules": [ 9014 { 9015 "e": 12202236e5, 9016 "s": 12122784e5 9017 }, 9018 { 9019 "e": 12508092e5, 9020 "s": 12438144e5 9021 }, 9022 { 9023 "e": 1281222e6, 9024 "s": 12727584e5 9025 }, 9026 { 9027 "e": 13120668e5, 9028 "s": 13017888e5 9029 }, 9030 { 9031 "e": 13489704e5, 9032 "s": 1345428e6 9033 }, 9034 { 9035 "e": 13828392e5, 9036 "s": 13761e8 9037 }, 9038 { 9039 "e": 14142888e5, 9040 "s": 14069448e5 9041 } 9042 ] 9043 }, 9044 { 9045 "name": "America/Asuncion", 9046 "rules": [ 9047 { 9048 "e": 12050316e5, 9049 "s": 12243888e5 9050 }, 9051 { 9052 "e": 12364812e5, 9053 "s": 12558384e5 9054 }, 9055 { 9056 "e": 12709548e5, 9057 "s": 12860784e5 9058 }, 9059 { 9060 "e": 13024044e5, 9061 "s": 1317528e6 9062 }, 9063 { 9064 "e": 1333854e6, 9065 "s": 13495824e5 9066 }, 9067 { 9068 "e": 1364094e6, 9069 "s": 1381032e6 9070 }, 9071 { 9072 "e": 13955436e5, 9073 "s": 14124816e5 9074 } 9075 ] 9076 }, 9077 { 9078 "name": "America/Campo_Grande", 9079 "rules": [ 9080 { 9081 "e": 12032172e5, 9082 "s": 12243888e5 9083 }, 9084 { 9085 "e": 12346668e5, 9086 "s": 12558384e5 9087 }, 9088 { 9089 "e": 12667212e5, 9090 "s": 1287288e6 9091 }, 9092 { 9093 "e": 12981708e5, 9094 "s": 13187376e5 9095 }, 9096 { 9097 "e": 13302252e5, 9098 "s": 1350792e6 9099 }, 9100 { 9101 "e": 136107e7, 9102 "s": 13822416e5 9103 }, 9104 { 9105 "e": 13925196e5, 9106 "s": 14136912e5 9107 } 9108 ] 9109 }, 9110 { 9111 "name": "America/Goose_Bay", 9112 "rules": [ 9113 { 9114 "e": 122559486e4, 9115 "s": 120503526e4 9116 }, 9117 { 9118 "e": 125704446e4, 9119 "s": 123648486e4 9120 }, 9121 { 9122 "e": 128909886e4, 9123 "s": 126853926e4 9124 }, 9125 { 9126 "e": 13205556e5, 9127 "s": 129998886e4 9128 }, 9129 { 9130 "e": 13520052e5, 9131 "s": 13314456e5 9132 }, 9133 { 9134 "e": 13834548e5, 9135 "s": 13628952e5 9136 }, 9137 { 9138 "e": 14149044e5, 9139 "s": 13943448e5 9140 } 9141 ] 9142 }, 9143 { 9144 "name": "America/Havana", 9145 "rules": [ 9146 { 9147 "e": 12249972e5, 9148 "s": 12056436e5 9149 }, 9150 { 9151 "e": 12564468e5, 9152 "s": 12364884e5 9153 }, 9154 { 9155 "e": 12885012e5, 9156 "s": 12685428e5 9157 }, 9158 { 9159 "e": 13211604e5, 9160 "s": 13005972e5 9161 }, 9162 { 9163 "e": 13520052e5, 9164 "s": 13332564e5 9165 }, 9166 { 9167 "e": 13834548e5, 9168 "s": 13628916e5 9169 }, 9170 { 9171 "e": 14149044e5, 9172 "s": 13943412e5 9173 } 9174 ] 9175 }, 9176 { 9177 "name": "America/Mazatlan", 9178 "rules": [ 9179 { 9180 "e": 1225008e6, 9181 "s": 12074724e5 9182 }, 9183 { 9184 "e": 12564576e5, 9185 "s": 1238922e6 9186 }, 9187 { 9188 "e": 1288512e6, 9189 "s": 12703716e5 9190 }, 9191 { 9192 "e": 13199616e5, 9193 "s": 13018212e5 9194 }, 9195 { 9196 "e": 13514112e5, 9197 "s": 13332708e5 9198 }, 9199 { 9200 "e": 13828608e5, 9201 "s": 13653252e5 9202 }, 9203 { 9204 "e": 14143104e5, 9205 "s": 13967748e5 9206 } 9207 ] 9208 }, 9209 { 9210 "name": "America/Mexico_City", 9211 "rules": [ 9212 { 9213 "e": 12250044e5, 9214 "s": 12074688e5 9215 }, 9216 { 9217 "e": 1256454e6, 9218 "s": 12389184e5 9219 }, 9220 { 9221 "e": 12885084e5, 9222 "s": 1270368e6 9223 }, 9224 { 9225 "e": 1319958e6, 9226 "s": 13018176e5 9227 }, 9228 { 9229 "e": 13514076e5, 9230 "s": 13332672e5 9231 }, 9232 { 9233 "e": 13828572e5, 9234 "s": 13653216e5 9235 }, 9236 { 9237 "e": 14143068e5, 9238 "s": 13967712e5 9239 } 9240 ] 9241 }, 9242 { 9243 "name": "America/Miquelon", 9244 "rules": [ 9245 { 9246 "e": 12255984e5, 9247 "s": 12050388e5 9248 }, 9249 { 9250 "e": 1257048e6, 9251 "s": 12364884e5 9252 }, 9253 { 9254 "e": 12891024e5, 9255 "s": 12685428e5 9256 }, 9257 { 9258 "e": 1320552e6, 9259 "s": 12999924e5 9260 }, 9261 { 9262 "e": 13520016e5, 9263 "s": 1331442e6 9264 }, 9265 { 9266 "e": 13834512e5, 9267 "s": 13628916e5 9268 }, 9269 { 9270 "e": 14149008e5, 9271 "s": 13943412e5 9272 } 9273 ] 9274 }, 9275 { 9276 "name": "America/Santa_Isabel", 9277 "rules": [ 9278 { 9279 "e": 12250116e5, 9280 "s": 1207476e6 9281 }, 9282 { 9283 "e": 12564612e5, 9284 "s": 12389256e5 9285 }, 9286 { 9287 "e": 12885156e5, 9288 "s": 12703752e5 9289 }, 9290 { 9291 "e": 13199652e5, 9292 "s": 13018248e5 9293 }, 9294 { 9295 "e": 13514148e5, 9296 "s": 13332744e5 9297 }, 9298 { 9299 "e": 13828644e5, 9300 "s": 13653288e5 9301 }, 9302 { 9303 "e": 1414314e6, 9304 "s": 13967784e5 9305 } 9306 ] 9307 }, 9308 { 9309 "name": "America/Santiago", 9310 "rules": [ 9311 { 9312 "e": 1206846e6, 9313 "s": 1223784e6 9314 }, 9315 { 9316 "e": 1237086e6, 9317 "s": 12552336e5 9318 }, 9319 { 9320 "e": 127035e7, 9321 "s": 12866832e5 9322 }, 9323 { 9324 "e": 13048236e5, 9325 "s": 13138992e5 9326 }, 9327 { 9328 "e": 13356684e5, 9329 "s": 13465584e5 9330 }, 9331 { 9332 "e": 1367118e6, 9333 "s": 13786128e5 9334 }, 9335 { 9336 "e": 13985676e5, 9337 "s": 14100624e5 9338 } 9339 ] 9340 }, 9341 { 9342 "name": "America/Sao_Paulo", 9343 "rules": [ 9344 { 9345 "e": 12032136e5, 9346 "s": 12243852e5 9347 }, 9348 { 9349 "e": 12346632e5, 9350 "s": 12558348e5 9351 }, 9352 { 9353 "e": 12667176e5, 9354 "s": 12872844e5 9355 }, 9356 { 9357 "e": 12981672e5, 9358 "s": 1318734e6 9359 }, 9360 { 9361 "e": 13302216e5, 9362 "s": 13507884e5 9363 }, 9364 { 9365 "e": 13610664e5, 9366 "s": 1382238e6 9367 }, 9368 { 9369 "e": 1392516e6, 9370 "s": 14136876e5 9371 } 9372 ] 9373 }, 9374 { 9375 "name": "Asia/Amman", 9376 "rules": [ 9377 { 9378 "e": 1225404e6, 9379 "s": 12066552e5 9380 }, 9381 { 9382 "e": 12568536e5, 9383 "s": 12381048e5 9384 }, 9385 { 9386 "e": 12883032e5, 9387 "s": 12695544e5 9388 }, 9389 { 9390 "e": 13197528e5, 9391 "s": 13016088e5 9392 }, 9393 false, 9394 false, 9395 { 9396 "e": 14147064e5, 9397 "s": 13959576e5 9398 } 9399 ] 9400 }, 9401 { 9402 "name": "Asia/Damascus", 9403 "rules": [ 9404 { 9405 "e": 12254868e5, 9406 "s": 120726e7 9407 }, 9408 { 9409 "e": 125685e7, 9410 "s": 12381048e5 9411 }, 9412 { 9413 "e": 12882996e5, 9414 "s": 12701592e5 9415 }, 9416 { 9417 "e": 13197492e5, 9418 "s": 13016088e5 9419 }, 9420 { 9421 "e": 13511988e5, 9422 "s": 13330584e5 9423 }, 9424 { 9425 "e": 13826484e5, 9426 "s": 1364508e6 9427 }, 9428 { 9429 "e": 14147028e5, 9430 "s": 13959576e5 9431 } 9432 ] 9433 }, 9434 { 9435 "name": "Asia/Dubai", 9436 "rules": [ 9437 false, 9438 false, 9439 false, 9440 false, 9441 false, 9442 false, 9443 false 9444 ] 9445 }, 9446 { 9447 "name": "Asia/Gaza", 9448 "rules": [ 9449 { 9450 "e": 12199572e5, 9451 "s": 12066552e5 9452 }, 9453 { 9454 "e": 12520152e5, 9455 "s": 12381048e5 9456 }, 9457 { 9458 "e": 1281474e6, 9459 "s": 126964086e4 9460 }, 9461 { 9462 "e": 1312146e6, 9463 "s": 130160886e4 9464 }, 9465 { 9466 "e": 13481784e5, 9467 "s": 13330584e5 9468 }, 9469 { 9470 "e": 13802292e5, 9471 "s": 1364508e6 9472 }, 9473 { 9474 "e": 1414098e6, 9475 "s": 13959576e5 9476 } 9477 ] 9478 }, 9479 { 9480 "name": "Asia/Irkutsk", 9481 "rules": [ 9482 { 9483 "e": 12249576e5, 9484 "s": 12068136e5 9485 }, 9486 { 9487 "e": 12564072e5, 9488 "s": 12382632e5 9489 }, 9490 { 9491 "e": 12884616e5, 9492 "s": 12697128e5 9493 }, 9494 false, 9495 false, 9496 false, 9497 false 9498 ] 9499 }, 9500 { 9501 "name": "Asia/Jerusalem", 9502 "rules": [ 9503 { 9504 "e": 12231612e5, 9505 "s": 12066624e5 9506 }, 9507 { 9508 "e": 1254006e6, 9509 "s": 1238112e6 9510 }, 9511 { 9512 "e": 1284246e6, 9513 "s": 12695616e5 9514 }, 9515 { 9516 "e": 131751e7, 9517 "s": 1301616e6 9518 }, 9519 { 9520 "e": 13483548e5, 9521 "s": 13330656e5 9522 }, 9523 { 9524 "e": 13828284e5, 9525 "s": 13645152e5 9526 }, 9527 { 9528 "e": 1414278e6, 9529 "s": 13959648e5 9530 } 9531 ] 9532 }, 9533 { 9534 "name": "Asia/Kamchatka", 9535 "rules": [ 9536 { 9537 "e": 12249432e5, 9538 "s": 12067992e5 9539 }, 9540 { 9541 "e": 12563928e5, 9542 "s": 12382488e5 9543 }, 9544 { 9545 "e": 12884508e5, 9546 "s": 12696984e5 9547 }, 9548 false, 9549 false, 9550 false, 9551 false 9552 ] 9553 }, 9554 { 9555 "name": "Asia/Krasnoyarsk", 9556 "rules": [ 9557 { 9558 "e": 12249612e5, 9559 "s": 12068172e5 9560 }, 9561 { 9562 "e": 12564108e5, 9563 "s": 12382668e5 9564 }, 9565 { 9566 "e": 12884652e5, 9567 "s": 12697164e5 9568 }, 9569 false, 9570 false, 9571 false, 9572 false 9573 ] 9574 }, 9575 { 9576 "name": "Asia/Omsk", 9577 "rules": [ 9578 { 9579 "e": 12249648e5, 9580 "s": 12068208e5 9581 }, 9582 { 9583 "e": 12564144e5, 9584 "s": 12382704e5 9585 }, 9586 { 9587 "e": 12884688e5, 9588 "s": 126972e7 9589 }, 9590 false, 9591 false, 9592 false, 9593 false 9594 ] 9595 }, 9596 { 9597 "name": "Asia/Vladivostok", 9598 "rules": [ 9599 { 9600 "e": 12249504e5, 9601 "s": 12068064e5 9602 }, 9603 { 9604 "e": 12564e8, 9605 "s": 1238256e6 9606 }, 9607 { 9608 "e": 12884544e5, 9609 "s": 12697056e5 9610 }, 9611 false, 9612 false, 9613 false, 9614 false 9615 ] 9616 }, 9617 { 9618 "name": "Asia/Yakutsk", 9619 "rules": [ 9620 { 9621 "e": 1224954e6, 9622 "s": 120681e7 9623 }, 9624 { 9625 "e": 12564036e5, 9626 "s": 12382596e5 9627 }, 9628 { 9629 "e": 1288458e6, 9630 "s": 12697092e5 9631 }, 9632 false, 9633 false, 9634 false, 9635 false 9636 ] 9637 }, 9638 { 9639 "name": "Asia/Yekaterinburg", 9640 "rules": [ 9641 { 9642 "e": 12249684e5, 9643 "s": 12068244e5 9644 }, 9645 { 9646 "e": 1256418e6, 9647 "s": 1238274e6 9648 }, 9649 { 9650 "e": 12884724e5, 9651 "s": 12697236e5 9652 }, 9653 false, 9654 false, 9655 false, 9656 false 9657 ] 9658 }, 9659 { 9660 "name": "Asia/Yerevan", 9661 "rules": [ 9662 { 9663 "e": 1224972e6, 9664 "s": 1206828e6 9665 }, 9666 { 9667 "e": 12564216e5, 9668 "s": 12382776e5 9669 }, 9670 { 9671 "e": 1288476e6, 9672 "s": 12697272e5 9673 }, 9674 { 9675 "e": 13199256e5, 9676 "s": 13011768e5 9677 }, 9678 false, 9679 false, 9680 false 9681 ] 9682 }, 9683 { 9684 "name": "Australia/Lord_Howe", 9685 "rules": [ 9686 { 9687 "e": 12074076e5, 9688 "s": 12231342e5 9689 }, 9690 { 9691 "e": 12388572e5, 9692 "s": 12545838e5 9693 }, 9694 { 9695 "e": 12703068e5, 9696 "s": 12860334e5 9697 }, 9698 { 9699 "e": 13017564e5, 9700 "s": 1317483e6 9701 }, 9702 { 9703 "e": 1333206e6, 9704 "s": 13495374e5 9705 }, 9706 { 9707 "e": 13652604e5, 9708 "s": 1380987e6 9709 }, 9710 { 9711 "e": 139671e7, 9712 "s": 14124366e5 9713 } 9714 ] 9715 }, 9716 { 9717 "name": "Australia/Perth", 9718 "rules": [ 9719 { 9720 "e": 12068136e5, 9721 "s": 12249576e5 9722 }, 9723 false, 9724 false, 9725 false, 9726 false, 9727 false, 9728 false 9729 ] 9730 }, 9731 { 9732 "name": "Europe/Helsinki", 9733 "rules": [ 9734 { 9735 "e": 12249828e5, 9736 "s": 12068388e5 9737 }, 9738 { 9739 "e": 12564324e5, 9740 "s": 12382884e5 9741 }, 9742 { 9743 "e": 12884868e5, 9744 "s": 1269738e6 9745 }, 9746 { 9747 "e": 13199364e5, 9748 "s": 13011876e5 9749 }, 9750 { 9751 "e": 1351386e6, 9752 "s": 13326372e5 9753 }, 9754 { 9755 "e": 13828356e5, 9756 "s": 13646916e5 9757 }, 9758 { 9759 "e": 14142852e5, 9760 "s": 13961412e5 9761 } 9762 ] 9763 }, 9764 { 9765 "name": "Europe/Minsk", 9766 "rules": [ 9767 { 9768 "e": 12249792e5, 9769 "s": 12068352e5 9770 }, 9771 { 9772 "e": 12564288e5, 9773 "s": 12382848e5 9774 }, 9775 { 9776 "e": 12884832e5, 9777 "s": 12697344e5 9778 }, 9779 false, 9780 false, 9781 false, 9782 false 9783 ] 9784 }, 9785 { 9786 "name": "Europe/Moscow", 9787 "rules": [ 9788 { 9789 "e": 12249756e5, 9790 "s": 12068316e5 9791 }, 9792 { 9793 "e": 12564252e5, 9794 "s": 12382812e5 9795 }, 9796 { 9797 "e": 12884796e5, 9798 "s": 12697308e5 9799 }, 9800 false, 9801 false, 9802 false, 9803 false 9804 ] 9805 }, 9806 { 9807 "name": "Pacific/Apia", 9808 "rules": [ 9809 false, 9810 false, 9811 false, 9812 { 9813 "e": 13017528e5, 9814 "s": 13168728e5 9815 }, 9816 { 9817 "e": 13332024e5, 9818 "s": 13489272e5 9819 }, 9820 { 9821 "e": 13652568e5, 9822 "s": 13803768e5 9823 }, 9824 { 9825 "e": 13967064e5, 9826 "s": 14118264e5 9827 } 9828 ] 9829 }, 9830 { 9831 "name": "Pacific/Fiji", 9832 "rules": [ 9833 false, 9834 false, 9835 { 9836 "e": 12696984e5, 9837 "s": 12878424e5 9838 }, 9839 { 9840 "e": 13271544e5, 9841 "s": 1319292e6 9842 }, 9843 { 9844 "e": 1358604e6, 9845 "s": 13507416e5 9846 }, 9847 { 9848 "e": 139005e7, 9849 "s": 1382796e6 9850 }, 9851 { 9852 "e": 14215032e5, 9853 "s": 14148504e5 9854 } 9855 ] 9856 }, 9857 { 9858 "name": "Europe/London", 9859 "rules": [ 9860 { 9861 "e": 12249828e5, 9862 "s": 12068388e5 9863 }, 9864 { 9865 "e": 12564324e5, 9866 "s": 12382884e5 9867 }, 9868 { 9869 "e": 12884868e5, 9870 "s": 1269738e6 9871 }, 9872 { 9873 "e": 13199364e5, 9874 "s": 13011876e5 9875 }, 9876 { 9877 "e": 1351386e6, 9878 "s": 13326372e5 9879 }, 9880 { 9881 "e": 13828356e5, 9882 "s": 13646916e5 9883 }, 9884 { 9885 "e": 14142852e5, 9886 "s": 13961412e5 9887 } 9888 ] 9889 } 9890 ] 9891 }; 9892 if (typeof module5 !== "undefined" && typeof module5.exports !== "undefined") { 9893 module5.exports = jstz2; 9894 } else if (typeof define !== "undefined" && define !== null && define.amd != null) { 9895 define([], function() { 9896 return jstz2; 9897 }); 9898 } else { 9899 if (typeof root === "undefined") { 9900 window.jstz = jstz2; 9901 } else { 9902 root.jstz = jstz2; 9903 } 9904 } 9905 })(); 9906 } 9907 }); 9908 9909
vendor: 186 bytes, lines 9909-9916
9909// ../../node_modules/jstz/index.js 9910 var require_jstz2 = __commonJS({ 9911 "../../node_modules/jstz/index.js"(exports2, module5) { 9912 module5.exports = require_jstz(); 9913 } 9914 }); 9915 9916
vendor: 16,989 bytes, lines 9916-10214
9916// ../../node_modules/local-time/app/assets/javascripts/local-time.js 9917 var require_local_time = __commonJS({ 9918 "../../node_modules/local-time/app/assets/javascripts/local-time.js"(exports2, module5) { 9919 (function() { 9920 var t = this; 9921 (function() { 9922 (function() { 9923 var t2 = [].slice; 9924 this.LocalTime = { config: {}, run: function() { 9925 return this.getController().processElements(); 9926 }, process: function() { 9927 var e3, n2, r3, a2; 9928 for (n2 = 1 <= arguments.length ? t2.call(arguments, 0) : [], r3 = 0, a2 = n2.length; r3 < a2; r3++) 9929 e3 = n2[r3], this.getController().processElement(e3); 9930 return n2.length; 9931 }, getController: function() { 9932 return this.controller != null ? this.controller : this.controller = new e2.Controller(); 9933 } }; 9934 }).call(this); 9935 }).call(t); 9936 var e2 = t.LocalTime; 9937 (function() { 9938 (function() { 9939 e2.config.i18n = { en: { date: { dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], abbrDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], abbrMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], yesterday: "yesterday", today: "today", tomorrow: "tomorrow", on: "on {date}", formats: { "default": "%b %e, %Y", thisYear: "%b %e" } }, time: { am: "am", pm: "pm", singular: "a {time}", singularAn: "an {time}", elapsed: "{time} ago", second: "second", seconds: "seconds", minute: "minute", minutes: "minutes", hour: "hour", hours: "hours", formats: { "default": "%l:%M%P" } }, datetime: { at: "{date} at {time}", formats: { "default": "%B %e, %Y at %l:%M%P %Z" } } } }; 9940 }).call(this), function() { 9941 e2.config.locale = "en", e2.config.defaultLocale = "en"; 9942 }.call(this), function() { 9943 e2.config.timerInterval = 6e4; 9944 }.call(this), function() { 9945 var t2, n2, r3; 9946 r3 = !isNaN(Date.parse("2011-01-01T12:00:00-05:00")), e2.parseDate = function(t3) { 9947 return t3 = t3.toString(), r3 || (t3 = n2(t3)), new Date(Date.parse(t3)); 9948 }, t2 = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[-+]?[\d:]+)$/, n2 = function(e3) { 9949 var n3, r4, a2, i2, o2, s2, u, c, l2; 9950 if (a2 = e3.match(t2)) 9951 return a2[0], c = a2[1], o2 = a2[2], n3 = a2[3], r4 = a2[4], i2 = a2[5], u = a2[6], l2 = a2[7], l2 !== "Z" && (s2 = l2.replace(":", "")), c + "/" + o2 + "/" + n3 + " " + r4 + ":" + i2 + ":" + u + " GMT" + [s2]; 9952 }; 9953 }.call(this), function() { 9954 e2.elementMatchesSelector = function() { 9955 var t2, e3, n2, r3, a2, i2; 9956 return t2 = document.documentElement, e3 = (n2 = (r3 = (a2 = (i2 = t2.matches) != null ? i2 : t2.matchesSelector) != null ? a2 : t2.webkitMatchesSelector) != null ? r3 : t2.mozMatchesSelector) != null ? n2 : t2.msMatchesSelector, function(t3, n3) { 9957 if ((t3 != null ? t3.nodeType : void 0) === Node.ELEMENT_NODE) 9958 return e3.call(t3, n3); 9959 }; 9960 }(); 9961 }.call(this), function() { 9962 var t2, n2, r3; 9963 t2 = e2.config, r3 = t2.i18n, e2.getI18nValue = function(a2, i2) { 9964 var o2, s2; 9965 return a2 == null && (a2 = ""), o2 = (i2 != null ? i2 : { locale: t2.locale }).locale, s2 = n2(r3[o2], a2), s2 != null ? s2 : o2 !== t2.defaultLocale ? e2.getI18nValue(a2, { locale: t2.defaultLocale }) : void 0; 9966 }, e2.translate = function(t3, n3, r4) { 9967 var a2, i2, o2; 9968 n3 == null && (n3 = {}), o2 = e2.getI18nValue(t3, r4); 9969 for (a2 in n3) 9970 i2 = n3[a2], o2 = o2.replace("{" + a2 + "}", i2); 9971 return o2; 9972 }, n2 = function(t3, e3) { 9973 var n3, r4, a2, i2, o2; 9974 for (o2 = t3, i2 = e3.split("."), n3 = 0, a2 = i2.length; n3 < a2; n3++) { 9975 if (r4 = i2[n3], o2[r4] == null) 9976 return null; 9977 o2 = o2[r4]; 9978 } 9979 return o2; 9980 }; 9981 }.call(this), function() { 9982 var t2, n2, r3, a2, i2; 9983 t2 = e2.getI18nValue, i2 = e2.translate, e2.strftime = a2 = function(e3, o2) { 9984 var s2, u, c, l2, d, h2, f; 9985 return u = e3.getDay(), s2 = e3.getDate(), d = e3.getMonth(), f = e3.getFullYear(), c = e3.getHours(), l2 = e3.getMinutes(), h2 = e3.getSeconds(), o2.replace(/%(-?)([%aAbBcdeHIlmMpPSwyYZ])/g, function(o3, m, p) { 9986 switch (p) { 9987 case "%": 9988 return "%"; 9989 case "a": 9990 return t2("date.abbrDayNames")[u]; 9991 case "A": 9992 return t2("date.dayNames")[u]; 9993 case "b": 9994 return t2("date.abbrMonthNames")[d]; 9995 case "B": 9996 return t2("date.monthNames")[d]; 9997 case "c": 9998 return e3.toString(); 9999 case "d": 10000 return n2(s2, m); 10001 case "e": 10002 return s2; 10003 case "H": 10004 return n2(c, m); 10005 case "I": 10006 return n2(a2(e3, "%l"), m); 10007 case "l": 10008 return c === 0 || c === 12 ? 12 : (c + 12) % 12; 10009 case "m": 10010 return n2(d + 1, m); 10011 case "M": 10012 return n2(l2, m); 10013 case "p": 10014 return i2("time." + (c > 11 ? "pm" : "am")).toUpperCase(); 10015 case "P": 10016 return i2("time." + (c > 11 ? "pm" : "am")); 10017 case "S": 10018 return n2(h2, m); 10019 case "w": 10020 return u; 10021 case "y": 10022 return n2(f % 100, m); 10023 case "Y": 10024 return f; 10025 case "Z": 10026 return r3(e3); 10027 } 10028 }); 10029 }, n2 = function(t3, e3) { 10030 switch (e3) { 10031 case "-": 10032 return t3; 10033 default: 10034 return ("0" + t3).slice(-2); 10035 } 10036 }, r3 = function(t3) { 10037 var e3, n3, r4, a3, i3; 10038 return i3 = t3.toString(), (e3 = (n3 = i3.match(/\(([\w\s]+)\)$/)) != null ? n3[1] : void 0) ? /\s/.test(e3) ? e3.match(/\b(\w)/g).join("") : e3 : (e3 = (r4 = i3.match(/(\w{3,4})\s\d{4}$/)) != null ? r4[1] : void 0) ? e3 : (e3 = (a3 = i3.match(/(UTC[\+\-]\d+)/)) != null ? a3[1] : void 0) ? e3 : ""; 10039 }; 10040 }.call(this), function() { 10041 e2.CalendarDate = function() { 10042 function t2(t3, e3, n2) { 10043 this.date = new Date(Date.UTC(t3, e3 - 1)), this.date.setUTCDate(n2), this.year = this.date.getUTCFullYear(), this.month = this.date.getUTCMonth() + 1, this.day = this.date.getUTCDate(), this.value = this.date.getTime(); 10044 } 10045 return t2.fromDate = function(t3) { 10046 return new this(t3.getFullYear(), t3.getMonth() + 1, t3.getDate()); 10047 }, t2.today = function() { 10048 return this.fromDate(new Date()); 10049 }, t2.prototype.equals = function(t3) { 10050 return (t3 != null ? t3.value : void 0) === this.value; 10051 }, t2.prototype.is = function(t3) { 10052 return this.equals(t3); 10053 }, t2.prototype.isToday = function() { 10054 return this.is(this.constructor.today()); 10055 }, t2.prototype.occursOnSameYearAs = function(t3) { 10056 return this.year === (t3 != null ? t3.year : void 0); 10057 }, t2.prototype.occursThisYear = function() { 10058 return this.occursOnSameYearAs(this.constructor.today()); 10059 }, t2.prototype.daysSince = function(t3) { 10060 if (t3) 10061 return (this.date - t3.date) / 864e5; 10062 }, t2.prototype.daysPassed = function() { 10063 return this.constructor.today().daysSince(this); 10064 }, t2; 10065 }(); 10066 }.call(this), function() { 10067 var t2, n2, r3; 10068 n2 = e2.strftime, r3 = e2.translate, t2 = e2.getI18nValue, e2.RelativeTime = function() { 10069 function a2(t3) { 10070 this.date = t3, this.calendarDate = e2.CalendarDate.fromDate(this.date); 10071 } 10072 return a2.prototype.toString = function() { 10073 var t3, e3; 10074 return (e3 = this.toTimeElapsedString()) ? r3("time.elapsed", { time: e3 }) : (t3 = this.toWeekdayString()) ? (e3 = this.toTimeString(), r3("datetime.at", { date: t3, time: e3 })) : r3("date.on", { date: this.toDateString() }); 10075 }, a2.prototype.toTimeOrDateString = function() { 10076 return this.calendarDate.isToday() ? this.toTimeString() : this.toDateString(); 10077 }, a2.prototype.toTimeElapsedString = function() { 10078 var t3, e3, n3, a3, i2; 10079 return n3 = new Date().getTime() - this.date.getTime(), a3 = Math.round(n3 / 1e3), e3 = Math.round(a3 / 60), t3 = Math.round(e3 / 60), n3 < 0 ? null : a3 < 10 ? (i2 = r3("time.second"), r3("time.singular", { time: i2 })) : a3 < 45 ? a3 + " " + r3("time.seconds") : a3 < 90 ? (i2 = r3("time.minute"), r3("time.singular", { time: i2 })) : e3 < 45 ? e3 + " " + r3("time.minutes") : e3 < 90 ? (i2 = r3("time.hour"), r3("time.singularAn", { time: i2 })) : t3 < 24 ? t3 + " " + r3("time.hours") : ""; 10080 }, a2.prototype.toWeekdayString = function() { 10081 switch (this.calendarDate.daysPassed()) { 10082 case 0: 10083 return r3("date.today"); 10084 case 1: 10085 return r3("date.yesterday"); 10086 case -1: 10087 return r3("date.tomorrow"); 10088 case 2: 10089 case 3: 10090 case 4: 10091 case 5: 10092 case 6: 10093 return n2(this.date, "%A"); 10094 default: 10095 return ""; 10096 } 10097 }, a2.prototype.toDateString = function() { 10098 var e3; 10099 return e3 = t2(this.calendarDate.occursThisYear() ? "date.formats.thisYear" : "date.formats.default"), n2(this.date, e3); 10100 }, a2.prototype.toTimeString = function() { 10101 return n2(this.date, t2("time.formats.default")); 10102 }, a2; 10103 }(); 10104 }.call(this), function() { 10105 var t2, n2 = function(t3, e3) { 10106 return function() { 10107 return t3.apply(e3, arguments); 10108 }; 10109 }; 10110 t2 = e2.elementMatchesSelector, e2.PageObserver = function() { 10111 function e3(t3, e4) { 10112 this.selector = t3, this.callback = e4, this.processInsertion = n2(this.processInsertion, this), this.processMutations = n2(this.processMutations, this); 10113 } 10114 return e3.prototype.start = function() { 10115 if (!this.started) 10116 return this.observeWithMutationObserver() || this.observeWithMutationEvent(), this.started = true; 10117 }, e3.prototype.observeWithMutationObserver = function() { 10118 var t3; 10119 if (typeof MutationObserver != "undefined" && MutationObserver !== null) 10120 return t3 = new MutationObserver(this.processMutations), t3.observe(document.documentElement, { childList: true, subtree: true }), true; 10121 }, e3.prototype.observeWithMutationEvent = function() { 10122 return addEventListener("DOMNodeInserted", this.processInsertion, false), true; 10123 }, e3.prototype.findSignificantElements = function(e4) { 10124 var n3; 10125 return n3 = [], (e4 != null ? e4.nodeType : void 0) === Node.ELEMENT_NODE && (t2(e4, this.selector) && n3.push(e4), n3.push.apply(n3, e4.querySelectorAll(this.selector))), n3; 10126 }, e3.prototype.processMutations = function(t3) { 10127 var e4, n3, r3, a2, i2, o2, s2, u; 10128 for (e4 = [], n3 = 0, a2 = t3.length; n3 < a2; n3++) 10129 switch (o2 = t3[n3], o2.type) { 10130 case "childList": 10131 for (u = o2.addedNodes, r3 = 0, i2 = u.length; r3 < i2; r3++) 10132 s2 = u[r3], e4.push.apply(e4, this.findSignificantElements(s2)); 10133 } 10134 return this.notify(e4); 10135 }, e3.prototype.processInsertion = function(t3) { 10136 var e4; 10137 return e4 = this.findSignificantElements(t3.target), this.notify(e4); 10138 }, e3.prototype.notify = function(t3) { 10139 if (t3 != null ? t3.length : void 0) 10140 return typeof this.callback == "function" ? this.callback(t3) : void 0; 10141 }, e3; 10142 }(); 10143 }.call(this), function() { 10144 var t2, n2, r3, a2, i2 = function(t3, e3) { 10145 return function() { 10146 return t3.apply(e3, arguments); 10147 }; 10148 }; 10149 r3 = e2.parseDate, a2 = e2.strftime, n2 = e2.getI18nValue, t2 = e2.config, e2.Controller = function() { 10150 function o2() { 10151 this.processElements = i2(this.processElements, this), this.pageObserver = new e2.PageObserver(s2, this.processElements); 10152 } 10153 var s2, u, c; 10154 return s2 = "time[data-local]:not([data-localized])", o2.prototype.start = function() { 10155 if (!this.started) 10156 return this.processElements(), this.startTimer(), this.pageObserver.start(), this.started = true; 10157 }, o2.prototype.startTimer = function() { 10158 var e3; 10159 if (e3 = t2.timerInterval) 10160 return this.timer != null ? this.timer : this.timer = setInterval(this.processElements, e3); 10161 }, o2.prototype.processElements = function(t3) { 10162 var e3, n3, r4; 10163 for (t3 == null && (t3 = document.querySelectorAll(s2)), n3 = 0, r4 = t3.length; n3 < r4; n3++) 10164 e3 = t3[n3], this.processElement(e3); 10165 return t3.length; 10166 }, o2.prototype.processElement = function(t3) { 10167 var e3, i3, o3, s3, l2, d; 10168 if (i3 = t3.getAttribute("datetime"), o3 = t3.getAttribute("data-format"), s3 = t3.getAttribute("data-local"), l2 = r3(i3), !isNaN(l2)) 10169 return t3.hasAttribute("title") || (d = a2(l2, n2("datetime.formats.default")), t3.setAttribute("title", d)), t3.textContent = e3 = function() { 10170 switch (s3) { 10171 case "time": 10172 return u(t3), a2(l2, o3); 10173 case "date": 10174 return u(t3), c(l2).toDateString(); 10175 case "time-ago": 10176 return c(l2).toString(); 10177 case "time-or-date": 10178 return c(l2).toTimeOrDateString(); 10179 case "weekday": 10180 return c(l2).toWeekdayString(); 10181 case "weekday-or-date": 10182 return c(l2).toWeekdayString() || c(l2).toDateString(); 10183 } 10184 }(), t3.hasAttribute("aria-label") ? void 0 : t3.setAttribute("aria-label", e3); 10185 }, u = function(t3) { 10186 return t3.setAttribute("data-localized", ""); 10187 }, c = function(t3) { 10188 return new e2.RelativeTime(t3); 10189 }, o2; 10190 }(); 10191 }.call(this), function() { 10192 var t2, n2, r3, a2; 10193 a2 = false, t2 = function() { 10194 return document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"; 10195 }, n2 = function(t3) { 10196 var e3; 10197 return (e3 = typeof requestAnimationFrame == "function" ? requestAnimationFrame(t3) : void 0) != null ? e3 : setTimeout(t3, 17); 10198 }, r3 = function() { 10199 var t3; 10200 return t3 = e2.getController(), t3.start(); 10201 }, e2.start = function() { 10202 if (!a2) 10203 return a2 = true, typeof MutationObserver != "undefined" && MutationObserver !== null || t2() ? r3() : n2(r3); 10204 }, window.LocalTime === e2 && e2.start(); 10205 }.call(this); 10206 }).call(this), typeof module5 == "object" && module5.exports ? module5.exports = e2 : typeof define == "function" && define.amd && define(e2); 10207 }).call(exports2); 10208 } 10209 }); 10210 10211 // application.js 10212 var import_ujs = __toESM(require_rails_ujs()); 10213 10214
vendor: 109,848 bytes, lines 10214-13419
10214// ../../node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js 10215 var turbo_es2017_esm_exports = {}; 10216 __export(turbo_es2017_esm_exports, { 10217 PageRenderer: () => PageRenderer, 10218 PageSnapshot: () => PageSnapshot, 10219 clearCache: () => clearCache, 10220 connectStreamSource: () => connectStreamSource, 10221 disconnectStreamSource: () => disconnectStreamSource, 10222 navigator: () => navigator$1, 10223 registerAdapter: () => registerAdapter, 10224 renderStreamMessage: () => renderStreamMessage, 10225 session: () => session, 10226 setConfirmMethod: () => setConfirmMethod, 10227 setProgressBarDelay: () => setProgressBarDelay, 10228 start: () => start, 10229 visit: () => visit 10230 }); 10231 (function() { 10232 if (window.Reflect === void 0 || window.customElements === void 0 || window.customElements.polyfillWrapFlushCallback) { 10233 return; 10234 } 10235 const BuiltInHTMLElement = HTMLElement; 10236 const wrapperForTheName = { 10237 "HTMLElement": function HTMLElement2() { 10238 return Reflect.construct(BuiltInHTMLElement, [], this.constructor); 10239 } 10240 }; 10241 window.HTMLElement = wrapperForTheName["HTMLElement"]; 10242 HTMLElement.prototype = BuiltInHTMLElement.prototype; 10243 HTMLElement.prototype.constructor = HTMLElement; 10244 Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement); 10245 })(); 10246 (function(prototype) { 10247 if (typeof prototype.requestSubmit == "function") 10248 return; 10249 prototype.requestSubmit = function(submitter) { 10250 if (submitter) { 10251 validateSubmitter(submitter, this); 10252 submitter.click(); 10253 } else { 10254 submitter = document.createElement("input"); 10255 submitter.type = "submit"; 10256 submitter.hidden = true; 10257 this.appendChild(submitter); 10258 submitter.click(); 10259 this.removeChild(submitter); 10260 } 10261 }; 10262 function validateSubmitter(submitter, form) { 10263 submitter instanceof HTMLElement || raise(TypeError, "parameter 1 is not of type 'HTMLElement'"); 10264 submitter.type == "submit" || raise(TypeError, "The specified element is not a submit button"); 10265 submitter.form == form || raise(DOMException, "The specified element is not owned by this form element", "NotFoundError"); 10266 } 10267 function raise(errorConstructor, message, name) { 10268 throw new errorConstructor("Failed to execute 'requestSubmit' on 'HTMLFormElement': " + message + ".", name); 10269 } 10270 })(HTMLFormElement.prototype); 10271 var submittersByForm = /* @__PURE__ */ new WeakMap(); 10272 function findSubmitterFromClickTarget(target) { 10273 const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null; 10274 const candidate = element ? element.closest("input, button") : null; 10275 return (candidate === null || candidate === void 0 ? void 0 : candidate.type) == "submit" ? candidate : null; 10276 } 10277 function clickCaptured(event) { 10278 const submitter = findSubmitterFromClickTarget(event.target); 10279 if (submitter && submitter.form) { 10280 submittersByForm.set(submitter.form, submitter); 10281 } 10282 } 10283 (function() { 10284 if ("submitter" in Event.prototype) 10285 return; 10286 let prototype; 10287 if ("SubmitEvent" in window && /Apple Computer/.test(navigator.vendor)) { 10288 prototype = window.SubmitEvent.prototype; 10289 } else if ("SubmitEvent" in window) { 10290 return; 10291 } else { 10292 prototype = window.Event.prototype; 10293 } 10294 addEventListener("click", clickCaptured, true); 10295 Object.defineProperty(prototype, "submitter", { 10296 get() { 10297 if (this.type == "submit" && this.target instanceof HTMLFormElement) { 10298 return submittersByForm.get(this.target); 10299 } 10300 } 10301 }); 10302 })(); 10303 var FrameLoadingStyle; 10304 (function(FrameLoadingStyle2) { 10305 FrameLoadingStyle2["eager"] = "eager"; 10306 FrameLoadingStyle2["lazy"] = "lazy"; 10307 })(FrameLoadingStyle || (FrameLoadingStyle = {})); 10308 var FrameElement = class extends HTMLElement { 10309 constructor() { 10310 super(); 10311 this.loaded = Promise.resolve(); 10312 this.delegate = new FrameElement.delegateConstructor(this); 10313 } 10314 static get observedAttributes() { 10315 return ["disabled", "loading", "src"]; 10316 } 10317 connectedCallback() { 10318 this.delegate.connect(); 10319 } 10320 disconnectedCallback() { 10321 this.delegate.disconnect(); 10322 } 10323 reload() { 10324 const { src } = this; 10325 this.src = null; 10326 this.src = src; 10327 } 10328 attributeChangedCallback(name) { 10329 if (name == "loading") { 10330 this.delegate.loadingStyleChanged(); 10331 } else if (name == "src") { 10332 this.delegate.sourceURLChanged(); 10333 } else { 10334 this.delegate.disabledChanged(); 10335 } 10336 } 10337 get src() { 10338 return this.getAttribute("src"); 10339 } 10340 set src(value) { 10341 if (value) { 10342 this.setAttribute("src", value); 10343 } else { 10344 this.removeAttribute("src"); 10345 } 10346 } 10347 get loading() { 10348 return frameLoadingStyleFromString(this.getAttribute("loading") || ""); 10349 } 10350 set loading(value) { 10351 if (value) { 10352 this.setAttribute("loading", value); 10353 } else { 10354 this.removeAttribute("loading"); 10355 } 10356 } 10357 get disabled() { 10358 return this.hasAttribute("disabled"); 10359 } 10360 set disabled(value) { 10361 if (value) { 10362 this.setAttribute("disabled", ""); 10363 } else { 10364 this.removeAttribute("disabled"); 10365 } 10366 } 10367 get autoscroll() { 10368 return this.hasAttribute("autoscroll"); 10369 } 10370 set autoscroll(value) { 10371 if (value) { 10372 this.setAttribute("autoscroll", ""); 10373 } else { 10374 this.removeAttribute("autoscroll"); 10375 } 10376 } 10377 get complete() { 10378 return !this.delegate.isLoading; 10379 } 10380 get isActive() { 10381 return this.ownerDocument === document && !this.isPreview; 10382 } 10383 get isPreview() { 10384 var _a, _b; 10385 return (_b = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.documentElement) === null || _b === void 0 ? void 0 : _b.hasAttribute("data-turbo-preview"); 10386 } 10387 }; 10388 function frameLoadingStyleFromString(style) { 10389 switch (style.toLowerCase()) { 10390 case "lazy": 10391 return FrameLoadingStyle.lazy; 10392 default: 10393 return FrameLoadingStyle.eager; 10394 } 10395 } 10396 function expandURL(locatable) { 10397 return new URL(locatable.toString(), document.baseURI); 10398 } 10399 function getAnchor(url) { 10400 let anchorMatch; 10401 if (url.hash) { 10402 return url.hash.slice(1); 10403 } else if (anchorMatch = url.href.match(/#(.*)$/)) { 10404 return anchorMatch[1]; 10405 } 10406 } 10407 function getAction(form, submitter) { 10408 const action = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formaction")) || form.getAttribute("action") || form.action; 10409 return expandURL(action); 10410 } 10411 function getExtension(url) { 10412 return (getLastPathComponent(url).match(/\.[^.]*$/) || [])[0] || ""; 10413 } 10414 function isHTML(url) { 10415 return !!getExtension(url).match(/^(?:|\.(?:htm|html|xhtml))$/); 10416 } 10417 function isPrefixedBy(baseURL, url) { 10418 const prefix = getPrefix(url); 10419 return baseURL.href === expandURL(prefix).href || baseURL.href.startsWith(prefix); 10420 } 10421 function locationIsVisitable(location2, rootLocation) { 10422 return isPrefixedBy(location2, rootLocation) && isHTML(location2); 10423 } 10424 function getRequestURL(url) { 10425 const anchor = getAnchor(url); 10426 return anchor != null ? url.href.slice(0, -(anchor.length + 1)) : url.href; 10427 } 10428 function toCacheKey(url) { 10429 return getRequestURL(url); 10430 } 10431 function urlsAreEqual(left2, right2) { 10432 return expandURL(left2).href == expandURL(right2).href; 10433 } 10434 function getPathComponents(url) { 10435 return url.pathname.split("/").slice(1); 10436 } 10437 function getLastPathComponent(url) { 10438 return getPathComponents(url).slice(-1)[0]; 10439 } 10440 function getPrefix(url) { 10441 return addTrailingSlash(url.origin + url.pathname); 10442 } 10443 function addTrailingSlash(value) { 10444 return value.endsWith("/") ? value : value + "/"; 10445 } 10446 var FetchResponse = class { 10447 constructor(response) { 10448 this.response = response; 10449 } 10450 get succeeded() { 10451 return this.response.ok; 10452 } 10453 get failed() { 10454 return !this.succeeded; 10455 } 10456 get clientError() { 10457 return this.statusCode >= 400 && this.statusCode <= 499; 10458 } 10459 get serverError() { 10460 return this.statusCode >= 500 && this.statusCode <= 599; 10461 } 10462 get redirected() { 10463 return this.response.redirected; 10464 } 10465 get location() { 10466 return expandURL(this.response.url); 10467 } 10468 get isHTML() { 10469 return this.contentType && this.contentType.match(/^(?:text\/([^\s;,]+\b)?html|application\/xhtml\+xml)\b/); 10470 } 10471 get statusCode() { 10472 return this.response.status; 10473 } 10474 get contentType() { 10475 return this.header("Content-Type"); 10476 } 10477 get responseText() { 10478 return this.response.clone().text(); 10479 } 10480 get responseHTML() { 10481 if (this.isHTML) { 10482 return this.response.clone().text(); 10483 } else { 10484 return Promise.resolve(void 0); 10485 } 10486 } 10487 header(name) { 10488 return this.response.headers.get(name); 10489 } 10490 }; 10491 function dispatch(eventName, { target, cancelable, detail } = {}) { 10492 const event = new CustomEvent(eventName, { cancelable, bubbles: true, detail }); 10493 if (target && target.isConnected) { 10494 target.dispatchEvent(event); 10495 } else { 10496 document.documentElement.dispatchEvent(event); 10497 } 10498 return event; 10499 } 10500 function nextAnimationFrame() { 10501 return new Promise((resolve) => requestAnimationFrame(() => resolve())); 10502 } 10503 function nextEventLoopTick() { 10504 return new Promise((resolve) => setTimeout(() => resolve(), 0)); 10505 } 10506 function nextMicrotask() { 10507 return Promise.resolve(); 10508 } 10509 function parseHTMLDocument(html = "") { 10510 return new DOMParser().parseFromString(html, "text/html"); 10511 } 10512 function unindent(strings, ...values) { 10513 const lines = interpolate(strings, values).replace(/^\n/, "").split("\n"); 10514 const match = lines[0].match(/^\s+/); 10515 const indent = match ? match[0].length : 0; 10516 return lines.map((line) => line.slice(indent)).join("\n"); 10517 } 10518 function interpolate(strings, values) { 10519 return strings.reduce((result, string, i2) => { 10520 const value = values[i2] == void 0 ? "" : values[i2]; 10521 return result + string + value; 10522 }, ""); 10523 } 10524 function uuid() { 10525 return Array.apply(null, { length: 36 }).map((_, i2) => { 10526 if (i2 == 8 || i2 == 13 || i2 == 18 || i2 == 23) { 10527 return "-"; 10528 } else if (i2 == 14) { 10529 return "4"; 10530 } else if (i2 == 19) { 10531 return (Math.floor(Math.random() * 4) + 8).toString(16); 10532 } else { 10533 return Math.floor(Math.random() * 15).toString(16); 10534 } 10535 }).join(""); 10536 } 10537 function getAttribute(attributeName, ...elements3) { 10538 for (const value of elements3.map((element) => element === null || element === void 0 ? void 0 : element.getAttribute(attributeName))) { 10539 if (typeof value == "string") 10540 return value; 10541 } 10542 return null; 10543 } 10544 function markAsBusy(...elements3) { 10545 for (const element of elements3) { 10546 if (element.localName == "turbo-frame") { 10547 element.setAttribute("busy", ""); 10548 } 10549 element.setAttribute("aria-busy", "true"); 10550 } 10551 } 10552 function clearBusyState(...elements3) { 10553 for (const element of elements3) { 10554 if (element.localName == "turbo-frame") { 10555 element.removeAttribute("busy"); 10556 } 10557 element.removeAttribute("aria-busy"); 10558 } 10559 } 10560 var FetchMethod; 10561 (function(FetchMethod2) { 10562 FetchMethod2[FetchMethod2["get"] = 0] = "get"; 10563 FetchMethod2[FetchMethod2["post"] = 1] = "post"; 10564 FetchMethod2[FetchMethod2["put"] = 2] = "put"; 10565 FetchMethod2[FetchMethod2["patch"] = 3] = "patch"; 10566 FetchMethod2[FetchMethod2["delete"] = 4] = "delete"; 10567 })(FetchMethod || (FetchMethod = {})); 10568 function fetchMethodFromString(method) { 10569 switch (method.toLowerCase()) { 10570 case "get": 10571 return FetchMethod.get; 10572 case "post": 10573 return FetchMethod.post; 10574 case "put": 10575 return FetchMethod.put; 10576 case "patch": 10577 return FetchMethod.patch; 10578 case "delete": 10579 return FetchMethod.delete; 10580 } 10581 } 10582 var FetchRequest = class { 10583 constructor(delegate, method, location2, body = new URLSearchParams(), target = null) { 10584 this.abortController = new AbortController(); 10585 this.resolveRequestPromise = (value) => { 10586 }; 10587 this.delegate = delegate; 10588 this.method = method; 10589 this.headers = this.defaultHeaders; 10590 this.body = body; 10591 this.url = location2; 10592 this.target = target; 10593 } 10594 get location() { 10595 return this.url; 10596 } 10597 get params() { 10598 return this.url.searchParams; 10599 } 10600 get entries() { 10601 return this.body ? Array.from(this.body.entries()) : []; 10602 } 10603 cancel() { 10604 this.abortController.abort(); 10605 } 10606 async perform() { 10607 var _a, _b; 10608 const { fetchOptions } = this; 10609 (_b = (_a = this.delegate).prepareHeadersForRequest) === null || _b === void 0 ? void 0 : _b.call(_a, this.headers, this); 10610 await this.allowRequestToBeIntercepted(fetchOptions); 10611 try { 10612 this.delegate.requestStarted(this); 10613 const response = await fetch(this.url.href, fetchOptions); 10614 return await this.receive(response); 10615 } catch (error2) { 10616 if (error2.name !== "AbortError") { 10617 this.delegate.requestErrored(this, error2); 10618 throw error2; 10619 } 10620 } finally { 10621 this.delegate.requestFinished(this); 10622 } 10623 } 10624 async receive(response) { 10625 const fetchResponse = new FetchResponse(response); 10626 const event = dispatch("turbo:before-fetch-response", { cancelable: true, detail: { fetchResponse }, target: this.target }); 10627 if (event.defaultPrevented) { 10628 this.delegate.requestPreventedHandlingResponse(this, fetchResponse); 10629 } else if (fetchResponse.succeeded) { 10630 this.delegate.requestSucceededWithResponse(this, fetchResponse); 10631 } else { 10632 this.delegate.requestFailedWithResponse(this, fetchResponse); 10633 } 10634 return fetchResponse; 10635 } 10636 get fetchOptions() { 10637 var _a; 10638 return { 10639 method: FetchMethod[this.method].toUpperCase(), 10640 credentials: "same-origin", 10641 headers: this.headers, 10642 redirect: "follow", 10643 body: this.isIdempotent ? null : this.body, 10644 signal: this.abortSignal, 10645 referrer: (_a = this.delegate.referrer) === null || _a === void 0 ? void 0 : _a.href 10646 }; 10647 } 10648 get defaultHeaders() { 10649 return { 10650 "Accept": "text/html, application/xhtml+xml" 10651 }; 10652 } 10653 get isIdempotent() { 10654 return this.method == FetchMethod.get; 10655 } 10656 get abortSignal() { 10657 return this.abortController.signal; 10658 } 10659 async allowRequestToBeIntercepted(fetchOptions) { 10660 const requestInterception = new Promise((resolve) => this.resolveRequestPromise = resolve); 10661 const event = dispatch("turbo:before-fetch-request", { 10662 cancelable: true, 10663 detail: { 10664 fetchOptions, 10665 url: this.url, 10666 resume: this.resolveRequestPromise 10667 }, 10668 target: this.target 10669 }); 10670 if (event.defaultPrevented) 10671 await requestInterception; 10672 } 10673 }; 10674 var AppearanceObserver = class { 10675 constructor(delegate, element) { 10676 this.started = false; 10677 this.intersect = (entries) => { 10678 const lastEntry = entries.slice(-1)[0]; 10679 if (lastEntry === null || lastEntry === void 0 ? void 0 : lastEntry.isIntersecting) { 10680 this.delegate.elementAppearedInViewport(this.element); 10681 } 10682 }; 10683 this.delegate = delegate; 10684 this.element = element; 10685 this.intersectionObserver = new IntersectionObserver(this.intersect); 10686 } 10687 start() { 10688 if (!this.started) { 10689 this.started = true; 10690 this.intersectionObserver.observe(this.element); 10691 } 10692 } 10693 stop() { 10694 if (this.started) { 10695 this.started = false; 10696 this.intersectionObserver.unobserve(this.element); 10697 } 10698 } 10699 }; 10700 var StreamMessage = class { 10701 constructor(html) { 10702 this.templateElement = document.createElement("template"); 10703 this.templateElement.innerHTML = html; 10704 } 10705 static wrap(message) { 10706 if (typeof message == "string") { 10707 return new this(message); 10708 } else { 10709 return message; 10710 } 10711 } 10712 get fragment() { 10713 const fragment = document.createDocumentFragment(); 10714 for (const element of this.foreignElements) { 10715 fragment.appendChild(document.importNode(element, true)); 10716 } 10717 return fragment; 10718 } 10719 get foreignElements() { 10720 return this.templateChildren.reduce((streamElements, child) => { 10721 if (child.tagName.toLowerCase() == "turbo-stream") { 10722 return [...streamElements, child]; 10723 } else { 10724 return streamElements; 10725 } 10726 }, []); 10727 } 10728 get templateChildren() { 10729 return Array.from(this.templateElement.content.children); 10730 } 10731 }; 10732 StreamMessage.contentType = "text/vnd.turbo-stream.html"; 10733 var FormSubmissionState; 10734 (function(FormSubmissionState2) { 10735 FormSubmissionState2[FormSubmissionState2["initialized"] = 0] = "initialized"; 10736 FormSubmissionState2[FormSubmissionState2["requesting"] = 1] = "requesting"; 10737 FormSubmissionState2[FormSubmissionState2["waiting"] = 2] = "waiting"; 10738 FormSubmissionState2[FormSubmissionState2["receiving"] = 3] = "receiving"; 10739 FormSubmissionState2[FormSubmissionState2["stopping"] = 4] = "stopping"; 10740 FormSubmissionState2[FormSubmissionState2["stopped"] = 5] = "stopped"; 10741 })(FormSubmissionState || (FormSubmissionState = {})); 10742 var FormEnctype; 10743 (function(FormEnctype2) { 10744 FormEnctype2["urlEncoded"] = "application/x-www-form-urlencoded"; 10745 FormEnctype2["multipart"] = "multipart/form-data"; 10746 FormEnctype2["plain"] = "text/plain"; 10747 })(FormEnctype || (FormEnctype = {})); 10748 function formEnctypeFromString(encoding) { 10749 switch (encoding.toLowerCase()) { 10750 case FormEnctype.multipart: 10751 return FormEnctype.multipart; 10752 case FormEnctype.plain: 10753 return FormEnctype.plain; 10754 default: 10755 return FormEnctype.urlEncoded; 10756 } 10757 } 10758 var FormSubmission = class { 10759 constructor(delegate, formElement, submitter, mustRedirect = false) { 10760 this.state = FormSubmissionState.initialized; 10761 this.delegate = delegate; 10762 this.formElement = formElement; 10763 this.submitter = submitter; 10764 this.formData = buildFormData(formElement, submitter); 10765 this.location = expandURL(this.action); 10766 if (this.method == FetchMethod.get) { 10767 mergeFormDataEntries(this.location, [...this.body.entries()]); 10768 } 10769 this.fetchRequest = new FetchRequest(this, this.method, this.location, this.body, this.formElement); 10770 this.mustRedirect = mustRedirect; 10771 } 10772 static confirmMethod(message, element) { 10773 return confirm(message); 10774 } 10775 get method() { 10776 var _a; 10777 const method = ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formmethod")) || this.formElement.getAttribute("method") || ""; 10778 return fetchMethodFromString(method.toLowerCase()) || FetchMethod.get; 10779 } 10780 get action() { 10781 var _a; 10782 const formElementAction = typeof this.formElement.action === "string" ? this.formElement.action : null; 10783 return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formaction")) || this.formElement.getAttribute("action") || formElementAction || ""; 10784 } 10785 get body() { 10786 if (this.enctype == FormEnctype.urlEncoded || this.method == FetchMethod.get) { 10787 return new URLSearchParams(this.stringFormData); 10788 } else { 10789 return this.formData; 10790 } 10791 } 10792 get enctype() { 10793 var _a; 10794 return formEnctypeFromString(((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formenctype")) || this.formElement.enctype); 10795 } 10796 get isIdempotent() { 10797 return this.fetchRequest.isIdempotent; 10798 } 10799 get stringFormData() { 10800 return [...this.formData].reduce((entries, [name, value]) => { 10801 return entries.concat(typeof value == "string" ? [[name, value]] : []); 10802 }, []); 10803 } 10804 get confirmationMessage() { 10805 return this.formElement.getAttribute("data-turbo-confirm"); 10806 } 10807 get needsConfirmation() { 10808 return this.confirmationMessage !== null; 10809 } 10810 async start() { 10811 const { initialized, requesting } = FormSubmissionState; 10812 if (this.needsConfirmation) { 10813 const answer = FormSubmission.confirmMethod(this.confirmationMessage, this.formElement); 10814 if (!answer) { 10815 return; 10816 } 10817 } 10818 if (this.state == initialized) { 10819 this.state = requesting; 10820 return this.fetchRequest.perform(); 10821 } 10822 } 10823 stop() { 10824 const { stopping, stopped } = FormSubmissionState; 10825 if (this.state != stopping && this.state != stopped) { 10826 this.state = stopping; 10827 this.fetchRequest.cancel(); 10828 return true; 10829 } 10830 } 10831 prepareHeadersForRequest(headers, request) { 10832 if (!request.isIdempotent) { 10833 const token = getCookieValue(getMetaContent("csrf-param")) || getMetaContent("csrf-token"); 10834 if (token) { 10835 headers["X-CSRF-Token"] = token; 10836 } 10837 headers["Accept"] = [StreamMessage.contentType, headers["Accept"]].join(", "); 10838 } 10839 } 10840 requestStarted(request) { 10841 var _a; 10842 this.state = FormSubmissionState.waiting; 10843 (_a = this.submitter) === null || _a === void 0 ? void 0 : _a.setAttribute("disabled", ""); 10844 dispatch("turbo:submit-start", { target: this.formElement, detail: { formSubmission: this } }); 10845 this.delegate.formSubmissionStarted(this); 10846 } 10847 requestPreventedHandlingResponse(request, response) { 10848 this.result = { success: response.succeeded, fetchResponse: response }; 10849 } 10850 requestSucceededWithResponse(request, response) { 10851 if (response.clientError || response.serverError) { 10852 this.delegate.formSubmissionFailedWithResponse(this, response); 10853 } else if (this.requestMustRedirect(request) && responseSucceededWithoutRedirect(response)) { 10854 const error2 = new Error("Form responses must redirect to another location"); 10855 this.delegate.formSubmissionErrored(this, error2); 10856 } else { 10857 this.state = FormSubmissionState.receiving; 10858 this.result = { success: true, fetchResponse: response }; 10859 this.delegate.formSubmissionSucceededWithResponse(this, response); 10860 } 10861 } 10862 requestFailedWithResponse(request, response) { 10863 this.result = { success: false, fetchResponse: response }; 10864 this.delegate.formSubmissionFailedWithResponse(this, response); 10865 } 10866 requestErrored(request, error2) { 10867 this.result = { success: false, error: error2 }; 10868 this.delegate.formSubmissionErrored(this, error2); 10869 } 10870 requestFinished(request) { 10871 var _a; 10872 this.state = FormSubmissionState.stopped; 10873 (_a = this.submitter) === null || _a === void 0 ? void 0 : _a.removeAttribute("disabled"); 10874 dispatch("turbo:submit-end", { target: this.formElement, detail: Object.assign({ formSubmission: this }, this.result) }); 10875 this.delegate.formSubmissionFinished(this); 10876 } 10877 requestMustRedirect(request) { 10878 return !request.isIdempotent && this.mustRedirect; 10879 } 10880 }; 10881 function buildFormData(formElement, submitter) { 10882 const formData = new FormData(formElement); 10883 const name = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("name"); 10884 const value = submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("value"); 10885 if (name && value != null && formData.get(name) != value) { 10886 formData.append(name, value); 10887 } 10888 return formData; 10889 } 10890 function getCookieValue(cookieName) { 10891 if (cookieName != null) { 10892 const cookies = document.cookie ? document.cookie.split("; ") : []; 10893 const cookie = cookies.find((cookie2) => cookie2.startsWith(cookieName)); 10894 if (cookie) { 10895 const value = cookie.split("=").slice(1).join("="); 10896 return value ? decodeURIComponent(value) : void 0; 10897 } 10898 } 10899 } 10900 function getMetaContent(name) { 10901 const element = document.querySelector(`meta[name="${name}"]`); 10902 return element && element.content; 10903 } 10904 function responseSucceededWithoutRedirect(response) { 10905 return response.statusCode == 200 && !response.redirected; 10906 } 10907 function mergeFormDataEntries(url, entries) { 10908 const searchParams = new URLSearchParams(); 10909 for (const [name, value] of entries) { 10910 if (value instanceof File) 10911 continue; 10912 searchParams.append(name, value); 10913 } 10914 url.search = searchParams.toString(); 10915 return url; 10916 } 10917 var Snapshot = class { 10918 constructor(element) { 10919 this.element = element; 10920 } 10921 get children() { 10922 return [...this.element.children]; 10923 } 10924 hasAnchor(anchor) { 10925 return this.getElementForAnchor(anchor) != null; 10926 } 10927 getElementForAnchor(anchor) { 10928 return anchor ? this.element.querySelector(`[id='${anchor}'], a[name='${anchor}']`) : null; 10929 } 10930 get isConnected() { 10931 return this.element.isConnected; 10932 } 10933 get firstAutofocusableElement() { 10934 return this.element.querySelector("[autofocus]"); 10935 } 10936 get permanentElements() { 10937 return [...this.element.querySelectorAll("[id][data-turbo-permanent]")]; 10938 } 10939 getPermanentElementById(id) { 10940 return this.element.querySelector(`#${id}[data-turbo-permanent]`); 10941 } 10942 getPermanentElementMapForSnapshot(snapshot) { 10943 const permanentElementMap = {}; 10944 for (const currentPermanentElement of this.permanentElements) { 10945 const { id } = currentPermanentElement; 10946 const newPermanentElement = snapshot.getPermanentElementById(id); 10947 if (newPermanentElement) { 10948 permanentElementMap[id] = [currentPermanentElement, newPermanentElement]; 10949 } 10950 } 10951 return permanentElementMap; 10952 } 10953 }; 10954 var FormInterceptor = class { 10955 constructor(delegate, element) { 10956 this.submitBubbled = (event) => { 10957 const form = event.target; 10958 if (!event.defaultPrevented && form instanceof HTMLFormElement && form.closest("turbo-frame, html") == this.element) { 10959 const submitter = event.submitter || void 0; 10960 const method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formmethod")) || form.method; 10961 if (method != "dialog" && this.delegate.shouldInterceptFormSubmission(form, submitter)) { 10962 event.preventDefault(); 10963 event.stopImmediatePropagation(); 10964 this.delegate.formSubmissionIntercepted(form, submitter); 10965 } 10966 } 10967 }; 10968 this.delegate = delegate; 10969 this.element = element; 10970 } 10971 start() { 10972 this.element.addEventListener("submit", this.submitBubbled); 10973 } 10974 stop() { 10975 this.element.removeEventListener("submit", this.submitBubbled); 10976 } 10977 }; 10978 var View = class { 10979 constructor(delegate, element) { 10980 this.resolveRenderPromise = (value) => { 10981 }; 10982 this.resolveInterceptionPromise = (value) => { 10983 }; 10984 this.delegate = delegate; 10985 this.element = element; 10986 } 10987 scrollToAnchor(anchor) { 10988 const element = this.snapshot.getElementForAnchor(anchor); 10989 if (element) { 10990 this.scrollToElement(element); 10991 this.focusElement(element); 10992 } else { 10993 this.scrollToPosition({ x: 0, y: 0 }); 10994 } 10995 } 10996 scrollToAnchorFromLocation(location2) { 10997 this.scrollToAnchor(getAnchor(location2)); 10998 } 10999 scrollToElement(element) { 11000 element.scrollIntoView(); 11001 } 11002 focusElement(element) { 11003 if (element instanceof HTMLElement) { 11004 if (element.hasAttribute("tabindex")) { 11005 element.focus(); 11006 } else { 11007 element.setAttribute("tabindex", "-1"); 11008 element.focus(); 11009 element.removeAttribute("tabindex"); 11010 } 11011 } 11012 } 11013 scrollToPosition({ x, y }) { 11014 this.scrollRoot.scrollTo(x, y); 11015 } 11016 scrollToTop() { 11017 this.scrollToPosition({ x: 0, y: 0 }); 11018 } 11019 get scrollRoot() { 11020 return window; 11021 } 11022 async render(renderer) { 11023 const { isPreview, shouldRender, newSnapshot: snapshot } = renderer; 11024 if (shouldRender) { 11025 try { 11026 this.renderPromise = new Promise((resolve) => this.resolveRenderPromise = resolve); 11027 this.renderer = renderer; 11028 this.prepareToRenderSnapshot(renderer); 11029 const renderInterception = new Promise((resolve) => this.resolveInterceptionPromise = resolve); 11030 const immediateRender = this.delegate.allowsImmediateRender(snapshot, this.resolveInterceptionPromise); 11031 if (!immediateRender) 11032 await renderInterception; 11033 await this.renderSnapshot(renderer); 11034 this.delegate.viewRenderedSnapshot(snapshot, isPreview); 11035 this.finishRenderingSnapshot(renderer); 11036 } finally { 11037 delete this.renderer; 11038 this.resolveRenderPromise(void 0); 11039 delete this.renderPromise; 11040 } 11041 } else { 11042 this.invalidate(); 11043 } 11044 } 11045 invalidate() { 11046 this.delegate.viewInvalidated(); 11047 } 11048 prepareToRenderSnapshot(renderer) { 11049 this.markAsPreview(renderer.isPreview); 11050 renderer.prepareToRender(); 11051 } 11052 markAsPreview(isPreview) { 11053 if (isPreview) { 11054 this.element.setAttribute("data-turbo-preview", ""); 11055 } else { 11056 this.element.removeAttribute("data-turbo-preview"); 11057 } 11058 } 11059 async renderSnapshot(renderer) { 11060 await renderer.render(); 11061 } 11062 finishRenderingSnapshot(renderer) { 11063 renderer.finishRendering(); 11064 } 11065 }; 11066 var FrameView = class extends View { 11067 invalidate() { 11068 this.element.innerHTML = ""; 11069 } 11070 get snapshot() { 11071 return new Snapshot(this.element); 11072 } 11073 }; 11074 var LinkInterceptor = class { 11075 constructor(delegate, element) { 11076 this.clickBubbled = (event) => { 11077 if (this.respondsToEventTarget(event.target)) { 11078 this.clickEvent = event; 11079 } else { 11080 delete this.clickEvent; 11081 } 11082 }; 11083 this.linkClicked = (event) => { 11084 if (this.clickEvent && this.respondsToEventTarget(event.target) && event.target instanceof Element) { 11085 if (this.delegate.shouldInterceptLinkClick(event.target, event.detail.url)) { 11086 this.clickEvent.preventDefault(); 11087 event.preventDefault(); 11088 this.delegate.linkClickIntercepted(event.target, event.detail.url); 11089 } 11090 } 11091 delete this.clickEvent; 11092 }; 11093 this.willVisit = () => { 11094 delete this.clickEvent; 11095 }; 11096 this.delegate = delegate; 11097 this.element = element; 11098 } 11099 start() { 11100 this.element.addEventListener("click", this.clickBubbled); 11101 document.addEventListener("turbo:click", this.linkClicked); 11102 document.addEventListener("turbo:before-visit", this.willVisit); 11103 } 11104 stop() { 11105 this.element.removeEventListener("click", this.clickBubbled); 11106 document.removeEventListener("turbo:click", this.linkClicked); 11107 document.removeEventListener("turbo:before-visit", this.willVisit); 11108 } 11109 respondsToEventTarget(target) { 11110 const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null; 11111 return element && element.closest("turbo-frame, html") == this.element; 11112 } 11113 }; 11114 var Bardo = class { 11115 constructor(permanentElementMap) { 11116 this.permanentElementMap = permanentElementMap; 11117 } 11118 static preservingPermanentElements(permanentElementMap, callback) { 11119 const bardo = new this(permanentElementMap); 11120 bardo.enter(); 11121 callback(); 11122 bardo.leave(); 11123 } 11124 enter() { 11125 for (const id in this.permanentElementMap) { 11126 const [, newPermanentElement] = this.permanentElementMap[id]; 11127 this.replaceNewPermanentElementWithPlaceholder(newPermanentElement); 11128 } 11129 } 11130 leave() { 11131 for (const id in this.permanentElementMap) { 11132 const [currentPermanentElement] = this.permanentElementMap[id]; 11133 this.replaceCurrentPermanentElementWithClone(currentPermanentElement); 11134 this.replacePlaceholderWithPermanentElement(currentPermanentElement); 11135 } 11136 } 11137 replaceNewPermanentElementWithPlaceholder(permanentElement) { 11138 const placeholder = createPlaceholderForPermanentElement(permanentElement); 11139 permanentElement.replaceWith(placeholder); 11140 } 11141 replaceCurrentPermanentElementWithClone(permanentElement) { 11142 const clone = permanentElement.cloneNode(true); 11143 permanentElement.replaceWith(clone); 11144 } 11145 replacePlaceholderWithPermanentElement(permanentElement) { 11146 const placeholder = this.getPlaceholderById(permanentElement.id); 11147 placeholder === null || placeholder === void 0 ? void 0 : placeholder.replaceWith(permanentElement); 11148 } 11149 getPlaceholderById(id) { 11150 return this.placeholders.find((element) => element.content == id); 11151 } 11152 get placeholders() { 11153 return [...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]; 11154 } 11155 }; 11156 function createPlaceholderForPermanentElement(permanentElement) { 11157 const element = document.createElement("meta"); 11158 element.setAttribute("name", "turbo-permanent-placeholder"); 11159 element.setAttribute("content", permanentElement.id); 11160 return element; 11161 } 11162 var Renderer = class { 11163 constructor(currentSnapshot, newSnapshot, isPreview, willRender = true) { 11164 this.currentSnapshot = currentSnapshot; 11165 this.newSnapshot = newSnapshot; 11166 this.isPreview = isPreview; 11167 this.willRender = willRender; 11168 this.promise = new Promise((resolve, reject) => this.resolvingFunctions = { resolve, reject }); 11169 } 11170 get shouldRender() { 11171 return true; 11172 } 11173 prepareToRender() { 11174 return; 11175 } 11176 finishRendering() { 11177 if (this.resolvingFunctions) { 11178 this.resolvingFunctions.resolve(); 11179 delete this.resolvingFunctions; 11180 } 11181 } 11182 createScriptElement(element) { 11183 if (element.getAttribute("data-turbo-eval") == "false") { 11184 return element; 11185 } else { 11186 const createdScriptElement = document.createElement("script"); 11187 if (this.cspNonce) { 11188 createdScriptElement.nonce = this.cspNonce; 11189 } 11190 createdScriptElement.textContent = element.textContent; 11191 createdScriptElement.async = false; 11192 copyElementAttributes(createdScriptElement, element); 11193 return createdScriptElement; 11194 } 11195 } 11196 preservingPermanentElements(callback) { 11197 Bardo.preservingPermanentElements(this.permanentElementMap, callback); 11198 } 11199 focusFirstAutofocusableElement() { 11200 const element = this.connectedSnapshot.firstAutofocusableElement; 11201 if (elementIsFocusable(element)) { 11202 element.focus(); 11203 } 11204 } 11205 get connectedSnapshot() { 11206 return this.newSnapshot.isConnected ? this.newSnapshot : this.currentSnapshot; 11207 } 11208 get currentElement() { 11209 return this.currentSnapshot.element; 11210 } 11211 get newElement() { 11212 return this.newSnapshot.element; 11213 } 11214 get permanentElementMap() { 11215 return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot); 11216 } 11217 get cspNonce() { 11218 var _a; 11219 return (_a = document.head.querySelector('meta[name="csp-nonce"]')) === null || _a === void 0 ? void 0 : _a.getAttribute("content"); 11220 } 11221 }; 11222 function copyElementAttributes(destinationElement, sourceElement) { 11223 for (const { name, value } of [...sourceElement.attributes]) { 11224 destinationElement.setAttribute(name, value); 11225 } 11226 } 11227 function elementIsFocusable(element) { 11228 return element && typeof element.focus == "function"; 11229 } 11230 var FrameRenderer = class extends Renderer { 11231 get shouldRender() { 11232 return true; 11233 } 11234 async render() { 11235 await nextAnimationFrame(); 11236 this.preservingPermanentElements(() => { 11237 this.loadFrameElement(); 11238 }); 11239 this.scrollFrameIntoView(); 11240 await nextAnimationFrame(); 11241 this.focusFirstAutofocusableElement(); 11242 await nextAnimationFrame(); 11243 this.activateScriptElements(); 11244 } 11245 loadFrameElement() { 11246 var _a; 11247 const destinationRange = document.createRange(); 11248 destinationRange.selectNodeContents(this.currentElement); 11249 destinationRange.deleteContents(); 11250 const frameElement = this.newElement; 11251 const sourceRange = (_a = frameElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.createRange(); 11252 if (sourceRange) { 11253 sourceRange.selectNodeContents(frameElement); 11254 this.currentElement.appendChild(sourceRange.extractContents()); 11255 } 11256 } 11257 scrollFrameIntoView() { 11258 if (this.currentElement.autoscroll || this.newElement.autoscroll) { 11259 const element = this.currentElement.firstElementChild; 11260 const block = readScrollLogicalPosition(this.currentElement.getAttribute("data-autoscroll-block"), "end"); 11261 if (element) { 11262 element.scrollIntoView({ block }); 11263 return true; 11264 } 11265 } 11266 return false; 11267 } 11268 activateScriptElements() { 11269 for (const inertScriptElement of this.newScriptElements) { 11270 const activatedScriptElement = this.createScriptElement(inertScriptElement); 11271 inertScriptElement.replaceWith(activatedScriptElement); 11272 } 11273 } 11274 get newScriptElements() { 11275 return this.currentElement.querySelectorAll("script"); 11276 } 11277 }; 11278 function readScrollLogicalPosition(value, defaultValue) { 11279 if (value == "end" || value == "start" || value == "center" || value == "nearest") { 11280 return value; 11281 } else { 11282 return defaultValue; 11283 } 11284 } 11285 var ProgressBar = class { 11286 constructor() { 11287 this.hiding = false; 11288 this.value = 0; 11289 this.visible = false; 11290 this.trickle = () => { 11291 this.setValue(this.value + Math.random() / 100); 11292 }; 11293 this.stylesheetElement = this.createStylesheetElement(); 11294 this.progressElement = this.createProgressElement(); 11295 this.installStylesheetElement(); 11296 this.setValue(0); 11297 } 11298 static get defaultCSS() { 11299 return unindent` 11300 .turbo-progress-bar { 11301 position: fixed; 11302 display: block; 11303 top: 0; 11304 left: 0; 11305 height: 3px; 11306 background: #0076ff; 11307 z-index: 9999; 11308 transition: 11309 width ${ProgressBar.animationDuration}ms ease-out, 11310 opacity ${ProgressBar.animationDuration / 2}ms ${ProgressBar.animationDuration / 2}ms ease-in; 11311 transform: translate3d(0, 0, 0); 11312 } 11313 `; 11314 } 11315 show() { 11316 if (!this.visible) { 11317 this.visible = true; 11318 this.installProgressElement(); 11319 this.startTrickling(); 11320 } 11321 } 11322 hide() { 11323 if (this.visible && !this.hiding) { 11324 this.hiding = true; 11325 this.fadeProgressElement(() => { 11326 this.uninstallProgressElement(); 11327 this.stopTrickling(); 11328 this.visible = false; 11329 this.hiding = false; 11330 }); 11331 } 11332 } 11333 setValue(value) { 11334 this.value = value; 11335 this.refresh(); 11336 } 11337 installStylesheetElement() { 11338 document.head.insertBefore(this.stylesheetElement, document.head.firstChild); 11339 } 11340 installProgressElement() { 11341 this.progressElement.style.width = "0"; 11342 this.progressElement.style.opacity = "1"; 11343 document.documentElement.insertBefore(this.progressElement, document.body); 11344 this.refresh(); 11345 } 11346 fadeProgressElement(callback) { 11347 this.progressElement.style.opacity = "0"; 11348 setTimeout(callback, ProgressBar.animationDuration * 1.5); 11349 } 11350 uninstallProgressElement() { 11351 if (this.progressElement.parentNode) { 11352 document.documentElement.removeChild(this.progressElement); 11353 } 11354 } 11355 startTrickling() { 11356 if (!this.trickleInterval) { 11357 this.trickleInterval = window.setInterval(this.trickle, ProgressBar.animationDuration); 11358 } 11359 } 11360 stopTrickling() { 11361 window.clearInterval(this.trickleInterval); 11362 delete this.trickleInterval; 11363 } 11364 refresh() { 11365 requestAnimationFrame(() => { 11366 this.progressElement.style.width = `${10 + this.value * 90}%`; 11367 }); 11368 } 11369 createStylesheetElement() { 11370 const element = document.createElement("style"); 11371 element.type = "text/css"; 11372 element.textContent = ProgressBar.defaultCSS; 11373 return element; 11374 } 11375 createProgressElement() { 11376 const element = document.createElement("div"); 11377 element.className = "turbo-progress-bar"; 11378 return element; 11379 } 11380 }; 11381 ProgressBar.animationDuration = 300; 11382 var HeadSnapshot = class extends Snapshot { 11383 constructor() { 11384 super(...arguments); 11385 this.detailsByOuterHTML = this.children.filter((element) => !elementIsNoscript(element)).map((element) => elementWithoutNonce(element)).reduce((result, element) => { 11386 const { outerHTML } = element; 11387 const details = outerHTML in result ? result[outerHTML] : { 11388 type: elementType(element), 11389 tracked: elementIsTracked(element), 11390 elements: [] 11391 }; 11392 return Object.assign(Object.assign({}, result), { [outerHTML]: Object.assign(Object.assign({}, details), { elements: [...details.elements, element] }) }); 11393 }, {}); 11394 } 11395 get trackedElementSignature() { 11396 return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => this.detailsByOuterHTML[outerHTML].tracked).join(""); 11397 } 11398 getScriptElementsNotInSnapshot(snapshot) { 11399 return this.getElementsMatchingTypeNotInSnapshot("script", snapshot); 11400 } 11401 getStylesheetElementsNotInSnapshot(snapshot) { 11402 return this.getElementsMatchingTypeNotInSnapshot("stylesheet", snapshot); 11403 } 11404 getElementsMatchingTypeNotInSnapshot(matchedType, snapshot) { 11405 return Object.keys(this.detailsByOuterHTML).filter((outerHTML) => !(outerHTML in snapshot.detailsByOuterHTML)).map((outerHTML) => this.detailsByOuterHTML[outerHTML]).filter(({ type }) => type == matchedType).map(({ elements: [element] }) => element); 11406 } 11407 get provisionalElements() { 11408 return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => { 11409 const { type, tracked, elements: elements3 } = this.detailsByOuterHTML[outerHTML]; 11410 if (type == null && !tracked) { 11411 return [...result, ...elements3]; 11412 } else if (elements3.length > 1) { 11413 return [...result, ...elements3.slice(1)]; 11414 } else { 11415 return result; 11416 } 11417 }, []); 11418 } 11419 getMetaValue(name) { 11420 const element = this.findMetaElementByName(name); 11421 return element ? element.getAttribute("content") : null; 11422 } 11423 findMetaElementByName(name) { 11424 return Object.keys(this.detailsByOuterHTML).reduce((result, outerHTML) => { 11425 const { elements: [element] } = this.detailsByOuterHTML[outerHTML]; 11426 return elementIsMetaElementWithName(element, name) ? element : result; 11427 }, void 0); 11428 } 11429 }; 11430 function elementType(element) { 11431 if (elementIsScript(element)) { 11432 return "script"; 11433 } else if (elementIsStylesheet(element)) { 11434 return "stylesheet"; 11435 } 11436 } 11437 function elementIsTracked(element) { 11438 return element.getAttribute("data-turbo-track") == "reload"; 11439 } 11440 function elementIsScript(element) { 11441 const tagName = element.tagName.toLowerCase(); 11442 return tagName == "script"; 11443 } 11444 function elementIsNoscript(element) { 11445 const tagName = element.tagName.toLowerCase(); 11446 return tagName == "noscript"; 11447 } 11448 function elementIsStylesheet(element) { 11449 const tagName = element.tagName.toLowerCase(); 11450 return tagName == "style" || tagName == "link" && element.getAttribute("rel") == "stylesheet"; 11451 } 11452 function elementIsMetaElementWithName(element, name) { 11453 const tagName = element.tagName.toLowerCase(); 11454 return tagName == "meta" && element.getAttribute("name") == name; 11455 } 11456 function elementWithoutNonce(element) { 11457 if (element.hasAttribute("nonce")) { 11458 element.setAttribute("nonce", ""); 11459 } 11460 return element; 11461 } 11462 var PageSnapshot = class extends Snapshot { 11463 constructor(element, headSnapshot) { 11464 super(element); 11465 this.headSnapshot = headSnapshot; 11466 } 11467 static fromHTMLString(html = "") { 11468 return this.fromDocument(parseHTMLDocument(html)); 11469 } 11470 static fromElement(element) { 11471 return this.fromDocument(element.ownerDocument); 11472 } 11473 static fromDocument({ head, body }) { 11474 return new this(body, new HeadSnapshot(head)); 11475 } 11476 clone() { 11477 return new PageSnapshot(this.element.cloneNode(true), this.headSnapshot); 11478 } 11479 get headElement() { 11480 return this.headSnapshot.element; 11481 } 11482 get rootLocation() { 11483 var _a; 11484 const root = (_a = this.getSetting("root")) !== null && _a !== void 0 ? _a : "/"; 11485 return expandURL(root); 11486 } 11487 get cacheControlValue() { 11488 return this.getSetting("cache-control"); 11489 } 11490 get isPreviewable() { 11491 return this.cacheControlValue != "no-preview"; 11492 } 11493 get isCacheable() { 11494 return this.cacheControlValue != "no-cache"; 11495 } 11496 get isVisitable() { 11497 return this.getSetting("visit-control") != "reload"; 11498 } 11499 getSetting(name) { 11500 return this.headSnapshot.getMetaValue(`turbo-${name}`); 11501 } 11502 }; 11503 var TimingMetric; 11504 (function(TimingMetric2) { 11505 TimingMetric2["visitStart"] = "visitStart"; 11506 TimingMetric2["requestStart"] = "requestStart"; 11507 TimingMetric2["requestEnd"] = "requestEnd"; 11508 TimingMetric2["visitEnd"] = "visitEnd"; 11509 })(TimingMetric || (TimingMetric = {})); 11510 var VisitState; 11511 (function(VisitState2) { 11512 VisitState2["initialized"] = "initialized"; 11513 VisitState2["started"] = "started"; 11514 VisitState2["canceled"] = "canceled"; 11515 VisitState2["failed"] = "failed"; 11516 VisitState2["completed"] = "completed"; 11517 })(VisitState || (VisitState = {})); 11518 var defaultOptions = { 11519 action: "advance", 11520 historyChanged: false, 11521 visitCachedSnapshot: () => { 11522 }, 11523 willRender: true 11524 }; 11525 var SystemStatusCode; 11526 (function(SystemStatusCode2) { 11527 SystemStatusCode2[SystemStatusCode2["networkFailure"] = 0] = "networkFailure"; 11528 SystemStatusCode2[SystemStatusCode2["timeoutFailure"] = -1] = "timeoutFailure"; 11529 SystemStatusCode2[SystemStatusCode2["contentTypeMismatch"] = -2] = "contentTypeMismatch"; 11530 })(SystemStatusCode || (SystemStatusCode = {})); 11531 var Visit = class { 11532 constructor(delegate, location2, restorationIdentifier, options2 = {}) { 11533 this.identifier = uuid(); 11534 this.timingMetrics = {}; 11535 this.followedRedirect = false; 11536 this.historyChanged = false; 11537 this.scrolled = false; 11538 this.snapshotCached = false; 11539 this.state = VisitState.initialized; 11540 this.delegate = delegate; 11541 this.location = location2; 11542 this.restorationIdentifier = restorationIdentifier || uuid(); 11543 const { action, historyChanged, referrer, snapshotHTML, response, visitCachedSnapshot, willRender } = Object.assign(Object.assign({}, defaultOptions), options2); 11544 this.action = action; 11545 this.historyChanged = historyChanged; 11546 this.referrer = referrer; 11547 this.snapshotHTML = snapshotHTML; 11548 this.response = response; 11549 this.isSamePage = this.delegate.locationWithActionIsSamePage(this.location, this.action); 11550 this.visitCachedSnapshot = visitCachedSnapshot; 11551 this.willRender = willRender; 11552 this.scrolled = !willRender; 11553 } 11554 get adapter() { 11555 return this.delegate.adapter; 11556 } 11557 get view() { 11558 return this.delegate.view; 11559 } 11560 get history() { 11561 return this.delegate.history; 11562 } 11563 get restorationData() { 11564 return this.history.getRestorationDataForIdentifier(this.restorationIdentifier); 11565 } 11566 get silent() { 11567 return this.isSamePage; 11568 } 11569 start() { 11570 if (this.state == VisitState.initialized) { 11571 this.recordTimingMetric(TimingMetric.visitStart); 11572 this.state = VisitState.started; 11573 this.adapter.visitStarted(this); 11574 this.delegate.visitStarted(this); 11575 } 11576 } 11577 cancel() { 11578 if (this.state == VisitState.started) { 11579 if (this.request) { 11580 this.request.cancel(); 11581 } 11582 this.cancelRender(); 11583 this.state = VisitState.canceled; 11584 } 11585 } 11586 complete() { 11587 if (this.state == VisitState.started) { 11588 this.recordTimingMetric(TimingMetric.visitEnd); 11589 this.state = VisitState.completed; 11590 this.adapter.visitCompleted(this); 11591 this.delegate.visitCompleted(this); 11592 this.followRedirect(); 11593 } 11594 } 11595 fail() { 11596 if (this.state == VisitState.started) { 11597 this.state = VisitState.failed; 11598 this.adapter.visitFailed(this); 11599 } 11600 } 11601 changeHistory() { 11602 var _a; 11603 if (!this.historyChanged) { 11604 const actionForHistory = this.location.href === ((_a = this.referrer) === null || _a === void 0 ? void 0 : _a.href) ? "replace" : this.action; 11605 const method = this.getHistoryMethodForAction(actionForHistory); 11606 this.history.update(method, this.location, this.restorationIdentifier); 11607 this.historyChanged = true; 11608 } 11609 } 11610 issueRequest() { 11611 if (this.hasPreloadedResponse()) { 11612 this.simulateRequest(); 11613 } else if (this.shouldIssueRequest() && !this.request) { 11614 this.request = new FetchRequest(this, FetchMethod.get, this.location); 11615 this.request.perform(); 11616 } 11617 } 11618 simulateRequest() { 11619 if (this.response) { 11620 this.startRequest(); 11621 this.recordResponse(); 11622 this.finishRequest(); 11623 } 11624 } 11625 startRequest() { 11626 this.recordTimingMetric(TimingMetric.requestStart); 11627 this.adapter.visitRequestStarted(this); 11628 } 11629 recordResponse(response = this.response) { 11630 this.response = response; 11631 if (response) { 11632 const { statusCode } = response; 11633 if (isSuccessful(statusCode)) { 11634 this.adapter.visitRequestCompleted(this); 11635 } else { 11636 this.adapter.visitRequestFailedWithStatusCode(this, statusCode); 11637 } 11638 } 11639 } 11640 finishRequest() { 11641 this.recordTimingMetric(TimingMetric.requestEnd); 11642 this.adapter.visitRequestFinished(this); 11643 } 11644 loadResponse() { 11645 if (this.response) { 11646 const { statusCode, responseHTML } = this.response; 11647 this.render(async () => { 11648 this.cacheSnapshot(); 11649 if (this.view.renderPromise) 11650 await this.view.renderPromise; 11651 if (isSuccessful(statusCode) && responseHTML != null) { 11652 await this.view.renderPage(PageSnapshot.fromHTMLString(responseHTML), false, this.willRender); 11653 this.adapter.visitRendered(this); 11654 this.complete(); 11655 } else { 11656 await this.view.renderError(PageSnapshot.fromHTMLString(responseHTML)); 11657 this.adapter.visitRendered(this); 11658 this.fail(); 11659 } 11660 }); 11661 } 11662 } 11663 getCachedSnapshot() { 11664 const snapshot = this.view.getCachedSnapshotForLocation(this.location) || this.getPreloadedSnapshot(); 11665 if (snapshot && (!getAnchor(this.location) || snapshot.hasAnchor(getAnchor(this.location)))) { 11666 if (this.action == "restore" || snapshot.isPreviewable) { 11667 return snapshot; 11668 } 11669 } 11670 } 11671 getPreloadedSnapshot() { 11672 if (this.snapshotHTML) { 11673 return PageSnapshot.fromHTMLString(this.snapshotHTML); 11674 } 11675 } 11676 hasCachedSnapshot() { 11677 return this.getCachedSnapshot() != null; 11678 } 11679 loadCachedSnapshot() { 11680 const snapshot = this.getCachedSnapshot(); 11681 if (snapshot) { 11682 const isPreview = this.shouldIssueRequest(); 11683 this.render(async () => { 11684 this.cacheSnapshot(); 11685 if (this.isSamePage) { 11686 this.adapter.visitRendered(this); 11687 } else { 11688 if (this.view.renderPromise) 11689 await this.view.renderPromise; 11690 await this.view.renderPage(snapshot, isPreview, this.willRender); 11691 this.adapter.visitRendered(this); 11692 if (!isPreview) { 11693 this.complete(); 11694 } 11695 } 11696 }); 11697 } 11698 } 11699 followRedirect() { 11700 var _a; 11701 if (this.redirectedToLocation && !this.followedRedirect && ((_a = this.response) === null || _a === void 0 ? void 0 : _a.redirected)) { 11702 this.adapter.visitProposedToLocation(this.redirectedToLocation, { 11703 action: "replace", 11704 response: this.response 11705 }); 11706 this.followedRedirect = true; 11707 } 11708 } 11709 goToSamePageAnchor() { 11710 if (this.isSamePage) { 11711 this.render(async () => { 11712 this.cacheSnapshot(); 11713 this.adapter.visitRendered(this); 11714 }); 11715 } 11716 } 11717 requestStarted() { 11718 this.startRequest(); 11719 } 11720 requestPreventedHandlingResponse(request, response) { 11721 } 11722 async requestSucceededWithResponse(request, response) { 11723 const responseHTML = await response.responseHTML; 11724 const { redirected, statusCode } = response; 11725 if (responseHTML == void 0) { 11726 this.recordResponse({ statusCode: SystemStatusCode.contentTypeMismatch, redirected }); 11727 } else { 11728 this.redirectedToLocation = response.redirected ? response.location : void 0; 11729 this.recordResponse({ statusCode, responseHTML, redirected }); 11730 } 11731 } 11732 async requestFailedWithResponse(request, response) { 11733 const responseHTML = await response.responseHTML; 11734 const { redirected, statusCode } = response; 11735 if (responseHTML == void 0) { 11736 this.recordResponse({ statusCode: SystemStatusCode.contentTypeMismatch, redirected }); 11737 } else { 11738 this.recordResponse({ statusCode, responseHTML, redirected }); 11739 } 11740 } 11741 requestErrored(request, error2) { 11742 this.recordResponse({ statusCode: SystemStatusCode.networkFailure, redirected: false }); 11743 } 11744 requestFinished() { 11745 this.finishRequest(); 11746 } 11747 performScroll() { 11748 if (!this.scrolled) { 11749 if (this.action == "restore") { 11750 this.scrollToRestoredPosition() || this.scrollToAnchor() || this.view.scrollToTop(); 11751 } else { 11752 this.scrollToAnchor() || this.view.scrollToTop(); 11753 } 11754 if (this.isSamePage) { 11755 this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation, this.location); 11756 } 11757 this.scrolled = true; 11758 } 11759 } 11760 scrollToRestoredPosition() { 11761 const { scrollPosition } = this.restorationData; 11762 if (scrollPosition) { 11763 this.view.scrollToPosition(scrollPosition); 11764 return true; 11765 } 11766 } 11767 scrollToAnchor() { 11768 const anchor = getAnchor(this.location); 11769 if (anchor != null) { 11770 this.view.scrollToAnchor(anchor); 11771 return true; 11772 } 11773 } 11774 recordTimingMetric(metric) { 11775 this.timingMetrics[metric] = new Date().getTime(); 11776 } 11777 getTimingMetrics() { 11778 return Object.assign({}, this.timingMetrics); 11779 } 11780 getHistoryMethodForAction(action) { 11781 switch (action) { 11782 case "replace": 11783 return history.replaceState; 11784 case "advance": 11785 case "restore": 11786 return history.pushState; 11787 } 11788 } 11789 hasPreloadedResponse() { 11790 return typeof this.response == "object"; 11791 } 11792 shouldIssueRequest() { 11793 if (this.isSamePage) { 11794 return false; 11795 } else if (this.action == "restore") { 11796 return !this.hasCachedSnapshot(); 11797 } else { 11798 return this.willRender; 11799 } 11800 } 11801 cacheSnapshot() { 11802 if (!this.snapshotCached) { 11803 this.view.cacheSnapshot().then((snapshot) => snapshot && this.visitCachedSnapshot(snapshot)); 11804 this.snapshotCached = true; 11805 } 11806 } 11807 async render(callback) { 11808 this.cancelRender(); 11809 await new Promise((resolve) => { 11810 this.frame = requestAnimationFrame(() => resolve()); 11811 }); 11812 await callback(); 11813 delete this.frame; 11814 this.performScroll(); 11815 } 11816 cancelRender() { 11817 if (this.frame) { 11818 cancelAnimationFrame(this.frame); 11819 delete this.frame; 11820 } 11821 } 11822 }; 11823 function isSuccessful(statusCode) { 11824 return statusCode >= 200 && statusCode < 300; 11825 } 11826 var BrowserAdapter = class { 11827 constructor(session2) { 11828 this.progressBar = new ProgressBar(); 11829 this.showProgressBar = () => { 11830 this.progressBar.show(); 11831 }; 11832 this.session = session2; 11833 } 11834 visitProposedToLocation(location2, options2) { 11835 this.navigator.startVisit(location2, uuid(), options2); 11836 } 11837 visitStarted(visit2) { 11838 visit2.loadCachedSnapshot(); 11839 visit2.issueRequest(); 11840 visit2.changeHistory(); 11841 visit2.goToSamePageAnchor(); 11842 } 11843 visitRequestStarted(visit2) { 11844 this.progressBar.setValue(0); 11845 if (visit2.hasCachedSnapshot() || visit2.action != "restore") { 11846 this.showVisitProgressBarAfterDelay(); 11847 } else { 11848 this.showProgressBar(); 11849 } 11850 } 11851 visitRequestCompleted(visit2) { 11852 visit2.loadResponse(); 11853 } 11854 visitRequestFailedWithStatusCode(visit2, statusCode) { 11855 switch (statusCode) { 11856 case SystemStatusCode.networkFailure: 11857 case SystemStatusCode.timeoutFailure: 11858 case SystemStatusCode.contentTypeMismatch: 11859 return this.reload(); 11860 default: 11861 return visit2.loadResponse(); 11862 } 11863 } 11864 visitRequestFinished(visit2) { 11865 this.progressBar.setValue(1); 11866 this.hideVisitProgressBar(); 11867 } 11868 visitCompleted(visit2) { 11869 } 11870 pageInvalidated() { 11871 this.reload(); 11872 } 11873 visitFailed(visit2) { 11874 } 11875 visitRendered(visit2) { 11876 } 11877 formSubmissionStarted(formSubmission) { 11878 this.progressBar.setValue(0); 11879 this.showFormProgressBarAfterDelay(); 11880 } 11881 formSubmissionFinished(formSubmission) { 11882 this.progressBar.setValue(1); 11883 this.hideFormProgressBar(); 11884 } 11885 showVisitProgressBarAfterDelay() { 11886 this.visitProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay); 11887 } 11888 hideVisitProgressBar() { 11889 this.progressBar.hide(); 11890 if (this.visitProgressBarTimeout != null) { 11891 window.clearTimeout(this.visitProgressBarTimeout); 11892 delete this.visitProgressBarTimeout; 11893 } 11894 } 11895 showFormProgressBarAfterDelay() { 11896 if (this.formProgressBarTimeout == null) { 11897 this.formProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay); 11898 } 11899 } 11900 hideFormProgressBar() { 11901 this.progressBar.hide(); 11902 if (this.formProgressBarTimeout != null) { 11903 window.clearTimeout(this.formProgressBarTimeout); 11904 delete this.formProgressBarTimeout; 11905 } 11906 } 11907 reload() { 11908 window.location.reload(); 11909 } 11910 get navigator() { 11911 return this.session.navigator; 11912 } 11913 }; 11914 var CacheObserver = class { 11915 constructor() { 11916 this.started = false; 11917 } 11918 start() { 11919 if (!this.started) { 11920 this.started = true; 11921 addEventListener("turbo:before-cache", this.removeStaleElements, false); 11922 } 11923 } 11924 stop() { 11925 if (this.started) { 11926 this.started = false; 11927 removeEventListener("turbo:before-cache", this.removeStaleElements, false); 11928 } 11929 } 11930 removeStaleElements() { 11931 const staleElements = [...document.querySelectorAll('[data-turbo-cache="false"]')]; 11932 for (const element of staleElements) { 11933 element.remove(); 11934 } 11935 } 11936 }; 11937 var FormSubmitObserver = class { 11938 constructor(delegate) { 11939 this.started = false; 11940 this.submitCaptured = () => { 11941 removeEventListener("submit", this.submitBubbled, false); 11942 addEventListener("submit", this.submitBubbled, false); 11943 }; 11944 this.submitBubbled = (event) => { 11945 if (!event.defaultPrevented) { 11946 const form = event.target instanceof HTMLFormElement ? event.target : void 0; 11947 const submitter = event.submitter || void 0; 11948 if (form) { 11949 const method = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("formmethod")) || form.getAttribute("method"); 11950 if (method != "dialog" && this.delegate.willSubmitForm(form, submitter)) { 11951 event.preventDefault(); 11952 this.delegate.formSubmitted(form, submitter); 11953 } 11954 } 11955 } 11956 }; 11957 this.delegate = delegate; 11958 } 11959 start() { 11960 if (!this.started) { 11961 addEventListener("submit", this.submitCaptured, true); 11962 this.started = true; 11963 } 11964 } 11965 stop() { 11966 if (this.started) { 11967 removeEventListener("submit", this.submitCaptured, true); 11968 this.started = false; 11969 } 11970 } 11971 }; 11972 var FrameRedirector = class { 11973 constructor(element) { 11974 this.element = element; 11975 this.linkInterceptor = new LinkInterceptor(this, element); 11976 this.formInterceptor = new FormInterceptor(this, element); 11977 } 11978 start() { 11979 this.linkInterceptor.start(); 11980 this.formInterceptor.start(); 11981 } 11982 stop() { 11983 this.linkInterceptor.stop(); 11984 this.formInterceptor.stop(); 11985 } 11986 shouldInterceptLinkClick(element, url) { 11987 return this.shouldRedirect(element); 11988 } 11989 linkClickIntercepted(element, url) { 11990 const frame = this.findFrameElement(element); 11991 if (frame) { 11992 frame.delegate.linkClickIntercepted(element, url); 11993 } 11994 } 11995 shouldInterceptFormSubmission(element, submitter) { 11996 return this.shouldSubmit(element, submitter); 11997 } 11998 formSubmissionIntercepted(element, submitter) { 11999 const frame = this.findFrameElement(element, submitter); 12000 if (frame) { 12001 frame.removeAttribute("reloadable"); 12002 frame.delegate.formSubmissionIntercepted(element, submitter); 12003 } 12004 } 12005 shouldSubmit(form, submitter) { 12006 var _a; 12007 const action = getAction(form, submitter); 12008 const meta = this.element.ownerDocument.querySelector(`meta[name="turbo-root"]`); 12009 const rootLocation = expandURL((_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : "/"); 12010 return this.shouldRedirect(form, submitter) && locationIsVisitable(action, rootLocation); 12011 } 12012 shouldRedirect(element, submitter) { 12013 const frame = this.findFrameElement(element, submitter); 12014 return frame ? frame != element.closest("turbo-frame") : false; 12015 } 12016 findFrameElement(element, submitter) { 12017 const id = (submitter === null || submitter === void 0 ? void 0 : submitter.getAttribute("data-turbo-frame")) || element.getAttribute("data-turbo-frame"); 12018 if (id && id != "_top") { 12019 const frame = this.element.querySelector(`#${id}:not([disabled])`); 12020 if (frame instanceof FrameElement) { 12021 return frame; 12022 } 12023 } 12024 } 12025 }; 12026 var History = class { 12027 constructor(delegate) { 12028 this.restorationIdentifier = uuid(); 12029 this.restorationData = {}; 12030 this.started = false; 12031 this.pageLoaded = false; 12032 this.onPopState = (event) => { 12033 if (this.shouldHandlePopState()) { 12034 const { turbo } = event.state || {}; 12035 if (turbo) { 12036 this.location = new URL(window.location.href); 12037 const { restorationIdentifier } = turbo; 12038 this.restorationIdentifier = restorationIdentifier; 12039 this.delegate.historyPoppedToLocationWithRestorationIdentifier(this.location, restorationIdentifier); 12040 } 12041 } 12042 }; 12043 this.onPageLoad = async (event) => { 12044 await nextMicrotask(); 12045 this.pageLoaded = true; 12046 }; 12047 this.delegate = delegate; 12048 } 12049 start() { 12050 if (!this.started) { 12051 addEventListener("popstate", this.onPopState, false); 12052 addEventListener("load", this.onPageLoad, false); 12053 this.started = true; 12054 this.replace(new URL(window.location.href)); 12055 } 12056 } 12057 stop() { 12058 if (this.started) { 12059 removeEventListener("popstate", this.onPopState, false); 12060 removeEventListener("load", this.onPageLoad, false); 12061 this.started = false; 12062 } 12063 } 12064 push(location2, restorationIdentifier) { 12065 this.update(history.pushState, location2, restorationIdentifier); 12066 } 12067 replace(location2, restorationIdentifier) { 12068 this.update(history.replaceState, location2, restorationIdentifier); 12069 } 12070 update(method, location2, restorationIdentifier = uuid()) { 12071 const state = { turbo: { restorationIdentifier } }; 12072 method.call(history, state, "", location2.href); 12073 this.location = location2; 12074 this.restorationIdentifier = restorationIdentifier; 12075 } 12076 getRestorationDataForIdentifier(restorationIdentifier) { 12077 return this.restorationData[restorationIdentifier] || {}; 12078 } 12079 updateRestorationData(additionalData) { 12080 const { restorationIdentifier } = this; 12081 const restorationData = this.restorationData[restorationIdentifier]; 12082 this.restorationData[restorationIdentifier] = Object.assign(Object.assign({}, restorationData), additionalData); 12083 } 12084 assumeControlOfScrollRestoration() { 12085 var _a; 12086 if (!this.previousScrollRestoration) { 12087 this.previousScrollRestoration = (_a = history.scrollRestoration) !== null && _a !== void 0 ? _a : "auto"; 12088 history.scrollRestoration = "manual"; 12089 } 12090 } 12091 relinquishControlOfScrollRestoration() { 12092 if (this.previousScrollRestoration) { 12093 history.scrollRestoration = this.previousScrollRestoration; 12094 delete this.previousScrollRestoration; 12095 } 12096 } 12097 shouldHandlePopState() { 12098 return this.pageIsLoaded(); 12099 } 12100 pageIsLoaded() { 12101 return this.pageLoaded || document.readyState == "complete"; 12102 } 12103 }; 12104 var LinkClickObserver = class { 12105 constructor(delegate) { 12106 this.started = false; 12107 this.clickCaptured = () => { 12108 removeEventListener("click", this.clickBubbled, false); 12109 addEventListener("click", this.clickBubbled, false); 12110 }; 12111 this.clickBubbled = (event) => { 12112 if (this.clickEventIsSignificant(event)) { 12113 const target = event.composedPath && event.composedPath()[0] || event.target; 12114 const link = this.findLinkFromClickTarget(target); 12115 if (link) { 12116 const location2 = this.getLocationForLink(link); 12117 if (this.delegate.willFollowLinkToLocation(link, location2)) { 12118 event.preventDefault(); 12119 this.delegate.followedLinkToLocation(link, location2); 12120 } 12121 } 12122 } 12123 }; 12124 this.delegate = delegate; 12125 } 12126 start() { 12127 if (!this.started) { 12128 addEventListener("click", this.clickCaptured, true); 12129 this.started = true; 12130 } 12131 } 12132 stop() { 12133 if (this.started) { 12134 removeEventListener("click", this.clickCaptured, true); 12135 this.started = false; 12136 } 12137 } 12138 clickEventIsSignificant(event) { 12139 return !(event.target && event.target.isContentEditable || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey); 12140 } 12141 findLinkFromClickTarget(target) { 12142 if (target instanceof Element) { 12143 return target.closest("a[href]:not([target^=_]):not([download])"); 12144 } 12145 } 12146 getLocationForLink(link) { 12147 return expandURL(link.getAttribute("href") || ""); 12148 } 12149 }; 12150 function isAction(action) { 12151 return action == "advance" || action == "replace" || action == "restore"; 12152 } 12153 var Navigator = class { 12154 constructor(delegate) { 12155 this.delegate = delegate; 12156 } 12157 proposeVisit(location2, options2 = {}) { 12158 if (this.delegate.allowsVisitingLocationWithAction(location2, options2.action)) { 12159 if (locationIsVisitable(location2, this.view.snapshot.rootLocation)) { 12160 this.delegate.visitProposedToLocation(location2, options2); 12161 } else { 12162 window.location.href = location2.toString(); 12163 } 12164 } 12165 } 12166 startVisit(locatable, restorationIdentifier, options2 = {}) { 12167 this.stop(); 12168 this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, Object.assign({ referrer: this.location }, options2)); 12169 this.currentVisit.start(); 12170 } 12171 submitForm(form, submitter) { 12172 this.stop(); 12173 this.formSubmission = new FormSubmission(this, form, submitter, true); 12174 this.formSubmission.start(); 12175 } 12176 stop() { 12177 if (this.formSubmission) { 12178 this.formSubmission.stop(); 12179 delete this.formSubmission; 12180 } 12181 if (this.currentVisit) { 12182 this.currentVisit.cancel(); 12183 delete this.currentVisit; 12184 } 12185 } 12186 get adapter() { 12187 return this.delegate.adapter; 12188 } 12189 get view() { 12190 return this.delegate.view; 12191 } 12192 get history() { 12193 return this.delegate.history; 12194 } 12195 formSubmissionStarted(formSubmission) { 12196 if (typeof this.adapter.formSubmissionStarted === "function") { 12197 this.adapter.formSubmissionStarted(formSubmission); 12198 } 12199 } 12200 async formSubmissionSucceededWithResponse(formSubmission, fetchResponse) { 12201 if (formSubmission == this.formSubmission) { 12202 const responseHTML = await fetchResponse.responseHTML; 12203 if (responseHTML) { 12204 if (formSubmission.method != FetchMethod.get) { 12205 this.view.clearSnapshotCache(); 12206 } 12207 const { statusCode, redirected } = fetchResponse; 12208 const action = this.getActionForFormSubmission(formSubmission); 12209 const visitOptions = { action, response: { statusCode, responseHTML, redirected } }; 12210 this.proposeVisit(fetchResponse.location, visitOptions); 12211 } 12212 } 12213 } 12214 async formSubmissionFailedWithResponse(formSubmission, fetchResponse) { 12215 const responseHTML = await fetchResponse.responseHTML; 12216 if (responseHTML) { 12217 const snapshot = PageSnapshot.fromHTMLString(responseHTML); 12218 if (fetchResponse.serverError) { 12219 await this.view.renderError(snapshot); 12220 } else { 12221 await this.view.renderPage(snapshot); 12222 } 12223 this.view.scrollToTop(); 12224 this.view.clearSnapshotCache(); 12225 } 12226 } 12227 formSubmissionErrored(formSubmission, error2) { 12228 console.error(error2); 12229 } 12230 formSubmissionFinished(formSubmission) { 12231 if (typeof this.adapter.formSubmissionFinished === "function") { 12232 this.adapter.formSubmissionFinished(formSubmission); 12233 } 12234 } 12235 visitStarted(visit2) { 12236 this.delegate.visitStarted(visit2); 12237 } 12238 visitCompleted(visit2) { 12239 this.delegate.visitCompleted(visit2); 12240 } 12241 locationWithActionIsSamePage(location2, action) { 12242 const anchor = getAnchor(location2); 12243 const currentAnchor = getAnchor(this.view.lastRenderedLocation); 12244 const isRestorationToTop = action === "restore" && typeof anchor === "undefined"; 12245 return action !== "replace" && getRequestURL(location2) === getRequestURL(this.view.lastRenderedLocation) && (isRestorationToTop || anchor != null && anchor !== currentAnchor); 12246 } 12247 visitScrolledToSamePageLocation(oldURL, newURL) { 12248 this.delegate.visitScrolledToSamePageLocation(oldURL, newURL); 12249 } 12250 get location() { 12251 return this.history.location; 12252 } 12253 get restorationIdentifier() { 12254 return this.history.restorationIdentifier; 12255 } 12256 getActionForFormSubmission(formSubmission) { 12257 const { formElement, submitter } = formSubmission; 12258 const action = getAttribute("data-turbo-action", submitter, formElement); 12259 return isAction(action) ? action : "advance"; 12260 } 12261 }; 12262 var PageStage; 12263 (function(PageStage2) { 12264 PageStage2[PageStage2["initial"] = 0] = "initial"; 12265 PageStage2[PageStage2["loading"] = 1] = "loading"; 12266 PageStage2[PageStage2["interactive"] = 2] = "interactive"; 12267 PageStage2[PageStage2["complete"] = 3] = "complete"; 12268 })(PageStage || (PageStage = {})); 12269 var PageObserver = class { 12270 constructor(delegate) { 12271 this.stage = PageStage.initial; 12272 this.started = false; 12273 this.interpretReadyState = () => { 12274 const { readyState } = this; 12275 if (readyState == "interactive") { 12276 this.pageIsInteractive(); 12277 } else if (readyState == "complete") { 12278 this.pageIsComplete(); 12279 } 12280 }; 12281 this.pageWillUnload = () => { 12282 this.delegate.pageWillUnload(); 12283 }; 12284 this.delegate = delegate; 12285 } 12286 start() { 12287 if (!this.started) { 12288 if (this.stage == PageStage.initial) { 12289 this.stage = PageStage.loading; 12290 } 12291 document.addEventListener("readystatechange", this.interpretReadyState, false); 12292 addEventListener("pagehide", this.pageWillUnload, false); 12293 this.started = true; 12294 } 12295 } 12296 stop() { 12297 if (this.started) { 12298 document.removeEventListener("readystatechange", this.interpretReadyState, false); 12299 removeEventListener("pagehide", this.pageWillUnload, false); 12300 this.started = false; 12301 } 12302 } 12303 pageIsInteractive() { 12304 if (this.stage == PageStage.loading) { 12305 this.stage = PageStage.interactive; 12306 this.delegate.pageBecameInteractive(); 12307 } 12308 } 12309 pageIsComplete() { 12310 this.pageIsInteractive(); 12311 if (this.stage == PageStage.interactive) { 12312 this.stage = PageStage.complete; 12313 this.delegate.pageLoaded(); 12314 } 12315 } 12316 get readyState() { 12317 return document.readyState; 12318 } 12319 }; 12320 var ScrollObserver = class { 12321 constructor(delegate) { 12322 this.started = false; 12323 this.onScroll = () => { 12324 this.updatePosition({ x: window.pageXOffset, y: window.pageYOffset }); 12325 }; 12326 this.delegate = delegate; 12327 } 12328 start() { 12329 if (!this.started) { 12330 addEventListener("scroll", this.onScroll, false); 12331 this.onScroll(); 12332 this.started = true; 12333 } 12334 } 12335 stop() { 12336 if (this.started) { 12337 removeEventListener("scroll", this.onScroll, false); 12338 this.started = false; 12339 } 12340 } 12341 updatePosition(position) { 12342 this.delegate.scrollPositionChanged(position); 12343 } 12344 }; 12345 var StreamObserver = class { 12346 constructor(delegate) { 12347 this.sources = /* @__PURE__ */ new Set(); 12348 this.started = false; 12349 this.inspectFetchResponse = (event) => { 12350 const response = fetchResponseFromEvent(event); 12351 if (response && fetchResponseIsStream(response)) { 12352 event.preventDefault(); 12353 this.receiveMessageResponse(response); 12354 } 12355 }; 12356 this.receiveMessageEvent = (event) => { 12357 if (this.started && typeof event.data == "string") { 12358 this.receiveMessageHTML(event.data); 12359 } 12360 }; 12361 this.delegate = delegate; 12362 } 12363 start() { 12364 if (!this.started) { 12365 this.started = true; 12366 addEventListener("turbo:before-fetch-response", this.inspectFetchResponse, false); 12367 } 12368 } 12369 stop() { 12370 if (this.started) { 12371 this.started = false; 12372 removeEventListener("turbo:before-fetch-response", this.inspectFetchResponse, false); 12373 } 12374 } 12375 connectStreamSource(source) { 12376 if (!this.streamSourceIsConnected(source)) { 12377 this.sources.add(source); 12378 source.addEventListener("message", this.receiveMessageEvent, false); 12379 } 12380 } 12381 disconnectStreamSource(source) { 12382 if (this.streamSourceIsConnected(source)) { 12383 this.sources.delete(source); 12384 source.removeEventListener("message", this.receiveMessageEvent, false); 12385 } 12386 } 12387 streamSourceIsConnected(source) { 12388 return this.sources.has(source); 12389 } 12390 async receiveMessageResponse(response) { 12391 const html = await response.responseHTML; 12392 if (html) { 12393 this.receiveMessageHTML(html); 12394 } 12395 } 12396 receiveMessageHTML(html) { 12397 this.delegate.receivedMessageFromStream(new StreamMessage(html)); 12398 } 12399 }; 12400 function fetchResponseFromEvent(event) { 12401 var _a; 12402 const fetchResponse = (_a = event.detail) === null || _a === void 0 ? void 0 : _a.fetchResponse; 12403 if (fetchResponse instanceof FetchResponse) { 12404 return fetchResponse; 12405 } 12406 } 12407 function fetchResponseIsStream(response) { 12408 var _a; 12409 const contentType = (_a = response.contentType) !== null && _a !== void 0 ? _a : ""; 12410 return contentType.startsWith(StreamMessage.contentType); 12411 } 12412 var ErrorRenderer = class extends Renderer { 12413 async render() { 12414 this.replaceHeadAndBody(); 12415 this.activateScriptElements(); 12416 } 12417 replaceHeadAndBody() { 12418 const { documentElement, head, body } = document; 12419 documentElement.replaceChild(this.newHead, head); 12420 documentElement.replaceChild(this.newElement, body); 12421 } 12422 activateScriptElements() { 12423 for (const replaceableElement of this.scriptElements) { 12424 const parentNode = replaceableElement.parentNode; 12425 if (parentNode) { 12426 const element = this.createScriptElement(replaceableElement); 12427 parentNode.replaceChild(element, replaceableElement); 12428 } 12429 } 12430 } 12431 get newHead() { 12432 return this.newSnapshot.headSnapshot.element; 12433 } 12434 get scriptElements() { 12435 return [...document.documentElement.querySelectorAll("script")]; 12436 } 12437 }; 12438 var PageRenderer = class extends Renderer { 12439 get shouldRender() { 12440 return this.newSnapshot.isVisitable && this.trackedElementsAreIdentical; 12441 } 12442 prepareToRender() { 12443 this.mergeHead(); 12444 } 12445 async render() { 12446 if (this.willRender) { 12447 this.replaceBody(); 12448 } 12449 } 12450 finishRendering() { 12451 super.finishRendering(); 12452 if (!this.isPreview) { 12453 this.focusFirstAutofocusableElement(); 12454 } 12455 } 12456 get currentHeadSnapshot() { 12457 return this.currentSnapshot.headSnapshot; 12458 } 12459 get newHeadSnapshot() { 12460 return this.newSnapshot.headSnapshot; 12461 } 12462 get newElement() { 12463 return this.newSnapshot.element; 12464 } 12465 mergeHead() { 12466 this.copyNewHeadStylesheetElements(); 12467 this.copyNewHeadScriptElements(); 12468 this.removeCurrentHeadProvisionalElements(); 12469 this.copyNewHeadProvisionalElements(); 12470 } 12471 replaceBody() { 12472 this.preservingPermanentElements(() => { 12473 this.activateNewBody(); 12474 this.assignNewBody(); 12475 }); 12476 } 12477 get trackedElementsAreIdentical() { 12478 return this.currentHeadSnapshot.trackedElementSignature == this.newHeadSnapshot.trackedElementSignature; 12479 } 12480 copyNewHeadStylesheetElements() { 12481 for (const element of this.newHeadStylesheetElements) { 12482 document.head.appendChild(element); 12483 } 12484 } 12485 copyNewHeadScriptElements() { 12486 for (const element of this.newHeadScriptElements) { 12487 document.head.appendChild(this.createScriptElement(element)); 12488 } 12489 } 12490 removeCurrentHeadProvisionalElements() { 12491 for (const element of this.currentHeadProvisionalElements) { 12492 document.head.removeChild(element); 12493 } 12494 } 12495 copyNewHeadProvisionalElements() { 12496 for (const element of this.newHeadProvisionalElements) { 12497 document.head.appendChild(element); 12498 } 12499 } 12500 activateNewBody() { 12501 document.adoptNode(this.newElement); 12502 this.activateNewBodyScriptElements(); 12503 } 12504 activateNewBodyScriptElements() { 12505 for (const inertScriptElement of this.newBodyScriptElements) { 12506 const activatedScriptElement = this.createScriptElement(inertScriptElement); 12507 inertScriptElement.replaceWith(activatedScriptElement); 12508 } 12509 } 12510 assignNewBody() { 12511 if (document.body && this.newElement instanceof HTMLBodyElement) { 12512 document.body.replaceWith(this.newElement); 12513 } else { 12514 document.documentElement.appendChild(this.newElement); 12515 } 12516 } 12517 get newHeadStylesheetElements() { 12518 return this.newHeadSnapshot.getStylesheetElementsNotInSnapshot(this.currentHeadSnapshot); 12519 } 12520 get newHeadScriptElements() { 12521 return this.newHeadSnapshot.getScriptElementsNotInSnapshot(this.currentHeadSnapshot); 12522 } 12523 get currentHeadProvisionalElements() { 12524 return this.currentHeadSnapshot.provisionalElements; 12525 } 12526 get newHeadProvisionalElements() { 12527 return this.newHeadSnapshot.provisionalElements; 12528 } 12529 get newBodyScriptElements() { 12530 return this.newElement.querySelectorAll("script"); 12531 } 12532 }; 12533 var SnapshotCache = class { 12534 constructor(size) { 12535 this.keys = []; 12536 this.snapshots = {}; 12537 this.size = size; 12538 } 12539 has(location2) { 12540 return toCacheKey(location2) in this.snapshots; 12541 } 12542 get(location2) { 12543 if (this.has(location2)) { 12544 const snapshot = this.read(location2); 12545 this.touch(location2); 12546 return snapshot; 12547 } 12548 } 12549 put(location2, snapshot) { 12550 this.write(location2, snapshot); 12551 this.touch(location2); 12552 return snapshot; 12553 } 12554 clear() { 12555 this.snapshots = {}; 12556 } 12557 read(location2) { 12558 return this.snapshots[toCacheKey(location2)]; 12559 } 12560 write(location2, snapshot) { 12561 this.snapshots[toCacheKey(location2)] = snapshot; 12562 } 12563 touch(location2) { 12564 const key = toCacheKey(location2); 12565 const index = this.keys.indexOf(key); 12566 if (index > -1) 12567 this.keys.splice(index, 1); 12568 this.keys.unshift(key); 12569 this.trim(); 12570 } 12571 trim() { 12572 for (const key of this.keys.splice(this.size)) { 12573 delete this.snapshots[key]; 12574 } 12575 } 12576 }; 12577 var PageView = class extends View { 12578 constructor() { 12579 super(...arguments); 12580 this.snapshotCache = new SnapshotCache(10); 12581 this.lastRenderedLocation = new URL(location.href); 12582 } 12583 renderPage(snapshot, isPreview = false, willRender = true) { 12584 const renderer = new PageRenderer(this.snapshot, snapshot, isPreview, willRender); 12585 return this.render(renderer); 12586 } 12587 renderError(snapshot) { 12588 const renderer = new ErrorRenderer(this.snapshot, snapshot, false); 12589 return this.render(renderer); 12590 } 12591 clearSnapshotCache() { 12592 this.snapshotCache.clear(); 12593 } 12594 async cacheSnapshot() { 12595 if (this.shouldCacheSnapshot) { 12596 this.delegate.viewWillCacheSnapshot(); 12597 const { snapshot, lastRenderedLocation: location2 } = this; 12598 await nextEventLoopTick(); 12599 const cachedSnapshot = snapshot.clone(); 12600 this.snapshotCache.put(location2, cachedSnapshot); 12601 return cachedSnapshot; 12602 } 12603 } 12604 getCachedSnapshotForLocation(location2) { 12605 return this.snapshotCache.get(location2); 12606 } 12607 get snapshot() { 12608 return PageSnapshot.fromElement(this.element); 12609 } 12610 get shouldCacheSnapshot() { 12611 return this.snapshot.isCacheable; 12612 } 12613 }; 12614 var Session = class { 12615 constructor() { 12616 this.navigator = new Navigator(this); 12617 this.history = new History(this); 12618 this.view = new PageView(this, document.documentElement); 12619 this.adapter = new BrowserAdapter(this); 12620 this.pageObserver = new PageObserver(this); 12621 this.cacheObserver = new CacheObserver(); 12622 this.linkClickObserver = new LinkClickObserver(this); 12623 this.formSubmitObserver = new FormSubmitObserver(this); 12624 this.scrollObserver = new ScrollObserver(this); 12625 this.streamObserver = new StreamObserver(this); 12626 this.frameRedirector = new FrameRedirector(document.documentElement); 12627 this.drive = true; 12628 this.enabled = true; 12629 this.progressBarDelay = 500; 12630 this.started = false; 12631 } 12632 start() { 12633 if (!this.started) { 12634 this.pageObserver.start(); 12635 this.cacheObserver.start(); 12636 this.linkClickObserver.start(); 12637 this.formSubmitObserver.start(); 12638 this.scrollObserver.start(); 12639 this.streamObserver.start(); 12640 this.frameRedirector.start(); 12641 this.history.start(); 12642 this.started = true; 12643 this.enabled = true; 12644 } 12645 } 12646 disable() { 12647 this.enabled = false; 12648 } 12649 stop() { 12650 if (this.started) { 12651 this.pageObserver.stop(); 12652 this.cacheObserver.stop(); 12653 this.linkClickObserver.stop(); 12654 this.formSubmitObserver.stop(); 12655 this.scrollObserver.stop(); 12656 this.streamObserver.stop(); 12657 this.frameRedirector.stop(); 12658 this.history.stop(); 12659 this.started = false; 12660 } 12661 } 12662 registerAdapter(adapter) { 12663 this.adapter = adapter; 12664 } 12665 visit(location2, options2 = {}) { 12666 this.navigator.proposeVisit(expandURL(location2), options2); 12667 } 12668 connectStreamSource(source) { 12669 this.streamObserver.connectStreamSource(source); 12670 } 12671 disconnectStreamSource(source) { 12672 this.streamObserver.disconnectStreamSource(source); 12673 } 12674 renderStreamMessage(message) { 12675 document.documentElement.appendChild(StreamMessage.wrap(message).fragment); 12676 } 12677 clearCache() { 12678 this.view.clearSnapshotCache(); 12679 } 12680 setProgressBarDelay(delay) { 12681 this.progressBarDelay = delay; 12682 } 12683 get location() { 12684 return this.history.location; 12685 } 12686 get restorationIdentifier() { 12687 return this.history.restorationIdentifier; 12688 } 12689 historyPoppedToLocationWithRestorationIdentifier(location2, restorationIdentifier) { 12690 if (this.enabled) { 12691 this.navigator.startVisit(location2, restorationIdentifier, { action: "restore", historyChanged: true }); 12692 } else { 12693 this.adapter.pageInvalidated(); 12694 } 12695 } 12696 scrollPositionChanged(position) { 12697 this.history.updateRestorationData({ scrollPosition: position }); 12698 } 12699 willFollowLinkToLocation(link, location2) { 12700 return this.elementDriveEnabled(link) && locationIsVisitable(location2, this.snapshot.rootLocation) && this.applicationAllowsFollowingLinkToLocation(link, location2); 12701 } 12702 followedLinkToLocation(link, location2) { 12703 const action = this.getActionForLink(link); 12704 this.convertLinkWithMethodClickToFormSubmission(link) || this.visit(location2.href, { action }); 12705 } 12706 convertLinkWithMethodClickToFormSubmission(link) { 12707 const linkMethod = link.getAttribute("data-turbo-method"); 12708 if (linkMethod) { 12709 const form = document.createElement("form"); 12710 form.method = linkMethod; 12711 form.action = link.getAttribute("href") || "undefined"; 12712 form.hidden = true; 12713 if (link.hasAttribute("data-turbo-confirm")) { 12714 form.setAttribute("data-turbo-confirm", link.getAttribute("data-turbo-confirm")); 12715 } 12716 const frame = this.getTargetFrameForLink(link); 12717 if (frame) { 12718 form.setAttribute("data-turbo-frame", frame); 12719 form.addEventListener("turbo:submit-start", () => form.remove()); 12720 } else { 12721 form.addEventListener("submit", () => form.remove()); 12722 } 12723 document.body.appendChild(form); 12724 return dispatch("submit", { cancelable: true, target: form }); 12725 } else { 12726 return false; 12727 } 12728 } 12729 allowsVisitingLocationWithAction(location2, action) { 12730 return this.locationWithActionIsSamePage(location2, action) || this.applicationAllowsVisitingLocation(location2); 12731 } 12732 visitProposedToLocation(location2, options2) { 12733 extendURLWithDeprecatedProperties(location2); 12734 this.adapter.visitProposedToLocation(location2, options2); 12735 } 12736 visitStarted(visit2) { 12737 extendURLWithDeprecatedProperties(visit2.location); 12738 if (!visit2.silent) { 12739 this.notifyApplicationAfterVisitingLocation(visit2.location, visit2.action); 12740 } 12741 } 12742 visitCompleted(visit2) { 12743 this.notifyApplicationAfterPageLoad(visit2.getTimingMetrics()); 12744 } 12745 locationWithActionIsSamePage(location2, action) { 12746 return this.navigator.locationWithActionIsSamePage(location2, action); 12747 } 12748 visitScrolledToSamePageLocation(oldURL, newURL) { 12749 this.notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL); 12750 } 12751 willSubmitForm(form, submitter) { 12752 const action = getAction(form, submitter); 12753 return this.elementDriveEnabled(form) && (!submitter || this.elementDriveEnabled(submitter)) && locationIsVisitable(expandURL(action), this.snapshot.rootLocation); 12754 } 12755 formSubmitted(form, submitter) { 12756 this.navigator.submitForm(form, submitter); 12757 } 12758 pageBecameInteractive() { 12759 this.view.lastRenderedLocation = this.location; 12760 this.notifyApplicationAfterPageLoad(); 12761 } 12762 pageLoaded() { 12763 this.history.assumeControlOfScrollRestoration(); 12764 } 12765 pageWillUnload() { 12766 this.history.relinquishControlOfScrollRestoration(); 12767 } 12768 receivedMessageFromStream(message) { 12769 this.renderStreamMessage(message); 12770 } 12771 viewWillCacheSnapshot() { 12772 var _a; 12773 if (!((_a = this.navigator.currentVisit) === null || _a === void 0 ? void 0 : _a.silent)) { 12774 this.notifyApplicationBeforeCachingSnapshot(); 12775 } 12776 } 12777 allowsImmediateRender({ element }, resume) { 12778 const event = this.notifyApplicationBeforeRender(element, resume); 12779 return !event.defaultPrevented; 12780 } 12781 viewRenderedSnapshot(snapshot, isPreview) { 12782 this.view.lastRenderedLocation = this.history.location; 12783 this.notifyApplicationAfterRender(); 12784 } 12785 viewInvalidated() { 12786 this.adapter.pageInvalidated(); 12787 } 12788 frameLoaded(frame) { 12789 this.notifyApplicationAfterFrameLoad(frame); 12790 } 12791 frameRendered(fetchResponse, frame) { 12792 this.notifyApplicationAfterFrameRender(fetchResponse, frame); 12793 } 12794 applicationAllowsFollowingLinkToLocation(link, location2) { 12795 const event = this.notifyApplicationAfterClickingLinkToLocation(link, location2); 12796 return !event.defaultPrevented; 12797 } 12798 applicationAllowsVisitingLocation(location2) { 12799 const event = this.notifyApplicationBeforeVisitingLocation(location2); 12800 return !event.defaultPrevented; 12801 } 12802 notifyApplicationAfterClickingLinkToLocation(link, location2) { 12803 return dispatch("turbo:click", { target: link, detail: { url: location2.href }, cancelable: true }); 12804 } 12805 notifyApplicationBeforeVisitingLocation(location2) { 12806 return dispatch("turbo:before-visit", { detail: { url: location2.href }, cancelable: true }); 12807 } 12808 notifyApplicationAfterVisitingLocation(location2, action) { 12809 markAsBusy(document.documentElement); 12810 return dispatch("turbo:visit", { detail: { url: location2.href, action } }); 12811 } 12812 notifyApplicationBeforeCachingSnapshot() { 12813 return dispatch("turbo:before-cache"); 12814 } 12815 notifyApplicationBeforeRender(newBody, resume) { 12816 return dispatch("turbo:before-render", { detail: { newBody, resume }, cancelable: true }); 12817 } 12818 notifyApplicationAfterRender() { 12819 return dispatch("turbo:render"); 12820 } 12821 notifyApplicationAfterPageLoad(timing = {}) { 12822 clearBusyState(document.documentElement); 12823 return dispatch("turbo:load", { detail: { url: this.location.href, timing } }); 12824 } 12825 notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL) { 12826 dispatchEvent(new HashChangeEvent("hashchange", { oldURL: oldURL.toString(), newURL: newURL.toString() })); 12827 } 12828 notifyApplicationAfterFrameLoad(frame) { 12829 return dispatch("turbo:frame-load", { target: frame }); 12830 } 12831 notifyApplicationAfterFrameRender(fetchResponse, frame) { 12832 return dispatch("turbo:frame-render", { detail: { fetchResponse }, target: frame, cancelable: true }); 12833 } 12834 elementDriveEnabled(element) { 12835 const container = element === null || element === void 0 ? void 0 : element.closest("[data-turbo]"); 12836 if (this.drive) { 12837 if (container) { 12838 return container.getAttribute("data-turbo") != "false"; 12839 } else { 12840 return true; 12841 } 12842 } else { 12843 if (container) { 12844 return container.getAttribute("data-turbo") == "true"; 12845 } else { 12846 return false; 12847 } 12848 } 12849 } 12850 getActionForLink(link) { 12851 const action = link.getAttribute("data-turbo-action"); 12852 return isAction(action) ? action : "advance"; 12853 } 12854 getTargetFrameForLink(link) { 12855 const frame = link.getAttribute("data-turbo-frame"); 12856 if (frame) { 12857 return frame; 12858 } else { 12859 const container = link.closest("turbo-frame"); 12860 if (container) { 12861 return container.id; 12862 } 12863 } 12864 } 12865 get snapshot() { 12866 return this.view.snapshot; 12867 } 12868 }; 12869 function extendURLWithDeprecatedProperties(url) { 12870 Object.defineProperties(url, deprecatedLocationPropertyDescriptors); 12871 } 12872 var deprecatedLocationPropertyDescriptors = { 12873 absoluteURL: { 12874 get() { 12875 return this.toString(); 12876 } 12877 } 12878 }; 12879 var session = new Session(); 12880 var { navigator: navigator$1 } = session; 12881 function start() { 12882 session.start(); 12883 } 12884 function registerAdapter(adapter) { 12885 session.registerAdapter(adapter); 12886 } 12887 function visit(location2, options2) { 12888 session.visit(location2, options2); 12889 } 12890 function connectStreamSource(source) { 12891 session.connectStreamSource(source); 12892 } 12893 function disconnectStreamSource(source) { 12894 session.disconnectStreamSource(source); 12895 } 12896 function renderStreamMessage(message) { 12897 session.renderStreamMessage(message); 12898 } 12899 function clearCache() { 12900 session.clearCache(); 12901 } 12902 function setProgressBarDelay(delay) { 12903 session.setProgressBarDelay(delay); 12904 } 12905 function setConfirmMethod(confirmMethod) { 12906 FormSubmission.confirmMethod = confirmMethod; 12907 } 12908 var Turbo = /* @__PURE__ */ Object.freeze({ 12909 __proto__: null, 12910 navigator: navigator$1, 12911 session, 12912 PageRenderer, 12913 PageSnapshot, 12914 start, 12915 registerAdapter, 12916 visit, 12917 connectStreamSource, 12918 disconnectStreamSource, 12919 renderStreamMessage, 12920 clearCache, 12921 setProgressBarDelay, 12922 setConfirmMethod 12923 }); 12924 var FrameController = class { 12925 constructor(element) { 12926 this.fetchResponseLoaded = (fetchResponse) => { 12927 }; 12928 this.currentFetchRequest = null; 12929 this.resolveVisitPromise = () => { 12930 }; 12931 this.connected = false; 12932 this.hasBeenLoaded = false; 12933 this.settingSourceURL = false; 12934 this.element = element; 12935 this.view = new FrameView(this, this.element); 12936 this.appearanceObserver = new AppearanceObserver(this, this.element); 12937 this.linkInterceptor = new LinkInterceptor(this, this.element); 12938 this.formInterceptor = new FormInterceptor(this, this.element); 12939 } 12940 connect() { 12941 if (!this.connected) { 12942 this.connected = true; 12943 this.reloadable = false; 12944 if (this.loadingStyle == FrameLoadingStyle.lazy) { 12945 this.appearanceObserver.start(); 12946 } 12947 this.linkInterceptor.start(); 12948 this.formInterceptor.start(); 12949 this.sourceURLChanged(); 12950 } 12951 } 12952 disconnect() { 12953 if (this.connected) { 12954 this.connected = false; 12955 this.appearanceObserver.stop(); 12956 this.linkInterceptor.stop(); 12957 this.formInterceptor.stop(); 12958 } 12959 } 12960 disabledChanged() { 12961 if (this.loadingStyle == FrameLoadingStyle.eager) { 12962 this.loadSourceURL(); 12963 } 12964 } 12965 sourceURLChanged() { 12966 if (this.loadingStyle == FrameLoadingStyle.eager || this.hasBeenLoaded) { 12967 this.loadSourceURL(); 12968 } 12969 } 12970 loadingStyleChanged() { 12971 if (this.loadingStyle == FrameLoadingStyle.lazy) { 12972 this.appearanceObserver.start(); 12973 } else { 12974 this.appearanceObserver.stop(); 12975 this.loadSourceURL(); 12976 } 12977 } 12978 async loadSourceURL() { 12979 if (!this.settingSourceURL && this.enabled && this.isActive && (this.reloadable || this.sourceURL != this.currentURL)) { 12980 const previousURL = this.currentURL; 12981 this.currentURL = this.sourceURL; 12982 if (this.sourceURL) { 12983 try { 12984 this.element.loaded = this.visit(expandURL(this.sourceURL)); 12985 this.appearanceObserver.stop(); 12986 await this.element.loaded; 12987 this.hasBeenLoaded = true; 12988 } catch (error2) { 12989 this.currentURL = previousURL; 12990 throw error2; 12991 } 12992 } 12993 } 12994 } 12995 async loadResponse(fetchResponse) { 12996 if (fetchResponse.redirected || fetchResponse.succeeded && fetchResponse.isHTML) { 12997 this.sourceURL = fetchResponse.response.url; 12998 } 12999 try { 13000 const html = await fetchResponse.responseHTML; 13001 if (html) { 13002 const { body } = parseHTMLDocument(html); 13003 const snapshot = new Snapshot(await this.extractForeignFrameElement(body)); 13004 const renderer = new FrameRenderer(this.view.snapshot, snapshot, false, false); 13005 if (this.view.renderPromise) 13006 await this.view.renderPromise; 13007 await this.view.render(renderer); 13008 session.frameRendered(fetchResponse, this.element); 13009 session.frameLoaded(this.element); 13010 this.fetchResponseLoaded(fetchResponse); 13011 } 13012 } catch (error2) { 13013 console.error(error2); 13014 this.view.invalidate(); 13015 } finally { 13016 this.fetchResponseLoaded = () => { 13017 }; 13018 } 13019 } 13020 elementAppearedInViewport(element) { 13021 this.loadSourceURL(); 13022 } 13023 shouldInterceptLinkClick(element, url) { 13024 if (element.hasAttribute("data-turbo-method")) { 13025 return false; 13026 } else { 13027 return this.shouldInterceptNavigation(element); 13028 } 13029 } 13030 linkClickIntercepted(element, url) { 13031 this.reloadable = true; 13032 this.navigateFrame(element, url); 13033 } 13034 shouldInterceptFormSubmission(element, submitter) { 13035 return this.shouldInterceptNavigation(element, submitter); 13036 } 13037 formSubmissionIntercepted(element, submitter) { 13038 if (this.formSubmission) { 13039 this.formSubmission.stop(); 13040 } 13041 this.reloadable = false; 13042 this.formSubmission = new FormSubmission(this, element, submitter); 13043 const { fetchRequest } = this.formSubmission; 13044 this.prepareHeadersForRequest(fetchRequest.headers, fetchRequest); 13045 this.formSubmission.start(); 13046 } 13047 prepareHeadersForRequest(headers, request) { 13048 headers["Turbo-Frame"] = this.id; 13049 } 13050 requestStarted(request) { 13051 markAsBusy(this.element); 13052 } 13053 requestPreventedHandlingResponse(request, response) { 13054 this.resolveVisitPromise(); 13055 } 13056 async requestSucceededWithResponse(request, response) { 13057 await this.loadResponse(response); 13058 this.resolveVisitPromise(); 13059 } 13060 requestFailedWithResponse(request, response) { 13061 console.error(response); 13062 this.resolveVisitPromise(); 13063 } 13064 requestErrored(request, error2) { 13065 console.error(error2); 13066 this.resolveVisitPromise(); 13067 } 13068 requestFinished(request) { 13069 clearBusyState(this.element); 13070 } 13071 formSubmissionStarted({ formElement }) { 13072 markAsBusy(formElement, this.findFrameElement(formElement)); 13073 } 13074 formSubmissionSucceededWithResponse(formSubmission, response) { 13075 const frame = this.findFrameElement(formSubmission.formElement, formSubmission.submitter); 13076 this.proposeVisitIfNavigatedWithAction(frame, formSubmission.formElement, formSubmission.submitter); 13077 frame.delegate.loadResponse(response); 13078 } 13079 formSubmissionFailedWithResponse(formSubmission, fetchResponse) { 13080 this.element.delegate.loadResponse(fetchResponse); 13081 } 13082 formSubmissionErrored(formSubmission, error2) { 13083 console.error(error2); 13084 } 13085 formSubmissionFinished({ formElement }) { 13086 clearBusyState(formElement, this.findFrameElement(formElement)); 13087 } 13088 allowsImmediateRender(snapshot, resume) { 13089 return true; 13090 } 13091 viewRenderedSnapshot(snapshot, isPreview) { 13092 } 13093 viewInvalidated() { 13094 } 13095 async visit(url) { 13096 var _a; 13097 const request = new FetchRequest(this, FetchMethod.get, url, new URLSearchParams(), this.element); 13098 (_a = this.currentFetchRequest) === null || _a === void 0 ? void 0 : _a.cancel(); 13099 this.currentFetchRequest = request; 13100 return new Promise((resolve) => { 13101 this.resolveVisitPromise = () => { 13102 this.resolveVisitPromise = () => { 13103 }; 13104 this.currentFetchRequest = null; 13105 resolve(); 13106 }; 13107 request.perform(); 13108 }); 13109 } 13110 navigateFrame(element, url, submitter) { 13111 const frame = this.findFrameElement(element, submitter); 13112 this.proposeVisitIfNavigatedWithAction(frame, element, submitter); 13113 frame.setAttribute("reloadable", ""); 13114 frame.src = url; 13115 } 13116 proposeVisitIfNavigatedWithAction(frame, element, submitter) { 13117 const action = getAttribute("data-turbo-action", submitter, element, frame); 13118 if (isAction(action)) { 13119 const { visitCachedSnapshot } = new SnapshotSubstitution(frame); 13120 frame.delegate.fetchResponseLoaded = (fetchResponse) => { 13121 if (frame.src) { 13122 const { statusCode, redirected } = fetchResponse; 13123 const responseHTML = frame.ownerDocument.documentElement.outerHTML; 13124 const response = { statusCode, redirected, responseHTML }; 13125 session.visit(frame.src, { action, response, visitCachedSnapshot, willRender: false }); 13126 } 13127 }; 13128 } 13129 } 13130 findFrameElement(element, submitter) { 13131 var _a; 13132 const id = getAttribute("data-turbo-frame", submitter, element) || this.element.getAttribute("target"); 13133 return (_a = getFrameElementById(id)) !== null && _a !== void 0 ? _a : this.element; 13134 } 13135 async extractForeignFrameElement(container) { 13136 let element; 13137 const id = CSS.escape(this.id); 13138 try { 13139 if (element = activateElement(container.querySelector(`turbo-frame#${id}`), this.currentURL)) { 13140 return element; 13141 } 13142 if (element = activateElement(container.querySelector(`turbo-frame[src][recurse~=${id}]`), this.currentURL)) { 13143 await element.loaded; 13144 return await this.extractForeignFrameElement(element); 13145 } 13146 console.error(`Response has no matching <turbo-frame id="${id}"> element`); 13147 } catch (error2) { 13148 console.error(error2); 13149 } 13150 return new FrameElement(); 13151 } 13152 formActionIsVisitable(form, submitter) { 13153 const action = getAction(form, submitter); 13154 return locationIsVisitable(expandURL(action), this.rootLocation); 13155 } 13156 shouldInterceptNavigation(element, submitter) { 13157 const id = getAttribute("data-turbo-frame", submitter, element) || this.element.getAttribute("target"); 13158 if (element instanceof HTMLFormElement && !this.formActionIsVisitable(element, submitter)) { 13159 return false; 13160 } 13161 if (!this.enabled || id == "_top") { 13162 return false; 13163 } 13164 if (id) { 13165 const frameElement = getFrameElementById(id); 13166 if (frameElement) { 13167 return !frameElement.disabled; 13168 } 13169 } 13170 if (!session.elementDriveEnabled(element)) { 13171 return false; 13172 } 13173 if (submitter && !session.elementDriveEnabled(submitter)) { 13174 return false; 13175 } 13176 return true; 13177 } 13178 get id() { 13179 return this.element.id; 13180 } 13181 get enabled() { 13182 return !this.element.disabled; 13183 } 13184 get sourceURL() { 13185 if (this.element.src) { 13186 return this.element.src; 13187 } 13188 } 13189 get reloadable() { 13190 const frame = this.findFrameElement(this.element); 13191 return frame.hasAttribute("reloadable"); 13192 } 13193 set reloadable(value) { 13194 const frame = this.findFrameElement(this.element); 13195 if (value) { 13196 frame.setAttribute("reloadable", ""); 13197 } else { 13198 frame.removeAttribute("reloadable"); 13199 } 13200 } 13201 set sourceURL(sourceURL) { 13202 this.settingSourceURL = true; 13203 this.element.src = sourceURL !== null && sourceURL !== void 0 ? sourceURL : null; 13204 this.currentURL = this.element.src; 13205 this.settingSourceURL = false; 13206 } 13207 get loadingStyle() { 13208 return this.element.loading; 13209 } 13210 get isLoading() { 13211 return this.formSubmission !== void 0 || this.resolveVisitPromise() !== void 0; 13212 } 13213 get isActive() { 13214 return this.element.isActive && this.connected; 13215 } 13216 get rootLocation() { 13217 var _a; 13218 const meta = this.element.ownerDocument.querySelector(`meta[name="turbo-root"]`); 13219 const root = (_a = meta === null || meta === void 0 ? void 0 : meta.content) !== null && _a !== void 0 ? _a : "/"; 13220 return expandURL(root); 13221 } 13222 }; 13223 var SnapshotSubstitution = class { 13224 constructor(element) { 13225 this.visitCachedSnapshot = ({ element: element2 }) => { 13226 var _a; 13227 const { id, clone } = this; 13228 (_a = element2.querySelector("#" + id)) === null || _a === void 0 ? void 0 : _a.replaceWith(clone); 13229 }; 13230 this.clone = element.cloneNode(true); 13231 this.id = element.id; 13232 } 13233 }; 13234 function getFrameElementById(id) { 13235 if (id != null) { 13236 const element = document.getElementById(id); 13237 if (element instanceof FrameElement) { 13238 return element; 13239 } 13240 } 13241 } 13242 function activateElement(element, currentURL) { 13243 if (element) { 13244 const src = element.getAttribute("src"); 13245 if (src != null && currentURL != null && urlsAreEqual(src, currentURL)) { 13246 throw new Error(`Matching <turbo-frame id="${element.id}"> element has a source URL which references itself`); 13247 } 13248 if (element.ownerDocument !== document) { 13249 element = document.importNode(element, true); 13250 } 13251 if (element instanceof FrameElement) { 13252 element.connectedCallback(); 13253 element.disconnectedCallback(); 13254 return element; 13255 } 13256 } 13257 } 13258 var StreamActions = { 13259 after() { 13260 this.targetElements.forEach((e2) => { 13261 var _a; 13262 return (_a = e2.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(this.templateContent, e2.nextSibling); 13263 }); 13264 }, 13265 append() { 13266 this.removeDuplicateTargetChildren(); 13267 this.targetElements.forEach((e2) => e2.append(this.templateContent)); 13268 }, 13269 before() { 13270 this.targetElements.forEach((e2) => { 13271 var _a; 13272 return (_a = e2.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(this.templateContent, e2); 13273 }); 13274 }, 13275 prepend() { 13276 this.removeDuplicateTargetChildren(); 13277 this.targetElements.forEach((e2) => e2.prepend(this.templateContent)); 13278 }, 13279 remove() { 13280 this.targetElements.forEach((e2) => e2.remove()); 13281 }, 13282 replace() { 13283 this.targetElements.forEach((e2) => e2.replaceWith(this.templateContent)); 13284 }, 13285 update() { 13286 this.targetElements.forEach((e2) => { 13287 e2.innerHTML = ""; 13288 e2.append(this.templateContent); 13289 }); 13290 } 13291 }; 13292 var StreamElement = class extends HTMLElement { 13293 async connectedCallback() { 13294 try { 13295 await this.render(); 13296 } catch (error2) { 13297 console.error(error2); 13298 } finally { 13299 this.disconnect(); 13300 } 13301 } 13302 async render() { 13303 var _a; 13304 return (_a = this.renderPromise) !== null && _a !== void 0 ? _a : this.renderPromise = (async () => { 13305 if (this.dispatchEvent(this.beforeRenderEvent)) { 13306 await nextAnimationFrame(); 13307 this.performAction(); 13308 } 13309 })(); 13310 } 13311 disconnect() { 13312 try { 13313 this.remove(); 13314 } catch (_a) { 13315 } 13316 } 13317 removeDuplicateTargetChildren() { 13318 this.duplicateChildren.forEach((c) => c.remove()); 13319 } 13320 get duplicateChildren() { 13321 var _a; 13322 const existingChildren = this.targetElements.flatMap((e2) => [...e2.children]).filter((c) => !!c.id); 13323 const newChildrenIds = [...(_a = this.templateContent) === null || _a === void 0 ? void 0 : _a.children].filter((c) => !!c.id).map((c) => c.id); 13324 return existingChildren.filter((c) => newChildrenIds.includes(c.id)); 13325 } 13326 get performAction() { 13327 if (this.action) { 13328 const actionFunction = StreamActions[this.action]; 13329 if (actionFunction) { 13330 return actionFunction; 13331 } 13332 this.raise("unknown action"); 13333 } 13334 this.raise("action attribute is missing"); 13335 } 13336 get targetElements() { 13337 if (this.target) { 13338 return this.targetElementsById; 13339 } else if (this.targets) { 13340 return this.targetElementsByQuery; 13341 } else { 13342 this.raise("target or targets attribute is missing"); 13343 } 13344 } 13345 get templateContent() { 13346 return this.templateElement.content.cloneNode(true); 13347 } 13348 get templateElement() { 13349 if (this.firstElementChild instanceof HTMLTemplateElement) { 13350 return this.firstElementChild; 13351 } 13352 this.raise("first child element must be a <template> element"); 13353 } 13354 get action() { 13355 return this.getAttribute("action"); 13356 } 13357 get target() { 13358 return this.getAttribute("target"); 13359 } 13360 get targets() { 13361 return this.getAttribute("targets"); 13362 } 13363 raise(message) { 13364 throw new Error(`${this.description}: ${message}`); 13365 } 13366 get description() { 13367 var _a, _b; 13368 return (_b = ((_a = this.outerHTML.match(/<[^>]+>/)) !== null && _a !== void 0 ? _a : [])[0]) !== null && _b !== void 0 ? _b : "<turbo-stream>"; 13369 } 13370 get beforeRenderEvent() { 13371 return new CustomEvent("turbo:before-stream-render", { bubbles: true, cancelable: true }); 13372 } 13373 get targetElementsById() { 13374 var _a; 13375 const element = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.getElementById(this.target); 13376 if (element !== null) { 13377 return [element]; 13378 } else { 13379 return []; 13380 } 13381 } 13382 get targetElementsByQuery() { 13383 var _a; 13384 const elements3 = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.querySelectorAll(this.targets); 13385 if (elements3.length !== 0) { 13386 return Array.prototype.slice.call(elements3); 13387 } else { 13388 return []; 13389 } 13390 } 13391 }; 13392 FrameElement.delegateConstructor = FrameController; 13393 customElements.define("turbo-frame", FrameElement); 13394 customElements.define("turbo-stream", StreamElement); 13395 (() => { 13396 let element = document.currentScript; 13397 if (!element) 13398 return; 13399 if (element.hasAttribute("data-turbo-suppress-warning")) 13400 return; 13401 while (element = element.parentElement) { 13402 if (element == document.body) { 13403 return console.warn(unindent` 13404 You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do! 13405 13406 Load your applicationâs JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change. 13407 13408 For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements 13409 13410 ââ 13411 Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s 13412 `, element.outerHTML); 13413 } 13414 } 13415 })(); 13416 window.Turbo = Turbo; 13417 start(); 13418 13419
vendor: 613 bytes, lines 13419-13436
13419// ../../node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable.js 13420 var consumer; 13421 async function getConsumer() { 13422 return consumer || setConsumer(createConsumer2().then(setConsumer)); 13423 } 13424 function setConsumer(newConsumer) { 13425 return consumer = newConsumer; 13426 } 13427 async function createConsumer2() { 13428 const { createConsumer: createConsumer4 } = await Promise.resolve().then(() => (init_src(), src_exports)); 13429 return createConsumer4(); 13430 } 13431 async function subscribeTo(channel, mixin) { 13432 const { subscriptions } = await getConsumer(); 13433 return subscriptions.create(channel, mixin); 13434 } 13435 13436
vendor: 914 bytes, lines 13436-13459
13436// ../../node_modules/@hotwired/turbo-rails/app/javascript/turbo/cable_stream_source_element.js 13437 var TurboCableStreamSourceElement = class extends HTMLElement { 13438 async connectedCallback() { 13439 connectStreamSource(this); 13440 this.subscription = await subscribeTo(this.channel, { received: this.dispatchMessageEvent.bind(this) }); 13441 } 13442 disconnectedCallback() { 13443 disconnectStreamSource(this); 13444 if (this.subscription) 13445 this.subscription.unsubscribe(); 13446 } 13447 dispatchMessageEvent(data) { 13448 const event = new MessageEvent("message", { data }); 13449 return this.dispatchEvent(event); 13450 } 13451 get channel() { 13452 const channel = this.getAttribute("channel"); 13453 const signed_stream_name = this.getAttribute("signed-stream-name"); 13454 return { channel, signed_stream_name }; 13455 } 13456 }; 13457 customElements.define("turbo-cable-stream-source", TurboCableStreamSourceElement); 13458 13459
vendor: 1,382 bytes, lines 13459-13496
13459// ../../node_modules/@rails/actiontext/app/javascript/actiontext/attachment_upload.js 13460 var import_activestorage = __toESM(require_activestorage(), 1); 13461 var AttachmentUpload = class { 13462 constructor(attachment, element) { 13463 this.attachment = attachment; 13464 this.element = element; 13465 this.directUpload = new import_activestorage.DirectUpload(attachment.file, this.directUploadUrl, this); 13466 } 13467 start() { 13468 this.directUpload.create(this.directUploadDidComplete.bind(this)); 13469 } 13470 directUploadWillStoreFileWithXHR(xhr) { 13471 xhr.upload.addEventListener("progress", (event) => { 13472 const progress = event.loaded / event.total * 100; 13473 this.attachment.setUploadProgress(progress); 13474 }); 13475 } 13476 directUploadDidComplete(error2, attributes) { 13477 if (error2) { 13478 throw new Error(`Direct upload failed: ${error2}`); 13479 } 13480 this.attachment.setAttributes({ 13481 sgid: attributes.attachable_sgid, 13482 url: this.createBlobUrl(attributes.signed_id, attributes.filename) 13483 }); 13484 } 13485 createBlobUrl(signedId, filename) { 13486 return this.blobUrlTemplate.replace(":signed_id", signedId).replace(":filename", encodeURIComponent(filename)); 13487 } 13488 get directUploadUrl() { 13489 return this.element.dataset.directUploadUrl; 13490 } 13491 get blobUrlTemplate() { 13492 return this.element.dataset.blobUrlTemplate; 13493 } 13494 }; 13495 13496
vendor: 299 bytes, lines 13496-13505
13496// ../../node_modules/@rails/actiontext/app/javascript/actiontext/index.js 13497 addEventListener("trix-attachment-add", (event) => { 13498 const { attachment, target } = event; 13499 if (attachment.file) { 13500 const upload = new AttachmentUpload(attachment, target); 13501 upload.start(); 13502 } 13503 }); 13504 13505
vendor: 61,400 bytes, lines 13505-15371
13505// ../../node_modules/@hotwired/stimulus/dist/stimulus.js 13506 var EventListener = class { 13507 constructor(eventTarget, eventName, eventOptions) { 13508 this.eventTarget = eventTarget; 13509 this.eventName = eventName; 13510 this.eventOptions = eventOptions; 13511 this.unorderedBindings = /* @__PURE__ */ new Set(); 13512 } 13513 connect() { 13514 this.eventTarget.addEventListener(this.eventName, this, this.eventOptions); 13515 } 13516 disconnect() { 13517 this.eventTarget.removeEventListener(this.eventName, this, this.eventOptions); 13518 } 13519 bindingConnected(binding) { 13520 this.unorderedBindings.add(binding); 13521 } 13522 bindingDisconnected(binding) { 13523 this.unorderedBindings.delete(binding); 13524 } 13525 handleEvent(event) { 13526 const extendedEvent = extendEvent(event); 13527 for (const binding of this.bindings) { 13528 if (extendedEvent.immediatePropagationStopped) { 13529 break; 13530 } else { 13531 binding.handleEvent(extendedEvent); 13532 } 13533 } 13534 } 13535 get bindings() { 13536 return Array.from(this.unorderedBindings).sort((left2, right2) => { 13537 const leftIndex = left2.index, rightIndex = right2.index; 13538 return leftIndex < rightIndex ? -1 : leftIndex > rightIndex ? 1 : 0; 13539 }); 13540 } 13541 }; 13542 function extendEvent(event) { 13543 if ("immediatePropagationStopped" in event) { 13544 return event; 13545 } else { 13546 const { stopImmediatePropagation } = event; 13547 return Object.assign(event, { 13548 immediatePropagationStopped: false, 13549 stopImmediatePropagation() { 13550 this.immediatePropagationStopped = true; 13551 stopImmediatePropagation.call(this); 13552 } 13553 }); 13554 } 13555 } 13556 var Dispatcher = class { 13557 constructor(application2) { 13558 this.application = application2; 13559 this.eventListenerMaps = /* @__PURE__ */ new Map(); 13560 this.started = false; 13561 } 13562 start() { 13563 if (!this.started) { 13564 this.started = true; 13565 this.eventListeners.forEach((eventListener) => eventListener.connect()); 13566 } 13567 } 13568 stop() { 13569 if (this.started) { 13570 this.started = false; 13571 this.eventListeners.forEach((eventListener) => eventListener.disconnect()); 13572 } 13573 } 13574 get eventListeners() { 13575 return Array.from(this.eventListenerMaps.values()).reduce((listeners, map) => listeners.concat(Array.from(map.values())), []); 13576 } 13577 bindingConnected(binding) { 13578 this.fetchEventListenerForBinding(binding).bindingConnected(binding); 13579 } 13580 bindingDisconnected(binding) { 13581 this.fetchEventListenerForBinding(binding).bindingDisconnected(binding); 13582 } 13583 handleError(error2, message, detail = {}) { 13584 this.application.handleError(error2, `Error ${message}`, detail); 13585 } 13586 fetchEventListenerForBinding(binding) { 13587 const { eventTarget, eventName, eventOptions } = binding; 13588 return this.fetchEventListener(eventTarget, eventName, eventOptions); 13589 } 13590 fetchEventListener(eventTarget, eventName, eventOptions) { 13591 const eventListenerMap = this.fetchEventListenerMapForEventTarget(eventTarget); 13592 const cacheKey = this.cacheKey(eventName, eventOptions); 13593 let eventListener = eventListenerMap.get(cacheKey); 13594 if (!eventListener) { 13595 eventListener = this.createEventListener(eventTarget, eventName, eventOptions); 13596 eventListenerMap.set(cacheKey, eventListener); 13597 } 13598 return eventListener; 13599 } 13600 createEventListener(eventTarget, eventName, eventOptions) { 13601 const eventListener = new EventListener(eventTarget, eventName, eventOptions); 13602 if (this.started) { 13603 eventListener.connect(); 13604 } 13605 return eventListener; 13606 } 13607 fetchEventListenerMapForEventTarget(eventTarget) { 13608 let eventListenerMap = this.eventListenerMaps.get(eventTarget); 13609 if (!eventListenerMap) { 13610 eventListenerMap = /* @__PURE__ */ new Map(); 13611 this.eventListenerMaps.set(eventTarget, eventListenerMap); 13612 } 13613 return eventListenerMap; 13614 } 13615 cacheKey(eventName, eventOptions) { 13616 const parts = [eventName]; 13617 Object.keys(eventOptions).sort().forEach((key) => { 13618 parts.push(`${eventOptions[key] ? "" : "!"}${key}`); 13619 }); 13620 return parts.join(":"); 13621 } 13622 }; 13623 var descriptorPattern = /^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/; 13624 function parseActionDescriptorString(descriptorString) { 13625 const source = descriptorString.trim(); 13626 const matches = source.match(descriptorPattern) || []; 13627 return { 13628 eventTarget: parseEventTarget(matches[4]), 13629 eventName: matches[2], 13630 eventOptions: matches[9] ? parseEventOptions(matches[9]) : {}, 13631 identifier: matches[5], 13632 methodName: matches[7] 13633 }; 13634 } 13635 function parseEventTarget(eventTargetName) { 13636 if (eventTargetName == "window") { 13637 return window; 13638 } else if (eventTargetName == "document") { 13639 return document; 13640 } 13641 } 13642 function parseEventOptions(eventOptions) { 13643 return eventOptions.split(":").reduce((options2, token) => Object.assign(options2, { [token.replace(/^!/, "")]: !/^!/.test(token) }), {}); 13644 } 13645 function stringifyEventTarget(eventTarget) { 13646 if (eventTarget == window) { 13647 return "window"; 13648 } else if (eventTarget == document) { 13649 return "document"; 13650 } 13651 } 13652 function camelize(value) { 13653 return value.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase()); 13654 } 13655 function capitalize(value) { 13656 return value.charAt(0).toUpperCase() + value.slice(1); 13657 } 13658 function dasherize(value) { 13659 return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`); 13660 } 13661 function tokenize(value) { 13662 return value.match(/[^\s]+/g) || []; 13663 } 13664 var Action = class { 13665 constructor(element, index, descriptor) { 13666 this.element = element; 13667 this.index = index; 13668 this.eventTarget = descriptor.eventTarget || element; 13669 this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name"); 13670 this.eventOptions = descriptor.eventOptions || {}; 13671 this.identifier = descriptor.identifier || error("missing identifier"); 13672 this.methodName = descriptor.methodName || error("missing method name"); 13673 } 13674 static forToken(token) { 13675 return new this(token.element, token.index, parseActionDescriptorString(token.content)); 13676 } 13677 toString() { 13678 const eventNameSuffix = this.eventTargetName ? `@${this.eventTargetName}` : ""; 13679 return `${this.eventName}${eventNameSuffix}->${this.identifier}#${this.methodName}`; 13680 } 13681 get params() { 13682 if (this.eventTarget instanceof Element) { 13683 return this.getParamsFromEventTargetAttributes(this.eventTarget); 13684 } else { 13685 return {}; 13686 } 13687 } 13688 getParamsFromEventTargetAttributes(eventTarget) { 13689 const params = {}; 13690 const pattern = new RegExp(`^data-${this.identifier}-(.+)-param$`); 13691 const attributes = Array.from(eventTarget.attributes); 13692 attributes.forEach(({ name, value }) => { 13693 const match = name.match(pattern); 13694 const key = match && match[1]; 13695 if (key) { 13696 Object.assign(params, { [camelize(key)]: typecast(value) }); 13697 } 13698 }); 13699 return params; 13700 } 13701 get eventTargetName() { 13702 return stringifyEventTarget(this.eventTarget); 13703 } 13704 }; 13705 var defaultEventNames = { 13706 "a": (e2) => "click", 13707 "button": (e2) => "click", 13708 "form": (e2) => "submit", 13709 "details": (e2) => "toggle", 13710 "input": (e2) => e2.getAttribute("type") == "submit" ? "click" : "input", 13711 "select": (e2) => "change", 13712 "textarea": (e2) => "input" 13713 }; 13714 function getDefaultEventNameForElement(element) { 13715 const tagName = element.tagName.toLowerCase(); 13716 if (tagName in defaultEventNames) { 13717 return defaultEventNames[tagName](element); 13718 } 13719 } 13720 function error(message) { 13721 throw new Error(message); 13722 } 13723 function typecast(value) { 13724 try { 13725 return JSON.parse(value); 13726 } catch (o_O) { 13727 return value; 13728 } 13729 } 13730 var Binding = class { 13731 constructor(context, action) { 13732 this.context = context; 13733 this.action = action; 13734 } 13735 get index() { 13736 return this.action.index; 13737 } 13738 get eventTarget() { 13739 return this.action.eventTarget; 13740 } 13741 get eventOptions() { 13742 return this.action.eventOptions; 13743 } 13744 get identifier() { 13745 return this.context.identifier; 13746 } 13747 handleEvent(event) { 13748 if (this.willBeInvokedByEvent(event)) { 13749 this.invokeWithEvent(event); 13750 } 13751 } 13752 get eventName() { 13753 return this.action.eventName; 13754 } 13755 get method() { 13756 const method = this.controller[this.methodName]; 13757 if (typeof method == "function") { 13758 return method; 13759 } 13760 throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`); 13761 } 13762 invokeWithEvent(event) { 13763 const { target, currentTarget } = event; 13764 try { 13765 const { params } = this.action; 13766 const actionEvent = Object.assign(event, { params }); 13767 this.method.call(this.controller, actionEvent); 13768 this.context.logDebugActivity(this.methodName, { event, target, currentTarget, action: this.methodName }); 13769 } catch (error2) { 13770 const { identifier, controller, element, index } = this; 13771 const detail = { identifier, controller, element, index, event }; 13772 this.context.handleError(error2, `invoking action "${this.action}"`, detail); 13773 } 13774 } 13775 willBeInvokedByEvent(event) { 13776 const eventTarget = event.target; 13777 if (this.element === eventTarget) { 13778 return true; 13779 } else if (eventTarget instanceof Element && this.element.contains(eventTarget)) { 13780 return this.scope.containsElement(eventTarget); 13781 } else { 13782 return this.scope.containsElement(this.action.element); 13783 } 13784 } 13785 get controller() { 13786 return this.context.controller; 13787 } 13788 get methodName() { 13789 return this.action.methodName; 13790 } 13791 get element() { 13792 return this.scope.element; 13793 } 13794 get scope() { 13795 return this.context.scope; 13796 } 13797 }; 13798 var ElementObserver = class { 13799 constructor(element, delegate) { 13800 this.mutationObserverInit = { attributes: true, childList: true, subtree: true }; 13801 this.element = element; 13802 this.started = false; 13803 this.delegate = delegate; 13804 this.elements = /* @__PURE__ */ new Set(); 13805 this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations)); 13806 } 13807 start() { 13808 if (!this.started) { 13809 this.started = true; 13810 this.mutationObserver.observe(this.element, this.mutationObserverInit); 13811 this.refresh(); 13812 } 13813 } 13814 pause(callback) { 13815 if (this.started) { 13816 this.mutationObserver.disconnect(); 13817 this.started = false; 13818 } 13819 callback(); 13820 if (!this.started) { 13821 this.mutationObserver.observe(this.element, this.mutationObserverInit); 13822 this.started = true; 13823 } 13824 } 13825 stop() { 13826 if (this.started) { 13827 this.mutationObserver.takeRecords(); 13828 this.mutationObserver.disconnect(); 13829 this.started = false; 13830 } 13831 } 13832 refresh() { 13833 if (this.started) { 13834 const matches = new Set(this.matchElementsInTree()); 13835 for (const element of Array.from(this.elements)) { 13836 if (!matches.has(element)) { 13837 this.removeElement(element); 13838 } 13839 } 13840 for (const element of Array.from(matches)) { 13841 this.addElement(element); 13842 } 13843 } 13844 } 13845 processMutations(mutations) { 13846 if (this.started) { 13847 for (const mutation of mutations) { 13848 this.processMutation(mutation); 13849 } 13850 } 13851 } 13852 processMutation(mutation) { 13853 if (mutation.type == "attributes") { 13854 this.processAttributeChange(mutation.target, mutation.attributeName); 13855 } else if (mutation.type == "childList") { 13856 this.processRemovedNodes(mutation.removedNodes); 13857 this.processAddedNodes(mutation.addedNodes); 13858 } 13859 } 13860 processAttributeChange(node, attributeName) { 13861 const element = node; 13862 if (this.elements.has(element)) { 13863 if (this.delegate.elementAttributeChanged && this.matchElement(element)) { 13864 this.delegate.elementAttributeChanged(element, attributeName); 13865 } else { 13866 this.removeElement(element); 13867 } 13868 } else if (this.matchElement(element)) { 13869 this.addElement(element); 13870 } 13871 } 13872 processRemovedNodes(nodes) { 13873 for (const node of Array.from(nodes)) { 13874 const element = this.elementFromNode(node); 13875 if (element) { 13876 this.processTree(element, this.removeElement); 13877 } 13878 } 13879 } 13880 processAddedNodes(nodes) { 13881 for (const node of Array.from(nodes)) { 13882 const element = this.elementFromNode(node); 13883 if (element && this.elementIsActive(element)) { 13884 this.processTree(element, this.addElement); 13885 } 13886 } 13887 } 13888 matchElement(element) { 13889 return this.delegate.matchElement(element); 13890 } 13891 matchElementsInTree(tree = this.element) { 13892 return this.delegate.matchElementsInTree(tree); 13893 } 13894 processTree(tree, processor) { 13895 for (const element of this.matchElementsInTree(tree)) { 13896 processor.call(this, element); 13897 } 13898 } 13899 elementFromNode(node) { 13900 if (node.nodeType == Node.ELEMENT_NODE) { 13901 return node; 13902 } 13903 } 13904 elementIsActive(element) { 13905 if (element.isConnected != this.element.isConnected) { 13906 return false; 13907 } else { 13908 return this.element.contains(element); 13909 } 13910 } 13911 addElement(element) { 13912 if (!this.elements.has(element)) { 13913 if (this.elementIsActive(element)) { 13914 this.elements.add(element); 13915 if (this.delegate.elementMatched) { 13916 this.delegate.elementMatched(element); 13917 } 13918 } 13919 } 13920 } 13921 removeElement(element) { 13922 if (this.elements.has(element)) { 13923 this.elements.delete(element); 13924 if (this.delegate.elementUnmatched) { 13925 this.delegate.elementUnmatched(element); 13926 } 13927 } 13928 } 13929 }; 13930 var AttributeObserver = class { 13931 constructor(element, attributeName, delegate) { 13932 this.attributeName = attributeName; 13933 this.delegate = delegate; 13934 this.elementObserver = new ElementObserver(element, this); 13935 } 13936 get element() { 13937 return this.elementObserver.element; 13938 } 13939 get selector() { 13940 return `[${this.attributeName}]`; 13941 } 13942 start() { 13943 this.elementObserver.start(); 13944 } 13945 pause(callback) { 13946 this.elementObserver.pause(callback); 13947 } 13948 stop() { 13949 this.elementObserver.stop(); 13950 } 13951 refresh() { 13952 this.elementObserver.refresh(); 13953 } 13954 get started() { 13955 return this.elementObserver.started; 13956 } 13957 matchElement(element) { 13958 return element.hasAttribute(this.attributeName); 13959 } 13960 matchElementsInTree(tree) { 13961 const match = this.matchElement(tree) ? [tree] : []; 13962 const matches = Array.from(tree.querySelectorAll(this.selector)); 13963 return match.concat(matches); 13964 } 13965 elementMatched(element) { 13966 if (this.delegate.elementMatchedAttribute) { 13967 this.delegate.elementMatchedAttribute(element, this.attributeName); 13968 } 13969 } 13970 elementUnmatched(element) { 13971 if (this.delegate.elementUnmatchedAttribute) { 13972 this.delegate.elementUnmatchedAttribute(element, this.attributeName); 13973 } 13974 } 13975 elementAttributeChanged(element, attributeName) { 13976 if (this.delegate.elementAttributeValueChanged && this.attributeName == attributeName) { 13977 this.delegate.elementAttributeValueChanged(element, attributeName); 13978 } 13979 } 13980 }; 13981 var StringMapObserver = class { 13982 constructor(element, delegate) { 13983 this.element = element; 13984 this.delegate = delegate; 13985 this.started = false; 13986 this.stringMap = /* @__PURE__ */ new Map(); 13987 this.mutationObserver = new MutationObserver((mutations) => this.processMutations(mutations)); 13988 } 13989 start() { 13990 if (!this.started) { 13991 this.started = true; 13992 this.mutationObserver.observe(this.element, { attributes: true, attributeOldValue: true }); 13993 this.refresh(); 13994 } 13995 } 13996 stop() { 13997 if (this.started) { 13998 this.mutationObserver.takeRecords(); 13999 this.mutationObserver.disconnect(); 14000 this.started = false; 14001 } 14002 } 14003 refresh() { 14004 if (this.started) { 14005 for (const attributeName of this.knownAttributeNames) { 14006 this.refreshAttribute(attributeName, null); 14007 } 14008 } 14009 } 14010 processMutations(mutations) { 14011 if (this.started) { 14012 for (const mutation of mutations) { 14013 this.processMutation(mutation); 14014 } 14015 } 14016 } 14017 processMutation(mutation) { 14018 const attributeName = mutation.attributeName; 14019 if (attributeName) { 14020 this.refreshAttribute(attributeName, mutation.oldValue); 14021 } 14022 } 14023 refreshAttribute(attributeName, oldValue) { 14024 const key = this.delegate.getStringMapKeyForAttribute(attributeName); 14025 if (key != null) { 14026 if (!this.stringMap.has(attributeName)) { 14027 this.stringMapKeyAdded(key, attributeName); 14028 } 14029 const value = this.element.getAttribute(attributeName); 14030 if (this.stringMap.get(attributeName) != value) { 14031 this.stringMapValueChanged(value, key, oldValue); 14032 } 14033 if (value == null) { 14034 const oldValue2 = this.stringMap.get(attributeName); 14035 this.stringMap.delete(attributeName); 14036 if (oldValue2) 14037 this.stringMapKeyRemoved(key, attributeName, oldValue2); 14038 } else { 14039 this.stringMap.set(attributeName, value); 14040 } 14041 } 14042 } 14043 stringMapKeyAdded(key, attributeName) { 14044 if (this.delegate.stringMapKeyAdded) { 14045 this.delegate.stringMapKeyAdded(key, attributeName); 14046 } 14047 } 14048 stringMapValueChanged(value, key, oldValue) { 14049 if (this.delegate.stringMapValueChanged) { 14050 this.delegate.stringMapValueChanged(value, key, oldValue); 14051 } 14052 } 14053 stringMapKeyRemoved(key, attributeName, oldValue) { 14054 if (this.delegate.stringMapKeyRemoved) { 14055 this.delegate.stringMapKeyRemoved(key, attributeName, oldValue); 14056 } 14057 } 14058 get knownAttributeNames() { 14059 return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames))); 14060 } 14061 get currentAttributeNames() { 14062 return Array.from(this.element.attributes).map((attribute) => attribute.name); 14063 } 14064 get recordedAttributeNames() { 14065 return Array.from(this.stringMap.keys()); 14066 } 14067 }; 14068 function add(map, key, value) { 14069 fetch2(map, key).add(value); 14070 } 14071 function del(map, key, value) { 14072 fetch2(map, key).delete(value); 14073 prune(map, key); 14074 } 14075 function fetch2(map, key) { 14076 let values = map.get(key); 14077 if (!values) { 14078 values = /* @__PURE__ */ new Set(); 14079 map.set(key, values); 14080 } 14081 return values; 14082 } 14083 function prune(map, key) { 14084 const values = map.get(key); 14085 if (values != null && values.size == 0) { 14086 map.delete(key); 14087 } 14088 } 14089 var Multimap = class { 14090 constructor() { 14091 this.valuesByKey = /* @__PURE__ */ new Map(); 14092 } 14093 get keys() { 14094 return Array.from(this.valuesByKey.keys()); 14095 } 14096 get values() { 14097 const sets = Array.from(this.valuesByKey.values()); 14098 return sets.reduce((values, set) => values.concat(Array.from(set)), []); 14099 } 14100 get size() { 14101 const sets = Array.from(this.valuesByKey.values()); 14102 return sets.reduce((size, set) => size + set.size, 0); 14103 } 14104 add(key, value) { 14105 add(this.valuesByKey, key, value); 14106 } 14107 delete(key, value) { 14108 del(this.valuesByKey, key, value); 14109 } 14110 has(key, value) { 14111 const values = this.valuesByKey.get(key); 14112 return values != null && values.has(value); 14113 } 14114 hasKey(key) { 14115 return this.valuesByKey.has(key); 14116 } 14117 hasValue(value) { 14118 const sets = Array.from(this.valuesByKey.values()); 14119 return sets.some((set) => set.has(value)); 14120 } 14121 getValuesForKey(key) { 14122 const values = this.valuesByKey.get(key); 14123 return values ? Array.from(values) : []; 14124 } 14125 getKeysForValue(value) { 14126 return Array.from(this.valuesByKey).filter(([key, values]) => values.has(value)).map(([key, values]) => key); 14127 } 14128 }; 14129 var TokenListObserver = class { 14130 constructor(element, attributeName, delegate) { 14131 this.attributeObserver = new AttributeObserver(element, attributeName, this); 14132 this.delegate = delegate; 14133 this.tokensByElement = new Multimap(); 14134 } 14135 get started() { 14136 return this.attributeObserver.started; 14137 } 14138 start() { 14139 this.attributeObserver.start(); 14140 } 14141 pause(callback) { 14142 this.attributeObserver.pause(callback); 14143 } 14144 stop() { 14145 this.attributeObserver.stop(); 14146 } 14147 refresh() { 14148 this.attributeObserver.refresh(); 14149 } 14150 get element() { 14151 return this.attributeObserver.element; 14152 } 14153 get attributeName() { 14154 return this.attributeObserver.attributeName; 14155 } 14156 elementMatchedAttribute(element) { 14157 this.tokensMatched(this.readTokensForElement(element)); 14158 } 14159 elementAttributeValueChanged(element) { 14160 const [unmatchedTokens, matchedTokens] = this.refreshTokensForElement(element); 14161 this.tokensUnmatched(unmatchedTokens); 14162 this.tokensMatched(matchedTokens); 14163 } 14164 elementUnmatchedAttribute(element) { 14165 this.tokensUnmatched(this.tokensByElement.getValuesForKey(element)); 14166 } 14167 tokensMatched(tokens) { 14168 tokens.forEach((token) => this.tokenMatched(token)); 14169 } 14170 tokensUnmatched(tokens) { 14171 tokens.forEach((token) => this.tokenUnmatched(token)); 14172 } 14173 tokenMatched(token) { 14174 this.delegate.tokenMatched(token); 14175 this.tokensByElement.add(token.element, token); 14176 } 14177 tokenUnmatched(token) { 14178 this.delegate.tokenUnmatched(token); 14179 this.tokensByElement.delete(token.element, token); 14180 } 14181 refreshTokensForElement(element) { 14182 const previousTokens = this.tokensByElement.getValuesForKey(element); 14183 const currentTokens = this.readTokensForElement(element); 14184 const firstDifferingIndex = zip(previousTokens, currentTokens).findIndex(([previousToken, currentToken]) => !tokensAreEqual(previousToken, currentToken)); 14185 if (firstDifferingIndex == -1) { 14186 return [[], []]; 14187 } else { 14188 return [previousTokens.slice(firstDifferingIndex), currentTokens.slice(firstDifferingIndex)]; 14189 } 14190 } 14191 readTokensForElement(element) { 14192 const attributeName = this.attributeName; 14193 const tokenString = element.getAttribute(attributeName) || ""; 14194 return parseTokenString(tokenString, element, attributeName); 14195 } 14196 }; 14197 function parseTokenString(tokenString, element, attributeName) { 14198 return tokenString.trim().split(/\s+/).filter((content) => content.length).map((content, index) => ({ element, attributeName, content, index })); 14199 } 14200 function zip(left2, right2) { 14201 const length = Math.max(left2.length, right2.length); 14202 return Array.from({ length }, (_, index) => [left2[index], right2[index]]); 14203 } 14204 function tokensAreEqual(left2, right2) { 14205 return left2 && right2 && left2.index == right2.index && left2.content == right2.content; 14206 } 14207 var ValueListObserver = class { 14208 constructor(element, attributeName, delegate) { 14209 this.tokenListObserver = new TokenListObserver(element, attributeName, this); 14210 this.delegate = delegate; 14211 this.parseResultsByToken = /* @__PURE__ */ new WeakMap(); 14212 this.valuesByTokenByElement = /* @__PURE__ */ new WeakMap(); 14213 } 14214 get started() { 14215 return this.tokenListObserver.started; 14216 } 14217 start() { 14218 this.tokenListObserver.start(); 14219 } 14220 stop() { 14221 this.tokenListObserver.stop(); 14222 } 14223 refresh() { 14224 this.tokenListObserver.refresh(); 14225 } 14226 get element() { 14227 return this.tokenListObserver.element; 14228 } 14229 get attributeName() { 14230 return this.tokenListObserver.attributeName; 14231 } 14232 tokenMatched(token) { 14233 const { element } = token; 14234 const { value } = this.fetchParseResultForToken(token); 14235 if (value) { 14236 this.fetchValuesByTokenForElement(element).set(token, value); 14237 this.delegate.elementMatchedValue(element, value); 14238 } 14239 } 14240 tokenUnmatched(token) { 14241 const { element } = token; 14242 const { value } = this.fetchParseResultForToken(token); 14243 if (value) { 14244 this.fetchValuesByTokenForElement(element).delete(token); 14245 this.delegate.elementUnmatchedValue(element, value); 14246 } 14247 } 14248 fetchParseResultForToken(token) { 14249 let parseResult = this.parseResultsByToken.get(token); 14250 if (!parseResult) { 14251 parseResult = this.parseToken(token); 14252 this.parseResultsByToken.set(token, parseResult); 14253 } 14254 return parseResult; 14255 } 14256 fetchValuesByTokenForElement(element) { 14257 let valuesByToken = this.valuesByTokenByElement.get(element); 14258 if (!valuesByToken) { 14259 valuesByToken = /* @__PURE__ */ new Map(); 14260 this.valuesByTokenByElement.set(element, valuesByToken); 14261 } 14262 return valuesByToken; 14263 } 14264 parseToken(token) { 14265 try { 14266 const value = this.delegate.parseValueForToken(token); 14267 return { value }; 14268 } catch (error2) { 14269 return { error: error2 }; 14270 } 14271 } 14272 }; 14273 var BindingObserver = class { 14274 constructor(context, delegate) { 14275 this.context = context; 14276 this.delegate = delegate; 14277 this.bindingsByAction = /* @__PURE__ */ new Map(); 14278 } 14279 start() { 14280 if (!this.valueListObserver) { 14281 this.valueListObserver = new ValueListObserver(this.element, this.actionAttribute, this); 14282 this.valueListObserver.start(); 14283 } 14284 } 14285 stop() { 14286 if (this.valueListObserver) { 14287 this.valueListObserver.stop(); 14288 delete this.valueListObserver; 14289 this.disconnectAllActions(); 14290 } 14291 } 14292 get element() { 14293 return this.context.element; 14294 } 14295 get identifier() { 14296 return this.context.identifier; 14297 } 14298 get actionAttribute() { 14299 return this.schema.actionAttribute; 14300 } 14301 get schema() { 14302 return this.context.schema; 14303 } 14304 get bindings() { 14305 return Array.from(this.bindingsByAction.values()); 14306 } 14307 connectAction(action) { 14308 const binding = new Binding(this.context, action); 14309 this.bindingsByAction.set(action, binding); 14310 this.delegate.bindingConnected(binding); 14311 } 14312 disconnectAction(action) { 14313 const binding = this.bindingsByAction.get(action); 14314 if (binding) { 14315 this.bindingsByAction.delete(action); 14316 this.delegate.bindingDisconnected(binding); 14317 } 14318 } 14319 disconnectAllActions() { 14320 this.bindings.forEach((binding) => this.delegate.bindingDisconnected(binding)); 14321 this.bindingsByAction.clear(); 14322 } 14323 parseValueForToken(token) { 14324 const action = Action.forToken(token); 14325 if (action.identifier == this.identifier) { 14326 return action; 14327 } 14328 } 14329 elementMatchedValue(element, action) { 14330 this.connectAction(action); 14331 } 14332 elementUnmatchedValue(element, action) { 14333 this.disconnectAction(action); 14334 } 14335 }; 14336 var ValueObserver = class { 14337 constructor(context, receiver) { 14338 this.context = context; 14339 this.receiver = receiver; 14340 this.stringMapObserver = new StringMapObserver(this.element, this); 14341 this.valueDescriptorMap = this.controller.valueDescriptorMap; 14342 this.invokeChangedCallbacksForDefaultValues(); 14343 } 14344 start() { 14345 this.stringMapObserver.start(); 14346 } 14347 stop() { 14348 this.stringMapObserver.stop(); 14349 } 14350 get element() { 14351 return this.context.element; 14352 } 14353 get controller() { 14354 return this.context.controller; 14355 } 14356 getStringMapKeyForAttribute(attributeName) { 14357 if (attributeName in this.valueDescriptorMap) { 14358 return this.valueDescriptorMap[attributeName].name; 14359 } 14360 } 14361 stringMapKeyAdded(key, attributeName) { 14362 const descriptor = this.valueDescriptorMap[attributeName]; 14363 if (!this.hasValue(key)) { 14364 this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), descriptor.writer(descriptor.defaultValue)); 14365 } 14366 } 14367 stringMapValueChanged(value, name, oldValue) { 14368 const descriptor = this.valueDescriptorNameMap[name]; 14369 if (value === null) 14370 return; 14371 if (oldValue === null) { 14372 oldValue = descriptor.writer(descriptor.defaultValue); 14373 } 14374 this.invokeChangedCallback(name, value, oldValue); 14375 } 14376 stringMapKeyRemoved(key, attributeName, oldValue) { 14377 const descriptor = this.valueDescriptorNameMap[key]; 14378 if (this.hasValue(key)) { 14379 this.invokeChangedCallback(key, descriptor.writer(this.receiver[key]), oldValue); 14380 } else { 14381 this.invokeChangedCallback(key, descriptor.writer(descriptor.defaultValue), oldValue); 14382 } 14383 } 14384 invokeChangedCallbacksForDefaultValues() { 14385 for (const { key, name, defaultValue, writer } of this.valueDescriptors) { 14386 if (defaultValue != void 0 && !this.controller.data.has(key)) { 14387 this.invokeChangedCallback(name, writer(defaultValue), void 0); 14388 } 14389 } 14390 } 14391 invokeChangedCallback(name, rawValue, rawOldValue) { 14392 const changedMethodName = `${name}Changed`; 14393 const changedMethod = this.receiver[changedMethodName]; 14394 if (typeof changedMethod == "function") { 14395 const descriptor = this.valueDescriptorNameMap[name]; 14396 const value = descriptor.reader(rawValue); 14397 let oldValue = rawOldValue; 14398 if (rawOldValue) { 14399 oldValue = descriptor.reader(rawOldValue); 14400 } 14401 changedMethod.call(this.receiver, value, oldValue); 14402 } 14403 } 14404 get valueDescriptors() { 14405 const { valueDescriptorMap } = this; 14406 return Object.keys(valueDescriptorMap).map((key) => valueDescriptorMap[key]); 14407 } 14408 get valueDescriptorNameMap() { 14409 const descriptors = {}; 14410 Object.keys(this.valueDescriptorMap).forEach((key) => { 14411 const descriptor = this.valueDescriptorMap[key]; 14412 descriptors[descriptor.name] = descriptor; 14413 }); 14414 return descriptors; 14415 } 14416 hasValue(attributeName) { 14417 const descriptor = this.valueDescriptorNameMap[attributeName]; 14418 const hasMethodName = `has${capitalize(descriptor.name)}`; 14419 return this.receiver[hasMethodName]; 14420 } 14421 }; 14422 var TargetObserver = class { 14423 constructor(context, delegate) { 14424 this.context = context; 14425 this.delegate = delegate; 14426 this.targetsByName = new Multimap(); 14427 } 14428 start() { 14429 if (!this.tokenListObserver) { 14430 this.tokenListObserver = new TokenListObserver(this.element, this.attributeName, this); 14431 this.tokenListObserver.start(); 14432 } 14433 } 14434 stop() { 14435 if (this.tokenListObserver) { 14436 this.disconnectAllTargets(); 14437 this.tokenListObserver.stop(); 14438 delete this.tokenListObserver; 14439 } 14440 } 14441 tokenMatched({ element, content: name }) { 14442 if (this.scope.containsElement(element)) { 14443 this.connectTarget(element, name); 14444 } 14445 } 14446 tokenUnmatched({ element, content: name }) { 14447 this.disconnectTarget(element, name); 14448 } 14449 connectTarget(element, name) { 14450 var _a; 14451 if (!this.targetsByName.has(name, element)) { 14452 this.targetsByName.add(name, element); 14453 (_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetConnected(element, name)); 14454 } 14455 } 14456 disconnectTarget(element, name) { 14457 var _a; 14458 if (this.targetsByName.has(name, element)) { 14459 this.targetsByName.delete(name, element); 14460 (_a = this.tokenListObserver) === null || _a === void 0 ? void 0 : _a.pause(() => this.delegate.targetDisconnected(element, name)); 14461 } 14462 } 14463 disconnectAllTargets() { 14464 for (const name of this.targetsByName.keys) { 14465 for (const element of this.targetsByName.getValuesForKey(name)) { 14466 this.disconnectTarget(element, name); 14467 } 14468 } 14469 } 14470 get attributeName() { 14471 return `data-${this.context.identifier}-target`; 14472 } 14473 get element() { 14474 return this.context.element; 14475 } 14476 get scope() { 14477 return this.context.scope; 14478 } 14479 }; 14480 var Context = class { 14481 constructor(module5, scope) { 14482 this.logDebugActivity = (functionName, detail = {}) => { 14483 const { identifier, controller, element } = this; 14484 detail = Object.assign({ identifier, controller, element }, detail); 14485 this.application.logDebugActivity(this.identifier, functionName, detail); 14486 }; 14487 this.module = module5; 14488 this.scope = scope; 14489 this.controller = new module5.controllerConstructor(this); 14490 this.bindingObserver = new BindingObserver(this, this.dispatcher); 14491 this.valueObserver = new ValueObserver(this, this.controller); 14492 this.targetObserver = new TargetObserver(this, this); 14493 try { 14494 this.controller.initialize(); 14495 this.logDebugActivity("initialize"); 14496 } catch (error2) { 14497 this.handleError(error2, "initializing controller"); 14498 } 14499 } 14500 connect() { 14501 this.bindingObserver.start(); 14502 this.valueObserver.start(); 14503 this.targetObserver.start(); 14504 try { 14505 this.controller.connect(); 14506 this.logDebugActivity("connect"); 14507 } catch (error2) { 14508 this.handleError(error2, "connecting controller"); 14509 } 14510 } 14511 disconnect() { 14512 try { 14513 this.controller.disconnect(); 14514 this.logDebugActivity("disconnect"); 14515 } catch (error2) { 14516 this.handleError(error2, "disconnecting controller"); 14517 } 14518 this.targetObserver.stop(); 14519 this.valueObserver.stop(); 14520 this.bindingObserver.stop(); 14521 } 14522 get application() { 14523 return this.module.application; 14524 } 14525 get identifier() { 14526 return this.module.identifier; 14527 } 14528 get schema() { 14529 return this.application.schema; 14530 } 14531 get dispatcher() { 14532 return this.application.dispatcher; 14533 } 14534 get element() { 14535 return this.scope.element; 14536 } 14537 get parentElement() { 14538 return this.element.parentElement; 14539 } 14540 handleError(error2, message, detail = {}) { 14541 const { identifier, controller, element } = this; 14542 detail = Object.assign({ identifier, controller, element }, detail); 14543 this.application.handleError(error2, `Error ${message}`, detail); 14544 } 14545 targetConnected(element, name) { 14546 this.invokeControllerMethod(`${name}TargetConnected`, element); 14547 } 14548 targetDisconnected(element, name) { 14549 this.invokeControllerMethod(`${name}TargetDisconnected`, element); 14550 } 14551 invokeControllerMethod(methodName, ...args) { 14552 const controller = this.controller; 14553 if (typeof controller[methodName] == "function") { 14554 controller[methodName](...args); 14555 } 14556 } 14557 }; 14558 function readInheritableStaticArrayValues(constructor, propertyName) { 14559 const ancestors = getAncestorsForConstructor(constructor); 14560 return Array.from(ancestors.reduce((values, constructor2) => { 14561 getOwnStaticArrayValues(constructor2, propertyName).forEach((name) => values.add(name)); 14562 return values; 14563 }, /* @__PURE__ */ new Set())); 14564 } 14565 function readInheritableStaticObjectPairs(constructor, propertyName) { 14566 const ancestors = getAncestorsForConstructor(constructor); 14567 return ancestors.reduce((pairs, constructor2) => { 14568 pairs.push(...getOwnStaticObjectPairs(constructor2, propertyName)); 14569 return pairs; 14570 }, []); 14571 } 14572 function getAncestorsForConstructor(constructor) { 14573 const ancestors = []; 14574 while (constructor) { 14575 ancestors.push(constructor); 14576 constructor = Object.getPrototypeOf(constructor); 14577 } 14578 return ancestors.reverse(); 14579 } 14580 function getOwnStaticArrayValues(constructor, propertyName) { 14581 const definition = constructor[propertyName]; 14582 return Array.isArray(definition) ? definition : []; 14583 } 14584 function getOwnStaticObjectPairs(constructor, propertyName) { 14585 const definition = constructor[propertyName]; 14586 return definition ? Object.keys(definition).map((key) => [key, definition[key]]) : []; 14587 } 14588 function bless(constructor) { 14589 return shadow(constructor, getBlessedProperties(constructor)); 14590 } 14591 function shadow(constructor, properties) { 14592 const shadowConstructor = extend2(constructor); 14593 const shadowProperties = getShadowProperties(constructor.prototype, properties); 14594 Object.defineProperties(shadowConstructor.prototype, shadowProperties); 14595 return shadowConstructor; 14596 } 14597 function getBlessedProperties(constructor) { 14598 const blessings = readInheritableStaticArrayValues(constructor, "blessings"); 14599 return blessings.reduce((blessedProperties, blessing) => { 14600 const properties = blessing(constructor); 14601 for (const key in properties) { 14602 const descriptor = blessedProperties[key] || {}; 14603 blessedProperties[key] = Object.assign(descriptor, properties[key]); 14604 } 14605 return blessedProperties; 14606 }, {}); 14607 } 14608 function getShadowProperties(prototype, properties) { 14609 return getOwnKeys(properties).reduce((shadowProperties, key) => { 14610 const descriptor = getShadowedDescriptor(prototype, properties, key); 14611 if (descriptor) { 14612 Object.assign(shadowProperties, { [key]: descriptor }); 14613 } 14614 return shadowProperties; 14615 }, {}); 14616 } 14617 function getShadowedDescriptor(prototype, properties, key) { 14618 const shadowingDescriptor = Object.getOwnPropertyDescriptor(prototype, key); 14619 const shadowedByValue = shadowingDescriptor && "value" in shadowingDescriptor; 14620 if (!shadowedByValue) { 14621 const descriptor = Object.getOwnPropertyDescriptor(properties, key).value; 14622 if (shadowingDescriptor) { 14623 descriptor.get = shadowingDescriptor.get || descriptor.get; 14624 descriptor.set = shadowingDescriptor.set || descriptor.set; 14625 } 14626 return descriptor; 14627 } 14628 } 14629 var getOwnKeys = (() => { 14630 if (typeof Object.getOwnPropertySymbols == "function") { 14631 return (object) => [ 14632 ...Object.getOwnPropertyNames(object), 14633 ...Object.getOwnPropertySymbols(object) 14634 ]; 14635 } else { 14636 return Object.getOwnPropertyNames; 14637 } 14638 })(); 14639 var extend2 = (() => { 14640 function extendWithReflect(constructor) { 14641 function extended() { 14642 return Reflect.construct(constructor, arguments, new.target); 14643 } 14644 extended.prototype = Object.create(constructor.prototype, { 14645 constructor: { value: extended } 14646 }); 14647 Reflect.setPrototypeOf(extended, constructor); 14648 return extended; 14649 } 14650 function testReflectExtension() { 14651 const a2 = function() { 14652 this.a.call(this); 14653 }; 14654 const b = extendWithReflect(a2); 14655 b.prototype.a = function() { 14656 }; 14657 return new b(); 14658 } 14659 try { 14660 testReflectExtension(); 14661 return extendWithReflect; 14662 } catch (error2) { 14663 return (constructor) => class extended extends constructor { 14664 }; 14665 } 14666 })(); 14667 function blessDefinition(definition) { 14668 return { 14669 identifier: definition.identifier, 14670 controllerConstructor: bless(definition.controllerConstructor) 14671 }; 14672 } 14673 var Module = class { 14674 constructor(application2, definition) { 14675 this.application = application2; 14676 this.definition = blessDefinition(definition); 14677 this.contextsByScope = /* @__PURE__ */ new WeakMap(); 14678 this.connectedContexts = /* @__PURE__ */ new Set(); 14679 } 14680 get identifier() { 14681 return this.definition.identifier; 14682 } 14683 get controllerConstructor() { 14684 return this.definition.controllerConstructor; 14685 } 14686 get contexts() { 14687 return Array.from(this.connectedContexts); 14688 } 14689 connectContextForScope(scope) { 14690 const context = this.fetchContextForScope(scope); 14691 this.connectedContexts.add(context); 14692 context.connect(); 14693 } 14694 disconnectContextForScope(scope) { 14695 const context = this.contextsByScope.get(scope); 14696 if (context) { 14697 this.connectedContexts.delete(context); 14698 context.disconnect(); 14699 } 14700 } 14701 fetchContextForScope(scope) { 14702 let context = this.contextsByScope.get(scope); 14703 if (!context) { 14704 context = new Context(this, scope); 14705 this.contextsByScope.set(scope, context); 14706 } 14707 return context; 14708 } 14709 }; 14710 var ClassMap = class { 14711 constructor(scope) { 14712 this.scope = scope; 14713 } 14714 has(name) { 14715 return this.data.has(this.getDataKey(name)); 14716 } 14717 get(name) { 14718 return this.getAll(name)[0]; 14719 } 14720 getAll(name) { 14721 const tokenString = this.data.get(this.getDataKey(name)) || ""; 14722 return tokenize(tokenString); 14723 } 14724 getAttributeName(name) { 14725 return this.data.getAttributeNameForKey(this.getDataKey(name)); 14726 } 14727 getDataKey(name) { 14728 return `${name}-class`; 14729 } 14730 get data() { 14731 return this.scope.data; 14732 } 14733 }; 14734 var DataMap = class { 14735 constructor(scope) { 14736 this.scope = scope; 14737 } 14738 get element() { 14739 return this.scope.element; 14740 } 14741 get identifier() { 14742 return this.scope.identifier; 14743 } 14744 get(key) { 14745 const name = this.getAttributeNameForKey(key); 14746 return this.element.getAttribute(name); 14747 } 14748 set(key, value) { 14749 const name = this.getAttributeNameForKey(key); 14750 this.element.setAttribute(name, value); 14751 return this.get(key); 14752 } 14753 has(key) { 14754 const name = this.getAttributeNameForKey(key); 14755 return this.element.hasAttribute(name); 14756 } 14757 delete(key) { 14758 if (this.has(key)) { 14759 const name = this.getAttributeNameForKey(key); 14760 this.element.removeAttribute(name); 14761 return true; 14762 } else { 14763 return false; 14764 } 14765 } 14766 getAttributeNameForKey(key) { 14767 return `data-${this.identifier}-${dasherize(key)}`; 14768 } 14769 }; 14770 var Guide = class { 14771 constructor(logger2) { 14772 this.warnedKeysByObject = /* @__PURE__ */ new WeakMap(); 14773 this.logger = logger2; 14774 } 14775 warn(object, key, message) { 14776 let warnedKeys = this.warnedKeysByObject.get(object); 14777 if (!warnedKeys) { 14778 warnedKeys = /* @__PURE__ */ new Set(); 14779 this.warnedKeysByObject.set(object, warnedKeys); 14780 } 14781 if (!warnedKeys.has(key)) { 14782 warnedKeys.add(key); 14783 this.logger.warn(message, object); 14784 } 14785 } 14786 }; 14787 function attributeValueContainsToken(attributeName, token) { 14788 return `[${attributeName}~="${token}"]`; 14789 } 14790 var TargetSet = class { 14791 constructor(scope) { 14792 this.scope = scope; 14793 } 14794 get element() { 14795 return this.scope.element; 14796 } 14797 get identifier() { 14798 return this.scope.identifier; 14799 } 14800 get schema() { 14801 return this.scope.schema; 14802 } 14803 has(targetName) { 14804 return this.find(targetName) != null; 14805 } 14806 find(...targetNames) { 14807 return targetNames.reduce((target, targetName) => target || this.findTarget(targetName) || this.findLegacyTarget(targetName), void 0); 14808 } 14809 findAll(...targetNames) { 14810 return targetNames.reduce((targets, targetName) => [ 14811 ...targets, 14812 ...this.findAllTargets(targetName), 14813 ...this.findAllLegacyTargets(targetName) 14814 ], []); 14815 } 14816 findTarget(targetName) { 14817 const selector = this.getSelectorForTargetName(targetName); 14818 return this.scope.findElement(selector); 14819 } 14820 findAllTargets(targetName) { 14821 const selector = this.getSelectorForTargetName(targetName); 14822 return this.scope.findAllElements(selector); 14823 } 14824 getSelectorForTargetName(targetName) { 14825 const attributeName = this.schema.targetAttributeForScope(this.identifier); 14826 return attributeValueContainsToken(attributeName, targetName); 14827 } 14828 findLegacyTarget(targetName) { 14829 const selector = this.getLegacySelectorForTargetName(targetName); 14830 return this.deprecate(this.scope.findElement(selector), targetName); 14831 } 14832 findAllLegacyTargets(targetName) { 14833 const selector = this.getLegacySelectorForTargetName(targetName); 14834 return this.scope.findAllElements(selector).map((element) => this.deprecate(element, targetName)); 14835 } 14836 getLegacySelectorForTargetName(targetName) { 14837 const targetDescriptor = `${this.identifier}.${targetName}`; 14838 return attributeValueContainsToken(this.schema.targetAttribute, targetDescriptor); 14839 } 14840 deprecate(element, targetName) { 14841 if (element) { 14842 const { identifier } = this; 14843 const attributeName = this.schema.targetAttribute; 14844 const revisedAttributeName = this.schema.targetAttributeForScope(identifier); 14845 this.guide.warn(element, `target:${targetName}`, `Please replace ${attributeName}="${identifier}.${targetName}" with ${revisedAttributeName}="${targetName}". The ${attributeName} attribute is deprecated and will be removed in a future version of Stimulus.`); 14846 } 14847 return element; 14848 } 14849 get guide() { 14850 return this.scope.guide; 14851 } 14852 }; 14853 var Scope = class { 14854 constructor(schema, element, identifier, logger2) { 14855 this.targets = new TargetSet(this); 14856 this.classes = new ClassMap(this); 14857 this.data = new DataMap(this); 14858 this.containsElement = (element2) => { 14859 return element2.closest(this.controllerSelector) === this.element; 14860 }; 14861 this.schema = schema; 14862 this.element = element; 14863 this.identifier = identifier; 14864 this.guide = new Guide(logger2); 14865 } 14866 findElement(selector) { 14867 return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement); 14868 } 14869 findAllElements(selector) { 14870 return [ 14871 ...this.element.matches(selector) ? [this.element] : [], 14872 ...this.queryElements(selector).filter(this.containsElement) 14873 ]; 14874 } 14875 queryElements(selector) { 14876 return Array.from(this.element.querySelectorAll(selector)); 14877 } 14878 get controllerSelector() { 14879 return attributeValueContainsToken(this.schema.controllerAttribute, this.identifier); 14880 } 14881 }; 14882 var ScopeObserver = class { 14883 constructor(element, schema, delegate) { 14884 this.element = element; 14885 this.schema = schema; 14886 this.delegate = delegate; 14887 this.valueListObserver = new ValueListObserver(this.element, this.controllerAttribute, this); 14888 this.scopesByIdentifierByElement = /* @__PURE__ */ new WeakMap(); 14889 this.scopeReferenceCounts = /* @__PURE__ */ new WeakMap(); 14890 } 14891 start() { 14892 this.valueListObserver.start(); 14893 } 14894 stop() { 14895 this.valueListObserver.stop(); 14896 } 14897 get controllerAttribute() { 14898 return this.schema.controllerAttribute; 14899 } 14900 parseValueForToken(token) { 14901 const { element, content: identifier } = token; 14902 const scopesByIdentifier = this.fetchScopesByIdentifierForElement(element); 14903 let scope = scopesByIdentifier.get(identifier); 14904 if (!scope) { 14905 scope = this.delegate.createScopeForElementAndIdentifier(element, identifier); 14906 scopesByIdentifier.set(identifier, scope); 14907 } 14908 return scope; 14909 } 14910 elementMatchedValue(element, value) { 14911 const referenceCount = (this.scopeReferenceCounts.get(value) || 0) + 1; 14912 this.scopeReferenceCounts.set(value, referenceCount); 14913 if (referenceCount == 1) { 14914 this.delegate.scopeConnected(value); 14915 } 14916 } 14917 elementUnmatchedValue(element, value) { 14918 const referenceCount = this.scopeReferenceCounts.get(value); 14919 if (referenceCount) { 14920 this.scopeReferenceCounts.set(value, referenceCount - 1); 14921 if (referenceCount == 1) { 14922 this.delegate.scopeDisconnected(value); 14923 } 14924 } 14925 } 14926 fetchScopesByIdentifierForElement(element) { 14927 let scopesByIdentifier = this.scopesByIdentifierByElement.get(element); 14928 if (!scopesByIdentifier) { 14929 scopesByIdentifier = /* @__PURE__ */ new Map(); 14930 this.scopesByIdentifierByElement.set(element, scopesByIdentifier); 14931 } 14932 return scopesByIdentifier; 14933 } 14934 }; 14935 var Router = class { 14936 constructor(application2) { 14937 this.application = application2; 14938 this.scopeObserver = new ScopeObserver(this.element, this.schema, this); 14939 this.scopesByIdentifier = new Multimap(); 14940 this.modulesByIdentifier = /* @__PURE__ */ new Map(); 14941 } 14942 get element() { 14943 return this.application.element; 14944 } 14945 get schema() { 14946 return this.application.schema; 14947 } 14948 get logger() { 14949 return this.application.logger; 14950 } 14951 get controllerAttribute() { 14952 return this.schema.controllerAttribute; 14953 } 14954 get modules() { 14955 return Array.from(this.modulesByIdentifier.values()); 14956 } 14957 get contexts() { 14958 return this.modules.reduce((contexts, module5) => contexts.concat(module5.contexts), []); 14959 } 14960 start() { 14961 this.scopeObserver.start(); 14962 } 14963 stop() { 14964 this.scopeObserver.stop(); 14965 } 14966 loadDefinition(definition) { 14967 this.unloadIdentifier(definition.identifier); 14968 const module5 = new Module(this.application, definition); 14969 this.connectModule(module5); 14970 } 14971 unloadIdentifier(identifier) { 14972 const module5 = this.modulesByIdentifier.get(identifier); 14973 if (module5) { 14974 this.disconnectModule(module5); 14975 } 14976 } 14977 getContextForElementAndIdentifier(element, identifier) { 14978 const module5 = this.modulesByIdentifier.get(identifier); 14979 if (module5) { 14980 return module5.contexts.find((context) => context.element == element); 14981 } 14982 } 14983 handleError(error2, message, detail) { 14984 this.application.handleError(error2, message, detail); 14985 } 14986 createScopeForElementAndIdentifier(element, identifier) { 14987 return new Scope(this.schema, element, identifier, this.logger); 14988 } 14989 scopeConnected(scope) { 14990 this.scopesByIdentifier.add(scope.identifier, scope); 14991 const module5 = this.modulesByIdentifier.get(scope.identifier); 14992 if (module5) { 14993 module5.connectContextForScope(scope); 14994 } 14995 } 14996 scopeDisconnected(scope) { 14997 this.scopesByIdentifier.delete(scope.identifier, scope); 14998 const module5 = this.modulesByIdentifier.get(scope.identifier); 14999 if (module5) { 15000 module5.disconnectContextForScope(scope); 15001 } 15002 } 15003 connectModule(module5) { 15004 this.modulesByIdentifier.set(module5.identifier, module5); 15005 const scopes = this.scopesByIdentifier.getValuesForKey(module5.identifier); 15006 scopes.forEach((scope) => module5.connectContextForScope(scope)); 15007 } 15008 disconnectModule(module5) { 15009 this.modulesByIdentifier.delete(module5.identifier); 15010 const scopes = this.scopesByIdentifier.getValuesForKey(module5.identifier); 15011 scopes.forEach((scope) => module5.disconnectContextForScope(scope)); 15012 } 15013 }; 15014 var defaultSchema = { 15015 controllerAttribute: "data-controller", 15016 actionAttribute: "data-action", 15017 targetAttribute: "data-target", 15018 targetAttributeForScope: (identifier) => `data-${identifier}-target` 15019 }; 15020 var Application = class { 15021 constructor(element = document.documentElement, schema = defaultSchema) { 15022 this.logger = console; 15023 this.debug = false; 15024 this.logDebugActivity = (identifier, functionName, detail = {}) => { 15025 if (this.debug) { 15026 this.logFormattedMessage(identifier, functionName, detail); 15027 } 15028 }; 15029 this.element = element; 15030 this.schema = schema; 15031 this.dispatcher = new Dispatcher(this); 15032 this.router = new Router(this); 15033 } 15034 static start(element, schema) { 15035 const application2 = new Application(element, schema); 15036 application2.start(); 15037 return application2; 15038 } 15039 async start() { 15040 await domReady(); 15041 this.logDebugActivity("application", "starting"); 15042 this.dispatcher.start(); 15043 this.router.start(); 15044 this.logDebugActivity("application", "start"); 15045 } 15046 stop() { 15047 this.logDebugActivity("application", "stopping"); 15048 this.dispatcher.stop(); 15049 this.router.stop(); 15050 this.logDebugActivity("application", "stop"); 15051 } 15052 register(identifier, controllerConstructor) { 15053 if (controllerConstructor.shouldLoad) { 15054 this.load({ identifier, controllerConstructor }); 15055 } 15056 } 15057 load(head, ...rest) { 15058 const definitions = Array.isArray(head) ? head : [head, ...rest]; 15059 definitions.forEach((definition) => this.router.loadDefinition(definition)); 15060 } 15061 unload(head, ...rest) { 15062 const identifiers = Array.isArray(head) ? head : [head, ...rest]; 15063 identifiers.forEach((identifier) => this.router.unloadIdentifier(identifier)); 15064 } 15065 get controllers() { 15066 return this.router.contexts.map((context) => context.controller); 15067 } 15068 getControllerForElementAndIdentifier(element, identifier) { 15069 const context = this.router.getContextForElementAndIdentifier(element, identifier); 15070 return context ? context.controller : null; 15071 } 15072 handleError(error2, message, detail) { 15073 var _a; 15074 this.logger.error(`%s 15075 15076%o 15077 15078%o`, message, error2, detail); 15079 (_a = window.onerror) === null || _a === void 0 ? void 0 : _a.call(window, message, "", 0, 0, error2); 15080 } 15081 logFormattedMessage(identifier, functionName, detail = {}) { 15082 detail = Object.assign({ application: this }, detail); 15083 this.logger.groupCollapsed(`${identifier} #${functionName}`); 15084 this.logger.log("details:", Object.assign({}, detail)); 15085 this.logger.groupEnd(); 15086 } 15087 }; 15088 function domReady() { 15089 return new Promise((resolve) => { 15090 if (document.readyState == "loading") { 15091 document.addEventListener("DOMContentLoaded", () => resolve()); 15092 } else { 15093 resolve(); 15094 } 15095 }); 15096 } 15097 function ClassPropertiesBlessing(constructor) { 15098 const classes = readInheritableStaticArrayValues(constructor, "classes"); 15099 return classes.reduce((properties, classDefinition) => { 15100 return Object.assign(properties, propertiesForClassDefinition(classDefinition)); 15101 }, {}); 15102 } 15103 function propertiesForClassDefinition(key) { 15104 return { 15105 [`${key}Class`]: { 15106 get() { 15107 const { classes } = this; 15108 if (classes.has(key)) { 15109 return classes.get(key); 15110 } else { 15111 const attribute = classes.getAttributeName(key); 15112 throw new Error(`Missing attribute "${attribute}"`); 15113 } 15114 } 15115 }, 15116 [`${key}Classes`]: { 15117 get() { 15118 return this.classes.getAll(key); 15119 } 15120 }, 15121 [`has${capitalize(key)}Class`]: { 15122 get() { 15123 return this.classes.has(key); 15124 } 15125 } 15126 }; 15127 } 15128 function TargetPropertiesBlessing(constructor) { 15129 const targets = readInheritableStaticArrayValues(constructor, "targets"); 15130 return targets.reduce((properties, targetDefinition) => { 15131 return Object.assign(properties, propertiesForTargetDefinition(targetDefinition)); 15132 }, {}); 15133 } 15134 function propertiesForTargetDefinition(name) { 15135 return { 15136 [`${name}Target`]: { 15137 get() { 15138 const target = this.targets.find(name); 15139 if (target) { 15140 return target; 15141 } else { 15142 throw new Error(`Missing target element "${name}" for "${this.identifier}" controller`); 15143 } 15144 } 15145 }, 15146 [`${name}Targets`]: { 15147 get() { 15148 return this.targets.findAll(name); 15149 } 15150 }, 15151 [`has${capitalize(name)}Target`]: { 15152 get() { 15153 return this.targets.has(name); 15154 } 15155 } 15156 }; 15157 } 15158 function ValuePropertiesBlessing(constructor) { 15159 const valueDefinitionPairs = readInheritableStaticObjectPairs(constructor, "values"); 15160 const propertyDescriptorMap = { 15161 valueDescriptorMap: { 15162 get() { 15163 return valueDefinitionPairs.reduce((result, valueDefinitionPair) => { 15164 const valueDescriptor = parseValueDefinitionPair(valueDefinitionPair); 15165 const attributeName = this.data.getAttributeNameForKey(valueDescriptor.key); 15166 return Object.assign(result, { [attributeName]: valueDescriptor }); 15167 }, {}); 15168 } 15169 } 15170 }; 15171 return valueDefinitionPairs.reduce((properties, valueDefinitionPair) => { 15172 return Object.assign(properties, propertiesForValueDefinitionPair(valueDefinitionPair)); 15173 }, propertyDescriptorMap); 15174 } 15175 function propertiesForValueDefinitionPair(valueDefinitionPair) { 15176 const definition = parseValueDefinitionPair(valueDefinitionPair); 15177 const { key, name, reader: read2, writer: write2 } = definition; 15178 return { 15179 [name]: { 15180 get() { 15181 const value = this.data.get(key); 15182 if (value !== null) { 15183 return read2(value); 15184 } else { 15185 return definition.defaultValue; 15186 } 15187 }, 15188 set(value) { 15189 if (value === void 0) { 15190 this.data.delete(key); 15191 } else { 15192 this.data.set(key, write2(value)); 15193 } 15194 } 15195 }, 15196 [`has${capitalize(name)}`]: { 15197 get() { 15198 return this.data.has(key) || definition.hasCustomDefaultValue; 15199 } 15200 } 15201 }; 15202 } 15203 function parseValueDefinitionPair([token, typeDefinition]) { 15204 return valueDescriptorForTokenAndTypeDefinition(token, typeDefinition); 15205 } 15206 function parseValueTypeConstant(constant) { 15207 switch (constant) { 15208 case Array: 15209 return "array"; 15210 case Boolean: 15211 return "boolean"; 15212 case Number: 15213 return "number"; 15214 case Object: 15215 return "object"; 15216 case String: 15217 return "string"; 15218 } 15219 } 15220 function parseValueTypeDefault(defaultValue) { 15221 switch (typeof defaultValue) { 15222 case "boolean": 15223 return "boolean"; 15224 case "number": 15225 return "number"; 15226 case "string": 15227 return "string"; 15228 } 15229 if (Array.isArray(defaultValue)) 15230 return "array"; 15231 if (Object.prototype.toString.call(defaultValue) === "[object Object]") 15232 return "object"; 15233 } 15234 function parseValueTypeObject(typeObject) { 15235 const typeFromObject = parseValueTypeConstant(typeObject.type); 15236 if (typeFromObject) { 15237 const defaultValueType = parseValueTypeDefault(typeObject.default); 15238 if (typeFromObject !== defaultValueType) { 15239 throw new Error(`Type "${typeFromObject}" must match the type of the default value. Given default value: "${typeObject.default}" as "${defaultValueType}"`); 15240 } 15241 return typeFromObject; 15242 } 15243 } 15244 function parseValueTypeDefinition(typeDefinition) { 15245 const typeFromObject = parseValueTypeObject(typeDefinition); 15246 const typeFromDefaultValue = parseValueTypeDefault(typeDefinition); 15247 const typeFromConstant = parseValueTypeConstant(typeDefinition); 15248 const type = typeFromObject || typeFromDefaultValue || typeFromConstant; 15249 if (type) 15250 return type; 15251 throw new Error(`Unknown value type "${typeDefinition}"`); 15252 } 15253 function defaultValueForDefinition(typeDefinition) { 15254 const constant = parseValueTypeConstant(typeDefinition); 15255 if (constant) 15256 return defaultValuesByType[constant]; 15257 const defaultValue = typeDefinition.default; 15258 if (defaultValue !== void 0) 15259 return defaultValue; 15260 return typeDefinition; 15261 } 15262 function valueDescriptorForTokenAndTypeDefinition(token, typeDefinition) { 15263 const key = `${dasherize(token)}-value`; 15264 const type = parseValueTypeDefinition(typeDefinition); 15265 return { 15266 type, 15267 key, 15268 name: camelize(key), 15269 get defaultValue() { 15270 return defaultValueForDefinition(typeDefinition); 15271 }, 15272 get hasCustomDefaultValue() { 15273 return parseValueTypeDefault(typeDefinition) !== void 0; 15274 }, 15275 reader: readers[type], 15276 writer: writers[type] || writers.default 15277 }; 15278 } 15279 var defaultValuesByType = { 15280 get array() { 15281 return []; 15282 }, 15283 boolean: false, 15284 number: 0, 15285 get object() { 15286 return {}; 15287 }, 15288 string: "" 15289 }; 15290 var readers = { 15291 array(value) { 15292 const array = JSON.parse(value); 15293 if (!Array.isArray(array)) { 15294 throw new TypeError("Expected array"); 15295 } 15296 return array; 15297 }, 15298 boolean(value) { 15299 return !(value == "0" || value == "false"); 15300 }, 15301 number(value) { 15302 return Number(value); 15303 }, 15304 object(value) { 15305 const object = JSON.parse(value); 15306 if (object === null || typeof object != "object" || Array.isArray(object)) { 15307 throw new TypeError("Expected object"); 15308 } 15309 return object; 15310 }, 15311 string(value) { 15312 return value; 15313 } 15314 }; 15315 var writers = { 15316 default: writeString, 15317 array: writeJSON, 15318 object: writeJSON 15319 }; 15320 function writeJSON(value) { 15321 return JSON.stringify(value); 15322 } 15323 function writeString(value) { 15324 return `${value}`; 15325 } 15326 var Controller = class { 15327 constructor(context) { 15328 this.context = context; 15329 } 15330 static get shouldLoad() { 15331 return true; 15332 } 15333 get application() { 15334 return this.context.application; 15335 } 15336 get scope() { 15337 return this.context.scope; 15338 } 15339 get element() { 15340 return this.scope.element; 15341 } 15342 get identifier() { 15343 return this.scope.identifier; 15344 } 15345 get targets() { 15346 return this.scope.targets; 15347 } 15348 get classes() { 15349 return this.scope.classes; 15350 } 15351 get data() { 15352 return this.scope.data; 15353 } 15354 initialize() { 15355 } 15356 connect() { 15357 } 15358 disconnect() { 15359 } 15360 dispatch(eventName, { target = this.element, detail = {}, prefix = this.identifier, bubbles = true, cancelable = true } = {}) { 15361 const type = prefix ? `${prefix}:${eventName}` : eventName; 15362 const event = new CustomEvent(type, { detail, bubbles, cancelable }); 15363 target.dispatchEvent(event); 15364 return event; 15365 } 15366 }; 15367 Controller.blessings = [ClassPropertiesBlessing, TargetPropertiesBlessing, ValuePropertiesBlessing]; 15368 Controller.targets = []; 15369 Controller.values = {}; 15370 15371
15371// controllers/application.js 15372 var application = Application.start(); 15373 application.debug = false; 15374 window.Stimulus = application; 15375 15376
15376// controllers/accounts_controller.js 15377 var accounts_controller_exports = {}; 15378 __export(accounts_controller_exports, { 15379 default: () => accounts_controller_default 15380 }); 15381 15382
vendor: 14,884 bytes, lines 15382-15848
15382// ../../node_modules/@rails/actioncable/app/assets/javascripts/actioncable.esm.js 15383 var adapters = { 15384 logger: self.console, 15385 WebSocket: self.WebSocket 15386 }; 15387 var logger = { 15388 log(...messages) { 15389 if (this.enabled) { 15390 messages.push(Date.now()); 15391 adapters.logger.log("[ActionCable]", ...messages); 15392 } 15393 } 15394 }; 15395 var now2 = () => new Date().getTime(); 15396 var secondsSince2 = (time) => (now2() - time) / 1e3; 15397 var ConnectionMonitor2 = class { 15398 constructor(connection) { 15399 this.visibilityDidChange = this.visibilityDidChange.bind(this); 15400 this.connection = connection; 15401 this.reconnectAttempts = 0; 15402 } 15403 start() { 15404 if (!this.isRunning()) { 15405 this.startedAt = now2(); 15406 delete this.stoppedAt; 15407 this.startPolling(); 15408 addEventListener("visibilitychange", this.visibilityDidChange); 15409 logger.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`); 15410 } 15411 } 15412 stop() { 15413 if (this.isRunning()) { 15414 this.stoppedAt = now2(); 15415 this.stopPolling(); 15416 removeEventListener("visibilitychange", this.visibilityDidChange); 15417 logger.log("ConnectionMonitor stopped"); 15418 } 15419 } 15420 isRunning() { 15421 return this.startedAt && !this.stoppedAt; 15422 } 15423 recordPing() { 15424 this.pingedAt = now2(); 15425 } 15426 recordConnect() { 15427 this.reconnectAttempts = 0; 15428 this.recordPing(); 15429 delete this.disconnectedAt; 15430 logger.log("ConnectionMonitor recorded connect"); 15431 } 15432 recordDisconnect() { 15433 this.disconnectedAt = now2(); 15434 logger.log("ConnectionMonitor recorded disconnect"); 15435 } 15436 startPolling() { 15437 this.stopPolling(); 15438 this.poll(); 15439 } 15440 stopPolling() { 15441 clearTimeout(this.pollTimeout); 15442 } 15443 poll() { 15444 this.pollTimeout = setTimeout(() => { 15445 this.reconnectIfStale(); 15446 this.poll(); 15447 }, this.getPollInterval()); 15448 } 15449 getPollInterval() { 15450 const { staleThreshold, reconnectionBackoffRate } = this.constructor; 15451 const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10)); 15452 const jitterMax = this.reconnectAttempts === 0 ? 1 : reconnectionBackoffRate; 15453 const jitter = jitterMax * Math.random(); 15454 return staleThreshold * 1e3 * backoff * (1 + jitter); 15455 } 15456 reconnectIfStale() { 15457 if (this.connectionIsStale()) { 15458 logger.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${secondsSince2(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`); 15459 this.reconnectAttempts++; 15460 if (this.disconnectedRecently()) { 15461 logger.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince2(this.disconnectedAt)} s`); 15462 } else { 15463 logger.log("ConnectionMonitor reopening"); 15464 this.connection.reopen(); 15465 } 15466 } 15467 } 15468 get refreshedAt() { 15469 return this.pingedAt ? this.pingedAt : this.startedAt; 15470 } 15471 connectionIsStale() { 15472 return secondsSince2(this.refreshedAt) > this.constructor.staleThreshold; 15473 } 15474 disconnectedRecently() { 15475 return this.disconnectedAt && secondsSince2(this.disconnectedAt) < this.constructor.staleThreshold; 15476 } 15477 visibilityDidChange() { 15478 if (document.visibilityState === "visible") { 15479 setTimeout(() => { 15480 if (this.connectionIsStale() || !this.connection.isOpen()) { 15481 logger.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`); 15482 this.connection.reopen(); 15483 } 15484 }, 200); 15485 } 15486 } 15487 }; 15488 ConnectionMonitor2.staleThreshold = 6; 15489 ConnectionMonitor2.reconnectionBackoffRate = 0.15; 15490 var INTERNAL = { 15491 message_types: { 15492 welcome: "welcome", 15493 disconnect: "disconnect", 15494 ping: "ping", 15495 confirmation: "confirm_subscription", 15496 rejection: "reject_subscription" 15497 }, 15498 disconnect_reasons: { 15499 unauthorized: "unauthorized", 15500 invalid_request: "invalid_request", 15501 server_restart: "server_restart" 15502 }, 15503 default_mount_path: "/cable", 15504 protocols: ["actioncable-v1-json", "actioncable-unsupported"] 15505 }; 15506 var { message_types: message_types2, protocols: protocols2 } = INTERNAL; 15507 var supportedProtocols2 = protocols2.slice(0, protocols2.length - 1); 15508 var indexOf2 = [].indexOf; 15509 var Connection2 = class { 15510 constructor(consumer2) { 15511 this.open = this.open.bind(this); 15512 this.consumer = consumer2; 15513 this.subscriptions = this.consumer.subscriptions; 15514 this.monitor = new ConnectionMonitor2(this); 15515 this.disconnected = true; 15516 } 15517 send(data) { 15518 if (this.isOpen()) { 15519 this.webSocket.send(JSON.stringify(data)); 15520 return true; 15521 } else { 15522 return false; 15523 } 15524 } 15525 open() { 15526 if (this.isActive()) { 15527 logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`); 15528 return false; 15529 } else { 15530 logger.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${protocols2}`); 15531 if (this.webSocket) { 15532 this.uninstallEventHandlers(); 15533 } 15534 this.webSocket = new adapters.WebSocket(this.consumer.url, protocols2); 15535 this.installEventHandlers(); 15536 this.monitor.start(); 15537 return true; 15538 } 15539 } 15540 close({ allowReconnect } = { 15541 allowReconnect: true 15542 }) { 15543 if (!allowReconnect) { 15544 this.monitor.stop(); 15545 } 15546 if (this.isActive()) { 15547 return this.webSocket.close(); 15548 } 15549 } 15550 reopen() { 15551 logger.log(`Reopening WebSocket, current state is ${this.getState()}`); 15552 if (this.isActive()) { 15553 try { 15554 return this.close(); 15555 } catch (error2) { 15556 logger.log("Failed to reopen WebSocket", error2); 15557 } finally { 15558 logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`); 15559 setTimeout(this.open, this.constructor.reopenDelay); 15560 } 15561 } else { 15562 return this.open(); 15563 } 15564 } 15565 getProtocol() { 15566 if (this.webSocket) { 15567 return this.webSocket.protocol; 15568 } 15569 } 15570 isOpen() { 15571 return this.isState("open"); 15572 } 15573 isActive() { 15574 return this.isState("open", "connecting"); 15575 } 15576 isProtocolSupported() { 15577 return indexOf2.call(supportedProtocols2, this.getProtocol()) >= 0; 15578 } 15579 isState(...states) { 15580 return indexOf2.call(states, this.getState()) >= 0; 15581 } 15582 getState() { 15583 if (this.webSocket) { 15584 for (let state in adapters.WebSocket) { 15585 if (adapters.WebSocket[state] === this.webSocket.readyState) { 15586 return state.toLowerCase(); 15587 } 15588 } 15589 } 15590 return null; 15591 } 15592 installEventHandlers() { 15593 for (let eventName in this.events) { 15594 const handler = this.events[eventName].bind(this); 15595 this.webSocket[`on${eventName}`] = handler; 15596 } 15597 } 15598 uninstallEventHandlers() { 15599 for (let eventName in this.events) { 15600 this.webSocket[`on${eventName}`] = function() { 15601 }; 15602 } 15603 } 15604 }; 15605 Connection2.reopenDelay = 500; 15606 Connection2.prototype.events = { 15607 message(event) { 15608 if (!this.isProtocolSupported()) { 15609 return; 15610 } 15611 const { identifier, message, reason, reconnect, type } = JSON.parse(event.data); 15612 switch (type) { 15613 case message_types2.welcome: 15614 this.monitor.recordConnect(); 15615 return this.subscriptions.reload(); 15616 case message_types2.disconnect: 15617 logger.log(`Disconnecting. Reason: ${reason}`); 15618 return this.close({ 15619 allowReconnect: reconnect 15620 }); 15621 case message_types2.ping: 15622 return this.monitor.recordPing(); 15623 case message_types2.confirmation: 15624 this.subscriptions.confirmSubscription(identifier); 15625 return this.subscriptions.notify(identifier, "connected"); 15626 case message_types2.rejection: 15627 return this.subscriptions.reject(identifier); 15628 default: 15629 return this.subscriptions.notify(identifier, "received", message); 15630 } 15631 }, 15632 open() { 15633 logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`); 15634 this.disconnected = false; 15635 if (!this.isProtocolSupported()) { 15636 logger.log("Protocol is unsupported. Stopping monitor and disconnecting."); 15637 return this.close({ 15638 allowReconnect: false 15639 }); 15640 } 15641 }, 15642 close(event) { 15643 logger.log("WebSocket onclose event"); 15644 if (this.disconnected) { 15645 return; 15646 } 15647 this.disconnected = true; 15648 this.monitor.recordDisconnect(); 15649 return this.subscriptions.notifyAll("disconnected", { 15650 willAttemptReconnect: this.monitor.isRunning() 15651 }); 15652 }, 15653 error() { 15654 logger.log("WebSocket onerror event"); 15655 } 15656 }; 15657 var extend3 = function(object, properties) { 15658 if (properties != null) { 15659 for (let key in properties) { 15660 const value = properties[key]; 15661 object[key] = value; 15662 } 15663 } 15664 return object; 15665 }; 15666 var Subscription2 = class { 15667 constructor(consumer2, params = {}, mixin) { 15668 this.consumer = consumer2; 15669 this.identifier = JSON.stringify(params); 15670 extend3(this, mixin); 15671 } 15672 perform(action, data = {}) { 15673 data.action = action; 15674 return this.send(data); 15675 } 15676 send(data) { 15677 return this.consumer.send({ 15678 command: "message", 15679 identifier: this.identifier, 15680 data: JSON.stringify(data) 15681 }); 15682 } 15683 unsubscribe() { 15684 return this.consumer.subscriptions.remove(this); 15685 } 15686 }; 15687 var SubscriptionGuarantor2 = class { 15688 constructor(subscriptions) { 15689 this.subscriptions = subscriptions; 15690 this.pendingSubscriptions = []; 15691 } 15692 guarantee(subscription) { 15693 if (this.pendingSubscriptions.indexOf(subscription) == -1) { 15694 logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`); 15695 this.pendingSubscriptions.push(subscription); 15696 } else { 15697 logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`); 15698 } 15699 this.startGuaranteeing(); 15700 } 15701 forget(subscription) { 15702 logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`); 15703 this.pendingSubscriptions = this.pendingSubscriptions.filter((s2) => s2 !== subscription); 15704 } 15705 startGuaranteeing() { 15706 this.stopGuaranteeing(); 15707 this.retrySubscribing(); 15708 } 15709 stopGuaranteeing() { 15710 clearTimeout(this.retryTimeout); 15711 } 15712 retrySubscribing() { 15713 this.retryTimeout = setTimeout(() => { 15714 if (this.subscriptions && typeof this.subscriptions.subscribe === "function") { 15715 this.pendingSubscriptions.map((subscription) => { 15716 logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`); 15717 this.subscriptions.subscribe(subscription); 15718 }); 15719 } 15720 }, 500); 15721 } 15722 }; 15723 var Subscriptions2 = class { 15724 constructor(consumer2) { 15725 this.consumer = consumer2; 15726 this.guarantor = new SubscriptionGuarantor2(this); 15727 this.subscriptions = []; 15728 } 15729 create(channelName, mixin) { 15730 const channel = channelName; 15731 const params = typeof channel === "object" ? channel : { 15732 channel 15733 }; 15734 const subscription = new Subscription2(this.consumer, params, mixin); 15735 return this.add(subscription); 15736 } 15737 add(subscription) { 15738 this.subscriptions.push(subscription); 15739 this.consumer.ensureActiveConnection(); 15740 this.notify(subscription, "initialized"); 15741 this.subscribe(subscription); 15742 return subscription; 15743 } 15744 remove(subscription) { 15745 this.forget(subscription); 15746 if (!this.findAll(subscription.identifier).length) { 15747 this.sendCommand(subscription, "unsubscribe"); 15748 } 15749 return subscription; 15750 } 15751 reject(identifier) { 15752 return this.findAll(identifier).map((subscription) => { 15753 this.forget(subscription); 15754 this.notify(subscription, "rejected"); 15755 return subscription; 15756 }); 15757 } 15758 forget(subscription) { 15759 this.guarantor.forget(subscription); 15760 this.subscriptions = this.subscriptions.filter((s2) => s2 !== subscription); 15761 return subscription; 15762 } 15763 findAll(identifier) { 15764 return this.subscriptions.filter((s2) => s2.identifier === identifier); 15765 } 15766 reload() { 15767 return this.subscriptions.map((subscription) => this.subscribe(subscription)); 15768 } 15769 notifyAll(callbackName, ...args) { 15770 return this.subscriptions.map((subscription) => this.notify(subscription, callbackName, ...args)); 15771 } 15772 notify(subscription, callbackName, ...args) { 15773 let subscriptions; 15774 if (typeof subscription === "string") { 15775 subscriptions = this.findAll(subscription); 15776 } else { 15777 subscriptions = [subscription]; 15778 } 15779 return subscriptions.map((subscription2) => typeof subscription2[callbackName] === "function" ? subscription2[callbackName](...args) : void 0); 15780 } 15781 subscribe(subscription) { 15782 if (this.sendCommand(subscription, "subscribe")) { 15783 this.guarantor.guarantee(subscription); 15784 } 15785 } 15786 confirmSubscription(identifier) { 15787 logger.log(`Subscription confirmed ${identifier}`); 15788 this.findAll(identifier).map((subscription) => this.guarantor.forget(subscription)); 15789 } 15790 sendCommand(subscription, command) { 15791 const { identifier } = subscription; 15792 return this.consumer.send({ 15793 command, 15794 identifier 15795 }); 15796 } 15797 }; 15798 var Consumer2 = class { 15799 constructor(url) { 15800 this._url = url; 15801 this.subscriptions = new Subscriptions2(this); 15802 this.connection = new Connection2(this); 15803 } 15804 get url() { 15805 return createWebSocketURL2(this._url); 15806 } 15807 send(data) { 15808 return this.connection.send(data); 15809 } 15810 connect() { 15811 return this.connection.open(); 15812 } 15813 disconnect() { 15814 return this.connection.close({ 15815 allowReconnect: false 15816 }); 15817 } 15818 ensureActiveConnection() { 15819 if (!this.connection.isActive()) { 15820 return this.connection.open(); 15821 } 15822 } 15823 }; 15824 function createWebSocketURL2(url) { 15825 if (typeof url === "function") { 15826 url = url(); 15827 } 15828 if (url && !/^wss?:/i.test(url)) { 15829 const a2 = document.createElement("a"); 15830 a2.href = url; 15831 a2.href = a2.href; 15832 a2.protocol = a2.protocol.replace("http", "ws"); 15833 return a2.href; 15834 } else { 15835 return url; 15836 } 15837 } 15838 function createConsumer3(url = getConfig2("url") || INTERNAL.default_mount_path) { 15839 return new Consumer2(url); 15840 } 15841 function getConfig2(name) { 15842 const element = document.head.querySelector(`meta[name='action-cable-${name}']`); 15843 if (element) { 15844 return element.getAttribute("content"); 15845 } 15846 } 15847 15848
15848// channels/consumer.js 15849 var consumer_default = createConsumer3(); 15850 15851
15851// controllers/accounts_controller.js 15852 var accounts_controller_default = class extends Controller { 15853 reconnect(event) { 15854 if (consumer_default.connection.isActive()) { 15855 consumer_default.connection.reopen(); 15856 } 15857 } 15858 }; 15859 15860
15860// controllers/admin_nav_controller.js 15861 var admin_nav_controller_exports = {}; 15862 __export(admin_nav_controller_exports, { 15863 default: () => admin_nav_controller_default 15864 }); 15865 var admin_nav_controller_default = class extends Controller { 15866 connect() { 15867 const activeSection = this.sectionTargets.find((s2) => this._sectionHasActiveLink(s2)); 15868 const firstSavedOpen = this.sectionTargets.find((s2) => s2.dataset.sectionId && this._readCollapsedRaw(s2.dataset.sectionId) === "0"); 15869 const openSection = activeSection || firstSavedOpen || null; 15870 this.sectionTargets.forEach((section) => { 15871 this._applyCollapsed(section, section !== openSection); 15872 }); 15873 this._persistAccordionState(openSection); 15874 } 15875 toggleSection(event) { 15876 if (this.searchTarget.value.trim() !== "") 15877 return; 15878 const section = event.currentTarget.closest("[data-admin-nav-target='section']"); 15879 if (!section) 15880 return; 15881 const willExpand = section.classList.contains("is-collapsed"); 15882 if (willExpand) { 15883 this.sectionTargets.forEach((s2) => { 15884 this._applyCollapsed(s2, s2 !== section); 15885 }); 15886 this._persistAccordionState(section); 15887 } else { 15888 this._applyCollapsed(section, true); 15889 this._persistAccordionState(null); 15890 } 15891 } 15892 _persistAccordionState(openSection) { 15893 this.sectionTargets.forEach((section) => { 15894 const id = section.dataset.sectionId; 15895 if (id) 15896 this._writeCollapsed(id, section !== openSection); 15897 }); 15898 } 15899 filter() { 15900 const query = this.searchTarget.value.trim().toLowerCase(); 15901 if (query === "") { 15902 this.reset(); 15903 return; 15904 } 15905 let anyVisible = false; 15906 this.sectionTargets.forEach((section) => { 15907 const heading = this._sectionHeadingText(section); 15908 const sectionMatches = heading.includes(query); 15909 let sectionHasVisibleLink = false; 15910 this._sectionLinks(section).forEach((link) => { 15911 const label = (link.textContent || "").trim().toLowerCase(); 15912 const matches = sectionMatches || label.includes(query); 15913 link.classList.toggle("is-dimmed", !matches); 15914 if (matches) { 15915 sectionHasVisibleLink = true; 15916 anyVisible = true; 15917 } 15918 }); 15919 this._applyCollapsed(section, false); 15920 section.hidden = !sectionHasVisibleLink; 15921 }); 15922 if (this.hasEmptyTarget) 15923 this.emptyTarget.hidden = anyVisible; 15924 } 15925 clearOnEscape(event) { 15926 if (event.key === "Escape") { 15927 this.searchTarget.value = ""; 15928 this.reset(); 15929 } 15930 } 15931 reset() { 15932 this.linkTargets.forEach((link) => link.classList.remove("is-dimmed")); 15933 this.sectionTargets.forEach((section) => { 15934 section.hidden = false; 15935 const id = section.dataset.sectionId; 15936 const saved = id ? this._readCollapsedRaw(id) : null; 15937 const collapsed = saved !== null ? saved === "1" : !this._sectionHasActiveLink(section); 15938 this._applyCollapsed(section, collapsed); 15939 }); 15940 if (this.hasEmptyTarget) 15941 this.emptyTarget.hidden = true; 15942 } 15943 _sectionLinks(section) { 15944 return Array.from(section.querySelectorAll("[data-admin-nav-target='link']")); 15945 } 15946 _sectionHeadingText(section) { 15947 const heading = section.querySelector("[data-admin-nav-target='heading']"); 15948 return heading ? (heading.textContent || "").trim().toLowerCase() : ""; 15949 } 15950 _applyCollapsed(section, collapsed) { 15951 section.classList.toggle("is-collapsed", collapsed); 15952 const header = section.querySelector(".admin-nav__section-header"); 15953 if (header) 15954 header.setAttribute("aria-expanded", String(!collapsed)); 15955 } 15956 _readCollapsedRaw(id) { 15957 try { 15958 return localStorage.getItem(this.constructor.STORAGE_PREFIX + id); 15959 } catch (e2) { 15960 return null; 15961 } 15962 } 15963 _sectionHasActiveLink(section) { 15964 return !!section.querySelector(".admin-nav__link--active, .navigation__link--active"); 15965 } 15966 _writeCollapsed(id, collapsed) { 15967 try { 15968 localStorage.setItem(this.constructor.STORAGE_PREFIX + id, collapsed ? "1" : "0"); 15969 } catch (e2) { 15970 } 15971 } 15972 }; 15973 __publicField(admin_nav_controller_default, "targets", ["search", "section", "heading", "link", "empty"]); 15974 __publicField(admin_nav_controller_default, "STORAGE_PREFIX", "adminNav:collapsed:"); 15975 15976
15976// controllers/braintree_controller.js 15977 var braintree_controller_exports = {}; 15978 __export(braintree_controller_exports, { 15979 default: () => braintree_controller_default 15980 }); 15981 var braintree_controller_default = class extends Controller { 15982 connect() { 15983 braintree.dropin.create({ 15984 authorization: this.data.get("clientToken"), 15985 container: this.dropinTarget, 15986 paypal: { 15987 flow: "vault" 15988 } 15989 }, this.clientCreated.bind(this)); 15990 } 15991 clientCreated(error2, instance) { 15992 if (error2) { 15993 console.error("Error setting up Braintree dropin:", error2); 15994 return; 15995 } 15996 this.instance = instance; 15997 } 15998 submit(event) { 15999 event.preventDefault(); 16000 this.instance.requestPaymentMethod(this.paymentMethod.bind(this)); 16001 } 16002 paymentMethod(error2, payload) { 16003 if (error2) { 16004 console.error("Error with payment method:", error2); 16005 return; 16006 } 16007 this.addHiddenField("processor", "braintree"); 16008 this.addHiddenField("payment_method_token", payload.nonce); 16009 Rails.fire(this.formTarget, "submit"); 16010 } 16011 addHiddenField(name, value) { 16012 let hiddenInput = document.createElement("input"); 16013 hiddenInput.setAttribute("type", "hidden"); 16014 hiddenInput.setAttribute("name", name); 16015 hiddenInput.setAttribute("value", value); 16016 this.formTarget.appendChild(hiddenInput); 16017 } 16018 }; 16019 __publicField(braintree_controller_default, "targets", ["dropin", "form"]); 16020 16021
16021// controllers/bulk_controller.js 16022 var bulk_controller_exports = {}; 16023 __export(bulk_controller_exports, { 16024 default: () => bulk_controller_default 16025 }); 16026 var bulk_controller_default = class extends Controller { 16027 toggleSelectAll(event) { 16028 !this.allCheckboxesSelected ? this.selectAll() : this.unselectAll(); 16029 } 16030 selectAll() { 16031 this.selectAllTarget.checked = true; 16032 this.selectAllTarget.indeterminate = false; 16033 this.unselected.forEach((target) => target.checked = true); 16034 } 16035 unselectAll() { 16036 this.selectAllTarget.checked = false; 16037 this.selectAllTarget.indeterminate = false; 16038 this.selected.forEach((target) => target.checked = false); 16039 } 16040 change(event) { 16041 if (this.noCheckboxesSelected) { 16042 this.selectAllTarget.checked = false; 16043 this.selectAllTarget.indeterminate = false; 16044 } else if (this.allCheckboxesSelected) { 16045 this.selectAllTarget.checked = true; 16046 this.selectAllTarget.indeterminate = false; 16047 } else { 16048 this.selectAllTarget.indeterminate = true; 16049 } 16050 } 16051 get selectedAll() { 16052 return this.selectAllTarget.checked; 16053 } 16054 get selected() { 16055 return this.checkboxTargets.filter((target) => target.checked); 16056 } 16057 get unselected() { 16058 return this.checkboxTargets.filter((target) => !target.checked); 16059 } 16060 get selectedIds() { 16061 return this.selected.map((target) => target.dataset.id); 16062 } 16063 get allCheckboxesSelected() { 16064 return this.checkboxTargets.every((target) => target.checked); 16065 } 16066 get noCheckboxesSelected() { 16067 return this.checkboxTargets.every((target) => !target.checked); 16068 } 16069 }; 16070 __publicField(bulk_controller_default, "targets", ["checkbox", "selectAll"]); 16071 16072
16072// controllers/cart_popup_controller.js 16073 var cart_popup_controller_exports = {}; 16074 __export(cart_popup_controller_exports, { 16075 default: () => cart_popup_controller_default 16076 }); 16077 var cart_popup_controller_default = class extends Controller { 16078 connect() { 16079 this.popupHandler = this.show.bind(this); 16080 window.showPopup = (message) => { 16081 document.dispatchEvent(new CustomEvent("cart:popup", { detail: { message } })); 16082 }; 16083 document.addEventListener("cart:popup", this.popupHandler); 16084 } 16085 disconnect() { 16086 document.removeEventListener("cart:popup", this.popupHandler); 16087 } 16088 show(event) { 16089 if (!this.hasContainerTarget) 16090 return; 16091 const message = event?.detail?.message; 16092 if (message && this.hasMessageTarget) { 16093 this.messageTarget.textContent = message; 16094 } 16095 this.containerTarget.classList.remove("hidden"); 16096 } 16097 close() { 16098 if (this.hasContainerTarget) { 16099 this.containerTarget.classList.add("hidden"); 16100 } 16101 } 16102 }; 16103 __publicField(cart_popup_controller_default, "targets", ["container", "message"]); 16104 16105
16105// controllers/category_filter_controller.js 16106 var category_filter_controller_exports = {}; 16107 __export(category_filter_controller_exports, { 16108 default: () => category_filter_controller_default 16109 }); 16110 var category_filter_controller_default = class extends Controller { 16111 connect() { 16112 this.handleOutsideClick = this.handleOutsideClick.bind(this); 16113 document.addEventListener("click", this.handleOutsideClick); 16114 } 16115 disconnect() { 16116 document.removeEventListener("click", this.handleOutsideClick); 16117 } 16118 toggle(event) { 16119 event.preventDefault(); 16120 this.panelTarget.classList.toggle("hidden"); 16121 } 16122 handleOutsideClick(event) { 16123 if (!this.element.contains(event.target)) { 16124 this.panelTarget.classList.add("hidden"); 16125 } 16126 } 16127 }; 16128 __publicField(category_filter_controller_default, "targets", ["panel"]); 16129 16130
16130// controllers/clipboard_controller.js 16131 var clipboard_controller_exports = {}; 16132 __export(clipboard_controller_exports, { 16133 default: () => clipboard_controller_default 16134 }); 16135 var import_clipboard = __toESM(require_clipboard()); 16136 16137
vendor: 1,135 bytes, lines 16137-16167
16137// ../../node_modules/@popperjs/core/lib/enums.js 16138 var top = "top"; 16139 var bottom = "bottom"; 16140 var right = "right"; 16141 var left = "left"; 16142 var auto = "auto"; 16143 var basePlacements = [top, bottom, right, left]; 16144 var start2 = "start"; 16145 var end = "end"; 16146 var clippingParents = "clippingParents"; 16147 var viewport = "viewport"; 16148 var popper = "popper"; 16149 var reference = "reference"; 16150 var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) { 16151 return acc.concat([placement + "-" + start2, placement + "-" + end]); 16152 }, []); 16153 var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) { 16154 return acc.concat([placement, placement + "-" + start2, placement + "-" + end]); 16155 }, []); 16156 var beforeRead = "beforeRead"; 16157 var read = "read"; 16158 var afterRead = "afterRead"; 16159 var beforeMain = "beforeMain"; 16160 var main = "main"; 16161 var afterMain = "afterMain"; 16162 var beforeWrite = "beforeWrite"; 16163 var write = "write"; 16164 var afterWrite = "afterWrite"; 16165 var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite]; 16166 16167
vendor: 175 bytes, lines 16167-16172
16167// ../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js 16168 function getNodeName(element) { 16169 return element ? (element.nodeName || "").toLowerCase() : null; 16170 } 16171 16172
vendor: 344 bytes, lines 16172-16184
16172// ../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js 16173 function getWindow(node) { 16174 if (node == null) { 16175 return window; 16176 } 16177 if (node.toString() !== "[object Window]") { 16178 var ownerDocument = node.ownerDocument; 16179 return ownerDocument ? ownerDocument.defaultView || window : window; 16180 } 16181 return node; 16182 } 16183 16184
vendor: 595 bytes, lines 16184-16201
16184// ../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js 16185 function isElement(node) { 16186 var OwnElement = getWindow(node).Element; 16187 return node instanceof OwnElement || node instanceof Element; 16188 } 16189 function isHTMLElement(node) { 16190 var OwnElement = getWindow(node).HTMLElement; 16191 return node instanceof OwnElement || node instanceof HTMLElement; 16192 } 16193 function isShadowRoot(node) { 16194 if (typeof ShadowRoot === "undefined") { 16195 return false; 16196 } 16197 var OwnElement = getWindow(node).ShadowRoot; 16198 return node instanceof OwnElement || node instanceof ShadowRoot; 16199 } 16200 16201
vendor: 2,127 bytes, lines 16201-16269
16201// ../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js 16202 function applyStyles(_ref) { 16203 var state = _ref.state; 16204 Object.keys(state.elements).forEach(function(name) { 16205 var style = state.styles[name] || {}; 16206 var attributes = state.attributes[name] || {}; 16207 var element = state.elements[name]; 16208 if (!isHTMLElement(element) || !getNodeName(element)) { 16209 return; 16210 } 16211 Object.assign(element.style, style); 16212 Object.keys(attributes).forEach(function(name2) { 16213 var value = attributes[name2]; 16214 if (value === false) { 16215 element.removeAttribute(name2); 16216 } else { 16217 element.setAttribute(name2, value === true ? "" : value); 16218 } 16219 }); 16220 }); 16221 } 16222 function effect(_ref2) { 16223 var state = _ref2.state; 16224 var initialStyles = { 16225 popper: { 16226 position: state.options.strategy, 16227 left: "0", 16228 top: "0", 16229 margin: "0" 16230 }, 16231 arrow: { 16232 position: "absolute" 16233 }, 16234 reference: {} 16235 }; 16236 Object.assign(state.elements.popper.style, initialStyles.popper); 16237 state.styles = initialStyles; 16238 if (state.elements.arrow) { 16239 Object.assign(state.elements.arrow.style, initialStyles.arrow); 16240 } 16241 return function() { 16242 Object.keys(state.elements).forEach(function(name) { 16243 var element = state.elements[name]; 16244 var attributes = state.attributes[name] || {}; 16245 var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); 16246 var style = styleProperties.reduce(function(style2, property) { 16247 style2[property] = ""; 16248 return style2; 16249 }, {}); 16250 if (!isHTMLElement(element) || !getNodeName(element)) { 16251 return; 16252 } 16253 Object.assign(element.style, style); 16254 Object.keys(attributes).forEach(function(attribute) { 16255 element.removeAttribute(attribute); 16256 }); 16257 }); 16258 }; 16259 } 16260 var applyStyles_default = { 16261 name: "applyStyles", 16262 enabled: true, 16263 phase: "write", 16264 fn: applyStyles, 16265 effect, 16266 requires: ["computeStyles"] 16267 }; 16268 16269
vendor: 151 bytes, lines 16269-16274
16269// ../../node_modules/@popperjs/core/lib/utils/getBasePlacement.js 16270 function getBasePlacement(placement) { 16271 return placement.split("-")[0]; 16272 } 16273 16274
vendor: 128 bytes, lines 16274-16279
16274// ../../node_modules/@popperjs/core/lib/utils/math.js 16275 var max = Math.max; 16276 var min = Math.min; 16277 var round = Math.round; 16278 16279
vendor: 911 bytes, lines 16279-16309
16279// ../../node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js 16280 function getBoundingClientRect(element, includeScale) { 16281 if (includeScale === void 0) { 16282 includeScale = false; 16283 } 16284 var rect = element.getBoundingClientRect(); 16285 var scaleX = 1; 16286 var scaleY = 1; 16287 if (isHTMLElement(element) && includeScale) { 16288 var offsetHeight = element.offsetHeight; 16289 var offsetWidth = element.offsetWidth; 16290 if (offsetWidth > 0) { 16291 scaleX = round(rect.width) / offsetWidth || 1; 16292 } 16293 if (offsetHeight > 0) { 16294 scaleY = round(rect.height) / offsetHeight || 1; 16295 } 16296 } 16297 return { 16298 width: rect.width / scaleX, 16299 height: rect.height / scaleY, 16300 top: rect.top / scaleY, 16301 right: rect.right / scaleX, 16302 bottom: rect.bottom / scaleY, 16303 left: rect.left / scaleX, 16304 x: rect.left / scaleX, 16305 y: rect.top / scaleY 16306 }; 16307 } 16308 16309
vendor: 525 bytes, lines 16309-16328
16309// ../../node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js 16310 function getLayoutRect(element) { 16311 var clientRect = getBoundingClientRect(element); 16312 var width = element.offsetWidth; 16313 var height = element.offsetHeight; 16314 if (Math.abs(clientRect.width - width) <= 1) { 16315 width = clientRect.width; 16316 } 16317 if (Math.abs(clientRect.height - height) <= 1) { 16318 height = clientRect.height; 16319 } 16320 return { 16321 x: element.offsetLeft, 16322 y: element.offsetTop, 16323 width, 16324 height 16325 }; 16326 } 16327 16328
vendor: 480 bytes, lines 16328-16345
16328// ../../node_modules/@popperjs/core/lib/dom-utils/contains.js 16329 function contains(parent, child) { 16330 var rootNode = child.getRootNode && child.getRootNode(); 16331 if (parent.contains(child)) { 16332 return true; 16333 } else if (rootNode && isShadowRoot(rootNode)) { 16334 var next = child; 16335 do { 16336 if (next && parent.isSameNode(next)) { 16337 return true; 16338 } 16339 next = next.parentNode || next.host; 16340 } while (next); 16341 } 16342 return false; 16343 } 16344 16345
vendor: 175 bytes, lines 16345-16350
16345// ../../node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js 16346 function getComputedStyle2(element) { 16347 return getWindow(element).getComputedStyle(element); 16348 } 16349 16350
vendor: 182 bytes, lines 16350-16355
16350// ../../node_modules/@popperjs/core/lib/dom-utils/isTableElement.js 16351 function isTableElement(element) { 16352 return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0; 16353 } 16354 16355
vendor: 234 bytes, lines 16355-16360
16355// ../../node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js 16356 function getDocumentElement(element) { 16357 return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement; 16358 } 16359 16360
vendor: 317 bytes, lines 16360-16368
16360// ../../node_modules/@popperjs/core/lib/dom-utils/getParentNode.js 16361 function getParentNode(element) { 16362 if (getNodeName(element) === "html") { 16363 return element; 16364 } 16365 return element.assignedSlot || element.parentNode || (isShadowRoot(element) ? element.host : null) || getDocumentElement(element); 16366 } 16367 16368
vendor: 1,760 bytes, lines 16368-16407
16368// ../../node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js 16369 function getTrueOffsetParent(element) { 16370 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") { 16371 return null; 16372 } 16373 return element.offsetParent; 16374 } 16375 function getContainingBlock(element) { 16376 var isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") !== -1; 16377 var isIE = navigator.userAgent.indexOf("Trident") !== -1; 16378 if (isIE && isHTMLElement(element)) { 16379 var elementCss = getComputedStyle2(element); 16380 if (elementCss.position === "fixed") { 16381 return null; 16382 } 16383 } 16384 var currentNode = getParentNode(element); 16385 while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) { 16386 var css = getComputedStyle2(currentNode); 16387 if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") { 16388 return currentNode; 16389 } else { 16390 currentNode = currentNode.parentNode; 16391 } 16392 } 16393 return null; 16394 } 16395 function getOffsetParent(element) { 16396 var window2 = getWindow(element); 16397 var offsetParent = getTrueOffsetParent(element); 16398 while (offsetParent && isTableElement(offsetParent) && getComputedStyle2(offsetParent).position === "static") { 16399 offsetParent = getTrueOffsetParent(offsetParent); 16400 } 16401 if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle2(offsetParent).position === "static")) { 16402 return window2; 16403 } 16404 return offsetParent || getContainingBlock(element) || window2; 16405 } 16406 16407
vendor: 197 bytes, lines 16407-16412
16407// ../../node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js 16408 function getMainAxisFromPlacement(placement) { 16409 return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y"; 16410 } 16411 16412
vendor: 265 bytes, lines 16412-16421
16412// ../../node_modules/@popperjs/core/lib/utils/within.js 16413 function within(min2, value, max2) { 16414 return max(min2, min(value, max2)); 16415 } 16416 function withinMaxClamp(min2, value, max2) { 16417 var v = within(min2, value, max2); 16418 return v > max2 ? max2 : v; 16419 } 16420 16421
vendor: 191 bytes, lines 16421-16431
16421// ../../node_modules/@popperjs/core/lib/utils/getFreshSideObject.js 16422 function getFreshSideObject() { 16423 return { 16424 top: 0, 16425 right: 0, 16426 bottom: 0, 16427 left: 0 16428 }; 16429 } 16430 16431
vendor: 190 bytes, lines 16431-16436
16431// ../../node_modules/@popperjs/core/lib/utils/mergePaddingObject.js 16432 function mergePaddingObject(paddingObject) { 16433 return Object.assign({}, getFreshSideObject(), paddingObject); 16434 } 16435 16436
vendor: 225 bytes, lines 16436-16444
16436// ../../node_modules/@popperjs/core/lib/utils/expandToHashMap.js 16437 function expandToHashMap(value, keys) { 16438 return keys.reduce(function(hashMap, key) { 16439 hashMap[key] = value; 16440 return hashMap; 16441 }, {}); 16442 } 16443 16444
vendor: 3,173 bytes, lines 16444-16514
16444// ../../node_modules/@popperjs/core/lib/modifiers/arrow.js 16445 var toPaddingObject = function toPaddingObject2(padding, state) { 16446 padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, { 16447 placement: state.placement 16448 })) : padding; 16449 return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements)); 16450 }; 16451 function arrow(_ref) { 16452 var _state$modifiersData$; 16453 var state = _ref.state, name = _ref.name, options2 = _ref.options; 16454 var arrowElement = state.elements.arrow; 16455 var popperOffsets2 = state.modifiersData.popperOffsets; 16456 var basePlacement = getBasePlacement(state.placement); 16457 var axis = getMainAxisFromPlacement(basePlacement); 16458 var isVertical = [left, right].indexOf(basePlacement) >= 0; 16459 var len = isVertical ? "height" : "width"; 16460 if (!arrowElement || !popperOffsets2) { 16461 return; 16462 } 16463 var paddingObject = toPaddingObject(options2.padding, state); 16464 var arrowRect = getLayoutRect(arrowElement); 16465 var minProp = axis === "y" ? top : left; 16466 var maxProp = axis === "y" ? bottom : right; 16467 var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len]; 16468 var startDiff = popperOffsets2[axis] - state.rects.reference[axis]; 16469 var arrowOffsetParent = getOffsetParent(arrowElement); 16470 var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0; 16471 var centerToReference = endDiff / 2 - startDiff / 2; 16472 var min2 = paddingObject[minProp]; 16473 var max2 = clientSize - arrowRect[len] - paddingObject[maxProp]; 16474 var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference; 16475 var offset2 = within(min2, center, max2); 16476 var axisProp = axis; 16477 state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$); 16478 } 16479 function effect2(_ref2) { 16480 var state = _ref2.state, options2 = _ref2.options; 16481 var _options$element = options2.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element; 16482 if (arrowElement == null) { 16483 return; 16484 } 16485 if (typeof arrowElement === "string") { 16486 arrowElement = state.elements.popper.querySelector(arrowElement); 16487 if (!arrowElement) { 16488 return; 16489 } 16490 } 16491 if (true) { 16492 if (!isHTMLElement(arrowElement)) { 16493 console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', "To use an SVG arrow, wrap it in an HTMLElement that will be used as", "the arrow."].join(" ")); 16494 } 16495 } 16496 if (!contains(state.elements.popper, arrowElement)) { 16497 if (true) { 16498 console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', "element."].join(" ")); 16499 } 16500 return; 16501 } 16502 state.elements.arrow = arrowElement; 16503 } 16504 var arrow_default = { 16505 name: "arrow", 16506 enabled: true, 16507 phase: "main", 16508 fn: arrow, 16509 effect: effect2, 16510 requires: ["popperOffsets"], 16511 requiresIfExists: ["preventOverflow"] 16512 }; 16513 16514
vendor: 143 bytes, lines 16514-16519
16514// ../../node_modules/@popperjs/core/lib/utils/getVariation.js 16515 function getVariation(placement) { 16516 return placement.split("-")[1]; 16517 } 16518 16519
vendor: 5,646 bytes, lines 16519-16643
16519// ../../node_modules/@popperjs/core/lib/modifiers/computeStyles.js 16520 var unsetSides = { 16521 top: "auto", 16522 right: "auto", 16523 bottom: "auto", 16524 left: "auto" 16525 }; 16526 function roundOffsetsByDPR(_ref) { 16527 var x = _ref.x, y = _ref.y; 16528 var win = window; 16529 var dpr = win.devicePixelRatio || 1; 16530 return { 16531 x: round(x * dpr) / dpr || 0, 16532 y: round(y * dpr) / dpr || 0 16533 }; 16534 } 16535 function mapToStyles(_ref2) { 16536 var _Object$assign2; 16537 var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed; 16538 var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y; 16539 var _ref3 = typeof roundOffsets === "function" ? roundOffsets({ 16540 x, 16541 y 16542 }) : { 16543 x, 16544 y 16545 }; 16546 x = _ref3.x; 16547 y = _ref3.y; 16548 var hasX = offsets.hasOwnProperty("x"); 16549 var hasY = offsets.hasOwnProperty("y"); 16550 var sideX = left; 16551 var sideY = top; 16552 var win = window; 16553 if (adaptive) { 16554 var offsetParent = getOffsetParent(popper2); 16555 var heightProp = "clientHeight"; 16556 var widthProp = "clientWidth"; 16557 if (offsetParent === getWindow(popper2)) { 16558 offsetParent = getDocumentElement(popper2); 16559 if (getComputedStyle2(offsetParent).position !== "static" && position === "absolute") { 16560 heightProp = "scrollHeight"; 16561 widthProp = "scrollWidth"; 16562 } 16563 } 16564 offsetParent = offsetParent; 16565 if (placement === top || (placement === left || placement === right) && variation === end) { 16566 sideY = bottom; 16567 var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : offsetParent[heightProp]; 16568 y -= offsetY - popperRect.height; 16569 y *= gpuAcceleration ? 1 : -1; 16570 } 16571 if (placement === left || (placement === top || placement === bottom) && variation === end) { 16572 sideX = right; 16573 var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : offsetParent[widthProp]; 16574 x -= offsetX - popperRect.width; 16575 x *= gpuAcceleration ? 1 : -1; 16576 } 16577 } 16578 var commonStyles = Object.assign({ 16579 position 16580 }, adaptive && unsetSides); 16581 var _ref4 = roundOffsets === true ? roundOffsetsByDPR({ 16582 x, 16583 y 16584 }) : { 16585 x, 16586 y 16587 }; 16588 x = _ref4.x; 16589 y = _ref4.y; 16590 if (gpuAcceleration) { 16591 var _Object$assign; 16592 return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign)); 16593 } 16594 return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2)); 16595 } 16596 function computeStyles(_ref5) { 16597 var state = _ref5.state, options2 = _ref5.options; 16598 var _options$gpuAccelerat = options2.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options2.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options2.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets; 16599 if (true) { 16600 var transitionProperty = getComputedStyle2(state.elements.popper).transitionProperty || ""; 16601 if (adaptive && ["transform", "top", "right", "bottom", "left"].some(function(property) { 16602 return transitionProperty.indexOf(property) >= 0; 16603 })) { 16604 console.warn(["Popper: Detected CSS transitions on at least one of the following", 'CSS properties: "transform", "top", "right", "bottom", "left".', "\n\n", 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', "for smooth transitions, or remove these properties from the CSS", "transition declaration on the popper element if only transitioning", "opacity or background-color for example.", "\n\n", "We recommend using the popper element as a wrapper around an inner", "element that can have any CSS property transitioned for animations."].join(" ")); 16605 } 16606 } 16607 var commonStyles = { 16608 placement: getBasePlacement(state.placement), 16609 variation: getVariation(state.placement), 16610 popper: state.elements.popper, 16611 popperRect: state.rects.popper, 16612 gpuAcceleration, 16613 isFixed: state.options.strategy === "fixed" 16614 }; 16615 if (state.modifiersData.popperOffsets != null) { 16616 state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, { 16617 offsets: state.modifiersData.popperOffsets, 16618 position: state.options.strategy, 16619 adaptive, 16620 roundOffsets 16621 }))); 16622 } 16623 if (state.modifiersData.arrow != null) { 16624 state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, { 16625 offsets: state.modifiersData.arrow, 16626 position: "absolute", 16627 adaptive: false, 16628 roundOffsets 16629 }))); 16630 } 16631 state.attributes.popper = Object.assign({}, state.attributes.popper, { 16632 "data-popper-placement": state.placement 16633 }); 16634 } 16635 var computeStyles_default = { 16636 name: "computeStyles", 16637 enabled: true, 16638 phase: "beforeWrite", 16639 fn: computeStyles, 16640 data: {} 16641 }; 16642 16643
vendor: 1,302 bytes, lines 16643-16681
16643// ../../node_modules/@popperjs/core/lib/modifiers/eventListeners.js 16644 var passive = { 16645 passive: true 16646 }; 16647 function effect3(_ref) { 16648 var state = _ref.state, instance = _ref.instance, options2 = _ref.options; 16649 var _options$scroll = options2.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options2.resize, resize = _options$resize === void 0 ? true : _options$resize; 16650 var window2 = getWindow(state.elements.popper); 16651 var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper); 16652 if (scroll) { 16653 scrollParents.forEach(function(scrollParent) { 16654 scrollParent.addEventListener("scroll", instance.update, passive); 16655 }); 16656 } 16657 if (resize) { 16658 window2.addEventListener("resize", instance.update, passive); 16659 } 16660 return function() { 16661 if (scroll) { 16662 scrollParents.forEach(function(scrollParent) { 16663 scrollParent.removeEventListener("scroll", instance.update, passive); 16664 }); 16665 } 16666 if (resize) { 16667 window2.removeEventListener("resize", instance.update, passive); 16668 } 16669 }; 16670 } 16671 var eventListeners_default = { 16672 name: "eventListeners", 16673 enabled: true, 16674 phase: "write", 16675 fn: function fn() { 16676 }, 16677 effect: effect3, 16678 data: {} 16679 }; 16680 16681
vendor: 329 bytes, lines 16681-16694
16681// ../../node_modules/@popperjs/core/lib/utils/getOppositePlacement.js 16682 var hash = { 16683 left: "right", 16684 right: "left", 16685 bottom: "top", 16686 top: "bottom" 16687 }; 16688 function getOppositePlacement(placement) { 16689 return placement.replace(/left|right|bottom|top/g, function(matched) { 16690 return hash[matched]; 16691 }); 16692 } 16693 16694
vendor: 297 bytes, lines 16694-16705
16694// ../../node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js 16695 var hash2 = { 16696 start: "end", 16697 end: "start" 16698 }; 16699 function getOppositeVariationPlacement(placement) { 16700 return placement.replace(/start|end/g, function(matched) { 16701 return hash2[matched]; 16702 }); 16703 } 16704 16705
vendor: 272 bytes, lines 16705-16716
16705// ../../node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js 16706 function getWindowScroll(node) { 16707 var win = getWindow(node); 16708 var scrollLeft = win.pageXOffset; 16709 var scrollTop = win.pageYOffset; 16710 return { 16711 scrollLeft, 16712 scrollTop 16713 }; 16714 } 16715 16716
vendor: 229 bytes, lines 16716-16721
16716// ../../node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js 16717 function getWindowScrollBarX(element) { 16718 return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft; 16719 } 16720 16721
vendor: 700 bytes, lines 16721-16746
16721// ../../node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js 16722 function getViewportRect(element) { 16723 var win = getWindow(element); 16724 var html = getDocumentElement(element); 16725 var visualViewport = win.visualViewport; 16726 var width = html.clientWidth; 16727 var height = html.clientHeight; 16728 var x = 0; 16729 var y = 0; 16730 if (visualViewport) { 16731 width = visualViewport.width; 16732 height = visualViewport.height; 16733 if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { 16734 x = visualViewport.offsetLeft; 16735 y = visualViewport.offsetTop; 16736 } 16737 } 16738 return { 16739 width, 16740 height, 16741 x: x + getWindowScrollBarX(element), 16742 y 16743 }; 16744 } 16745 16746
vendor: 885 bytes, lines 16746-16767
16746// ../../node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js 16747 function getDocumentRect(element) { 16748 var _element$ownerDocumen; 16749 var html = getDocumentElement(element); 16750 var winScroll = getWindowScroll(element); 16751 var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body; 16752 var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0); 16753 var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0); 16754 var x = -winScroll.scrollLeft + getWindowScrollBarX(element); 16755 var y = -winScroll.scrollTop; 16756 if (getComputedStyle2(body || html).direction === "rtl") { 16757 x += max(html.clientWidth, body ? body.clientWidth : 0) - width; 16758 } 16759 return { 16760 width, 16761 height, 16762 x, 16763 y 16764 }; 16765 } 16766 16767
vendor: 370 bytes, lines 16767-16773
16767// ../../node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js 16768 function isScrollParent(element) { 16769 var _getComputedStyle = getComputedStyle2(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY; 16770 return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); 16771 } 16772 16773
vendor: 358 bytes, lines 16773-16784
16773// ../../node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js 16774 function getScrollParent(node) { 16775 if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) { 16776 return node.ownerDocument.body; 16777 } 16778 if (isHTMLElement(node) && isScrollParent(node)) { 16779 return node; 16780 } 16781 return getScrollParent(getParentNode(node)); 16782 } 16783 16784
vendor: 695 bytes, lines 16784-16798
16784// ../../node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js 16785 function listScrollParents(element, list) { 16786 var _element$ownerDocumen; 16787 if (list === void 0) { 16788 list = []; 16789 } 16790 var scrollParent = getScrollParent(element); 16791 var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body); 16792 var win = getWindow(scrollParent); 16793 var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent; 16794 var updatedList = list.concat(target); 16795 return isBody ? updatedList : updatedList.concat(listScrollParents(getParentNode(target))); 16796 } 16797 16798
vendor: 263 bytes, lines 16798-16808
16798// ../../node_modules/@popperjs/core/lib/utils/rectToClientRect.js 16799 function rectToClientRect(rect) { 16800 return Object.assign({}, rect, { 16801 left: rect.x, 16802 top: rect.y, 16803 right: rect.x + rect.width, 16804 bottom: rect.y + rect.height 16805 }); 16806 } 16807 16808
vendor: 2,373 bytes, lines 16808-16854
16808// ../../node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js 16809 function getInnerBoundingClientRect(element) { 16810 var rect = getBoundingClientRect(element); 16811 rect.top = rect.top + element.clientTop; 16812 rect.left = rect.left + element.clientLeft; 16813 rect.bottom = rect.top + element.clientHeight; 16814 rect.right = rect.left + element.clientWidth; 16815 rect.width = element.clientWidth; 16816 rect.height = element.clientHeight; 16817 rect.x = rect.left; 16818 rect.y = rect.top; 16819 return rect; 16820 } 16821 function getClientRectFromMixedType(element, clippingParent) { 16822 return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element))); 16823 } 16824 function getClippingParents(element) { 16825 var clippingParents2 = listScrollParents(getParentNode(element)); 16826 var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle2(element).position) >= 0; 16827 var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element; 16828 if (!isElement(clipperElement)) { 16829 return []; 16830 } 16831 return clippingParents2.filter(function(clippingParent) { 16832 return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body"; 16833 }); 16834 } 16835 function getClippingRect(element, boundary, rootBoundary) { 16836 var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary); 16837 var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]); 16838 var firstClippingParent = clippingParents2[0]; 16839 var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) { 16840 var rect = getClientRectFromMixedType(element, clippingParent); 16841 accRect.top = max(rect.top, accRect.top); 16842 accRect.right = min(rect.right, accRect.right); 16843 accRect.bottom = min(rect.bottom, accRect.bottom); 16844 accRect.left = max(rect.left, accRect.left); 16845 return accRect; 16846 }, getClientRectFromMixedType(element, firstClippingParent)); 16847 clippingRect.width = clippingRect.right - clippingRect.left; 16848 clippingRect.height = clippingRect.bottom - clippingRect.top; 16849 clippingRect.x = clippingRect.left; 16850 clippingRect.y = clippingRect.top; 16851 return clippingRect; 16852 } 16853 16854
vendor: 1,653 bytes, lines 16854-16909
16854// ../../node_modules/@popperjs/core/lib/utils/computeOffsets.js 16855 function computeOffsets(_ref) { 16856 var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement; 16857 var basePlacement = placement ? getBasePlacement(placement) : null; 16858 var variation = placement ? getVariation(placement) : null; 16859 var commonX = reference2.x + reference2.width / 2 - element.width / 2; 16860 var commonY = reference2.y + reference2.height / 2 - element.height / 2; 16861 var offsets; 16862 switch (basePlacement) { 16863 case top: 16864 offsets = { 16865 x: commonX, 16866 y: reference2.y - element.height 16867 }; 16868 break; 16869 case bottom: 16870 offsets = { 16871 x: commonX, 16872 y: reference2.y + reference2.height 16873 }; 16874 break; 16875 case right: 16876 offsets = { 16877 x: reference2.x + reference2.width, 16878 y: commonY 16879 }; 16880 break; 16881 case left: 16882 offsets = { 16883 x: reference2.x - element.width, 16884 y: commonY 16885 }; 16886 break; 16887 default: 16888 offsets = { 16889 x: reference2.x, 16890 y: reference2.y 16891 }; 16892 } 16893 var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null; 16894 if (mainAxis != null) { 16895 var len = mainAxis === "y" ? "height" : "width"; 16896 switch (variation) { 16897 case start2: 16898 offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2); 16899 break; 16900 case end: 16901 offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2); 16902 break; 16903 default: 16904 } 16905 } 16906 return offsets; 16907 } 16908 16909
vendor: 2,649 bytes, lines 16909-16947
16909// ../../node_modules/@popperjs/core/lib/utils/detectOverflow.js 16910 function detectOverflow(state, options2) { 16911 if (options2 === void 0) { 16912 options2 = {}; 16913 } 16914 var _options = options2, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding; 16915 var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements)); 16916 var altContext = elementContext === popper ? reference : popper; 16917 var popperRect = state.rects.popper; 16918 var element = state.elements[altBoundary ? altContext : elementContext]; 16919 var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary); 16920 var referenceClientRect = getBoundingClientRect(state.elements.reference); 16921 var popperOffsets2 = computeOffsets({ 16922 reference: referenceClientRect, 16923 element: popperRect, 16924 strategy: "absolute", 16925 placement 16926 }); 16927 var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2)); 16928 var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; 16929 var overflowOffsets = { 16930 top: clippingClientRect.top - elementClientRect.top + paddingObject.top, 16931 bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom, 16932 left: clippingClientRect.left - elementClientRect.left + paddingObject.left, 16933 right: elementClientRect.right - clippingClientRect.right + paddingObject.right 16934 }; 16935 var offsetData = state.modifiersData.offset; 16936 if (elementContext === popper && offsetData) { 16937 var offset2 = offsetData[placement]; 16938 Object.keys(overflowOffsets).forEach(function(key) { 16939 var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1; 16940 var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x"; 16941 overflowOffsets[key] += offset2[axis] * multiply; 16942 }); 16943 } 16944 return overflowOffsets; 16945 } 16946 16947
vendor: 1,709 bytes, lines 16947-16980
16947// ../../node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js 16948 function computeAutoPlacement(state, options2) { 16949 if (options2 === void 0) { 16950 options2 = {}; 16951 } 16952 var _options = options2, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP; 16953 var variation = getVariation(placement); 16954 var placements2 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) { 16955 return getVariation(placement2) === variation; 16956 }) : basePlacements; 16957 var allowedPlacements = placements2.filter(function(placement2) { 16958 return allowedAutoPlacements.indexOf(placement2) >= 0; 16959 }); 16960 if (allowedPlacements.length === 0) { 16961 allowedPlacements = placements2; 16962 if (true) { 16963 console.error(["Popper: The `allowedAutoPlacements` option did not allow any", "placements. Ensure the `placement` option matches the variation", "of the allowed placements.", 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(" ")); 16964 } 16965 } 16966 var overflows = allowedPlacements.reduce(function(acc, placement2) { 16967 acc[placement2] = detectOverflow(state, { 16968 placement: placement2, 16969 boundary, 16970 rootBoundary, 16971 padding 16972 })[getBasePlacement(placement2)]; 16973 return acc; 16974 }, {}); 16975 return Object.keys(overflows).sort(function(a2, b) { 16976 return overflows[a2] - overflows[b]; 16977 }); 16978 } 16979 16980
vendor: 4,377 bytes, lines 16980-17086
16980// ../../node_modules/@popperjs/core/lib/modifiers/flip.js 16981 function getExpandedFallbackPlacements(placement) { 16982 if (getBasePlacement(placement) === auto) { 16983 return []; 16984 } 16985 var oppositePlacement = getOppositePlacement(placement); 16986 return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)]; 16987 } 16988 function flip(_ref) { 16989 var state = _ref.state, options2 = _ref.options, name = _ref.name; 16990 if (state.modifiersData[name]._skip) { 16991 return; 16992 } 16993 var _options$mainAxis = options2.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options2.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options2.fallbackPlacements, padding = options2.padding, boundary = options2.boundary, rootBoundary = options2.rootBoundary, altBoundary = options2.altBoundary, _options$flipVariatio = options2.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options2.allowedAutoPlacements; 16994 var preferredPlacement = state.options.placement; 16995 var basePlacement = getBasePlacement(preferredPlacement); 16996 var isBasePlacement = basePlacement === preferredPlacement; 16997 var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement)); 16998 var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) { 16999 return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, { 17000 placement: placement2, 17001 boundary, 17002 rootBoundary, 17003 padding, 17004 flipVariations, 17005 allowedAutoPlacements 17006 }) : placement2); 17007 }, []); 17008 var referenceRect = state.rects.reference; 17009 var popperRect = state.rects.popper; 17010 var checksMap = /* @__PURE__ */ new Map(); 17011 var makeFallbackChecks = true; 17012 var firstFittingPlacement = placements2[0]; 17013 for (var i2 = 0; i2 < placements2.length; i2++) { 17014 var placement = placements2[i2]; 17015 var _basePlacement = getBasePlacement(placement); 17016 var isStartVariation = getVariation(placement) === start2; 17017 var isVertical = [top, bottom].indexOf(_basePlacement) >= 0; 17018 var len = isVertical ? "width" : "height"; 17019 var overflow = detectOverflow(state, { 17020 placement, 17021 boundary, 17022 rootBoundary, 17023 altBoundary, 17024 padding 17025 }); 17026 var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top; 17027 if (referenceRect[len] > popperRect[len]) { 17028 mainVariationSide = getOppositePlacement(mainVariationSide); 17029 } 17030 var altVariationSide = getOppositePlacement(mainVariationSide); 17031 var checks = []; 17032 if (checkMainAxis) { 17033 checks.push(overflow[_basePlacement] <= 0); 17034 } 17035 if (checkAltAxis) { 17036 checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0); 17037 } 17038 if (checks.every(function(check) { 17039 return check; 17040 })) { 17041 firstFittingPlacement = placement; 17042 makeFallbackChecks = false; 17043 break; 17044 } 17045 checksMap.set(placement, checks); 17046 } 17047 if (makeFallbackChecks) { 17048 var numberOfChecks = flipVariations ? 3 : 1; 17049 var _loop = function _loop2(_i2) { 17050 var fittingPlacement = placements2.find(function(placement2) { 17051 var checks2 = checksMap.get(placement2); 17052 if (checks2) { 17053 return checks2.slice(0, _i2).every(function(check) { 17054 return check; 17055 }); 17056 } 17057 }); 17058 if (fittingPlacement) { 17059 firstFittingPlacement = fittingPlacement; 17060 return "break"; 17061 } 17062 }; 17063 for (var _i = numberOfChecks; _i > 0; _i--) { 17064 var _ret = _loop(_i); 17065 if (_ret === "break") 17066 break; 17067 } 17068 } 17069 if (state.placement !== firstFittingPlacement) { 17070 state.modifiersData[name]._skip = true; 17071 state.placement = firstFittingPlacement; 17072 state.reset = true; 17073 } 17074 } 17075 var flip_default = { 17076 name: "flip", 17077 enabled: true, 17078 phase: "main", 17079 fn: flip, 17080 requiresIfExists: ["offset"], 17081 data: { 17082 _skip: false 17083 } 17084 }; 17085 17086
vendor: 1,862 bytes, lines 17086-17140
17086// ../../node_modules/@popperjs/core/lib/modifiers/hide.js 17087 function getSideOffsets(overflow, rect, preventedOffsets) { 17088 if (preventedOffsets === void 0) { 17089 preventedOffsets = { 17090 x: 0, 17091 y: 0 17092 }; 17093 } 17094 return { 17095 top: overflow.top - rect.height - preventedOffsets.y, 17096 right: overflow.right - rect.width + preventedOffsets.x, 17097 bottom: overflow.bottom - rect.height + preventedOffsets.y, 17098 left: overflow.left - rect.width - preventedOffsets.x 17099 }; 17100 } 17101 function isAnySideFullyClipped(overflow) { 17102 return [top, right, bottom, left].some(function(side) { 17103 return overflow[side] >= 0; 17104 }); 17105 } 17106 function hide(_ref) { 17107 var state = _ref.state, name = _ref.name; 17108 var referenceRect = state.rects.reference; 17109 var popperRect = state.rects.popper; 17110 var preventedOffsets = state.modifiersData.preventOverflow; 17111 var referenceOverflow = detectOverflow(state, { 17112 elementContext: "reference" 17113 }); 17114 var popperAltOverflow = detectOverflow(state, { 17115 altBoundary: true 17116 }); 17117 var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect); 17118 var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets); 17119 var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets); 17120 var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets); 17121 state.modifiersData[name] = { 17122 referenceClippingOffsets, 17123 popperEscapeOffsets, 17124 isReferenceHidden, 17125 hasPopperEscaped 17126 }; 17127 state.attributes.popper = Object.assign({}, state.attributes.popper, { 17128 "data-popper-reference-hidden": isReferenceHidden, 17129 "data-popper-escaped": hasPopperEscaped 17130 }); 17131 } 17132 var hide_default = { 17133 name: "hide", 17134 enabled: true, 17135 phase: "main", 17136 requiresIfExists: ["preventOverflow"], 17137 fn: hide 17138 }; 17139 17140
vendor: 1,470 bytes, lines 17140-17179
17140// ../../node_modules/@popperjs/core/lib/modifiers/offset.js 17141 function distanceAndSkiddingToXY(placement, rects, offset2) { 17142 var basePlacement = getBasePlacement(placement); 17143 var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1; 17144 var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, { 17145 placement 17146 })) : offset2, skidding = _ref[0], distance = _ref[1]; 17147 skidding = skidding || 0; 17148 distance = (distance || 0) * invertDistance; 17149 return [left, right].indexOf(basePlacement) >= 0 ? { 17150 x: distance, 17151 y: skidding 17152 } : { 17153 x: skidding, 17154 y: distance 17155 }; 17156 } 17157 function offset(_ref2) { 17158 var state = _ref2.state, options2 = _ref2.options, name = _ref2.name; 17159 var _options$offset = options2.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset; 17160 var data = placements.reduce(function(acc, placement) { 17161 acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2); 17162 return acc; 17163 }, {}); 17164 var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y; 17165 if (state.modifiersData.popperOffsets != null) { 17166 state.modifiersData.popperOffsets.x += x; 17167 state.modifiersData.popperOffsets.y += y; 17168 } 17169 state.modifiersData[name] = data; 17170 } 17171 var offset_default = { 17172 name: "offset", 17173 enabled: true, 17174 phase: "main", 17175 requires: ["popperOffsets"], 17176 fn: offset 17177 }; 17178 17179
vendor: 485 bytes, lines 17179-17197
17179// ../../node_modules/@popperjs/core/lib/modifiers/popperOffsets.js 17180 function popperOffsets(_ref) { 17181 var state = _ref.state, name = _ref.name; 17182 state.modifiersData[name] = computeOffsets({ 17183 reference: state.rects.reference, 17184 element: state.rects.popper, 17185 strategy: "absolute", 17186 placement: state.placement 17187 }); 17188 } 17189 var popperOffsets_default = { 17190 name: "popperOffsets", 17191 enabled: true, 17192 phase: "read", 17193 fn: popperOffsets, 17194 data: {} 17195 }; 17196 17197
vendor: 135 bytes, lines 17197-17202
17197// ../../node_modules/@popperjs/core/lib/utils/getAltAxis.js 17198 function getAltAxis(axis) { 17199 return axis === "x" ? "y" : "x"; 17200 } 17201 17202
vendor: 5,565 bytes, lines 17202-17295
17202// ../../node_modules/@popperjs/core/lib/modifiers/preventOverflow.js 17203 function preventOverflow(_ref) { 17204 var state = _ref.state, options2 = _ref.options, name = _ref.name; 17205 var _options$mainAxis = options2.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options2.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options2.boundary, rootBoundary = options2.rootBoundary, altBoundary = options2.altBoundary, padding = options2.padding, _options$tether = options2.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options2.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset; 17206 var overflow = detectOverflow(state, { 17207 boundary, 17208 rootBoundary, 17209 padding, 17210 altBoundary 17211 }); 17212 var basePlacement = getBasePlacement(state.placement); 17213 var variation = getVariation(state.placement); 17214 var isBasePlacement = !variation; 17215 var mainAxis = getMainAxisFromPlacement(basePlacement); 17216 var altAxis = getAltAxis(mainAxis); 17217 var popperOffsets2 = state.modifiersData.popperOffsets; 17218 var referenceRect = state.rects.reference; 17219 var popperRect = state.rects.popper; 17220 var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, { 17221 placement: state.placement 17222 })) : tetherOffset; 17223 var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? { 17224 mainAxis: tetherOffsetValue, 17225 altAxis: tetherOffsetValue 17226 } : Object.assign({ 17227 mainAxis: 0, 17228 altAxis: 0 17229 }, tetherOffsetValue); 17230 var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null; 17231 var data = { 17232 x: 0, 17233 y: 0 17234 }; 17235 if (!popperOffsets2) { 17236 return; 17237 } 17238 if (checkMainAxis) { 17239 var _offsetModifierState$; 17240 var mainSide = mainAxis === "y" ? top : left; 17241 var altSide = mainAxis === "y" ? bottom : right; 17242 var len = mainAxis === "y" ? "height" : "width"; 17243 var offset2 = popperOffsets2[mainAxis]; 17244 var min2 = offset2 + overflow[mainSide]; 17245 var max2 = offset2 - overflow[altSide]; 17246 var additive = tether ? -popperRect[len] / 2 : 0; 17247 var minLen = variation === start2 ? referenceRect[len] : popperRect[len]; 17248 var maxLen = variation === start2 ? -popperRect[len] : -referenceRect[len]; 17249 var arrowElement = state.elements.arrow; 17250 var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : { 17251 width: 0, 17252 height: 0 17253 }; 17254 var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject(); 17255 var arrowPaddingMin = arrowPaddingObject[mainSide]; 17256 var arrowPaddingMax = arrowPaddingObject[altSide]; 17257 var arrowLen = within(0, referenceRect[len], arrowRect[len]); 17258 var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis; 17259 var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis; 17260 var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow); 17261 var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0; 17262 var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0; 17263 var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset; 17264 var tetherMax = offset2 + maxOffset - offsetModifierValue; 17265 var preventedOffset = within(tether ? min(min2, tetherMin) : min2, offset2, tether ? max(max2, tetherMax) : max2); 17266 popperOffsets2[mainAxis] = preventedOffset; 17267 data[mainAxis] = preventedOffset - offset2; 17268 } 17269 if (checkAltAxis) { 17270 var _offsetModifierState$2; 17271 var _mainSide = mainAxis === "x" ? top : left; 17272 var _altSide = mainAxis === "x" ? bottom : right; 17273 var _offset = popperOffsets2[altAxis]; 17274 var _len = altAxis === "y" ? "height" : "width"; 17275 var _min = _offset + overflow[_mainSide]; 17276 var _max = _offset - overflow[_altSide]; 17277 var isOriginSide = [top, left].indexOf(basePlacement) !== -1; 17278 var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0; 17279 var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis; 17280 var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max; 17281 var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max); 17282 popperOffsets2[altAxis] = _preventedOffset; 17283 data[altAxis] = _preventedOffset - _offset; 17284 } 17285 state.modifiersData[name] = data; 17286 } 17287 var preventOverflow_default = { 17288 name: "preventOverflow", 17289 enabled: true, 17290 phase: "main", 17291 fn: preventOverflow, 17292 requiresIfExists: ["offset"] 17293 }; 17294 17295
vendor: 218 bytes, lines 17295-17303
17295// ../../node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js 17296 function getHTMLElementScroll(element) { 17297 return { 17298 scrollLeft: element.scrollLeft, 17299 scrollTop: element.scrollTop 17300 }; 17301 } 17302 17303
vendor: 264 bytes, lines 17303-17312
17303// ../../node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js 17304 function getNodeScroll(node) { 17305 if (node === getWindow(node) || !isHTMLElement(node)) { 17306 return getWindowScroll(node); 17307 } else { 17308 return getHTMLElementScroll(node); 17309 } 17310 } 17311 17312
vendor: 1,579 bytes, lines 17312-17355
17312// ../../node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js 17313 function isElementScaled(element) { 17314 var rect = element.getBoundingClientRect(); 17315 var scaleX = round(rect.width) / element.offsetWidth || 1; 17316 var scaleY = round(rect.height) / element.offsetHeight || 1; 17317 return scaleX !== 1 || scaleY !== 1; 17318 } 17319 function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) { 17320 if (isFixed === void 0) { 17321 isFixed = false; 17322 } 17323 var isOffsetParentAnElement = isHTMLElement(offsetParent); 17324 var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent); 17325 var documentElement = getDocumentElement(offsetParent); 17326 var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled); 17327 var scroll = { 17328 scrollLeft: 0, 17329 scrollTop: 0 17330 }; 17331 var offsets = { 17332 x: 0, 17333 y: 0 17334 }; 17335 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 17336 if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) { 17337 scroll = getNodeScroll(offsetParent); 17338 } 17339 if (isHTMLElement(offsetParent)) { 17340 offsets = getBoundingClientRect(offsetParent, true); 17341 offsets.x += offsetParent.clientLeft; 17342 offsets.y += offsetParent.clientTop; 17343 } else if (documentElement) { 17344 offsets.x = getWindowScrollBarX(documentElement); 17345 } 17346 } 17347 return { 17348 x: rect.left + scroll.scrollLeft - offsets.x, 17349 y: rect.top + scroll.scrollTop - offsets.y, 17350 width: rect.width, 17351 height: rect.height 17352 }; 17353 } 17354 17355
vendor: 1,115 bytes, lines 17355-17392
17355// ../../node_modules/@popperjs/core/lib/utils/orderModifiers.js 17356 function order(modifiers) { 17357 var map = /* @__PURE__ */ new Map(); 17358 var visited = /* @__PURE__ */ new Set(); 17359 var result = []; 17360 modifiers.forEach(function(modifier) { 17361 map.set(modifier.name, modifier); 17362 }); 17363 function sort(modifier) { 17364 visited.add(modifier.name); 17365 var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []); 17366 requires.forEach(function(dep) { 17367 if (!visited.has(dep)) { 17368 var depModifier = map.get(dep); 17369 if (depModifier) { 17370 sort(depModifier); 17371 } 17372 } 17373 }); 17374 result.push(modifier); 17375 } 17376 modifiers.forEach(function(modifier) { 17377 if (!visited.has(modifier.name)) { 17378 sort(modifier); 17379 } 17380 }); 17381 return result; 17382 } 17383 function orderModifiers(modifiers) { 17384 var orderedModifiers = order(modifiers); 17385 return modifierPhases.reduce(function(acc, phase) { 17386 return acc.concat(orderedModifiers.filter(function(modifier) { 17387 return modifier.phase === phase; 17388 })); 17389 }, []); 17390 } 17391 17392
vendor: 373 bytes, lines 17392-17408
17392// ../../node_modules/@popperjs/core/lib/utils/debounce.js 17393 function debounce(fn2) { 17394 var pending; 17395 return function() { 17396 if (!pending) { 17397 pending = new Promise(function(resolve) { 17398 Promise.resolve().then(function() { 17399 pending = void 0; 17400 resolve(fn2()); 17401 }); 17402 }); 17403 } 17404 return pending; 17405 }; 17406 } 17407 17408
vendor: 346 bytes, lines 17408-17418
17408// ../../node_modules/@popperjs/core/lib/utils/format.js 17409 function format(str) { 17410 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 17411 args[_key - 1] = arguments[_key]; 17412 } 17413 return [].concat(args).reduce(function(p, c) { 17414 return p.replace(/%s/, c); 17415 }, str); 17416 } 17417 17418
vendor: 3,264 bytes, lines 17418-17482
17418// ../../node_modules/@popperjs/core/lib/utils/validateModifiers.js 17419 var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s'; 17420 var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available'; 17421 var VALID_PROPERTIES = ["name", "enabled", "phase", "fn", "effect", "requires", "options"]; 17422 function validateModifiers(modifiers) { 17423 modifiers.forEach(function(modifier) { 17424 [].concat(Object.keys(modifier), VALID_PROPERTIES).filter(function(value, index, self2) { 17425 return self2.indexOf(value) === index; 17426 }).forEach(function(key) { 17427 switch (key) { 17428 case "name": 17429 if (typeof modifier.name !== "string") { 17430 console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', '"' + String(modifier.name) + '"')); 17431 } 17432 break; 17433 case "enabled": 17434 if (typeof modifier.enabled !== "boolean") { 17435 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', '"' + String(modifier.enabled) + '"')); 17436 } 17437 break; 17438 case "phase": 17439 if (modifierPhases.indexOf(modifier.phase) < 0) { 17440 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(", "), '"' + String(modifier.phase) + '"')); 17441 } 17442 break; 17443 case "fn": 17444 if (typeof modifier.fn !== "function") { 17445 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', '"' + String(modifier.fn) + '"')); 17446 } 17447 break; 17448 case "effect": 17449 if (modifier.effect != null && typeof modifier.effect !== "function") { 17450 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', '"' + String(modifier.fn) + '"')); 17451 } 17452 break; 17453 case "requires": 17454 if (modifier.requires != null && !Array.isArray(modifier.requires)) { 17455 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', '"' + String(modifier.requires) + '"')); 17456 } 17457 break; 17458 case "requiresIfExists": 17459 if (!Array.isArray(modifier.requiresIfExists)) { 17460 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', '"' + String(modifier.requiresIfExists) + '"')); 17461 } 17462 break; 17463 case "options": 17464 case "data": 17465 break; 17466 default: 17467 console.error('PopperJS: an invalid property has been provided to the "' + modifier.name + '" modifier, valid properties are ' + VALID_PROPERTIES.map(function(s2) { 17468 return '"' + s2 + '"'; 17469 }).join(", ") + '; but "' + key + '" was provided.'); 17470 } 17471 modifier.requires && modifier.requires.forEach(function(requirement) { 17472 if (modifiers.find(function(mod) { 17473 return mod.name === requirement; 17474 }) == null) { 17475 console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement)); 17476 } 17477 }); 17478 }); 17479 }); 17480 } 17481 17482
vendor: 336 bytes, lines 17482-17494
17482// ../../node_modules/@popperjs/core/lib/utils/uniqueBy.js 17483 function uniqueBy(arr, fn2) { 17484 var identifiers = /* @__PURE__ */ new Set(); 17485 return arr.filter(function(item) { 17486 var identifier = fn2(item); 17487 if (!identifiers.has(identifier)) { 17488 identifiers.add(identifier); 17489 return true; 17490 } 17491 }); 17492 } 17493 17494
vendor: 563 bytes, lines 17494-17509
17494// ../../node_modules/@popperjs/core/lib/utils/mergeByName.js 17495 function mergeByName(modifiers) { 17496 var merged = modifiers.reduce(function(merged2, current) { 17497 var existing = merged2[current.name]; 17498 merged2[current.name] = existing ? Object.assign({}, existing, current, { 17499 options: Object.assign({}, existing.options, current.options), 17500 data: Object.assign({}, existing.data, current.data) 17501 }) : current; 17502 return merged2; 17503 }, {}); 17504 return Object.keys(merged).map(function(key) { 17505 return merged[key]; 17506 }); 17507 } 17508 17509
vendor: 7,326 bytes, lines 17509-17680
17509// ../../node_modules/@popperjs/core/lib/createPopper.js 17510 var INVALID_ELEMENT_ERROR = "Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element."; 17511 var INFINITE_LOOP_ERROR = "Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash."; 17512 var DEFAULT_OPTIONS = { 17513 placement: "bottom", 17514 modifiers: [], 17515 strategy: "absolute" 17516 }; 17517 function areValidElements() { 17518 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 17519 args[_key] = arguments[_key]; 17520 } 17521 return !args.some(function(element) { 17522 return !(element && typeof element.getBoundingClientRect === "function"); 17523 }); 17524 } 17525 function popperGenerator(generatorOptions) { 17526 if (generatorOptions === void 0) { 17527 generatorOptions = {}; 17528 } 17529 var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions2 = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2; 17530 return function createPopper2(reference2, popper2, options2) { 17531 if (options2 === void 0) { 17532 options2 = defaultOptions2; 17533 } 17534 var state = { 17535 placement: "bottom", 17536 orderedModifiers: [], 17537 options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions2), 17538 modifiersData: {}, 17539 elements: { 17540 reference: reference2, 17541 popper: popper2 17542 }, 17543 attributes: {}, 17544 styles: {} 17545 }; 17546 var effectCleanupFns = []; 17547 var isDestroyed = false; 17548 var instance = { 17549 state, 17550 setOptions: function setOptions(setOptionsAction) { 17551 var options3 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction; 17552 cleanupModifierEffects(); 17553 state.options = Object.assign({}, defaultOptions2, state.options, options3); 17554 state.scrollParents = { 17555 reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [], 17556 popper: listScrollParents(popper2) 17557 }; 17558 var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers))); 17559 state.orderedModifiers = orderedModifiers.filter(function(m) { 17560 return m.enabled; 17561 }); 17562 if (true) { 17563 var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function(_ref) { 17564 var name = _ref.name; 17565 return name; 17566 }); 17567 validateModifiers(modifiers); 17568 if (getBasePlacement(state.options.placement) === auto) { 17569 var flipModifier = state.orderedModifiers.find(function(_ref2) { 17570 var name = _ref2.name; 17571 return name === "flip"; 17572 }); 17573 if (!flipModifier) { 17574 console.error(['Popper: "auto" placements require the "flip" modifier be', "present and enabled to work."].join(" ")); 17575 } 17576 } 17577 var _getComputedStyle = getComputedStyle2(popper2), marginTop = _getComputedStyle.marginTop, marginRight = _getComputedStyle.marginRight, marginBottom = _getComputedStyle.marginBottom, marginLeft = _getComputedStyle.marginLeft; 17578 if ([marginTop, marginRight, marginBottom, marginLeft].some(function(margin) { 17579 return parseFloat(margin); 17580 })) { 17581 console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', "between the popper and its reference element or boundary.", "To replicate margin, use the `offset` modifier, as well as", "the `padding` option in the `preventOverflow` and `flip`", "modifiers."].join(" ")); 17582 } 17583 } 17584 runModifierEffects(); 17585 return instance.update(); 17586 }, 17587 forceUpdate: function forceUpdate() { 17588 if (isDestroyed) { 17589 return; 17590 } 17591 var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper; 17592 if (!areValidElements(reference3, popper3)) { 17593 if (true) { 17594 console.error(INVALID_ELEMENT_ERROR); 17595 } 17596 return; 17597 } 17598 state.rects = { 17599 reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"), 17600 popper: getLayoutRect(popper3) 17601 }; 17602 state.reset = false; 17603 state.placement = state.options.placement; 17604 state.orderedModifiers.forEach(function(modifier) { 17605 return state.modifiersData[modifier.name] = Object.assign({}, modifier.data); 17606 }); 17607 var __debug_loops__ = 0; 17608 for (var index = 0; index < state.orderedModifiers.length; index++) { 17609 if (true) { 17610 __debug_loops__ += 1; 17611 if (__debug_loops__ > 100) { 17612 console.error(INFINITE_LOOP_ERROR); 17613 break; 17614 } 17615 } 17616 if (state.reset === true) { 17617 state.reset = false; 17618 index = -1; 17619 continue; 17620 } 17621 var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name; 17622 if (typeof fn2 === "function") { 17623 state = fn2({ 17624 state, 17625 options: _options, 17626 name, 17627 instance 17628 }) || state; 17629 } 17630 } 17631 }, 17632 update: debounce(function() { 17633 return new Promise(function(resolve) { 17634 instance.forceUpdate(); 17635 resolve(state); 17636 }); 17637 }), 17638 destroy: function destroy2() { 17639 cleanupModifierEffects(); 17640 isDestroyed = true; 17641 } 17642 }; 17643 if (!areValidElements(reference2, popper2)) { 17644 if (true) { 17645 console.error(INVALID_ELEMENT_ERROR); 17646 } 17647 return instance; 17648 } 17649 instance.setOptions(options2).then(function(state2) { 17650 if (!isDestroyed && options2.onFirstUpdate) { 17651 options2.onFirstUpdate(state2); 17652 } 17653 }); 17654 function runModifierEffects() { 17655 state.orderedModifiers.forEach(function(_ref3) { 17656 var name = _ref3.name, _ref3$options = _ref3.options, options3 = _ref3$options === void 0 ? {} : _ref3$options, effect5 = _ref3.effect; 17657 if (typeof effect5 === "function") { 17658 var cleanupFn = effect5({ 17659 state, 17660 name, 17661 instance, 17662 options: options3 17663 }); 17664 var noopFn = function noopFn2() { 17665 }; 17666 effectCleanupFns.push(cleanupFn || noopFn); 17667 } 17668 }); 17669 } 17670 function cleanupModifierEffects() { 17671 effectCleanupFns.forEach(function(fn2) { 17672 return fn2(); 17673 }); 17674 effectCleanupFns = []; 17675 } 17676 return instance; 17677 }; 17678 } 17679 17680
vendor: 338 bytes, lines 17680-17686
17680// ../../node_modules/@popperjs/core/lib/popper.js 17681 var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default, offset_default, flip_default, preventOverflow_default, arrow_default, hide_default]; 17682 var createPopper = /* @__PURE__ */ popperGenerator({ 17683 defaultModifiers 17684 }); 17685 17686
vendor: 44,511 bytes, lines 17686-18954
17686// ../../node_modules/tippy.js/dist/tippy.esm.js 17687 var BOX_CLASS = "tippy-box"; 17688 var CONTENT_CLASS = "tippy-content"; 17689 var BACKDROP_CLASS = "tippy-backdrop"; 17690 var ARROW_CLASS = "tippy-arrow"; 17691 var SVG_ARROW_CLASS = "tippy-svg-arrow"; 17692 var TOUCH_OPTIONS = { 17693 passive: true, 17694 capture: true 17695 }; 17696 var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO2() { 17697 return document.body; 17698 }; 17699 function hasOwnProperty(obj, key) { 17700 return {}.hasOwnProperty.call(obj, key); 17701 } 17702 function getValueAtIndexOrReturn(value, index, defaultValue) { 17703 if (Array.isArray(value)) { 17704 var v = value[index]; 17705 return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v; 17706 } 17707 return value; 17708 } 17709 function isType(value, type) { 17710 var str = {}.toString.call(value); 17711 return str.indexOf("[object") === 0 && str.indexOf(type + "]") > -1; 17712 } 17713 function invokeWithArgsOrReturn(value, args) { 17714 return typeof value === "function" ? value.apply(void 0, args) : value; 17715 } 17716 function debounce2(fn2, ms) { 17717 if (ms === 0) { 17718 return fn2; 17719 } 17720 var timeout; 17721 return function(arg) { 17722 clearTimeout(timeout); 17723 timeout = setTimeout(function() { 17724 fn2(arg); 17725 }, ms); 17726 }; 17727 } 17728 function removeProperties(obj, keys) { 17729 var clone = Object.assign({}, obj); 17730 keys.forEach(function(key) { 17731 delete clone[key]; 17732 }); 17733 return clone; 17734 } 17735 function splitBySpaces(value) { 17736 return value.split(/\s+/).filter(Boolean); 17737 } 17738 function normalizeToArray(value) { 17739 return [].concat(value); 17740 } 17741 function pushIfUnique(arr, value) { 17742 if (arr.indexOf(value) === -1) { 17743 arr.push(value); 17744 } 17745 } 17746 function unique(arr) { 17747 return arr.filter(function(item, index) { 17748 return arr.indexOf(item) === index; 17749 }); 17750 } 17751 function getBasePlacement2(placement) { 17752 return placement.split("-")[0]; 17753 } 17754 function arrayFrom(value) { 17755 return [].slice.call(value); 17756 } 17757 function removeUndefinedProps(obj) { 17758 return Object.keys(obj).reduce(function(acc, key) { 17759 if (obj[key] !== void 0) { 17760 acc[key] = obj[key]; 17761 } 17762 return acc; 17763 }, {}); 17764 } 17765 function div() { 17766 return document.createElement("div"); 17767 } 17768 function isElement2(value) { 17769 return ["Element", "Fragment"].some(function(type) { 17770 return isType(value, type); 17771 }); 17772 } 17773 function isNodeList(value) { 17774 return isType(value, "NodeList"); 17775 } 17776 function isMouseEvent(value) { 17777 return isType(value, "MouseEvent"); 17778 } 17779 function isReferenceElement(value) { 17780 return !!(value && value._tippy && value._tippy.reference === value); 17781 } 17782 function getArrayOfElements(value) { 17783 if (isElement2(value)) { 17784 return [value]; 17785 } 17786 if (isNodeList(value)) { 17787 return arrayFrom(value); 17788 } 17789 if (Array.isArray(value)) { 17790 return value; 17791 } 17792 return arrayFrom(document.querySelectorAll(value)); 17793 } 17794 function setTransitionDuration(els, value) { 17795 els.forEach(function(el) { 17796 if (el) { 17797 el.style.transitionDuration = value + "ms"; 17798 } 17799 }); 17800 } 17801 function setVisibilityState(els, state) { 17802 els.forEach(function(el) { 17803 if (el) { 17804 el.setAttribute("data-state", state); 17805 } 17806 }); 17807 } 17808 function getOwnerDocument(elementOrElements) { 17809 var _element$ownerDocumen; 17810 var _normalizeToArray = normalizeToArray(elementOrElements), element = _normalizeToArray[0]; 17811 return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document; 17812 } 17813 function isCursorOutsideInteractiveBorder(popperTreeData, event) { 17814 var clientX = event.clientX, clientY = event.clientY; 17815 return popperTreeData.every(function(_ref) { 17816 var popperRect = _ref.popperRect, popperState = _ref.popperState, props = _ref.props; 17817 var interactiveBorder = props.interactiveBorder; 17818 var basePlacement = getBasePlacement2(popperState.placement); 17819 var offsetData = popperState.modifiersData.offset; 17820 if (!offsetData) { 17821 return true; 17822 } 17823 var topDistance = basePlacement === "bottom" ? offsetData.top.y : 0; 17824 var bottomDistance = basePlacement === "top" ? offsetData.bottom.y : 0; 17825 var leftDistance = basePlacement === "right" ? offsetData.left.x : 0; 17826 var rightDistance = basePlacement === "left" ? offsetData.right.x : 0; 17827 var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder; 17828 var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder; 17829 var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder; 17830 var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder; 17831 return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight; 17832 }); 17833 } 17834 function updateTransitionEndListener(box, action, listener) { 17835 var method = action + "EventListener"; 17836 ["transitionend", "webkitTransitionEnd"].forEach(function(event) { 17837 box[method](event, listener); 17838 }); 17839 } 17840 function actualContains(parent, child) { 17841 var target = child; 17842 while (target) { 17843 var _target$getRootNode; 17844 if (parent.contains(target)) { 17845 return true; 17846 } 17847 target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host; 17848 } 17849 return false; 17850 } 17851 var currentInput = { 17852 isTouch: false 17853 }; 17854 var lastMouseMoveTime = 0; 17855 function onDocumentTouchStart() { 17856 if (currentInput.isTouch) { 17857 return; 17858 } 17859 currentInput.isTouch = true; 17860 if (window.performance) { 17861 document.addEventListener("mousemove", onDocumentMouseMove); 17862 } 17863 } 17864 function onDocumentMouseMove() { 17865 var now3 = performance.now(); 17866 if (now3 - lastMouseMoveTime < 20) { 17867 currentInput.isTouch = false; 17868 document.removeEventListener("mousemove", onDocumentMouseMove); 17869 } 17870 lastMouseMoveTime = now3; 17871 } 17872 function onWindowBlur() { 17873 var activeElement = document.activeElement; 17874 if (isReferenceElement(activeElement)) { 17875 var instance = activeElement._tippy; 17876 if (activeElement.blur && !instance.state.isVisible) { 17877 activeElement.blur(); 17878 } 17879 } 17880 } 17881 function bindGlobalEventListeners() { 17882 document.addEventListener("touchstart", onDocumentTouchStart, TOUCH_OPTIONS); 17883 window.addEventListener("blur", onWindowBlur); 17884 } 17885 var isBrowser = typeof window !== "undefined" && typeof document !== "undefined"; 17886 var isIE11 = isBrowser ? !!window.msCrypto : false; 17887 function createMemoryLeakWarning(method) { 17888 var txt = method === "destroy" ? "n already-" : " "; 17889 return [method + "() was called on a" + txt + "destroyed instance. This is a no-op but", "indicates a potential memory leak."].join(" "); 17890 } 17891 function clean(value) { 17892 var spacesAndTabs = /[ \t]{2,}/g; 17893 var lineStartWithSpaces = /^[ \t]*/gm; 17894 return value.replace(spacesAndTabs, " ").replace(lineStartWithSpaces, "").trim(); 17895 } 17896 function getDevMessage(message) { 17897 return clean("\n %ctippy.js\n\n %c" + clean(message) + "\n\n %c\u{1F477}\u200D This is a development-only message. It will be removed in production.\n "); 17898 } 17899 function getFormattedMessage(message) { 17900 return [ 17901 getDevMessage(message), 17902 "color: #00C584; font-size: 1.3em; font-weight: bold;", 17903 "line-height: 1.5", 17904 "color: #a6a095;" 17905 ]; 17906 } 17907 var visitedMessages; 17908 if (true) { 17909 resetVisitedMessages(); 17910 } 17911 function resetVisitedMessages() { 17912 visitedMessages = /* @__PURE__ */ new Set(); 17913 } 17914 function warnWhen(condition, message) { 17915 if (condition && !visitedMessages.has(message)) { 17916 var _console; 17917 visitedMessages.add(message); 17918 (_console = console).warn.apply(_console, getFormattedMessage(message)); 17919 } 17920 } 17921 function errorWhen(condition, message) { 17922 if (condition && !visitedMessages.has(message)) { 17923 var _console2; 17924 visitedMessages.add(message); 17925 (_console2 = console).error.apply(_console2, getFormattedMessage(message)); 17926 } 17927 } 17928 function validateTargets(targets) { 17929 var didPassFalsyValue = !targets; 17930 var didPassPlainObject = Object.prototype.toString.call(targets) === "[object Object]" && !targets.addEventListener; 17931 errorWhen(didPassFalsyValue, ["tippy() was passed", "`" + String(targets) + "`", "as its targets (first) argument. Valid types are: String, Element,", "Element[], or NodeList."].join(" ")); 17932 errorWhen(didPassPlainObject, ["tippy() was passed a plain object which is not supported as an argument", "for virtual positioning. Use props.getReferenceClientRect instead."].join(" ")); 17933 } 17934 var pluginProps = { 17935 animateFill: false, 17936 followCursor: false, 17937 inlinePositioning: false, 17938 sticky: false 17939 }; 17940 var renderProps = { 17941 allowHTML: false, 17942 animation: "fade", 17943 arrow: true, 17944 content: "", 17945 inertia: false, 17946 maxWidth: 350, 17947 role: "tooltip", 17948 theme: "", 17949 zIndex: 9999 17950 }; 17951 var defaultProps = Object.assign({ 17952 appendTo: TIPPY_DEFAULT_APPEND_TO, 17953 aria: { 17954 content: "auto", 17955 expanded: "auto" 17956 }, 17957 delay: 0, 17958 duration: [300, 250], 17959 getReferenceClientRect: null, 17960 hideOnClick: true, 17961 ignoreAttributes: false, 17962 interactive: false, 17963 interactiveBorder: 2, 17964 interactiveDebounce: 0, 17965 moveTransition: "", 17966 offset: [0, 10], 17967 onAfterUpdate: function onAfterUpdate() { 17968 }, 17969 onBeforeUpdate: function onBeforeUpdate() { 17970 }, 17971 onCreate: function onCreate() { 17972 }, 17973 onDestroy: function onDestroy() { 17974 }, 17975 onHidden: function onHidden() { 17976 }, 17977 onHide: function onHide() { 17978 }, 17979 onMount: function onMount() { 17980 }, 17981 onShow: function onShow() { 17982 }, 17983 onShown: function onShown() { 17984 }, 17985 onTrigger: function onTrigger() { 17986 }, 17987 onUntrigger: function onUntrigger() { 17988 }, 17989 onClickOutside: function onClickOutside() { 17990 }, 17991 placement: "top", 17992 plugins: [], 17993 popperOptions: {}, 17994 render: null, 17995 showOnCreate: false, 17996 touch: true, 17997 trigger: "mouseenter focus", 17998 triggerTarget: null 17999 }, pluginProps, renderProps); 18000 var defaultKeys = Object.keys(defaultProps); 18001 var setDefaultProps = function setDefaultProps2(partialProps) { 18002 if (true) { 18003 validateProps(partialProps, []); 18004 } 18005 var keys = Object.keys(partialProps); 18006 keys.forEach(function(key) { 18007 defaultProps[key] = partialProps[key]; 18008 }); 18009 }; 18010 function getExtendedPassedProps(passedProps) { 18011 var plugins = passedProps.plugins || []; 18012 var pluginProps2 = plugins.reduce(function(acc, plugin) { 18013 var name = plugin.name, defaultValue = plugin.defaultValue; 18014 if (name) { 18015 var _name; 18016 acc[name] = passedProps[name] !== void 0 ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue; 18017 } 18018 return acc; 18019 }, {}); 18020 return Object.assign({}, passedProps, pluginProps2); 18021 } 18022 function getDataAttributeProps(reference2, plugins) { 18023 var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, { 18024 plugins 18025 }))) : defaultKeys; 18026 var props = propKeys.reduce(function(acc, key) { 18027 var valueAsString = (reference2.getAttribute("data-tippy-" + key) || "").trim(); 18028 if (!valueAsString) { 18029 return acc; 18030 } 18031 if (key === "content") { 18032 acc[key] = valueAsString; 18033 } else { 18034 try { 18035 acc[key] = JSON.parse(valueAsString); 18036 } catch (e2) { 18037 acc[key] = valueAsString; 18038 } 18039 } 18040 return acc; 18041 }, {}); 18042 return props; 18043 } 18044 function evaluateProps(reference2, props) { 18045 var out = Object.assign({}, props, { 18046 content: invokeWithArgsOrReturn(props.content, [reference2]) 18047 }, props.ignoreAttributes ? {} : getDataAttributeProps(reference2, props.plugins)); 18048 out.aria = Object.assign({}, defaultProps.aria, out.aria); 18049 out.aria = { 18050 expanded: out.aria.expanded === "auto" ? props.interactive : out.aria.expanded, 18051 content: out.aria.content === "auto" ? props.interactive ? null : "describedby" : out.aria.content 18052 }; 18053 return out; 18054 } 18055 function validateProps(partialProps, plugins) { 18056 if (partialProps === void 0) { 18057 partialProps = {}; 18058 } 18059 if (plugins === void 0) { 18060 plugins = []; 18061 } 18062 var keys = Object.keys(partialProps); 18063 keys.forEach(function(prop) { 18064 var nonPluginProps = removeProperties(defaultProps, Object.keys(pluginProps)); 18065 var didPassUnknownProp = !hasOwnProperty(nonPluginProps, prop); 18066 if (didPassUnknownProp) { 18067 didPassUnknownProp = plugins.filter(function(plugin) { 18068 return plugin.name === prop; 18069 }).length === 0; 18070 } 18071 warnWhen(didPassUnknownProp, ["`" + prop + "`", "is not a valid prop. You may have spelled it incorrectly, or if it's", "a plugin, forgot to pass it in an array as props.plugins.", "\n\n", "All props: https://atomiks.github.io/tippyjs/v6/all-props/\n", "Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" ")); 18072 }); 18073 } 18074 var innerHTML = function innerHTML2() { 18075 return "innerHTML"; 18076 }; 18077 function dangerouslySetInnerHTML(element, html) { 18078 element[innerHTML()] = html; 18079 } 18080 function createArrowElement(value) { 18081 var arrow2 = div(); 18082 if (value === true) { 18083 arrow2.className = ARROW_CLASS; 18084 } else { 18085 arrow2.className = SVG_ARROW_CLASS; 18086 if (isElement2(value)) { 18087 arrow2.appendChild(value); 18088 } else { 18089 dangerouslySetInnerHTML(arrow2, value); 18090 } 18091 } 18092 return arrow2; 18093 } 18094 function setContent(content, props) { 18095 if (isElement2(props.content)) { 18096 dangerouslySetInnerHTML(content, ""); 18097 content.appendChild(props.content); 18098 } else if (typeof props.content !== "function") { 18099 if (props.allowHTML) { 18100 dangerouslySetInnerHTML(content, props.content); 18101 } else { 18102 content.textContent = props.content; 18103 } 18104 } 18105 } 18106 function getChildren(popper2) { 18107 var box = popper2.firstElementChild; 18108 var boxChildren = arrayFrom(box.children); 18109 return { 18110 box, 18111 content: boxChildren.find(function(node) { 18112 return node.classList.contains(CONTENT_CLASS); 18113 }), 18114 arrow: boxChildren.find(function(node) { 18115 return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS); 18116 }), 18117 backdrop: boxChildren.find(function(node) { 18118 return node.classList.contains(BACKDROP_CLASS); 18119 }) 18120 }; 18121 } 18122 function render(instance) { 18123 var popper2 = div(); 18124 var box = div(); 18125 box.className = BOX_CLASS; 18126 box.setAttribute("data-state", "hidden"); 18127 box.setAttribute("tabindex", "-1"); 18128 var content = div(); 18129 content.className = CONTENT_CLASS; 18130 content.setAttribute("data-state", "hidden"); 18131 setContent(content, instance.props); 18132 popper2.appendChild(box); 18133 box.appendChild(content); 18134 onUpdate(instance.props, instance.props); 18135 function onUpdate(prevProps, nextProps) { 18136 var _getChildren = getChildren(popper2), box2 = _getChildren.box, content2 = _getChildren.content, arrow2 = _getChildren.arrow; 18137 if (nextProps.theme) { 18138 box2.setAttribute("data-theme", nextProps.theme); 18139 } else { 18140 box2.removeAttribute("data-theme"); 18141 } 18142 if (typeof nextProps.animation === "string") { 18143 box2.setAttribute("data-animation", nextProps.animation); 18144 } else { 18145 box2.removeAttribute("data-animation"); 18146 } 18147 if (nextProps.inertia) { 18148 box2.setAttribute("data-inertia", ""); 18149 } else { 18150 box2.removeAttribute("data-inertia"); 18151 } 18152 box2.style.maxWidth = typeof nextProps.maxWidth === "number" ? nextProps.maxWidth + "px" : nextProps.maxWidth; 18153 if (nextProps.role) { 18154 box2.setAttribute("role", nextProps.role); 18155 } else { 18156 box2.removeAttribute("role"); 18157 } 18158 if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) { 18159 setContent(content2, instance.props); 18160 } 18161 if (nextProps.arrow) { 18162 if (!arrow2) { 18163 box2.appendChild(createArrowElement(nextProps.arrow)); 18164 } else if (prevProps.arrow !== nextProps.arrow) { 18165 box2.removeChild(arrow2); 18166 box2.appendChild(createArrowElement(nextProps.arrow)); 18167 } 18168 } else if (arrow2) { 18169 box2.removeChild(arrow2); 18170 } 18171 } 18172 return { 18173 popper: popper2, 18174 onUpdate 18175 }; 18176 } 18177 render.$$tippy = true; 18178 var idCounter = 1; 18179 var mouseMoveListeners = []; 18180 var mountedInstances = []; 18181 function createTippy(reference2, passedProps) { 18182 var props = evaluateProps(reference2, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps)))); 18183 var showTimeout; 18184 var hideTimeout; 18185 var scheduleHideAnimationFrame; 18186 var isVisibleFromClick = false; 18187 var didHideDueToDocumentMouseDown = false; 18188 var didTouchMove = false; 18189 var ignoreOnFirstUpdate = false; 18190 var lastTriggerEvent; 18191 var currentTransitionEndListener; 18192 var onFirstUpdate; 18193 var listeners = []; 18194 var debouncedOnMouseMove = debounce2(onMouseMove, props.interactiveDebounce); 18195 var currentTarget; 18196 var id = idCounter++; 18197 var popperInstance = null; 18198 var plugins = unique(props.plugins); 18199 var state = { 18200 isEnabled: true, 18201 isVisible: false, 18202 isDestroyed: false, 18203 isMounted: false, 18204 isShown: false 18205 }; 18206 var instance = { 18207 id, 18208 reference: reference2, 18209 popper: div(), 18210 popperInstance, 18211 props, 18212 state, 18213 plugins, 18214 clearDelayTimeouts, 18215 setProps, 18216 setContent: setContent2, 18217 show, 18218 hide: hide2, 18219 hideWithInteractivity, 18220 enable, 18221 disable, 18222 unmount, 18223 destroy: destroy2 18224 }; 18225 if (!props.render) { 18226 if (true) { 18227 errorWhen(true, "render() function has not been supplied."); 18228 } 18229 return instance; 18230 } 18231 var _props$render = props.render(instance), popper2 = _props$render.popper, onUpdate = _props$render.onUpdate; 18232 popper2.setAttribute("data-tippy-root", ""); 18233 popper2.id = "tippy-" + instance.id; 18234 instance.popper = popper2; 18235 reference2._tippy = instance; 18236 popper2._tippy = instance; 18237 var pluginsHooks = plugins.map(function(plugin) { 18238 return plugin.fn(instance); 18239 }); 18240 var hasAriaExpanded = reference2.hasAttribute("aria-expanded"); 18241 addListeners(); 18242 handleAriaExpandedAttribute(); 18243 handleStyles(); 18244 invokeHook("onCreate", [instance]); 18245 if (props.showOnCreate) { 18246 scheduleShow(); 18247 } 18248 popper2.addEventListener("mouseenter", function() { 18249 if (instance.props.interactive && instance.state.isVisible) { 18250 instance.clearDelayTimeouts(); 18251 } 18252 }); 18253 popper2.addEventListener("mouseleave", function() { 18254 if (instance.props.interactive && instance.props.trigger.indexOf("mouseenter") >= 0) { 18255 getDocument().addEventListener("mousemove", debouncedOnMouseMove); 18256 } 18257 }); 18258 return instance; 18259 function getNormalizedTouchSettings() { 18260 var touch = instance.props.touch; 18261 return Array.isArray(touch) ? touch : [touch, 0]; 18262 } 18263 function getIsCustomTouchBehavior() { 18264 return getNormalizedTouchSettings()[0] === "hold"; 18265 } 18266 function getIsDefaultRenderFn() { 18267 var _instance$props$rende; 18268 return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy); 18269 } 18270 function getCurrentTarget() { 18271 return currentTarget || reference2; 18272 } 18273 function getDocument() { 18274 var parent = getCurrentTarget().parentNode; 18275 return parent ? getOwnerDocument(parent) : document; 18276 } 18277 function getDefaultTemplateChildren() { 18278 return getChildren(popper2); 18279 } 18280 function getDelay(isShow) { 18281 if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === "focus") { 18282 return 0; 18283 } 18284 return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay); 18285 } 18286 function handleStyles(fromHide) { 18287 if (fromHide === void 0) { 18288 fromHide = false; 18289 } 18290 popper2.style.pointerEvents = instance.props.interactive && !fromHide ? "" : "none"; 18291 popper2.style.zIndex = "" + instance.props.zIndex; 18292 } 18293 function invokeHook(hook, args, shouldInvokePropsHook) { 18294 if (shouldInvokePropsHook === void 0) { 18295 shouldInvokePropsHook = true; 18296 } 18297 pluginsHooks.forEach(function(pluginHooks) { 18298 if (pluginHooks[hook]) { 18299 pluginHooks[hook].apply(pluginHooks, args); 18300 } 18301 }); 18302 if (shouldInvokePropsHook) { 18303 var _instance$props; 18304 (_instance$props = instance.props)[hook].apply(_instance$props, args); 18305 } 18306 } 18307 function handleAriaContentAttribute() { 18308 var aria = instance.props.aria; 18309 if (!aria.content) { 18310 return; 18311 } 18312 var attr = "aria-" + aria.content; 18313 var id2 = popper2.id; 18314 var nodes = normalizeToArray(instance.props.triggerTarget || reference2); 18315 nodes.forEach(function(node) { 18316 var currentValue = node.getAttribute(attr); 18317 if (instance.state.isVisible) { 18318 node.setAttribute(attr, currentValue ? currentValue + " " + id2 : id2); 18319 } else { 18320 var nextValue = currentValue && currentValue.replace(id2, "").trim(); 18321 if (nextValue) { 18322 node.setAttribute(attr, nextValue); 18323 } else { 18324 node.removeAttribute(attr); 18325 } 18326 } 18327 }); 18328 } 18329 function handleAriaExpandedAttribute() { 18330 if (hasAriaExpanded || !instance.props.aria.expanded) { 18331 return; 18332 } 18333 var nodes = normalizeToArray(instance.props.triggerTarget || reference2); 18334 nodes.forEach(function(node) { 18335 if (instance.props.interactive) { 18336 node.setAttribute("aria-expanded", instance.state.isVisible && node === getCurrentTarget() ? "true" : "false"); 18337 } else { 18338 node.removeAttribute("aria-expanded"); 18339 } 18340 }); 18341 } 18342 function cleanupInteractiveMouseListeners() { 18343 getDocument().removeEventListener("mousemove", debouncedOnMouseMove); 18344 mouseMoveListeners = mouseMoveListeners.filter(function(listener) { 18345 return listener !== debouncedOnMouseMove; 18346 }); 18347 } 18348 function onDocumentPress(event) { 18349 if (currentInput.isTouch) { 18350 if (didTouchMove || event.type === "mousedown") { 18351 return; 18352 } 18353 } 18354 var actualTarget = event.composedPath && event.composedPath()[0] || event.target; 18355 if (instance.props.interactive && actualContains(popper2, actualTarget)) { 18356 return; 18357 } 18358 if (normalizeToArray(instance.props.triggerTarget || reference2).some(function(el) { 18359 return actualContains(el, actualTarget); 18360 })) { 18361 if (currentInput.isTouch) { 18362 return; 18363 } 18364 if (instance.state.isVisible && instance.props.trigger.indexOf("click") >= 0) { 18365 return; 18366 } 18367 } else { 18368 invokeHook("onClickOutside", [instance, event]); 18369 } 18370 if (instance.props.hideOnClick === true) { 18371 instance.clearDelayTimeouts(); 18372 instance.hide(); 18373 didHideDueToDocumentMouseDown = true; 18374 setTimeout(function() { 18375 didHideDueToDocumentMouseDown = false; 18376 }); 18377 if (!instance.state.isMounted) { 18378 removeDocumentPress(); 18379 } 18380 } 18381 } 18382 function onTouchMove() { 18383 didTouchMove = true; 18384 } 18385 function onTouchStart() { 18386 didTouchMove = false; 18387 } 18388 function addDocumentPress() { 18389 var doc = getDocument(); 18390 doc.addEventListener("mousedown", onDocumentPress, true); 18391 doc.addEventListener("touchend", onDocumentPress, TOUCH_OPTIONS); 18392 doc.addEventListener("touchstart", onTouchStart, TOUCH_OPTIONS); 18393 doc.addEventListener("touchmove", onTouchMove, TOUCH_OPTIONS); 18394 } 18395 function removeDocumentPress() { 18396 var doc = getDocument(); 18397 doc.removeEventListener("mousedown", onDocumentPress, true); 18398 doc.removeEventListener("touchend", onDocumentPress, TOUCH_OPTIONS); 18399 doc.removeEventListener("touchstart", onTouchStart, TOUCH_OPTIONS); 18400 doc.removeEventListener("touchmove", onTouchMove, TOUCH_OPTIONS); 18401 } 18402 function onTransitionedOut(duration2, callback) { 18403 onTransitionEnd(duration2, function() { 18404 if (!instance.state.isVisible && popper2.parentNode && popper2.parentNode.contains(popper2)) { 18405 callback(); 18406 } 18407 }); 18408 } 18409 function onTransitionedIn(duration2, callback) { 18410 onTransitionEnd(duration2, callback); 18411 } 18412 function onTransitionEnd(duration2, callback) { 18413 var box = getDefaultTemplateChildren().box; 18414 function listener(event) { 18415 if (event.target === box) { 18416 updateTransitionEndListener(box, "remove", listener); 18417 callback(); 18418 } 18419 } 18420 if (duration2 === 0) { 18421 return callback(); 18422 } 18423 updateTransitionEndListener(box, "remove", currentTransitionEndListener); 18424 updateTransitionEndListener(box, "add", listener); 18425 currentTransitionEndListener = listener; 18426 } 18427 function on(eventType, handler, options2) { 18428 if (options2 === void 0) { 18429 options2 = false; 18430 } 18431 var nodes = normalizeToArray(instance.props.triggerTarget || reference2); 18432 nodes.forEach(function(node) { 18433 node.addEventListener(eventType, handler, options2); 18434 listeners.push({ 18435 node, 18436 eventType, 18437 handler, 18438 options: options2 18439 }); 18440 }); 18441 } 18442 function addListeners() { 18443 if (getIsCustomTouchBehavior()) { 18444 on("touchstart", onTrigger2, { 18445 passive: true 18446 }); 18447 on("touchend", onMouseLeave, { 18448 passive: true 18449 }); 18450 } 18451 splitBySpaces(instance.props.trigger).forEach(function(eventType) { 18452 if (eventType === "manual") { 18453 return; 18454 } 18455 on(eventType, onTrigger2); 18456 switch (eventType) { 18457 case "mouseenter": 18458 on("mouseleave", onMouseLeave); 18459 break; 18460 case "focus": 18461 on(isIE11 ? "focusout" : "blur", onBlurOrFocusOut); 18462 break; 18463 case "focusin": 18464 on("focusout", onBlurOrFocusOut); 18465 break; 18466 } 18467 }); 18468 } 18469 function removeListeners() { 18470 listeners.forEach(function(_ref) { 18471 var node = _ref.node, eventType = _ref.eventType, handler = _ref.handler, options2 = _ref.options; 18472 node.removeEventListener(eventType, handler, options2); 18473 }); 18474 listeners = []; 18475 } 18476 function onTrigger2(event) { 18477 var _lastTriggerEvent; 18478 var shouldScheduleClickHide = false; 18479 if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) { 18480 return; 18481 } 18482 var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === "focus"; 18483 lastTriggerEvent = event; 18484 currentTarget = event.currentTarget; 18485 handleAriaExpandedAttribute(); 18486 if (!instance.state.isVisible && isMouseEvent(event)) { 18487 mouseMoveListeners.forEach(function(listener) { 18488 return listener(event); 18489 }); 18490 } 18491 if (event.type === "click" && (instance.props.trigger.indexOf("mouseenter") < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) { 18492 shouldScheduleClickHide = true; 18493 } else { 18494 scheduleShow(event); 18495 } 18496 if (event.type === "click") { 18497 isVisibleFromClick = !shouldScheduleClickHide; 18498 } 18499 if (shouldScheduleClickHide && !wasFocused) { 18500 scheduleHide(event); 18501 } 18502 } 18503 function onMouseMove(event) { 18504 var target = event.target; 18505 var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper2.contains(target); 18506 if (event.type === "mousemove" && isCursorOverReferenceOrPopper) { 18507 return; 18508 } 18509 var popperTreeData = getNestedPopperTree().concat(popper2).map(function(popper3) { 18510 var _instance$popperInsta; 18511 var instance2 = popper3._tippy; 18512 var state2 = (_instance$popperInsta = instance2.popperInstance) == null ? void 0 : _instance$popperInsta.state; 18513 if (state2) { 18514 return { 18515 popperRect: popper3.getBoundingClientRect(), 18516 popperState: state2, 18517 props 18518 }; 18519 } 18520 return null; 18521 }).filter(Boolean); 18522 if (isCursorOutsideInteractiveBorder(popperTreeData, event)) { 18523 cleanupInteractiveMouseListeners(); 18524 scheduleHide(event); 18525 } 18526 } 18527 function onMouseLeave(event) { 18528 var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf("click") >= 0 && isVisibleFromClick; 18529 if (shouldBail) { 18530 return; 18531 } 18532 if (instance.props.interactive) { 18533 instance.hideWithInteractivity(event); 18534 return; 18535 } 18536 scheduleHide(event); 18537 } 18538 function onBlurOrFocusOut(event) { 18539 if (instance.props.trigger.indexOf("focusin") < 0 && event.target !== getCurrentTarget()) { 18540 return; 18541 } 18542 if (instance.props.interactive && event.relatedTarget && popper2.contains(event.relatedTarget)) { 18543 return; 18544 } 18545 scheduleHide(event); 18546 } 18547 function isEventListenerStopped(event) { 18548 return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf("touch") >= 0 : false; 18549 } 18550 function createPopperInstance() { 18551 destroyPopperInstance(); 18552 var _instance$props2 = instance.props, popperOptions = _instance$props2.popperOptions, placement = _instance$props2.placement, offset2 = _instance$props2.offset, getReferenceClientRect = _instance$props2.getReferenceClientRect, moveTransition = _instance$props2.moveTransition; 18553 var arrow2 = getIsDefaultRenderFn() ? getChildren(popper2).arrow : null; 18554 var computedReference = getReferenceClientRect ? { 18555 getBoundingClientRect: getReferenceClientRect, 18556 contextElement: getReferenceClientRect.contextElement || getCurrentTarget() 18557 } : reference2; 18558 var tippyModifier = { 18559 name: "$$tippy", 18560 enabled: true, 18561 phase: "beforeWrite", 18562 requires: ["computeStyles"], 18563 fn: function fn2(_ref2) { 18564 var state2 = _ref2.state; 18565 if (getIsDefaultRenderFn()) { 18566 var _getDefaultTemplateCh = getDefaultTemplateChildren(), box = _getDefaultTemplateCh.box; 18567 ["placement", "reference-hidden", "escaped"].forEach(function(attr) { 18568 if (attr === "placement") { 18569 box.setAttribute("data-placement", state2.placement); 18570 } else { 18571 if (state2.attributes.popper["data-popper-" + attr]) { 18572 box.setAttribute("data-" + attr, ""); 18573 } else { 18574 box.removeAttribute("data-" + attr); 18575 } 18576 } 18577 }); 18578 state2.attributes.popper = {}; 18579 } 18580 } 18581 }; 18582 var modifiers = [{ 18583 name: "offset", 18584 options: { 18585 offset: offset2 18586 } 18587 }, { 18588 name: "preventOverflow", 18589 options: { 18590 padding: { 18591 top: 2, 18592 bottom: 2, 18593 left: 5, 18594 right: 5 18595 } 18596 } 18597 }, { 18598 name: "flip", 18599 options: { 18600 padding: 5 18601 } 18602 }, { 18603 name: "computeStyles", 18604 options: { 18605 adaptive: !moveTransition 18606 } 18607 }, tippyModifier]; 18608 if (getIsDefaultRenderFn() && arrow2) { 18609 modifiers.push({ 18610 name: "arrow", 18611 options: { 18612 element: arrow2, 18613 padding: 3 18614 } 18615 }); 18616 } 18617 modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []); 18618 instance.popperInstance = createPopper(computedReference, popper2, Object.assign({}, popperOptions, { 18619 placement, 18620 onFirstUpdate, 18621 modifiers 18622 })); 18623 } 18624 function destroyPopperInstance() { 18625 if (instance.popperInstance) { 18626 instance.popperInstance.destroy(); 18627 instance.popperInstance = null; 18628 } 18629 } 18630 function mount() { 18631 var appendTo = instance.props.appendTo; 18632 var parentNode; 18633 var node = getCurrentTarget(); 18634 if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === "parent") { 18635 parentNode = node.parentNode; 18636 } else { 18637 parentNode = invokeWithArgsOrReturn(appendTo, [node]); 18638 } 18639 if (!parentNode.contains(popper2)) { 18640 parentNode.appendChild(popper2); 18641 } 18642 instance.state.isMounted = true; 18643 createPopperInstance(); 18644 if (true) { 18645 warnWhen(instance.props.interactive && appendTo === defaultProps.appendTo && node.nextElementSibling !== popper2, ["Interactive tippy element may not be accessible via keyboard", "navigation because it is not directly after the reference element", "in the DOM source order.", "\n\n", "Using a wrapper <div> or <span> tag around the reference element", "solves this by creating a new parentNode context.", "\n\n", "Specifying `appendTo: document.body` silences this warning, but it", "assumes you are using a focus management solution to handle", "keyboard navigation.", "\n\n", "See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" ")); 18646 } 18647 } 18648 function getNestedPopperTree() { 18649 return arrayFrom(popper2.querySelectorAll("[data-tippy-root]")); 18650 } 18651 function scheduleShow(event) { 18652 instance.clearDelayTimeouts(); 18653 if (event) { 18654 invokeHook("onTrigger", [instance, event]); 18655 } 18656 addDocumentPress(); 18657 var delay = getDelay(true); 18658 var _getNormalizedTouchSe = getNormalizedTouchSettings(), touchValue = _getNormalizedTouchSe[0], touchDelay = _getNormalizedTouchSe[1]; 18659 if (currentInput.isTouch && touchValue === "hold" && touchDelay) { 18660 delay = touchDelay; 18661 } 18662 if (delay) { 18663 showTimeout = setTimeout(function() { 18664 instance.show(); 18665 }, delay); 18666 } else { 18667 instance.show(); 18668 } 18669 } 18670 function scheduleHide(event) { 18671 instance.clearDelayTimeouts(); 18672 invokeHook("onUntrigger", [instance, event]); 18673 if (!instance.state.isVisible) { 18674 removeDocumentPress(); 18675 return; 18676 } 18677 if (instance.props.trigger.indexOf("mouseenter") >= 0 && instance.props.trigger.indexOf("click") >= 0 && ["mouseleave", "mousemove"].indexOf(event.type) >= 0 && isVisibleFromClick) { 18678 return; 18679 } 18680 var delay = getDelay(false); 18681 if (delay) { 18682 hideTimeout = setTimeout(function() { 18683 if (instance.state.isVisible) { 18684 instance.hide(); 18685 } 18686 }, delay); 18687 } else { 18688 scheduleHideAnimationFrame = requestAnimationFrame(function() { 18689 instance.hide(); 18690 }); 18691 } 18692 } 18693 function enable() { 18694 instance.state.isEnabled = true; 18695 } 18696 function disable() { 18697 instance.hide(); 18698 instance.state.isEnabled = false; 18699 } 18700 function clearDelayTimeouts() { 18701 clearTimeout(showTimeout); 18702 clearTimeout(hideTimeout); 18703 cancelAnimationFrame(scheduleHideAnimationFrame); 18704 } 18705 function setProps(partialProps) { 18706 if (true) { 18707 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("setProps")); 18708 } 18709 if (instance.state.isDestroyed) { 18710 return; 18711 } 18712 invokeHook("onBeforeUpdate", [instance, partialProps]); 18713 removeListeners(); 18714 var prevProps = instance.props; 18715 var nextProps = evaluateProps(reference2, Object.assign({}, prevProps, removeUndefinedProps(partialProps), { 18716 ignoreAttributes: true 18717 })); 18718 instance.props = nextProps; 18719 addListeners(); 18720 if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) { 18721 cleanupInteractiveMouseListeners(); 18722 debouncedOnMouseMove = debounce2(onMouseMove, nextProps.interactiveDebounce); 18723 } 18724 if (prevProps.triggerTarget && !nextProps.triggerTarget) { 18725 normalizeToArray(prevProps.triggerTarget).forEach(function(node) { 18726 node.removeAttribute("aria-expanded"); 18727 }); 18728 } else if (nextProps.triggerTarget) { 18729 reference2.removeAttribute("aria-expanded"); 18730 } 18731 handleAriaExpandedAttribute(); 18732 handleStyles(); 18733 if (onUpdate) { 18734 onUpdate(prevProps, nextProps); 18735 } 18736 if (instance.popperInstance) { 18737 createPopperInstance(); 18738 getNestedPopperTree().forEach(function(nestedPopper) { 18739 requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate); 18740 }); 18741 } 18742 invokeHook("onAfterUpdate", [instance, partialProps]); 18743 } 18744 function setContent2(content) { 18745 instance.setProps({ 18746 content 18747 }); 18748 } 18749 function show() { 18750 if (true) { 18751 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("show")); 18752 } 18753 var isAlreadyVisible = instance.state.isVisible; 18754 var isDestroyed = instance.state.isDestroyed; 18755 var isDisabled = !instance.state.isEnabled; 18756 var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch; 18757 var duration2 = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration); 18758 if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) { 18759 return; 18760 } 18761 if (getCurrentTarget().hasAttribute("disabled")) { 18762 return; 18763 } 18764 invokeHook("onShow", [instance], false); 18765 if (instance.props.onShow(instance) === false) { 18766 return; 18767 } 18768 instance.state.isVisible = true; 18769 if (getIsDefaultRenderFn()) { 18770 popper2.style.visibility = "visible"; 18771 } 18772 handleStyles(); 18773 addDocumentPress(); 18774 if (!instance.state.isMounted) { 18775 popper2.style.transition = "none"; 18776 } 18777 if (getIsDefaultRenderFn()) { 18778 var _getDefaultTemplateCh2 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh2.box, content = _getDefaultTemplateCh2.content; 18779 setTransitionDuration([box, content], 0); 18780 } 18781 onFirstUpdate = function onFirstUpdate2() { 18782 var _instance$popperInsta2; 18783 if (!instance.state.isVisible || ignoreOnFirstUpdate) { 18784 return; 18785 } 18786 ignoreOnFirstUpdate = true; 18787 void popper2.offsetHeight; 18788 popper2.style.transition = instance.props.moveTransition; 18789 if (getIsDefaultRenderFn() && instance.props.animation) { 18790 var _getDefaultTemplateCh3 = getDefaultTemplateChildren(), _box = _getDefaultTemplateCh3.box, _content = _getDefaultTemplateCh3.content; 18791 setTransitionDuration([_box, _content], duration2); 18792 setVisibilityState([_box, _content], "visible"); 18793 } 18794 handleAriaContentAttribute(); 18795 handleAriaExpandedAttribute(); 18796 pushIfUnique(mountedInstances, instance); 18797 (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate(); 18798 invokeHook("onMount", [instance]); 18799 if (instance.props.animation && getIsDefaultRenderFn()) { 18800 onTransitionedIn(duration2, function() { 18801 instance.state.isShown = true; 18802 invokeHook("onShown", [instance]); 18803 }); 18804 } 18805 }; 18806 mount(); 18807 } 18808 function hide2() { 18809 if (true) { 18810 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("hide")); 18811 } 18812 var isAlreadyHidden = !instance.state.isVisible; 18813 var isDestroyed = instance.state.isDestroyed; 18814 var isDisabled = !instance.state.isEnabled; 18815 var duration2 = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration); 18816 if (isAlreadyHidden || isDestroyed || isDisabled) { 18817 return; 18818 } 18819 invokeHook("onHide", [instance], false); 18820 if (instance.props.onHide(instance) === false) { 18821 return; 18822 } 18823 instance.state.isVisible = false; 18824 instance.state.isShown = false; 18825 ignoreOnFirstUpdate = false; 18826 isVisibleFromClick = false; 18827 if (getIsDefaultRenderFn()) { 18828 popper2.style.visibility = "hidden"; 18829 } 18830 cleanupInteractiveMouseListeners(); 18831 removeDocumentPress(); 18832 handleStyles(true); 18833 if (getIsDefaultRenderFn()) { 18834 var _getDefaultTemplateCh4 = getDefaultTemplateChildren(), box = _getDefaultTemplateCh4.box, content = _getDefaultTemplateCh4.content; 18835 if (instance.props.animation) { 18836 setTransitionDuration([box, content], duration2); 18837 setVisibilityState([box, content], "hidden"); 18838 } 18839 } 18840 handleAriaContentAttribute(); 18841 handleAriaExpandedAttribute(); 18842 if (instance.props.animation) { 18843 if (getIsDefaultRenderFn()) { 18844 onTransitionedOut(duration2, instance.unmount); 18845 } 18846 } else { 18847 instance.unmount(); 18848 } 18849 } 18850 function hideWithInteractivity(event) { 18851 if (true) { 18852 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("hideWithInteractivity")); 18853 } 18854 getDocument().addEventListener("mousemove", debouncedOnMouseMove); 18855 pushIfUnique(mouseMoveListeners, debouncedOnMouseMove); 18856 debouncedOnMouseMove(event); 18857 } 18858 function unmount() { 18859 if (true) { 18860 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("unmount")); 18861 } 18862 if (instance.state.isVisible) { 18863 instance.hide(); 18864 } 18865 if (!instance.state.isMounted) { 18866 return; 18867 } 18868 destroyPopperInstance(); 18869 getNestedPopperTree().forEach(function(nestedPopper) { 18870 nestedPopper._tippy.unmount(); 18871 }); 18872 if (popper2.parentNode) { 18873 popper2.parentNode.removeChild(popper2); 18874 } 18875 mountedInstances = mountedInstances.filter(function(i2) { 18876 return i2 !== instance; 18877 }); 18878 instance.state.isMounted = false; 18879 invokeHook("onHidden", [instance]); 18880 } 18881 function destroy2() { 18882 if (true) { 18883 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("destroy")); 18884 } 18885 if (instance.state.isDestroyed) { 18886 return; 18887 } 18888 instance.clearDelayTimeouts(); 18889 instance.unmount(); 18890 removeListeners(); 18891 delete reference2._tippy; 18892 instance.state.isDestroyed = true; 18893 invokeHook("onDestroy", [instance]); 18894 } 18895 } 18896 function tippy(targets, optionalProps) { 18897 if (optionalProps === void 0) { 18898 optionalProps = {}; 18899 } 18900 var plugins = defaultProps.plugins.concat(optionalProps.plugins || []); 18901 if (true) { 18902 validateTargets(targets); 18903 validateProps(optionalProps, plugins); 18904 } 18905 bindGlobalEventListeners(); 18906 var passedProps = Object.assign({}, optionalProps, { 18907 plugins 18908 }); 18909 var elements3 = getArrayOfElements(targets); 18910 if (true) { 18911 var isSingleContentElement = isElement2(passedProps.content); 18912 var isMoreThanOneReferenceElement = elements3.length > 1; 18913 warnWhen(isSingleContentElement && isMoreThanOneReferenceElement, ["tippy() was passed an Element as the `content` prop, but more than", "one tippy instance was created by this invocation. This means the", "content element will only be appended to the last tippy instance.", "\n\n", "Instead, pass the .innerHTML of the element, or use a function that", "returns a cloned version of the element instead.", "\n\n", "1) content: element.innerHTML\n", "2) content: () => element.cloneNode(true)"].join(" ")); 18914 } 18915 var instances = elements3.reduce(function(acc, reference2) { 18916 var instance = reference2 && createTippy(reference2, passedProps); 18917 if (instance) { 18918 acc.push(instance); 18919 } 18920 return acc; 18921 }, []); 18922 return isElement2(targets) ? instances[0] : instances; 18923 } 18924 tippy.defaultProps = defaultProps; 18925 tippy.setDefaultProps = setDefaultProps; 18926 tippy.currentInput = currentInput; 18927 var applyStylesModifier = Object.assign({}, applyStyles_default, { 18928 effect: function effect4(_ref) { 18929 var state = _ref.state; 18930 var initialStyles = { 18931 popper: { 18932 position: state.options.strategy, 18933 left: "0", 18934 top: "0", 18935 margin: "0" 18936 }, 18937 arrow: { 18938 position: "absolute" 18939 }, 18940 reference: {} 18941 }; 18942 Object.assign(state.elements.popper.style, initialStyles.popper); 18943 state.styles = initialStyles; 18944 if (state.elements.arrow) { 18945 Object.assign(state.elements.arrow.style, initialStyles.arrow); 18946 } 18947 } 18948 }); 18949 tippy.setDefaultProps({ 18950 render 18951 }); 18952 var tippy_esm_default = tippy; 18953 18954
18954// controllers/clipboard_controller.js 18955 var clipboard_controller_default = class extends Controller { 18956 connect() { 18957 this.clipboard = new import_clipboard.default(this.element); 18958 this.clipboard.on("success", (e2) => this.tooltip(this.successMessage)); 18959 this.clipboard.on("error", (e2) => this.tooltip(this.errorMessage)); 18960 } 18961 tooltip(message) { 18962 tippy_esm_default(this.element, { 18963 content: message, 18964 showOnCreate: true, 18965 onHidden: (instance) => { 18966 instance.destroy(); 18967 } 18968 }); 18969 } 18970 get successMessage() { 18971 return this.successMessageValue || "Copied!"; 18972 } 18973 get errorMessage() { 18974 return this.errorMessageValue || "Failed!"; 18975 } 18976 }; 18977 __publicField(clipboard_controller_default, "values", { 18978 successMessage: String, 18979 errorMessage: String 18980 }); 18981 18982
18982// controllers/disable_controller.js 18983 var disable_controller_exports = {}; 18984 __export(disable_controller_exports, { 18985 default: () => disable_controller_default 18986 }); 18987 var disable_controller_default = class extends Controller { 18988 connect() { 18989 this.updateSubmitButtonState(); 18990 } 18991 updateSubmitButtonState() { 18992 if (this.checkboxTarget.checked) { 18993 this.submitTarget.removeAttribute("disabled"); 18994 } else { 18995 this.submitTarget.setAttribute("disabled", "disabled"); 18996 } 18997 } 18998 }; 18999 __publicField(disable_controller_default, "targets", ["checkbox", "submit"]); 19000 19001
19001// controllers/expandable_section_controller.js 19002 var expandable_section_controller_exports = {}; 19003 __export(expandable_section_controller_exports, { 19004 default: () => expandable_section_controller_default 19005 }); 19006 var expandable_section_controller_default = class extends Controller { 19007 connect() { 19008 this.expanded = false; 19009 } 19010 toggle(event) { 19011 event.preventDefault(); 19012 if (!this.hasContentTarget) { 19013 return; 19014 } 19015 this.contentTargets.forEach((el) => el.classList.toggle("hidden")); 19016 this.expanded = !this.expanded; 19017 if (this.hasToggleTarget) { 19018 if (!this.iconOnlyValue) { 19019 const text = this.expanded ? this.element.dataset.hideText || "Show less" : this.element.dataset.showText || "See all"; 19020 this.toggleTarget.textContent = text; 19021 } 19022 this.toggleTarget.setAttribute("aria-expanded", this.expanded); 19023 } 19024 this.element.classList.toggle("expanded", this.expanded); 19025 if (this.hasIconTarget) { 19026 this.iconTarget.classList.toggle("rotate-180", this.expanded); 19027 } 19028 } 19029 stop(event) { 19030 event.stopPropagation(); 19031 } 19032 }; 19033 __publicField(expandable_section_controller_default, "targets", ["content", "toggle", "icon"]); 19034 __publicField(expandable_section_controller_default, "values", { iconOnly: { type: Boolean, default: false } }); 19035 19036
19036// controllers/form_controller.js 19037 var form_controller_exports = {}; 19038 __export(form_controller_exports, { 19039 default: () => form_controller_default 19040 }); 19041 var form_controller_default = class extends Controller { 19042 connect() { 19043 if (this.hasForm_errorTarget) { 19044 this.errorMessage(this.emailTarget); 19045 } 19046 } 19047 errorMessage(element) { 19048 let error2; 19049 if (element.value === "") { 19050 error2 = "This field can't be blank."; 19051 } else { 19052 error2 = "Please enter an email address."; 19053 } 19054 this.form_errorTarget.innerText = error2; 19055 this.form_errorTarget.classList.remove("hidden"); 19056 this.iconTarget.classList.remove("hidden"); 19057 element.classList.add("text-[#7F1D1D]"); 19058 element.classList.add("border-[#FCA5A5]"); 19059 } 19060 handleError(event) { 19061 if (event.target.value != "") { 19062 if (this.hasForm_errorTarget) { 19063 this.form_errorTarget.classList.add("hidden"); 19064 } 19065 this.iconTarget.classList.add("hidden"); 19066 this.emailTarget.classList.remove("text-[#7F1D1D]"); 19067 this.emailTarget.classList.remove("border-[#FCA5A5]"); 19068 } 19069 } 19070 }; 19071 __publicField(form_controller_default, "targets", ["email", "form_error", "icon"]); 19072 19073
19073// controllers/group_session_form_controller.js 19074 var group_session_form_controller_exports = {}; 19075 __export(group_session_form_controller_exports, { 19076 default: () => group_session_form_controller_default 19077 }); 19078 var group_session_form_controller_default = class extends Controller { 19079 connect() { 19080 this.refreshEmptyState(); 19081 } 19082 addSelected(event) { 19083 event?.preventDefault(); 19084 if (!this.hasPickerTarget || !this.hasQueueListTarget) 19085 return; 19086 const selected = Array.from(this.pickerTarget.selectedOptions); 19087 selected.forEach((option) => this.appendQueueItem(option.value, option.text)); 19088 this.refreshEmptyState(); 19089 } 19090 prepareSubmit(event) { 19091 this.addSelected(); 19092 if (!this.hasQueueListTarget || this.queueListTarget.querySelectorAll("li").length > 0) 19093 return; 19094 event.preventDefault(); 19095 window.alert("Please add at least one session to queue."); 19096 } 19097 moveUp(event) { 19098 event.preventDefault(); 19099 const item = event.currentTarget.closest("li"); 19100 if (!item || !item.previousElementSibling) 19101 return; 19102 item.parentNode.insertBefore(item, item.previousElementSibling); 19103 } 19104 moveDown(event) { 19105 event.preventDefault(); 19106 const item = event.currentTarget.closest("li"); 19107 if (!item || !item.nextElementSibling) 19108 return; 19109 item.parentNode.insertBefore(item.nextElementSibling, item); 19110 } 19111 removeItem(event) { 19112 event.preventDefault(); 19113 event.currentTarget.closest("li")?.remove(); 19114 this.refreshEmptyState(); 19115 } 19116 appendQueueItem(sessionId, sessionTitle) { 19117 if (!sessionId) 19118 return; 19119 if (this.queueListTarget.querySelector(`[data-session-id="${sessionId}"]`)) 19120 return; 19121 const li = document.createElement("li"); 19122 li.dataset.sessionId = sessionId; 19123 li.dataset.sessionTitle = sessionTitle; 19124 li.className = "group-session-queue-item"; 19125 li.innerHTML = ` 19126 <span class="group-session-queue-item-title">${sessionTitle}</span> 19127 <a href="#" class="button group-session-queue-btn" data-action="group-session-form#moveUp">\u2191</a> 19128 <a href="#" class="button group-session-queue-btn" data-action="group-session-form#moveDown">\u2193</a> 19129 <a href="#" class="button button--danger group-session-queue-remove" data-action="group-session-form#removeItem">Remove</a> 19130 <input type="hidden" name="group_session[tap_session_ids][]" value="${sessionId}"> 19131 `; 19132 this.queueListTarget.appendChild(li); 19133 this.refreshEmptyState(); 19134 } 19135 refreshEmptyState() { 19136 if (!this.hasEmptyStateTarget || !this.hasQueueListTarget) 19137 return; 19138 const hasItems = this.queueListTarget.querySelectorAll("li").length > 0; 19139 this.emptyStateTarget.style.display = hasItems ? "none" : "block"; 19140 } 19141 }; 19142 __publicField(group_session_form_controller_default, "targets", ["picker", "queueList", "emptyState"]); 19143 19144
19144// controllers/group_session_realtime_controller.js 19145 var group_session_realtime_controller_exports = {}; 19146 __export(group_session_realtime_controller_exports, { 19147 default: () => group_session_realtime_controller_default 19148 }); 19149 var group_session_realtime_controller_default = class extends Controller { 19150 connect() { 19151 this.subscriptionReady = false; 19152 this.handleVisibilityChange = this.handleVisibilityChange.bind(this); 19153 this.subscribe(); 19154 this.updateProgress(); 19155 if (this.statusValue === "in_progress") 19156 this.startProgressTimer(); 19157 this.refreshParticipantsSnapshot(); 19158 document.addEventListener("visibilitychange", this.handleVisibilityChange); 19159 } 19160 disconnect() { 19161 this.subscriptionReady = false; 19162 this.safeUnsubscribe(); 19163 this.stopHeartbeatTimer(); 19164 this.stopProgressTimer(); 19165 document.removeEventListener("visibilitychange", this.handleVisibilityChange); 19166 } 19167 subscribe() { 19168 if (!this.hasSessionIdValue) 19169 return; 19170 this.subscription = consumer_default.subscriptions.create({ channel: "GroupSessionChannel", group_session_id: this.sessionIdValue }, { 19171 connected: () => { 19172 this.subscriptionReady = true; 19173 this.startHeartbeatTimer(); 19174 this.requestStatus(); 19175 }, 19176 disconnected: () => { 19177 this.subscriptionReady = false; 19178 this.stopHeartbeatTimer(); 19179 }, 19180 rejected: () => { 19181 this.subscriptionReady = false; 19182 this.stopHeartbeatTimer(); 19183 }, 19184 received: (data) => this.handleEvent(data) 19185 }); 19186 } 19187 handleEvent(data) { 19188 const event = data.event; 19189 if (event === "participant_joined" || event === "participant_left") { 19190 this.upsertParticipant(data.participant); 19191 this.refreshParticipantsSnapshot(); 19192 } 19193 if (event === "participant_ready") { 19194 this.upsertParticipant(data.participant); 19195 } 19196 if (event === "pause") { 19197 this.statusValue = "paused"; 19198 this.stopProgressTimer(); 19199 } 19200 if (event === "start") { 19201 this.statusValue = "in_progress"; 19202 this.currentPositionMsValue = 0; 19203 this.updateProgress(); 19204 this.startProgressTimer(); 19205 } 19206 if (event === "resume") { 19207 this.statusValue = "in_progress"; 19208 this.startProgressTimer(); 19209 } 19210 if (event === "next_item") 19211 this.updateNowPlaying(data); 19212 if (event === "current_status") 19213 this.applyCurrentStatus(data); 19214 if (event === "ended") { 19215 this.statusValue = "completed"; 19216 this.stopProgressTimer(); 19217 this.refreshStatusLabels(); 19218 this.reloadForStaleState(); 19219 return; 19220 } 19221 this.refreshStatusLabels(); 19222 } 19223 requestStatus() { 19224 if (!this.subscription || !this.subscriptionReady) 19225 return; 19226 try { 19227 this.subscription.perform("request_status", {}); 19228 } catch (_error) { 19229 } 19230 } 19231 handleVisibilityChange() { 19232 if (document.visibilityState === "visible") 19233 this.requestStatus(); 19234 } 19235 applyCurrentStatus(data) { 19236 if (data.tap_session_id !== void 0 && this.hasTapSessionIdValue) { 19237 const reportedTapSessionId = data.tap_session_id === null ? "" : String(data.tap_session_id); 19238 if (reportedTapSessionId !== this.tapSessionIdValue) { 19239 this.reloadForStaleState(); 19240 return; 19241 } 19242 } 19243 if (["completed", "cancelled", "expired"].includes(data.status)) { 19244 this.reloadForStaleState(); 19245 return; 19246 } 19247 this.statusValue = data.status; 19248 if (data.target_position_ms !== void 0) 19249 this.currentPositionMsValue = Number(data.target_position_ms); 19250 if (this.hasQueueIndicatorTarget && data.queue_indicator) 19251 this.queueIndicatorTarget.textContent = data.queue_indicator; 19252 if (this.hasParticipantCountTarget && data.participant_count !== void 0) { 19253 this.participantCountTarget.textContent = String(data.participant_count); 19254 } 19255 if (this.hasLiveCountTarget && data.live_count !== void 0) 19256 this.liveCountTarget.textContent = String(data.live_count); 19257 this.updateProgress(); 19258 this.refreshStatusLabels(); 19259 if (this.statusValue === "in_progress") { 19260 this.startProgressTimer(); 19261 } else { 19262 this.stopProgressTimer(); 19263 } 19264 } 19265 pause(event) { 19266 event?.preventDefault(); 19267 this.postTransportAction(this.pauseUrlValue); 19268 } 19269 resume(event) { 19270 event?.preventDefault(); 19271 this.postTransportAction(this.resumeUrlValue); 19272 } 19273 async postTransportAction(url) { 19274 if (!url) 19275 return; 19276 const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content"); 19277 const body = new URLSearchParams(); 19278 body.append("host_position_ms", String(this.currentPositionMsValue));
19279 try { 19280 const response = await fetch(url, { 19281 method: "POST", 19282 headers: { 19283 "X-CSRF-Token": csrfToken, 19284 Accept: "text/vnd.turbo-stream.html", 19285 "Content-Type": "application/x-www-form-urlencoded" 19286 }, 19287 body: body.toString() 19288 }); 19289 const html = await response.text(); 19290 turbo_es2017_esm_exports.renderStreamMessage(html); 19291 } catch (_error) { 19292 } 19293 } 19294 refreshParticipantsSnapshot() { 19295 if (!this.hasParticipantsUrlValue || this.participantsRefreshInFlight) 19296 return; 19297 this.participantsRefreshInFlight = true; 19298 window.fetch(this.participantsUrlValue, { headers: { Accept: "application/json" } }).then((response) => response.ok ? response.json() : null).then((payload) => { 19299 if (!payload || !Array.isArray(payload.participants) || !this.hasParticipantTableBodyTarget) 19300 return; 19301 const rowByUserId = new Map([...this.participantTableBodyTarget.querySelectorAll("tr")].map((row) => [String(row.dataset.participantId), row]));
19302 payload.participants.forEach((participant) => { 19303 const key = String(participant.user_id); 19304 let row = rowByUserId.get(key); 19305 if (!row) { 19306 row = document.createElement("tr"); 19307 row.dataset.participantId = participant.user_id; 19308 row.innerHTML = `<td>User #${participant.user_id}</td><td data-role="status"></td><td data-role="joined"></td><td data-role="heartbeat"></td><td data-role="ready"></td>`; 19309 this.participantTableBodyTarget.appendChild(row); 19310 } 19311 row.querySelector("td:first-child").textContent = participant.name || `User #${participant.user_id}`; 19312 row.querySelector('[data-role="status"]').textContent = participant.status || "-"; 19313 row.querySelector('[data-role="joined"]').textContent = participant.joined_at || "-"; 19314 row.querySelector('[data-role="heartbeat"]').textContent = participant.last_heartbeat_at || "-"; 19315 row.querySelector('[data-role="ready"]').textContent = participant.audio_downloaded ? "Ready" : "-"; 19316 }); 19317 if (this.hasParticipantCountTarget) 19318 this.participantCountTarget.textContent = String(payload.participant_count || 0); 19319 if (this.hasLiveCountTarget) 19320 this.liveCountTarget.textContent = String(payload.live_count || 0); 19321 }).catch(() => { 19322 }).finally(() => { 19323 this.participantsRefreshInFlight = false; 19324 }); 19325 } 19326 updateNowPlaying(data) { 19327 this.currentPositionMsValue = 0; 19328 if (data.total_duration_ms !== void 0) 19329 this.currentDurationMsValue = Number(data.total_duration_ms); 19330 if (data.tap_session_id !== void 0) 19331 this.tapSessionIdValue = String(data.tap_session_id); 19332 if (this.hasNowPlayingTitleTarget) 19333 this.nowPlayingTitleTarget.textContent = data.tap_session_title || "-"; 19334 if (this.hasQueueIndicatorTarget) 19335 this.queueIndicatorTarget.textContent = data.queue_indicator || "-"; 19336 if (this.hasNowPlayingImageTarget && data.tap_session_image_url) { 19337 this.nowPlayingImageTarget.src = data.tap_session_image_url; 19338 } 19339 this.updateProgress(); 19340 if (this.statusValue === "in_progress") 19341 this.startProgressTimer(); 19342 } 19343 upsertParticipant(participant) { 19344 if (!participant || !this.hasParticipantTableBodyTarget) 19345 return; 19346 const isHostRow = this.hasHostUserIdValue && String(participant.user_id) === this.hostUserIdValue; 19347 if (isHostRow) { 19348 const hostRow = this.participantTableBodyTarget.querySelector('[data-host-row="true"]'); 19349 if (!hostRow) 19350 return; 19351 hostRow.querySelector('[data-role="status"]').textContent = participant.status || "-"; 19352 hostRow.querySelector('[data-role="joined"]').textContent = participant.joined_at || "-"; 19353 hostRow.querySelector('[data-role="heartbeat"]').textContent = participant.last_heartbeat_at || "-"; 19354 hostRow.querySelector('[data-role="ready"]').textContent = participant.audio_downloaded ? "Ready" : "-"; 19355 return; 19356 } 19357 let row = this.participantTableBodyTarget.querySelector(`[data-
19357participant-id="${participant.user_id}"]`); 19358 if (!row) { 19359 row = document.createElement("tr"); 19360 row.dataset.participantId = participant.user_id; 19361 row.innerHTML = `<td>User #${participant.user_id}</td><td data-role="status"></td><td data-role="joined"></td><td data-role="heartbeat"></td><td data-role="ready"></td>`; 19362 this.participantTableBodyTarget.prepend(row); 19363 } 19364 row.querySelector("td:first-child").textContent = participant.name || `User #${participant.user_id}`; 19365 row.querySelector('[data-role="status"]').textContent = participant.status || "-"; 19366 row.querySelector('[data-role="joined"]').textContent = participant.joined_at || "-"; 19367 row.querySelector('[data-role="heartbeat"]').textContent = participant.last_heartbeat_at || "-"; 19368 row.querySelector('[data-role="ready"]').textContent = participant.audio_downloaded ? "Ready" : "-"; 19369 const nonHostRowCount = this.participantTableBodyTarget.querySelectorAll("tr:not([data-host-row])").length; 19370 this.participantCountTarget.textContent = nonHostRowCount; 19371 const activeCount = [...this.participantTableBodyTarget.querySelectorAll('tr:not([data-host-row]) [data-role="status"]')].filter((cell) => cell.textContent === "active").length; 19372 if (this.hasLiveCountTarget) 19373 this.liveCountTarget.textContent = activeCount; 19374 if (this.hasLiveCountLabelTarget && this.statusValue === "paused") { 19375 this.liveCountLabelTarget.textContent = `Paused \u2022 All ${activeCount} participants waiting for you to resume`; 19376 } 19377 } 19378 startProgressTimer() { 19379 this.stopProgressTimer(); 19380 this.itemFinishedReported = false; 19381 this.progressTimer = setInterval(() => { 19382 const duration2 = this.currentDurationMsValue || 0; 19383 this.currentPositionMsValue = Math.min(this.currentPositionMsValue + 1e3, duration2); 19384 this.updateProgress(); 19385 if (duration2 > 0 && this.currentPositionMsValue >= duration2) 19386 this.reportItemFinishedOnce(); 19387 }, 1e3); 19388 } 19389 reportItemFinishedOnce() { 19390 if (this.itemFinishedReported) 19391 return; 19392 this.itemFinishedReported = true; 19393 this.stopProgressTimer(); 19394 if (!this.subscription || !this.subscriptionReady) 19395 return; 19396 try { 19397 this.subscription.perform("item_finished", {}); 19398 } catch (_error) { 19399 } 19400 } 19401 stopProgressTimer() { 19402 if (!this.progressTimer) 19403 return; 19404 clearInterval(this.progressTimer); 19405 this.progressTimer = null; 19406 } 19407 startHeartbeatTimer() { 19408 this.stopHeartbeatTimer(); 19409 this.sendHeartbeat(); 19410 this.heartbeatTimer = setInterval(() => this.sendHeartbeat(), 1e4); 19411 } 19412 stopHeartbeatTimer() { 19413 if (!this.heartbeatTimer) 19414 return; 19415 clearInterval(this.heartbeatTimer); 19416 this.heartbeatTimer = null; 19417 } 19418 sendHeartbeat() { 19419 if (!this.subscription || !this.subscriptionReady) 19420 return; 19421 if (!(this.statusValue === "in_progress" || this.statusValue === "paused")) 19422 return; 19423 const activeSubscriptions = consumer_default.subscriptions.subscriptions || []; 19424 const stillSubscribed = activeSubscriptions.some((subscription) => subscription.identifier === this.subscription.identifier); 19425 if (!stillSubscribed) 19426 return; 19427 try { 19428 this.subscription.perform("heartbeat", { clock_offset_ms: 0 }); 19429 } catch (_error) { 19430 this.subscriptionReady = false; 19431 this.stopHeartbeatTimer(); 19432 } 19433 } 19434 updateProgress() { 19435 if (!this.hasProgressBarTarget || !this.currentDurationMsValue) 19436 return; 19437 const percent = Math.max(0, Math.min(100, this.currentPositionMsValue / this.currentDurationMsValue * 100)); 19438 this.progressBarTarget.style.width = `${percent}%`; 19439 if (this.hasCurrentTimeTarget) 19440 this.currentTimeTarget.textContent = this.formatMs(this.currentPositionMsValue); 19441 if (this.hasTotalTimeTarget) 19442 this.totalTimeTarget.textContent = this.formatMs(this.currentDurationMsValue); 19443 } 19444 refreshStatusLabels() { 19445 if (this.hasStatusLabelTarget) 19446 this.statusLabelTarget.textContent = (this.statusValue || "").replace("_", " "); 19447 } 19448 formatMs(ms) { 19449 const seconds = Math.floor((ms || 0) / 1e3); 19450 const minutes = Math.floor(seconds / 60); 19451 const remainder = seconds % 60; 19452 return `${minutes}:${String(remainder).padStart(2, "0")}`; 19453 } 19454 reloadForStaleState() { 19455 if (this.reloadTriggered) 19456 return; 19457 this.reloadTriggered = true; 19458 window.setTimeout(() => { 19459 window.location.reload(); 19460 }, 250); 19461 } 19462 safeUnsubscribe() { 19463 if (!this.subscription) 19464 return; 19465 const activeSubscriptions = consumer_default.subscriptions.subscriptions || []; 19466 const stillSubscribed = activeSubscriptions.some((subscription) => subscription.identifier === this.subscription.identifier); 19467 if (!stillSubscribed) 19468 return;
19469 try { 19470 this.subscription.unsubscribe(); 19471 } catch (_error) { 19472 } 19473 } 19474 }; 19475 __publicField(group_session_realtime_controller_default, "values", { 19476 sessionId: String, 19477 currentPositionMs: Number, 19478 currentDurationMs: Number, 19479 tapSessionId: String, 19480 status: String, 19481 participantsUrl: String, 19482 pauseUrl: String, 19483 resumeUrl: String, 19484 hostUserId: String 19485 }); 19486 __publicField(group_session_realtime_controller_default, "targets", [ 19487 "participantCount", 19488 "participantTableBody", 19489 "statusLabel", 19490 "liveCount", 19491 "liveCountLabel", 19492 "progressBar", 19493 "currentTime", 19494 "totalTime", 19495 "queueIndicator", 19496 "nowPlayingTitle", 19497 "nowPlayingImage" 19498 ]); 19499 19500
19500// controllers/marketing_materials_admin_controller.js 19501 var marketing_materials_admin_controller_exports = {}; 19502 __export(marketing_materials_admin_controller_exports, { 19503 default: () => marketing_materials_admin_controller_default 19504 }); 19505 19506
19506// src/confirm.js 19507 var Rails2 = require_rails_ujs(); 19508 var old_confirm = Rails2.confirm; 19509 var elements = ["a[data-confirm]", "button[data-confirm]", "input[type=submit][data-confirm]"]; 19510 var createConfirmModal = (element, onCommit = () => { 19511 Rails2.confirm = () => { 19512 return true; 19513 }; 19514 element.click(); 19515 }, onCancel = () => { 19516 }) => { 19517 var id = "confirm-modal-" + String(Math.random()).slice(2, -1); 19518 var confirm2 = element.dataset.confirm; 19519 var content = ` 19520 <div id="${id}" class="z-50 animated fadeIn fixed top-0 left-0 w-full h-full table" style="background-color: rgba(0, 0, 0, 0.8);"> 19521 <div class="table-cell align-middle"> 19522 19523 <div class="bg-white mx-auto rounded shadow p-8 max-w-sm"> 19524 <h4>${confirm2}</h4> 19525 19526 <div class="flex justify-end items-center flex-wrap mt-6"> 19527 <button data-behavior="cancel" class="btn btn-light-gray mr-2">Cancel</button> 19528 <button data-behavior="commit" class="btn btn-danger focus:outline-none">Confirm</button> 19529 </div> 19530 </div> 19531 </div> 19532 </div> 19533 `; 19534 element.insertAdjacentHTML("afterend", content); 19535 var modal = element.nextElementSibling; 19536 element.dataset.confirmModal = `#${id}`; 19537 modal.addEventListener("keyup", (event) => { 19538 if (event.key === "Escape") { 19539 event.preventDefault(); 19540 onCancel(); 19541 element.removeAttribute("data-confirm-modal"); 19542 modal.remove(); 19543 } 19544 }); 19545 modal.querySelector("[data-behavior='cancel']").addEventListener("click", (event) => { 19546 event.preventDefault(); 19547 onCancel(); 19548 element.removeAttribute("data-confirm-modal"); 19549 modal.remove(); 19550 }); 19551 modal.querySelector("[data-behavior='commit']").addEventListener("click", (event) => { 19552 event.preventDefault(); 19553 onCommit(); 19554 element.removeAttribute("data-confirm-modal"); 19555 Rails2.confirm = old_confirm; 19556 modal.remove(); 19557 }); 19558 modal.querySelector("[data-behavior='commit']").focus(); 19559 return modal; 19560 }; 19561 var confirmWithModal = (message) => new Promise((resolve) => { 19562 const element = document.createElement("button"); 19563 element.type = "button"; 19564 element.dataset.confirm = message; 19565 element.hidden = true; 19566 document.body.appendChild(element); 19567 createConfirmModal(element, () => { 19568 resolve(true); 19569 element.remove(); 19570 }, () => { 19571 resolve(false); 19572 element.remove(); 19573 }); 19574 }); 19575 var confirmModalOpen = (element) => { 19576 return !!element.dataset.confirmModal; 19577 }; 19578 var handleConfirm = (event) => { 19579 if (confirmModalOpen(event.target)) { 19580 return true; 19581 } else { 19582 createConfirmModal(event.target); 19583 return false; 19584 } 19585 }; 19586 Rails2.delegate(document, elements.join(", "), "confirm", handleConfirm); 19587 19588
19588// controllers/marketing_materials_admin_controller.js 19589 var ACCEPT = "image/*,video/*,application/pdf,.pdf"; 19590 var marketing_materials_admin_controller_default = class extends Controller { 19591 connect() { 19592 this.refreshAfterUploadsTimeout = null; 19593 this.boundCloseAddMenuIfOutside = this.closeAddMenuIfOutside.bind(this); 19594 document.addEventListener("click", this.boundCloseAddMenuIfOutside); 19595 this.updateBulkDeleteButton(); 19596 } 19597 disconnect() { 19598 document.removeEventListener("click", this.boundCloseAddMenuIfOutside); 19599 if (this.refreshAfterUploadsTimeout) 19600 clearTimeout(this.refreshAfterUploadsTimeout); 19601 } 19602 toggleSelectAll(event) { 19603 const checked = event.target.checked; 19604 this.rowCheckboxTargets.forEach((checkbox) => { 19605 checkbox.checked = checked; 19606 }); 19607 this.updateBulkDeleteButton(); 19608 } 19609 toggleRowSelection() { 19610 if (this.hasSelectAllCheckboxTarget) { 19611 const total = this.rowCheckboxTargets.length; 19612 const checkedCount = this.rowCheckboxTargets.filter((checkbox) => checkbox.checked).length; 19613 this.selectAllCheckboxTarget.checked = total > 0 && checkedCount === total; 19614 this.selectAllCheckboxTarget.indeterminate = checkedCount > 0 && checkedCount < total; 19615 } 19616 this.updateBulkDeleteButton(); 19617 } 19618 selectedResourceIds() { 19619 return this.rowCheckboxTargets.filter((checkbox) => checkbox.checked).map((checkbox) => checkbox.value); 19620 } 19621 updateBulkDeleteButton() { 19622 if (!this.hasBulkDeleteButtonTarget) 19623 return; 19624 const count = this.selectedResourceIds().length; 19625 this.bulkDeleteButtonTarget.disabled = count === 0; 19626 if (this.hasBulkDeleteCountTarget) { 19627 this.bulkDeleteCountTarget.textContent = count > 0 ? String(count) : ""; 19628 } 19629 } 19630 async bulkDelete(event) { 19631 event?.preventDefault(); 19632 const ids = this.selectedResourceIds(); 19633 if (ids.length === 0) 19634 return; 19635 const folderCount = ids.filter((id) => id.startsWith("folder-")).length; 19636 const confirmed = await confirmWithModal(folderCount > 0 ? `Are you sure you want to delete the selected ${ids.length} item(s)? This includes ${folderCount} folder(s) \u2014 deleting a folder permanently removes everything inside it. This cannot be undone.` : ids.length === 1 ? "Are you sure you want to delete this file?" : `Are you sure you want to delete these ${ids.length} files?`); 19637 if (!confirmed) 19638 return; 19639 const body = new URLSearchParams(); 19640 ids.forEach((id) => body.append("ids[]", id)); 19641 const res = await fetch(this.bulkDeleteUrlValue, { 19642 method: "DELETE", 19643 headers: { 19644 "X-CSRF-Token": this.csrfTokenValue, 19645 Accept: "application/json", 19646 "Content-Type": "application/x-www-form-urlencoded" 19647 }, 19648 body: body.toString() 19649 }); 19650 let responseBody = {}; 19651 try { 19652 responseBody = await res.json(); 19653 } catch (_e) { 19654 responseBody = { ok: false, errors: ["Invalid response"] }; 19655 } 19656 if (res.ok && responseBody.ok) { 19657 window.Turbo.visit(responseBody.redirect_url || this.indexUrlValue); 19658 } else { 19659 window.alert((responseBody.errors || ["Could not delete selected files"]).join("\n")); 19660 } 19661 } 19662 closeAddMenuIfOutside(event) { 19663 if (!this.hasAddMenuTarget) 19664 return; 19665 if (!this.addMenuTarget.open) 19666 return; 19667 if (this.addMenuTarget.contains(event.target)) 19668 return; 19669 this.addMenuTarget.removeAttribute("open"); 19670 } 19671 closeAddMenu() { 19672 if (this.hasAddMenuTarget && this.addMenuTarget.open) { 19673 this.addMenuTarget.removeAttribute("open"); 19674 } 19675 } 19676 openFolderDialog(event) { 19677 event?.preventDefault(); 19678 this.closeAddMenu(); 19679 if (!this.hasFolderDialogTarget) 19680 return; 19681 this.folderDialogTarget.showModal(); 19682 queueMicrotask(() => this.folderNameInputTarget?.focus()); 19683 } 19684 closeFolderDialog(event) { 19685 event?.preventDefault(); 19686 if (!this.hasFolderDialogTarget) 19687 return; 19688 this.folderDialogTarget.close(); 19689 } 19690 backdropCloseFolder(event) { 19691 if (event.target === this.folderDialogTarget) 19692 this.closeFolderDialog(); 19693 } 19694 stopPropagation(event) { 19695 event.stopPropagation(); 19696 }
19697 openUploadPanel(event) { 19698 event?.preventDefault(); 19699 this.closeAddMenu(); 19700 if (!this.hasUploadPanelTarget) 19701 return; 19702 this.uploadPanelTarget.classList.remove("mma-upload-panel--hidden"); 19703 this.fileInputTarget.setAttribute("accept", ACCEPT); 19704 } 19705 closeUploadPanel(event) { 19706 event?.preventDefault(); 19707 if (!this.hasUploadPanelTarget) 19708 return; 19709 this.uploadPanelTarget.classList.add("mma-upload-panel--hidden"); 19710 } 19711 browseFiles(event) { 19712 event?.preventDefault(); 19713 this.fileInputTarget.click(); 19714 } 19715 dragOver(event) { 19716 event.preventDefault(); 19717 event.stopPropagation(); 19718 this.dropZoneTarget.classList.add("mma-dropzone--active"); 19719 } 19720 dragLeave(event) { 19721 event.preventDefault(); 19722 event.stopPropagation(); 19723 this.dropZoneTarget.classList.remove("mma-dropzone--active"); 19724 } 19725 dropFiles(event) { 19726 event.preventDefault(); 19727 event.stopPropagation(); 19728 this.dropZoneTarget.classList.remove("mma-dropzone--active"); 19729 const files = event.dataTransfer?.files; 19730 if (files?.length) 19731 this.enqueueUploads(Array.from(files)); 19732 } 19733 filesChosen(event) { 19734 const files = event.target.files; 19735 if (files?.length) 19736 this.enqueueUploads(Array.from(files)); 19737 event.target.value = ""; 19738 } 19739 effectiveFolderId() { 19740 if (this.hasUploadTargetSelectTarget) { 19741 const v = this.uploadTargetSelectTarget.value; 19742 if (v) 19743 return v; 19744 } 19745 if (this.hasFolderIdValue && this.folderIdValue) 19746 return this.folderIdValue; 19747 return ""; 19748 } 19749 enqueueUploads(files) { 19750 if (!this.effectiveFolderId()) { 19751 window.alert("Select a folder to upload into."); 19752 this.openUploadPanel(); 19753 return; 19754 } 19755 this.uploadListTarget.hidden = false; 19756 files.forEach((file) => this.startUploadRow(file)); 19757 } 19758 startUploadRow(file) { 19759 const li = document.createElement("li"); 19760 li.className = "mma-upload-item"; 19761 li.innerHTML = ` 19762 <div class="mma-upload-item__meta"> 19763 <span class="mma-upload-item__name"></span> 19764 <a href="#" class="mma-upload-item__retry button button--secondary" role="button" hidden>Retry</a> 19765 </div> 19766 <div class="mma-upload-item__track" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"> 19767 <div class="mma-upload-item__bar"></div> 19768 </div> 19769 <p class="mma-upload-item__error" hidden></p> 19770 `; 19771 li.querySelector(".mma-upload-item__name").textContent = file.name; 19772 const retryBtn = li.querySelector(".mma-upload-item__retry"); 19773 const bar = li.querySelector(".mma-upload-item__bar"); 19774 const track = li.querySelector(".mma-upload-item__track"); 19775 const errorEl = li.querySelector(".mma-upload-item__error"); 19776 const run = () => { 19777 li.classList.remove("mma-upload-item--error", "mma-upload-item--done"); 19778 errorEl.hidden = true; 19779 errorEl.textContent = ""; 19780 retryBtn.hidden = true; 19781 bar.style.width = "0%"; 19782 track.setAttribute("aria-valuenow", "0"); 19783 this.uploadFileWithProgress(file, (pct) => { 19784 const p = Math.round(pct * 100); 19785 bar.style.width = `${p}%`; 19786 track.setAttribute("aria-valuenow", String(p)); 19787 }).then((data) => { 19788 if (data.ok) { 19789 bar.style.width = "100%"; 19790 track.setAttribute("aria-valuenow", "100"); 19791 li.classList.add("mma-upload-item--done"); 19792 this.scheduleRefreshAfterUploads(); 19793 } else { 19794 this.showUploadError(li, file, (data.errors || ["Upload failed"]).join(", "), run); 19795 } 19796 }).catch(() => { 19797 this.showUploadError(li, file, "Network error", run); 19798 }); 19799 }; 19800 retryBtn.addEventListener("click", (event) => { 19801 event.preventDefault(); 19802 run(); 19803 }); 19804 this.uploadListTarget.appendChild(li); 19805 run(); 19806 } 19807 scheduleRefreshAfterUploads() { 19808 clearTimeout(this.refreshAfterUploadsTimeout); 19809 this.refreshAfterUploadsTimeout = setTimeout(() => { 19810 if (this.hasUploadListTarget && this.uploadListTarget.querySelector(".mma-upload-item--error")) 19811 return; 19812 window.location.reload(); 19813 }, 1e3); 19814 } 19815 showUploadError(li, _file, message, _retryFn) { 19816 const errorEl = li.querySelector(".mma-upload-item__error"); 19817 const retryBtn = li.querySelector(".mma-upload-item__retry"); 19818 errorEl.textContent = message; 19819 errorEl.hidden = false;
19820 retryBtn.hidden = false; 19821 li.classList.add("mma-upload-item--error"); 19822 } 19823 uploadFileWithProgress(file, onProgress) { 19824 return new Promise((resolve) => { 19825 const formData = new FormData(); 19826 formData.append("folder_id", this.effectiveFolderId()); 19827 formData.append("file", file, file.name); 19828 const xhr = new XMLHttpRequest(); 19829 xhr.open("POST", this.uploadUrlValue); 19830 xhr.setRequestHeader("X-CSRF-Token", this.csrfTokenValue); 19831 xhr.setRequestHeader("Accept", "application/json"); 19832 xhr.upload.addEventListener("progress", (e2) => { 19833 if (e2.lengthComputable && e2.total > 0) 19834 onProgress(e2.loaded / e2.total); 19835 }); 19836 xhr.onload = () => { 19837 let body = {}; 19838 try { 19839 body = JSON.parse(xhr.responseText || "{}"); 19840 } catch (_e) { 19841 body = { ok: false, errors: ["Invalid response"] }; 19842 } 19843 if (xhr.status >= 200 && xhr.status < 300 && body.ok) 19844 resolve(body); 19845 else 19846 resolve({ ok: false, errors: body.errors || [`HTTP ${xhr.status}`] }); 19847 }; 19848 xhr.onerror = () => resolve({ ok: false, errors: ["Network error"] }); 19849 xhr.send(formData); 19850 }); 19851 } 19852 async submitFolder(event) { 19853 const form = event.currentTarget; 19854 const formData = new FormData(form); 19855 const res = await fetch(this.createFolderUrlValue, { 19856 method: "POST", 19857 headers: { 19858 "X-CSRF-Token": this.csrfTokenValue, 19859 Accept: "application/json" 19860 }, 19861 body: formData 19862 }); 19863 let body = {}; 19864 try { 19865 body = await res.json(); 19866 } catch (_e) { 19867 body = { ok: false, errors: ["Invalid response"] }; 19868 } 19869 if (res.ok && body.ok) { 19870 this.closeFolderDialog(); 19871 if (body.redirect_url) { 19872 window.Turbo.visit(body.redirect_url); 19873 } else { 19874 window.location.reload(); 19875 } 19876 } else { 19877 window.alert((body.errors || ["Could not create folder"]).join("\n")); 19878 } 19879 } 19880 }; 19881 __publicField(marketing_materials_admin_controller_default, "targets", [ 19882 "addMenu", 19883 "folderDialog", 19884 "folderForm", 19885 "folderNameInput", 19886 "dropZone", 19887 "fileInput", 19888 "uploadPanel", 19889 "uploadList", 19890 "uploadTargetSelect", 19891 "bulkDeleteButton", 19892 "bulkDeleteCount", 19893 "selectAllCheckbox", 19894 "rowCheckbox" 19895 ]); 19896 __publicField(marketing_materials_admin_controller_default, "values", { 19897 uploadUrl: String, 19898 createFolderUrl: String, 19899 bulkDeleteUrl: String, 19900 csrfToken: String, 19901 folderId: String, 19902 indexUrl: String 19903 }); 19904 19905
19905// controllers/marketing_resource_search_controller.js 19906 var marketing_resource_search_controller_exports = {}; 19907 __export(marketing_resource_search_controller_exports, { 19908 default: () => marketing_resource_search_controller_default 19909 }); 19910 var marketing_resource_search_controller_default = class extends Controller { 19911 connect() { 19912 this.timer = null; 19913 this.updateSearchPlaceholder(); 19914 this.restoreInputFocus(); 19915 } 19916 disconnect() { 19917 this.clearTimer(); 19918 } 19919 capInput() { 19920 if (!this.hasInputTarget) 19921 return; 19922 const max2 = this.maxLengthValue; 19923 if (this.inputTarget.value.length > max2) { 19924 this.inputTarget.value = this.inputTarget.value.slice(0, max2); 19925 } 19926 } 19927 scheduleSubmit() { 19928 this.capInput(); 19929 if (!this.hasFormTarget) 19930 return; 19931 const q = this.inputTarget.value.trim(); 19932 if (q.length === 0) { 19933 this.clearTimer(); 19934 this.persistInputFocus(); 19935 this.formTarget.requestSubmit(); 19936 return; 19937 } 19938 if (q.length < this.minLengthValue) { 19939 this.clearTimer(); 19940 return; 19941 } 19942 this.clearTimer(); 19943 this.timer = window.setTimeout(() => { 19944 this.persistInputFocus(); 19945 this.formTarget.requestSubmit(); 19946 }, this.debounceValue); 19947 } 19948 handleKeydown(event) { 19949 if (event.key !== "Enter") 19950 return; 19951 event.preventDefault(); 19952 this.clearTimer(); 19953 this.persistInputFocus(); 19954 this.formTarget.requestSubmit(); 19955 } 19956 persistInputFocus() { 19957 if (!this.hasInputTarget) 19958 return; 19959 const payload = { 19960 wasFocused: document.activeElement === this.inputTarget 19961 }; 19962 window.sessionStorage.setItem(this.constructor.FOCUS_STATE_KEY, JSON.stringify(payload)); 19963 } 19964 restoreInputFocus() { 19965 if (!this.hasInputTarget) 19966 return; 19967 const raw = window.sessionStorage.getItem(this.constructor.FOCUS_STATE_KEY); 19968 if (!raw) 19969 return; 19970 window.sessionStorage.removeItem(this.constructor.FOCUS_STATE_KEY); 19971 try { 19972 const state = JSON.parse(raw); 19973 if (!state?.wasFocused) 19974 return; 19975 this.inputTarget.focus({ preventScroll: true }); 19976 const len = this.inputTarget.value.length; 19977 this.inputTarget.setSelectionRange(len, len); 19978 } catch (_error) { 19979 } 19980 } 19981 clearTimer() { 19982 if (!this.timer) 19983 return; 19984 window.clearTimeout(this.timer); 19985 this.timer = null; 19986 } 19987 clearSearch() { 19988 if (!this.hasInputTarget) 19989 return; 19990 this.inputTarget.value = ""; 19991 this.clearTimer(); 19992 } 19993 updateSearchPlaceholder() { 19994 if (!this.hasInputTarget) 19995 return; 19996 if (this.hasPlaceholderValue) { 19997 this.inputTarget.placeholder = this.placeholderValue; 19998 } 19999 if (this.hasFolderTitleValue && this.folderTitleValue.length > 0) { 20000 this.inputTarget.title = this.folderTitleValue; 20001 } else { 20002 this.inputTarget.removeAttribute("title"); 20003 } 20004 } 20005 }; 20006 __publicField(marketing_resource_search_controller_default, "targets", ["form", "input", "submitButton", "suggestions"]); 20007 __publicField(marketing_resource_search_controller_default, "values", { 20008 debounce: { type: Number, default: 250 }, 20009 minLength: { type: Number, default: 3 }, 20010 maxLength: { type: Number, default: 200 }, 20011 placeholder: String, 20012 folderTitle: String 20013 }); 20014 __publicField(marketing_resource_search_controller_default, "FOCUS_STATE_KEY", "marketingResourceSearchFocusState"); 20015 20016
20016// controllers/mentions_controller.js 20017 var mentions_controller_exports = {}; 20018 __export(mentions_controller_exports, { 20019 default: () => mentions_controller_default 20020 }); 20021 var import_tributejs = __toESM(require_tribute_min()); 20022 var import_trix = __toESM(require_trix()); 20023 var mentions_controller_default = class extends Controller { 20024 connect() { 20025 this.editor = this.fieldTarget.editor; 20026 this.initializeTribute(); 20027 } 20028 initializeTribute() { 20029 this.tribute = new import_tributejs.default({ 20030 allowSpaces: true, 20031 lookup: "name", 20032 values: this.fetchUsers, 20033 menuShowMinLength: 1 20034 }); 20035 this.tribute.attach(this.fieldTarget); 20036 this.fieldTarget.addEventListener("tribute-replaced", this.replaced); 20037 this.tribute.range.pasteHtml = this._pasteHtml.bind(this); 20038 } 20039 disconnect() { 20040 this.tribute.detach(this.fieldTarget); 20041 } 20042 fetchUsers(text, callback) { 20043 fetch(`/users/mentions.json?query=${text}`).then((response) => response.json()).then((users) => callback(users)).catch((error2) => callback([])); 20044 } 20045 replaced(e2) { 20046 let mention = e2.detail.item.original; 20047 let attachment = new import_trix.default.Attachment({ 20048 content: mention.content, 20049 sgid: mention.sgid 20050 }); 20051 this.editor.insertAttachment(attachment); 20052 this.editor.insertString(" "); 20053 } 20054 _pasteHtml(html, startPos, endPos) { 20055 let range = this.editor.getSelectedRange(); 20056 let position = range[0]; 20057 let length = endPos - startPos; 20058 this.editor.setSelectedRange([position - length, position]); 20059 this.editor.deleteInDirection("backward"); 20060 } 20061 }; 20062 __publicField(mentions_controller_default, "targets", ["field"]); 20063 20064
20064// controllers/notifications_controller.js 20065 var notifications_controller_exports = {}; 20066 __export(notifications_controller_exports, { 20067 default: () => notifications_controller_default 20068 }); 20069 var notifications_controller_default = class extends Controller { 20070 connect() { 20071 this.subscription = consumer_default.subscriptions.create({ channel: "NotificationChannel" }, { 20072 connected: this._connected.bind(this), 20073 disconnected: this._disconnected.bind(this), 20074 received: this._received.bind(this) 20075 }); 20076 if (this.hasUnread()) 20077 this.showUnreadBadge(); 20078 } 20079 disconnect() { 20080 this.subscription.unsubscribe(); 20081 } 20082 _connected() { 20083 } 20084 _disconnected() { 20085 } 20086 _received(data) { 20087 this.totalUnreadValue += 1; 20088 if (data.account_id && data.account_id == this.accountIdValue) { 20089 this.accountUnreadValue += 1; 20090 } 20091 if (data.account_id && data.account_id != this.accountIdValue) { 20092 return; 20093 } 20094 if (data.html) { 20095 this.listTarget.insertAdjacentHTML("afterbegin", data.html); 20096 this.showUnreadBadge(); 20097 } 20098 if (data.browser) { 20099 this.checkPermissionAndNotify(data.browser); 20100 } 20101 } 20102 open() { 20103 this.hideUnreadBadge(); 20104 this.markAllAsRead(); 20105 } 20106 hasUnread() { 20107 return !!this.accountUnreadValue; 20108 } 20109 showUnreadBadge() { 20110 if (this.hasBadgeTarget == false) { 20111 return; 20112 } 20113 this.badgeTarget.classList.remove("hidden"); 20114 } 20115 hideUnreadBadge() { 20116 if (this.hasBadgeTarget == false) { 20117 return; 20118 } 20119 this.badgeTarget.classList.add("hidden"); 20120 } 20121 markAllAsRead() { 20122 let ids = this.notificationTargets.map((target) => target.dataset.id); 20123 this.subscription.perform("mark_as_read", { ids }); 20124 this.accountUnreadValue = 0; 20125 this.totalUnreadValue -= ids.length; 20126 } 20127 markAsInteracted(event) { 20128 let id = event.currentTarget.dataset.id; 20129 if (id == null) 20130 return; 20131 this.subscription.perform("mark_as_interacted", { ids: [id] }); 20132 } 20133 checkPermissionAndNotify(data) { 20134 if (!("Notification" in window)) 20135 return; 20136 if (Notification.permission === "granted") { 20137 this.browserNotification(data); 20138 } else if (Notification.permission !== "denied") { 20139 Notification.requestPermission().then((permission) => { 20140 if (permission === "granted") { 20141 this.browserNotification(data); 20142 } 20143 }); 20144 } 20145 } 20146 browserNotification(data) { 20147 new Notification(data.title, data.options); 20148 } 20149 totalUnreadValueChanged() { 20150 this.syncCountToNative(); 20151 } 20152 accountUnreadValueChanged() { 20153 this.syncCountToNative(); 20154 } 20155 syncCountToNative() { 20156 window.TurboNativeBridge.setNotificationCount(this.totalUnreadValue, this.accountUnreadValue); 20157 } 20158 }; 20159 __publicField(notifications_controller_default, "targets", ["badge", "list", "placeholder", "notification"]); 20160 __publicField(notifications_controller_default, "values", { 20161 accountId: String, 20162 accountUnread: Number, 20163 totalUnread: Number 20164 }); 20165 20166
20166// controllers/paddle_controller.js 20167 var paddle_controller_exports = {}; 20168 __export(paddle_controller_exports, { 20169 default: () => paddle_controller_default 20170 }); 20171 var paddle_controller_default = class extends Controller { 20172 connect() { 20173 let params = { 20174 method: "inline", 20175 allowQuantity: false, 20176 disableLogout: true, 20177 frameTarget: "paddle-checkout", 20178 frameInitialHeight: 416, 20179 frameStyle: "width:100%; background-color: transparent; border: none;", 20180 successCallback: this.checkoutComplete.bind(this) 20181 }; 20182 if (this.data.get("action") == "create-subscription") { 20183 Paddle.Checkout.open({ 20184 ...params, 20185 product: this.data.get("product"), 20186 email: this.data.get("email"), 20187 passthrough: this.data.get("passthrough") 20188 }); 20189 } else if (this.data.get("action") == "update-payment-details") { 20190 Paddle.Checkout.open({ 20191 ...params, 20192 override: this.data.get("update-url") 20193 }); 20194 } 20195 } 20196 checkoutComplete(data) { 20197 this.addHiddenField("processor", "paddle"); 20198 Rails.fire(this.formTarget, "submit"); 20199 } 20200 addHiddenField(name, value) { 20201 let hiddenInput = document.createElement("input"); 20202 hiddenInput.setAttribute("type", "hidden"); 20203 hiddenInput.setAttribute("name", name); 20204 hiddenInput.setAttribute("value", value); 20205 this.formTarget.appendChild(hiddenInput); 20206 } 20207 }; 20208 __publicField(paddle_controller_default, "targets", ["form"]); 20209 20210
20210// controllers/partner_add_to_cart_controller.js 20211 var partner_add_to_cart_controller_exports = {}; 20212 __export(partner_add_to_cart_controller_exports, { 20213 default: () => partner_add_to_cart_controller_default 20214 }); 20215 var partner_add_to_cart_controller_default = class extends Controller { 20216 connect() { 20217 this.formElement = this.element.matches("form") ? this.element : this.element.querySelector("form"); 20218 this.ensureMinimumQuantity(); 20219 this.submitButton = this.formElement?.querySelector('button[type="submit"], input[type="submit"]'); 20220 this.updatePricingForQuantity(); 20221 } 20222 submit(event) { 20223 event.preventDefault(); 20224 this.addToCart(); 20225 } 20226 increment(event) { 20227 event.preventDefault(); 20228 this.changeQuantity(1); 20229 } 20230 decrement(event) { 20231 event.preventDefault(); 20232 this.changeQuantity(-1); 20233 } 20234 quantityChanged() { 20235 this.ensureMinimumQuantity(); 20236 this.updatePricingForQuantity(); 20237 } 20238 async addToCart() { 20239 const priceId = this.priceIdTarget?.value; 20240 if (!priceId) { 20241 this.showFeedback("Pricing is not available for this product."); 20242 return; 20243 } 20244 if (!this.formElement?.action) { 20245 this.showFeedback("Unable to add product to cart."); 20246 return; 20247 } 20248 const quantity = this.quantityValue; 20249 const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content"); 20250 if (!token) { 20251 console.warn("Missing CSRF token for partner add to cart request"); 20252 } 20253 this.disableSubmit(); 20254 try { 20255 const response = await fetch(this.formElement.action, { 20256 method: "POST", 20257 headers: { 20258 "Content-Type": "application/json", 20259 "X-CSRF-Token": token, 20260 "Accept": "application/json" 20261 }, 20262 body: JSON.stringify({ 20263 price_id: priceId, 20264 quantity 20265 }) 20266 }); 20267 const payload = await response.json().catch(() => ({})); 20268 if (response.ok) { 20269 const resolvedCount = this.resolveCartCount(payload, quantity); 20270 this.updateCartCount(resolvedCount); 20271 this.showFeedback("Product successfully added to the cart!"); 20272 this.refreshCartPreview(resolvedCount); 20273 } else {
20274 this.showFeedback(payload.message || "Unable to add product to cart."); 20275 } 20276 } catch (error2) { 20277 console.error("Partner add to cart failed:", error2); 20278 this.showFeedback("An error occurred while adding the product to the cart."); 20279 } finally { 20280 this.enableSubmit(); 20281 } 20282 } 20283 changeQuantity(delta) { 20284 if (!this.hasQuantityTarget) 20285 return; 20286 const quantity = Math.max(1, this.quantityValue + delta); 20287 this.quantityTarget.value = quantity; 20288 this.updatePricingForQuantity(); 20289 } 20290 updatePricingForQuantity() { 20291 if (!this.hasCurrentPriceTarget) 20292 return; 20293 if (!this.hasRetailCentsValue || !Number.isFinite(this.retailCentsValue) || this.retailCentsValue <= 0) 20294 return; 20295 const quantity = this.quantityValue; 20296 const tier = this.matchingTier(quantity); 20297 const discountPct = Number(tier?.discount_percentage || this.baseDiscountPctValue || 0); 20298 const discountedCents = this.discountedPriceCents(this.retailCentsValue, discountPct); 20299 const savingsCents = Math.max(this.retailCentsValue - discountedCents, 0); 20300 this.currentPriceTarget.textContent = this.formatCurrency(discountedCents); 20301 if (this.hasCurrentDiscountTarget) { 20302 if (discountPct > 0) { 20303 this.currentDiscountTarget.textContent = `${discountPct}% OFF`; 20304 this.currentDiscountTarget.classList.remove("hidden"); 20305 } else { 20306 this.currentDiscountTarget.classList.add("hidden"); 20307 } 20308 } 20309 if (this.hasCurrentSavingsTarget) { 20310 this.currentSavingsTarget.textContent = `You save ${this.formatCurrency(savingsCents)} per item`; 20311 this.currentSavingsTarget.classList.toggle("hidden", savingsCents <= 0); 20312 } 20313 if (this.hasActiveTierTarget) { 20314 if (tier?.label) { 20315 this.activeTierTarget.textContent = `Active Tier: ${tier.label}`; 20316 } else { 20317 this.activeTierTarget.textContent = "Active Tier: Standard"; 20318 } 20319 } 20320 this.highlightTierRow(tier); 20321 } 20322 matchingTier(quantity) { 20323 const qty = Number(quantity); 20324 if (!Number.isFinite(qty) || qty < 1) 20325 return null; 20326 const tiers = Array.isArray(this.tiersValue) ? this.tiersValue : []; 20327 for (const tier of tiers) { 20328 const min2 = Number(tier?.min_quantity); 20329 const maxRaw = tier?.max_quantity; 20330 const max2 = maxRaw === null || maxRaw === void 0 || maxRaw === "" ? null : Number(maxRaw); 20331 if (!Number.isFinite(min2)) 20332 continue; 20333 const inRange = qty >= min2 && (max2 === null || Number.isFinite(max2) && qty <= max2); 20334 if (inRange) 20335 return tier; 20336 } 20337 return null; 20338 } 20339 highlightTierRow(activeTier) { 20340 if (!this.hasTierRowTarget) 20341 return; 20342 const activeMin = Number(activeTier?.min_quantity); 20343 const activeMaxRaw = activeTier?.max_quantity; 20344 const activeMax = activeMaxRaw === null || activeMaxRaw === void 0 || activeMaxRaw === "" ? null : Number(activeMaxRaw); 20345 this.tierRowTargets.forEach((row) => { 20346 const rowMin = Number(row.dataset.tierMin); 20347 const rowMaxRaw = row.dataset.tierMax; 20348 const rowMax = rowMaxRaw === "" ? null : Number(rowMaxRaw); 20349 const isActive = Number.isFinite(activeMin) && rowMin === activeMin && (activeMax === null && rowMax === null || Number.isFinite(activeMax) && Number.isFinite(rowMax) && rowMax === activeMax); 20350 row.classList.toggle("active-tier-row", isActive); 20351 row.classList.toggle("bg-green-50/50", isActive); 20352 Array.from(row.cells).forEach((cell) => { 20353 cell.classList.toggle("border-green-300", isActive); 20354 cell.classList.toggle("border-b-green-400", isActive); 20355 }); 20356 }); 20357 } 20358 discountedPriceCents(baseCents, discountPct) { 20359 const discount = Number(discountPct); 20360 if (!Number.isFinite(discount) || discount <= 0) 20361 return Math.round(baseCents); 20362 return Math.round(baseCents * (100 - discount) / 100); 20363 } 20364 formatCurrency(cents) { 20365 return new Intl.NumberFormat("en-US", { 20366 style: "currency", 20367 currency: "USD" 20368 }).format((Number(cents) || 0) / 100); 20369 } 20370 get quantityValue() { 20371 const value = parseInt(this.quantityTarget?.value, 10); 20372 return Number.isNaN(value) ? 1 : Math.max(1, value); 20373 } 20374 updateCartCount(count) { 20375 const cartCountElements = document.querySelectorAll("#cart-count");
20376 cartCountElements.forEach((el) => { 20377 if (count > 0) { 20378 el.classList.remove("hidden"); 20379 el.textContent = count; 20380 } else { 20381 el.classList.add("hidden"); 20382 } 20383 }); 20384 } 20385 resolveCartCount(payload, addedQuantity) { 20386 const totalItemsCount = Number(payload?.total_items_count); 20387 if (Number.isFinite(totalItemsCount) && totalItemsCount >= 0) { 20388 return totalItemsCount; 20389 } 20390 const itemsCount = Number(payload?.items_count); 20391 if (Number.isFinite(itemsCount) && itemsCount >= 0) { 20392 return itemsCount; 20393 } 20394 const firstVisibleCount = document.querySelector("#cart-count"); 20395 const existingCount = Number(firstVisibleCount?.textContent?.trim()); 20396 const safeExistingCount = Number.isFinite(existingCount) ? existingCount : 0; 20397 return safeExistingCount + Number(addedQuantity || 1); 20398 } 20399 showFeedback(message) { 20400 if (!message) 20401 return; 20402 if (typeof window.showPopup === "function") { 20403 window.showPopup(message); 20404 } 20405 } 20406 refreshCartPreview(count) { 20407 document.dispatchEvent(new CustomEvent("cart:updated", { detail: { count } })); 20408 } 20409 disableSubmit() { 20410 if (this.submitButton) { 20411 this.submitButton.disabled = true; 20412 } 20413 } 20414 enableSubmit() { 20415 if (this.submitButton) { 20416 this.submitButton.disabled = false; 20417 } 20418 } 20419 ensureMinimumQuantity() { 20420 if (this.hasQuantityTarget) { 20421 this.quantityTarget.value = this.quantityValue; 20422 } 20423 } 20424 }; 20425 __publicField(partner_add_to_cart_controller_default, "targets", [ 20426 "quantity", 20427 "priceId", 20428 "currentPrice", 20429 "currentDiscount", 20430 "currentSavings", 20431 "tierRow", 20432 "activeTier" 20433 ]); 20434 __publicField(partner_add_to_cart_controller_default, "values", { 20435 retailCents: Number, 20436 tiers: Array, 20437 baseDiscountPct: Number 20438 }); 20439 20440
20440// controllers/partner_cart_updater_controller.js 20441 var partner_cart_updater_controller_exports = {}; 20442 __export(partner_cart_updater_controller_exports, { 20443 default: () => partner_cart_updater_controller_default 20444 }); 20445 var partner_cart_updater_controller_default = class extends Controller { 20446 connect() { 20447 this.refreshHandler = this.refresh.bind(this); 20448 this.turboLoadHandler = this.refresh.bind(this); 20449 document.addEventListener("cart:updated", this.refreshHandler); 20450 document.addEventListener("turbo:load", this.turboLoadHandler); 20451 this.refresh(); 20452 } 20453 disconnect() { 20454 document.removeEventListener("cart:updated", this.refreshHandler); 20455 document.removeEventListener("turbo:load", this.turboLoadHandler); 20456 } 20457 async refresh() { 20458 if (!this.urlValue || !this.hasContainerTarget) 20459 return; 20460 try { 20461 const response = await fetch(this.urlValue, { 20462 headers: { 20463 "Accept": "text/html" 20464 }, 20465 credentials: "same-origin" 20466 }); 20467 if (response.ok) { 20468 const html = await response.text(); 20469 this.containerTarget.innerHTML = html; 20470 } 20471 } catch (error2) { 20472 console.error("Failed to refresh cart preview", error2); 20473 } 20474 } 20475 }; 20476 __publicField(partner_cart_updater_controller_default, "targets", ["container"]); 20477 __publicField(partner_cart_updater_controller_default, "values", { url: String }); 20478 20479
20479// controllers/partner_price_form_controller.js 20480 var partner_price_form_controller_exports = {}; 20481 __export(partner_price_form_controller_exports, { 20482 default: () => partner_price_form_controller_default 20483 }); 20484 var TIER_OPTIONS = [ 20485 { value: "bronze", label: "Bronze" }, 20486 { value: "silver", label: "Silver" }, 20487 { value: "gold", label: "Gold" } 20488 ]; 20489 var partner_price_form_controller_default = class extends Controller { 20490 get initialPriceId() { 20491 if (!this.currentPriceIdValue) 20492 return null; 20493 const parsed = Number(this.currentPriceIdValue); 20494 return Number.isInteger(parsed) ? parsed : null; 20495 } 20496 connect() { 20497 this.toggleDiscountTiers = this.toggleDiscountTiers.bind(this); 20498 this.pricingTypeField = this.element.querySelector("select[name*='[pricing_type]']") || this.element.querySelector("[name*='[pricing_type]']"); 20499 this.tiers = this.parseTiers(); 20500 this.addTierButton = this.element.querySelector("[data-action*='partner-price-form#addTierRow']"); 20501 this.pricingTypeField?.addEventListener("change", this.toggleDiscountTiers); 20502 this.toggleDiscountTiers(); 20503 this.renderRows(); 20504 this.userGroupSelect = this.element.querySelector("#partner_price_user_group_id"); 20505 this.handleUserGroupChange = this.handleUserGroupChange.bind(this); 20506 this.userGroupSelect?.addEventListener("change", this.handleUserGroupChange); 20507 this.didInitializePriceSelect = false; 20508 this.updateProductSelect(); 20509 setTimeout(() => this.updateProductSelect(), 0); 20510 } 20511 disconnect() { 20512 this.pricingTypeField?.removeEventListener("change", this.toggleDiscountTiers); 20513 this.userGroupSelect?.removeEventListener("change", this.handleUserGroupChange); 20514 } 20515 addTierRow(event) { 20516 event.preventDefault(); 20517 const nextTier = this.nextAvailableTierValue(); 20518 if (!nextTier) 20519 return; 20520 this.tiers.push({ 20521 tier: nextTier, 20522 min_quantity: "", 20523 max_quantity: "", 20524 discount_percentage: "" 20525 }); 20526 this.renderRows(); 20527 this.updateInput(); 20528 } 20529 removeTierRow(event) { 20530 event.preventDefault(); 20531 const index = Number(event.currentTarget.dataset.tierIndex); 20532 this.tiers.splice(index, 1); 20533 this.renderRows(); 20534 this.updateInput(); 20535 } 20536 updateTierValue(event) { 20537 const row = event.currentTarget.closest("tr"); 20538 const index = Number(row.dataset.tierIndex); 20539 const field = event.currentTarget.dataset.tierField; 20540 let value = event.currentTarget.value; 20541 if (["min_quantity", "max_quantity", "discount_percentage"].includes(field)) { 20542 if (value === "") { 20543 value = null; 20544 } else { 20545 const parsedValue = field === "discount_percentage" ? parseFloat(value) : parseInt(value, 10); 20546 value = Number.isNaN(parsedValue) ? null : parsedValue; 20547 } 20548 } 20549 this.tiers[index][field] = value; 20550 if (field === "tier") 20551 this.renderRows(); 20552 this.updateInput(); 20553 } 20554 sanitizeTierInput(event) { 20555 const field = event.currentTarget.dataset.tierField; 20556 if (!["min_quantity", "max_quantity", "discount_percentage"].includes(field)) 20557 return; 20558 const sanitizedValue = (event.currentTarget.value || "").replace(/[^0-9.]/g, ""); 20559 if (event.currentTarget.value !== sanitizedValue) { 20560 event.currentTarget.value = sanitizedValue; 20561 } 20562 } 20563 toggleDiscountTiers(event = null) { 20564 const field = event?.target || this.pricingTypeField; 20565 const pricingType = this.normalizedPricingType(field?.value); 20566 const tiered = pricingType === "tiered"; 20567 const fixed = pricingType === "fixed"; 20568 const percentage = pricingType === "percentage"; 20569 if (this.hasDiscountContainerTarget) { 20570 this.discountContainerTarget.classList.toggle("hidden", !tiered); 20571 this.setFieldEnabled(tiered); 20572 } 20573 if (this.hasGuidanceTarget) { 20574 this.guidanceTarget.classList.toggle("hidden", !tiered); 20575 } 20576 this.updateTierTableVisibility(); 20577 this.updateAmountFieldVisibility(fixed); 20578 this.updatePercentageFieldVisibility(percentage); 20579 } 20580 renderRows() { 20581 if (!this.hasTierBodyTarget) 20582 return; 20583 this.tierBodyTarget.innerHTML = "";
20584 this.tiers.forEach((tier, index) => { 20585 const options2 = this.tierOptionsForRow(index, tier.tier); 20586 const row = document.createElement("tr"); 20587 row.dataset.tierIndex = index; 20588 row.innerHTML = ` 20589 <td class="px-3 py-2"> 20590 <select 20591 class="w-full border border-gray-300 rounded-md px-3 py-2 text-sm bg-white focus:ring-2 focus:ring-purple-500 focus:border-purple-500" 20592 style="width: 110px" 20593 data-tier-field="tier" 20594 data-action="change->partner-price-form#updateTierValue" 20595 > 20596 ${options2.map((option) => `<option value="${option.value}" ${option.value === normalizeTierValue(tier.tier) ? "selected" : ""}>${option.label}</option>`).join("")} 20597 </select> 20598 </td> 20599 20600 <td class="px-3 py-2"> 20601 <input 20602 type="text" 20603 class="w-full border border-gray-300 rounded-md px-3 py-2 text-sm focus:ring-2 focus:ring-purple-500 focus:border-purple-500" 20604 inputmode="numeric" 20605 pattern="[0-9]*" 20606 value="${displayValue(tier.min_quantity)}" 20607 data-tier-field="min_quantity" 20608 data-action="input->partner-price-form#sanitizeTierInput change->partner-price-form#updateTierValue" 20609 > 20610 </td> 20611 20612 <td class="px-3 py-2"> 20613 <input 20614 type="text" 20615 class="w-full border border-gray-300 rounded-md px-3 py-2 text-sm focus:ring-2 focus:ring-purple-500 focus:border-purple-500" 20616 inputmode="numeric" 20617 pattern="[0-9]*" 20618 value="${displayValue(tier.max_quantity)}" 20619 data-tier-field="max_quantity" 20620 data-action="input->partner-price-form#sanitizeTierInput change->partner-price-form#updateTierValue" 20621 > 20622 </td> 20623 20624 <td class="px-3 py-2"> 20625 <input 20626 type="number" 20627 class="w-full border border-gray-300 rounded-md px-3 py-2 text-sm focus:ring-2 focus:ring-purple-500 focus:border-purple-500" 20628 step="any" 20629 min="1" 20630 max="100" 20631 placeholder="1 - 100" 20632 value="${displayValue(tier.discount_percentage)}" 20633 data-tier-field="discount_percentage" 20634 data-action="change->partner-price-form#updateTierValue" 20635 > 20636 </td> 20637 20638 <td class="px-3 py-2 text-right"> 20639 <button 20640 type="button" 20641 class="text-red-500 hover:text-red-700 text-sm font-medium" 20642 data-action="partner-price-form#removeTierRow" 20643 data-tier-index="${index}" 20644 aria-label="Remove tier" 20645 > 20646 <i class="fa-solid fa-trash" style="color: rgb(214, 42, 14);"></i> 20647 </button> 20648 </td> 20649 `; 20650 this.tierBodyTarget.appendChild(row); 20651 }); 20652 this.updateTierTableVisibility(); 20653 this.updateAddTierButtonState(); 20654 } 20655 updateInput() { 20656 if (!this.tierInputTarget) 20657 return; 20658 this.tierInputTarget.value = JSON.stringify(this.sanitizeTiers()); 20659 } 20660 parseTiers() { 20661 if (!this.tierInputTarget) 20662 return [];
20663 try { 20664 const parsed = JSON.parse(this.tierInputTarget.value); 20665 return Array.isArray(parsed) ? parsed : []; 20666 } catch { 20667 return []; 20668 } 20669 } 20670 syncFromInput = () => { 20671 this.tiers = this.parseTiers(); 20672 this.renderRows(); 20673 }; 20674 setFieldEnabled(enabled) { 20675 if (this.tierInputTarget) { 20676 this.tierInputTarget.disabled = !enabled; 20677 } 20678 if (this.hasDiscountContainerTarget) { 20679 this.discountContainerTarget.querySelectorAll("input, select, button").forEach((el) => { 20680 el.disabled = !enabled; 20681 }); 20682 } 20683 } 20684 sanitizeTiers() { 20685 return this.tiers.map((tier) => ({ 20686 tier: tier.tier, 20687 min_quantity: this.sanitizeTierNumber(tier.min_quantity), 20688 max_quantity: this.sanitizeTierNumber(tier.max_quantity), 20689 discount_percentage: this.sanitizeTierNumber(tier.discount_percentage) 20690 })); 20691 } 20692 sanitizeTierNumber(value) { 20693 if (value === "" || value === null || value === void 0) 20694 return null; 20695 const digitsOnly = String(value).replace(/\D/g, ""); 20696 if (digitsOnly === "") 20697 return null; 20698 const parsed = parseInt(digitsOnly, 10); 20699 return Number.isNaN(parsed) ? null : parsed; 20700 } 20701 updateTierTableVisibility() { 20702 if (!this.hasTierTableWrapperTarget) 20703 return; 20704 const hasRows = this.tiers.length > 0; 20705 this.tierTableWrapperTarget.classList.toggle("hidden", !hasRows); 20706 } 20707 updateAmountFieldVisibility(showAmountField) { 20708 if (!this.hasAmountFieldWrapperTarget) 20709 return; 20710 this.amountFieldWrapperTarget.classList.toggle("hidden", !showAmountField); 20711 this.amountFieldWrapperTarget.querySelectorAll("input, select, textarea").forEach((el) => { 20712 el.disabled = !showAmountField; 20713 }); 20714 } 20715 updatePercentageFieldVisibility(showPercentageField) { 20716 if (!this.hasAmountPercentageFieldWrapperTarget) 20717 return; 20718 this.amountPercentageFieldWrapperTarget.classList.toggle("hidden", !showPercentageField); 20719 this.amountPercentageFieldWrapperTarget.querySelectorAll("input, select, textarea").forEach((el) => { 20720 el.disabled = !showPercentageField; 20721 }); 20722 } 20723 normalizedPricingType(rawValue) { 20724 if (!rawValue) 20725 return ""; 20726 const value = String(rawValue).trim().toLowerCase(); 20727 if (value === "none" || value === "no_discount") 20728 return "no_discount"; 20729 return value; 20730 } 20731 handleUserGroupChange() { 20732 this.updateProductSelect(); 20733 } 20734 updateProductSelect() { 20735 if (!this.hasPriceSelectTarget) 20736 return; 20737 const selectedGroupId = this.userGroupSelect?.value ? Number(this.userGroupSelect.value) : null; 20738 const hasGroupSelection = Boolean(this.userGroupSelect?.value); 20739 const blockedPriceIds = this.blockedPriceIdsForGroup(selectedGroupId); 20740 const groupPrices = this.availablePricesForGroup(selectedGroupId); 20741 const currentPriceId = this.selectedPriceId(!this.didInitializePriceSelect); 20742 const placeholderText = hasGroupSelection ? "Select prices" : "Select a user group first"; 20743 this.priceSelectTarget.disabled = !hasGroupSelection; 20744 const slimSelect = this.slimSelectInstance(); 20745 if (slimSelect) { 20746 const options2 = groupPrices.map((price) => { 20747 const isSelected = currentPriceId === price.id; 20748 const isBlocked = blockedPriceIds.includes(price.id) && !isSelected; 20749 return { 20750 text: isBlocked ? `${price.label} (already configured)` : isSelected ? `${price.label} (selected)` : price.label, 20751 value: price.id.toString(), 20752 disabled: isBlocked 20753 }; 20754 }); 20755 slimSelect.setData([ 20756 { 20757 text: placeholderText, 20758 value: "", 20759 placeholder: true, 20760 selected: currentPriceId === null 20761 }, 20762 ...options2 20763 ]); 20764 slimSelect.set(currentPriceId ? currentPriceId.toString() : ""); 20765 hasGroupSelection ? slimSelect.enable() : slimSelect.disable(); 20766 this.didInitializePriceSelect = true; 20767 return; 20768 } 20769 this.priceSelectTarget.innerHTML = ""; 20770 const placeholderOption = document.createElement("option"); 20771 placeholderOption.value = ""; 20772 placeholderOption.textContent = placeholderText; 20773 placeholderOption.selected = currentPriceId === null; 20774 this.priceSelectTarget.appendChild(placeholderOption);
20775 groupPrices.forEach((price) => { 20776 const option = document.createElement("option"); 20777 option.value = price.id; 20778 option.textContent = price.label; 20779 const isBlocked = blockedPriceIds.includes(price.id) && currentPriceId !== price.id; 20780 if (isBlocked) { 20781 option.disabled = true; 20782 option.textContent = `${price.label} (already configured)`; 20783 } 20784 if (currentPriceId === price.id) { 20785 option.selected = true; 20786 } 20787 this.priceSelectTarget.appendChild(option); 20788 }); 20789 this.priceSelectTarget.disabled = !hasGroupSelection; 20790 this.didInitializePriceSelect = true; 20791 } 20792 slimSelectInstance() { 20793 return this.priceSelectTarget && this.priceSelectTarget._slimSelect || null; 20794 } 20795 blockedPriceIdsForGroup(groupId) { 20796 if (!groupId) 20797 return []; 20798 const group = this.userGroupsValue.find((item) => item.id === groupId); 20799 return group?.blocked_price_ids || []; 20800 } 20801 availablePricesForGroup(groupId) { 20802 if (!groupId) 20803 return []; 20804 const group = this.userGroupsValue.find((item) => item.id === groupId); 20805 return group?.prices || []; 20806 } 20807 selectedPriceId(useInitialFallback = false) { 20808 const selectedValue = Number(this.priceSelectTarget.value); 20809 if (Number.isInteger(selectedValue) && selectedValue > 0) 20810 return selectedValue; 20811 return useInitialFallback ? this.initialPriceId : null; 20812 } 20813 tierOptionsForRow(index, currentValue) { 20814 const normalizedCurrent = normalizeTierValue(currentValue); 20815 const usedInOtherRows = this.usedTierValues(index); 20816 const options2 = TIER_OPTIONS.filter((option) => option.value === normalizedCurrent || !usedInOtherRows.includes(option.value)); 20817 if (normalizedCurrent && !options2.some((option) => option.value === normalizedCurrent)) { 20818 options2.unshift({ 20819 value: normalizedCurrent, 20820 label: capitalizeTier(normalizedCurrent) 20821 }); 20822 } 20823 return options2; 20824 } 20825 usedTierValues(excludedIndex = null) { 20826 return this.tiers.map((tier, index) => { 20827 if (excludedIndex !== null && index === excludedIndex) 20828 return null; 20829 return normalizeTierValue(tier.tier); 20830 }).filter(Boolean); 20831 } 20832 nextAvailableTierValue() { 20833 const usedTiers = this.usedTierValues(); 20834 const availableOption = TIER_OPTIONS.find((option) => !usedTiers.includes(option.value)); 20835 return availableOption?.value || null; 20836 } 20837 updateAddTierButtonState() { 20838 if (!this.addTierButton) 20839 return; 20840 const canAddMore = this.nextAvailableTierValue() !== null; 20841 this.addTierButton.classList.toggle("hidden", !canAddMore); 20842 this.addTierButton.disabled = !canAddMore; 20843 this.addTierButton.title = canAddMore ? "" : "All tiers have already been added."; 20844 } 20845 }; 20846 __publicField(partner_price_form_controller_default, "targets", [ 20847 "discountContainer", 20848 "guidance", 20849 "tierInput", 20850 "tierBody", 20851 "tierTableWrapper", 20852 "priceSelect", 20853 "amountFieldWrapper", 20854 "amountPercentageFieldWrapper" 20855 ]); 20856 __publicField(partner_price_form_controller_default, "values", { 20857 userGroups: Array, 20858 currentPriceId: String 20859 }); 20860 function displayValue(value) { 20861 return value === null || value === void 0 ? "" : value; 20862 } 20863 function normalizeTierValue(value) { 20864 return String(value || "").toLowerCase().trim(); 20865 } 20866 function capitalizeTier(value) { 20867 if (!value) 20868 return ""; 20869 return `${value.charAt(0).toUpperCase()}${value.slice(1)}`; 20870 } 20871 20872
20872// controllers/partner_products_catalog_controller.js 20873 var partner_products_catalog_controller_exports = {}; 20874 __export(partner_products_catalog_controller_exports, { 20875 default: () => partner_products_catalog_controller_default 20876 }); 20877 var partner_products_catalog_controller_default = class extends Controller { 20878 connect() { 20879 this.timer = null; 20880 this.restoreInputFocus(); 20881 } 20882 disconnect() { 20883 this.clearTimer(); 20884 } 20885 capInput() { 20886 if (!this.hasInputTarget) 20887 return; 20888 const max2 = this.maxLengthValue; 20889 if (this.inputTarget.value.length > max2) { 20890 this.inputTarget.value = this.inputTarget.value.slice(0, max2); 20891 } 20892 } 20893 scheduleSubmit() { 20894 this.capInput(); 20895 if (!this.hasFormTarget) 20896 return; 20897 const q = this.inputTarget.value.trim(); 20898 if (q.length === 0) { 20899 this.clearTimer(); 20900 this.persistInputFocus(); 20901 this.formTarget.requestSubmit(); 20902 return; 20903 } 20904 if (q.length < this.minLengthValue) { 20905 this.clearTimer(); 20906 return; 20907 } 20908 this.clearTimer(); 20909 this.timer = window.setTimeout(() => { 20910 this.persistInputFocus(); 20911 this.formTarget.requestSubmit(); 20912 }, this.debounceValue); 20913 } 20914 persistInputFocus() { 20915 if (!this.hasInputTarget) 20916 return; 20917 const payload = { 20918 wasFocused: document.activeElement === this.inputTarget 20919 }; 20920 window.sessionStorage.setItem(this.constructor.FOCUS_STATE_KEY, JSON.stringify(payload)); 20921 } 20922 restoreInputFocus() { 20923 if (!this.hasInputTarget) 20924 return; 20925 const raw = window.sessionStorage.getItem(this.constructor.FOCUS_STATE_KEY); 20926 if (!raw) 20927 return; 20928 window.sessionStorage.removeItem(this.constructor.FOCUS_STATE_KEY); 20929 try { 20930 const state = JSON.parse(raw); 20931 if (!state?.wasFocused) 20932 return; 20933 this.inputTarget.focus({ preventScroll: true }); 20934 const len = this.inputTarget.value.length; 20935 this.inputTarget.setSelectionRange(len, len); 20936 } catch (_error) { 20937 } 20938 } 20939 clearTimer() { 20940 if (!this.timer) 20941 return; 20942 window.clearTimeout(this.timer); 20943 this.timer = null; 20944 } 20945 userGroupCheckboxChanged(event) { 20946 const toggledAll = this.hasUserGroupAllCheckboxTarget && event.target === this.userGroupAllCheckboxTarget; 20947 if (toggledAll) { 20948 if (this.userGroupAllCheckboxTarget.checked) { 20949 this.userGroupCheckboxTargets.forEach((checkbox) => { 20950 checkbox.checked = false; 20951 }); 20952 } else { 20953 this.userGroupAllCheckboxTarget.checked = true; 20954 } 20955 } else { 20956 const anySpecificChecked = this.userGroupCheckboxTargets.some((checkbox) => checkbox.checked); 20957 if (this.hasUserGroupAllCheckboxTarget) 20958 this.userGroupAllCheckboxTarget.checked = !anySpecificChecked; 20959 } 20960 } 20961 applyUserGroupFilter() { 20962 if (!this.hasFormTarget) 20963 return; 20964 this.formTarget.requestSubmit(); 20965 } 20966 resetUserGroupFilter() { 20967 if (this.hasUserGroupAllCheckboxTarget) 20968 this.userGroupAllCheckboxTarget.checked = true; 20969 this.userGroupCheckboxTargets.forEach((checkbox) => { 20970 checkbox.checked = false; 20971 }); 20972 this.applyUserGroupFilter(); 20973 } 20974 filterUserGroupOptions() { 20975 if (!this.hasUserGroupSearchInputTarget) 20976 return; 20977 const query = this.userGroupSearchInputTarget.value.trim().toLowerCase(); 20978 let anyVisible = false; 20979 this.userGroupOptionTargets.forEach((option) => { 20980 const title = option.dataset.userGroupTitle || ""; 20981 const matches = title.includes(query); 20982 option.classList.toggle("hidden", !matches); 20983 if (matches) 20984 anyVisible = true; 20985 }); 20986 if (this.hasUserGroupNoResultsTarget) { 20987 this.userGroupNoResultsTarget.classList.toggle("hidden", anyVisible); 20988 } 20989 } 20990 }; 20991 __publicField(partner_products_catalog_controller_default, "targets", [ 20992 "form", 20993 "input", 20994 "userGroupAllCheckbox", 20995 "userGroupCheckbox", 20996 "userGroupSearchInput", 20997 "userGroupOptionsList", 20998 "userGroupOption", 20999 "userGroupNoResults" 21000 ]); 21001 __publicField(partner_products_catalog_controller_default, "values", { 21002 debounce: { type: Number, default: 250 }, 21003 minLength: { type: Number, default: 3 }, 21004 maxLength: { type: Number, default: 200 } 21005 }); 21006 __publicField(partner_products_catalog_controller_default, "FOCUS_STATE_KEY", "partnerProductsCatalogFocusState"); 21007 21008
21008// controllers/partner_resource_file_controller.js 21009 var partner_resource_file_controller_exports = {}; 21010 __export(partner_resource_file_controller_exports, { 21011 default: () => partner_resource_file_controller_default 21012 }); 21013 var ACCEPT_MAP = { 21014 image: "image/*", 21015 video: "video/*", 21016 pdf: "application/pdf" 21017 }; 21018 var partner_resource_file_controller_default = class extends Controller { 21019 connect() { 21020 this.resourceTypeInput = this.element.closest("form")?.querySelector("select[name='partner_resource[resource_type]']"); 21021 this.fileInput = this.element.closest("form")?.querySelector("input[type='file'][name='partner_resource[file]']"); 21022 this.boundTypeChange = this.updateAccept.bind(this); 21023 if (this.resourceTypeInput) { 21024 this.resourceTypeInput.addEventListener("change", this.boundTypeChange); 21025 } 21026 this.updateAccept(); 21027 } 21028 disconnect() { 21029 if (this.resourceTypeInput) { 21030 this.resourceTypeInput.removeEventListener("change", this.boundTypeChange); 21031 } 21032 } 21033 updateAccept() { 21034 const type = this.resourceTypeInput?.value; 21035 const accept = ACCEPT_MAP[type] || "image/*,video/*,application/pdf"; 21036 this.fileInput?.setAttribute("accept", accept); 21037 } 21038 }; 21039 21040
21040// controllers/partner_resource_preview_controller.js 21041 var partner_resource_preview_controller_exports = {}; 21042 __export(partner_resource_preview_controller_exports, { 21043 default: () => partner_resource_preview_controller_default 21044 }); 21045 var partner_resource_preview_controller_default = class extends Controller { 21046 connect() { 21047 this.fileInput = this.element.closest("form")?.querySelector("input[type='file'][name='partner_resource[file]']"); 21048 this.reader = new FileReader(); 21049 this.reader.addEventListener("load", () => { 21050 this.latestDataUrl = this.reader.result; 21051 }); 21052 if (this.fileInput) { 21053 this.boundFileChange = this.handleFileChange.bind(this); 21054 this.fileInput.addEventListener("change", this.boundFileChange); 21055 } 21056 } 21057 disconnect() { 21058 if (this.fileInput) { 21059 this.fileInput.removeEventListener("change", this.boundFileChange); 21060 } 21061 } 21062 handleFileChange() { 21063 const file = this.fileInput?.files?.[0]; 21064 if (!file) { 21065 this.clearPreview(); 21066 return; 21067 } 21068 this.fileType = file.type || ""; 21069 this.latestDataUrl = null; 21070 this.reader.readAsDataURL(file); 21071 } 21072 renderPreview(event) { 21073 event.preventDefault(); 21074 const file = this.fileInput?.files?.[0]; 21075 if (!file) { 21076 this.renderMessage("Select a file to preview."); 21077 return; 21078 } 21079 if (!this.latestDataUrl) { 21080 this.renderMessage("Preparing preview, please try again."); 21081 return; 21082 } 21083 const type = this.fileType || file.type || ""; 21084 let content = ""; 21085 if (type.startsWith("image/")) { 21086 content = `<img src="${this.latestDataUrl}" alt="${file.name}" class="h-full w-full object-contain" />`; 21087 } else if (type === "application/pdf" || type === "application/x-pdf") { 21088 content = `<iframe src="${this.latestDataUrl}" class="h-full w-full" title="${file.name}"></iframe>`; 21089 } else if (type.startsWith("video/")) { 21090 content = `<video controls class="h-full w-full"><source src="${this.latestDataUrl}" type="${type}">Your browser does not support video previews.</video>`; 21091 } else { 21092 content = "<div class='flex h-full items-center justify-center text-sm text-gray-500'>Preview not supported for this file type.</div>"; 21093 } 21094 this.outputTarget.classList.remove("hidden"); 21095 this.outputTarget.innerHTML = content; 21096 } 21097 renderMessage(message) { 21098 this.outputTarget.classList.remove("hidden"); 21099 this.outputTarget.innerHTML = `<div class="flex h-full items-center justify-center text-sm text-gray-500">${message}</div>`; 21100 } 21101 clearPreview() { 21102 this.outputTarget.classList.add("hidden"); 21103 this.outputTarget.innerHTML = ""; 21104 } 21105 }; 21106 __publicField(partner_resource_preview_controller_default, "targets", ["output"]); 21107 21108
21108// controllers/partner_resources_search_controller.js 21109 var partner_resources_search_controller_exports = {}; 21110 __export(partner_resources_search_controller_exports, { 21111 default: () => partner_resources_search_controller_default 21112 }); 21113 var partner_resources_search_controller_default = class extends Controller { 21114 connect() { 21115 this.timer = null; 21116 } 21117 disconnect() { 21118 this.clearTimer(); 21119 } 21120 capInput() { 21121 if (!this.hasInputTarget) 21122 return; 21123 const max2 = this.maxLengthValue; 21124 if (this.inputTarget.value.length > max2) { 21125 this.inputTarget.value = this.inputTarget.value.slice(0, max2); 21126 } 21127 } 21128 scheduleSubmit() { 21129 this.capInput(); 21130 if (!this.hasFormTarget) 21131 return; 21132 const q = this.inputTarget.value.trim(); 21133 if (q.length === 0) { 21134 this.clearTimer(); 21135 this.formTarget.requestSubmit(); 21136 return; 21137 } 21138 if (q.length < this.minLengthValue) { 21139 this.clearTimer(); 21140 return; 21141 } 21142 this.clearTimer(); 21143 this.timer = window.setTimeout(() => { 21144 this.formTarget.requestSubmit(); 21145 }, this.debounceValue); 21146 } 21147 showLoading() { 21148 if (!this.hasLoadingTarget) 21149 return; 21150 this.loadingTarget.classList.remove("hidden"); 21151 } 21152 hideLoading() { 21153 if (!this.hasLoadingTarget) 21154 return; 21155 this.loadingTarget.classList.add("hidden"); 21156 } 21157 clearTimer() { 21158 if (!this.timer) 21159 return; 21160 window.clearTimeout(this.timer); 21161 this.timer = null; 21162 } 21163 }; 21164 __publicField(partner_resources_search_controller_default, "targets", ["form", "input", "loading"]); 21165 __publicField(partner_resources_search_controller_default, "values", { 21166 debounce: { type: Number, default: 400 }, 21167 minLength: { type: Number, default: 2 }, 21168 maxLength: { type: Number, default: 200 } 21169 }); 21170 21171
21171// controllers/partner_sidebar_controller.js 21172 var partner_sidebar_controller_exports = {}; 21173 __export(partner_sidebar_controller_exports, { 21174 default: () => partner_sidebar_controller_default 21175 }); 21176 var partner_sidebar_controller_default = class extends Controller { 21177 toggle() { 21178 const isOpen = this.sidebarTarget.classList.contains("translate-x-0"); 21179 if (isOpen) { 21180 this._close(); 21181 } else { 21182 this._open(); 21183 } 21184 } 21185 closeOverlay() { 21186 this._close(); 21187 } 21188 closeMobileOnNav() { 21189 if (window.innerWidth < 768) { 21190 this._close(); 21191 } 21192 } 21193 _open() { 21194 this.sidebarTarget.classList.remove("-translate-x-full"); 21195 this.sidebarTarget.classList.add("translate-x-0"); 21196 this.overlayTarget.classList.remove("hidden", "opacity-0"); 21197 this.overlayTarget.classList.add("opacity-100"); 21198 this.overlayTarget.classList.remove("pointer-events-none"); 21199 document.body.classList.add("overflow-hidden"); 21200 } 21201 _close() { 21202 this.sidebarTarget.classList.remove("translate-x-0"); 21203 this.sidebarTarget.classList.add("-translate-x-full"); 21204 this.overlayTarget.classList.remove("opacity-100"); 21205 this.overlayTarget.classList.add("opacity-0"); 21206 this.overlayTarget.classList.add("pointer-events-none"); 21207 setTimeout(() => { 21208 if (this.hasOverlayTarget) { 21209 this.overlayTarget.classList.add("hidden"); 21210 } 21211 }, 300); 21212 document.body.classList.remove("overflow-hidden"); 21213 } 21214 }; 21215 __publicField(partner_sidebar_controller_default, "targets", ["sidebar", "overlay"]); 21216 21217
21217// controllers/password_controller.js 21218 var password_controller_exports = {}; 21219 __export(password_controller_exports, { 21220 default: () => password_controller_default 21221 }); 21222 var password_controller_default = class extends Controller { 21223 handlePassword(event) { 21224 let field = event.target.previousElementSibling; 21225 let eyeIcon = event.target; 21226 if (field.value.trim().length === 0) { 21227 return null; 21228 } 21229 if (field.type === "password") { 21230 field.type = "text"; 21231 eyeIcon.classList.remove("fa-eye"); 21232 eyeIcon.classList.add("fa-eye-slash"); 21233 } else { 21234 field.type = "password"; 21235 eyeIcon.classList.remove("fa-eye-slash"); 21236 eyeIcon.classList.add("fa-eye"); 21237 } 21238 } 21239 }; 21240 21241
21241// controllers/password_strength_controller.js 21242 var password_strength_controller_exports = {}; 21243 __export(password_strength_controller_exports, { 21244 default: () => password_strength_controller_default 21245 }); 21246 var password_strength_controller_default = class extends Controller { 21247 connect() { 21248 this.passwordTarget.addEventListener("input", this.checkPasswordStrength.bind(this)); 21249 this.confirmationTarget.addEventListener("input", this.checkPasswordMatch.bind(this)); 21250 } 21251 checkPasswordStrength() { 21252 const password = this.passwordTarget.value; 21253 const strength = this.calculatePasswordStrength(password); 21254 this.hidePasswordInstructions(); 21255 this.showPasswordRequirements(); 21256 this.checkPasswordMatch(); 21257 this.updateStrength(strength); 21258 this.updateStrengthText(strength); 21259 } 21260 hidePasswordInstructions() { 21261 if (this.passwordTarget.value.length === 0) { 21262 this.instructionsTarget.style.display = "block"; 21263 } else { 21264 this.instructionsTarget.style.display = "none"; 21265 } 21266 } 21267 showPasswordRequirements() { 21268 this.requirementsTarget.style.display = "block"; 21269 } 21270 checkPasswordMatch() { 21271 if (this.confirmationTarget.value && this.passwordTarget.value !== this.confirmationTarget.value) { 21272 this.confirmationTextTarget.innerHTML = "Passwords do not match"; 21273 this.confirmationTextTarget.style.color = "#F44336"; 21274 } else { 21275 this.confirmationTextTarget.innerHTML = ""; 21276 this.confirmationTextTarget.style.color = ""; 21277 } 21278 } 21279 calculatePasswordStrength(password) { 21280 let strength = 0; 21281 if (password.match(/[a-z]/)) { 21282 this.lowercaseLetterTarget.classList.toggle("invalid", false); 21283 strength += 20; 21284 } else { 21285 this.lowercaseLetterTarget.classList.toggle("invalid", true); 21286 } 21287 if (password.match(/[A-Z]/)) { 21288 this.uppercaseLetterTarget.classList.toggle("invalid", false); 21289 strength += 20; 21290 } else { 21291 this.uppercaseLetterTarget.classList.toggle("invalid", true); 21292 } 21293 if (password.match(/\d+/)) { 21294 this.numberTarget.classList.toggle("invalid", false); 21295 strength += 20; 21296 } else { 21297 this.numberTarget.classList.toggle("invalid", true); 21298 } 21299 if (password.match(/(?=.*[!@#\$%\^&\*])/)) { 21300 this.symbolTarget.classList.toggle("invalid", false); 21301 strength += 20; 21302 } else { 21303 this.symbolTarget.classList.toggle("invalid", true); 21304 } 21305 if (password.trim().length >= 8) { 21306 this.lengthTarget.classList.toggle("invalid", false); 21307 strength += 20; 21308 } else { 21309 this.lengthTarget.classList.toggle("invalid", true); 21310 } 21311 return strength; 21312 } 21313 updateStrength(strength) { 21314 this.barTarget.style.width = `${strength}%`; 21315 } 21316 updateStrengthText(strength) { 21317 this.strengthTextTarget.innerHTML = `Password strength: ${strength}%`; 21318 } 21319 }; 21320 __publicField(password_strength_controller_default, "targets", [ 21321 "password", 21322 "confirmation", 21323 "confirmationText", 21324 "bar", 21325 "strengthText", 21326 "length", 21327 "lowercaseLetter", 21328 "uppercaseLetter", 21329 "number", 21330 "symbol", 21331 "requirements", 21332 "instructions" 21333 ]); 21334 21335
21335// controllers/paypal_controller.js 21336 var paypal_controller_exports = {}; 21337 __export(paypal_controller_exports, { 21338 default: () => paypal_controller_default 21339 }); 21340 var paypal_controller_default = class extends Controller { 21341 connect() { 21342 braintree.client.create({ 21343 authorization: this.data.get("clientToken") 21344 }, this.clientCreated.bind(this)); 21345 } 21346 disconnect() { 21347 this.buttonTarget.querySelector(".paypal-button").remove(); 21348 } 21349 clientCreated(error2, clientInstance) { 21350 if (error2) { 21351 console.error("Error creating client", error2); 21352 return; 21353 } 21354 braintree.paypalCheckout.create({ 21355 client: clientInstance 21356 }, this.paypalCreated.bind(this)); 21357 } 21358 paypalCreated(paypalCheckoutErr, paypalCheckoutInstance) { 21359 if (paypalCheckoutErr) { 21360 console.error("Error creating PayPal Checkout:", paypalCheckoutErr); 21361 return; 21362 } 21363 paypal.Button.render({ 21364 env: this.data.get("env"), 21365 style: { 21366 color: "gold", 21367 shape: "rect", 21368 size: "medium", 21369 label: "pay", 21370 tagline: false 21371 }, 21372 payment: () => { 21373 return paypalCheckoutInstance.createPayment({ 21374 flow: "vault" 21375 }); 21376 }, 21377 onAuthorize: (data, actions) => { 21378 return paypalCheckoutInstance.tokenizePayment(data, this.paymentMethod.bind(this)); 21379 }, 21380 onCancel: (data) => { 21381 console.log("checkout.js payment cancelled", JSON.stringify(data, 0, 2)); 21382 }, 21383 onError: (err) => { 21384 console.error("checkout.js error", err); 21385 } 21386 }, this.buttonTarget).then(() => { 21387 }); 21388 } 21389 paymentMethod(error2, payload) { 21390 if (error2) { 21391 console.error("Error with payment method:", error2); 21392 return; 21393 } 21394 this.addHiddenField("processor", "braintree"); 21395 this.addHiddenField("payment_method_token", payload.nonce); 21396 Rails.fire(this.formTarget, "submit"); 21397 } 21398 addHiddenField(name, value) { 21399 let hiddenInput = document.createElement("input"); 21400 hiddenInput.setAttribute("type", "hidden"); 21401 hiddenInput.setAttribute("name", name); 21402 hiddenInput.setAttribute("value", value); 21403 this.formTarget.appendChild(hiddenInput); 21404 } 21405 }; 21406 __publicField(paypal_controller_default, "targets", ["button", "form"]); 21407 21408
21408// controllers/places_autocomplete_controller.js 21409 var places_autocomplete_controller_exports = {}; 21410 __export(places_autocomplete_controller_exports, { 21411 default: () => places_autocomplete_controller_default 21412 }); 21413 var places_autocomplete_controller_default = class extends Controller { 21414 connect() { 21415 this.initializeAutocomplete(); 21416 } 21417 initializeAutocomplete() { 21418 if (typeof google === "undefined" || !google.maps || !google.maps.places) { 21419 setTimeout(() => this.initializeAutocomplete(), 100); 21420 return; 21421 } 21422 const options2 = { 21423 types: ["address"], 21424 fields: ["address_components", "formatted_address", "geometry"], 21425 componentRestrictions: { 21426 country: this.countryRestrictionsValue.length > 0 ? this.countryRestrictionsValue : ["US", "CA", "GB", "AU", "IN"] 21427 } 21428 }; 21429 this.autocomplete = new google.maps.places.Autocomplete(this.autocompleteTarget, options2); 21430 this.autocomplete.addListener("place_changed", () => this.handlePlaceSelect()); 21431 } 21432 handlePlaceSelect() { 21433 const place = this.autocomplete.getPlace(); 21434 if (!place.address_components) { 21435 return; 21436 } 21437 this.populateAddressFields(place.address_components); 21438 if (this.hasCountryTarget) { 21439 } 21440 if (typeof updateShippingCost === "function" && this.hasCountryTarget) { 21441 } 21442 } 21443 populateAddressFields(addressComponents) { 21444 const address = { 21445 line1: "", 21446 line2: "", 21447 city: "", 21448 state: "", 21449 country: "", 21450 zipcode: "" 21451 }; 21452 addressComponents.forEach((component) => { 21453 const types = component.types; 21454 if (types.includes("street_number")) { 21455 address.line1 = component.long_name + " "; 21456 } 21457 if (types.includes("route")) { 21458 address.line1 += component.long_name; 21459 } 21460 if (types.includes("subpremise")) { 21461 address.line2 = component.long_name; 21462 } 21463 if (types.includes("locality")) { 21464 address.city = component.long_name; 21465 } else if (types.includes("sublocality_level_1") && !address.city) { 21466 address.city = component.long_name; 21467 } else if (types.includes("sublocality") && types.includes("political") && !address.city) { 21468 address.city = component.long_name; 21469 } else if (types.includes("administrative_area_level_3") && !address.city) { 21470 address.city = component.long_name; 21471 } 21472 if (types.includes("administrative_area_level_1")) { 21473 address.state = component.short_name; 21474 } 21475 if (types.includes("country")) { 21476 address.country = component.short_name; 21477 } 21478 if (types.includes("postal_code")) { 21479 address.zipcode = component.long_name; 21480 } 21481 }); 21482 if (!address.city) { 21483 const cityCandidate = addressComponents.find((component) => component.types.some((type) => type.includes("sublocality") || type.includes("neighborhood") || type.includes("administrative_area_level_2"))); 21484 if (cityCandidate) { 21485 address.city = cityCandidate.long_name; 21486 } 21487 } 21488 this.populateField(this.line1Target, address.line1.trim()); 21489 this.populateField(this.line2Target, address.line2); 21490 this.populateField(this.cityTarget, address.city); 21491 this.populateField(this.countryTarget, address.country); 21492 this.populateField(this.zipcodeTarget, address.zipcode); 21493 this.populateStateField(address.state); 21494 } 21495 populateField(target, value) { 21496 if (target && value) { 21497 target.value = value; 21498 target.dispatchEvent(new Event("change", { bubbles: true })); 21499 } 21500 } 21501 populateStateField(stateCode) { 21502 if (!this.hasStateTarget || !stateCode) 21503 return; 21504 if (this.stateTarget.tagName === "SELECT") { 21505 setTimeout(() => { 21506 const options2 = this.stateTarget.options; 21507 for (let i2 = 0; i2 < options2.length; i2++) { 21508 if (options2[i2].value === stateCode) { 21509 this.stateTarget.selectedIndex = i2; 21510 this.stateTarget.dispatchEvent(new Event("change", { bubbles: true })); 21511 break; 21512 } 21513 } 21514 }, 1500); 21515 } else { 21516 this.populateField(this.stateTarget, stateCode); 21517 } 21518 } 21519 clearAutocomplete() { 21520 if (this.hasAutocompleteTarget) { 21521 this.autocompleteTarget.value = ""; 21522 } 21523 } 21524 disableAutocomplete() { 21525 if (this.autocomplete) { 21526 google.maps.event.clearInstanceListeners(this.autocomplete); 21527 } 21528 } 21529 enableAutocomplete() { 21530 if (this.autocomplete) { 21531 this.autocomplete.addListener("place_changed", () => this.handlePlaceSelect()); 21532 } 21533 } 21534 }; 21535 __publicField(places_autocomplete_controller_default, "targets", ["autocomplete", "line1", "line2", "city", "state", "country", "zipcode"]); 21536 __publicField(places_autocomplete_controller_default, "values", { 21537 addressType: String, 21538 countryRestrictions: Array 21539 }); 21540 21541
21541// controllers/pricing_controller.js 21542 var pricing_controller_exports = {}; 21543 __export(pricing_controller_exports, { 21544 default: () => pricing_controller_default 21545 }); 21546 var pricing_controller_default = class extends Controller { 21547 connect() { 21548 this.activeFrequencyClass = (this.data.get("active-frequency-class") || "bg-white shadow-sm text-black hover:text-black").split(" "); 21549 this.inactiveFrequencyClass = (this.data.get("inactive-frequency-class") || "hover:text-gray-900").split(" "); 21550 this.activePlansClass = (this.data.get("activePlansClass") || "flex").split(" "); 21551 this.inactivePlansClass = (this.data.get("inactivePlansClass") || "hidden").split(" "); 21552 this.frequencyTargets.forEach((target) => { 21553 let frequency2 = target.dataset.frequency; 21554 let index = this.plansTargets.findIndex((element) => element.dataset.frequency == frequency2 && element.childElementCount > 0); 21555 if (index == -1) 21556 target.remove(); 21557 }); 21558 if (this.frequencyTargets.length < 2) 21559 this._hideFrequencyToggle(); 21560 let frequency = this.data.get("active") || this.frequencyTargets[0].dataset.frequency; 21561 this._toggle(frequency); 21562 } 21563 switch(event) { 21564 event.preventDefault(); 21565 this._toggle(event.target.dataset.frequency); 21566 } 21567 _hideFrequencyToggle() { 21568 this.toggleTarget.classList.add("hidden"); 21569 } 21570 _toggle(frequency) { 21571 this.data.set("active", frequency); 21572 this.frequencyTargets.forEach((target) => { 21573 if (target.dataset.frequency == frequency) { 21574 this.showFrequency(target); 21575 } else { 21576 this.hideFrequency(target); 21577 } 21578 }); 21579 this.plansTargets.forEach((target) => { 21580 if (target.dataset.frequency == frequency) { 21581 this.showPlans(target); 21582 } else { 21583 this.hidePlans(target); 21584 } 21585 }); 21586 } 21587 showFrequency(element) { 21588 element.classList.add(...this.activeFrequencyClass); 21589 element.classList.remove(...this.inactiveFrequencyClass); 21590 } 21591 hideFrequency(element) { 21592 element.classList.remove(...this.activeFrequencyClass); 21593 element.classList.add(...this.inactiveFrequencyClass); 21594 } 21595 showPlans(element) { 21596 element.classList.add(...this.activePlansClass); 21597 element.classList.remove(...this.inactivePlansClass); 21598 } 21599 hidePlans(element) { 21600 element.classList.remove(...this.activePlansClass); 21601 element.classList.add(...this.inactivePlansClass); 21602 } 21603 }; 21604 __publicField(pricing_controller_default, "targets", ["toggle", "frequency", "plans"]); 21605 21606
21606// controllers/search_controller.js 21607 var search_controller_exports = {}; 21608 __export(search_controller_exports, { 21609 default: () => search_controller_default 21610 }); 21611 var search_controller_default = class extends Controller { 21612 clearSearch() { 21613 if (this.search_fieldTarget.value == "") { 21614 this.search_formTarget.dispatchEvent(new CustomEvent("submit", { bubbles: true })); 21615 if (document.querySelector(".options")) { 21616 this.handleOptions("hidden", "block"); 21617 } 21618 } 21619 } 21620 submit() { 21621 this.search_formTarget.requestSubmit(); 21622 } 21623 showOptions() { 21624 this.handleOptions("hidden", "block"); 21625 } 21626 hideOptions() { 21627 setTimeout(() => { 21628 this.handleOptions("block", "hidden"); 21629 }, 300); 21630 } 21631 selectOption(event) { 21632 this.selected_optionTarget.value = event.params.id; 21633 this.search_fieldTarget.value = event.target.innerText; 21634 this.search_fieldTarget.focus(); 21635 this.handleOptions("block", "hidden"); 21636 } 21637 handleOptions(option1, option2) { 21638 this.optionsTarget.classList.remove(option1); 21639 this.optionsTarget.classList.add(option2); 21640 } 21641 updateUserGroups() { 21642 if (!this.hasCheckboxListTarget) 21643 return; 21644 const selectedBrandId = this.brandSelectTarget.value; 21645 const checkboxList = this.checkboxListTarget; 21646 const assignedIds = JSON.parse(checkboxList.dataset.assignedIds || "[]"); 21647 if (!selectedBrandId) { 21648 checkboxList.innerHTML = '<p class="text-gray-400 text-sm p-3">Select a brand to view user groups</p>'; 21649 return; 21650 } 21651 fetch(`/user_groups?brand_id=${selectedBrandId}`).then((response) => response.json()).then((data) => { 21652 if (data.length === 0) { 21653 checkboxList.innerHTML = '<p class="text-gray-400 text-sm p-3">No user groups found for this brand</p>'; 21654 return; 21655 } 21656 checkboxList.innerHTML = data.map((userGroup) => { 21657 const isAssigned = assignedIds.includes(userGroup.id); 21658 return ` 21659 <label class="flex items-center px-3 py-2 border-b border-gray-100 last:border-0 ${isAssigned ? "opacity-60 cursor-not-allowed" : "hover:bg-gray-50 cursor-pointer"}"> 21660 <input type="checkbox" name="user_group_ids[]" value="${userGroup.id}" 21661 class="mr-2 ug-checkbox" ${isAssigned ? "disabled" : ""} 21662 data-action="change->search#syncSelectAll"> 21663 <span class="text-sm">${userGroup.title}${isAssigned ? ' <span class="text-gray-400 text-xs ml-1">(already added)</span>' : ""}</span> 21664 </label> 21665 `; 21666 }).join(""); 21667 if (this.hasSelectAllRowTarget) { 21668 this.selectAllRowTarget.classList.remove("hidden"); 21669 this.selectAllCheckboxTarget.checked = false; 21670 } 21671 }).catch((error2) => console.error("Error fetching user groups:", error2)); 21672 } 21673 toggleSelectAll(event) { 21674 const checked = event.target.checked; 21675 this.checkboxListTarget.querySelectorAll("input.ug-checkbox:not(:disabled)").forEach((cb) => { 21676 cb.checked = checked; 21677 }); 21678 } 21679 syncSelectAll() { 21680 if (!this.hasSelectAllCheckboxTarget) 21681 return; 21682 const all = this.checkboxListTarget.querySelectorAll("input.ug-checkbox:not(:disabled)"); 21683 const allChecked = all.length > 0 && [...all].every((cb) => cb.checked); 21684 this.selectAllCheckboxTarget.checked = allChecked; 21685 } 21686 }; 21687 __publicField(search_controller_default, "targets", ["search_field", "search_form", "selected_option", "options", "brandSelect", "checkboxList", "selectAllRow", "selectAllCheckbox"]); 21688 21689
21689// controllers/select_controller.js 21690 var select_controller_exports = {}; 21691 __export(select_controller_exports, { 21692 default: () => select_controller_default 21693 }); 21694 21695
vendor: 48,582 bytes, lines 21695-22310
21695// ../../node_modules/slim-select/dist/slimselect.min.mjs 21696 var exports = {}; 21697 !function(e2, t) { 21698 typeof exports == "object" && typeof module == "object" ? module.exports = t() : typeof define == "function" && define.amd ? define([], t) : typeof exports == "object" ? exports.SlimSelect = t() : e2.SlimSelect = t(); 21699 }(window, function() { 21700 return n2 = {}, s2.m = i2 = [function(e2, t, i3) { 21701 "use strict"; 21702 function n3(e3, t2) { 21703 t2 = t2 || { bubbles: false, cancelable: false, detail: void 0 }; 21704 var i4 = document.createEvent("CustomEvent"); 21705 return i4.initCustomEvent(e3, t2.bubbles, t2.cancelable, t2.detail), i4; 21706 } 21707 t.__esModule = true, t.kebabCase = t.highlight = t.isValueInArrayOfObjects = t.debounce = t.putContent = t.ensureElementInView = t.hasClassInTree = void 0, t.hasClassInTree = function(e3, t2) { 21708 function n4(e4, t3) { 21709 return t3 && e4 && e4.classList && e4.classList.contains(t3) ? e4 : null; 21710 } 21711 return n4(e3, t2) || function e4(t3, i4) { 21712 return t3 && t3 !== document ? n4(t3, i4) ? t3 : e4(t3.parentNode, i4) : null; 21713 }(e3, t2); 21714 }, t.ensureElementInView = function(e3, t2) { 21715 var i4 = e3.scrollTop + e3.offsetTop, n4 = i4 + e3.clientHeight, s3 = t2.offsetTop, t2 = s3 + t2.clientHeight; 21716 s3 < i4 ? e3.scrollTop -= i4 - s3 : n4 < t2 && (e3.scrollTop += t2 - n4); 21717 }, t.putContent = function(e3, t2, i4) { 21718 var n4 = e3.offsetHeight, s3 = e3.getBoundingClientRect(), e3 = i4 ? s3.top : s3.top - n4, n4 = i4 ? s3.bottom : s3.bottom + n4; 21719 return e3 <= 0 ? "below" : n4 >= window.innerHeight ? "above" : i4 ? t2 : "below"; 21720 }, t.debounce = function(s3, a2, o2) { 21721 var l2; 21722 return a2 === void 0 && (a2 = 100), o2 === void 0 && (o2 = false), function() { 21723 for (var e3 = [], t2 = 0; t2 < arguments.length; t2++) 21724 e3[t2] = arguments[t2]; 21725 var i4 = self, n4 = o2 && !l2; 21726 clearTimeout(l2), l2 = setTimeout(function() { 21727 l2 = null, o2 || s3.apply(i4, e3); 21728 }, a2), n4 && s3.apply(i4, e3); 21729 }; 21730 }, t.isValueInArrayOfObjects = function(e3, t2, i4) { 21731 if (!Array.isArray(e3)) 21732 return e3[t2] === i4; 21733 for (var n4 = 0, s3 = e3; n4 < s3.length; n4++) { 21734 var a2 = s3[n4]; 21735 if (a2 && a2[t2] && a2[t2] === i4) 21736 return true; 21737 } 21738 return false; 21739 }, t.highlight = function(e3, t2, i4) { 21740 var n4 = e3, s3 = new RegExp("(" + t2.trim() + ")(?![^<]*>[^<>]*</)", "i"); 21741 if (!e3.match(s3)) 21742 return e3; 21743 var a2 = e3.match(s3).index, t2 = a2 + e3.match(s3)[0].toString().length, t2 = e3.substring(a2, t2); 21744 return n4 = n4.replace(s3, '<mark class="'.concat(i4, '">').concat(t2, "</mark>")); 21745 }, t.kebabCase = function(e3) { 21746 var t2 = e3.replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g, function(e4) { 21747 return "-" + e4.toLowerCase(); 21748 }); 21749 return e3[0] === e3[0].toUpperCase() ? t2.substring(1) : t2; 21750 }, typeof (t = window).CustomEvent != "function" && (n3.prototype = t.Event.prototype, t.CustomEvent = n3); 21751 }, function(e2, t, i3) { 21752 "use strict"; 21753 t.__esModule = true, t.validateOption = t.validateData = t.Data = void 0; 21754 var n3 = (s3.prototype.newOption = function(e3) { 21755 return { id: e3.id || String(Math.floor(1e8 * Math.random())), value: e3.value || "", text: e3.text || "", innerHTML: e3.innerHTML || "", selected: e3.selected || false, display: e3.display === void 0 || e3.display, disabled: e3.disabled || false, placeholder: e3.placeholder || false, class: e3.class || void 0, data: e3.data || {}, mandatory: e3.mandatory || false }; 21756 }, s3.prototype.add = function(e3) { 21757 this.data.push({ id: String(Math.floor(1e8 * Math.random())), value: e3.value, text: e3.text, innerHTML: "", selected: false, display: true, disabled: false, placeholder: false, class: void 0, mandatory: e3.mandatory, data: {} }); 21758 }, s3.prototype.parseSelectData = function() { 21759 this.data = []; 21760 for (var e3 = 0, t2 = this.main.select.element.childNodes; e3 < t2.length; e3++) { 21761 var i4 = t2[e3]; 21762 if (i4.nodeName === "OPTGROUP") { 21763 for (var n4 = { label: i4.label, options: [] }, s4 = 0, a2 = i4.childNodes; s4 < a2.length; s4++) { 21764 var o2, l2 = a2[s4]; 21765 l2.nodeName === "OPTION" && (o2 = this.pullOptionData(l2), n4.options.push(o2), o2.placeholder && o2.text.trim() !== "" && (this.main.config.placeholderText = o2.text)); 21766 } 21767 this.data.push(n4); 21768 } else 21769 i4.nodeName === "OPTION" && (o2 = this.pullOptionData(i4), this.data.push(o2), o2.placeholder && o2.text.trim() !== "" && (this.main.config.placeholderText = o2.text)); 21770 } 21771 }, s3.prototype.pullOptionData = function(e3) { 21772 return { id: !!e3.dataset && e3.dataset.id || String(Math.floor(1e8 * Math.random())), value: e3.value, text: e3.text, innerHTML: e3.innerHTML, selected: e3.selected, disabled: e3.disabled, placeholder: e3.dataset.placeholder === "true", class: e3.className, style: e3.style.cssText, data: e3.dataset, mandatory: !!e3.dataset && e3.dataset.mandatory === "true" }; 21773 }, s3.prototype.setSelectedFromSelect = function() { 21774 if (this.main.config.isMultiple) { 21775 for (var e3 = [], t2 = 0, i4 = this.main.select.element.options; t2 < i4.length; t2++) { 21776 var n4 = i4[t2]; 21777 !n4.selected || (n4 = this.getObjectFromData(n4.value, "value")) && n4.id && e3.push(n4.id); 21778 } 21779 this.setSelected(e3, "id"); 21780 } else { 21781 var s4 = this.main.select.element; 21782 s4.selectedIndex !== -1 && (s4 = s4.options[s4.selectedIndex].value, this.setSelected(s4, "value")); 21783 } 21784 }, s3.prototype.setSelected = function(e3, t2) { 21785 t2 === void 0 && (t2 = "id"); 21786 for (var i4 = 0, n4 = this.data; i4 < n4.length; i4++) { 21787 var s4 = n4[i4]; 21788 if (s4.hasOwnProperty("label")) { 21789 if (s4.hasOwnProperty("options")) { 21790 var a2 = s4.options; 21791 if (a2) 21792 for (var o2 = 0, l2 = a2; o2 < l2.length; o2++) { 21793 var r4 = l2[o2]; 21794 r4.placeholder || (r4.selected = this.shouldBeSelected(r4, e3, t2)); 21795 } 21796 } 21797 } else 21798 s4.selected = this.shouldBeSelected(s4, e3, t2); 21799 } 21800 }, s3.prototype.shouldBeSelected = function(e3, t2, i4) { 21801 if (i4 === void 0 && (i4 = "id"), Array.isArray(t2)) 21802 for (var n4 = 0, s4 = t2; n4 < s4.length; n4++) { 21803 var a2 = s4[n4]; 21804 if (i4 in e3 && String(e3[i4]) === String(a2)) 21805 return true; 21806 } 21807 else if (i4 in e3 && String(e3[i4]) === String(t2)) 21808 return true; 21809 return false; 21810 }, s3.prototype.getSelected = function() { 21811 for (var e3 = { text: "", placeholder: this.main.config.placeholderText }, t2 = [], i4 = 0, n4 = this.data; i4 < n4.length; i4++) { 21812 var s4 = n4[i4]; 21813 if (s4.hasOwnProperty("label")) { 21814 if (s4.hasOwnProperty("options")) { 21815 var a2 = s4.options; 21816 if (a2) 21817 for (var o2 = 0, l2 = a2; o2 < l2.length; o2++) { 21818 var r4 = l2[o2]; 21819 r4.selected && (this.main.config.isMultiple ? t2.push(r4) : e3 = r4); 21820 } 21821 } 21822 } else 21823 s4.selected && (this.main.config.isMultiple ? t2.push(s4) : e3 = s4); 21824 } 21825 return this.main.config.isMultiple ? t2 : e3; 21826 }, s3.prototype.addToSelected = function(e3, t2) { 21827 if (t2 === void 0 && (t2 = "id"), this.main.config.isMultiple) { 21828 var i4 = [], n4 = this.getSelected(); 21829 if (Array.isArray(n4)) 21830 for (var s4 = 0, a2 = n4; s4 < a2.length; s4++) { 21831 var o2 = a2[s4]; 21832 i4.push(o2[t2]); 21833 } 21834 i4.push(e3), this.setSelected(i4, t2); 21835 } 21836 }, s3.prototype.removeFromSelected = function(e3, t2) { 21837 if (t2 === void 0 && (t2 = "id"), this.main.config.isMultiple) { 21838 for (var i4 = [], n4 = 0, s4 = this.getSelected(); n4 < s4.length; n4++) { 21839 var a2 = s4[n4]; 21840 String(a2[t2]) !== String(e3) && i4.push(a2[t2]); 21841 } 21842 this.setSelected(i4, t2); 21843 } 21844 }, s3.prototype.onDataChange = function() { 21845 this.main.onChange && this.isOnChangeEnabled && this.main.onChange(JSON.parse(JSON.stringify(this.getSelected()))); 21846 }, s3.prototype.getObjectFromData = function(e3, t2) { 21847 t2 === void 0 && (t2 = "id"); 21848 for (var i4 = 0, n4 = this.data; i4 < n4.length; i4++) { 21849 var s4 = n4[i4]; 21850 if (t2 in s4 && String(s4[t2]) === String(e3)) 21851 return s4; 21852 if (s4.hasOwnProperty("options")) { 21853 if (s4.options) 21854 for (var a2 = 0, o2 = s4.options; a2 < o2.length; a2++) { 21855 var l2 = o2[a2]; 21856 if (String(l2[t2]) === String(e3)) 21857 return l2; 21858 } 21859 } 21860 } 21861 return null; 21862 }, s3.prototype.search = function(n4) { 21863 var s4, e3; 21864 (this.searchValue = n4).trim() !== "" ? (s4 = this.main.config.searchFilter, e3 = this.data.slice(0), n4 = n4.trim(), e3 = e3.map(function(e4) { 21865 if (e4.hasOwnProperty("options")) { 21866 var t2 = e4, i4 = []; 21867 if ((i4 = t2.options ? t2.options.filter(function(e5) { 21868 return s4(e5, n4); 21869 }) : i4).length !== 0) { 21870 t2 = Object.assign({}, t2); 21871 return t2.options = i4, t2; 21872 } 21873 } 21874 if (e4.hasOwnProperty("text") && s4(e4, n4)) 21875 return e4; 21876 return null; 21877 }), this.filtered = e3.filter(function(e4) { 21878 return e4; 21879 })) : this.filtered = null; 21880 }, s3); 21881 function s3(e3) { 21882 this.contentOpen = false, this.contentPosition = "below", this.isOnChangeEnabled = true, this.main = e3.main, this.searchValue = "", this.data = [], this.filtered = null, this.parseSelectData(), this.setSelectedFromSelect(); 21883 } 21884 function r3(e3) { 21885 return e3.text !== void 0 || (console.error("Data object option must have at least have a text value. Check object: " + JSON.stringify(e3)), false); 21886 } 21887 t.Data = n3, t.validateData = function(e3) { 21888 if (!e3) 21889 return console.error("Data must be an array of objects"), false; 21890 for (var t2 = 0, i4 = 0, n4 = e3; i4 < n4.length; i4++) { 21891 var s4 = n4[i4]; 21892 if (s4.hasOwnProperty("label")) { 21893 if (s4.hasOwnProperty("options")) { 21894 var a2 = s4.options; 21895 if (a2) 21896 for (var o2 = 0, l2 = a2; o2 < l2.length; o2++) 21897 r3(l2[o2]) || t2++; 21898 } 21899 } else 21900 r3(s4) || t2++; 21901 } 21902 return t2 === 0; 21903 }, t.validateOption = r3; 21904 }, function(e2, t, i3) { 21905 "use strict"; 21906 t.__esModule = true; 21907 var n3 = i3(3), s3 = i3(4), a2 = i3(5), r3 = i3(1), o2 = i3(0), i3 = (l2.prototype.validate = function(e3) { 21908 e3 = typeof e3.select == "string" ? document.querySelector(e3.select) : e3.select; 21909 if (!e3) 21910 throw new Error("Could not find select element"); 21911 if (e3.tagName !== "SELECT") 21912 throw new Error("Element isnt of type select"); 21913 return e3; 21914 }, l2.prototype.selected = function() { 21915 if (this.config.isMultiple) { 21916 for (var e3 = [], t2 = 0, i4 = s4 = this.data.getSelected(); t2 < i4.length; t2++) { 21917 var n4 = i4[t2]; 21918 e3.push(n4.value); 21919 } 21920 return e3; 21921 } 21922 var s4; 21923 return (s4 = this.data.getSelected()) ? s4.value : ""; 21924 }, l2.prototype.set = function(e3, t2, i4, n4) { 21925 t2 === void 0 && (t2 = "value"), i4 === void 0 && (i4 = true), n4 === void 0 && (n4 = true), this.config.isMultiple && !Array.isArray(e3) ? this.data.addToSelected(e3, t2) : this.data.setSelected(e3, t2), this.select.setValue(), this.data.onDataChange(), this.render(), (i4 = this.config.hideSelectedOption && this.config.isMultiple && this.data.getSelected().length === this.data.data.length ? true : i4) && this.close(); 21926 }, l2.prototype.setSelected = function(e3, t2, i4, n4) { 21927 this.set(e3, t2 = t2 === void 0 ? "value" : t2, i4 = i4 === void 0 ? true : i4, n4 = n4 === void 0 ? true : n4); 21928 }, l2.prototype.setData = function(e3) { 21929 if ((0, r3.validateData)(e3)) { 21930 for (var t2 = JSON.parse(JSON.stringify(e3)), i4 = this.data.getSelected(), n4 = 0; n4 < t2.length; n4++) 21931 t2[n4].value || t2[n4].placeholder || (t2[n4].value = t2[n4].text); 21932 if (this.config.isAjax && i4) 21933 if (this.config.isMultiple) 21934 for (var s4 = 0, a3 = i4.reverse(); s4 < a3.length; s4++) { 21935 var o3 = a3[s4]; 21936 t2.unshift(o3); 21937 } 21938 else { 21939 t2.unshift(i4); 21940 for (n4 = 0; n4 < t2.length; n4++) 21941 t2[n4].placeholder || t2[n4].value !== i4.value || t2[n4].text !== i4.text || t2.splice(n4, 1); 21942 for (var l3 = false, n4 = 0; n4 < t2.length; n4++) 21943 t2[n4].placeholder && (l3 = true); 21944 l3 || t2.unshift({ text: "", placeholder: true }); 21945 } 21946 this.select.create(t2), this.data.parseSelectData(), this.data.setSelectedFromSelect(); 21947 } else 21948 console.error("Validation problem on: #" + this.select.element.id); 21949 }, l2.prototype.addData = function(e3) { 21950 (0, r3.validateData)([e3]) ? (this.data.add(this.data.newOption(e3)), this.select.create(this.data.data), this.data.parseSelectData(), this.data.setSelectedFromSelect(), this.render()) : console.error("Validation problem on: #" + this.select.element.id); 21951 }, l2.prototype.open = function() { 21952 var e3, t2 = this; 21953 this.config.isEnabled && (this.data.contentOpen || this.config.hideSelectedOption && this.config.isMultiple && this.data.getSelected().length === this.data.data.length || (this.beforeOpen && this.beforeOpen(), this.config.isMultiple && this.slim.multiSelected ? this.slim.multiSelected.plus.classList.add("ss-cross") : this.slim.singleSelected && (this.slim.singleSelected.arrowIcon.arrow.classList.remove("arrow-down"), this.slim.singleSelected.arrowIcon.arrow.classList.add("arrow-up")), this.slim[this.config.isMultiple ? "multiSelected" : "singleSelected"].container.classList.add(this.data.contentPosition === "above" ? this.config.openAbove : this.config.openBelow), this.config.addToBody && (e3 = this.slim.container.getBoundingClientRect(), this.slim.content.style.top = e3.top + e3.height + window.scrollY + "px", this.slim.content.style.left = e3.left + window.scrollX + "px", this.slim.content.style.width = e3.width + "px"), this.slim.content.classList.add(this.config.open), this.config.showContent.toLowerCase() === "up" || this.config.showContent.toLowerCase() !== "down" && (0, o2.putContent)(this.slim.content, this.data.contentPosition, this.data.contentOpen) === "above" ? this.moveContentAbove() : this.moveContentBelow(), this.config.isMultiple || (e3 = this.data.getSelected()) && (e3 = e3.id, (e3 = this.slim.list.querySelector('[data-id="' + e3 + '"]')) && (0, o2.ensureElementInView)(this.slim.list, e3)), setTimeout(function() { 21954 t2.data.contentOpen = true, t2.config.searchFocus && t2.slim.search.input.focus(), t2.afterOpen && t2.afterOpen(); 21955 }, this.config.timeoutDelay))); 21956 }, l2.prototype.close = function() { 21957 var e3 = this; 21958 this.data.contentOpen && (this.beforeClose && this.beforeClose(), this.config.isMultiple && this.slim.multiSelected ? (this.slim.multiSelected.container.classList.remove(this.config.openAbove), this.slim.multiSelected.container.classList.remove(this.config.openBelow), this.slim.multiSelected.plus.classList.remove("ss-cross")) : this.slim.singleSelected && (this.slim.singleSelected.container.classList.remove(this.config.openAbove), this.slim.singleSelected.container.classList.remove(this.config.openBelow), this.slim.singleSelected.arrowIcon.arrow.classList.add("arrow-down"), this.slim.singleSelected.arrowIcon.arrow.classList.remove("arrow-up")), this.slim.content.classList.remove(this.config.open), this.data.contentOpen = false, this.search(""), setTimeout(function() { 21959 e3.slim.content.removeAttribute("style"), e3.data.contentPosition = "below", e3.config.isMultiple && e3.slim.multiSelected ? (e3.slim.multiSelected.container.classList.remove(e3.config.openAbove), e3.slim.multiSelected.container.classList.remove(e3.config.openBelow)) : e3.slim.singleSelected && (e3.slim.singleSelected.container.classList.remove(e3.config.openAbove), e3.slim.singleSelected.container.classList.remove(e3.config.openBelow)), e3.slim.search.input.blur(), e3.afterClose && e3.afterClose(); 21960 }, this.config.timeoutDelay)); 21961 }, l2.prototype.moveContentAbove = function() { 21962 var e3 = 0; 21963 this.config.isMultiple && this.slim.multiSelected ? e3 = this.slim.multiSelected.container.offsetHeight : this.slim.singleSelected && (e3 = this.slim.singleSelected.container.offsetHeight); 21964 var t2 = e3 + this.slim.content.offsetHeight - 1; 21965 this.slim.content.style.margin = "-" + t2 + "px 0 0 0", this.slim.content.style.height = t2 - e3 + 1 + "px", this.slim.content.style.transformOrigin = "center bottom", this.data.contentPosition = "above", this.config.isMultiple && this.slim.multiSelected ? (this.slim.multiSelected.container.classList.remove(this.config.openBelow), this.slim.multiSelected.container.classList.add(this.config.openAbove)) : this.slim.singleSelected && (this.slim.singleSelected.container.classList.remove(this.config.openBelow), this.slim.singleSelected.container.classList.add(this.config.openAbove)); 21966 }, l2.prototype.moveContentBelow = function() { 21967 this.data.contentPosition = "below", this.config.isMultiple && this.slim.multiSelected ? (this.slim.multiSelected.container.classList.remove(this.config.openAbove), this.slim.multiSelected.container.classList.add(this.config.openBelow)) : this.slim.singleSelected && (this.slim.singleSelected.container.classList.remove(this.config.openAbove), this.slim.singleSelected.container.classList.add(this.config.openBelow)); 21968 }, l2.prototype.enable = function() { 21969 this.config.isEnabled = true, this.config.isMultiple && this.slim.multiSelected ? this.slim.multiSelected.container.classList.remove(this.config.disabled) : this.slim.singleSelected && this.slim.singleSelected.container.classList.remove(this.config.disabled), this.select.triggerMutationObserver = false, this.select.element.disabled = false, this.slim.search.input.disabled = false, this.select.triggerMutationObserver = true; 21970 }, l2.prototype.disable = function() { 21971 this.config.isEnabled = false, this.config.isMultiple && this.slim.multiSelected ? this.slim.multiSelected.container.classList.add(this.config.disabled) : this.slim.singleSelected && this.slim.singleSelected.container.classList.add(this.config.disabled), this.select.triggerMutationObserver = false, this.select.element.disabled = true, this.slim.search.input.disabled = true, this.select.triggerMutationObserver = true; 21972 }, l2.prototype.search = function(t2) { 21973 var i4; 21974 this.data.searchValue !== t2 && (this.slim.search.input.value = t2, this.config.isAjax ? ((i4 = this).config.isSearching = true, this.render(), this.ajax && this.ajax(t2, function(e3) { 21975 i4.config.isSearching = false, Array.isArray(e3) ? (e3.unshift({ text: "", placeholder: true }), i4.setData(e3), i4.data.search(t2), i4.render()) : typeof e3 == "string" ? i4.slim.options(e3) : i4.render(); 21976 })) : (this.data.search(t2), this.render())); 21977 }, l2.prototype.setSearchText = function(e3) { 21978 this.config.searchText = e3; 21979 }, l2.prototype.render = function() { 21980 this.config.isMultiple ? this.slim.values() : (this.slim.placeholder(), this.slim.deselect()), this.slim.options(); 21981 }, l2.prototype.destroy = function(e3) { 21982 var t2 = (e3 = e3 === void 0 ? null : e3) ? document.querySelector("." + e3 + ".ss-main") : this.slim.container, i4 = e3 ? document.querySelector("[data-ssid=".concat(e3, "]")) : this.select.element; 21983 t2 && i4 && (document.removeEventListener("click", this.documentClick), this.config.showContent === "auto" && window.removeEventListener("scroll", this.windowScroll, false), i4.style.display = "", delete i4.dataset.ssid, i4.slim = null, t2.parentElement && t2.parentElement.removeChild(t2), !this.config.addToBody || (e3 = e3 ? document.querySelector("." + e3 + ".ss-content") : this.slim.content) && document.body.removeChild(e3)); 21984 }, l2); 21985 function l2(e3) { 21986 var t2 = this; 21987 this.ajax = null, this.addable = null, this.beforeOnChange = null, this.onChange = null, this.beforeOpen = null, this.afterOpen = null, this.beforeClose = null, this.afterClose = null, this.windowScroll = (0, o2.debounce)(function(e4) { 21988 t2.data.contentOpen && ((0, o2.putContent)(t2.slim.content, t2.data.contentPosition, t2.data.contentOpen) === "above" ? t2.moveContentAbove() : t2.moveContentBelow()); 21989 }), this.documentClick = function(e4) { 21990 e4.target && !(0, o2.hasClassInTree)(e4.target, t2.config.id) && t2.close(); 21991 }; 21992 var i4 = this.validate(e3); 21993 i4.dataset.ssid && this.destroy(i4.dataset.ssid), e3.ajax && (this.ajax = e3.ajax), e3.addable && (this.addable = e3.addable), this.config = new n3.Config({ select: i4, isAjax: !!e3.ajax, showSearch: e3.showSearch, searchPlaceholder: e3.searchPlaceholder, searchText: e3.searchText, searchingText: e3.searchingText, searchFocus: e3.searchFocus, searchHighlight: e3.searchHighlight, searchFilter: e3.searchFilter, closeOnSelect: e3.closeOnSelect, showContent: e3.showContent, placeholderText: e3.placeholder, allowDeselect: e3.allowDeselect, allowDeselectOption: e3.allowDeselectOption, hideSelectedOption: e3.hideSelectedOption, deselectLabel: e3.deselectLabel, isEnabled: e3.isEnabled, valuesUseText: e3.valuesUseText, showOptionTooltips: e3.showOptionTooltips, selectByGroup: e3.selectByGroup, limit: e3.limit, timeoutDelay: e3.timeoutDelay, addToBody: e3.addToBody }), this.select = new s3.Select({ select: i4, main: this }), this.data = new r3.Data({ main: this }), this.slim = new a2.Slim({ main: this }), this.select.element.parentNode && this.select.element.parentNode.insertBefore(this.slim.container, this.select.element.nextSibling), e3.data ? this.setData(e3.data) : this.render(), document.addEventListener("click", this.documentClick), this.config.showContent === "auto" && window.addEventListener("scroll", this.windowScroll, false), e3.beforeOnChange && (this.beforeOnChange = e3.beforeOnChange), e3.onChange && (this.onChange = e3.onChange), e3.beforeOpen && (this.beforeOpen = e3.beforeOpen), e3.afterOpen && (this.afterOpen = e3.afterOpen), e3.beforeClose && (this.beforeClose = e3.beforeClose), e3.afterClose && (this.afterClose = e3.afterClose), this.config.isEnabled || this.disable(); 21994 } 21995 t.default = i3; 21996 }, function(e2, t, i3) { 21997 "use strict"; 21998 t.__esModule = true, t.Config = void 0; 21999 var n3 = (s3.prototype.searchFilter = function(e3, t2) { 22000 return e3.text.toLowerCase().indexOf(t2.toLowerCase()) !== -1; 22001 }, s3); 22002 function s3(e3) { 22003 this.id = "", this.isMultiple = false, this.isAjax = false, this.isSearching = false, this.showSearch = true, this.searchFocus = true, this.searchHighlight = false, this.closeOnSelect = true, this.showContent = "auto", this.searchPlaceholder = "Search", this.searchText = "No Results", this.searchingText = "Searching...", this.placeholderText = "Select Value", this.allowDeselect = false, this.allowDeselectOption = false, this.hideSelectedOption = false, this.deselectLabel = "x", this.isEnabled = true, this.valuesUseText = false, this.showOptionTooltips = false, this.selectByGroup = false, this.limit = 0, this.timeoutDelay = 200, this.addToBody = false, this.main = "ss-main", this.singleSelected = "ss-single-selected", this.arrow = "ss-arrow", this.multiSelected = "ss-multi-selected", this.add = "ss-add", this.plus = "ss-plus", this.values = "ss-values", this.value = "ss-value", this.valueText = "ss-value-text", this.valueDelete = "ss-value-delete", this.content = "ss-content", this.open = "ss-open", this.openAbove = "ss-open-above", this.openBelow = "ss-open-below", this.search = "ss-search", this.searchHighlighter = "ss-search-highlight", this.addable = "ss-addable", this.list = "ss-list", this.optgroup = "ss-optgroup", this.optgroupLabel = "ss-optgroup-label", this.optgroupLabelSelectable = "ss-optgroup-label-selectable", this.option = "ss-option", this.optionSelected = "ss-option-selected", this.highlighted = "ss-highlighted", this.disabled = "ss-disabled", this.hide = "ss-hide", this.id = "ss-" + Math.floor(1e5 * Math.random()), this.style = e3.select.style.cssText, this.class = e3.select.className.split(" "), this.isMultiple = e3.select.multiple, this.isAjax = e3.isAjax, this.showSearch = e3.showSearch !== false, this.searchFocus = e3.searchFocus !== false, this.searchHighlight = e3.searchHighlight === true, this.closeOnSelect = e3.closeOnSelect !== false, e3.showContent && (this.showContent = e3.showContent), this.isEnabled = e3.isEnabled !== false, e3.searchPlaceholder && (this.searchPlaceholder = e3.searchPlaceholder), e3.searchText && (this.searchText = e3.searchText), e3.searchingText && (this.searchingText = e3.searchingText), e3.placeholderText && (this.placeholderText = e3.placeholderText), this.allowDeselect = e3.allowDeselect === true, this.allowDeselectOption = e3.allowDeselectOption === true, this.hideSelectedOption = e3.hideSelectedOption === true, e3.deselectLabel && (this.deselectLabel = e3.deselectLabel), e3.valuesUseText && (this.valuesUseText = e3.valuesUseText), e3.showOptionTooltips && (this.showOptionTooltips = e3.showOptionTooltips), e3.selectByGroup && (this.selectByGroup = e3.selectByGroup), e3.limit && (this.limit = e3.limit), e3.searchFilter && (this.searchFilter = e3.searchFilter), e3.timeoutDelay != null && (this.timeoutDelay = e3.timeoutDelay), this.addToBody = e3.addToBody === true; 22004 } 22005 t.Config = n3; 22006 }, function(e2, t, i3) { 22007 "use strict"; 22008 t.__esModule = true, t.Select = void 0; 22009 var n3 = i3(0), i3 = (s3.prototype.setValue = function() { 22010 if (this.main.data.getSelected()) { 22011 if (this.main.config.isMultiple) 22012 for (var e3 = this.main.data.getSelected(), t2 = 0, i4 = this.element.options; t2 < i4.length; t2++) { 22013 var n4 = i4[t2]; 22014 n4.selected = false; 22015 for (var s4 = 0, a2 = e3; s4 < a2.length; s4++) 22016 a2[s4].value === n4.value && (n4.selected = true); 22017 } 22018 else { 22019 e3 = this.main.data.getSelected(); 22020 this.element.value = e3 ? e3.value : ""; 22021 } 22022 this.main.data.isOnChangeEnabled = false, this.element.dispatchEvent(new CustomEvent("change", { bubbles: true })), this.main.data.isOnChangeEnabled = true; 22023 } 22024 }, s3.prototype.addAttributes = function() { 22025 this.element.tabIndex = -1, this.element.style.display = "none", this.element.dataset.ssid = this.main.config.id, this.element.setAttribute("aria-hidden", "true"); 22026 }, s3.prototype.addEventListeners = function() { 22027 var t2 = this; 22028 this.element.addEventListener("change", function(e3) { 22029 t2.main.data.setSelectedFromSelect(), t2.main.render(); 22030 }); 22031 }, s3.prototype.addMutationObserver = function() { 22032 var t2 = this; 22033 this.main.config.isAjax || (this.mutationObserver = new MutationObserver(function(e3) { 22034 t2.triggerMutationObserver && (t2.main.data.parseSelectData(), t2.main.data.setSelectedFromSelect(), t2.main.render(), e3.forEach(function(e4) { 22035 e4.attributeName === "class" && t2.main.slim.updateContainerDivClass(t2.main.slim.container); 22036 })); 22037 }), this.observeMutationObserver()); 22038 }, s3.prototype.observeMutationObserver = function() { 22039 this.mutationObserver && this.mutationObserver.observe(this.element, { attributes: true, childList: true, characterData: true }); 22040 }, s3.prototype.disconnectMutationObserver = function() { 22041 this.mutationObserver && this.mutationObserver.disconnect(); 22042 }, s3.prototype.create = function(e3) { 22043 this.element.innerHTML = ""; 22044 for (var t2 = 0, i4 = e3; t2 < i4.length; t2++) { 22045 var n4 = i4[t2]; 22046 if (n4.hasOwnProperty("options")) { 22047 var s4 = n4, a2 = document.createElement("optgroup"); 22048 if (a2.label = s4.label, s4.options) 22049 for (var o2 = 0, l2 = s4.options; o2 < l2.length; o2++) { 22050 var r3 = l2[o2]; 22051 a2.appendChild(this.createOption(r3)); 22052 } 22053 this.element.appendChild(a2); 22054 } else 22055 this.element.appendChild(this.createOption(n4)); 22056 } 22057 }, s3.prototype.createOption = function(t2) { 22058 var i4 = document.createElement("option"); 22059 return i4.value = t2.value !== "" ? t2.value : t2.text, i4.innerHTML = t2.innerHTML || t2.text, t2.selected && (i4.selected = t2.selected), t2.display === false && (i4.style.display = "none"), t2.disabled && (i4.disabled = true), t2.placeholder && i4.setAttribute("data-placeholder", "true"), t2.mandatory && i4.setAttribute("data-mandatory", "true"), t2.class && t2.class.split(" ").forEach(function(e3) { 22060 i4.classList.add(e3); 22061 }), t2.data && typeof t2.data == "object" && Object.keys(t2.data).forEach(function(e3) { 22062 i4.setAttribute("data-" + (0, n3.kebabCase)(e3), t2.data[e3]); 22063 }), i4; 22064 }, s3); 22065 function s3(e3) { 22066 this.triggerMutationObserver = true, this.element = e3.select, this.main = e3.main, this.element.disabled && (this.main.config.isEnabled = false), this.addAttributes(), this.addEventListeners(), this.mutationObserver = null, this.addMutationObserver(), this.element.slim = e3.main; 22067 } 22068 t.Select = i3; 22069 }, function(e2, t, i3) { 22070 "use strict"; 22071 t.__esModule = true, t.Slim = void 0; 22072 var n3 = i3(0), o2 = i3(1), i3 = (s3.prototype.containerDiv = function() { 22073 var e3 = document.createElement("div"); 22074 return e3.style.cssText = this.main.config.style, this.updateContainerDivClass(e3), e3; 22075 }, s3.prototype.updateContainerDivClass = function(e3) { 22076 this.main.config.class = this.main.select.element.className.split(" "), e3.className = "", e3.classList.add(this.main.config.id), e3.classList.add(this.main.config.main); 22077 for (var t2 = 0, i4 = this.main.config.class; t2 < i4.length; t2++) { 22078 var n4 = i4[t2]; 22079 n4.trim() !== "" && e3.classList.add(n4); 22080 } 22081 }, s3.prototype.singleSelectedDiv = function() { 22082 var t2 = this, e3 = document.createElement("div"); 22083 e3.classList.add(this.main.config.singleSelected); 22084 var i4 = document.createElement("span"); 22085 i4.classList.add("placeholder"), e3.appendChild(i4); 22086 var n4 = document.createElement("span"); 22087 n4.innerHTML = this.main.config.deselectLabel, n4.classList.add("ss-deselect"), n4.onclick = function(e4) { 22088 e4.stopPropagation(), t2.main.config.isEnabled && t2.main.set(""); 22089 }, e3.appendChild(n4); 22090 var s4 = document.createElement("span"); 22091 s4.classList.add(this.main.config.arrow); 22092 var a2 = document.createElement("span"); 22093 return a2.classList.add("arrow-down"), s4.appendChild(a2), e3.appendChild(s4), e3.onclick = function() { 22094 t2.main.config.isEnabled && (t2.main.data.contentOpen ? t2.main.close() : t2.main.open()); 22095 }, { container: e3, placeholder: i4, deselect: n4, arrowIcon: { container: s4, arrow: a2 } }; 22096 }, s3.prototype.placeholder = function() { 22097 var e3, t2 = this.main.data.getSelected(); 22098 t2 === null || t2 && t2.placeholder ? ((e3 = document.createElement("span")).classList.add(this.main.config.disabled), e3.innerHTML = this.main.config.placeholderText, this.singleSelected && (this.singleSelected.placeholder.innerHTML = e3.outerHTML)) : (e3 = "", t2 && (e3 = t2.innerHTML && this.main.config.valuesUseText !== true ? t2.innerHTML : t2.text), this.singleSelected && (this.singleSelected.placeholder.innerHTML = t2 ? e3 : "")); 22099 }, s3.prototype.deselect = function() { 22100 this.singleSelected && (!this.main.config.allowDeselect || this.main.selected() === "" ? this.singleSelected.deselect.classList.add("ss-hide") : this.singleSelected.deselect.classList.remove("ss-hide")); 22101 }, s3.prototype.multiSelectedDiv = function() { 22102 var t2 = this, e3 = document.createElement("div"); 22103 e3.classList.add(this.main.config.multiSelected); 22104 var i4 = document.createElement("div"); 22105 i4.classList.add(this.main.config.values), e3.appendChild(i4); 22106 var n4 = document.createElement("div"); 22107 n4.classList.add(this.main.config.add); 22108 var s4 = document.createElement("span"); 22109 return s4.classList.add(this.main.config.plus), s4.onclick = function(e4) { 22110 t2.main.data.contentOpen && (t2.main.close(), e4.stopPropagation()); 22111 }, n4.appendChild(s4), e3.appendChild(n4), e3.onclick = function(e4) { 22112 t2.main.config.isEnabled && (e4.target.classList.contains(t2.main.config.valueDelete) || (t2.main.data.contentOpen ? t2.main.close() : t2.main.open())); 22113 }, { container: e3, values: i4, add: n4, plus: s4 }; 22114 }, s3.prototype.values = function() { 22115 if (this.multiSelected) { 22116 for (var e3 = this.multiSelected.values.childNodes, t2 = this.main.data.getSelected(), i4 = [], n4 = 0, s4 = e3; n4 < s4.length; n4++) { 22117 for (var a2 = s4[n4], o3 = true, l2 = 0, r3 = t2; l2 < r3.length; l2++) { 22118 var c = r3[l2]; 22119 String(c.id) === String(a2.dataset.id) && (o3 = false); 22120 } 22121 o3 && i4.push(a2); 22122 } 22123 for (var d = 0, h2 = i4; d < h2.length; d++) { 22124 var u = h2[d]; 22125 u.classList.add("ss-out"), this.multiSelected.values.removeChild(u); 22126 } 22127 for (var p, e3 = this.multiSelected.values.childNodes, c = 0; c < t2.length; c++) { 22128 o3 = false; 22129 for (var m = 0, f = e3; m < f.length; m++) { 22130 a2 = f[m]; 22131 String(t2[c].id) === String(a2.dataset.id) && (o3 = true); 22132 } 22133 o3 || (e3.length !== 0 && HTMLElement.prototype.insertAdjacentElement ? c === 0 ? this.multiSelected.values.insertBefore(this.valueDiv(t2[c]), e3[c]) : e3[c - 1].insertAdjacentElement("afterend", this.valueDiv(t2[c])) : this.multiSelected.values.appendChild(this.valueDiv(t2[c]))); 22134 } 22135 t2.length === 0 && ((p = document.createElement("span")).classList.add(this.main.config.disabled), p.innerHTML = this.main.config.placeholderText, this.multiSelected.values.innerHTML = p.outerHTML); 22136 } 22137 }, s3.prototype.valueDiv = function(s4) { 22138 var a2 = this, e3 = document.createElement("div"); 22139 e3.classList.add(this.main.config.value), e3.dataset.id = s4.id; 22140 var t2 = document.createElement("span"); 22141 return t2.classList.add(this.main.config.valueText), t2.innerHTML = s4.innerHTML && this.main.config.valuesUseText !== true ? s4.innerHTML : s4.text, e3.appendChild(t2), s4.mandatory || ((t2 = document.createElement("span")).classList.add(this.main.config.valueDelete), t2.innerHTML = this.main.config.deselectLabel, t2.onclick = function(e4) { 22142 e4.preventDefault(), e4.stopPropagation(); 22143 var t3 = false; 22144 if (a2.main.beforeOnChange || (t3 = true), a2.main.beforeOnChange) { 22145 for (var e4 = a2.main.data.getSelected(), i4 = JSON.parse(JSON.stringify(e4)), n4 = 0; n4 < i4.length; n4++) 22146 i4[n4].id === s4.id && i4.splice(n4, 1); 22147 a2.main.beforeOnChange(i4) !== false && (t3 = true); 22148 } 22149 t3 && (a2.main.data.removeFromSelected(s4.id, "id"), a2.main.render(), a2.main.select.setValue(), a2.main.data.onDataChange()); 22150 }, e3.appendChild(t2)), e3; 22151 }, s3.prototype.contentDiv = function() { 22152 var e3 = document.createElement("div"); 22153 return e3.classList.add(this.main.config.content), e3; 22154 }, s3.prototype.searchDiv = function() { 22155 var n4 = this, e3 = document.createElement("div"), s4 = document.createElement("input"), a2 = document.createElement("div"); 22156 e3.classList.add(this.main.config.search); 22157 var t2 = { container: e3, input: s4 }; 22158 return this.main.config.showSearch || (e3.classList.add(this.main.config.hide), s4.readOnly = true), s4.type = "search", s4.placeholder = this.main.config.searchPlaceholder, s4.tabIndex = 0, s4.setAttribute("aria-label", this.main.config.searchPlaceholder), s4.setAttribute("autocapitalize", "off"), s4.setAttribute("autocomplete", "off"), s4.setAttribute("autocorrect", "off"), s4.onclick = function(e4) { 22159 setTimeout(function() { 22160 e4.target.value === "" && n4.main.search(""); 22161 }, 10); 22162 }, s4.onkeydown = function(e4) { 22163 e4.key === "ArrowUp" ? (n4.main.open(), n4.highlightUp(), e4.preventDefault()) : e4.key === "ArrowDown" ? (n4.main.open(), n4.highlightDown(), e4.preventDefault()) : e4.key === "Tab" ? n4.main.data.contentOpen ? n4.main.close() : setTimeout(function() { 22164 n4.main.close(); 22165 }, n4.main.config.timeoutDelay) : e4.key === "Enter" && e4.preventDefault(); 22166 }, s4.onkeyup = function(e4) { 22167 var t3 = e4.target; 22168 if (e4.key === "Enter") { 22169 if (n4.main.addable && e4.ctrlKey) 22170 return a2.click(), e4.preventDefault(), void e4.stopPropagation(); 22171 var i4 = n4.list.querySelector("." + n4.main.config.highlighted); 22172 i4 && i4.click(); 22173 } else 22174 e4.key === "ArrowUp" || e4.key === "ArrowDown" || (e4.key === "Escape" ? n4.main.close() : n4.main.config.showSearch && n4.main.data.contentOpen ? n4.main.search(t3.value) : s4.value = ""); 22175 e4.preventDefault(), e4.stopPropagation(); 22176 }, s4.onfocus = function() { 22177 n4.main.open(); 22178 }, e3.appendChild(s4), this.main.addable && (a2.classList.add(this.main.config.addable), a2.innerHTML = "+", a2.onclick = function(e4) { 22179 var t3; 22180 n4.main.addable && (e4.preventDefault(), e4.stopPropagation(), (e4 = n4.search.input.value).trim() !== "" ? (e4 = n4.main.addable(e4), t3 = "", e4 && (typeof e4 == "object" ? (0, o2.validateOption)(e4) && (n4.main.addData(e4), t3 = e4.value || e4.text) : (n4.main.addData(n4.main.data.newOption({ text: e4, value: e4 })), t3 = e4), n4.main.search(""), setTimeout(function() { 22181 n4.main.set(t3, "value", false, false); 22182 }, 100), n4.main.config.closeOnSelect && setTimeout(function() { 22183 n4.main.close(); 22184 }, 100))) : n4.search.input.focus()); 22185 }, e3.appendChild(a2), t2.addable = a2), t2; 22186 }, s3.prototype.highlightUp = function() { 22187 var e3 = this.list.querySelector("." + this.main.config.highlighted), t2 = null; 22188 if (e3) 22189 for (t2 = e3.previousSibling; t2 !== null && t2.classList.contains(this.main.config.disabled); ) 22190 t2 = t2.previousSibling; 22191 else 22192 var i4 = this.list.querySelectorAll("." + this.main.config.option + ":not(." + this.main.config.disabled + ")"), t2 = i4[i4.length - 1]; 22193 (t2 = t2 && t2.classList.contains(this.main.config.optgroupLabel) ? null : t2) !== null || (i4 = e3.parentNode).classList.contains(this.main.config.optgroup) && (!i4.previousSibling || (i4 = i4.previousSibling.querySelectorAll("." + this.main.config.option + ":not(." + this.main.config.disabled + ")")).length && (t2 = i4[i4.length - 1])), t2 && (e3 && e3.classList.remove(this.main.config.highlighted), t2.classList.add(this.main.config.highlighted), (0, n3.ensureElementInView)(this.list, t2)); 22194 }, s3.prototype.highlightDown = function() { 22195 var e3, t2 = this.list.querySelector("." + this.main.config.highlighted), i4 = null; 22196 if (t2) 22197 for (i4 = t2.nextSibling; i4 !== null && i4.classList.contains(this.main.config.disabled); ) 22198 i4 = i4.nextSibling; 22199 else 22200 i4 = this.list.querySelector("." + this.main.config.option + ":not(." + this.main.config.disabled + ")"); 22201 i4 !== null || t2 === null || (e3 = t2.parentNode).classList.contains(this.main.config.optgroup) && e3.nextSibling && (i4 = e3.nextSibling.querySelector("." + this.main.config.option + ":not(." + this.main.config.disabled + ")")), i4 && (t2 && t2.classList.remove(this.main.config.highlighted), i4.classList.add(this.main.config.highlighted), (0, n3.ensureElementInView)(this.list, i4)); 22202 }, s3.prototype.listDiv = function() { 22203 var e3 = document.createElement("div"); 22204 return e3.classList.add(this.main.config.list), e3.setAttribute("role", "listbox"), e3; 22205 }, s3.prototype.options = function(e3) { 22206 e3 === void 0 && (e3 = ""); 22207 var t2 = this.main.data.filtered || this.main.data.data; 22208 if ((this.list.innerHTML = "") !== e3) 22209 return (i4 = document.createElement("div")).classList.add(this.main.config.option), i4.classList.add(this.main.config.disabled), i4.innerHTML = e3, void this.list.appendChild(i4); 22210 if (this.main.config.isAjax && this.main.config.isSearching) 22211 return (i4 = document.createElement("div")).classList.add(this.main.config.option), i4.classList.add(this.main.config.disabled), i4.innerHTML = this.main.config.searchingText, void this.list.appendChild(i4); 22212 if (t2.length === 0) { 22213 var i4 = document.createElement("div"); 22214 return i4.classList.add(this.main.config.option), i4.classList.add(this.main.config.disabled), i4.innerHTML = this.main.config.searchText, void this.list.appendChild(i4); 22215 } 22216 for (var r3 = this, n4 = 0, s4 = t2; n4 < s4.length; n4++) 22217 !function(e4) { 22218 if (e4.hasOwnProperty("label")) { 22219 var t3 = e4, s5 = document.createElement("div"); 22220 s5.classList.add(r3.main.config.optgroup); 22221 var i5 = document.createElement("div"); 22222 i5.classList.add(r3.main.config.optgroupLabel), r3.main.config.selectByGroup && r3.main.config.isMultiple && i5.classList.add(r3.main.config.optgroupLabelSelectable), i5.innerHTML = t3.label, s5.appendChild(i5); 22223 t3 = t3.options; 22224 if (t3) { 22225 for (var a2, n5 = 0, o3 = t3; n5 < o3.length; n5++) { 22226 var l2 = o3[n5]; 22227 s5.appendChild(r3.option(l2)); 22228 } 22229 r3.main.config.selectByGroup && r3.main.config.isMultiple && (a2 = r3, i5.addEventListener("click", function(e5) { 22230 e5.preventDefault(), e5.stopPropagation(); 22231 for (var t4 = 0, i6 = s5.children; t4 < i6.length; t4++) { 22232 var n6 = i6[t4]; 22233 n6.className.indexOf(a2.main.config.option) !== -1 && n6.click(); 22234 } 22235 })); 22236 } 22237 r3.list.appendChild(s5); 22238 } else 22239 r3.list.appendChild(r3.option(e4)); 22240 }(s4[n4]); 22241 }, s3.prototype.option = function(o3) { 22242 if (o3.placeholder) { 22243 var e3 = document.createElement("div"); 22244 return e3.classList.add(this.main.config.option), e3.classList.add(this.main.config.hide), e3; 22245 } 22246 var t2 = document.createElement("div"); 22247 t2.classList.add(this.main.config.option), t2.setAttribute("role", "option"), o3.class && o3.class.split(" ").forEach(function(e4) { 22248 t2.classList.add(e4); 22249 }), o3.style && (t2.style.cssText = o3.style); 22250 var l2 = this.main.data.getSelected(); 22251 t2.dataset.id = o3.id, this.main.config.searchHighlight && this.main.slim && o3.innerHTML && this.main.slim.search.input.value.trim() !== "" ? t2.innerHTML = (0, n3.highlight)(o3.innerHTML, this.main.slim.search.input.value, this.main.config.searchHighlighter) : o3.innerHTML && (t2.innerHTML = o3.innerHTML), this.main.config.showOptionTooltips && t2.textContent && t2.setAttribute("title", t2.textContent); 22252 var r3 = this; 22253 t2.addEventListener("click", function(e4) { 22254 e4.preventDefault(), e4.stopPropagation(); 22255 var t3 = this.dataset.id; 22256 if (o3.selected === true && r3.main.config.allowDeselectOption) { 22257 var i4 = false; 22258 if (r3.main.beforeOnChange && r3.main.config.isMultiple || (i4 = true), r3.main.beforeOnChange && r3.main.config.isMultiple) { 22259 for (var n4 = r3.main.data.getSelected(), s4 = JSON.parse(JSON.stringify(n4)), a2 = 0; a2 < s4.length; a2++) 22260 s4[a2].id === t3 && s4.splice(a2, 1); 22261 r3.main.beforeOnChange(s4) !== false && (i4 = true); 22262 } 22263 i4 && (r3.main.config.isMultiple ? (r3.main.data.removeFromSelected(t3, "id"), r3.main.render(), r3.main.select.setValue(), r3.main.data.onDataChange()) : r3.main.set("")); 22264 } else 22265 o3.disabled || o3.selected || r3.main.config.limit && Array.isArray(l2) && r3.main.config.limit <= l2.length || (r3.main.beforeOnChange ? (n4 = void 0, (i4 = JSON.parse(JSON.stringify(r3.main.data.getObjectFromData(t3)))).selected = true, r3.main.config.isMultiple ? (n4 = JSON.parse(JSON.stringify(l2))).push(i4) : n4 = JSON.parse(JSON.stringify(i4)), r3.main.beforeOnChange(n4) !== false && r3.main.set(t3, "id", r3.main.config.closeOnSelect)) : r3.main.set(t3, "id", r3.main.config.closeOnSelect)); 22266 }); 22267 e3 = l2 && (0, n3.isValueInArrayOfObjects)(l2, "id", o3.id); 22268 return (o3.disabled || e3) && (t2.onclick = null, r3.main.config.allowDeselectOption || t2.classList.add(this.main.config.disabled), r3.main.config.hideSelectedOption && t2.classList.add(this.main.config.hide)), e3 ? t2.classList.add(this.main.config.optionSelected) : t2.classList.remove(this.main.config.optionSelected), t2; 22269 }, s3); 22270 function s3(e3) { 22271 this.main = e3.main, this.container = this.containerDiv(), this.content = this.contentDiv(), this.search = this.searchDiv(), this.list = this.listDiv(), this.options(), this.singleSelected = null, this.multiSelected = null, this.main.config.isMultiple ? (this.multiSelected = this.multiSelectedDiv(), this.multiSelected && this.container.appendChild(this.multiSelected.container)) : (this.singleSelected = this.singleSelectedDiv(), this.container.appendChild(this.singleSelected.container)), this.main.config.addToBody ? (this.content.classList.add(this.main.config.id), document.body.appendChild(this.content)) : this.container.appendChild(this.content), this.content.appendChild(this.search.container), this.content.appendChild(this.list); 22272 } 22273 t.Slim = i3; 22274 }], s2.c = n2, s2.d = function(e2, t, i3) { 22275 s2.o(e2, t) || Object.defineProperty(e2, t, { enumerable: true, get: i3 }); 22276 }, s2.r = function(e2) { 22277 typeof Symbol != "undefined" && Symbol.toStringTag && Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e2, "__esModule", { value: true }); 22278 }, s2.t = function(t, e2) { 22279 if (1 & e2 && (t = s2(t)), 8 & e2) 22280 return t; 22281 if (4 & e2 && typeof t == "object" && t && t.__esModule) 22282 return t; 22283 var i3 = /* @__PURE__ */ Object.create(null); 22284 if (s2.r(i3), Object.defineProperty(i3, "default", { enumerable: true, value: t }), 2 & e2 && typeof t != "string") 22285 for (var n3 in t) 22286 s2.d(i3, n3, function(e3) { 22287 return t[e3]; 22288 }.bind(null, n3)); 22289 return i3; 22290 }, s2.n = function(e2) { 22291 var t = e2 && e2.__esModule ? function() { 22292 return e2.default; 22293 } : function() { 22294 return e2; 22295 }; 22296 return s2.d(t, "a", t), t; 22297 }, s2.o = function(e2, t) { 22298 return Object.prototype.hasOwnProperty.call(e2, t); 22299 }, s2.p = "", s2(s2.s = 2).default; 22300 function s2(e2) { 22301 if (n2[e2]) 22302 return n2[e2].exports; 22303 var t = n2[e2] = { i: e2, l: false, exports: {} }; 22304 return i2[e2].call(t.exports, t, t.exports, s2), t.l = true, t.exports; 22305 } 22306 var i2, n2; 22307 }); 22308 var slimselect_min_default = exports.SlimSelect; 22309 22310
22310// controllers/select_controller.js 22311 var select_controller_default = class extends Controller { 22312 connect() { 22313 const options2 = { select: this.element }; 22314 if (this.hasAjaxUrlValue) { 22315 options2.ajax = (search, callback) => { 22316 fetch(`${this.ajaxUrlValue}?q=${encodeURIComponent(search)}`, { 22317 headers: { Accept: "application/json" } 22318 }).then((response) => response.json()).then((data) => callback(data)).catch(() => callback("Error fetching results")); 22319 }; 22320 } 22321 this.select = new slimselect_min_default(options2); 22322 this.element._slimSelect = this.select; 22323 } 22324 disconnect() { 22325 this.select.destroy(); 22326 this.element._slimSelect = null; 22327 } 22328 }; 22329 __publicField(select_controller_default, "values", { ajaxUrl: String }); 22330 22331
22331// controllers/stripe_controller.js 22332 var stripe_controller_exports = {}; 22333 __export(stripe_controller_exports, { 22334 default: () => stripe_controller_default 22335 }); 22336 var stripe_controller_default = class extends Controller { 22337 connect() { 22338 let stripeMeta = document.querySelector('meta[name="stripe-key"]'); 22339 if (stripeMeta === null) { 22340 return; 22341 } 22342 let stripeKey = stripeMeta.getAttribute("content"); 22343 this.stripe = Stripe(stripeKey); 22344 let elements3 = this.stripe.elements(); 22345 this.setup_intent = this.data.get("setup-intent"); 22346 this.payment_intent = this.data.get("payment-intent"); 22347 this.card = elements3.create("card", { 22348 style: { 22349 base: { 22350 fontFamily: 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif', 22351 fontSize: "16px", 22352 fontSmoothing: "antialiased" 22353 } 22354 } 22355 }); 22356 this.card.mount(this.cardTarget); 22357 this.card.addEventListener("change", this.changed.bind(this)); 22358 } 22359 changed(event) { 22360 if (event.error) { 22361 this.errorTarget.textContent = event.error.message; 22362 } else { 22363 this.errorTarget.textContent = ""; 22364 } 22365 } 22366 submit(event) { 22367 event.preventDefault(); 22368 Rails.disableElement(this.formTarget); 22369 if (this.nameTarget.value == "") { 22370 this.showError("Name on card is required."); 22371 return; 22372 } 22373 if (this.payment_intent) { 22374 this.handleCardPayment(); 22375 } else if (this.setup_intent) { 22376 this.setupNewCard(); 22377 } else { 22378 this.stripe.createPaymentMethod({ 22379 type: "card", 22380 card: this.card, 22381 billing_details: { 22382 name: this.nameTarget.value 22383 } 22384 }).then((result) => this.handlePaymentMethod(result.paymentMethod.id)); 22385 } 22386 } 22387 setupNewCard() { 22388 let data = { 22389 payment_method: { 22390 card: this.card, 22391 billing_details: { 22392 name: this.nameTarget.value 22393 } 22394 } 22395 }; 22396 this.stripe.confirmCardSetup(this.setup_intent, data).then((result) => { 22397 if (result.error) { 22398 this.showError(result.error.message); 22399 } else { 22400 this.handlePaymentMethod(result.setupIntent.payment_method); 22401 } 22402 }); 22403 } 22404 handlePaymentMethod(payment_method_id) { 22405 this.addHiddenField("processor", "stripe"); 22406 this.addHiddenField("payment_method_token", payment_method_id); 22407 this.formTarget.submit(); 22408 } 22409 addHiddenField(name, value) { 22410 let hiddenInput = document.createElement("input"); 22411 hiddenInput.setAttribute("type", "hidden"); 22412 hiddenInput.setAttribute("name", name); 22413 hiddenInput.setAttribute("value", value); 22414 this.formTarget.appendChild(hiddenInput); 22415 } 22416 handleCardPayment() { 22417 this.stripe.confirmCardPayment(this.payment_intent).then((result) => { 22418 if (result.error) { 22419 this.showError(result.error.message); 22420 } else if (result.paymentIntent && result.paymentIntent.status === "succeeded") { 22421 turbo_es2017_esm_exports.clearCache(); 22422 turbo_es2017_esm_exports.visit("/"); 22423 } 22424 }); 22425 } 22426 showError(message) { 22427 this.errorTarget.textContent = message; 22428 setTimeout(() => { 22429 Rails.enableElement(this.formTarget); 22430 }, 100); 22431 } 22432 }; 22433 __publicField(stripe_controller_default, "targets", ["card", "name", "error", "form"]); 22434 22435
22435// controllers/tooltip_controller.js 22436 var tooltip_controller_exports = {}; 22437 __export(tooltip_controller_exports, { 22438 default: () => tooltip_controller_default 22439 }); 22440 var tooltip_controller_default = class extends Controller { 22441 connect() { 22442 let options2 = {}; 22443 if (this.hasContentValue) { 22444 options2["content"] = this.contentValue; 22445 } 22446 this.tippy = tippy_esm_default(this.element, options2); 22447 } 22448 disconnect() { 22449 this.tippy.destroy(); 22450 } 22451 }; 22452 __publicField(tooltip_controller_default, "values", { 22453 content: String 22454 }); 22455 22456
22456// controllers/trustpilot_controller.js 22457 var trustpilot_controller_exports = {}; 22458 __export(trustpilot_controller_exports, { 22459 default: () => trustpilot_controller_default 22460 }); 22461 var trustpilot_controller_default = class extends Controller { 22462 connect() { 22463 let dispatched = false; 22464 const fetchAndDispatch = async () => { 22465 if (dispatched) 22466 return; 22467 dispatched = true; 22468 try { 22469 const response = await fetch(this.payloadUrlValue); 22470 if (!response.ok) 22471 return; 22472 const payload = await response.json(); 22473 this.element.dispatchEvent(new CustomEvent("customerDataResponse", { detail: payload })); 22474 } catch (_e) { 22475 } 22476 }; 22477 this.element.onReady = fetchAndDispatch; 22478 fetchAndDispatch(); 22479 } 22480 }; 22481 __publicField(trustpilot_controller_default, "values", { payloadUrl: String }); 22482 22483
22483// controllers/turbo_native/sign_out_controller.js 22484 var sign_out_controller_exports = {}; 22485 __export(sign_out_controller_exports, { 22486 default: () => sign_out_controller_default 22487 }); 22488 var sign_out_controller_default = class extends Controller { 22489 signOut(event) { 22490 if (this._isTurboNativeApp) { 22491 event.preventDefault(); 22492 event.stopImmediatePropagation(); 22493 window.TurboNativeBridge.postMessage("signOut"); 22494 } 22495 } 22496 get _isTurboNativeApp() { 22497 return navigator.userAgent.indexOf("Turbo Native") !== -1; 22498 } 22499 }; 22500 22501
22501// controllers/update_form_controller.js 22502 var update_form_controller_exports = {}; 22503 __export(update_form_controller_exports, { 22504 default: () => update_form_controller_default 22505 }); 22506 var update_form_controller_default = class extends Controller { 22507 connect() { 22508 var url = window.location.href; 22509 if (url.includes("edit")) { 22510 var submit_button = document.querySelector("#content_form button"); 22511 submit_button.disabled = true; 22512 var input_fields = document.querySelectorAll("#content_form input"); 22513 input_fields.forEach(function(item, index) { 22514 item.addEventListener("input", () => { 22515 submit_button.disabled = false; 22516 }); 22517 }); 22518 var text_area = document.querySelectorAll("#content_form textarea"); 22519 text_area.forEach(function(item, index) { 22520 item.addEventListener("input", () => { 22521 submit_button.disabled = false; 22522 }); 22523 }); 22524 var select_fields = document.querySelectorAll("#content_form select"); 22525 select_fields.forEach(function(item, index) { 22526 item.addEventListener("change", () => { 22527 submit_button.disabled = false; 22528 }); 22529 }); 22530 } 22531 } 22532 }; 22533 22534
22534// controllers/user_group_controller.js 22535 var user_group_controller_exports = {}; 22536 __export(user_group_controller_exports, { 22537 default: () => user_group_controller_default 22538 }); 22539 var user_group_controller_default = class extends Controller { 22540 connect() { 22541 } 22542 initialize() { 22543 this.disableSessionInput(); 22544 } 22545 disableSessionInput() { 22546 const checkbox = document.getElementById("user_group_unlimited_access"); 22547 const sessionLimitInput = document.getElementById("user_group_session_limit"); 22548 checkbox.addEventListener("change", function() { 22549 if (this.checked) { 22550 sessionLimitInput.style.display = "none"; 22551 } else { 22552 sessionLimitInput.style.display = "block"; 22553 } 22554 }); 22555 if (checkbox.checked) { 22556 sessionLimitInput.style.display = "none"; 22557 } else { 22558 sessionLimitInput.style.display = "block"; 22559 } 22560 } 22561 }; 22562 22563
22563// controllers/user_group_pricing_controller.js 22564 var user_group_pricing_controller_exports = {}; 22565 __export(user_group_pricing_controller_exports, { 22566 default: () => user_group_pricing_controller_default 22567 }); 22568 var user_group_pricing_controller_default = class extends Controller { 22569 connect() { 22570 this.applyFilters = this.applyFilters.bind(this); 22571 } 22572 togglePanel(event) { 22573 event?.preventDefault(); 22574 if (!this.hasPanelTarget || !this.hasToggleButtonTarget) 22575 return; 22576 const hidden = this.panelTarget.classList.toggle("hidden"); 22577 this.toggleButtonTarget.textContent = hidden ? "View Assigned Product" : "Hide Prices"; 22578 } 22579 applyFilters() { 22580 const query = this.hasSearchInputTarget ? this.searchInputTarget.value.toLowerCase().trim() : ""; 22581 const type = this.hasTypeSelectTarget ? this.typeSelectTarget.value.toLowerCase() : ""; 22582 this.rowTargets.forEach((row) => { 22583 const haystack = row.dataset.search || ""; 22584 const rowType = (row.dataset.priceType || "").toLowerCase(); 22585 const matchesQuery = !query || haystack.includes(query); 22586 const matchesType = !type || rowType === type; 22587 row.classList.toggle("hidden", !(matchesQuery && matchesType)); 22588 row.classList.add("ugp-price-row"); 22589 }); 22590 this.groupTargets.forEach((group) => { 22591 const anyVisible = Array.from(group.querySelectorAll("[data-user-group-pricing-target='row']")).some((row) => !row.classList.contains("hidden")); 22592 group.classList.toggle("hidden", !anyVisible); 22593 }); 22594 } 22595 }; 22596 __publicField(user_group_pricing_controller_default, "targets", ["toggleButton", "panel", "searchInput", "typeSelect", "row", "group"]); 22597 22598
22598// controllers/users_controller.js 22599 var users_controller_exports = {}; 22600 __export(users_controller_exports, { 22601 default: () => users_controller_default 22602 }); 22603 var users_controller_default = class extends Controller { 22604 connect() { 22605 } 22606 brandChanged(event) { 22607 this.loadUserGroups(event); 22608 } 22609 loadUserGroups(event) { 22610 let brand_id = event.target.value; 22611 if (brand_id == null) { 22612 return; 22613 } 22614 fetch(`/user_groups?brand_id=${brand_id}`).then((response) => response.json()).then((data) => { 22615 document.getElementById("user_group_ids").innerHTML = ""; 22616 data.forEach((group) => { 22617 const option = document.createElement("option"); 22618 option.value = group.id; 22619 option.textContent = group.title; 22620 if (group.title === "BT Paid Customer (Limited)") { 22621 option.selected = true; 22622 } 22623 document.getElementById("user_group_ids").appendChild(option); 22624 }); 22625 }); 22626 } 22627 }; 22628 __publicField(users_controller_default, "targets", ["userGroupSelect"]); 22629 22630 // rails:/app/app/javascript/controllers/**/*_controller.js 22631 var modules = [{ name: "accounts", module: accounts_controller_exports, filename: "./accounts_controller.js" }, { name: "admin-nav", module: admin_nav_controller_exports, filename: "./admin_nav_controller.js" }, { name: "braintree", module: braintree_controller_exports, filename: "./braintree_controller.js" }, { name: "bulk", module: bulk_controller_exports, filename: "./bulk_controller.js" }, { name: "cart-popup", module: cart_popup_controller_exports, filename: "./cart_popup_controller.js" }, { name: "category-filter", module: category_filter_controller_exports, filename: "./category_filter_controller.js" }, { name: "clipboard", module: clipboard_controller_exports, filename: "./clipboard_controller.js" }, { name: "disable", module: disable_controller_exports, filename: "./disable_controller.js" }, { name: "expandable-section", module: expandable_section_controller_exports, filename: "./expandable_section_controller.js" }, { name: "form", module: form_controller_exports, filename: "./form_controller.js" }, { name: "group-session-form", module: group_session_form_controller_exports, filename: "./group_session_form_controller.js" }, { name: "group-session-realtime", module: group_session_realtime_controller_exports, filename: "./group_session_realtime_controller.js" }, { name: "marketing-materials-admin", module: marketing_materials_admin_controller_exports, filename: "./marketing_materials_admin_controller.js" }, { name: "marketing-resource-search", module: marketing_resource_search_controller_exports, filename: "./marketing_resource_search_controller.js" }, { name: "mentions", module: mentions_controller_exports, filename: "./mentions_controller.js" }, { name: "notifications", module: notifications_controller_exports, filename: "./notifications_controller.js" }, { name: "paddle", module: paddle_controller_exports, filename: "./paddle_controller.js" }, { name: "partner-add-to-cart", module: partner_add_to_cart_controller_exports, filename: "./partner_add_to_cart_controller.js" }, { name: "partner-cart-updater", module: partner_cart_updater_controller_exports, filename: "./partner_cart_updater_controller.js" }, { name: "partner-price-form", module: partner_price_form_controller_exports, filename: "./partner_price_form_controller.js" }, { name: "partner-products-catalog", module: partner_products_catalog_controller_exports, filename: "./partner_products_catalog_controller.js" }, { name: "partner-resource-file", module: partner_resource_file_controller_exports, filename: "./partner_resource_file_controller.js" }, { name: "partner-resource-preview", module: partner_resource_preview_controller_exports, filename: "./partner_resource_preview_controller.js" }, { name: "partner-resources-search", module: partner_resources_search_controller_exports, filename: "./partner_resources_search_controller.js" }, { name: "partner-sidebar", module: partner_sidebar_controller_exports, filename: "./partner_sidebar_controller.js" }, { name: "password", module: password_controller_exports, filename: "./password_controller.js" }, { name: "password-strength", module: password_strength_controller_exports, filename: "./password_strength_controller.js" }
22631, { name: "paypal", module: paypal_controller_exports, filename: "./paypal_controller.js" }, { name: "places-autocomplete", module: places_autocomplete_controller_exports, filename: "./places_autocomplete_controller.js" }, { name: "pricing", module: pricing_controller_exports, filename: "./pricing_controller.js" }, { name: "search", module: search_controller_exports, filename: "./search_controller.js" }, { name: "select", module: select_controller_exports, filename: "./select_controller.js" }, { name: "stripe", module: stripe_controller_exports, filename: "./stripe_controller.js" }, { name: "tooltip", module: tooltip_controller_exports, filename: "./tooltip_controller.js" }, { name: "trustpilot", module: trustpilot_controller_exports, filename: "./trustpilot_controller.js" }, { name: "turbo-native--sign-out", module: sign_out_controller_exports, filename: "./turbo_native/sign_out_controller.js" }, { name: "update-form", module: update_form_controller_exports, filename: "./update_form_controller.js" }, { name: "user-group", module: user_group_controller_exports, filename: "./user_group_controller.js" }, { name: "user-group-pricing", module: user_group_pricing_controller_exports, filename: "./user_group_pricing_controller.js" }, { name: "users", module: users_controller_exports, filename: "./users_controller.js" }]; 22632 var controller_default = modules; 22633 22634
vendor: 12,403 bytes, lines 22634-22892
22634// ../../node_modules/tailwindcss-stimulus-components/dist/tailwindcss-stimulus-components.modern.js 22635 var s = class extends Controller { 22636 initialize() { 22637 this.hide(); 22638 } 22639 connect() { 22640 setTimeout(() => { 22641 this.show(); 22642 }, this.showAfter), this.hasDismissAfterValue && setTimeout(() => { 22643 this.close(); 22644 }, this.dismissAfterValue); 22645 } 22646 close() { 22647 this.hide(), setTimeout(() => { 22648 this.element.remove(); 22649 }, this.removeAfter); 22650 } 22651 show() { 22652 this.element.classList.add(...this.showClasses), this.element.classList.remove(...this.hideClasses); 22653 } 22654 hide() { 22655 this.element.classList.add(...this.hideClasses), this.element.classList.remove(...this.showClasses); 22656 } 22657 get removeAfter() { 22658 return this.hasRemoveDelayValue ? this.removeDelayValue : 1100; 22659 } 22660 get showAfter() { 22661 return this.hasShowDelayValue ? this.showDelayValue : 200; 22662 } 22663 }; 22664 s.values = { dismissAfter: Number, showDelay: Number, removeDelay: Number }, s.classes = ["show", "hide"]; 22665 var e = class extends Controller { 22666 connect() { 22667 this.timeout = null, this.duration = this.data.get("duration") || 1e3; 22668 } 22669 save() { 22670 clearTimeout(this.timeout), this.timeout = setTimeout(() => { 22671 this.statusTarget.textContent = "Saving...", Rails.fire(this.formTarget, "submit"); 22672 }, this.duration); 22673 } 22674 success() { 22675 this.setStatus("Saved!"); 22676 } 22677 error() { 22678 this.setStatus("Unable to save!"); 22679 } 22680 setStatus(t) { 22681 this.statusTarget.textContent = t, this.timeout = setTimeout(() => { 22682 this.statusTarget.textContent = ""; 22683 }, 2e3); 22684 } 22685 }; 22686 e.targets = ["form", "status"]; 22687 var i = class extends Controller { 22688 constructor(...t) { 22689 super(...t), this._onMenuButtonKeydown = (t2) => { 22690 switch (t2.keyCode) { 22691 case 13: 22692 case 32: 22693 t2.preventDefault(), this.toggle(); 22694 } 22695 }; 22696 } 22697 connect() { 22698 this.toggleClass = this.data.get("class") || "hidden", this.visibleClass = this.data.get("visibleClass") || null, this.invisibleClass = this.data.get("invisibleClass") || null, this.activeClass = this.data.get("activeClass") || null, this.enteringClass = this.data.get("enteringClass") || null, this.leavingClass = this.data.get("leavingClass") || null, this.hasButtonTarget && this.buttonTarget.addEventListener("keydown", this._onMenuButtonKeydown), this.element.setAttribute("aria-haspopup", "true"); 22699 } 22700 disconnect() { 22701 this.hasButtonTarget && this.buttonTarget.removeEventListener("keydown", this._onMenuButtonKeydown); 22702 } 22703 toggle() { 22704 this.openValue = !this.openValue; 22705 } 22706 openValueChanged() { 22707 this.openValue ? this._show() : this._hide(); 22708 } 22709 _show(t) { 22710 setTimeout((() => { 22711 this.menuTarget.classList.remove(this.toggleClass), this.element.setAttribute("aria-expanded", "true"), this._enteringClassList[0].forEach(((t2) => { 22712 this.menuTarget.classList.add(t2); 22713 }).bind(this)), this._activeClassList[0].forEach((t2) => { 22714 this.activeTarget.classList.add(t2); 22715 }), this._invisibleClassList[0].forEach((t2) => this.menuTarget.classList.remove(t2)), this._visibleClassList[0].forEach((t2) => { 22716 this.menuTarget.classList.add(t2); 22717 }), setTimeout((() => { 22718 this._enteringClassList[0].forEach((t2) => this.menuTarget.classList.remove(t2)); 22719 }).bind(this), this.enterTimeout[0]), typeof t == "function" && t(); 22720 }).bind(this)); 22721 } 22722 _hide(t) { 22723 setTimeout((() => { 22724 this.element.setAttribute("aria-expanded", "false"), this._invisibleClassList[0].forEach((t2) => this.menuTarget.classList.add(t2)), this._visibleClassList[0].forEach((t2) => this.menuTarget.classList.remove(t2)), this._activeClassList[0].forEach((t2) => this.activeTarget.classList.remove(t2)), this._leavingClassList[0].forEach((t2) => this.menuTarget.classList.add(t2)), setTimeout((() => { 22725 this._leavingClassList[0].forEach((t2) => this.menuTarget.classList.remove(t2)), typeof t == "function" && t(), this.menuTarget.classList.add(this.toggleClass); 22726 }).bind(this), this.leaveTimeout[0]); 22727 }).bind(this)); 22728 } 22729 show() { 22730 this.openValue = true; 22731 } 22732 hide(t) { 22733 this.element.contains(t.target) === false && this.openValue && (this.openValue = false); 22734 } 22735 get activeTarget() { 22736 return this.data.has("activeTarget") ? document.querySelector(this.data.get("activeTarget")) : this.element; 22737 } 22738 get _activeClassList() { 22739 return this.activeClass ? this.activeClass.split(",").map((t) => t.split(" ")) : [[], []]; 22740 } 22741 get _visibleClassList() { 22742 return this.visibleClass ? this.visibleClass.split(",").map((t) => t.split(" ")) : [[], []]; 22743 } 22744 get _invisibleClassList() { 22745 return this.invisibleClass ? this.invisibleClass.split(",").map((t) => t.split(" ")) : [[], []]; 22746 } 22747 get _enteringClassList() { 22748 return this.enteringClass ? this.enteringClass.split(",").map((t) => t.split(" ")) : [[], []]; 22749 } 22750 get _leavingClassList() { 22751 return this.leavingClass ? this.leavingClass.split(",").map((t) => t.split(" ")) : [[], []]; 22752 } 22753 get enterTimeout() { 22754 return (this.data.get("enterTimeout") || "0,0").split(",").map((t) => parseInt(t)); 22755 } 22756 get leaveTimeout() { 22757 return (this.data.get("leaveTimeout") || "0,0").split(",").map((t) => parseInt(t)); 22758 } 22759 }; 22760 i.targets = ["menu", "button"], i.values = { open: Boolean }; 22761 var a = class extends Controller { 22762 connect() { 22763 this.toggleClass = this.data.get("class") || "hidden", this.backgroundId = this.data.get("backgroundId") || "modal-background", this.backgroundHtml = this.data.get("backgroundHtml") || this._backgroundHTML(), this.allowBackgroundClose = (this.data.get("allowBackgroundClose") || "true") === "true", this.preventDefaultActionOpening = (this.data.get("preventDefaultActionOpening") || "true") === "true", this.preventDefaultActionClosing = (this.data.get("preventDefaultActionClosing") || "true") === "true"; 22764 } 22765 disconnect() { 22766 this.close(); 22767 } 22768 open(t) { 22769 this.preventDefaultActionOpening && t.preventDefault(), t.target.blur && t.target.blur(), this.lockScroll(), this.containerTarget.classList.remove(this.toggleClass), this.data.get("disable-backdrop") || (document.body.insertAdjacentHTML("beforeend", this.backgroundHtml), this.background = document.querySelector(`#${this.backgroundId}`)); 22770 } 22771 close(t) { 22772 t && this.preventDefaultActionClosing && t.preventDefault(), this.unlockScroll(), this.containerTarget.classList.add(this.toggleClass), this.background && this.background.remove(); 22773 } 22774 closeBackground(t) { 22775 this.allowBackgroundClose && t.target === this.containerTarget && this.close(t); 22776 } 22777 closeWithKeyboard(t) { 22778 t.keyCode !== 27 || this.containerTarget.classList.contains(this.toggleClass) || this.close(t); 22779 } 22780 _backgroundHTML() { 22781 return `<div id="${this.backgroundId}" class="fixed top-0 left-0 w-full h-full" style="background-color: ${this.backdropColorValue}; z-index: 9998;"></div>`; 22782 } 22783 lockScroll() { 22784 const t = window.innerWidth - document.documentElement.clientWidth; 22785 document.body.style.paddingRight = `${t}px`, this.saveScrollPosition(), document.body.classList.add("fixed", "inset-x-0", "overflow-hidden"), document.body.style.top = `-${this.scrollPosition}px`; 22786 } 22787 unlockScroll() { 22788 document.body.style.paddingRight = null, document.body.classList.remove("fixed", "inset-x-0", "overflow-hidden"), this.restoreScrollValue && this.restoreScrollPosition(), document.body.style.top = null; 22789 } 22790 saveScrollPosition() { 22791 this.scrollPosition = window.pageYOffset || document.body.scrollTop; 22792 } 22793 restoreScrollPosition() { 22794 this.scrollPosition !== void 0 && (document.documentElement.scrollTop = this.scrollPosition); 22795 } 22796 }; 22797 a.targets = ["container"], a.values = { backdropColor: { type: String, default: "rgba(0, 0, 0, 0.8)" }, restoreScroll: { type: Boolean, default: true } }; 22798 var l = class extends Controller { 22799 connect() { 22800 this.activeTabClasses = (this.data.get("activeTab") || "active").split(" "), this.inactiveTabClasses = (this.data.get("inactiveTab") || "inactive").split(" "), this.anchor && (this.index = this.tabTargets.findIndex((t) => t.id === this.anchor)), this.showTab(); 22801 } 22802 change(t) { 22803 t.preventDefault(), this.index = t.currentTarget.dataset.index ? t.currentTarget.dataset.index : t.currentTarget.dataset.id ? this.tabTargets.findIndex((s2) => s2.id == t.currentTarget.dataset.id) : this.tabTargets.indexOf(t.currentTarget), window.dispatchEvent(new CustomEvent("tsc:tab-change")); 22804 } 22805 showTab() { 22806 this.tabTargets.forEach((t, s2) => { 22807 const e2 = this.panelTargets[s2]; 22808 s2 === this.index ? (e2.classList.remove("hidden"), t.classList.remove(...this.inactiveTabClasses), t.classList.add(...this.activeTabClasses), t.id && (location.hash = t.id)) : (e2.classList.add("hidden"), t.classList.remove(...this.activeTabClasses), t.classList.add(...this.inactiveTabClasses)); 22809 }); 22810 } 22811 get index() { 22812 return parseInt(this.data.get("index") || 0); 22813 } 22814 set index(t) { 22815 this.data.set("index", t >= 0 ? t : 0), this.showTab(); 22816 } 22817 get anchor() { 22818 return document.URL.split("#").length > 1 ? document.URL.split("#")[1] : null; 22819 } 22820 }; 22821 l.targets = ["tab", "panel"]; 22822 var o = class extends Controller { 22823 connect() { 22824 this.toggleClass = this.data.get("class") || "hidden"; 22825 } 22826 toggle(t) { 22827 t.preventDefault(), this.openValue = !this.openValue; 22828 } 22829 hide(t) { 22830 t.preventDefault(), this.openValue = false; 22831 } 22832 show(t) { 22833 t.preventDefault(), this.openValue = true; 22834 } 22835 openValueChanged() { 22836 this.toggleClass && this.toggleableTargets.forEach((t) => { 22837 t.classList.toggle(this.toggleClass); 22838 }); 22839 } 22840 }; 22841 o.targets = ["toggleable"], o.values = { open: Boolean }; 22842 var n = class extends Controller { 22843 initialize() { 22844 this.contentTarget.setAttribute("style", `transform:translate(${this.data.get("translateX")}, ${this.data.get("translateY")});`); 22845 } 22846 mouseOver() { 22847 this.contentTarget.classList.remove("hidden"); 22848 } 22849 mouseOut() { 22850 this.contentTarget.classList.add("hidden"); 22851 } 22852 }; 22853 n.targets = ["content"]; 22854 var r = class extends i { 22855 _show() { 22856 this.overlayTarget.classList.remove(this.toggleClass), super._show((() => { 22857 this._activeClassList[1].forEach((t) => this.overlayTarget.classList.add(t)), this._invisibleClassList[1].forEach((t) => this.overlayTarget.classList.remove(t)), this._visibleClassList[1].forEach((t) => this.overlayTarget.classList.add(t)), setTimeout((() => { 22858 this._enteringClassList[1].forEach((t) => this.overlayTarget.classList.remove(t)); 22859 }).bind(this), this.enterTimeout[1]); 22860 }).bind(this)); 22861 } 22862 _hide() { 22863 this._leavingClassList[1].forEach((t) => this.overlayTarget.classList.add(t)), super._hide((() => { 22864 setTimeout((() => { 22865 this._visibleClassList[1].forEach((t) => this.overlayTarget.classList.remove(t)), this._invisibleClassList[1].forEach((t) => this.overlayTarget.classList.add(t)), this._activeClassList[1].forEach((t) => this.overlayTarget.classList.remove(t)), this._leavingClassList[1].forEach((t) => this.overlayTarget.classList.remove(t)), this.overlayTarget.classList.add(this.toggleClass); 22866 }).bind(this), this.leaveTimeout[1]); 22867 }).bind(this)); 22868 } 22869 }; 22870 r.targets = ["menu", "overlay"]; 22871 var h = class extends Controller { 22872 connect() { 22873 this.styleProperty = this.data.get("style") || "backgroundColor"; 22874 } 22875 update() { 22876 this.preview = this.color; 22877 } 22878 set preview(t) { 22879 this.previewTarget.style[this.styleProperty] = t; 22880 const s2 = this._getContrastYIQ(t); 22881 this.styleProperty === "color" ? this.previewTarget.style.backgroundColor = s2 : this.previewTarget.style.color = s2; 22882 } 22883 get color() { 22884 return this.colorTarget.value; 22885 } 22886 _getContrastYIQ(t) { 22887 return t = t.replace("#", ""), (299 * parseInt(t.substr(0, 2), 16) + 587 * parseInt(t.substr(2, 2), 16) + 114 * parseInt(t.substr(4, 2), 16)) / 1e3 >= 128 ? "#000" : "#fff"; 22888 } 22889 }; 22890 h.targets = ["preview", "color"]; 22891 22892
vendor: 2,492 bytes, lines 22892-22970
22892// ../../node_modules/flatpickr/dist/esm/types/options.js 22893 var HOOKS = [ 22894 "onChange", 22895 "onClose", 22896 "onDayCreate", 22897 "onDestroy", 22898 "onKeyDown", 22899 "onMonthChange", 22900 "onOpen", 22901 "onParseConfig", 22902 "onReady", 22903 "onValueUpdate", 22904 "onYearChange", 22905 "onPreCalendarPosition" 22906 ]; 22907 var defaults = { 22908 _disable: [], 22909 allowInput: false, 22910 allowInvalidPreload: false, 22911 altFormat: "F j, Y", 22912 altInput: false, 22913 altInputClass: "form-control input", 22914 animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1, 22915 ariaDateFormat: "F j, Y", 22916 autoFillDefaultTime: true, 22917 clickOpens: true, 22918 closeOnSelect: true, 22919 conjunction: ", ", 22920 dateFormat: "Y-m-d", 22921 defaultHour: 12, 22922 defaultMinute: 0, 22923 defaultSeconds: 0, 22924 disable: [], 22925 disableMobile: false, 22926 enableSeconds: false, 22927 enableTime: false, 22928 errorHandler: (err) => typeof console !== "undefined" && console.warn(err), 22929 getWeek: (givenDate) => { 22930 const date = new Date(givenDate.getTime()); 22931 date.setHours(0, 0, 0, 0); 22932 date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); 22933 var week1 = new Date(date.getFullYear(), 0, 4); 22934 return 1 + Math.round(((date.getTime() - week1.getTime()) / 864e5 - 3 + (week1.getDay() + 6) % 7) / 7); 22935 }, 22936 hourIncrement: 1, 22937 ignoredFocusElements: [], 22938 inline: false, 22939 locale: "default", 22940 minuteIncrement: 5, 22941 mode: "single", 22942 monthSelectorType: "dropdown", 22943 nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>", 22944 noCalendar: false, 22945 now: new Date(), 22946 onChange: [], 22947 onClose: [], 22948 onDayCreate: [], 22949 onDestroy: [], 22950 onKeyDown: [], 22951 onMonthChange: [], 22952 onOpen: [], 22953 onParseConfig: [], 22954 onReady: [], 22955 onValueUpdate: [], 22956 onYearChange: [], 22957 onPreCalendarPosition: [], 22958 plugins: [], 22959 position: "auto", 22960 positionElement: void 0, 22961 prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>", 22962 shorthandCurrentMonth: false, 22963 showMonths: 1, 22964 static: false, 22965 time_24hr: false, 22966 weekNumbers: false, 22967 wrap: false 22968 }; 22969 22970
vendor: 1,517 bytes, lines 22970-23044
22970// ../../node_modules/flatpickr/dist/esm/l10n/default.js 22971 var english = { 22972 weekdays: { 22973 shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 22974 longhand: [ 22975 "Sunday", 22976 "Monday", 22977 "Tuesday", 22978 "Wednesday", 22979 "Thursday", 22980 "Friday", 22981 "Saturday" 22982 ] 22983 }, 22984 months: { 22985 shorthand: [ 22986 "Jan", 22987 "Feb", 22988 "Mar", 22989 "Apr", 22990 "May", 22991 "Jun", 22992 "Jul", 22993 "Aug", 22994 "Sep", 22995 "Oct", 22996 "Nov", 22997 "Dec" 22998 ], 22999 longhand: [ 23000 "January", 23001 "February", 23002 "March", 23003 "April", 23004 "May", 23005 "June", 23006 "July", 23007 "August", 23008 "September", 23009 "October", 23010 "November", 23011 "December" 23012 ] 23013 }, 23014 daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], 23015 firstDayOfWeek: 0, 23016 ordinal: (nth) => { 23017 const s2 = nth % 100; 23018 if (s2 > 3 && s2 < 21) 23019 return "th"; 23020 switch (s2 % 10) { 23021 case 1: 23022 return "st"; 23023 case 2: 23024 return "nd"; 23025 case 3: 23026 return "rd"; 23027 default: 23028 return "th"; 23029 } 23030 }, 23031 rangeSeparator: " to ", 23032 weekAbbreviation: "Wk", 23033 scrollTitle: "Scroll to increment", 23034 toggleTitle: "Click to toggle", 23035 amPM: ["AM", "PM"], 23036 yearAriaLabel: "Year", 23037 monthAriaLabel: "Month", 23038 hourAriaLabel: "Hour", 23039 minuteAriaLabel: "Minute", 23040 time_24hr: false 23041 }; 23042 var default_default = english; 23043 23044
vendor: 402 bytes, lines 23044-23056
23044// ../../node_modules/flatpickr/dist/esm/utils/index.js 23045 var pad = (number, length = 2) => `000${number}`.slice(length * -1); 23046 var int = (bool) => bool === true ? 1 : 0; 23047 function debounce3(fn2, wait) { 23048 let t; 23049 return function() { 23050 clearTimeout(t); 23051 t = setTimeout(() => fn2.apply(this, arguments), wait); 23052 }; 23053 } 23054 var arrayify = (obj) => obj instanceof Array ? obj : [obj]; 23055 23056
vendor: 1,716 bytes, lines 23056-23110
23056// ../../node_modules/flatpickr/dist/esm/utils/dom.js 23057 function toggleClass(elem, className, bool) { 23058 if (bool === true) 23059 return elem.classList.add(className); 23060 elem.classList.remove(className); 23061 } 23062 function createElement(tag, className, content) { 23063 const e2 = window.document.createElement(tag); 23064 className = className || ""; 23065 content = content || ""; 23066 e2.className = className; 23067 if (content !== void 0) 23068 e2.textContent = content; 23069 return e2; 23070 } 23071 function clearNode(node) { 23072 while (node.firstChild) 23073 node.removeChild(node.firstChild); 23074 } 23075 function findParent(node, condition) { 23076 if (condition(node)) 23077 return node; 23078 else if (node.parentNode) 23079 return findParent(node.parentNode, condition); 23080 return void 0; 23081 } 23082 function createNumberInput(inputClassName, opts) { 23083 const wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown"); 23084 if (navigator.userAgent.indexOf("MSIE 9.0") === -1) { 23085 numInput.type = "number"; 23086 } else { 23087 numInput.type = "text"; 23088 numInput.pattern = "\\d*"; 23089 } 23090 if (opts !== void 0) 23091 for (const key in opts) 23092 numInput.setAttribute(key, opts[key]); 23093 wrapper.appendChild(numInput); 23094 wrapper.appendChild(arrowUp); 23095 wrapper.appendChild(arrowDown); 23096 return wrapper; 23097 } 23098 function getEventTarget(event) { 23099 try { 23100 if (typeof event.composedPath === "function") { 23101 const path = event.composedPath(); 23102 return path[0]; 23103 } 23104 return event.target; 23105 } catch (error2) { 23106 return event.target; 23107 } 23108 } 23109 23110
vendor: 4,154 bytes, lines 23110-23240
23110// ../../node_modules/flatpickr/dist/esm/utils/formatting.js 23111 var doNothing = () => void 0; 23112 var monthToStr = (monthNumber, shorthand, locale) => locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; 23113 var revFormat = { 23114 D: doNothing, 23115 F: function(dateObj, monthName, locale) { 23116 dateObj.setMonth(locale.months.longhand.indexOf(monthName)); 23117 }, 23118 G: (dateObj, hour) => { 23119 dateObj.setHours(parseFloat(hour)); 23120 }, 23121 H: (dateObj, hour) => { 23122 dateObj.setHours(parseFloat(hour)); 23123 }, 23124 J: (dateObj, day) => { 23125 dateObj.setDate(parseFloat(day)); 23126 }, 23127 K: (dateObj, amPM, locale) => { 23128 dateObj.setHours(dateObj.getHours() % 12 + 12 * int(new RegExp(locale.amPM[1], "i").test(amPM))); 23129 }, 23130 M: function(dateObj, shortMonth, locale) { 23131 dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth)); 23132 }, 23133 S: (dateObj, seconds) => { 23134 dateObj.setSeconds(parseFloat(seconds)); 23135 }, 23136 U: (_, unixSeconds) => new Date(parseFloat(unixSeconds) * 1e3), 23137 W: function(dateObj, weekNum, locale) { 23138 const weekNumber = parseInt(weekNum); 23139 const date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0); 23140 date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek); 23141 return date; 23142 }, 23143 Y: (dateObj, year) => { 23144 dateObj.setFullYear(parseFloat(year)); 23145 }, 23146 Z: (_, ISODate) => new Date(ISODate), 23147 d: (dateObj, day) => { 23148 dateObj.setDate(parseFloat(day)); 23149 }, 23150 h: (dateObj, hour) => { 23151 dateObj.setHours(parseFloat(hour)); 23152 }, 23153 i: (dateObj, minutes) => { 23154 dateObj.setMinutes(parseFloat(minutes)); 23155 }, 23156 j: (dateObj, day) => { 23157 dateObj.setDate(parseFloat(day)); 23158 }, 23159 l: doNothing, 23160 m: (dateObj, month) => { 23161 dateObj.setMonth(parseFloat(month) - 1); 23162 }, 23163 n: (dateObj, month) => { 23164 dateObj.setMonth(parseFloat(month) - 1); 23165 }, 23166 s: (dateObj, seconds) => { 23167 dateObj.setSeconds(parseFloat(seconds)); 23168 }, 23169 u: (_, unixMillSeconds) => new Date(parseFloat(unixMillSeconds)), 23170 w: doNothing, 23171 y: (dateObj, year) => { 23172 dateObj.setFullYear(2e3 + parseFloat(year)); 23173 } 23174 }; 23175 var tokenRegex = { 23176 D: "(\\w+)", 23177 F: "(\\w+)", 23178 G: "(\\d\\d|\\d)", 23179 H: "(\\d\\d|\\d)", 23180 J: "(\\d\\d|\\d)\\w+", 23181 K: "", 23182 M: "(\\w+)", 23183 S: "(\\d\\d|\\d)", 23184 U: "(.+)", 23185 W: "(\\d\\d|\\d)", 23186 Y: "(\\d{4})", 23187 Z: "(.+)", 23188 d: "(\\d\\d|\\d)", 23189 h: "(\\d\\d|\\d)", 23190 i: "(\\d\\d|\\d)", 23191 j: "(\\d\\d|\\d)", 23192 l: "(\\w+)", 23193 m: "(\\d\\d|\\d)", 23194 n: "(\\d\\d|\\d)", 23195 s: "(\\d\\d|\\d)", 23196 u: "(.+)", 23197 w: "(\\d\\d|\\d)", 23198 y: "(\\d{2})" 23199 }; 23200 var formats = { 23201 Z: (date) => date.toISOString(), 23202 D: function(date, locale, options2) { 23203 return locale.weekdays.shorthand[formats.w(date, locale, options2)]; 23204 }, 23205 F: function(date, locale, options2) { 23206 return monthToStr(formats.n(date, locale, options2) - 1, false, locale); 23207 }, 23208 G: function(date, locale, options2) { 23209 return pad(formats.h(date, locale, options2)); 23210 }, 23211 H: (date) => pad(date.getHours()), 23212 J: function(date, locale) { 23213 return locale.ordinal !== void 0 ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate(); 23214 }, 23215 K: (date, locale) => locale.amPM[int(date.getHours() > 11)], 23216 M: function(date, locale) { 23217 return monthToStr(date.getMonth(), true, locale); 23218 }, 23219 S: (date) => pad(date.getSeconds()), 23220 U: (date) => date.getTime() / 1e3, 23221 W: function(date, _, options2) { 23222 return options2.getWeek(date); 23223 }, 23224 Y: (date) => pad(date.getFullYear(), 4), 23225 d: (date) => pad(date.getDate()), 23226 h: (date) => date.getHours() % 12 ? date.getHours() % 12 : 12, 23227 i: (date) => pad(date.getMinutes()), 23228 j: (date) => date.getDate(), 23229 l: function(date, locale) { 23230 return locale.weekdays.longhand[date.getDay()]; 23231 }, 23232 m: (date) => pad(date.getMonth() + 1), 23233 n: (date) => date.getMonth() + 1, 23234 s: (date) => date.getSeconds(), 23235 u: (date) => date.getTime(), 23236 w: (date) => date.getDay(), 23237 y: (date) => String(date.getFullYear()).substring(2) 23238 }; 23239 23240
vendor: 4,108 bytes, lines 23240-23340
23240// ../../node_modules/flatpickr/dist/esm/utils/dates.js 23241 var createDateFormatter = ({ config = defaults, l10n = english, isMobile = false }) => (dateObj, frmt, overrideLocale) => { 23242 const locale = overrideLocale || l10n; 23243 if (config.formatDate !== void 0 && !isMobile) { 23244 return config.formatDate(dateObj, frmt, locale); 23245 } 23246 return frmt.split("").map((c, i2, arr) => formats[c] && arr[i2 - 1] !== "\\" ? formats[c](dateObj, locale, config) : c !== "\\" ? c : "").join(""); 23247 }; 23248 var createDateParser = ({ config = defaults, l10n = english }) => (date, givenFormat, timeless, customLocale) => { 23249 if (date !== 0 && !date) 23250 return void 0; 23251 const locale = customLocale || l10n; 23252 let parsedDate; 23253 const dateOrig = date; 23254 if (date instanceof Date) 23255 parsedDate = new Date(date.getTime()); 23256 else if (typeof date !== "string" && date.toFixed !== void 0) 23257 parsedDate = new Date(date); 23258 else if (typeof date === "string") { 23259 const format2 = givenFormat || (config || defaults).dateFormat; 23260 const datestr = String(date).trim(); 23261 if (datestr === "today") { 23262 parsedDate = new Date(); 23263 timeless = true; 23264 } else if (/Z$/.test(datestr) || /GMT$/.test(datestr)) 23265 parsedDate = new Date(date); 23266 else if (config && config.parseDate) 23267 parsedDate = config.parseDate(date, format2); 23268 else { 23269 parsedDate = !config || !config.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0)); 23270 let matched, ops = []; 23271 for (let i2 = 0, matchIndex = 0, regexStr = ""; i2 < format2.length; i2++) { 23272 const token = format2[i2]; 23273 const isBackSlash = token === "\\"; 23274 const escaped = format2[i2 - 1] === "\\" || isBackSlash; 23275 if (tokenRegex[token] && !escaped) { 23276 regexStr += tokenRegex[token]; 23277 const match = new RegExp(regexStr).exec(date); 23278 if (match && (matched = true)) { 23279 ops[token !== "Y" ? "push" : "unshift"]({ 23280 fn: revFormat[token], 23281 val: match[++matchIndex] 23282 }); 23283 } 23284 } else if (!isBackSlash) 23285 regexStr += "."; 23286 ops.forEach(({ fn: fn2, val }) => parsedDate = fn2(parsedDate, val, locale) || parsedDate); 23287 } 23288 parsedDate = matched ? parsedDate : void 0; 23289 } 23290 } 23291 if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) { 23292 config.errorHandler(new Error(`Invalid date provided: ${dateOrig}`)); 23293 return void 0; 23294 } 23295 if (timeless === true) 23296 parsedDate.setHours(0, 0, 0, 0); 23297 return parsedDate; 23298 }; 23299 function compareDates(date1, date2, timeless = true) { 23300 if (timeless !== false) { 23301 return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0); 23302 } 23303 return date1.getTime() - date2.getTime(); 23304 } 23305 var isBetween = (ts, ts1, ts2) => { 23306 return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2); 23307 }; 23308 var duration = { 23309 DAY: 864e5 23310 }; 23311 function getDefaultHours(config) { 23312 let hours = config.defaultHour; 23313 let minutes = config.defaultMinute; 23314 let seconds = config.defaultSeconds; 23315 if (config.minDate !== void 0) { 23316 const minHour = config.minDate.getHours(); 23317 const minMinutes = config.minDate.getMinutes(); 23318 const minSeconds = config.minDate.getSeconds(); 23319 if (hours < minHour) { 23320 hours = minHour; 23321 } 23322 if (hours === minHour && minutes < minMinutes) { 23323 minutes = minMinutes; 23324 } 23325 if (hours === minHour && minutes === minMinutes && seconds < minSeconds) 23326 seconds = config.minDate.getSeconds(); 23327 } 23328 if (config.maxDate !== void 0) { 23329 const maxHr = config.maxDate.getHours(); 23330 const maxMinutes = config.maxDate.getMinutes(); 23331 hours = Math.min(hours, maxHr); 23332 if (hours === maxHr) 23333 minutes = Math.min(maxMinutes, minutes); 23334 if (hours === maxHr && minutes === maxMinutes) 23335 seconds = config.maxDate.getSeconds(); 23336 } 23337 return { hours, minutes, seconds }; 23338 } 23339 23340
vendor: 438 bytes, lines 23340-23355
23340// ../../node_modules/flatpickr/dist/esm/utils/polyfills.js 23341 if (typeof Object.assign !== "function") { 23342 Object.assign = function(target, ...args) { 23343 if (!target) { 23344 throw TypeError("Cannot convert undefined or null to object"); 23345 } 23346 for (const source of args) { 23347 if (source) { 23348 Object.keys(source).forEach((key) => target[key] = source[key]); 23349 } 23350 } 23351 return target; 23352 }; 23353 } 23354 23355
vendor: 75,861 bytes, lines 23355-24995
23355// ../../node_modules/flatpickr/dist/esm/index.js 23356 var DEBOUNCED_CHANGE_MS = 300; 23357 function FlatpickrInstance(element, instanceConfig) { 23358 const self2 = { 23359 config: Object.assign(Object.assign({}, defaults), flatpickr.defaultConfig), 23360 l10n: default_default 23361 }; 23362 self2.parseDate = createDateParser({ config: self2.config, l10n: self2.l10n }); 23363 self2._handlers = []; 23364 self2.pluginElements = []; 23365 self2.loadedPlugins = []; 23366 self2._bind = bind; 23367 self2._setHoursFromDate = setHoursFromDate; 23368 self2._positionCalendar = positionCalendar; 23369 self2.changeMonth = changeMonth; 23370 self2.changeYear = changeYear; 23371 self2.clear = clear; 23372 self2.close = close; 23373 self2._createElement = createElement; 23374 self2.destroy = destroy2; 23375 self2.isEnabled = isEnabled; 23376 self2.jumpToDate = jumpToDate; 23377 self2.open = open; 23378 self2.redraw = redraw; 23379 self2.set = set; 23380 self2.setDate = setDate; 23381 self2.toggle = toggle; 23382 function setupHelperFunctions() { 23383 self2.utils = { 23384 getDaysInMonth(month = self2.currentMonth, yr = self2.currentYear) { 23385 if (month === 1 && (yr % 4 === 0 && yr % 100 !== 0 || yr % 400 === 0)) 23386 return 29; 23387 return self2.l10n.daysInMonth[month]; 23388 } 23389 }; 23390 } 23391 function init2() { 23392 self2.element = self2.input = element; 23393 self2.isOpen = false; 23394 parseConfig(); 23395 setupLocale(); 23396 setupInputs(); 23397 setupDates(); 23398 setupHelperFunctions(); 23399 if (!self2.isMobile) 23400 build(); 23401 bindEvents(); 23402 if (self2.selectedDates.length || self2.config.noCalendar) { 23403 if (self2.config.enableTime) { 23404 setHoursFromDate(self2.config.noCalendar ? self2.latestSelectedDateObj : void 0); 23405 } 23406 updateValue(false); 23407 } 23408 setCalendarWidth(); 23409 const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); 23410 if (!self2.isMobile && isSafari) { 23411 positionCalendar(); 23412 } 23413 triggerEvent("onReady"); 23414 } 23415 function bindToInstance(fn2) { 23416 return fn2.bind(self2); 23417 } 23418 function setCalendarWidth() { 23419 const config = self2.config; 23420 if (config.weekNumbers === false && config.showMonths === 1) { 23421 return; 23422 } else if (config.noCalendar !== true) { 23423 window.requestAnimationFrame(function() { 23424 if (self2.calendarContainer !== void 0) { 23425 self2.calendarContainer.style.visibility = "hidden"; 23426 self2.calendarContainer.style.display = "block"; 23427 } 23428 if (self2.daysContainer !== void 0) { 23429 const daysWidth = (self2.days.offsetWidth + 1) * config.showMonths; 23430 self2.daysContainer.style.width = daysWidth + "px"; 23431 self2.calendarContainer.style.width = daysWidth + (self2.weekWrapper !== void 0 ? self2.weekWrapper.offsetWidth : 0) + "px"; 23432 self2.calendarContainer.style.removeProperty("visibility"); 23433 self2.calendarContainer.style.removeProperty("display"); 23434 } 23435 }); 23436 } 23437 } 23438 function updateTime(e2) { 23439 if (self2.selectedDates.length === 0) { 23440 const defaultDate = self2.config.minDate === void 0 || compareDates(new Date(), self2.config.minDate) >= 0 ? new Date() : new Date(self2.config.minDate.getTime()); 23441 const defaults2 = getDefaultHours(self2.config); 23442 defaultDate.setHours(defaults2.hours, defaults2.minutes, defaults2.seconds, defaultDate.getMilliseconds()); 23443 self2.selectedDates = [defaultDate]; 23444 self2.latestSelectedDateObj = defaultDate; 23445 } 23446 if (e2 !== void 0 && e2.type !== "blur") { 23447 timeWrapper(e2); 23448 } 23449 const prevValue = self2._input.value; 23450 setHoursFromInputs(); 23451 updateValue(); 23452 if (self2._input.value !== prevValue) { 23453 self2._debouncedChange(); 23454 } 23455 } 23456 function ampm2military(hour, amPM) { 23457 return hour % 12 + 12 * int(amPM === self2.l10n.amPM[1]); 23458 } 23459 function military2ampm(hour) { 23460 switch (hour % 24) { 23461 case 0: 23462 case 12: 23463 return 12; 23464 default: 23465 return hour % 12; 23466 } 23467 } 23468 function setHoursFromInputs() { 23469 if (self2.hourElement === void 0 || self2.minuteElement === void 0) 23470 return; 23471 let hours = (parseInt(self2.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self2.minuteElement.value, 10) || 0) % 60, seconds = self2.secondElement !== void 0 ? (parseInt(self2.secondElement.value, 10) || 0) % 60 : 0; 23472 if (self2.amPM !== void 0) { 23473 hours = ampm2military(hours, self2.amPM.textContent); 23474 } 23475 const limitMinHours = self2.config.minTime !== void 0 || self2.config.minDate && self2.minDateHasTime && self2.latestSelectedDateObj && compareDates(self2.latestSelectedDateObj, self2.config.minDate, true) === 0; 23476 const limitMaxHours = self2.config.maxTime !== void 0 || self2.config.maxDate && self2.maxDateHasTime && self2.latestSelectedDateObj && compareDates(self2.latestSelectedDateObj, self2.config.maxDate, true) === 0; 23477 if (limitMaxHours) { 23478 const maxTime = self2.config.maxTime !== void 0 ? self2.config.maxTime : self2.config.maxDate; 23479 hours = Math.min(hours, maxTime.getHours()); 23480 if (hours === maxTime.getHours()) 23481 minutes = Math.min(minutes, maxTime.getMinutes()); 23482 if (minutes === maxTime.getMinutes()) 23483 seconds = Math.min(seconds, maxTime.getSeconds()); 23484 } 23485 if (limitMinHours) { 23486 const minTime = self2.config.minTime !== void 0 ? self2.config.minTime : self2.config.minDate; 23487 hours = Math.max(hours, minTime.getHours()); 23488 if (hours === minTime.getHours() && minutes < minTime.getMinutes()) 23489 minutes = minTime.getMinutes(); 23490 if (minutes === minTime.getMinutes()) 23491 seconds = Math.max(seconds, minTime.getSeconds()); 23492 } 23493 setHours(hours, minutes, seconds); 23494 } 23495 function setHoursFromDate(dateObj) { 23496 const date = dateObj || self2.latestSelectedDateObj; 23497 if (date) { 23498 setHours(date.getHours(), date.getMinutes(), date.getSeconds()); 23499 } 23500 } 23501 function setHours(hours, minutes, seconds) { 23502 if (self2.latestSelectedDateObj !== void 0) { 23503 self2.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0); 23504 } 23505 if (!self2.hourElement || !self2.minuteElement || self2.isMobile) 23506 return; 23507 self2.hourElement.value = pad(!self2.config.time_24hr ? (12 + hours) % 12 + 12 * int(hours % 12 === 0) : hours); 23508 self2.minuteElement.value = pad(minutes); 23509 if (self2.amPM !== void 0) 23510 self2.amPM.textContent = self2.l10n.amPM[int(hours >= 12)]; 23511 if (self2.secondElement !== void 0) 23512 self2.secondElement.value = pad(seconds); 23513 } 23514 function onYearInput(event) { 23515 const eventTarget = getEventTarget(event); 23516 const year = parseInt(eventTarget.value) + (event.delta || 0); 23517 if (year / 1e3 > 1 || event.key === "Enter" && !/[^\d]/.test(year.toString())) { 23518 changeYear(year); 23519 } 23520 } 23521 function bind(element2, event, handler, options2) { 23522 if (event instanceof Array) 23523 return event.forEach((ev) => bind(element2, ev, handler, options2)); 23524 if (element2 instanceof Array) 23525 return element2.forEach((el) => bind(el, event, handler, options2)); 23526 element2.addEventListener(event, handler, options2); 23527 self2._handlers.push({ 23528 remove: () => element2.removeEventListener(event, handler) 23529 }); 23530 } 23531 function triggerChange() { 23532 triggerEvent("onChange"); 23533 } 23534 function bindEvents() { 23535 if (self2.config.wrap) { 23536 ["open", "close", "toggle", "clear"].forEach((evt) => { 23537 Array.prototype.forEach.call(self2.element.querySelectorAll(`[data-${evt}]`), (el) => bind(el, "click", self2[evt])); 23538 }); 23539 } 23540 if (self2.isMobile) { 23541 setupMobile(); 23542 return; 23543 } 23544 const debouncedResize = debounce3(onResize, 50); 23545 self2._debouncedChange = debounce3(triggerChange, DEBOUNCED_CHANGE_MS); 23546 if (self2.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent)) 23547 bind(self2.daysContainer, "mouseover", (e2) => { 23548 if (self2.config.mode === "range") 23549 onMouseOver(getEventTarget(e2)); 23550 }); 23551 bind(window.document.body, "keydown", onKeyDown); 23552 if (!self2.config.inline && !self2.config.static) 23553 bind(window, "resize", debouncedResize); 23554 if (window.ontouchstart !== void 0) 23555 bind(window.document, "touchstart", documentClick); 23556 else 23557 bind(window.document, "mousedown", documentClick); 23558 bind(window.document, "focus", documentClick, { capture: true }); 23559 if (self2.config.clickOpens === true) { 23560 bind(self2._input, "focus", self2.open); 23561 bind(self2._input, "click", self2.open); 23562 } 23563 if (self2.daysContainer !== void 0) { 23564 bind(self2.monthNav, "click", onMonthNavClick); 23565 bind(self2.monthNav, ["keyup", "increment"], onYearInput); 23566 bind(self2.daysContainer, "click", selectDate); 23567 } 23568 if (self2.timeContainer !== void 0 && self2.minuteElement !== void 0 && self2.hourElement !== void 0) { 23569 const selText = (e2) => getEventTarget(e2).select(); 23570 bind(self2.timeContainer, ["increment"], updateTime); 23571 bind(self2.timeContainer, "blur", updateTime, { capture: true }); 23572 bind(self2.timeContainer, "click", timeIncrement); 23573 bind([self2.hourElement, self2.minuteElement], ["focus", "click"], selText); 23574 if (self2.secondElement !== void 0) 23575 bind(self2.secondElement, "focus", () => self2.secondElement && self2.secondElement.select()); 23576 if (self2.amPM !== void 0) { 23577 bind(self2.amPM, "click", (e2) => { 23578 updateTime(e2); 23579 triggerChange(); 23580 }); 23581 } 23582 } 23583 if (self2.config.allowInput) { 23584 bind(self2._input, "blur", onBlur); 23585 } 23586 } 23587 function jumpToDate(jumpDate, triggerChange2) { 23588 const jumpTo = jumpDate !== void 0 ? self2.parseDate(jumpDate) : self2.latestSelectedDateObj || (self2.config.minDate && self2.config.minDate > self2.now ? self2.config.minDate : self2.config.maxDate && self2.config.maxDate < self2.now ? self2.config.maxDate : self2.now); 23589 const oldYear = self2.currentYear; 23590 const oldMonth = self2.currentMonth; 23591 try { 23592 if (jumpTo !== void 0) { 23593 self2.currentYear = jumpTo.getFullYear(); 23594 self2.currentMonth = jumpTo.getMonth(); 23595 } 23596 } catch (e2) { 23597 e2.message = "Invalid date supplied: " + jumpTo; 23598 self2.config.errorHandler(e2); 23599 } 23600 if (triggerChange2 && self2.currentYear !== oldYear) { 23601 triggerEvent("onYearChange"); 23602 buildMonthSwitch(); 23603 } 23604 if (triggerChange2 && (self2.currentYear !== oldYear || self2.currentMonth !== oldMonth)) { 23605 triggerEvent("onMonthChange"); 23606 } 23607 self2.redraw(); 23608 } 23609 function timeIncrement(e2) { 23610 const eventTarget = getEventTarget(e2); 23611 if (~eventTarget.className.indexOf("arrow")) 23612 incrementNumInput(e2, eventTarget.classList.contains("arrowUp") ? 1 : -1); 23613 } 23614 function incrementNumInput(e2, delta, inputElem) { 23615 const target = e2 && getEventTarget(e2); 23616 const input = inputElem || target && target.parentNode && target.parentNode.firstChild; 23617 const event = createEvent("increment"); 23618 event.delta = delta; 23619 input && input.dispatchEvent(event); 23620 } 23621 function build() { 23622 const fragment = window.document.createDocumentFragment(); 23623 self2.calendarContainer = createElement("div", "flatpickr-calendar"); 23624 self2.calendarContainer.tabIndex = -1; 23625 if (!self2.config.noCalendar) { 23626 fragment.appendChild(buildMonthNav()); 23627 self2.innerContainer = createElement("div", "flatpickr-innerContainer"); 23628 if (self2.config.weekNumbers) { 23629 const { weekWrapper, weekNumbers } = buildWeeks(); 23630 self2.innerContainer.appendChild(weekWrapper); 23631 self2.weekNumbers = weekNumbers; 23632 self2.weekWrapper = weekWrapper; 23633 } 23634 self2.rContainer = createElement("div", "flatpickr-rContainer"); 23635 self2.rContainer.appendChild(buildWeekdays()); 23636 if (!self2.daysContainer) { 23637 self2.daysContainer = createElement("div", "flatpickr-days"); 23638 self2.daysContainer.tabIndex = -1; 23639 } 23640 buildDays(); 23641 self2.rContainer.appendChild(self2.daysContainer); 23642 self2.innerContainer.appendChild(self2.rContainer); 23643 fragment.appendChild(self2.innerContainer); 23644 } 23645 if (self2.config.enableTime) { 23646 fragment.appendChild(buildTime()); 23647 } 23648 toggleClass(self2.calendarContainer, "rangeMode", self2.config.mode === "range"); 23649 toggleClass(self2.calendarContainer, "animate", self2.config.animate === true); 23650 toggleClass(self2.calendarContainer, "multiMonth", self2.config.showMonths > 1); 23651 self2.calendarContainer.appendChild(fragment); 23652 const customAppend = self2.config.appendTo !== void 0 && self2.config.appendTo.nodeType !== void 0; 23653 if (self2.config.inline || self2.config.static) { 23654 self2.calendarContainer.classList.add(self2.config.inline ? "inline" : "static"); 23655 if (self2.config.inline) { 23656 if (!customAppend && self2.element.parentNode) 23657 self2.element.parentNode.insertBefore(self2.calendarContainer, self2._input.nextSibling); 23658 else if (self2.config.appendTo !== void 0) 23659 self2.config.appendTo.appendChild(self2.calendarContainer); 23660 } 23661 if (self2.config.static) { 23662 const wrapper = createElement("div", "flatpickr-wrapper"); 23663 if (self2.element.parentNode) 23664 self2.element.parentNode.insertBefore(wrapper, self2.element); 23665 wrapper.appendChild(self2.element); 23666 if (self2.altInput) 23667 wrapper.appendChild(self2.altInput); 23668 wrapper.appendChild(self2.calendarContainer); 23669 } 23670 } 23671 if (!self2.config.static && !self2.config.inline) 23672 (self2.config.appendTo !== void 0 ? self2.config.appendTo : window.document.body).appendChild(self2.calendarContainer); 23673 } 23674 function createDay(className, date, dayNumber, i2) { 23675 const dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", "flatpickr-day " + className, date.getDate().toString()); 23676 dayElement.dateObj = date; 23677 dayElement.$i = i2; 23678 dayElement.setAttribute("aria-label", self2.formatDate(date, self2.config.ariaDateFormat)); 23679 if (className.indexOf("hidden") === -1 && compareDates(date, self2.now) === 0) { 23680 self2.todayDateElem = dayElement; 23681 dayElement.classList.add("today"); 23682 dayElement.setAttribute("aria-current", "date"); 23683 } 23684 if (dateIsEnabled) { 23685 dayElement.tabIndex = -1; 23686 if (isDateSelected(date)) { 23687 dayElement.classList.add("selected"); 23688 self2.selectedDateElem = dayElement; 23689 if (self2.config.mode === "range") { 23690 toggleClass(dayElement, "startRange", self2.selectedDates[0] && compareDates(date, self2.selectedDates[0], true) === 0); 23691 toggleClass(dayElement, "endRange", self2.selectedDates[1] && compareDates(date, self2.selectedDates[1], true) === 0); 23692 if (className === "nextMonthDay") 23693 dayElement.classList.add("inRange"); 23694 } 23695 } 23696 } else { 23697 dayElement.classList.add("flatpickr-disabled"); 23698 } 23699 if (self2.config.mode === "range") { 23700 if (isDateInRange(date) && !isDateSelected(date)) 23701 dayElement.classList.add("inRange"); 23702 } 23703 if (self2.weekNumbers && self2.config.showMonths === 1 && className !== "prevMonthDay" && dayNumber % 7 === 1) { 23704 self2.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self2.config.getWeek(date) + "</span>"); 23705 } 23706 triggerEvent("onDayCreate", dayElement); 23707 return dayElement; 23708 } 23709 function focusOnDayElem(targetNode) { 23710 targetNode.focus(); 23711 if (self2.config.mode === "range") 23712 onMouseOver(targetNode); 23713 } 23714 function getFirstAvailableDay(delta) { 23715 const startMonth = delta > 0 ? 0 : self2.config.showMonths - 1; 23716 const endMonth = delta > 0 ? self2.config.showMonths : -1; 23717 for (let m = startMonth; m != endMonth; m += delta) { 23718 const month = self2.daysContainer.children[m]; 23719 const startIndex = delta > 0 ? 0 : month.children.length - 1; 23720 const endIndex = delta > 0 ? month.children.length : -1; 23721 for (let i2 = startIndex; i2 != endIndex; i2 += delta) { 23722 const c = month.children[i2]; 23723 if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj)) 23724 return c; 23725 } 23726 } 23727 return void 0; 23728 } 23729 function getNextAvailableDay(current, delta) { 23730 const givenMonth = current.className.indexOf("Month") === -1 ? current.dateObj.getMonth() : self2.currentMonth; 23731 const endMonth = delta > 0 ? self2.config.showMonths : -1; 23732 const loopDelta = delta > 0 ? 1 : -1; 23733 for (let m = givenMonth - self2.currentMonth; m != endMonth; m += loopDelta) { 23734 const month = self2.daysContainer.children[m]; 23735 const startIndex = givenMonth - self2.currentMonth === m ? current.$i + delta : delta < 0 ? month.children.length - 1 : 0; 23736 const numMonthDays = month.children.length; 23737 for (let i2 = startIndex; i2 >= 0 && i2 < numMonthDays && i2 != (delta > 0 ? numMonthDays : -1); i2 += loopDelta) { 23738 const c = month.children[i2]; 23739 if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj) && Math.abs(current.$i - i2) >= Math.abs(delta)) 23740 return focusOnDayElem(c); 23741 } 23742 } 23743 self2.changeMonth(loopDelta); 23744 focusOnDay(getFirstAvailableDay(loopDelta), 0); 23745 return void 0; 23746 } 23747 function focusOnDay(current, offset2) { 23748 const dayFocused = isInView(document.activeElement || document.body); 23749 const startElem = current !== void 0 ? current : dayFocused ? document.activeElement : self2.selectedDateElem !== void 0 && isInView(self2.selectedDateElem) ? self2.selectedDateElem : self2.todayDateElem !== void 0 && isInView(self2.todayDateElem) ? self2.todayDateElem : getFirstAvailableDay(offset2 > 0 ? 1 : -1); 23750 if (startElem === void 0) { 23751 self2._input.focus(); 23752 } else if (!dayFocused) { 23753 focusOnDayElem(startElem); 23754 } else { 23755 getNextAvailableDay(startElem, offset2); 23756 } 23757 } 23758 function buildMonthDays(year, month) { 23759 const firstOfMonth = (new Date(year, month, 1).getDay() - self2.l10n.firstDayOfWeek + 7) % 7; 23760 const prevMonthDays = self2.utils.getDaysInMonth((month - 1 + 12) % 12, year); 23761 const daysInMonth = self2.utils.getDaysInMonth(month, year), days = window.document.createDocumentFragment(), isMultiMonth = self2.config.showMonths > 1, prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay", nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay"; 23762 let dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0; 23763 for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) { 23764 days.appendChild(createDay(prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex)); 23765 } 23766 for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) { 23767 days.appendChild(createDay("", new Date(year, month, dayNumber), dayNumber, dayIndex)); 23768 } 23769 for (let dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth && (self2.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) { 23770 days.appendChild(createDay(nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex)); 23771 } 23772 const dayContainer = createElement("div", "dayContainer"); 23773 dayContainer.appendChild(days); 23774 return dayContainer; 23775 } 23776 function buildDays() { 23777 if (self2.daysContainer === void 0) { 23778 return; 23779 } 23780 clearNode(self2.daysContainer); 23781 if (self2.weekNumbers) 23782 clearNode(self2.weekNumbers); 23783 const frag = document.createDocumentFragment(); 23784 for (let i2 = 0; i2 < self2.config.showMonths; i2++) { 23785 const d = new Date(self2.currentYear, self2.currentMonth, 1); 23786 d.setMonth(self2.currentMonth + i2); 23787 frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth())); 23788 } 23789 self2.daysContainer.appendChild(frag); 23790 self2.days = self2.daysContainer.firstChild; 23791 if (self2.config.mode === "range" && self2.selectedDates.length === 1) { 23792 onMouseOver(); 23793 } 23794 } 23795 function buildMonthSwitch() { 23796 if (self2.config.showMonths > 1 || self2.config.monthSelectorType !== "dropdown") 23797 return; 23798 const shouldBuildMonth = function(month) { 23799 if (self2.config.minDate !== void 0 && self2.currentYear === self2.config.minDate.getFullYear() && month < self2.config.minDate.getMonth()) { 23800 return false; 23801 } 23802 return !(self2.config.maxDate !== void 0 && self2.currentYear === self2.config.maxDate.getFullYear() && month > self2.config.maxDate.getMonth()); 23803 }; 23804 self2.monthsDropdownContainer.tabIndex = -1; 23805 self2.monthsDropdownContainer.innerHTML = ""; 23806 for (let i2 = 0; i2 < 12; i2++) { 23807 if (!shouldBuildMonth(i2)) 23808 continue; 23809 const month = createElement("option", "flatpickr-monthDropdown-month"); 23810 month.value = new Date(self2.currentYear, i2).getMonth().toString(); 23811 month.textContent = monthToStr(i2, self2.config.shorthandCurrentMonth, self2.l10n); 23812 month.tabIndex = -1; 23813 if (self2.currentMonth === i2) { 23814 month.selected = true; 23815 } 23816 self2.monthsDropdownContainer.appendChild(month); 23817 } 23818 } 23819 function buildMonth() { 23820 const container = createElement("div", "flatpickr-month"); 23821 const monthNavFragment = window.document.createDocumentFragment(); 23822 let monthElement; 23823 if (self2.config.showMonths > 1 || self2.config.monthSelectorType === "static") { 23824 monthElement = createElement("span", "cur-month"); 23825 } else { 23826 self2.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months"); 23827 self2.monthsDropdownContainer.setAttribute("aria-label", self2.l10n.monthAriaLabel); 23828 bind(self2.monthsDropdownContainer, "change", (e2) => { 23829 const target = getEventTarget(e2); 23830 const selectedMonth = parseInt(target.value, 10); 23831 self2.changeMonth(selectedMonth - self2.currentMonth); 23832 triggerEvent("onMonthChange"); 23833 }); 23834 buildMonthSwitch(); 23835 monthElement = self2.monthsDropdownContainer; 23836 } 23837 const yearInput = createNumberInput("cur-year", { tabindex: "-1" }); 23838 const yearElement = yearInput.getElementsByTagName("input")[0]; 23839 yearElement.setAttribute("aria-label", self2.l10n.yearAriaLabel); 23840 if (self2.config.minDate) { 23841 yearElement.setAttribute("min", self2.config.minDate.getFullYear().toString()); 23842 } 23843 if (self2.config.maxDate) { 23844 yearElement.setAttribute("max", self2.config.maxDate.getFullYear().toString()); 23845 yearElement.disabled = !!self2.config.minDate && self2.config.minDate.getFullYear() === self2.config.maxDate.getFullYear(); 23846 } 23847 const currentMonth = createElement("div", "flatpickr-current-month"); 23848 currentMonth.appendChild(monthElement); 23849 currentMonth.appendChild(yearInput); 23850 monthNavFragment.appendChild(currentMonth); 23851 container.appendChild(monthNavFragment); 23852 return { 23853 container, 23854 yearElement, 23855 monthElement 23856 }; 23857 } 23858 function buildMonths() { 23859 clearNode(self2.monthNav); 23860 self2.monthNav.appendChild(self2.prevMonthNav); 23861 if (self2.config.showMonths) { 23862 self2.yearElements = []; 23863 self2.monthElements = []; 23864 } 23865 for (let m = self2.config.showMonths; m--; ) { 23866 const month = buildMonth(); 23867 self2.yearElements.push(month.yearElement); 23868 self2.monthElements.push(month.monthElement); 23869 self2.monthNav.appendChild(month.container); 23870 } 23871 self2.monthNav.appendChild(self2.nextMonthNav); 23872 } 23873 function buildMonthNav() { 23874 self2.monthNav = createElement("div", "flatpickr-months"); 23875 self2.yearElements = []; 23876 self2.monthElements = []; 23877 self2.prevMonthNav = createElement("span", "flatpickr-prev-month"); 23878 self2.prevMonthNav.innerHTML = self2.config.prevArrow; 23879 self2.nextMonthNav = createElement("span", "flatpickr-next-month"); 23880 self2.nextMonthNav.innerHTML = self2.config.nextArrow; 23881 buildMonths(); 23882 Object.defineProperty(self2, "_hidePrevMonthArrow", { 23883 get: () => self2.__hidePrevMonthArrow, 23884 set(bool) { 23885 if (self2.__hidePrevMonthArrow !== bool) { 23886 toggleClass(self2.prevMonthNav, "flatpickr-disabled", bool); 23887 self2.__hidePrevMonthArrow = bool; 23888 } 23889 } 23890 }); 23891 Object.defineProperty(self2, "_hideNextMonthArrow", { 23892 get: () => self2.__hideNextMonthArrow, 23893 set(bool) { 23894 if (self2.__hideNextMonthArrow !== bool) { 23895 toggleClass(self2.nextMonthNav, "flatpickr-disabled", bool); 23896 self2.__hideNextMonthArrow = bool; 23897 } 23898 } 23899 }); 23900 self2.currentYearElement = self2.yearElements[0]; 23901 updateNavigationCurrentMonth(); 23902 return self2.monthNav; 23903 } 23904 function buildTime() { 23905 self2.calendarContainer.classList.add("hasTime"); 23906 if (self2.config.noCalendar) 23907 self2.calendarContainer.classList.add("noCalendar"); 23908 const defaults2 = getDefaultHours(self2.config); 23909 self2.timeContainer = createElement("div", "flatpickr-time"); 23910 self2.timeContainer.tabIndex = -1; 23911 const separator = createElement("span", "flatpickr-time-separator", ":"); 23912 const hourInput = createNumberInput("flatpickr-hour", { 23913 "aria-label": self2.l10n.hourAriaLabel 23914 }); 23915 self2.hourElement = hourInput.getElementsByTagName("input")[0]; 23916 const minuteInput = createNumberInput("flatpickr-minute", { 23917 "aria-label": self2.l10n.minuteAriaLabel 23918 }); 23919 self2.minuteElement = minuteInput.getElementsByTagName("input")[0]; 23920 self2.hourElement.tabIndex = self2.minuteElement.tabIndex = -1; 23921 self2.hourElement.value = pad(self2.latestSelectedDateObj ? self2.latestSelectedDateObj.getHours() : self2.config.time_24hr ? defaults2.hours : military2ampm(defaults2.hours)); 23922 self2.minuteElement.value = pad(self2.latestSelectedDateObj ? self2.latestSelectedDateObj.getMinutes() : defaults2.minutes); 23923 self2.hourElement.setAttribute("step", self2.config.hourIncrement.toString()); 23924 self2.minuteElement.setAttribute("step", self2.config.minuteIncrement.toString()); 23925 self2.hourElement.setAttribute("min", self2.config.time_24hr ? "0" : "1"); 23926 self2.hourElement.setAttribute("max", self2.config.time_24hr ? "23" : "12"); 23927 self2.hourElement.setAttribute("maxlength", "2"); 23928 self2.minuteElement.setAttribute("min", "0"); 23929 self2.minuteElement.setAttribute("max", "59"); 23930 self2.minuteElement.setAttribute("maxlength", "2"); 23931 self2.timeContainer.appendChild(hourInput); 23932 self2.timeContainer.appendChild(separator); 23933 self2.timeContainer.appendChild(minuteInput); 23934 if (self2.config.time_24hr) 23935 self2.timeContainer.classList.add("time24hr"); 23936 if (self2.config.enableSeconds) { 23937 self2.timeContainer.classList.add("hasSeconds"); 23938 const secondInput = createNumberInput("flatpickr-second"); 23939 self2.secondElement = secondInput.getElementsByTagName("input")[0]; 23940 self2.secondElement.value = pad(self2.latestSelectedDateObj ? self2.latestSelectedDateObj.getSeconds() : defaults2.seconds); 23941 self2.secondElement.setAttribute("step", self2.minuteElement.getAttribute("step")); 23942 self2.secondElement.setAttribute("min", "0"); 23943 self2.secondElement.setAttribute("max", "59"); 23944 self2.secondElement.setAttribute("maxlength", "2"); 23945 self2.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":")); 23946 self2.timeContainer.appendChild(secondInput); 23947 } 23948 if (!self2.config.time_24hr) { 23949 self2.amPM = createElement("span", "flatpickr-am-pm", self2.l10n.amPM[int((self2.latestSelectedDateObj ? self2.hourElement.value : self2.config.defaultHour) > 11)]); 23950 self2.amPM.title = self2.l10n.toggleTitle; 23951 self2.amPM.tabIndex = -1; 23952 self2.timeContainer.appendChild(self2.amPM); 23953 } 23954 return self2.timeContainer; 23955 } 23956 function buildWeekdays() { 23957 if (!self2.weekdayContainer) 23958 self2.weekdayContainer = createElement("div", "flatpickr-weekdays"); 23959 else 23960 clearNode(self2.weekdayContainer); 23961 for (let i2 = self2.config.showMonths; i2--; ) { 23962 const container = createElement("div", "flatpickr-weekdaycontainer"); 23963 self2.weekdayContainer.appendChild(container); 23964 } 23965 updateWeekdays(); 23966 return self2.weekdayContainer; 23967 } 23968 function updateWeekdays() { 23969 if (!self2.weekdayContainer) { 23970 return; 23971 } 23972 const firstDayOfWeek = self2.l10n.firstDayOfWeek; 23973 let weekdays = [...self2.l10n.weekdays.shorthand]; 23974 if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) { 23975 weekdays = [ 23976 ...weekdays.splice(firstDayOfWeek, weekdays.length), 23977 ...weekdays.splice(0, firstDayOfWeek) 23978 ]; 23979 } 23980 for (let i2 = self2.config.showMonths; i2--; ) { 23981 self2.weekdayContainer.children[i2].innerHTML = ` 23982 <span class='flatpickr-weekday'> 23983 ${weekdays.join("</span><span class='flatpickr-weekday'>")} 23984 </span> 23985 `; 23986 } 23987 } 23988 function buildWeeks() { 23989 self2.calendarContainer.classList.add("hasWeeks"); 23990 const weekWrapper = createElement("div", "flatpickr-weekwrapper"); 23991 weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self2.l10n.weekAbbreviation)); 23992 const weekNumbers = createElement("div", "flatpickr-weeks"); 23993 weekWrapper.appendChild(weekNumbers); 23994 return { 23995 weekWrapper, 23996 weekNumbers 23997 }; 23998 } 23999 function changeMonth(value, isOffset = true) { 24000 const delta = isOffset ? value : value - self2.currentMonth; 24001 if (delta < 0 && self2._hidePrevMonthArrow === true || delta > 0 && self2._hideNextMonthArrow === true) 24002 return; 24003 self2.currentMonth += delta; 24004 if (self2.currentMonth < 0 || self2.currentMonth > 11) { 24005 self2.currentYear += self2.currentMonth > 11 ? 1 : -1; 24006 self2.currentMonth = (self2.currentMonth + 12) % 12; 24007 triggerEvent("onYearChange"); 24008 buildMonthSwitch(); 24009 } 24010 buildDays(); 24011 triggerEvent("onMonthChange"); 24012 updateNavigationCurrentMonth(); 24013 } 24014 function clear(triggerChangeEvent = true, toInitial = true) { 24015 self2.input.value = ""; 24016 if (self2.altInput !== void 0) 24017 self2.altInput.value = ""; 24018 if (self2.mobileInput !== void 0) 24019 self2.mobileInput.value = ""; 24020 self2.selectedDates = []; 24021 self2.latestSelectedDateObj = void 0; 24022 if (toInitial === true) { 24023 self2.currentYear = self2._initialDate.getFullYear(); 24024 self2.currentMonth = self2._initialDate.getMonth(); 24025 } 24026 if (self2.config.enableTime === true) { 24027 const { hours, minutes, seconds } = getDefaultHours(self2.config); 24028 setHours(hours, minutes, seconds); 24029 } 24030 self2.redraw(); 24031 if (triggerChangeEvent) 24032 triggerEvent("onChange"); 24033 } 24034 function close() { 24035 self2.isOpen = false; 24036 if (!self2.isMobile) { 24037 if (self2.calendarContainer !== void 0) { 24038 self2.calendarContainer.classList.remove("open"); 24039 } 24040 if (self2._input !== void 0) { 24041 self2._input.classList.remove("active"); 24042 } 24043 } 24044 triggerEvent("onClose"); 24045 } 24046 function destroy2() { 24047 if (self2.config !== void 0) 24048 triggerEvent("onDestroy"); 24049 for (let i2 = self2._handlers.length; i2--; ) { 24050 self2._handlers[i2].remove(); 24051 } 24052 self2._handlers = []; 24053 if (self2.mobileInput) { 24054 if (self2.mobileInput.parentNode) 24055 self2.mobileInput.parentNode.removeChild(self2.mobileInput); 24056 self2.mobileInput = void 0; 24057 } else if (self2.calendarContainer && self2.calendarContainer.parentNode) { 24058 if (self2.config.static && self2.calendarContainer.parentNode) { 24059 const wrapper = self2.calendarContainer.parentNode; 24060 wrapper.lastChild && wrapper.removeChild(wrapper.lastChild); 24061 if (wrapper.parentNode) { 24062 while (wrapper.firstChild) 24063 wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper); 24064 wrapper.parentNode.removeChild(wrapper); 24065 } 24066 } else 24067 self2.calendarContainer.parentNode.removeChild(self2.calendarContainer); 24068 } 24069 if (self2.altInput) { 24070 self2.input.type = "text"; 24071 if (self2.altInput.parentNode) 24072 self2.altInput.parentNode.removeChild(self2.altInput); 24073 delete self2.altInput; 24074 } 24075 if (self2.input) { 24076 self2.input.type = self2.input._type; 24077 self2.input.classList.remove("flatpickr-input"); 24078 self2.input.removeAttribute("readonly"); 24079 } 24080 [ 24081 "_showTimeInput", 24082 "latestSelectedDateObj", 24083 "_hideNextMonthArrow", 24084 "_hidePrevMonthArrow", 24085 "__hideNextMonthArrow", 24086 "__hidePrevMonthArrow", 24087 "isMobile", 24088 "isOpen", 24089 "selectedDateElem", 24090 "minDateHasTime", 24091 "maxDateHasTime", 24092 "days", 24093 "daysContainer", 24094 "_input", 24095 "_positionElement", 24096 "innerContainer", 24097 "rContainer", 24098 "monthNav", 24099 "todayDateElem", 24100 "calendarContainer", 24101 "weekdayContainer", 24102 "prevMonthNav", 24103 "nextMonthNav", 24104 "monthsDropdownContainer", 24105 "currentMonthElement", 24106 "currentYearElement", 24107 "navigationCurrentMonth", 24108 "selectedDateElem", 24109 "config" 24110 ].forEach((k) => { 24111 try { 24112 delete self2[k]; 24113 } catch (_) { 24114 } 24115 }); 24116 } 24117 function isCalendarElem(elem) { 24118 if (self2.config.appendTo && self2.config.appendTo.contains(elem)) 24119 return true; 24120 return self2.calendarContainer.contains(elem); 24121 } 24122 function documentClick(e2) { 24123 if (self2.isOpen && !self2.config.inline) { 24124 const eventTarget = getEventTarget(e2); 24125 const isCalendarElement = isCalendarElem(eventTarget); 24126 const isInput = eventTarget === self2.input || eventTarget === self2.altInput || self2.element.contains(eventTarget) || e2.path && e2.path.indexOf && (~e2.path.indexOf(self2.input) || ~e2.path.indexOf(self2.altInput)); 24127 const lostFocus = e2.type === "blur" ? isInput && e2.relatedTarget && !isCalendarElem(e2.relatedTarget) : !isInput && !isCalendarElement && !isCalendarElem(e2.relatedTarget); 24128 const isIgnored = !self2.config.ignoredFocusElements.some((elem) => elem.contains(eventTarget)); 24129 if (lostFocus && isIgnored) { 24130 if (self2.timeContainer !== void 0 && self2.minuteElement !== void 0 && self2.hourElement !== void 0 && self2.input.value !== "" && self2.input.value !== void 0) { 24131 updateTime(); 24132 } 24133 self2.close(); 24134 if (self2.config && self2.config.mode === "range" && self2.selectedDates.length === 1) { 24135 self2.clear(false); 24136 self2.redraw(); 24137 } 24138 } 24139 } 24140 } 24141 function changeYear(newYear) { 24142 if (!newYear || self2.config.minDate && newYear < self2.config.minDate.getFullYear() || self2.config.maxDate && newYear > self2.config.maxDate.getFullYear()) 24143 return; 24144 const newYearNum = newYear, isNewYear = self2.currentYear !== newYearNum; 24145 self2.currentYear = newYearNum || self2.currentYear; 24146 if (self2.config.maxDate && self2.currentYear === self2.config.maxDate.getFullYear()) { 24147 self2.currentMonth = Math.min(self2.config.maxDate.getMonth(), self2.currentMonth); 24148 } else if (self2.config.minDate && self2.currentYear === self2.config.minDate.getFullYear()) { 24149 self2.currentMonth = Math.max(self2.config.minDate.getMonth(), self2.currentMonth); 24150 } 24151 if (isNewYear) { 24152 self2.redraw(); 24153 triggerEvent("onYearChange"); 24154 buildMonthSwitch(); 24155 } 24156 } 24157 function isEnabled(date, timeless = true) { 24158 var _a; 24159 const dateToCheck = self2.parseDate(date, void 0, timeless); 24160 if (self2.config.minDate && dateToCheck && compareDates(dateToCheck, self2.config.minDate, timeless !== void 0 ? timeless : !self2.minDateHasTime) < 0 || self2.config.maxDate && dateToCheck && compareDates(dateToCheck, self2.config.maxDate, timeless !== void 0 ? timeless : !self2.maxDateHasTime) > 0) 24161 return false; 24162 if (!self2.config.enable && self2.config.disable.length === 0) 24163 return true; 24164 if (dateToCheck === void 0) 24165 return false; 24166 const bool = !!self2.config.enable, array = (_a = self2.config.enable) !== null && _a !== void 0 ? _a : self2.config.disable; 24167 for (let i2 = 0, d; i2 < array.length; i2++) { 24168 d = array[i2]; 24169 if (typeof d === "function" && d(dateToCheck)) 24170 return bool; 24171 else if (d instanceof Date && dateToCheck !== void 0 && d.getTime() === dateToCheck.getTime()) 24172 return bool; 24173 else if (typeof d === "string") { 24174 const parsed = self2.parseDate(d, void 0, true); 24175 return parsed && parsed.getTime() === dateToCheck.getTime() ? bool : !bool; 24176 } else if (typeof d === "object" && dateToCheck !== void 0 && d.from && d.to && dateToCheck.getTime() >= d.from.getTime() && dateToCheck.getTime() <= d.to.getTime()) 24177 return bool; 24178 } 24179 return !bool; 24180 } 24181 function isInView(elem) { 24182 if (self2.daysContainer !== void 0) 24183 return elem.className.indexOf("hidden") === -1 && elem.className.indexOf("flatpickr-disabled") === -1 && self2.daysContainer.contains(elem); 24184 return false; 24185 } 24186 function onBlur(e2) { 24187 const isInput = e2.target === self2._input; 24188 if (isInput && (self2.selectedDates.length > 0 || self2._input.value.length > 0) && !(e2.relatedTarget && isCalendarElem(e2.relatedTarget))) { 24189 self2.setDate(self2._input.value, true, e2.target === self2.altInput ? self2.config.altFormat : self2.config.dateFormat); 24190 } 24191 } 24192 function onKeyDown(e2) { 24193 const eventTarget = getEventTarget(e2); 24194 const isInput = self2.config.wrap ? element.contains(eventTarget) : eventTarget === self2._input; 24195 const allowInput = self2.config.allowInput; 24196 const allowKeydown = self2.isOpen && (!allowInput || !isInput); 24197 const allowInlineKeydown = self2.config.inline && isInput && !allowInput; 24198 if (e2.keyCode === 13 && isInput) { 24199 if (allowInput) { 24200 self2.setDate(self2._input.value, true, eventTarget === self2.altInput ? self2.config.altFormat : self2.config.dateFormat); 24201 return eventTarget.blur(); 24202 } else { 24203 self2.open(); 24204 } 24205 } else if (isCalendarElem(eventTarget) || allowKeydown || allowInlineKeydown) { 24206 const isTimeObj = !!self2.timeContainer && self2.timeContainer.contains(eventTarget); 24207 switch (e2.keyCode) { 24208 case 13: 24209 if (isTimeObj) { 24210 e2.preventDefault(); 24211 updateTime(); 24212 focusAndClose(); 24213 } else 24214 selectDate(e2); 24215 break; 24216 case 27: 24217 e2.preventDefault(); 24218 focusAndClose(); 24219 break; 24220 case 8: 24221 case 46: 24222 if (isInput && !self2.config.allowInput) { 24223 e2.preventDefault(); 24224 self2.clear(); 24225 } 24226 break; 24227 case 37: 24228 case 39: 24229 if (!isTimeObj && !isInput) { 24230 e2.preventDefault(); 24231 if (self2.daysContainer !== void 0 && (allowInput === false || document.activeElement && isInView(document.activeElement))) { 24232 const delta2 = e2.keyCode === 39 ? 1 : -1; 24233 if (!e2.ctrlKey) 24234 focusOnDay(void 0, delta2); 24235 else { 24236 e2.stopPropagation(); 24237 changeMonth(delta2); 24238 focusOnDay(getFirstAvailableDay(1), 0); 24239 } 24240 } 24241 } else if (self2.hourElement) 24242 self2.hourElement.focus(); 24243 break; 24244 case 38: 24245 case 40: 24246 e2.preventDefault(); 24247 const delta = e2.keyCode === 40 ? 1 : -1; 24248 if (self2.daysContainer && eventTarget.$i !== void 0 || eventTarget === self2.input || eventTarget === self2.altInput) { 24249 if (e2.ctrlKey) { 24250 e2.stopPropagation(); 24251 changeYear(self2.currentYear - delta); 24252 focusOnDay(getFirstAvailableDay(1), 0); 24253 } else if (!isTimeObj) 24254 focusOnDay(void 0, delta * 7); 24255 } else if (eventTarget === self2.currentYearElement) { 24256 changeYear(self2.currentYear - delta); 24257 } else if (self2.config.enableTime) { 24258 if (!isTimeObj && self2.hourElement) 24259 self2.hourElement.focus(); 24260 updateTime(e2); 24261 self2._debouncedChange(); 24262 } 24263 break; 24264 case 9: 24265 if (isTimeObj) { 24266 const elems = [ 24267 self2.hourElement, 24268 self2.minuteElement, 24269 self2.secondElement, 24270 self2.amPM 24271 ].concat(self2.pluginElements).filter((x) => x); 24272 const i2 = elems.indexOf(eventTarget); 24273 if (i2 !== -1) { 24274 const target = elems[i2 + (e2.shiftKey ? -1 : 1)]; 24275 e2.preventDefault(); 24276 (target || self2._input).focus(); 24277 } 24278 } else if (!self2.config.noCalendar && self2.daysContainer && self2.daysContainer.contains(eventTarget) && e2.shiftKey) { 24279 e2.preventDefault(); 24280 self2._input.focus(); 24281 } 24282 break; 24283 default: 24284 break; 24285 } 24286 } 24287 if (self2.amPM !== void 0 && eventTarget === self2.amPM) { 24288 switch (e2.key) { 24289 case self2.l10n.amPM[0].charAt(0): 24290 case self2.l10n.amPM[0].charAt(0).toLowerCase(): 24291 self2.amPM.textContent = self2.l10n.amPM[0]; 24292 setHoursFromInputs(); 24293 updateValue(); 24294 break; 24295 case self2.l10n.amPM[1].charAt(0): 24296 case self2.l10n.amPM[1].charAt(0).toLowerCase(): 24297 self2.amPM.textContent = self2.l10n.amPM[1]; 24298 setHoursFromInputs(); 24299 updateValue(); 24300 break; 24301 } 24302 } 24303 if (isInput || isCalendarElem(eventTarget)) { 24304 triggerEvent("onKeyDown", e2); 24305 } 24306 } 24307 function onMouseOver(elem) { 24308 if (self2.selectedDates.length !== 1 || elem && (!elem.classList.contains("flatpickr-day") || elem.classList.contains("flatpickr-disabled"))) 24309 return; 24310 const hoverDate = elem ? elem.dateObj.getTime() : self2.days.firstElementChild.dateObj.getTime(), initialDate = self2.parseDate(self2.selectedDates[0], void 0, true).getTime(), rangeStartDate = Math.min(hoverDate, self2.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate, self2.selectedDates[0].getTime()); 24311 let containsDisabled = false; 24312 let minRange = 0, maxRange = 0; 24313 for (let t = rangeStartDate; t < rangeEndDate; t += duration.DAY) { 24314 if (!isEnabled(new Date(t), true)) { 24315 containsDisabled = containsDisabled || t > rangeStartDate && t < rangeEndDate; 24316 if (t < initialDate && (!minRange || t > minRange)) 24317 minRange = t; 24318 else if (t > initialDate && (!maxRange || t < maxRange)) 24319 maxRange = t; 24320 } 24321 } 24322 for (let m = 0; m < self2.config.showMonths; m++) { 24323 const month = self2.daysContainer.children[m]; 24324 for (let i2 = 0, l2 = month.children.length; i2 < l2; i2++) { 24325 const dayElem = month.children[i2], date = dayElem.dateObj; 24326 const timestamp = date.getTime(); 24327 const outOfRange = minRange > 0 && timestamp < minRange || maxRange > 0 && timestamp > maxRange; 24328 if (outOfRange) { 24329 dayElem.classList.add("notAllowed"); 24330 ["inRange", "startRange", "endRange"].forEach((c) => { 24331 dayElem.classList.remove(c); 24332 }); 24333 continue; 24334 } else if (containsDisabled && !outOfRange) 24335 continue; 24336 ["startRange", "inRange", "endRange", "notAllowed"].forEach((c) => { 24337 dayElem.classList.remove(c); 24338 }); 24339 if (elem !== void 0) { 24340 elem.classList.add(hoverDate <= self2.selectedDates[0].getTime() ? "startRange" : "endRange"); 24341 if (initialDate < hoverDate && timestamp === initialDate) 24342 dayElem.classList.add("startRange"); 24343 else if (initialDate > hoverDate && timestamp === initialDate) 24344 dayElem.classList.add("endRange"); 24345 if (timestamp >= minRange && (maxRange === 0 || timestamp <= maxRange) && isBetween(timestamp, initialDate, hoverDate)) 24346 dayElem.classList.add("inRange"); 24347 } 24348 } 24349 } 24350 } 24351 function onResize() { 24352 if (self2.isOpen && !self2.config.static && !self2.config.inline) 24353 positionCalendar(); 24354 } 24355 function open(e2, positionElement = self2._positionElement) { 24356 if (self2.isMobile === true) { 24357 if (e2) { 24358 e2.preventDefault(); 24359 const eventTarget = getEventTarget(e2); 24360 if (eventTarget) { 24361 eventTarget.blur(); 24362 } 24363 } 24364 if (self2.mobileInput !== void 0) { 24365 self2.mobileInput.focus(); 24366 self2.mobileInput.click(); 24367 } 24368 triggerEvent("onOpen"); 24369 return; 24370 } else if (self2._input.disabled || self2.config.inline) { 24371 return; 24372 } 24373 const wasOpen = self2.isOpen; 24374 self2.isOpen = true; 24375 if (!wasOpen) { 24376 self2.calendarContainer.classList.add("open"); 24377 self2._input.classList.add("active"); 24378 triggerEvent("onOpen"); 24379 positionCalendar(positionElement); 24380 } 24381 if (self2.config.enableTime === true && self2.config.noCalendar === true) { 24382 if (self2.config.allowInput === false && (e2 === void 0 || !self2.timeContainer.contains(e2.relatedTarget))) { 24383 setTimeout(() => self2.hourElement.select(), 50); 24384 } 24385 } 24386 } 24387 function minMaxDateSetter(type) { 24388 return (date) => { 24389 const dateObj = self2.config[`_${type}Date`] = self2.parseDate(date, self2.config.dateFormat); 24390 const inverseDateObj = self2.config[`_${type === "min" ? "max" : "min"}Date`]; 24391 if (dateObj !== void 0) { 24392 self2[type === "min" ? "minDateHasTime" : "maxDateHasTime"] = dateObj.getHours() > 0 || dateObj.getMinutes() > 0 || dateObj.getSeconds() > 0; 24393 } 24394 if (self2.selectedDates) { 24395 self2.selectedDates = self2.selectedDates.filter((d) => isEnabled(d)); 24396 if (!self2.selectedDates.length && type === "min") 24397 setHoursFromDate(dateObj); 24398 updateValue(); 24399 } 24400 if (self2.daysContainer) { 24401 redraw(); 24402 if (dateObj !== void 0) 24403 self2.currentYearElement[type] = dateObj.getFullYear().toString(); 24404 else 24405 self2.currentYearElement.removeAttribute(type); 24406 self2.currentYearElement.disabled = !!inverseDateObj && dateObj !== void 0 && inverseDateObj.getFullYear() === dateObj.getFullYear(); 24407 } 24408 }; 24409 } 24410 function parseConfig() { 24411 const boolOpts = [ 24412 "wrap", 24413 "weekNumbers", 24414 "allowInput", 24415 "allowInvalidPreload", 24416 "clickOpens", 24417 "time_24hr", 24418 "enableTime", 24419 "noCalendar", 24420 "altInput", 24421 "shorthandCurrentMonth", 24422 "inline", 24423 "static", 24424 "enableSeconds", 24425 "disableMobile" 24426 ]; 24427 const userConfig = Object.assign(Object.assign({}, JSON.parse(JSON.stringify(element.dataset || {}))), instanceConfig); 24428 const formats2 = {}; 24429 self2.config.parseDate = userConfig.parseDate; 24430 self2.config.formatDate = userConfig.formatDate; 24431 Object.defineProperty(self2.config, "enable", { 24432 get: () => self2.config._enable, 24433 set: (dates) => { 24434 self2.config._enable = parseDateRules(dates); 24435 } 24436 }); 24437 Object.defineProperty(self2.config, "disable", { 24438 get: () => self2.config._disable, 24439 set: (dates) => { 24440 self2.config._disable = parseDateRules(dates); 24441 } 24442 }); 24443 const timeMode = userConfig.mode === "time"; 24444 if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) { 24445 const defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat; 24446 formats2.dateFormat = userConfig.noCalendar || timeMode ? "H:i" + (userConfig.enableSeconds ? ":S" : "") : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : ""); 24447 } 24448 if (userConfig.altInput && (userConfig.enableTime || timeMode) && !userConfig.altFormat) { 24449 const defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat; 24450 formats2.altFormat = userConfig.noCalendar || timeMode ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K") : defaultAltFormat + ` h:i${userConfig.enableSeconds ? ":S" : ""} K`; 24451 } 24452 Object.defineProperty(self2.config, "minDate", { 24453 get: () => self2.config._minDate, 24454 set: minMaxDateSetter("min") 24455 }); 24456 Object.defineProperty(self2.config, "maxDate", { 24457 get: () => self2.config._maxDate, 24458 set: minMaxDateSetter("max") 24459 }); 24460 const minMaxTimeSetter = (type) => (val) => { 24461 self2.config[type === "min" ? "_minTime" : "_maxTime"] = self2.parseDate(val, "H:i:S"); 24462 }; 24463 Object.defineProperty(self2.config, "minTime", { 24464 get: () => self2.config._minTime, 24465 set: minMaxTimeSetter("min") 24466 }); 24467 Object.defineProperty(self2.config, "maxTime", { 24468 get: () => self2.config._maxTime, 24469 set: minMaxTimeSetter("max") 24470 }); 24471 if (userConfig.mode === "time") { 24472 self2.config.noCalendar = true; 24473 self2.config.enableTime = true; 24474 } 24475 Object.assign(self2.config, formats2, userConfig); 24476 for (let i2 = 0; i2 < boolOpts.length; i2++) 24477 self2.config[boolOpts[i2]] = self2.config[boolOpts[i2]] === true || self2.config[boolOpts[i2]] === "true"; 24478 HOOKS.filter((hook) => self2.config[hook] !== void 0).forEach((hook) => { 24479 self2.config[hook] = arrayify(self2.config[hook] || []).map(bindToInstance); 24480 }); 24481 self2.isMobile = !self2.config.disableMobile && !self2.config.inline && self2.config.mode === "single" && !self2.config.disable.length && !self2.config.enable && !self2.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); 24482 for (let i2 = 0; i2 < self2.config.plugins.length; i2++) { 24483 const pluginConf = self2.config.plugins[i2](self2) || {}; 24484 for (const key in pluginConf) { 24485 if (HOOKS.indexOf(key) > -1) { 24486 self2.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self2.config[key]); 24487 } else if (typeof userConfig[key] === "undefined") 24488 self2.config[key] = pluginConf[key]; 24489 } 24490 } 24491 if (!userConfig.altInputClass) { 24492 self2.config.altInputClass = getInputElem().className + " " + self2.config.altInputClass; 24493 } 24494 triggerEvent("onParseConfig"); 24495 } 24496 function getInputElem() { 24497 return self2.config.wrap ? element.querySelector("[data-input]") : element; 24498 } 24499 function setupLocale() { 24500 if (typeof self2.config.locale !== "object" && typeof flatpickr.l10ns[self2.config.locale] === "undefined") 24501 self2.config.errorHandler(new Error(`flatpickr: invalid locale ${self2.config.locale}`)); 24502 self2.l10n = Object.assign(Object.assign({}, flatpickr.l10ns.default), typeof self2.config.locale === "object" ? self2.config.locale : self2.config.locale !== "default" ? flatpickr.l10ns[self2.config.locale] : void 0); 24503 tokenRegex.K = `(${self2.l10n.amPM[0]}|${self2.l10n.amPM[1]}|${self2.l10n.amPM[0].toLowerCase()}|${self2.l10n.amPM[1].toLowerCase()})`; 24504 const userConfig = Object.assign(Object.assign({}, instanceConfig), JSON.parse(JSON.stringify(element.dataset || {}))); 24505 if (userConfig.time_24hr === void 0 && flatpickr.defaultConfig.time_24hr === void 0) { 24506 self2.config.time_24hr = self2.l10n.time_24hr; 24507 } 24508 self2.formatDate = createDateFormatter(self2); 24509 self2.parseDate = createDateParser({ config: self2.config, l10n: self2.l10n }); 24510 } 24511 function positionCalendar(customPositionElement) { 24512 if (typeof self2.config.position === "function") { 24513 return void self2.config.position(self2, customPositionElement); 24514 } 24515 if (self2.calendarContainer === void 0) 24516 return; 24517 triggerEvent("onPreCalendarPosition"); 24518 const positionElement = customPositionElement || self2._positionElement; 24519 const calendarHeight = Array.prototype.reduce.call(self2.calendarContainer.children, (acc, child) => acc + child.offsetHeight, 0), calendarWidth = self2.calendarContainer.offsetWidth, configPos = self2.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPosVertical === "above" || configPosVertical !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight; 24520 const top2 = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2); 24521 toggleClass(self2.calendarContainer, "arrowTop", !showOnTop); 24522 toggleClass(self2.calendarContainer, "arrowBottom", showOnTop); 24523 if (self2.config.inline) 24524 return; 24525 let left2 = window.pageXOffset + inputBounds.left; 24526 let isCenter = false; 24527 let isRight = false; 24528 if (configPosHorizontal === "center") { 24529 left2 -= (calendarWidth - inputBounds.width) / 2; 24530 isCenter = true; 24531 } else if (configPosHorizontal === "right") { 24532 left2 -= calendarWidth - inputBounds.width; 24533 isRight = true; 24534 } 24535 toggleClass(self2.calendarContainer, "arrowLeft", !isCenter && !isRight); 24536 toggleClass(self2.calendarContainer, "arrowCenter", isCenter); 24537 toggleClass(self2.calendarContainer, "arrowRight", isRight); 24538 const right2 = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right); 24539 const rightMost = left2 + calendarWidth > window.document.body.offsetWidth; 24540 const centerMost = right2 + calendarWidth > window.document.body.offsetWidth; 24541 toggleClass(self2.calendarContainer, "rightMost", rightMost); 24542 if (self2.config.static) 24543 return; 24544 self2.calendarContainer.style.top = `${top2}px`; 24545 if (!rightMost) { 24546 self2.calendarContainer.style.left = `${left2}px`; 24547 self2.calendarContainer.style.right = "auto"; 24548 } else if (!centerMost) { 24549 self2.calendarContainer.style.left = "auto"; 24550 self2.calendarContainer.style.right = `${right2}px`; 24551 } else { 24552 const doc = getDocumentStyleSheet(); 24553 if (doc === void 0) 24554 return; 24555 const bodyWidth = window.document.body.offsetWidth; 24556 const centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2); 24557 const centerBefore = ".flatpickr-calendar.centerMost:before"; 24558 const centerAfter = ".flatpickr-calendar.centerMost:after"; 24559 const centerIndex = doc.cssRules.length; 24560 const centerStyle = `{left:${inputBounds.left}px;right:auto;}`; 24561 toggleClass(self2.calendarContainer, "rightMost", false); 24562 toggleClass(self2.calendarContainer, "centerMost", true); 24563 doc.insertRule(`${centerBefore},${centerAfter}${centerStyle}`, centerIndex); 24564 self2.calendarContainer.style.left = `${centerLeft}px`; 24565 self2.calendarContainer.style.right = "auto"; 24566 } 24567 } 24568 function getDocumentStyleSheet() { 24569 let editableSheet = null; 24570 for (let i2 = 0; i2 < document.styleSheets.length; i2++) { 24571 const sheet = document.styleSheets[i2]; 24572 try { 24573 sheet.cssRules; 24574 } catch (err) { 24575 continue; 24576 } 24577 editableSheet = sheet; 24578 break; 24579 } 24580 return editableSheet != null ? editableSheet : createStyleSheet(); 24581 } 24582 function createStyleSheet() { 24583 const style = document.createElement("style"); 24584 document.head.appendChild(style); 24585 return style.sheet; 24586 } 24587 function redraw() { 24588 if (self2.config.noCalendar || self2.isMobile) 24589 return; 24590 buildMonthSwitch(); 24591 updateNavigationCurrentMonth(); 24592 buildDays(); 24593 } 24594 function focusAndClose() { 24595 self2._input.focus(); 24596 if (window.navigator.userAgent.indexOf("MSIE") !== -1 || navigator.msMaxTouchPoints !== void 0) { 24597 setTimeout(self2.close, 0); 24598 } else { 24599 self2.close(); 24600 } 24601 } 24602 function selectDate(e2) { 24603 e2.preventDefault(); 24604 e2.stopPropagation(); 24605 const isSelectable = (day) => day.classList && day.classList.contains("flatpickr-day") && !day.classList.contains("flatpickr-disabled") && !day.classList.contains("notAllowed"); 24606 const t = findParent(getEventTarget(e2), isSelectable); 24607 if (t === void 0) 24608 return; 24609 const target = t; 24610 const selectedDate = self2.latestSelectedDateObj = new Date(target.dateObj.getTime()); 24611 const shouldChangeMonth = (selectedDate.getMonth() < self2.currentMonth || selectedDate.getMonth() > self2.currentMonth + self2.config.showMonths - 1) && self2.config.mode !== "range"; 24612 self2.selectedDateElem = target; 24613 if (self2.config.mode === "single") 24614 self2.selectedDates = [selectedDate]; 24615 else if (self2.config.mode === "multiple") { 24616 const selectedIndex = isDateSelected(selectedDate); 24617 if (selectedIndex) 24618 self2.selectedDates.splice(parseInt(selectedIndex), 1); 24619 else 24620 self2.selectedDates.push(selectedDate); 24621 } else if (self2.config.mode === "range") { 24622 if (self2.selectedDates.length === 2) { 24623 self2.clear(false, false); 24624 } 24625 self2.latestSelectedDateObj = selectedDate; 24626 self2.selectedDates.push(selectedDate); 24627 if (compareDates(selectedDate, self2.selectedDates[0], true) !== 0) 24628 self2.selectedDates.sort((a2, b) => a2.getTime() - b.getTime()); 24629 } 24630 setHoursFromInputs(); 24631 if (shouldChangeMonth) { 24632 const isNewYear = self2.currentYear !== selectedDate.getFullYear(); 24633 self2.currentYear = selectedDate.getFullYear(); 24634 self2.currentMonth = selectedDate.getMonth(); 24635 if (isNewYear) { 24636 triggerEvent("onYearChange"); 24637 buildMonthSwitch(); 24638 } 24639 triggerEvent("onMonthChange"); 24640 } 24641 updateNavigationCurrentMonth(); 24642 buildDays(); 24643 updateValue(); 24644 if (!shouldChangeMonth && self2.config.mode !== "range" && self2.config.showMonths === 1) 24645 focusOnDayElem(target); 24646 else if (self2.selectedDateElem !== void 0 && self2.hourElement === void 0) { 24647 self2.selectedDateElem && self2.selectedDateElem.focus(); 24648 } 24649 if (self2.hourElement !== void 0) 24650 self2.hourElement !== void 0 && self2.hourElement.focus(); 24651 if (self2.config.closeOnSelect) { 24652 const single = self2.config.mode === "single" && !self2.config.enableTime; 24653 const range = self2.config.mode === "range" && self2.selectedDates.length === 2 && !self2.config.enableTime; 24654 if (single || range) { 24655 focusAndClose(); 24656 } 24657 } 24658 triggerChange(); 24659 } 24660 const CALLBACKS = { 24661 locale: [setupLocale, updateWeekdays], 24662 showMonths: [buildMonths, setCalendarWidth, buildWeekdays], 24663 minDate: [jumpToDate], 24664 maxDate: [jumpToDate], 24665 clickOpens: [ 24666 () => { 24667 if (self2.config.clickOpens === true) { 24668 bind(self2._input, "focus", self2.open); 24669 bind(self2._input, "click", self2.open); 24670 } else { 24671 self2._input.removeEventListener("focus", self2.open); 24672 self2._input.removeEventListener("click", self2.open); 24673 } 24674 } 24675 ] 24676 }; 24677 function set(option, value) { 24678 if (option !== null && typeof option === "object") { 24679 Object.assign(self2.config, option); 24680 for (const key in option) { 24681 if (CALLBACKS[key] !== void 0) 24682 CALLBACKS[key].forEach((x) => x()); 24683 } 24684 } else { 24685 self2.config[option] = value; 24686 if (CALLBACKS[option] !== void 0) 24687 CALLBACKS[option].forEach((x) => x()); 24688 else if (HOOKS.indexOf(option) > -1) 24689 self2.config[option] = arrayify(value); 24690 } 24691 self2.redraw(); 24692 updateValue(true); 24693 } 24694 function setSelectedDate(inputDate, format2) { 24695 let dates = []; 24696 if (inputDate instanceof Array) 24697 dates = inputDate.map((d) => self2.parseDate(d, format2)); 24698 else if (inputDate instanceof Date || typeof inputDate === "number") 24699 dates = [self2.parseDate(inputDate, format2)]; 24700 else if (typeof inputDate === "string") { 24701 switch (self2.config.mode) { 24702 case "single": 24703 case "time": 24704 dates = [self2.parseDate(inputDate, format2)]; 24705 break; 24706 case "multiple": 24707 dates = inputDate.split(self2.config.conjunction).map((date) => self2.parseDate(date, format2)); 24708 break; 24709 case "range": 24710 dates = inputDate.split(self2.l10n.rangeSeparator).map((date) => self2.parseDate(date, format2)); 24711 break; 24712 default: 24713 break; 24714 } 24715 } else 24716 self2.config.errorHandler(new Error(`Invalid date supplied: ${JSON.stringify(inputDate)}`)); 24717 self2.selectedDates = self2.config.allowInvalidPreload ? dates : dates.filter((d) => d instanceof Date && isEnabled(d, false)); 24718 if (self2.config.mode === "range") 24719 self2.selectedDates.sort((a2, b) => a2.getTime() - b.getTime()); 24720 } 24721 function setDate(date, triggerChange2 = false, format2 = self2.config.dateFormat) { 24722 if (date !== 0 && !date || date instanceof Array && date.length === 0) 24723 return self2.clear(triggerChange2); 24724 setSelectedDate(date, format2); 24725 self2.latestSelectedDateObj = self2.selectedDates[self2.selectedDates.length - 1]; 24726 self2.redraw(); 24727 jumpToDate(void 0, triggerChange2); 24728 setHoursFromDate(); 24729 if (self2.selectedDates.length === 0) { 24730 self2.clear(false); 24731 } 24732 updateValue(triggerChange2); 24733 if (triggerChange2) 24734 triggerEvent("onChange"); 24735 } 24736 function parseDateRules(arr) { 24737 return arr.slice().map((rule) => { 24738 if (typeof rule === "string" || typeof rule === "number" || rule instanceof Date) { 24739 return self2.parseDate(rule, void 0, true); 24740 } else if (rule && typeof rule === "object" && rule.from && rule.to) 24741 return { 24742 from: self2.parseDate(rule.from, void 0), 24743 to: self2.parseDate(rule.to, void 0) 24744 }; 24745 return rule; 24746 }).filter((x) => x); 24747 } 24748 function setupDates() { 24749 self2.selectedDates = []; 24750 self2.now = self2.parseDate(self2.config.now) || new Date(); 24751 const preloadedDate = self2.config.defaultDate || ((self2.input.nodeName === "INPUT" || self2.input.nodeName === "TEXTAREA") && self2.input.placeholder && self2.input.value === self2.input.placeholder ? null : self2.input.value); 24752 if (preloadedDate) 24753 setSelectedDate(preloadedDate, self2.config.dateFormat); 24754 self2._initialDate = self2.selectedDates.length > 0 ? self2.selectedDates[0] : self2.config.minDate && self2.config.minDate.getTime() > self2.now.getTime() ? self2.config.minDate : self2.config.maxDate && self2.config.maxDate.getTime() < self2.now.getTime() ? self2.config.maxDate : self2.now; 24755 self2.currentYear = self2._initialDate.getFullYear(); 24756 self2.currentMonth = self2._initialDate.getMonth(); 24757 if (self2.selectedDates.length > 0) 24758 self2.latestSelectedDateObj = self2.selectedDates[0]; 24759 if (self2.config.minTime !== void 0) 24760 self2.config.minTime = self2.parseDate(self2.config.minTime, "H:i"); 24761 if (self2.config.maxTime !== void 0) 24762 self2.config.maxTime = self2.parseDate(self2.config.maxTime, "H:i"); 24763 self2.minDateHasTime = !!self2.config.minDate && (self2.config.minDate.getHours() > 0 || self2.config.minDate.getMinutes() > 0 || self2.config.minDate.getSeconds() > 0); 24764 self2.maxDateHasTime = !!self2.config.maxDate && (self2.config.maxDate.getHours() > 0 || self2.config.maxDate.getMinutes() > 0 || self2.config.maxDate.getSeconds() > 0); 24765 } 24766 function setupInputs() { 24767 self2.input = getInputElem(); 24768 if (!self2.input) { 24769 self2.config.errorHandler(new Error("Invalid input element specified")); 24770 return; 24771 } 24772 self2.input._type = self2.input.type; 24773 self2.input.type = "text"; 24774 self2.input.classList.add("flatpickr-input"); 24775 self2._input = self2.input; 24776 if (self2.config.altInput) { 24777 self2.altInput = createElement(self2.input.nodeName, self2.config.altInputClass); 24778 self2._input = self2.altInput; 24779 self2.altInput.placeholder = self2.input.placeholder; 24780 self2.altInput.disabled = self2.input.disabled; 24781 self2.altInput.required = self2.input.required; 24782 self2.altInput.tabIndex = self2.input.tabIndex; 24783 self2.altInput.type = "text"; 24784 self2.input.setAttribute("type", "hidden"); 24785 if (!self2.config.static && self2.input.parentNode) 24786 self2.input.parentNode.insertBefore(self2.altInput, self2.input.nextSibling); 24787 } 24788 if (!self2.config.allowInput) 24789 self2._input.setAttribute("readonly", "readonly"); 24790 self2._positionElement = self2.config.positionElement || self2._input; 24791 } 24792 function setupMobile() { 24793 const inputType = self2.config.enableTime ? self2.config.noCalendar ? "time" : "datetime-local" : "date"; 24794 self2.mobileInput = createElement("input", self2.input.className + " flatpickr-mobile"); 24795 self2.mobileInput.tabIndex = 1; 24796 self2.mobileInput.type = inputType; 24797 self2.mobileInput.disabled = self2.input.disabled; 24798 self2.mobileInput.required = self2.input.required; 24799 self2.mobileInput.placeholder = self2.input.placeholder; 24800 self2.mobileFormatStr = inputType === "datetime-local" ? "Y-m-d\\TH:i:S" : inputType === "date" ? "Y-m-d" : "H:i:S"; 24801 if (self2.selectedDates.length > 0) { 24802 self2.mobileInput.defaultValue = self2.mobileInput.value = self2.formatDate(self2.selectedDates[0], self2.mobileFormatStr); 24803 } 24804 if (self2.config.minDate) 24805 self2.mobileInput.min = self2.formatDate(self2.config.minDate, "Y-m-d"); 24806 if (self2.config.maxDate) 24807 self2.mobileInput.max = self2.formatDate(self2.config.maxDate, "Y-m-d"); 24808 if (self2.input.getAttribute("step")) 24809 self2.mobileInput.step = String(self2.input.getAttribute("step")); 24810 self2.input.type = "hidden"; 24811 if (self2.altInput !== void 0) 24812 self2.altInput.type = "hidden"; 24813 try { 24814 if (self2.input.parentNode) 24815 self2.input.parentNode.insertBefore(self2.mobileInput, self2.input.nextSibling); 24816 } catch (_a) { 24817 } 24818 bind(self2.mobileInput, "change", (e2) => { 24819 self2.setDate(getEventTarget(e2).value, false, self2.mobileFormatStr); 24820 triggerEvent("onChange"); 24821 triggerEvent("onClose"); 24822 }); 24823 } 24824 function toggle(e2) { 24825 if (self2.isOpen === true) 24826 return self2.close(); 24827 self2.open(e2); 24828 } 24829 function triggerEvent(event, data) { 24830 if (self2.config === void 0) 24831 return; 24832 const hooks = self2.config[event]; 24833 if (hooks !== void 0 && hooks.length > 0) { 24834 for (let i2 = 0; hooks[i2] && i2 < hooks.length; i2++) 24835 hooks[i2](self2.selectedDates, self2.input.value, self2, data); 24836 } 24837 if (event === "onChange") { 24838 self2.input.dispatchEvent(createEvent("change")); 24839 self2.input.dispatchEvent(createEvent("input")); 24840 } 24841 } 24842 function createEvent(name) { 24843 const e2 = document.createEvent("Event"); 24844 e2.initEvent(name, true, true); 24845 return e2; 24846 } 24847 function isDateSelected(date) { 24848 for (let i2 = 0; i2 < self2.selectedDates.length; i2++) { 24849 if (compareDates(self2.selectedDates[i2], date) === 0) 24850 return "" + i2; 24851 } 24852 return false; 24853 } 24854 function isDateInRange(date) { 24855 if (self2.config.mode !== "range" || self2.selectedDates.length < 2) 24856 return false; 24857 return compareDates(date, self2.selectedDates[0]) >= 0 && compareDates(date, self2.selectedDates[1]) <= 0; 24858 } 24859 function updateNavigationCurrentMonth() { 24860 if (self2.config.noCalendar || self2.isMobile || !self2.monthNav) 24861 return; 24862 self2.yearElements.forEach((yearElement, i2) => { 24863 const d = new Date(self2.currentYear, self2.currentMonth, 1); 24864 d.setMonth(self2.currentMonth + i2); 24865 if (self2.config.showMonths > 1 || self2.config.monthSelectorType === "static") { 24866 self2.monthElements[i2].textContent = monthToStr(d.getMonth(), self2.config.shorthandCurrentMonth, self2.l10n) + " "; 24867 } else { 24868 self2.monthsDropdownContainer.value = d.getMonth().toString(); 24869 } 24870 yearElement.value = d.getFullYear().toString(); 24871 }); 24872 self2._hidePrevMonthArrow = self2.config.minDate !== void 0 && (self2.currentYear === self2.config.minDate.getFullYear() ? self2.currentMonth <= self2.config.minDate.getMonth() : self2.currentYear < self2.config.minDate.getFullYear()); 24873 self2._hideNextMonthArrow = self2.config.maxDate !== void 0 && (self2.currentYear === self2.config.maxDate.getFullYear() ? self2.currentMonth + 1 > self2.config.maxDate.getMonth() : self2.currentYear > self2.config.maxDate.getFullYear()); 24874 } 24875 function getDateStr(format2) { 24876 return self2.selectedDates.map((dObj) => self2.formatDate(dObj, format2)).filter((d, i2, arr) => self2.config.mode !== "range" || self2.config.enableTime || arr.indexOf(d) === i2).join(self2.config.mode !== "range" ? self2.config.conjunction : self2.l10n.rangeSeparator); 24877 } 24878 function updateValue(triggerChange2 = true) { 24879 if (self2.mobileInput !== void 0 && self2.mobileFormatStr) { 24880 self2.mobileInput.value = self2.latestSelectedDateObj !== void 0 ? self2.formatDate(self2.latestSelectedDateObj, self2.mobileFormatStr) : ""; 24881 } 24882 self2.input.value = getDateStr(self2.config.dateFormat); 24883 if (self2.altInput !== void 0) { 24884 self2.altInput.value = getDateStr(self2.config.altFormat); 24885 } 24886 if (triggerChange2 !== false) 24887 triggerEvent("onValueUpdate"); 24888 } 24889 function onMonthNavClick(e2) { 24890 const eventTarget = getEventTarget(e2); 24891 const isPrevMonth = self2.prevMonthNav.contains(eventTarget); 24892 const isNextMonth = self2.nextMonthNav.contains(eventTarget); 24893 if (isPrevMonth || isNextMonth) { 24894 changeMonth(isPrevMonth ? -1 : 1); 24895 } else if (self2.yearElements.indexOf(eventTarget) >= 0) { 24896 eventTarget.select(); 24897 } else if (eventTarget.classList.contains("arrowUp")) { 24898 self2.changeYear(self2.currentYear + 1); 24899 } else if (eventTarget.classList.contains("arrowDown")) { 24900 self2.changeYear(self2.currentYear - 1); 24901 } 24902 } 24903 function timeWrapper(e2) { 24904 e2.preventDefault(); 24905 const isKeyDown = e2.type === "keydown", eventTarget = getEventTarget(e2), input = eventTarget; 24906 if (self2.amPM !== void 0 && eventTarget === self2.amPM) { 24907 self2.amPM.textContent = self2.l10n.amPM[int(self2.amPM.textContent === self2.l10n.amPM[0])]; 24908 } 24909 const min2 = parseFloat(input.getAttribute("min")), max2 = parseFloat(input.getAttribute("max")), step = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e2.delta || (isKeyDown ? e2.which === 38 ? 1 : -1 : 0); 24910 let newValue = curValue + step * delta; 24911 if (typeof input.value !== "undefined" && input.value.length === 2) { 24912 const isHourElem = input === self2.hourElement, isMinuteElem = input === self2.minuteElement; 24913 if (newValue < min2) { 24914 newValue = max2 + newValue + int(!isHourElem) + (int(isHourElem) && int(!self2.amPM)); 24915 if (isMinuteElem) 24916 incrementNumInput(void 0, -1, self2.hourElement); 24917 } else if (newValue > max2) { 24918 newValue = input === self2.hourElement ? newValue - max2 - int(!self2.amPM) : min2; 24919 if (isMinuteElem) 24920 incrementNumInput(void 0, 1, self2.hourElement); 24921 } 24922 if (self2.amPM && isHourElem && (step === 1 ? newValue + curValue === 23 : Math.abs(newValue - curValue) > step)) { 24923 self2.amPM.textContent = self2.l10n.amPM[int(self2.amPM.textContent === self2.l10n.amPM[0])]; 24924 } 24925 input.value = pad(newValue); 24926 } 24927 } 24928 init2(); 24929 return self2; 24930 } 24931 function _flatpickr(nodeList, config) { 24932 const nodes = Array.prototype.slice.call(nodeList).filter((x) => x instanceof HTMLElement); 24933 const instances = []; 24934 for (let i2 = 0; i2 < nodes.length; i2++) { 24935 const node = nodes[i2]; 24936 try { 24937 if (node.getAttribute("data-fp-omit") !== null) 24938 continue; 24939 if (node._flatpickr !== void 0) { 24940 node._flatpickr.destroy(); 24941 node._flatpickr = void 0; 24942 } 24943 node._flatpickr = FlatpickrInstance(node, config || {}); 24944 instances.push(node._flatpickr); 24945 } catch (e2) { 24946 console.error(e2); 24947 } 24948 } 24949 return instances.length === 1 ? instances[0] : instances; 24950 } 24951 if (typeof HTMLElement !== "undefined" && typeof HTMLCollection !== "undefined" && typeof NodeList !== "undefined") { 24952 HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function(config) { 24953 return _flatpickr(this, config); 24954 }; 24955 HTMLElement.prototype.flatpickr = function(config) { 24956 return _flatpickr([this], config); 24957 }; 24958 } 24959 var flatpickr = function(selector, config) { 24960 if (typeof selector === "string") { 24961 return _flatpickr(window.document.querySelectorAll(selector), config); 24962 } else if (selector instanceof Node) { 24963 return _flatpickr([selector], config); 24964 } else { 24965 return _flatpickr(selector, config); 24966 } 24967 }; 24968 flatpickr.defaultConfig = {}; 24969 flatpickr.l10ns = { 24970 en: Object.assign({}, default_default), 24971 default: Object.assign({}, default_default) 24972 }; 24973 flatpickr.localize = (l10n) => { 24974 flatpickr.l10ns.default = Object.assign(Object.assign({}, flatpickr.l10ns.default), l10n); 24975 }; 24976 flatpickr.setDefaults = (config) => { 24977 flatpickr.defaultConfig = Object.assign(Object.assign({}, flatpickr.defaultConfig), config); 24978 }; 24979 flatpickr.parseDate = createDateParser({}); 24980 flatpickr.formatDate = createDateFormatter({}); 24981 flatpickr.compareDates = compareDates; 24982 if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") { 24983 jQuery.fn.flatpickr = function(config) { 24984 return _flatpickr(this, config); 24985 }; 24986 } 24987 Date.prototype.fp_incr = function(days) { 24988 return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days)); 24989 }; 24990 if (typeof window !== "undefined") { 24991 window.flatpickr = flatpickr; 24992 } 24993 var esm_default = flatpickr; 24994 24995
vendor: 21,832 bytes, lines 24995-25691
24995// ../../node_modules/stimulus-flatpickr/dist/index.m.js 24996 function _classCallCheck(instance, Constructor) { 24997 if (!(instance instanceof Constructor)) { 24998 throw new TypeError("Cannot call a class as a function"); 24999 } 25000 } 25001 function _defineProperties(target, props) { 25002 for (var i2 = 0; i2 < props.length; i2++) { 25003 var descriptor = props[i2]; 25004 descriptor.enumerable = descriptor.enumerable || false; 25005 descriptor.configurable = true; 25006 if ("value" in descriptor) 25007 descriptor.writable = true; 25008 Object.defineProperty(target, descriptor.key, descriptor); 25009 } 25010 } 25011 function _createClass(Constructor, protoProps, staticProps) { 25012 if (protoProps) 25013 _defineProperties(Constructor.prototype, protoProps); 25014 if (staticProps) 25015 _defineProperties(Constructor, staticProps); 25016 return Constructor; 25017 } 25018 function _defineProperty(obj, key, value) { 25019 if (key in obj) { 25020 Object.defineProperty(obj, key, { 25021 value, 25022 enumerable: true, 25023 configurable: true, 25024 writable: true 25025 }); 25026 } else { 25027 obj[key] = value; 25028 } 25029 return obj; 25030 } 25031 function ownKeys(object, enumerableOnly) { 25032 var keys = Object.keys(object); 25033 if (Object.getOwnPropertySymbols) { 25034 var symbols = Object.getOwnPropertySymbols(object); 25035 if (enumerableOnly) 25036 symbols = symbols.filter(function(sym) { 25037 return Object.getOwnPropertyDescriptor(object, sym).enumerable; 25038 }); 25039 keys.push.apply(keys, symbols); 25040 } 25041 return keys; 25042 } 25043 function _objectSpread2(target) { 25044 for (var i2 = 1; i2 < arguments.length; i2++) { 25045 var source = arguments[i2] != null ? arguments[i2] : {}; 25046 if (i2 % 2) { 25047 ownKeys(Object(source), true).forEach(function(key) { 25048 _defineProperty(target, key, source[key]); 25049 }); 25050 } else if (Object.getOwnPropertyDescriptors) { 25051 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); 25052 } else { 25053 ownKeys(Object(source)).forEach(function(key) { 25054 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); 25055 }); 25056 } 25057 } 25058 return target; 25059 } 25060 function _inherits(subClass, superClass) { 25061 if (typeof superClass !== "function" && superClass !== null) { 25062 throw new TypeError("Super expression must either be null or a function"); 25063 } 25064 subClass.prototype = Object.create(superClass && superClass.prototype, { 25065 constructor: { 25066 value: subClass, 25067 writable: true, 25068 configurable: true 25069 } 25070 }); 25071 if (superClass) 25072 _setPrototypeOf(subClass, superClass); 25073 } 25074 function _getPrototypeOf(o2) { 25075 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o3) { 25076 return o3.__proto__ || Object.getPrototypeOf(o3); 25077 }; 25078 return _getPrototypeOf(o2); 25079 } 25080 function _setPrototypeOf(o2, p) { 25081 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o3, p2) { 25082 o3.__proto__ = p2; 25083 return o3; 25084 }; 25085 return _setPrototypeOf(o2, p); 25086 } 25087 function _isNativeReflectConstruct() { 25088 if (typeof Reflect === "undefined" || !Reflect.construct) 25089 return false; 25090 if (Reflect.construct.sham) 25091 return false; 25092 if (typeof Proxy === "function") 25093 return true; 25094 try { 25095 Date.prototype.toString.call(Reflect.construct(Date, [], function() { 25096 })); 25097 return true; 25098 } catch (e2) { 25099 return false; 25100 } 25101 } 25102 function _assertThisInitialized(self2) { 25103 if (self2 === void 0) { 25104 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 25105 } 25106 return self2; 25107 } 25108 function _possibleConstructorReturn(self2, call) { 25109 if (call && (typeof call === "object" || typeof call === "function")) { 25110 return call; 25111 } 25112 return _assertThisInitialized(self2); 25113 } 25114 function _createSuper(Derived) { 25115 return function() { 25116 var Super = _getPrototypeOf(Derived), result; 25117 if (_isNativeReflectConstruct()) { 25118 var NewTarget = _getPrototypeOf(this).constructor; 25119 result = Reflect.construct(Super, arguments, NewTarget); 25120 } else { 25121 result = Super.apply(this, arguments); 25122 } 25123 return _possibleConstructorReturn(this, result); 25124 }; 25125 } 25126 function camelize2(value) { 25127 return value.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase()); 25128 } 25129 function capitalize2(value) { 25130 return value.charAt(0).toUpperCase() + value.slice(1); 25131 } 25132 function dasherize2(value) { 25133 return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`); 25134 } 25135 function readInheritableStaticArrayValues2(constructor, propertyName) { 25136 const ancestors = getAncestorsForConstructor2(constructor); 25137 return Array.from(ancestors.reduce((values, constructor2) => { 25138 getOwnStaticArrayValues2(constructor2, propertyName).forEach((name) => values.add(name)); 25139 return values; 25140 }, /* @__PURE__ */ new Set())); 25141 } 25142 function readInheritableStaticObjectPairs2(constructor, propertyName) { 25143 const ancestors = getAncestorsForConstructor2(constructor); 25144 return ancestors.reduce((pairs, constructor2) => { 25145 pairs.push(...getOwnStaticObjectPairs2(constructor2, propertyName)); 25146 return pairs; 25147 }, []); 25148 } 25149 function getAncestorsForConstructor2(constructor) { 25150 const ancestors = []; 25151 while (constructor) { 25152 ancestors.push(constructor); 25153 constructor = Object.getPrototypeOf(constructor); 25154 } 25155 return ancestors.reverse(); 25156 } 25157 function getOwnStaticArrayValues2(constructor, propertyName) { 25158 const definition = constructor[propertyName]; 25159 return Array.isArray(definition) ? definition : []; 25160 } 25161 function getOwnStaticObjectPairs2(constructor, propertyName) { 25162 const definition = constructor[propertyName]; 25163 return definition ? Object.keys(definition).map((key) => [key, definition[key]]) : []; 25164 } 25165 var extend4 = (() => { 25166 function extendWithReflect(constructor) { 25167 function extended() { 25168 return Reflect.construct(constructor, arguments, new.target); 25169 } 25170 extended.prototype = Object.create(constructor.prototype, { 25171 constructor: { 25172 value: extended 25173 } 25174 }); 25175 Reflect.setPrototypeOf(extended, constructor); 25176 return extended; 25177 } 25178 function testReflectExtension() { 25179 const a2 = function() { 25180 this.a.call(this); 25181 }; 25182 const b = extendWithReflect(a2); 25183 b.prototype.a = function() { 25184 }; 25185 return new b(); 25186 } 25187 try { 25188 testReflectExtension(); 25189 return extendWithReflect; 25190 } catch (error2) { 25191 return (constructor) => class extended extends constructor { 25192 }; 25193 } 25194 })(); 25195 function ClassPropertiesBlessing2(constructor) { 25196 const classes = readInheritableStaticArrayValues2(constructor, "classes"); 25197 return classes.reduce((properties, classDefinition) => { 25198 return Object.assign(properties, propertiesForClassDefinition2(classDefinition)); 25199 }, {}); 25200 } 25201 function propertiesForClassDefinition2(key) { 25202 return { 25203 [`${key}Class`]: { 25204 get() { 25205 const { 25206 classes 25207 } = this; 25208 if (classes.has(key)) { 25209 return classes.get(key); 25210 } else { 25211 const attribute = classes.getAttributeName(key); 25212 throw new Error(`Missing attribute "${attribute}"`); 25213 } 25214 } 25215 }, 25216 [`${key}Classes`]: { 25217 get() { 25218 return this.classes.getAll(key); 25219 } 25220 }, 25221 [`has${capitalize2(key)}Class`]: { 25222 get() { 25223 return this.classes.has(key); 25224 } 25225 } 25226 }; 25227 } 25228 function TargetPropertiesBlessing2(constructor) { 25229 const targets = readInheritableStaticArrayValues2(constructor, "targets"); 25230 return targets.reduce((properties, targetDefinition) => { 25231 return Object.assign(properties, propertiesForTargetDefinition2(targetDefinition)); 25232 }, {}); 25233 } 25234 function propertiesForTargetDefinition2(name) { 25235 return { 25236 [`${name}Target`]: { 25237 get() { 25238 const target = this.targets.find(name); 25239 if (target) { 25240 return target; 25241 } else { 25242 throw new Error(`Missing target element "${name}" for "${this.identifier}" controller`); 25243 } 25244 } 25245 }, 25246 [`${name}Targets`]: { 25247 get() { 25248 return this.targets.findAll(name); 25249 } 25250 }, 25251 [`has${capitalize2(name)}Target`]: { 25252 get() { 25253 return this.targets.has(name); 25254 } 25255 } 25256 }; 25257 } 25258 function ValuePropertiesBlessing2(constructor) { 25259 const valueDefinitionPairs = readInheritableStaticObjectPairs2(constructor, "values"); 25260 const propertyDescriptorMap = { 25261 valueDescriptorMap: { 25262 get() { 25263 return valueDefinitionPairs.reduce((result, valueDefinitionPair) => { 25264 const valueDescriptor = parseValueDefinitionPair2(valueDefinitionPair); 25265 const attributeName = this.data.getAttributeNameForKey(valueDescriptor.key); 25266 return Object.assign(result, { 25267 [attributeName]: valueDescriptor 25268 }); 25269 }, {}); 25270 } 25271 } 25272 }; 25273 return valueDefinitionPairs.reduce((properties, valueDefinitionPair) => { 25274 return Object.assign(properties, propertiesForValueDefinitionPair2(valueDefinitionPair)); 25275 }, propertyDescriptorMap); 25276 } 25277 function propertiesForValueDefinitionPair2(valueDefinitionPair) { 25278 const definition = parseValueDefinitionPair2(valueDefinitionPair); 25279 const { 25280 key, 25281 name, 25282 reader: read2, 25283 writer: write2 25284 } = definition; 25285 return { 25286 [name]: { 25287 get() { 25288 const value = this.data.get(key); 25289 if (value !== null) { 25290 return read2(value); 25291 } else { 25292 return definition.defaultValue; 25293 } 25294 }, 25295 set(value) { 25296 if (value === void 0) { 25297 this.data.delete(key); 25298 } else { 25299 this.data.set(key, write2(value)); 25300 } 25301 } 25302 }, 25303 [`has${capitalize2(name)}`]: { 25304 get() { 25305 return this.data.has(key) || definition.hasCustomDefaultValue; 25306 } 25307 } 25308 }; 25309 } 25310 function parseValueDefinitionPair2([token, typeDefinition]) { 25311 return valueDescriptorForTokenAndTypeDefinition2(token, typeDefinition); 25312 } 25313 function parseValueTypeConstant2(constant) { 25314 switch (constant) { 25315 case Array: 25316 return "array"; 25317 case Boolean: 25318 return "boolean"; 25319 case Number: 25320 return "number"; 25321 case Object: 25322 return "object"; 25323 case String: 25324 return "string"; 25325 } 25326 } 25327 function parseValueTypeDefault2(defaultValue) { 25328 switch (typeof defaultValue) { 25329 case "boolean": 25330 return "boolean"; 25331 case "number": 25332 return "number"; 25333 case "string": 25334 return "string"; 25335 } 25336 if (Array.isArray(defaultValue)) 25337 return "array"; 25338 if (Object.prototype.toString.call(defaultValue) === "[object Object]") 25339 return "object"; 25340 } 25341 function parseValueTypeObject2(typeObject) { 25342 const typeFromObject = parseValueTypeConstant2(typeObject.type); 25343 if (typeFromObject) { 25344 const defaultValueType = parseValueTypeDefault2(typeObject.default); 25345 if (typeFromObject !== defaultValueType) { 25346 throw new Error(`Type "${typeFromObject}" must match the type of the default value. Given default value: "${typeObject.default}" as "${defaultValueType}"`); 25347 } 25348 return typeFromObject; 25349 } 25350 } 25351 function parseValueTypeDefinition2(typeDefinition) { 25352 const typeFromObject = parseValueTypeObject2(typeDefinition); 25353 const typeFromDefaultValue = parseValueTypeDefault2(typeDefinition); 25354 const typeFromConstant = parseValueTypeConstant2(typeDefinition); 25355 const type = typeFromObject || typeFromDefaultValue || typeFromConstant; 25356 if (type) 25357 return type; 25358 throw new Error(`Unknown value type "${typeDefinition}"`); 25359 } 25360 function defaultValueForDefinition2(typeDefinition) { 25361 const constant = parseValueTypeConstant2(typeDefinition); 25362 if (constant) 25363 return defaultValuesByType2[constant]; 25364 const defaultValue = typeDefinition.default; 25365 if (defaultValue !== void 0) 25366 return defaultValue; 25367 return typeDefinition; 25368 } 25369 function valueDescriptorForTokenAndTypeDefinition2(token, typeDefinition) { 25370 const key = `${dasherize2(token)}-value`; 25371 const type = parseValueTypeDefinition2(typeDefinition); 25372 return { 25373 type, 25374 key, 25375 name: camelize2(key), 25376 get defaultValue() { 25377 return defaultValueForDefinition2(typeDefinition); 25378 }, 25379 get hasCustomDefaultValue() { 25380 return parseValueTypeDefault2(typeDefinition) !== void 0; 25381 }, 25382 reader: readers2[type], 25383 writer: writers2[type] || writers2.default 25384 }; 25385 } 25386 var defaultValuesByType2 = { 25387 get array() { 25388 return []; 25389 }, 25390 boolean: false, 25391 number: 0, 25392 get object() { 25393 return {}; 25394 }, 25395 string: "" 25396 }; 25397 var readers2 = { 25398 array(value) { 25399 const array = JSON.parse(value); 25400 if (!Array.isArray(array)) { 25401 throw new TypeError("Expected array"); 25402 } 25403 return array; 25404 }, 25405 boolean(value) { 25406 return !(value == "0" || value == "false"); 25407 }, 25408 number(value) { 25409 return Number(value); 25410 }, 25411 object(value) { 25412 const object = JSON.parse(value); 25413 if (object === null || typeof object != "object" || Array.isArray(object)) { 25414 throw new TypeError("Expected object"); 25415 } 25416 return object; 25417 }, 25418 string(value) { 25419 return value; 25420 } 25421 }; 25422 var writers2 = { 25423 default: writeString2, 25424 array: writeJSON2, 25425 object: writeJSON2 25426 }; 25427 function writeJSON2(value) { 25428 return JSON.stringify(value); 25429 } 25430 function writeString2(value) { 25431 return `${value}`; 25432 } 25433 var Controller2 = class { 25434 constructor(context) { 25435 this.context = context; 25436 } 25437 static get shouldLoad() { 25438 return true; 25439 } 25440 get application() { 25441 return this.context.application; 25442 } 25443 get scope() { 25444 return this.context.scope; 25445 } 25446 get element() { 25447 return this.scope.element; 25448 } 25449 get identifier() { 25450 return this.scope.identifier; 25451 } 25452 get targets() { 25453 return this.scope.targets; 25454 } 25455 get classes() { 25456 return this.scope.classes; 25457 } 25458 get data() { 25459 return this.scope.data; 25460 } 25461 initialize() { 25462 } 25463 connect() { 25464 } 25465 disconnect() { 25466 } 25467 dispatch(eventName, { 25468 target = this.element, 25469 detail = {}, 25470 prefix = this.identifier, 25471 bubbles = true, 25472 cancelable = true 25473 } = {}) { 25474 const type = prefix ? `${prefix}:${eventName}` : eventName; 25475 const event = new CustomEvent(type, { 25476 detail, 25477 bubbles, 25478 cancelable 25479 }); 25480 target.dispatchEvent(event); 25481 return event; 25482 } 25483 }; 25484 Controller2.blessings = [ClassPropertiesBlessing2, TargetPropertiesBlessing2, ValuePropertiesBlessing2]; 25485 Controller2.targets = []; 25486 Controller2.values = {}; 25487 var kebabCase = (string) => string.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase(); 25488 var capitalize$1 = (string) => { 25489 return string.charAt(0).toUpperCase() + string.slice(1); 25490 }; 25491 var booleanOptions = ["allowInput", "altInput", "animate", "clickOpens", "closeOnSelect", "disableMobile", "enableSeconds", "enableTime", "inline", "noCalendar", "shorthandCurrentMonth", "static", "time_24hr", "weekNumbers", "wrap"]; 25492 var stringOptions = ["altInputClass", "conjunction", "mode", "nextArrow", "position", "prevArrow", "monthSelectorType"]; 25493 var numberOptions = ["defaultHour", "defaultMinute", "defaultSeconds", "hourIncrement", "minuteIncrement", "showMonths"]; 25494 var arrayOptions = ["disable", "enable", "disableDaysOfWeek", "enableDaysOfWeek"]; 25495 var arrayOrStringOptions = ["defaultDate"]; 25496 var dateOptions = ["maxDate", "minDate", "maxTime", "minTime", "now"]; 25497 var dateFormats = ["altFormat", "ariaDateFormat", "dateFormat"]; 25498 var options = { 25499 string: stringOptions, 25500 boolean: booleanOptions, 25501 date: dateOptions, 25502 array: arrayOptions, 25503 number: numberOptions, 25504 arrayOrString: arrayOrStringOptions 25505 }; 25506 var events = ["change", "open", "close", "monthChange", "yearChange", "ready", "valueUpdate", "dayCreate"]; 25507 var elements2 = ["calendarContainer", "currentYearElement", "days", "daysContainer", "input", "nextMonthNav", "monthNav", "prevMonthNav", "rContainer", "selectedDateElem", "todayDateElem", "weekdayContainer"]; 25508 var mapping = { 25509 "%Y": "Y", 25510 "%y": "y", 25511 "%C": "Y", 25512 "%m": "m", 25513 "%-m": "n", 25514 "%_m": "n", 25515 "%B": "F", 25516 "%^B": "F", 25517 "%b": "M", 25518 "%^b": "M", 25519 "%h": "M", 25520 "%^h": "M", 25521 "%d": "d", 25522 "%-d": "j", 25523 "%e": "j", 25524 "%H": "H", 25525 "%k": "H", 25526 "%I": "h", 25527 "%l": "h", 25528 "%-l": "h", 25529 "%P": "K", 25530 "%p": "K", 25531 "%M": "i", 25532 "%S": "S", 25533 "%A": "l", 25534 "%a": "D", 25535 "%w": "w" 25536 }; 25537 var strftimeRegex = new RegExp(Object.keys(mapping).join("|").replace(new RegExp("\\^", "g"), "\\^"), "g"); 25538 var convertDateFormat = (format2) => { 25539 return format2.replace(strftimeRegex, (match) => { 25540 return mapping[match]; 25541 }); 25542 }; 25543 var StimulusFlatpickr = /* @__PURE__ */ function(_Controller) { 25544 _inherits(StimulusFlatpickr2, _Controller); 25545 var _super = _createSuper(StimulusFlatpickr2); 25546 function StimulusFlatpickr2() { 25547 _classCallCheck(this, StimulusFlatpickr2); 25548 return _super.apply(this, arguments); 25549 } 25550 _createClass(StimulusFlatpickr2, [{ 25551 key: "initialize", 25552 value: function initialize() { 25553 this.config = {}; 25554 } 25555 }, { 25556 key: "connect", 25557 value: function connect() { 25558 this._initializeEvents(); 25559 this._initializeOptions(); 25560 this._initializeDateFormats(); 25561 this.fp = esm_default(this.flatpickrElement, _objectSpread2({}, this.config)); 25562 this._initializeElements(); 25563 } 25564 }, { 25565 key: "disconnect", 25566 value: function disconnect() { 25567 const value = this.inputTarget.value; 25568 this.fp.destroy(); 25569 this.inputTarget.value = value; 25570 } 25571 }, { 25572 key: "_initializeEvents", 25573 value: function _initializeEvents() { 25574 events.forEach((event) => { 25575 if (this[event]) { 25576 const hook = `on${capitalize$1(event)}`; 25577 this.config[hook] = this[event].bind(this); 25578 } 25579 }); 25580 } 25581 }, { 25582 key: "_initializeOptions", 25583 value: function _initializeOptions() { 25584 Object.keys(options).forEach((optionType) => { 25585 const optionsCamelCase = options[optionType]; 25586 optionsCamelCase.forEach((option) => { 25587 const optionKebab = kebabCase(option); 25588 if (this.data.has(optionKebab)) { 25589 this.config[option] = this[`_${optionType}`](optionKebab); 25590 } 25591 }); 25592 }); 25593 this._handleDaysOfWeek(); 25594 } 25595 }, { 25596 key: "_handleDaysOfWeek", 25597 value: function _handleDaysOfWeek() { 25598 if (this.config.disableDaysOfWeek) { 25599 this.config.disableDaysOfWeek = this._validateDaysOfWeek(this.config.disableDaysOfWeek); 25600 this.config.disable = [...this.config.disable || [], this._disable.bind(this)]; 25601 } 25602 if (this.config.enableDaysOfWeek) { 25603 this.config.enableDaysOfWeek = this._validateDaysOfWeek(this.config.enableDaysOfWeek); 25604 this.config.enable = [...this.config.enable || [], this._enable.bind(this)]; 25605 } 25606 } 25607 }, { 25608 key: "_validateDaysOfWeek", 25609 value: function _validateDaysOfWeek(days) { 25610 if (Array.isArray(days)) { 25611 return days.map((day) => parseInt(day)); 25612 } else { 25613 console.error("days of week must be a valid array"); 25614 return []; 25615 } 25616 } 25617 }, { 25618 key: "_disable", 25619 value: function _disable(date) { 25620 const disabledDays = this.config.disableDaysOfWeek; 25621 return disabledDays.includes(date.getDay()); 25622 } 25623 }, { 25624 key: "_enable", 25625 value: function _enable(date) { 25626 const enabledDays = this.config.enableDaysOfWeek; 25627 return enabledDays.includes(date.getDay()); 25628 } 25629 }, { 25630 key: "_initializeDateFormats", 25631 value: function _initializeDateFormats() { 25632 dateFormats.forEach((dateFormat) => { 25633 if (this.data.has(dateFormat)) { 25634 this.config[dateFormat] = convertDateFormat(this.data.get(dateFormat)); 25635 } 25636 }); 25637 } 25638 }, { 25639 key: "_initializeElements", 25640 value: function _initializeElements() { 25641 elements2.forEach((element) => { 25642 this[`${element}Target`] = this.fp[element]; 25643 }); 25644 } 25645 }, { 25646 key: "_string", 25647 value: function _string(option) { 25648 return this.data.get(option); 25649 } 25650 }, { 25651 key: "_date", 25652 value: function _date(option) { 25653 return this.data.get(option); 25654 } 25655 }, { 25656 key: "_boolean", 25657 value: function _boolean(option) { 25658 return !(this.data.get(option) == "0" || this.data.get(option) == "false"); 25659 } 25660 }, { 25661 key: "_array", 25662 value: function _array(option) { 25663 return JSON.parse(this.data.get(option)); 25664 } 25665 }, { 25666 key: "_number", 25667 value: function _number(option) { 25668 return parseInt(this.data.get(option)); 25669 } 25670 }, { 25671 key: "_arrayOrString", 25672 value: function _arrayOrString(option) { 25673 const val = this.data.get(option); 25674 try { 25675 return JSON.parse(val); 25676 } catch (e2) { 25677 return val; 25678 } 25679 } 25680 }, { 25681 key: "flatpickrElement", 25682 get: function() { 25683 return this.hasInstanceTarget && this.instanceTarget || this.element; 25684 } 25685 }]); 25686 return StimulusFlatpickr2; 25687 }(Controller2); 25688 _defineProperty(StimulusFlatpickr, "targets", ["instance"]); 25689 var index_m_default = StimulusFlatpickr; 25690 25691
vendor: 808 bytes, lines 25691-25718
25691// ../../node_modules/stimulus-rails-nested-form/dist/stimulus-rails-nested-form.mjs 25692 var r2 = class extends Controller { 25693 add(t) { 25694 t.preventDefault(); 25695 const e2 = this.templateTarget.innerHTML.replace(/NEW_RECORD/g, new Date().getTime().toString()); 25696 this.targetTarget.insertAdjacentHTML("beforebegin", e2); 25697 } 25698 remove(t) { 25699 t.preventDefault(); 25700 const e2 = t.target.closest(this.wrapperSelectorValue); 25701 if (e2.dataset.newRecord === "true") 25702 e2.remove(); 25703 else { 25704 e2.style.display = "none"; 25705 const a2 = e2.querySelector("input[name*='_destroy']"); 25706 a2.value = "1"; 25707 } 25708 } 25709 }; 25710 r2.targets = ["target", "template"]; 25711 r2.values = { 25712 wrapperSelector: { 25713 type: String, 25714 default: ".nested-form-wrapper" 25715 } 25716 }; 25717 25718
25718// controllers/index.js 25719 controller_default.forEach((controller) => { 25720 application.register(controller.name, controller.module.default); 25721 }); 25722 application.register("accounts", accounts_controller_default); 25723 application.register("dropdown", i); 25724 application.register("modal", a); 25725 application.register("tabs", l); 25726 application.register("popover", n); 25727 application.register("toggle", o); 25728 application.register("slideover", r); 25729 application.register("braintree", braintree_controller_default); 25730 application.register("flatpickr", index_m_default); 25731 application.register("bulk", bulk_controller_default); 25732 application.register("clipboard", clipboard_controller_default); 25733 application.register("form", form_controller_default); 25734 application.register("mentions", mentions_controller_default); 25735 application.register("notifications", notifications_controller_default); 25736 application.register("paddle", paddle_controller_default); 25737 application.register("password", password_controller_default); 25738 application.register("password-strength", password_strength_controller_default); 25739 application.register("paypal", paypal_controller_default); 25740 application.register("pricing", pricing_controller_default); 25741 application.register("search", search_controller_default); 25742 application.register("select", select_controller_default); 25743 application.register("stripe", stripe_controller_default); 25744 application.register("tooltip", tooltip_controller_default); 25745 application.register("turbo-native--sign-out", sign_out_controller_default); 25746 application.register("disable", disable_controller_default); 25747 application.register("update_form", update_form_controller_default); 25748 application.register("nested-form", r2); 25749 application.register("users", users_controller_default); 25750 application.register("user_group", user_group_controller_default); 25751 application.register("places-autocomplete", places_autocomplete_controller_default); 25752 application.register("partner-price-form", partner_price_form_controller_default); 25753 application.register("category-filter", category_filter_controller_default); 25754 application.register("partner-resource-preview", partner_resource_preview_controller_default); 25755 application.register("partner-resource-file", partner_resource_file_controller_default); 25756 application.register("expandable-section", expandable_section_controller_default); 25757 application.register("partner-sidebar", partner_sidebar_controller_default); 25758 25759
25759// src/actiontext.js 25760 var import_trix2 = __toESM(require_trix()); 25761 25762
vendor: 1,988 bytes, lines 25762-25823
25762// ../../node_modules/@rails/request.js/src/fetch_response.js 25763 var FetchResponse2 = class { 25764 constructor(response) { 25765 this.response = response; 25766 } 25767 get statusCode() { 25768 return this.response.status; 25769 } 25770 get redirected() { 25771 return this.response.redirected; 25772 } 25773 get ok() { 25774 return this.response.ok; 25775 } 25776 get unauthenticated() { 25777 return this.statusCode === 401; 25778 } 25779 get unprocessableEntity() { 25780 return this.statusCode === 422; 25781 } 25782 get authenticationURL() { 25783 return this.response.headers.get("WWW-Authenticate"); 25784 } 25785 get contentType() { 25786 const contentType = this.response.headers.get("Content-Type") || ""; 25787 return contentType.replace(/;.*$/, ""); 25788 } 25789 get headers() { 25790 return this.response.headers; 25791 } 25792 get html() { 25793 if (this.contentType.match(/^(application|text)\/(html|xhtml\+xml)$/)) { 25794 return this.text; 25795 } 25796 return Promise.reject(new Error(`Expected an HTML response but got "${this.contentType}" instead`)); 25797 } 25798 get json() { 25799 if (this.contentType.match(/^application\/.*json$/)) { 25800 return this.responseJson || (this.responseJson = this.response.json()); 25801 } 25802 return Promise.reject(new Error(`Expected a JSON response but got "${this.contentType}" instead`)); 25803 } 25804 get text() { 25805 return this.responseText || (this.responseText = this.response.text()); 25806 } 25807 get isTurboStream() { 25808 return this.contentType.match(/^text\/vnd\.turbo-stream\.html/); 25809 } 25810 async renderTurboStream() { 25811 if (this.isTurboStream) { 25812 if (window.Turbo) { 25813 await window.Turbo.renderStreamMessage(await this.text); 25814 } else { 25815 console.warn("You must set `window.Turbo = Turbo` to automatically process Turbo Stream events with request.js"); 25816 } 25817 } else { 25818 return Promise.reject(new Error(`Expected a Turbo Stream response but got "${this.contentType}" instead`)); 25819 } 25820 } 25821 }; 25822 25823
vendor: 305 bytes, lines 25823-25836
25823// ../../node_modules/@rails/request.js/src/request_interceptor.js 25824 var RequestInterceptor = class { 25825 static register(interceptor) { 25826 this.interceptor = interceptor; 25827 } 25828 static get() { 25829 return this.interceptor; 25830 } 25831 static reset() { 25832 this.interceptor = void 0; 25833 } 25834 }; 25835 25836
vendor: 1,342 bytes, lines 25836-25880
25836// ../../node_modules/@rails/request.js/src/lib/utils.js 25837 function getCookie(name) { 25838 const cookies = document.cookie ? document.cookie.split("; ") : []; 25839 const prefix = `${encodeURIComponent(name)}=`; 25840 const cookie = cookies.find((cookie2) => cookie2.startsWith(prefix)); 25841 if (cookie) { 25842 const value = cookie.split("=").slice(1).join("="); 25843 if (value) { 25844 return decodeURIComponent(value); 25845 } 25846 } 25847 } 25848 function compact(object) { 25849 const result = {}; 25850 for (const key in object) { 25851 const value = object[key]; 25852 if (value !== void 0) { 25853 result[key] = value; 25854 } 25855 } 25856 return result; 25857 } 25858 function metaContent(name) { 25859 const element = document.head.querySelector(`meta[name="${name}"]`); 25860 return element && element.content; 25861 } 25862 function stringEntriesFromFormData(formData) { 25863 return [...formData].reduce((entries, [name, value]) => { 25864 return entries.concat(typeof value === "string" ? [[name, value]] : []); 25865 }, []); 25866 } 25867 function mergeEntries(searchParams, entries) { 25868 for (const [name, value] of entries) { 25869 if (value instanceof window.File) 25870 continue; 25871 if (searchParams.has(name)) { 25872 searchParams.delete(name); 25873 searchParams.set(name, value); 25874 } else { 25875 searchParams.append(name, value); 25876 } 25877 } 25878 } 25879 25880
vendor: 3,784 bytes, lines 25880-25996
25880// ../../node_modules/@rails/request.js/src/fetch_request.js 25881 var FetchRequest2 = class { 25882 constructor(method, url, options2 = {}) { 25883 this.method = method; 25884 this.options = options2; 25885 this.originalUrl = url.toString(); 25886 } 25887 async perform() { 25888 try { 25889 const requestInterceptor = RequestInterceptor.get(); 25890 if (requestInterceptor) { 25891 await requestInterceptor(this); 25892 } 25893 } catch (error2) { 25894 console.error(error2); 25895 } 25896 const response = new FetchResponse2(await window.fetch(this.url, this.fetchOptions)); 25897 if (response.unauthenticated && response.authenticationURL) { 25898 return Promise.reject(window.location.href = response.authenticationURL); 25899 } 25900 if (response.ok && response.isTurboStream) { 25901 await response.renderTurboStream(); 25902 } 25903 return response; 25904 } 25905 addHeader(key, value) { 25906 const headers = this.additionalHeaders; 25907 headers[key] = value; 25908 this.options.headers = headers; 25909 } 25910 get fetchOptions() { 25911 return { 25912 method: this.method.toUpperCase(), 25913 headers: this.headers, 25914 body: this.formattedBody, 25915 signal: this.signal, 25916 credentials: "same-origin", 25917 redirect: this.redirect 25918 }; 25919 } 25920 get headers() { 25921 return compact(Object.assign({ 25922 "X-Requested-With": "XMLHttpRequest", 25923 "X-CSRF-Token": this.csrfToken, 25924 "Content-Type": this.contentType, 25925 Accept: this.accept 25926 }, this.additionalHeaders)); 25927 } 25928 get csrfToken() { 25929 return getCookie(metaContent("csrf-param")) || metaContent("csrf-token"); 25930 } 25931 get contentType() { 25932 if (this.options.contentType) { 25933 return this.options.contentType; 25934 } else if (this.body == null || this.body instanceof window.FormData) { 25935 return void 0; 25936 } else if (this.body instanceof window.File) { 25937 return this.body.type; 25938 } 25939 return "application/json"; 25940 } 25941 get accept() { 25942 switch (this.responseKind) { 25943 case "html": 25944 return "text/html, application/xhtml+xml"; 25945 case "turbo-stream": 25946 return "text/vnd.turbo-stream.html, text/html, application/xhtml+xml"; 25947 case "json": 25948 return "application/json, application/vnd.api+json"; 25949 default: 25950 return "*/*"; 25951 } 25952 } 25953 get body() { 25954 return this.options.body; 25955 } 25956 get query() { 25957 const originalQuery = (this.originalUrl.split("?")[1] || "").split("#")[0]; 25958 const params = new URLSearchParams(originalQuery); 25959 let requestQuery = this.options.query; 25960 if (requestQuery instanceof window.FormData) { 25961 requestQuery = stringEntriesFromFormData(requestQuery); 25962 } else if (requestQuery instanceof window.URLSearchParams) { 25963 requestQuery = requestQuery.entries(); 25964 } else { 25965 requestQuery = Object.entries(requestQuery || {}); 25966 } 25967 mergeEntries(params, requestQuery); 25968 const query = params.toString(); 25969 return query.length > 0 ? `?${query}` : ""; 25970 } 25971 get url() { 25972 return this.originalUrl.split("?")[0].split("#")[0] + this.query; 25973 } 25974 get responseKind() { 25975 return this.options.responseKind || "html"; 25976 } 25977 get signal() { 25978 return this.options.signal; 25979 } 25980 get redirect() { 25981 return this.options.redirect || "follow"; 25982 } 25983 get additionalHeaders() { 25984 return this.options.headers || {}; 25985 } 25986 get formattedBody() { 25987 const bodyIsAString = Object.prototype.toString.call(this.body) === "[object String]"; 25988 const contentTypeIsJson = this.headers["Content-Type"] === "application/json"; 25989 if (contentTypeIsJson && !bodyIsAString) { 25990 return JSON.stringify(this.body); 25991 } 25992 return this.body; 25993 } 25994 }; 25995 25996
vendor: 189 bytes, lines 25996-26002
25996// ../../node_modules/@rails/request.js/src/verbs.js 25997 async function get(url, options2) { 25998 const request = new FetchRequest2("get", url, options2); 25999 return request.perform(); 26000 } 26001 26002
26002// src/actiontext.js 26003 import_trix2.default.config.textAttributes.inlineCode = { 26004 tagName: "code", 26005 inheritable: true 26006 }; 26007 var EmbedController = class { 26008 constructor(element) { 26009 this.patterns = void 0; 26010 this.element = element; 26011 this.editor = element.editor; 26012 this.toolbar = element.toolbarElement; 26013 this.injectHTML(); 26014 this.hrefElement = this.toolbar.querySelector("[data-trix-input][name='href']"); 26015 this.embedContainerElement = this.toolbar.querySelector("[data-behavior='embed_container']"); 26016 this.embedElement = this.toolbar.querySelector("[data-behavior='embed_url']"); 26017 this.reset(); 26018 this.installEventHandlers(); 26019 } 26020 injectHTML() { 26021 this.toolbar.querySelector('[data-trix-dialog="href"]').insertAdjacentHTML("beforeend", ` 26022 <div data-behavior="embed_container"> 26023 <div class="link_to_embed link_to_embed--new"> 26024 Would you like to embed media from this site? 26025 <input class="btn btn-tertiary btn-small outline" type="button" data-behavior="embed_url" value="Yes, embed it"> 26026 </div> 26027 </div> 26028 `); 26029 } 26030 installEventHandlers() { 26031 this.hrefElement.addEventListener("input", this.didInput.bind(this)); 26032 this.hrefElement.addEventListener("focusin", this.didInput.bind(this)); 26033 this.embedElement.addEventListener("click", this.embed.bind(this)); 26034 } 26035 didInput(event) { 26036 let value = event.target.value.trim(); 26037 if (this.patterns === void 0) { 26038 this.loadPatterns(value); 26039 } else if (this.match(value)) { 26040 this.fetch(value); 26041 } else { 26042 this.reset(); 26043 } 26044 } 26045 async loadPatterns(value) { 26046 const response = await get("/action_text/embeds/patterns.json", { responseKind: "json" }); 26047 if (response.ok) { 26048 const patterns = await response.json; 26049 this.patterns = patterns.map((pattern) => new RegExp(pattern.source, pattern.options)); 26050 if (this.match(value)) { 26051 this.fetch(value); 26052 } 26053 } 26054 } 26055 match(value) { 26056 return this.patterns.some((regex) => regex.test(value)); 26057 } 26058 fetch(value) { 26059 Rails.ajax({ 26060 url: `/action_text/embeds?id=${encodeURIComponent(value)}`, 26061 type: "post", 26062 error: this.reset.bind(this), 26063 success: this.showEmbed.bind(this) 26064 }); 26065 } 26066 embed(event) { 26067 if (this.currentEmbed == null) { 26068 return; 26069 } 26070 let attachment = new import_trix2.default.Attachment(this.currentEmbed); 26071 this.editor.insertAttachment(attachment); 26072 this.element.focus(); 26073 } 26074 showEmbed(embed) { 26075 this.currentEmbed = embed; 26076 this.embedContainerElement.style.display = "block"; 26077 } 26078 reset() { 26079 this.embedContainerElement.style.display = "none"; 26080 this.currentEmbed = null; 26081 } 26082 }; 26083 var InlineCode = class { 26084 constructor(element) { 26085 this.element = element; 26086 this.editor = element.editor; 26087 this.toolbar = element.toolbarElement; 26088 this.installEventHandlers(); 26089 } 26090 installEventHandlers() { 26091 const blockCodeButton = this.toolbar.querySelector("[data-trix-attribute=code]"); 26092 const inlineCodeButton = blockCodeButton.cloneNode(true); 26093 inlineCodeButton.hidden = true; 26094 inlineCodeButton.dataset.trixAttribute = "inlineCode"; 26095 blockCodeButton.insertAdjacentElement("afterend", inlineCodeButton); 26096 this.element.addEventListener("trix-selection-change", (_) => { 26097 const type = this.getCodeFormattingType(); 26098 blockCodeButton.hidden = type == "inline"; 26099 inlineCodeButton.hidden = type == "block"; 26100 }); 26101 } 26102 getCodeFormattingType() { 26103 if (this.editor.attributeIsActive("code")) 26104 return "block"; 26105 if (this.editor.attributeIsActive("inlineCode")) 26106 return "inline"; 26107 const range = this.editor.getSelectedRange(); 26108 if (range[0] == range[1]) 26109 return "block"; 26110 const text = this.editor.getSelectedDocument().toString().trim(); 26111 return /\n/.test(text) ? "block" : "inline"; 26112 } 26113 }; 26114 document.addEventListener("trix-initialize", function(event) { 26115 new EmbedController(event.target); 26116 new InlineCode(event.target); 26117 }); 26118 26119 // rails:/app/app/javascript/src/**/* 26120 var module2 = __toESM(require_confirm_email_modal()); 26121 var module3 = __toESM(require_direct_uploads()); 26122 var module4 = __toESM(require_lazysrc()); 26123 26124
vendor: 2,987 bytes, lines 26124-26213
26124// ../../node_modules/js-cookie/dist/js.cookie.mjs 26125 function assign(target) { 26126 for (var i2 = 1; i2 < arguments.length; i2++) { 26127 var source = arguments[i2]; 26128 for (var key in source) { 26129 target[key] = source[key]; 26130 } 26131 } 26132 return target; 26133 } 26134 var defaultConverter = { 26135 read: function(value) { 26136 if (value[0] === '"') { 26137 value = value.slice(1, -1); 26138 } 26139 return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent); 26140 }, 26141 write: function(value) { 26142 return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent); 26143 } 26144 }; 26145 function init(converter, defaultAttributes) { 26146 function set(key, value, attributes) { 26147 if (typeof document === "undefined") { 26148 return; 26149 } 26150 attributes = assign({}, defaultAttributes, attributes); 26151 if (typeof attributes.expires === "number") { 26152 attributes.expires = new Date(Date.now() + attributes.expires * 864e5); 26153 } 26154 if (attributes.expires) { 26155 attributes.expires = attributes.expires.toUTCString(); 26156 } 26157 key = encodeURIComponent(key).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); 26158 var stringifiedAttributes = ""; 26159 for (var attributeName in attributes) { 26160 if (!attributes[attributeName]) { 26161 continue; 26162 } 26163 stringifiedAttributes += "; " + attributeName; 26164 if (attributes[attributeName] === true) { 26165 continue; 26166 } 26167 stringifiedAttributes += "=" + attributes[attributeName].split(";")[0]; 26168 } 26169 return document.cookie = key + "=" + converter.write(value, key) + stringifiedAttributes; 26170 } 26171 function get2(key) { 26172 if (typeof document === "undefined" || arguments.length && !key) { 26173 return; 26174 } 26175 var cookies = document.cookie ? document.cookie.split("; ") : []; 26176 var jar = {}; 26177 for (var i2 = 0; i2 < cookies.length; i2++) { 26178 var parts = cookies[i2].split("="); 26179 var value = parts.slice(1).join("="); 26180 try { 26181 var foundKey = decodeURIComponent(parts[0]); 26182 jar[foundKey] = converter.read(value, foundKey); 26183 if (key === foundKey) { 26184 break; 26185 } 26186 } catch (e2) { 26187 } 26188 } 26189 return key ? jar[key] : jar; 26190 } 26191 return Object.create({ 26192 set, 26193 get: get2, 26194 remove: function(key, attributes) { 26195 set(key, "", assign({}, attributes, { 26196 expires: -1 26197 })); 26198 }, 26199 withAttributes: function(attributes) { 26200 return init(this.converter, assign({}, this.attributes, attributes)); 26201 }, 26202 withConverter: function(converter2) { 26203 return init(assign({}, this.converter, converter2), this.attributes); 26204 } 26205 }, { 26206 attributes: { value: Object.freeze(defaultAttributes) }, 26207 converter: { value: Object.freeze(converter) } 26208 }); 26209 } 26210 var api = init(defaultConverter, { path: "/" }); 26211 var js_cookie_default = api; 26212 26213
26213// src/timezone.js 26214 var import_jstz = __toESM(require_jstz2()); 26215 function findTimeZone() { 26216 const oldIntl = window.Intl; 26217 try { 26218 window.Intl = void 0; 26219 const tz = import_jstz.default.determine().name(); 26220 window.Intl = oldIntl; 26221 return tz; 26222 } catch (e2) { 26223 return import_jstz.default.determine().name(); 26224 } 26225 } 26226 document.addEventListener("turbo:load", () => { 26227 js_cookie_default.set("browser_time_zone", findTimeZone(), { expires: 365, path: "/", secure: true }); 26228 }); 26229 26230
26230// src/turbo_native/bridge.js 26231 var Bridge = class { 26232 static toggleNavBar() { 26233 const event = new CustomEvent("toggle-nav-bar"); 26234 window.dispatchEvent(event); 26235 } 26236 static setNotificationCount(icon, tab = icon) { 26237 this.postMessage("showNotificationBadge", { icon, tab }); 26238 } 26239 static postMessage(name, data = {}) { 26240 window.webkit?.messageHandlers?.nativeApp?.postMessage({ name, ...data }); 26241 window.nativeApp?.postMessage(JSON.stringify({ name, ...data })); 26242 } 26243 }; 26244 window.TurboNativeBridge = Bridge; 26245 26246 // application.js 26247 window.Rails = import_ujs.default; 26248 window.Turbo = turbo_es2017_esm_exports; 26249 require_activestorage().start(); 26250 require_local_time().start(); 26251 import_ujs.default.start(); 26252})(); 26253/*! 26254 * clipboard.js v2.0.10 26255 * https://clipboardjs.com/ 26256 * 26257 * Licensed MIT © Zeno Rocha 26258 */ 26259/*! js-cookie v3.0.1 | MIT */ 26260/** 26261 * This script gives you the zone info key representing your device's time zone setting. 26262 * 26263 * @name jsTimezoneDetect 26264 * @version 1.0.6 26265 * @author Jon Nylander 26266 * @license MIT License - https://bitbucket.org/pellepim/jstimezonedetect/src/default/LICENCE.txt 26267 * 26268 * For usage and examples, visit: 26269 * http://pellepim.bitbucket.org/jstz/ 26270 * 26271 * Copyright (c) Jon Nylander 26272 */ 26273//# sourceMappingURL=/assets/application.js-a41e6453a218e8a6b6151c590a37f50e978d12c403c13a837175eea802ce8078.map 26274//! 26275;
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.