import{C as e,D as t,E as n,G as r,H as i,L as a,P as o,Q as s,R as c,S as ee,W as l,Y as u,Z as d,_ as te,d as ne,et as f,i as re,k as p,m,p as h,r as ie,tt as ae,u as oe,v as g,w as _,x as v}from"./app-D89C2uIa.js";import{n as y}from"./toast-CAIOPcb2.js";import{t as b}from"./i18n-DlPAX0tK.js";import{t as x}from"./AdminLayout-Bxc4A-2m.js";var S={key:0},C={class:`mb-4`},w={key:0,class:`overflow-hidden rounded-2xl border border-line bg-appbg`},T=[`src`,`title`],E={key:1,class:`max-w-2xl space-y-5`},D={class:`rounded-2xl border border-line bg-surface p-5`},O={class:`flex items-start gap-3`},k={class:`min-w-0 flex-1`},A={class:`text-sm text-ink-2`},j={class:`mt-2 flex items-center gap-2`},M={class:`text-[11px] text-ink-muted`},N={key:0,class:`flex items-center gap-3`},P=[`onUpdate:modelValue`],F={class:`text-sm font-medium text-ink`},se={class:`block text-sm font-medium text-ink-2`},I=[`onUpdate:modelValue`],L=[`onUpdate:modelValue`],R=[`value`],z=[`type`,`onUpdate:modelValue`],B={key:2,class:`mt-1 text-xs text-ink-muted`},V={class:`flex items-center gap-2 pt-1 text-sm`},H={key:0,class:`text-ink-muted`},U={key:1,class:`font-semibold text-emerald-500`},W={key:2,class:`text-red-500`},G={key:3,class:`text-ink-muted`},K={key:1,class:`rounded-2xl border border-dashed border-line p-8 text-center text-sm text-ink-muted`},q=p({__name:`ExtensionSettings`,props:{ext:{}},setup(p){let q=p,J=u({...q.ext.values}),Y=u(`idle`),X=null;function Z(){Y.value=`saving`,ae.post(`/admin/marketplace/settings`,{id:q.ext.id,values:J.value},{preserveScroll:!0,preserveState:!0,only:[],onSuccess:()=>{Y.value=`saved`,y(b(`Settings saved`)),setTimeout(()=>{Y.value===`saved`&&(Y.value=`idle`)},2e3)},onError:()=>{Y.value=`error`,y(b(`Couldn't save — will retry`),`error`)}})}i(J,()=>{X&&clearTimeout(X),Y.value=`saving`,X=setTimeout(Z,700)},{deep:!0});let Q=u(null),$=null;function ce(){let e=Q.value;if(e)try{let t=e.contentDocument;if(!t)return;let n=getComputedStyle(document.documentElement),r=e=>n.getPropertyValue(e).trim(),i=(document.documentElement.dataset.theme||document.body.dataset.theme)===`dark`,a=t.createElement(`style`);a.textContent=`
      :root{
        --c-bg:${r(`--c-bg`)};--c-surface:${r(`--c-surface`)};--c-surface-2:${r(`--c-surface-2`)};
        --c-border:${r(`--c-border`)};--c-text:${r(`--c-text`)};--c-text-2:${r(`--c-text-2`)};
        --c-muted:${r(`--c-muted`)};--c-primary:${r(`--c-primary`)};
        color-scheme:${i?`dark`:`light`};
      }
      .top{display:none!important}
      a[href="/admin/marketplace"]{display:none!important}
      .wrap,.container{max-width:none!important;margin:0!important;padding:18px 20px!important}
      html,body{background:transparent!important;color:rgb(var(--c-text))!important;min-height:0!important}
      h1,h2,h3,h4{color:rgb(var(--c-text))!important}
      .card,.panel,.box,.stat,.tile,.well{background:rgb(var(--c-surface))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      .sub,.hint,.muted,.meta,.note{color:rgb(var(--c-muted))!important}
      label,.f,.chk,.lbl,legend,th{color:rgb(var(--c-text-2))!important}
      input:not([type=checkbox]):not([type=radio]),textarea,select{background:rgb(var(--c-surface-2))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      .toggle,.switch,.option-row,.field-row,.input-row{background:rgb(var(--c-surface-2))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      a:not(.btn){color:rgb(var(--c-primary))!important}
      .btn.ghost{border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text-2))!important}
      table,th,td,hr,.row,.item,.divider{border-color:rgb(var(--c-border))!important}
      ::-webkit-scrollbar{width:0;height:0}
    `,t.head.appendChild(a);let o=!!t.querySelector(`.top, .wrap, .container`),s=()=>{try{e.style.height=(t.documentElement.scrollHeight||t.body.scrollHeight)+`px`}catch{}};o?(e.style.minHeight=`0`,s(),t.body&&($=new ResizeObserver(s),$.observe(t.body))):e.style.minHeight=`78vh`}catch{e.style.minHeight=`78vh`}}return o(()=>{$?.disconnect(),$=null}),(i,o)=>(a(),ee(x,null,{title:l(()=>[n(f(p.ext.name),1)]),subtitle:l(()=>[n(f(p.ext.type===`theme`?d(b)(`Theme`):d(b)(`Extension`))+` · v`+f(p.ext.version),1),p.ext.author?(a(),_(`span`,S,` · `+f(d(b)(`by {author}`,{author:p.ext.author})),1)):e(``,!0)]),default:l(()=>[t(d(ie),{title:`${p.ext.name}`},null,8,[`title`]),v(`div`,C,[t(d(re),{href:`/admin/marketplace`,class:`inline-flex items-center gap-1.5 text-sm font-semibold text-ink-2 hover:text-ink`},{default:l(()=>[o[0]||=v(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[v(`path`,{d:`M19 12H5M12 19l-7-7 7-7`})],-1),n(` `+f(d(b)(`Marketplace`)),1)]),_:1})]),p.ext.adminUrl?(a(),_(`div`,w,[v(`iframe`,{ref_key:`frame`,ref:Q,src:p.ext.adminUrl+(p.ext.adminUrl.includes(`?`)?`&`:`?`)+`embed=1`,title:d(b)(`Extension settings`),class:`block w-full border-0`,style:{"min-height":`60vh`},onLoad:ce},null,40,T)])):(a(),_(`div`,E,[v(`div`,D,[v(`div`,O,[v(`div`,{class:s([`grid h-11 w-11 shrink-0 place-items-center rounded-xl text-lg`,p.ext.type===`theme`?`bg-fuchsia-500/15 text-fuchsia-300`:`bg-indigo-500/15 text-indigo-300`])},f(p.ext.type===`theme`?`🎨`:`🧩`),3),v(`div`,k,[v(`p`,A,f(p.ext.description),1),v(`div`,j,[v(`span`,{class:s([`rounded px-1.5 py-0.5 text-[11px] font-semibold`,p.ext.enabled?`bg-emerald-500/15 text-emerald-300`:`bg-surface-2 text-ink-2`])},f(p.ext.enabled?d(b)(`Enabled`):d(b)(`Disabled`)),3),v(`span`,M,f(p.ext.id),1)])])])]),p.ext.settings.length?(a(),_(`form`,{key:0,class:`rounded-2xl border border-line bg-surface p-5 space-y-4`,onSubmit:te(Z,[`prevent`])},[(a(!0),_(g,null,c(p.ext.settings,t=>(a(),_(`div`,{key:t.key},[t.type===`boolean`?(a(),_(`label`,N,[r(v(`input`,{type:`checkbox`,"onUpdate:modelValue":e=>J.value[t.key]=e,class:`rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500`},null,8,P),[[oe,J.value[t.key]]]),v(`span`,F,f(t.label),1)])):(a(),_(g,{key:1},[v(`label`,se,f(t.label),1),t.type===`textarea`?r((a(),_(`textarea`,{key:0,"onUpdate:modelValue":e=>J.value[t.key]=e,rows:`3`,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500`},null,8,I)),[[m,J.value[t.key]]]):t.type===`select`?r((a(),_(`select`,{key:1,"onUpdate:modelValue":e=>J.value[t.key]=e,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500`},[(a(!0),_(g,null,c(t.options||[],e=>(a(),_(`option`,{key:e.value,value:e.value},f(e.label),9,R))),128))],8,L)),[[h,J.value[t.key]]]):r((a(),_(`input`,{key:2,type:t.type===`number`?`number`:t.type===`color`?`color`:`text`,"onUpdate:modelValue":e=>J.value[t.key]=e,class:`mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500`},null,8,z)),[[ne,J.value[t.key]]])],64)),t.help?(a(),_(`p`,B,f(t.help),1)):e(``,!0)]))),128)),v(`div`,V,[Y.value===`saving`?(a(),_(`span`,H,f(d(b)(`Saving…`)),1)):Y.value===`saved`?(a(),_(`span`,U,f(d(b)(`✓ All changes saved`)),1)):Y.value===`error`?(a(),_(`span`,W,f(d(b)(`Couldn't save — will retry on next change`)),1)):(a(),_(`span`,G,f(d(b)(`Changes save automatically`)),1))])],32)):(a(),_(`p`,K,f(d(b)(`This {type} has no configurable settings.`,{type:p.ext.type})),1))]))]),_:1}))}});export{q as default};