| |
| |
| |
| (function () { |
| var PIN_H = "40px"; |
| var ROW_H = "56px"; |
|
|
| function pinInput() { |
| var tas = document.querySelectorAll( |
| '#nyra-input textarea, #nyra-input input, textarea[data-testid="textbox"]' |
| ); |
| for (var i = 0; i < tas.length; i++) { |
| var el = tas[i]; |
| |
| el.style.setProperty("height", PIN_H, "important"); |
| el.style.setProperty("min-height", PIN_H, "important"); |
| el.style.setProperty("max-height", PIN_H, "important"); |
| el.style.setProperty("resize", "none", "important"); |
| el.style.setProperty("overflow", "hidden", "important"); |
| el.style.setProperty("line-height", PIN_H, "important"); |
| el.setAttribute("rows", "1"); |
| |
| try { |
| Object.defineProperty(el, "scrollHeight", { |
| configurable: true, |
| get: function () { |
| return 40; |
| }, |
| }); |
| } catch (e) {} |
| } |
|
|
| var row = document.getElementById("nyra-input-row"); |
| if (row) { |
| row.style.setProperty("height", ROW_H, "important"); |
| row.style.setProperty("max-height", ROW_H, "important"); |
| row.style.setProperty("min-height", ROW_H, "important"); |
| row.style.setProperty("flex-grow", "0", "important"); |
| row.style.setProperty("overflow", "hidden", "important"); |
| } |
|
|
| |
| var main = document.getElementById("nyra-main"); |
| if (main) { |
| main.style.setProperty("flex-grow", "0", "important"); |
| main.style.setProperty("height", "auto", "important"); |
| main.style.setProperty("min-height", "0", "important"); |
| } |
|
|
| document.documentElement.style.setProperty("height", "auto", "important"); |
| document.body.style.setProperty("height", "auto", "important"); |
| document.body.style.setProperty("min-height", "0", "important"); |
|
|
| var gc = document.querySelector(".gradio-container"); |
| if (gc) { |
| gc.style.setProperty("height", "auto", "important"); |
| gc.style.setProperty("min-height", "0", "important"); |
| gc.style.setProperty("flex-grow", "0", "important"); |
| |
| try { |
| if (window.parent && window.parent !== window) { |
| var h = Math.ceil(document.documentElement.scrollHeight); |
| |
| if (h > 2000) h = 900; |
| window.parent.postMessage( |
| { iframeHeight: h, type: "setHeight" }, |
| "*" |
| ); |
| } |
| } catch (e) {} |
| } |
| } |
|
|
| function updateEmptyState() { |
| var bot = document.querySelector("#nyra-chatbot"); |
| if (!bot) return; |
| var messages = bot.querySelectorAll( |
| ".message, .message-row, [data-testid='user'], [data-testid='bot']" |
| ); |
| var has = messages && messages.length > 0; |
| document.body.classList.toggle("nyra-has-messages", !!has); |
| var hero = document.getElementById("nyra-hero"); |
| var chips = document.getElementById("nyra-chips"); |
| if (hero) hero.style.display = has ? "none" : ""; |
| if (chips) chips.style.display = has ? "none" : ""; |
| } |
|
|
| function hydrateLucide() { |
| try { |
| if (window.lucide && typeof window.lucide.createIcons === "function") { |
| window.lucide.createIcons({ attrs: { "stroke-width": 1.85 } }); |
| } |
| } catch (e) {} |
| } |
|
|
| function boot() { |
| pinInput(); |
| updateEmptyState(); |
| hydrateLucide(); |
| } |
|
|
| |
| try { |
| window.iFrameResizer = { |
| autoResize: false, |
| sizeWidth: false, |
| heightCalculationMethod: "taggedElement", |
| }; |
| } catch (e) {} |
|
|
| if (document.readyState === "loading") { |
| document.addEventListener("DOMContentLoaded", boot); |
| } else { |
| boot(); |
| } |
| window.addEventListener("load", boot); |
|
|
| |
| setInterval(pinInput, 250); |
|
|
| |
| var mo = new MutationObserver(function () { |
| pinInput(); |
| updateEmptyState(); |
| }); |
| if (document.body) { |
| mo.observe(document.body, { |
| childList: true, |
| subtree: true, |
| attributes: true, |
| attributeFilter: ["style", "rows", "class"], |
| }); |
| } |
| })(); |
|
|