1import{i as f,ay as R,az as T,aA as D,aB as I,aC as L,I as M,u as G,r as v,aD as E,j as e,aE as P}from"./index-CMjJqRFh.js";import{R as V,L as S}from"./Logo-AfP5kKSv.js";function _(t){const{id:r,is_active:c,created_at:d,updated_at:x,...i}=t;return i}function J(){const t=f(R),r=f(T),c=f(D),d=f(I),x=f(L),i=M(),u=G({queryKey:["brand","versions"],queryFn:()=>t({data:void 0})}),h=u.data??[],[g,j]=v.useState(null),[s,y]=v.useState(_(E)),[k,m]=v.useState(!1),[B,l]=v.useState(null);v.useEffect(()=>{if(!g&&h.length>0){const a=h.find(C=>C.is_active)??h[0];j(a.id),y(_(a))}},[h,g]);const n=h.find(a=>a.id===g)??null;function o(a,C){y(Q=>({...Q,[a]:C}))}async function F(){if(n){m(!0),l(null);try{await r({data:{id:n.id,...s}}),await i.invalidateQueries({queryKey:["brand"]}),l("Sparat.")}catch(a){l(a instanceof Error?a.message:"Kunde inte spara")}finally{m(!1)}}}async function K(){m(!0),l(null);try{const a=await c({data:{...s,version:H(h,s.version)}});await i.invalidateQueries({queryKey:["brand"]}),j(a.id),y(_(a)),l(`Ny version ${a.version} sparad (inaktiv).`)}catch(a){l(a instanceof Error?a.message:"Kunde inte skapa version")}finally{m(!1)}}async function A(){if(!(!n||n.is_active)){m(!0),l(null);try{await d({data:{id:n.id}}),await i.invalidateQueries({queryKey:["brand"]}),l(`Version ${n.version} aktiverad â live pÃ¥ sajten.`)}catch(a){l(a instanceof Error?a.message:"Kunde inte aktivera")}finally{m(!1)}}}async function q(){if(!(!n||n.is_active)&&confirm(`Ta bort version ${n.version}?`)){m(!0);try{await x({data:{id:n.id}}),await i.invalidateQueries({queryKey:["brand"]}),j(null),l("Version borttagen.")}catch(a){l(a instanceof Error?a.message:"Kunde inte ta bort")}finally{m(!1)}}}const p=n?{...n,...s}:{...E,...s};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("header",{className:"flex items-baseline justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-extrabold tracking-tight",children:"Grafisk profil"}),e.jsx("p",{className:"mt-1 text-sm text-zinc-600",children:"Redigera färger, märke och wordmark. Ãndringar är förhandsvisning tills du aktiverar en version."})]})}),e.jsxs("section",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono text-[11px] uppercase tracking-widest text-zinc-500",children:"Versioner"}),u.isLoading&&e.jsx("span",{className:"text-xs text-zinc-400",children:"Laddarâ¦"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(a=>e.jsxs("button",{onClick:()=>{j(a.id),y(_(a)),l(null)},className:`rounded-md border px-3 py-1.5 text-xs font-medium ${a.id===g?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-200 bg-white text-zinc-700 hover:bg-zinc-50"}`,children:[a.version,a.is_active&&e.jsx("span",{className:"ml-2 rounded-sm bg-emerald-500/20 px-1 py-0.5 font-mono text-[9px] uppercase text-emerald-700",children:"live"})]},a.id))})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[1fr_440px]",children:[e.jsxs("section",{className:"space-y-6 rounded-lg border border-zinc-200 bg-white p-6",children:[e.jsx(b,{label:"Version-namn",children:e.jsx("input",{type:"text",value:s.version,onChange:a=>o("version",a.target.value),className:"w-full rounded-md border border-zinc-300 px-3 py-2 font-mono text-sm"})}),e.jsxs($,{title:"Färg",children:[e.jsx(N,{label:"Ink",value:s.ink_color,onChange:a=>o("ink_color",a)}),e.jsx(N,{label:"Paper",value:s.paper_color,onChange:a=>o("paper_color",a)}),e.jsx(N,{label:"Border",value:s.border_color,onChange:a=>o("border_color",a)}),e.jsx(N,{label:"Muted",value:s.muted_color,onChange:a=>o("muted_color",a)})]}),e.jsxs($,{title:"Märke (Reticle)",children:[e.jsx(w,{label:"Stroke-bredd",value:s.mark_stroke_width,min:.5,max:6,step:.5,onChange:a=>o("mark_stroke_width",a)}),e.jsx(w,{label:"Hörn-längd",value:s.mark_corner_length,min:2,max:12,step:1,onChange:a=>o("mark_corner_length",a)}),e.jsx(w,{label:"Pricksstorlek",value:s.mark_dot_size,min:1,max:8,step:1,onChange:a=>o("mark_dot_size",a)}),e.jsx(w,{label:"Animation (ms)",value:s.animation_speed_ms,min:400,max:8e3,
1step:100,onChange:a=>o("animation_speed_ms",Math.round(a))})]}),e.jsxs($,{title:"Wordmark",children:[e.jsx(b,{label:"Text",children:e.jsx("input",{type:"text",value:s.wordmark_text,onChange:a=>o("wordmark_text",a.target.value),className:"w-full rounded-md border border-zinc-300 px-3 py-2 text-sm"})}),e.jsx(b,{label:"Suffix",children:e.jsx("input",{type:"text",value:s.wordmark_suffix,onChange:a=>o("wordmark_suffix",a.target.value),className:"w-full rounded-md border border-zinc-300 px-3 py-2 font-mono text-sm"})}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:s.show_suffix,onChange:a=>o("show_suffix",a.target.checked)}),"Visa suffix"]})]}),e.jsx(b,{label:"Anteckningar",children:e.jsx("textarea",{value:s.notes??"",onChange:a=>o("notes",a.target.value),rows:2,className:"w-full rounded-md border border-zinc-300 px-3 py-2 text-sm"})}),e.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-zinc-200 pt-4",children:[e.jsx("button",{onClick:F,disabled:k||!n,className:"rounded-md bg-zinc-900 px-4 py-2 text-sm font-bold text-white disabled:opacity-50",children:"Spara ändringar"}),e.jsx("button",{onClick:K,disabled:k,className:"rounded-md border border-zinc-300 px-4 py-2 text-sm font-medium hover:bg-zinc-50",children:"Spara som ny version"}),e.jsx("button",{onClick:A,disabled:k||!n||n.is_active,className:"rounded-md border border-emerald-600 bg-emerald-600 px-4 py-2 text-sm font-bold text-white disabled:opacity-40",children:"Aktivera (publicera)"}),e.jsx("button",{onClick:q,disabled:k||!n||n.is_active,className:"ml-auto rounded-md border border-red-300 px-4 py-2 text-sm font-medium text-red-700 disabled:opacity-40",children:"Ta bort"})]}),B&&e.jsx("p",{className:"font-mono text-xs uppercase tracking-widest text-zinc-600",children:B})]}),e.jsx(P,{override:p,children:e.jsxs("aside",{className:"space-y-4",children:[e.jsx("h2",{className:"font-mono text-[11px] uppercase tracking-widest text-zinc-500",children:"Förhandsvisning"}),e.jsx("div",{className:"rounded-lg border p-8",style:{background:p.paper_color,borderColor:p.border_color},children:e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsx(V,{size:140,animated:!0}),e.jsx(S,{variant:"horizontal",size:40}),e.jsx(S,{variant:"stacked",size:56})]})}),e.jsx("div",{className:"rounded-lg p-8",style:{background:p.ink_color},children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(S,{variant:"horizontal",size:36,tone:"paper"}),e.jsx(V,{size:64,tone:"paper"})]})}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-[10px]",children:[e.jsx(z,{label:"ink",hex:p.ink_color}),e.jsx(z,{label:"paper",hex:p.paper_color}),e.jsx(z,{label:"border",hex:p.border_color}),e.jsx(z,{label:"muted",hex:p.muted_color})]})]})})]})]})}function H(t,r){const c=new Set(t.map(i=>i.version));if(!c.has(r))return r;const d=r.match(/^v?(\d+)\.(\d+)$/);if(d){let i=Number(d[1]),u=Number(d[2])+1;for(;c.has(`v${i}.${u}`);)u++;return`v${i}.${u}`}let x=2;for(;c.has(`${r} (${x})`);)x++;return`${r} (${x})`}function b({label:t,children:r}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"font-mono text-[10px] uppercase tracking-widest text-zinc-500",children:t}),r]})}function $({title:t,children:r}){return e.jsxs("fieldset",{className:"space-y-3 rounded-md border border-zinc-200 p-4",children:[e.jsx("legend",{className:"px-2 font-mono text-[10px] uppercase tracking-widest text-zinc-500",children:t}),r]})}function N({label:t,value:r,onChange:c}){return e.jsx(b,{label:t,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:r,onChange:d=>c(d.target.value),className:"h-10 w-14 cursor-pointer rounded border border-zinc-300"}),e.jsx("input",{type:"text",value:r,onChange:d=>c(d.target.value),className:"flex-1 rounded-md border border-zinc-300 px-3 py-2 font-mono text-sm uppercase"})]})})}function w({label:t,value:r,min:c,max:d,step:x,onChange:i}){return e.jsx(b,{label:`${t} · ${r}`,children:e.jsx("input",{type:"range",value:r,min:c,max:d,step:x,onChange:u=>i(Number(u.target.value)),className:"w-full"})})}function z({label:t,hex:r}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"h-10 w-full rounded border border-zinc-200",style:{background:r}}),e.jsxs("div",{className:"flex items-center justify-between font-mono uppercase text-zinc-500",children:[e.jsx("span",{children:t}),e.jsx("span",{children:r})]})]})}export{J as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.