import{k as e,X as n,ea as t,U as r,al as a,an as l,ap as o,aV as s,E as d,a2 as i,S as c,a0 as f,q as u}from"./index-WdfADTOW.js";var m=o("<div id=swf-container style=position:relative;width:100%;height:75vh;display:flex;justify-content:center;align-items:center>");const w=()=>{const o=u(),{replace:w}=e(),[h,y]=n(!0),[p,g]=n(!1),{ruffleJSPath:v}=t();let E=r.objs.filter(e=>e.name.toLowerCase().endsWith(".swf"));0===E.length&&(E=[r.obj]);const L=e=>{const n=E.findIndex(e=>e.name===r.obj.name);"ArrowLeft"===e.key&&n>0?w(E[n-1].name):"ArrowRight"===e.key&&n<E.length-1&&w(E[n+1].name)};a(()=>{window.addEventListener("keydown",L),j()}),l(()=>{window.removeEventListener("keydown",L);const e=document.getElementById("ruffle-player");null==e||e.remove();const n=document.getElementById("ruffle-script");null==n||n.remove()});const j=()=>{y(!0),g(!1);const e=document.getElementById("ruffle-player");if(null==e||e.remove(),window.RufflePlayer)return void k();const n=document.createElement("script");n.src=v(),n.async=!0,n.id="ruffle-script",n.onload=()=>{k()},n.onerror=()=>{g(!0),y(!1),console.error("无法加载Ruffle播放器")},document.head.appendChild(n)},k=()=>{try{const e=window.RufflePlayer.newest().createPlayer();e.id="ruffle-player",e.style.width="100%",e.style.height="100%";const n=document.getElementById("swf-container");n&&(n.innerHTML="",n.appendChild(e),e.addEventListener("loaded",()=>{y(!1)}),e.addEventListener("error",()=>{g(!0),y(!1)}),e.load(r.raw_url))}catch(e){console.error("Ruffle初始化失败:",e),g(!0),y(!1)}};return I=m(),s(I,d(c,{get when(){return h()},get children(){return d(i,{})}}),null),s(I,d(c,{get when(){return p()},get children(){return d(f,{get msg(){return o("preview.failed_load_swf")},h:"75vh"})}}),null),I;var I};export{w as default};
