!function(){"use strict";function n(n){return String(n??"").replace(/[&<>"']/g,n=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"}[n]))}function e(n){n&&!n.closed&&"function"==typeof n.close&&n.close()}window.aipkit_chatUI_downloadTranscriptActionPdf=function(t,i,o=null){let r=t&&t.messagesEl?t.messagesEl:null,a=function(n,e){let t=n&&n.messagesEl?n.messagesEl:null;return function(i,o="info",r=!0,a=4500){"function"!=typeof window.aipkit_chatUI_showInlineNotice?"error"===o&&alert(i):window.aipkit_chatUI_showInlineNotice(i,o,{elements:n,config:e,messagesEl:t},r,a)}}(t,i);if(!r||!i||!i.text)return void e(o);if("function"!=typeof window.aipkit_chatUI_buildTranscriptDocument)return e(o),void a(i.text?.downloadPrepareError||"Error: Could not prepare download.","error",!0,7e3);let s=window.aipkit_chatUI_buildTranscriptDocument(r,i);if(!s.entries.length)return e(o),void a(i.text.downloadEmpty||"Nothing to download.","info",!0);let p=o||window.open("","_blank");p?(p.opener=null,p.document.open(),p.document.write(function(e){let t=e.title||"Chat Transcript",i=e.entries.map((e,t)=>`\n            <section class="aipkit-print-message aipkit-print-message--${function(n){return"user"===n?"user":"error"===n?"error":"bot"}(e.role)}">\n                <header>\n                    <span>${n(e.label||"Bot")}</span>\n                    <small>#${t+1}</small>\n                </header>\n                <div class="aipkit-print-message-body">${function(e){return n(e).replace(/\n/g,"<br>")}(e.text)}</div>\n            </section>\n        `).join("");return`<!doctype html>\n<html>\n<head>\n    <meta charset="utf-8">\n    <title>${n(t)}</title>\n    <style>\n        * { box-sizing: border-box; }\n        html, body { margin: 0; padding: 0; }\n        body {\n            color: #111827;\n            font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;\n            background: #ffffff;\n        }\n        main {\n            width: min(760px, calc(100% - 48px));\n            margin: 36px auto;\n        }\n        h1 {\n            margin: 0 0 6px;\n            font-size: 22px;\n            line-height: 1.25;\n        }\n        .aipkit-print-meta {\n            margin: 0 0 22px;\n            color: #64748b;\n            font-size: 12px;\n        }\n        .aipkit-print-message {\n            break-inside: avoid;\n            margin: 0 0 18px;\n            padding: 0 0 16px;\n            border-bottom: 1px solid #e5e7eb;\n        }\n        .aipkit-print-message header {\n            display: flex;\n            justify-content: space-between;\n            gap: 12px;\n            margin: 0 0 8px;\n            font-size: 12px;\n            font-weight: 700;\n            text-transform: uppercase;\n            letter-spacing: .04em;\n        }\n        .aipkit-print-message header small {\n            color: #94a3b8;\n            font-weight: 600;\n        }\n        .aipkit-print-message--user header { color: #1d4ed8; }\n        .aipkit-print-message--bot header { color: #111827; }\n        .aipkit-print-message--error header { color: #b91c1c; }\n        .aipkit-print-message-body {\n            white-space: normal;\n            overflow-wrap: anywhere;\n        }\n        @page { margin: 16mm; }\n        @media print {\n            main {\n                width: auto;\n                margin: 0;\n            }\n            .aipkit-print-message {\n                break-inside: avoid;\n            }\n        }\n    </style>\n</head>\n<body>\n    <main>\n        <h1>${n(t)}</h1>\n        <p class="aipkit-print-meta">\n            ${n(e.botName||"Bot")} - ${n(e.exportedAt||"")}\n        </p>\n        ${i}\n    </main>\n    <script>\n        window.addEventListener('load', function() {\n            window.focus();\n            setTimeout(function() { window.print(); }, 100);\n        });\n    <\/script>\n</body>\n</html>`}(s)),p.document.close()):a(i.text?.pdfError||"Could not open the print window. Please allow popups and try again.","error",!0,7e3)}}();