import{k as te,j as f,t as ne,g as ie,m as re,n as w,p as t,w as _,i as S,v as oe,B as le,A as ae,x as D,s as se}from"./web.Os7kOAdY.js";import{g as J,t as de}from"./i18n-runtime._BAkvU05.js";var ce=ae(`<div class=tool-card style=padding:20px><div style=display:flex;gap:12px;align-items:center;margin-bottom:16px;flex-wrap:wrap><button style="padding:6px 16px;font-size:13px;border-radius:6px;cursor:pointer;background:#10b981;color:#fff;border:none;font-weight:600"></button><button style="padding:6px 16px;font-size:13px;border-radius:6px;cursor:pointer;background:var(--c-surface,#f3f4f6);color:var(--c-text,#333);border:1px solid var(--c-border,#ddd)"></button><label style=display:flex;align-items:center;gap:6px;font-size:13px;margin-left:auto;cursor:pointer><input type=checkbox><!$><!/></label><span style=font-size:12px;color:var(--c-muted,#888)><!$><!/> <!$><!/></span></div><div class=mobile-stack-grid style="display:grid;grid-template-columns:1fr 1fr;gap:16px;min-height:500px"><div style=display:flex;flex-direction:column><div style=font-size:12px;font-weight:600;margin-bottom:6px;color:var(--c-muted,#666)></div><textarea style="flex:1;width:100%;padding:12px;font-family:'JetBrains Mono',monospace;font-size:13px;line-height:1.5;border:1px solid var(--c-border,#ddd);border-radius:8px;resize:none;background:#1e1e2e;color:#cdd6f4;tab-size:2"></textarea></div><div style=display:flex;flex-direction:column><div style=font-size:12px;font-weight:600;margin-bottom:6px;color:var(--c-muted,#666)></div><div style="flex:1;border:1px solid var(--c-border,#ddd);border-radius:8px;overflow:hidden;background:#fff"><iframe sandbox="allow-scripts allow-modals"title="HTML Preview"style=width:100%;height:100%;border:none;min-height:460px></iframe></div></div></div><div style="margin-top:12px;padding:10px 14px;background:var(--c-surface,#f9fafb);border-radius:6px;font-size:12px;color:var(--c-muted,#666)">`);const s=`<!DOCTYPE html>
<html>
<head>
  <style>
    body {
      font-family: system-ui, sans-serif;
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
      margin: 0;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    .card {
      background: white;
      padding: 2rem 3rem;
      border-radius: 16px;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
      text-align: center;
    }
    h1 { color: #333; margin: 0 0 0.5rem; }
    p { color: #666; margin: 0; }
    button {
      margin-top: 1rem;
      padding: 0.5rem 1.5rem;
      border: none;
      background: #764ba2;
      color: white;
      border-radius: 8px;
      cursor: pointer;
      font-size: 1rem;
    }
    button:hover { background: #667eea; }
  </style>
</head>
<body>
  <div class="card">
    <h1>Hello World</h1>
    <p>在左侧编辑 HTML/CSS/JS，实时预览效果</p>
    <button onclick="document.querySelector('h1').textContent='Clicked!'">
      点击试试
    </button>
  </div>
</body>
</html>`;function ge(){const[j,k]=f(J(),{equals:!1}),n=e=>de(e,j());ne(()=>{const e=c=>{const r=c.detail?.locale;r&&k(r)};window.addEventListener("taitan:locale-change",e),k(J()),se(()=>window.removeEventListener("taitan:locale-change",e))});const[o,g]=f(s),[T,x]=f(s),[C,q]=f(!0);let u,b;const m=typeof window<"u"&&window.location.protocol==="chrome-extension:"?"/html-preview-sandbox.html":"",d=e=>{m&&b?.contentWindow?.postMessage({type:"lvonce-html-preview",html:e},"*")};ie(()=>{const e=o();C()&&(u&&clearTimeout(u),u=setTimeout(()=>{x(e),d(e)},600))});const B=()=>{x(o()),d(o())},F=()=>{g(s),x(s),d(s)};return(()=>{var e=re(ce),c=e.firstChild,r=c.firstChild,v=r.nextSibling,h=v.nextSibling,y=h.firstChild,N=y.nextSibling,[U,W]=w(N.nextSibling),$=h.nextSibling,O=$.firstChild,[E,Y]=w(O.nextSibling),G=E.nextSibling,I=G.nextSibling,[K,Q]=w(I.nextSibling),L=c.nextSibling,z=L.firstChild,M=z.firstChild,p=M.nextSibling,V=z.nextSibling,H=V.firstChild,X=H.nextSibling,l=X.firstChild,Z=L.nextSibling;r.$$click=B,t(r,()=>n("▶ 运行")),v.$$click=F,t(v,()=>n("重置")),y.addEventListener("change",i=>q(i.currentTarget.checked)),t(h,()=>n("自动刷新"),U,W),t($,()=>o().length,E,Y),t($,()=>n("字符"),K,Q),t(M,()=>n("HTML / CSS / JS 编辑器")),p.$$keydown=i=>{if(i.key==="Tab"){i.preventDefault();const a=i.currentTarget,R=a.selectionStart,ee=a.selectionEnd,A=a.value;g(A.substring(0,R)+"  "+A.substring(ee)),setTimeout(()=>{a.selectionStart=a.selectionEnd=R+2},0)}},p.$$input=i=>g(i.currentTarget.value),_(p,"spellcheck",!1),t(H,()=>n("实时预览")),l.addEventListener("load",()=>d(T()));var P=b;return typeof P=="function"?le(P,l):b=l,_(l,"src",m||void 0),t(Z,()=>n("提示：支持完整的 HTML 文档（含 &lt;style&gt; 和 &lt;script&gt;），iframe 沙箱环境运行，Tab 键插入缩进。")),S(()=>_(l,"srcdoc",m?void 0:T())),S(()=>D(y,"checked",C())),S(()=>D(p,"value",o())),oe(),e})()}te(["click","input","keydown"]);export{ge as default};
