/*! shiny 1.13.0 | (c) 2012-2026 Posit Software, PBC. | License: MIT + file LICENSE */ "use strict"; (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __typeError = (msg) => { throw TypeError(msg); }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method); // globals:jquery var require_jquery = __commonJS({ "globals:jquery"(exports, module) { module.exports = window.jQuery; } }); // srcts/src/initialize/browser.ts var import_jquery = __toESM(require_jquery()); // srcts/src/utils/browser.ts var isQtVal = false; var isIEVal = false; var versionIE = -1; function setIsQt(isQt2) { isQtVal = isQt2; } function setIsIE(isIE2) { isIEVal = isIE2; } function setIEVersion(versionIE_) { versionIE = versionIE_; } function isQt() { return isQtVal; } function isIE() { return isIEVal; } function IEVersion() { return versionIE; } // srcts/src/utils/userAgent.ts var userAgent; function setUserAgent(userAgent_) { userAgent = userAgent_; } // srcts/src/initialize/browser.ts function getIEVersion() { const msie = userAgent.indexOf("MSIE "); if (isIE() && msie > 0) { return parseInt( userAgent.substring(msie + 5, userAgent.indexOf(".", msie)), 10 ); } const trident = userAgent.indexOf("Trident/"); if (trident > 0) { const rv = userAgent.indexOf("rv:"); return parseInt( userAgent.substring(rv + 3, userAgent.indexOf(".", rv)), 10 ); } return -1; } function determineBrowserInfo() { if (/\bQt\//.test(userAgent)) { (0, import_jquery.default)(document.documentElement).addClass("qt"); setIsQt(true); } else { setIsQt(false); } if (/\bQt/.test(userAgent) && /\bMacintosh/.test(userAgent)) { (0, import_jquery.default)(document.documentElement).addClass("qtmac"); } if (/\bQt\/5/.test(userAgent) && /Linux/.test(userAgent)) { (0, import_jquery.default)(document.documentElement).addClass("qt5"); } setIsIE(/MSIE|Trident|Edge/.test(userAgent)); setIEVersion(getIEVersion()); } // srcts/src/initialize/disableForm.ts var import_jquery2 = __toESM(require_jquery()); function disableFormSubmission() { (0, import_jquery2.default)(document).on("submit", "form:not([action])", function(e4) { e4.preventDefault(); }); } // srcts/src/initialize/history.ts var import_jquery3 = __toESM(require_jquery()); function trackHistory() { const origPushState = window.history.pushState; window.history.pushState = function(...args) { const result = origPushState.apply(this, args); (0, import_jquery3.default)(document).trigger("pushstate"); return result; }; } // srcts/src/shiny/index.ts var import_jquery40 = __toESM(require_jquery()); // srcts/src/utils/index.ts var import_jquery6 = __toESM(require_jquery()); // srcts/src/shiny/render.ts var import_jquery5 = __toESM(require_jquery()); // srcts/src/utils/object.ts function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } function hasDefinedProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop) && obj[prop] !== void 0; } function ifUndefined(value, alternate) { if (value === void 0) return alternate; return value; } function asArray(value) { if (value === null || value === void 0) return []; if (Array.isArray(value)) return value; return [value]; } // srcts/src/shiny/initedMethods.ts var fullShinyObj; function setShinyObj(shiny) { fullShinyObj = shiny; } function validateShinyHasBeenSet() { if (typeof fullShinyObj === "undefined") { throw "Shiny has not finish initialization yet. Please wait for the 'shiny-initialized' event."; } return fullShinyObj; } function shinySetInputValue(name, value, opts) { validateShinyHasBeenSet().setInputValue(name, value, opts); } function shinyShinyApp() { return validateShinyHasBeenSet().shinyapp; } function setShinyUser(user) { validateShinyHasBeenSet().user = user; } function shinyForgetLastInputValue(name) { validateShinyHasBeenSet().forgetLastInputValue(name); } async function shinyBindAll(scope) { await validateShinyHasBeenSet().bindAll(scope); } function shinyUnbindAll(scope, includeSelf = false) { validateShinyHasBeenSet().unbindAll(scope, includeSelf); } function shinyInitializeInputs(scope) { validateShinyHasBeenSet().initializeInputs(scope); } async function shinyAppBindOutput(id, binding) { await shinyShinyApp().bindOutput(id, binding); } function shinyAppUnbindOutput(id, binding) { return shinyShinyApp().unbindOutput(id, binding); } function getShinyOnCustomMessage() { return validateShinyHasBeenSet().oncustommessage; } var fileInputBinding; function getFileInputBinding() { return fileInputBinding; } function setFileInputBinding(fileInputBinding_) { fileInputBinding = fileInputBinding_; } function getShinyCreateWebsocket() { return validateShinyHasBeenSet().createSocket; } // srcts/src/time/debounce.ts var Debouncer = class { constructor(target, func, delayMs) { this.target = target; this.func = func; this.delayMs = delayMs; this.timerId = null; this.args = null; } normalCall(...args) { this.$clearTimer(); this.args = args; this.timerId = setTimeout(() => { if (this.timerId === null) return; this.$clearTimer(); this.$invoke(); }, this.delayMs); } immediateCall(...args) { this.$clearTimer(); this.args = args; this.$invoke(); } isPending() { return this.timerId !== null; } $clearTimer() { if (this.timerId !== null) { clearTimeout(this.timerId); this.timerId = null; } } $invoke() { if (this.args && this.args.length > 0) { this.func.apply(this.target, this.args); } else { this.func.apply(this.target); } this.args = null; } }; function debounce(threshold, func) { let timerId = null; return function thisFunc(...args) { if (timerId !== null) { clearTimeout(timerId); timerId = null; } timerId = setTimeout(() => { if (timerId === null) return; timerId = null; func.apply(thisFunc, args); }, threshold); }; } // srcts/src/time/invoke.ts var Invoker = class { constructor(target, func) { this.target = target; this.func = func; } // TODO-barret - Don't know how to define the method twice and still have access to "this" normalCall(...args) { this.func.apply(this.target, args); } immediateCall(...args) { this.func.apply(this.target, args); } }; // srcts/src/time/throttle.ts var Throttler = class { constructor(target, func, delayMs) { this.target = target; this.func = func; this.delayMs = delayMs; this.timerId = null; this.args = null; } // If no timer is currently running, immediately call the function and set the // timer; if a timer is running out, just queue up the args for the call when // the timer runs out. Later calls during the same timeout will overwrite // earlier ones. normalCall(...args) { this.args = args; if (this.timerId === null) { this.$invoke(); } } // Reset the timer if active and call immediately immediateCall(...args) { this.$clearTimer(); this.args = args; this.$invoke(); } // Is there a call waiting to send? isPending() { return this.args !== null; } $clearTimer() { if (this.timerId !== null) { clearTimeout(this.timerId); this.timerId = null; } } // Invoke the throttled function with the currently-stored args and start the // timer. $invoke() { if (this.args === null) { return; } this.func.apply(this.target, this.args); this.args = null; this.timerId = setTimeout(() => { if (this.timerId === null) return; this.$clearTimer(); if (this.isPending()) { this.$invoke(); } }, this.delayMs); } }; // srcts/src/shiny/sendImageSize.ts var SendImageSize = class { setImageSend(inputBatchSender, doSendImageSize) { const sendImageSizeDebouncer = new Debouncer(null, doSendImageSize, 0); this.regular = function() { sendImageSizeDebouncer.normalCall(); }; inputBatchSender.lastChanceCallback.push(function() { if (sendImageSizeDebouncer.isPending()) sendImageSizeDebouncer.immediateCall(); }); this.transitioned = debounce(200, this.regular); return sendImageSizeDebouncer; } }; var sendImageSizeFns = new SendImageSize(); // srcts/src/shiny/singletons.ts var import_jquery4 = __toESM(require_jquery()); var reSingleton = /([\s\S]*?)/; var reHead = /]*)?>([\s\S]*?)<\/head>/; var knownSingletons = {}; function renderHtml(html, el, where) { const processed = processHtml(html); addToHead(processed.head); register(processed.singletons); switch (where.toLowerCase()) { case "replace": (0, import_jquery4.default)(el).html(processed.html); break; case "beforebegin": (0, import_jquery4.default)(el).before(processed.html); break; case "afterbegin": (0, import_jquery4.default)(el).prepend(processed.html); break; case "beforeend": (0, import_jquery4.default)(el).append(processed.html); break; case "afterend": (0, import_jquery4.default)(el).after(processed.html); break; default: throw new Error("Unknown where position: " + where); } return processed; } function register(s4) { import_jquery4.default.extend(knownSingletons, s4); } function registerNames(s4) { if (typeof s4 === "string") { knownSingletons[s4] = true; } else if (s4 instanceof Array) { for (let i5 = 0; i5 < s4.length; i5++) { knownSingletons[s4[i5]] = true; } } } function addToHead(head) { if (head.length > 0) { const tempDiv = (0, import_jquery4.default)("
" + head + "
").get(0); const $head = (0, import_jquery4.default)("head"); while (tempDiv.hasChildNodes()) { $head.append(tempDiv.firstChild); } } } function processHtml(val) { const newSingletons = {}; let newVal; const findNewPayload = function(match, p1, sig, payload) { if (knownSingletons[sig] || newSingletons[sig]) return ""; newSingletons[sig] = true; return payload; }; while (true) { newVal = val.replace(reSingleton, findNewPayload); if (val.length === newVal.length) break; val = newVal; } const heads = []; const headAddPayload = function(match, payload) { heads.push(payload); return ""; }; while (true) { newVal = val.replace(reHead, headAddPayload); if (val.length === newVal.length) break; val = newVal; } return { html: val, head: heads.join("\n"), singletons: newSingletons }; } // srcts/src/shiny/render.ts async function renderContentAsync(el, content, where = "replace") { if (where === "replace") { shinyUnbindAll(el); } let html = ""; let dependencies = []; if (content === null) { html = ""; } else if (typeof content === "string") { html = content; } else if (typeof content === "object") { html = content.html; dependencies = content.deps || []; } await renderHtmlAsync(html, el, dependencies, where); let scope = el; if (where === "replace") { shinyInitializeInputs(el); await shinyBindAll(el); } else { const $parent = (0, import_jquery5.default)(el).parent(); if ($parent.length > 0) { scope = $parent; if (where === "beforeBegin" || where === "afterEnd") { const $grandparent = $parent.parent(); if ($grandparent.length > 0) scope = $grandparent; } } shinyInitializeInputs(scope); await shinyBindAll(scope); } } function renderContent(el, content, where = "replace") { if (where === "replace") { shinyUnbindAll(el); } let html = ""; let dependencies = []; if (content === null) { html = ""; } else if (typeof content === "string") { html = content; } else if (typeof content === "object") { html = content.html; dependencies = content.deps || []; } renderHtml2(html, el, dependencies, where); let scope = el; if (where === "replace") { shinyInitializeInputs(el); return shinyBindAll(el); } else { const $parent = (0, import_jquery5.default)(el).parent(); if ($parent.length > 0) { scope = $parent; if (where === "beforeBegin" || where === "afterEnd") { const $grandparent = $parent.parent(); if ($grandparent.length > 0) scope = $grandparent; } } shinyInitializeInputs(scope); return shinyBindAll(scope); } } async function renderHtmlAsync(html, el, dependencies, where = "replace") { await renderDependenciesAsync(dependencies); return renderHtml(html, el, where); } function renderHtml2(html, el, dependencies, where = "replace") { renderDependencies(dependencies); return renderHtml(html, el, where); } async function renderDependenciesAsync(dependencies) { if (dependencies) { for (const dep of dependencies) { await renderDependencyAsync(dep); } } } function renderDependencies(dependencies) { if (dependencies) { for (const dep of dependencies) { renderDependency(dep); } } } var htmlDependencies = {}; function registerDependency(name, version) { htmlDependencies[name] = version; } function needsRestyle(dep) { if (!dep.restyle) { return false; } const names = Object.keys(htmlDependencies); const idx = names.indexOf(dep.name); if (idx === -1) { return false; } return htmlDependencies[names[idx]] === dep.version; } function addStylesheetsAndRestyle(links) { const $head = (0, import_jquery5.default)("head").first(); const refreshStyle = function(href, oldSheet) { const xhr = new XMLHttpRequest(); xhr.open("GET", href); xhr.onload = function() { const id = "shiny_restyle_" + href.split("?restyle")[0].replace(/\W/g, "_"); const oldStyle = $head.find("style#" + id); const newStyle = (0, import_jquery5.default)("