import{k as Y,j as g,t as I,h as P,m as $,p as i,f as F,i as x,v as H,A as C,y as b,s as J,F as M,z as Q,x as R,w as U}from"./web.Os7kOAdY.js";import{c as X}from"./clipboard.BNxbz_oK.js";import{g as V,t as Z}from"./i18n-runtime._BAkvU05.js";var ee=C('<div style=display:flex;flex-direction:column;gap:16px><div style=display:flex;flex-direction:column;gap:12px></div><div style=display:flex;gap:8px;align-items:center><span style=color:#aaa;font-size:13px></span><button style="padding:4px 12px;border:none;border-radius:4px;cursor:pointer;font-size:12px">HTTP Header</button><button style="padding:4px 12px;border:none;border-radius:4px;cursor:pointer;font-size:12px">Meta Tag</button></div><div style=position:relative><pre style=background:#111;color:#0f0;padding:14px;border-radius:8px;font-size:12px;overflow:auto;margin:0;white-space:pre-wrap;word-break:break-all></pre><button style="position:absolute;top:8px;right:8px;padding:4px 10px;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:12px">'),te=C('<fieldset style="border:1px solid #333;padding:10px 12px;border-radius:6px;margin:0"><legend style=color:#7ecfff;font-size:13px;font-weight:bold;font-family:monospace></legend><div style=display:flex;gap:6px;flex-wrap:wrap;margin-bottom:6px></div><input type=text style="width:100%;padding:5px 8px;background:#111;color:#fff;border:1px solid #444;border-radius:4px;font-size:12px;font-family:monospace">'),ne=C("<label><input type=checkbox style=accent-color:#7ecfff><span style=font-family:monospace>");const ae=["'self'","'unsafe-inline'","'unsafe-eval'","'none'","'strict-dynamic'","'unsafe-hashes'","data:","blob:","https:","http:"],oe=[{name:"default-src",label:"default-src"},{name:"script-src",label:"script-src"},{name:"style-src",label:"style-src"},{name:"img-src",label:"img-src"},{name:"font-src",label:"font-src"},{name:"connect-src",label:"connect-src"},{name:"frame-src",label:"frame-src"},{name:"media-src",label:"media-src"},{name:"object-src",label:"object-src"},{name:"base-uri",label:"base-uri"},{name:"form-action",label:"form-action"}];function ie(){const[q,S]=g(V(),{equals:!1}),_=e=>Z(e,q());I(()=>{const e=n=>{const a=n.detail?.locale;a&&S(a)};window.addEventListener("taitan:locale-change",e),S(V()),J(()=>window.removeEventListener("taitan:locale-change",e))});const[k,w]=g(oe.map(e=>({name:e.name,label:e.label,values:e.name==="default-src"?["'self'"]:[],customOrigins:""}))),[E,z]=g(!1),[p,T]=g("header");function A(e,n){w(a=>{const o=[...a],s={...o[e]};return s.values.includes(n)?s.values=s.values.filter(l=>l!==n):n==="'none'"?s.values=["'none'"]:s.values=[...s.values.filter(l=>l!=="'none'"),n],o[e]=s,o})}function D(e,n){w(a=>{const o=[...a];return o[e]={...o[e],customOrigins:n},o})}const O=P(()=>{const e=[];for(const n of k()){const a=[...n.values],o=n.customOrigins.trim().split(/[\s,]+/).filter(Boolean);a.push(...o),a.length>0&&e.push(`${n.name} ${a.join(" ")}`)}return e.join("; ")}),j=P(()=>p()==="meta"?`<meta http-equiv="Content-Security-Policy" content="${O()}" />`:`Content-Security-Policy: ${O()}`);async function B(){await X(j()),z(!0),setTimeout(()=>z(!1),1500)}const G={display:"inline-flex","align-items":"center",gap:"4px",padding:"2px 8px",background:"#1a1a2e","border-radius":"4px","font-size":"12px",color:"#ccc",cursor:"pointer"};return(()=>{var e=$(ee),n=e.firstChild,a=n.nextSibling,o=a.firstChild,s=o.nextSibling,l=s.nextSibling,K=a.nextSibling,L=K.firstChild,y=L.nextSibling;return i(n,F(M,{get each(){return k()},children:(t,d)=>(()=>{var u=$(te),f=u.firstChild,m=f.nextSibling,c=m.nextSibling;return i(f,()=>t.name),i(m,F(M,{each:ae,children:r=>(()=>{var v=$(ne),h=v.firstChild,N=h.nextSibling;return h.addEventListener("change",()=>A(d(),r)),i(N,r),x(W=>Q(v,{...G,background:t.values.includes(r)?"#234":"#1a1a2e",border:t.values.includes(r)?"1px solid #7ecfff":"1px solid #333"},W)),x(()=>R(h,"checked",t.values.includes(r))),v})()})),c.$$input=r=>D(d(),r.currentTarget.value),x(()=>U(c,"placeholder",_("自定义源 (空格分隔，如 https://cdn.example.com)"))),x(()=>R(c,"value",t.customOrigins)),H(),u})()})),i(o,()=>_("输出格式：")),s.$$click=()=>T("header"),l.$$click=()=>T("meta"),i(L,j),y.$$click=B,i(y,()=>E()?"已复制":"复制"),x(t=>{var d=p()==="header"?"#7ecfff":"#222",u=p()==="header"?"#000":"#ccc",f=p()==="meta"?"#7ecfff":"#222",m=p()==="meta"?"#000":"#ccc",c=E()?"#2d5a27":"#333";return d!==t.e&&b(s,"background",t.e=d),u!==t.t&&b(s,"color",t.t=u),f!==t.a&&b(l,"background",t.a=f),m!==t.o&&b(l,"color",t.o=m),c!==t.i&&b(y,"background",t.i=c),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),H(),e})()}Y(["click","input"]);export{ie as default};
