import{l as E,h as e}from"./schema-B1NKxfZc.js";import{m as F}from"./spine-showcase-BBAaV6oO.js";const H=["dark","checker","light"],R={dark:[.078,.067,.055],checker:[.145,.145,.145],light:[.812,.78,.729]};async function N(){const u=await E(),d=await fetch(`${u.assetBase}/spine/index.json`).then(n=>n.json()),b=new URLSearchParams(location.search);let a,s=null,o="",m=!0,h=Number(b.get("scale"))||1100,c=!b.get("scale"),g="dark";const x=e("input.sl-search",{type:"search",placeholder:`Filter ${d.length} sets…`,oninput:()=>y()}),f=e("div.sl-list"),C=e("span.sl-title"),S=e("span.sl-path"),M=e("span.sl-path"),l=e("div.sl-stage"),$=e("div.sl-anims"),w=e("input",{type:"checkbox",checked:!0,onchange:()=>{m=w.checked,o&&s?.play(o,m)}}),B=e("input",{type:"range",min:"200",max:"8000",step:"25",value:String(h),oninput:()=>{h=+B.value,c=!1,k(),v()}}),L=e("span",{},"fit"),A=e("button.sl-fit",{onclick:()=>{c=!0,k(),v()}},"Fit"),k=()=>{L.textContent=c?"fit":String(h),A.classList.toggle("on",c)},I=e("select",{onchange:()=>{g=I.value,v()}},...H.map(n=>e("option",{value:n},n))),T=e("div.sl-bar",{},C,S,M,e("label",{},w,"loop"),e("label",{},"scale",B,L,A),e("label",{},"bg",I));document.getElementById("app").append(e("div.sl-side",{},x,f),e("div.sl-main",{},T,l,$));function v(){s?.destroy(),s=null,l.querySelector(".sl-err")?.remove();for(const t of[...l.querySelectorAll("canvas")])t.remove();if(l.className=`sl-stage ${g}`,!a)return;const n=a;s=F(l,u.assetBase,n.group,n.name,o||n.animations[0]||"",t=>{l.append(e("div.sl-err",{},`${n.name}: ${t.message}`))},c?{fill:.95,bottomMargin:.02,widthSlack:3,boundsMode:"all",clearColor:R[g]}:{unitHeight:h,bottomMargin:.02,widthSlack:3,boundsMode:"all",clearColor:R[g]}),o&&s.play(o,m);const i=setInterval(()=>{const t=s?.info();if(!t)return;clearInterval(i);const r=t.fit,p=t.view;M.textContent=r&&p?`bounds ${Math.round(r.refW)}x${Math.round(r.refH)} @cx ${Math.round(r.cx)} bottom ${Math.round(r.bottomY)}  ·  view ${Math.round(p.w)}x${Math.round(p.h)} @ ${Math.round(p.x)},${Math.round(p.y)}`:""},250);setTimeout(()=>clearInterval(i),15e3)}function j(n){a=n,o=n.animations[0]??"",C.textContent=n.name,S.textContent=`spine/${n.group?`${n.group}/`:""}${n.name}  ·  ${n.pages} page${n.pages===1?"":"s"}`+(n.skins.length>1?`  ·  skins: ${n.skins.join(", ")}`:""),history.replaceState(null,"",`?set=${encodeURIComponent(n.name)}`),y(),q(),v()}function q(){if($.replaceChildren(),!!a){if(!a.animations.length){$.append(e("span.sl-none",{},"This set has no animations."));return}for(const n of a.animations)$.append(e("button.sl-anim"+(n===o?".on":""),{onclick:()=>{o=n,q(),s?.play(n,m)}},n))}}function y(){const n=x.value.trim().toLowerCase();f.replaceChildren();let i;for(const t of d)n&&!`${t.group??""} ${t.name}`.toLowerCase().includes(n)||(t.group!==i&&(i=t.group,f.append(e("div.sl-group",{},i??"ungrouped"))),f.append(e("button.sl-item"+(t===a?".on":""),{onclick:()=>j(t)},e("span",{},t.name),e("span.sl-count",{},String(t.animations.length)))))}k(),y(),j(d.find(n=>n.name===b.get("set"))??d[0])}N().catch(u=>{document.body.insertAdjacentText("beforeend",`fatal: ${u.message}`)});
