(()=>{function e(e,t){const n=document.getElementById(e);if(!n)return;const i="string"==typeof t.code?t.code:null;if(!i)return void(n.innerHTML='<p style="color:#c00;padding:12px">No chart code found.</p>');const o=window.vizD3Renderer&&window.vizD3Renderer.iframeJsUrl?window.vizD3Renderer.iframeJsUrl:null;function r(){const r=n.offsetWidth||800,d=n.offsetHeight||400,a='<!DOCTYPE html><html><head><meta charset="utf-8"><style>*{margin:0;padding:0;box-sizing:border-box}body{overflow:hidden}#chart{width:100%;height:100vh}</style></head><body><div id="chart"></div><script src="'+o+'"><\/script></body></html>',s=document.createElement("iframe");s.setAttribute("sandbox","allow-scripts"),s.setAttribute("srcdoc",a),s.setAttribute("data-viz-id",e),s.style.cssText="border:0;width:"+r+"px;height:"+d+"px;display:block;",window.addEventListener("message",(function e(n){if(n.source!==s.contentWindow)return;const o=n.data;o&&"iframe-ready"===o.type&&(window.removeEventListener("message",e),s.contentWindow.postMessage({type:"render",code:i,series:t.series,data:t.data},"*"))})),n.innerHTML="",n.appendChild(s)}o?requestAnimationFrame((()=>requestAnimationFrame(r))):n.innerHTML='<p style="color:#c00;padding:12px">D3 renderer iframe URL not configured.</p>'}var t;(t=jQuery)("body").on("visualizer:render:chart:start",(function(t,n){if(n.charts)if(n.id){const t=n.charts[n.id];t&&"d3"===t.library&&e(n.id,t)}else Object.keys(n.charts).forEach((t=>{const i=n.charts[t];i&&"d3"===i.library&&e(t,i)}))})),t("body").on("visualizer:action:specificchart",(function(e,t){"image"!==t.action&&"print"!==t.action||function(e,t,n){const i=document.getElementById(e);if(!i)return;const o=i.querySelector("iframe[data-viz-id]");o&&o.contentWindow&&(window.addEventListener("message",(function e(i){if(i.source!==o.contentWindow)return;const r=i.data;if(!r||"export-image-result"!==r.type)return;window.removeEventListener("message",e);const d=r.dataUrl;if(function(e){return"string"==typeof e&&/^data:image\/(png|jpeg|webp);base64,[a-z0-9+/]+=*$/i.test(e)}(d))if("print"===n){const e=window.open();if(!e)return;const t=e.document.createElement("img");t.src=d,e.document.body.appendChild(t),e.document.close(),e.onload=function(){e.print(),setTimeout(e.close,500)}}else!function(e,t){const n=document.createElement("a");n.href=e,n.download=function(e){return e?e.toLowerCase().endsWith(".png")?e:`${e}.png`:"chart.png"}(t),document.body.appendChild(n),n.click(),n.remove()}(d,t)})),o.contentWindow.postMessage({type:"export-image"},"*"))}(t.id,t?.dataObj?.name,t.action)}))})();