import{C as e,D as t,E as n,F as r,H as i,I as a,Q as o,S as s,T as c,U as l,X as u,Y as d,_ as f,a as p,b as m,g as h,i as g,l as _,n as ee,p as te,y as v}from"./app-BNNvMbNy.js";import{t as y}from"./i18n-BjJj2gGS.js";import{t as b}from"./AdminLayout-C1Rf_3q-.js";import{t as x}from"./UploadButton-BvsKj9dO.js";var S={key:0,class:`mb-5 rounded-xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-300`},C={class:`grid gap-6 lg:grid-cols-2`},w={class:`rounded-2xl border border-line bg-surface p-6`},T={class:`mb-4 text-sm font-bold text-ink`},E={class:`block text-sm font-medium text-ink-2`},D={class:`flex items-center gap-3`},O={class:`text-sm text-ink-2`},k=[`disabled`],A={class:`mt-4 text-xs text-ink-muted`},j={class:`rounded-2xl border border-line bg-surface p-6`},M={class:`mb-1 text-sm font-bold text-ink`},N={class:`mb-4 text-xs text-ink-muted`},ne={class:`flex flex-wrap items-center gap-3`},P=[`src`],F={class:`mt-4`},I={class:`mt-6 rounded-2xl border border-line bg-surface p-6`},L={class:`text-sm font-bold text-ink`},R={class:`mt-1 text-xs text-ink-muted`},z={class:`mt-4 flex flex-wrap items-center gap-x-6 gap-y-2 text-sm`},B={class:`flex items-center gap-2`},V={class:`text-ink-2`},H={key:0,class:`font-mono text-xs text-ink-muted`},U={class:`text-ink-muted`},W={class:`mt-4`},G=[`disabled`],K={class:`mt-2 text-xs text-amber-500`},q=t({__name:`Pwa`,props:{values:{},icons:{},push:{}},setup(t){let q=t,J=p(),Y=v(()=>J.props.flash?.status),X=g({short_name:q.values.short_name,banner:q.values.banner});function Z(){X.post(`/admin/pwa`,{preserveScroll:!0})}let Q=g({icon:null});function re(e){Q.icon=e,Q.post(`/admin/pwa/icon`,{preserveScroll:!0,forceFormData:!0})}let $=g({});function ie(){let e=q.push.configured?y(`Generate new push keys? Every member with push enabled will need to turn it back on. Use this only if push is broken.`):y(`Generate push notification keys now?`);confirm(e)&&$.post(`/admin/pwa/vapid`,{preserveScroll:!0})}return(p,g)=>(r(),e(f,null,[n(d(ee),{title:d(y)(`Admin · PWA`)},null,8,[`title`]),n(b,null,{title:i(()=>[c(o(d(y)(`Progressive Web App`)),1)]),subtitle:i(()=>[c(o(d(y)(`Install experience, icons & push`)),1)]),default:i(()=>[Y.value?(r(),e(`div`,S,o(Y.value),1)):s(``,!0),m(`div`,C,[m(`section`,w,[m(`h3`,T,o(d(y)(`Install settings`)),1),m(`form`,{class:`space-y-5`,onSubmit:h(Z,[`prevent`])},[m(`div`,null,[m(`label`,E,o(d(y)(`App short name (home-screen label)`)),1),l(m(`input`,{"onUpdate:modelValue":g[0]||=e=>d(X).short_name=e,type:`text`,maxlength:`30`,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-ink focus:border-indigo-500 focus:ring-indigo-500`},null,512),[[te,d(X).short_name]])]),m(`label`,D,[l(m(`input`,{"onUpdate:modelValue":g[1]||=e=>d(X).banner=e,type:`checkbox`,class:`rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500`},null,512),[[_,d(X).banner]]),m(`span`,O,o(d(y)(`Show the “install app” banner on supported devices`)),1)]),m(`button`,{type:`submit`,disabled:d(X).processing,class:`rounded-lg bg-indigo-500 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-600 disabled:opacity-60`},o(d(y)(`Save`)),9,k)],32),m(`p`,A,[c(o(d(y)(`The theme color comes from the brand color in`))+` `,1),m(`strong`,null,o(d(y)(`Theme`)),1),g[2]||=c(`.`,-1)])]),m(`section`,j,[m(`h3`,M,o(d(y)(`App icons`)),1),m(`p`,N,o(d(y)(`Upload one square image — every PWA/favicon size is generated automatically (WebP/PNG).`)),1),m(`div`,ne,[(r(!0),e(f,null,a(t.icons,t=>(r(),e(`img`,{key:t,src:t,class:`h-12 w-12 rounded-lg border border-line`,alt:``},null,8,P))),128))]),m(`div`,F,[n(x,{uploading:d(Q).processing,label:d(y)(`Choose app icon`),accept:`image/png,image/jpeg,image/webp`,onFile:re},null,8,[`uploading`,`label`])])])]),m(`section`,I,[m(`h3`,L,o(d(y)(`Push notification keys (VAPID)`)),1),m(`p`,R,o(d(y)(`VAPID keys sign browser push notifications. They normally come from your server config — regenerate them here only if push has stopped working (e.g. corrupted keys).`)),1),m(`div`,z,[m(`span`,B,[m(`span`,{class:u([`h-2 w-2 rounded-full`,t.push.configured?`bg-emerald-500`:`bg-amber-500`])},null,2),m(`span`,V,o(t.push.configured?d(y)(`Push keys are configured`):d(y)(`No push keys yet`)),1)]),t.push.publicKey?(r(),e(`span`,H,o(d(y)(`Public key`))+`: `+o(t.push.publicKey),1)):s(``,!0),m(`span`,U,o(d(y)(`{n} device(s) subscribed`,{n:t.push.subscriptions})),1)]),m(`div`,W,[m(`button`,{type:`button`,disabled:d($).processing,class:`rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm font-semibold text-ink hover:bg-appbg disabled:opacity-60`,onClick:ie},o(d($).processing?d(y)(`Generating…`):t.push.configured?d(y)(`Regenerate push keys`):d(y)(`Generate push keys`)),9,G),m(`p`,K,o(d(y)(`Heads up: regenerating invalidates every existing subscription — members will have to re-enable push on their devices.`)),1)])])]),_:1})],64))}});export{q as default};