import{k as Qe,j as i,t as Ve,m as c,n as Xe,p as t,f as Ze,i as a,v as _e,x as n,A as u,s as et,S as tt}from"./web.Os7kOAdY.js";import{c as be,d as xe}from"./clipboard.BNxbz_oK.js";import{g as Se,t as lt}from"./i18n-runtime._BAkvU05.js";var nt=u("<div class=tool-field><span class=tool-label></span><pre class=tool-pre style=font-size:12px;max-height:300px;overflow:auto>"),st=u('<div class=tool-actions><button class="tool-btn is-ghost"></button><button class="tool-btn is-ghost">'),it=u('<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><input class=tool-input></div><div class=tool-field><span class=tool-label></span><input class=tool-input></div></div><div class=tool-field><span class=tool-label></span><input class=tool-input></div><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><input class=tool-input></div><div class=tool-field><span class=tool-label>Scope</span><input class=tool-input></div></div><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><select class=tool-input></select></div><div class=tool-field><span class=tool-label></span><select class=tool-input></select></div></div><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><div style=display:flex;gap:8px;align-items:center><input type=color style=width:36px;height:30px;border:none;cursor:pointer><input class=tool-input style=flex:1></div></div><div class=tool-field><span class=tool-label></span><div style=display:flex;gap:8px;align-items:center><input type=color style=width:36px;height:30px;border:none;cursor:pointer><input class=tool-input style=flex:1></div></div></div><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><input class=tool-input></div><div class=tool-field><span class=tool-label></span><input class=tool-input></div></div><div class=tool-field><span class=tool-label></span><input class=tool-input placeholder=zh-CN></div><div class=tool-field><span class=tool-label>manifest.json</span><pre class=tool-pre style=font-size:12px;max-height:260px;overflow:auto></pre></div><div class=tool-actions><button class="tool-btn is-primary"></button><button class="tool-btn is-ghost"></button><button class="tool-btn is-ghost"></button></div><!$><!/><p class=tool-hint>'),me=u("<option>");function ct(){const[Ce,T]=i(Se(),{equals:!1}),l=o=>lt(o,Ce());Ve(()=>{const o=p=>{const r=p.detail?.locale;r&&T(r)};window.addEventListener("taitan:locale-change",o),T(Se()),et(()=>window.removeEventListener("taitan:locale-change",o))});const[E,ye]=i("My App"),[v,Te]=i("App"),[k,Ee]=i("A progressive web application"),[w,ke]=i("/"),[A,we]=i("standalone"),[N,Ae]=i("any"),[$,j]=i("#4f8cff"),[g,L]=i("#ffffff"),[W,Ne]=i("/icons/icon-192.png"),[M,je]=i("/icons/icon-512.png"),[z,Le]=i("zh-CN"),[H,We]=i("/"),[f,Me]=i(!1);function h(){const o={name:E(),short_name:v(),description:k(),start_url:w(),display:A(),orientation:N(),theme_color:$(),background_color:g(),lang:z(),scope:H(),icons:[{src:W(),sizes:"192x192",type:"image/png"},{src:M(),sizes:"512x512",type:"image/png"}]};return JSON.stringify(o,null,2)}function _(){return`// Service Worker Template
const CACHE_NAME = '${v()}-v1';
const ASSETS = [
  '/',
  '/index.html',
  '/manifest.json',
  '/icons/icon-192.png',
  '/icons/icon-512.png',
];

self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
  );
});

self.addEventListener('fetch', (event) => {
  event.respondWith(
    caches.match(event.request).then((cached) => {
      return cached || fetch(event.request).then((response) => {
        if (response.status === 200) {
          const clone = response.clone();
          caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
        }
        return response;
      });
    })
  );
});

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) =>
      Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
    )
  );
});`}const ze=["standalone","fullscreen","minimal-ui","browser"],He=["any","portrait","landscape","portrait-primary","landscape-primary"];return(()=>{var o=c(it),p=o.firstChild,r=p.firstChild,I=r.firstChild,P=I.nextSibling,Ie=r.nextSibling,U=Ie.firstChild,q=U.nextSibling,O=p.nextSibling,D=O.firstChild,R=D.nextSibling,B=O.nextSibling,F=B.firstChild,J=F.firstChild,Y=J.nextSibling,Pe=F.nextSibling,Ue=Pe.firstChild,G=Ue.nextSibling,K=B.nextSibling,Q=K.firstChild,V=Q.firstChild,b=V.nextSibling,qe=Q.nextSibling,X=qe.firstChild,x=X.nextSibling,Z=K.nextSibling,ee=Z.firstChild,te=ee.firstChild,Oe=te.nextSibling,S=Oe.firstChild,le=S.nextSibling,De=ee.nextSibling,ne=De.firstChild,Re=ne.nextSibling,m=Re.firstChild,se=m.nextSibling,ie=Z.nextSibling,ae=ie.firstChild,oe=ae.firstChild,re=oe.nextSibling,Be=ae.nextSibling,ce=Be.firstChild,pe=ce.nextSibling,de=ie.nextSibling,ue=de.firstChild,ve=ue.nextSibling,$e=de.nextSibling,Fe=$e.firstChild,Je=Fe.nextSibling,ge=$e.nextSibling,C=ge.firstChild,y=C.nextSibling,fe=y.nextSibling,Ye=ge.nextSibling,[he,Ge]=Xe(Ye.nextSibling),Ke=he.nextSibling;return t(I,()=>l("应用名称")),P.$$input=e=>ye(e.currentTarget.value),t(U,()=>l("短名称")),q.$$input=e=>Te(e.currentTarget.value),t(D,()=>l("描述")),R.$$input=e=>Ee(e.currentTarget.value),t(J,()=>l("起始 URL")),Y.$$input=e=>ke(e.currentTarget.value),G.$$input=e=>We(e.currentTarget.value),t(V,()=>l("显示模式")),b.addEventListener("change",e=>we(e.currentTarget.value)),t(b,()=>ze.map(e=>(()=>{var s=c(me);return n(s,"value",e),t(s,e),s})())),t(X,()=>l("方向")),x.addEventListener("change",e=>Ae(e.currentTarget.value)),t(x,()=>He.map(e=>(()=>{var s=c(me);return n(s,"value",e),t(s,e),s})())),t(te,()=>l("主题色")),S.$$input=e=>j(e.currentTarget.value),le.$$input=e=>j(e.currentTarget.value),t(ne,()=>l("背景色")),m.$$input=e=>L(e.currentTarget.value),se.$$input=e=>L(e.currentTarget.value),t(oe,()=>l("图标 192x192 路径")),re.$$input=e=>Ne(e.currentTarget.value),t(ce,()=>l("图标 512x512 路径")),pe.$$input=e=>je(e.currentTarget.value),t(ue,()=>l("语言")),ve.$$input=e=>Le(e.currentTarget.value),t(Je,h),C.$$click=()=>be(h()),t(C,()=>l("复制 manifest.json")),y.$$click=()=>xe(h(),"manifest.json","application/json"),t(y,()=>l("下载 manifest.json")),fe.$$click=()=>Me(!f()),t(fe,()=>f()?"隐藏 SW 模板":"查看 Service Worker 模板"),t(o,Ze(tt,{get when(){return f()},get children(){return[(()=>{var e=c(nt),s=e.firstChild,d=s.nextSibling;return t(s,()=>l("sw.js (Service Worker 模板)")),t(d,_),e})(),(()=>{var e=c(st),s=e.firstChild,d=s.nextSibling;return s.$$click=()=>be(_()),t(s,()=>l("复制 SW 代码")),d.$$click=()=>xe(_(),"sw.js","application/javascript"),t(d,()=>l("下载 sw.js")),_e(),e})()]}}),he,Ge),t(Ke,()=>l("填写应用信息自动生成 PWA manifest.json 和 Service Worker 模板，可直接用于 PWA 项目。")),a(()=>n(P,"value",E())),a(()=>n(q,"value",v())),a(()=>n(R,"value",k())),a(()=>n(Y,"value",w())),a(()=>n(G,"value",H())),a(()=>n(b,"value",A())),a(()=>n(x,"value",N())),a(()=>n(S,"value",$())),a(()=>n(le,"value",$())),a(()=>n(m,"value",g())),a(()=>n(se,"value",g())),a(()=>n(re,"value",W())),a(()=>n(pe,"value",M())),a(()=>n(ve,"value",z())),_e(),o})()}Qe(["input","click"]);export{ct as default};
