1import{j as e,c as f,a as Pe,r as c,u as qe,b as De,d as R,B as h,P as de,C as oe,e as ce,f as xe,U as $e,g as me,h as Me,i as Qe,T as ze,k as Ae,l as pe,m as ue,X as Ve,n as Ge,D as he,o as be,p as fe,q as ge,I as B,s as je}from"./index-ced28d60.js";const He=Pe("whitespace-nowrap inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 hover-elevate ",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-xs",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-xs",outline:" border [border-color:var(--badge-outline)] shadow-xs"}},defaultVariants:{variant:"default"}});function Je({className:s,variant:r,...o}){return e.jsx("div",{className:f(He({variant:r}),s),...o})}const ye=c.forwardRef(({className:s,...r},o)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:o,className:f("w-full caption-bottom text-sm",s),...r})}));ye.displayName="Table";const ke=c.forwardRef(({className:s,...r},o)=>e.jsx("thead",{ref:o,className:f("[&_tr]:border-b",s),...r}));ke.displayName="TableHeader";const Ne=c.forwardRef(({className:s,...r},o)=>e.jsx("tbody",{ref:o,className:f("[&_tr:last-child]:border-0",s),...r}));Ne.displayName="TableBody";const _e=c.forwardRef(({className:s,...r},o)=>e.jsx("tfoot",{ref:o,className:f("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...r}));_e.displayName="TableFooter";const V=c.forwardRef(({className:s,...r},o)=>e.jsx("tr",{ref:o,className:f("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...r}));V.displayName="TableRow";const v=c.forwardRef(({className:s,...r},o)=>e.jsx("th",{ref:o,className:f("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",s),...r}));v.displayName="TableHead";const y=c.forwardRef(({className:s,...r},o)=>e.jsx("td",{ref:o,className:f("p-4 align-middle [&:has([role=checkbox])]:pr-0",s),...r}));y.displayName="TableCell";const We=c.forwardRef(({className:s,...r},o)=>e.jsx("caption",{ref:o,className:f("mt-4 text-sm text-muted-foreground",s),...r}));We.displayName="TableCaption";function ve(s){return{name:(s==null?void 0:s.name)??"",companyName:(s==null?void 0:s.companyName)??"",orgNr:(s==null?void 0:s.orgNr)??"",slug:(s==null?void 0:s.slug)??"",address:(s==null?void 0:s.address)??"",zipCode:(s==null?void 0:s.zipCode)??"",city:(s==null?void 0:s.city)??"",phone:(s==null?void 0:s.phone)??"",companyEmail:(s==null?void 0:s.companyEmail)??"",sendFromEmail:(s==null?void 0:s.sendFromEmail)??"",accentColor:(s==null?void 0:s.accentColor)??"#2563eb",darkColor:(s==null?void 0:s.darkColor)??"#1e3a5f",recoUrl:(s==null?void 0:s.recoUrl)??"",recoVenueId:(s==null?void 0:s.recoVenueId)??"",signingMethod:(s==null?void 0:s.signingMethod)??"native",termsUrl:(s==null?void 0:s.termsUrl)??"",validityDays:String((s==null?void 0:s.validityDays)??30),paymentTermsNote:(s==null?void 0:s.paymentTermsNote)??"",offerTheme:(s==null?void 0:s.offerTheme)??"varm"}}function Xe(s,r){switch(s){case"editorial":return"#f0ede7";case"cover":return`linear-gradient(180deg, ${r}cc 0%, ${r}22 100%)`;case"split":return`linear-gradient(90deg, ${r}55 0 48%, #f0ede7 48% 100%)`;case"spread":return`linear-gradient(90deg, ${r}66 0 33%, #f0ede7 33% 100%)`;case"pano":return`linear-gradient(180deg, ${r}99 0 22%, #f0ede7 22% 100%)`;default:return`linear-gradient(150deg, ${r}20 0%, ${r}44 100%)`}}function p({label:s,value:r}){return!r&&r!==0?null:e.jsxs("div",{className:"p-3 bg-slate-50/50 dark:bg-slate-800/50 rounded-lg border border-slate-200/50 dark:border-slate-700/50",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:s}),e.jsx("p",{className:"text-sm font-medium text-slate-800 dark:text-slate-200 mt-0.5 break-all",children:String(r)})]})}function u({label:s,value:r,onChange:o,type:g="text",placeholder:d}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:s}
1),e.jsx(B,{type:g,value:r,onChange:O=>o(O.target.value),placeholder:d})]})}function Ze(){var le,re,ne,ie;const s=qe(),{toast:r}=De(),{data:o}=R({queryKey:["/api/user"]}),{data:g=[]}=R({queryKey:["/api/offer-types"]}),{data:d,isLoading:O}=R({queryKey:["/api/org"],queryFn:async()=>{const a=await fetch("/api/org",{credentials:"include"});if(!a.ok)throw new Error("Kunde inte hämta teamdata");return a.json()}}),G=(le=o==null?void 0:o.user)==null?void 0:le.id,N=((ne=(re=d==null?void 0:d.members)==null?void 0:re.find(a=>a.id===G))==null?void 0:ne.orgRole)==="owner",[we,w]=c.useState(!1),[C,H]=c.useState(""),[L,J]=c.useState(""),[I,_]=c.useState(""),[K,W]=c.useState(!1),[b,T]=c.useState(null),[X,P]=c.useState(!1),[n,q]=c.useState(ve()),[D,Y]=c.useState(!1),[Z,ee]=c.useState(null),[ae,te]=c.useState(!1),[S,E]=c.useState(!1),[Ce,$]=c.useState(!1),[M,U]=c.useState(!1),{data:Q=[]}=R({queryKey:["/api/gallery"]}),Te=async a=>{const l=Array.from(a.target.files??[]);if(l.length){for(const i of l){const m=new FormData;m.append("image",i),await fetch("/api/gallery",{method:"POST",body:m,credentials:"include"})}s.invalidateQueries({queryKey:["/api/gallery"]}),r({title:`${l.length} bild${l.length>1?"er":""} uppladdad${l.length>1?"e":""}`}),a.target.value=""}},Se=async a=>{await fetch(`/api/gallery/${a}`,{method:"DELETE",credentials:"include"}),s.invalidateQueries({queryKey:["/api/gallery"]}),r({title:"Bild borttagen"})};function x(a){return l=>q(i=>({...i,[a]:l}))}function Ee(){q(ve(d==null?void 0:d.org)),P(!0)}async function Ue(){if(!C||!L||!I){r({variant:"destructive",title:"Fält saknas",description:"Alla fält måste fyllas i"});return}W(!0);try{const a=await fetch("/api/org/members",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({fullName:C,username:L,password:I})}),l=await a.json();if(!a.ok)throw new Error(l.error||"Kunde inte bjuda in");s.invalidateQueries({queryKey:["/api/org"]}),r({title:"Medlem tillagd",description:`${C} har lagts till i teamet`}),w(!1),H(""),J(""),_("")}catch(a){r({variant:"destructive",title:"Fel",description:a.message})}finally{W(!1)}}async function Fe(a){try{const l=await fetch(`/api/org/members/${a.id}`,{method:"DELETE",credentials:"include"}),i=await l.json();if(!l.ok)throw new Error(i.error||"Kunde inte ta bort");s.invalidateQueries({queryKey:["/api/org"]}),r({title:"Medlem borttagen",description:`${a.fullName||a.username} har tagits bort`}),T(null)}catch(l){r({variant:"destructive",title:"Fel",description:l.message})}}async function se(a,l){const i=[...(d==null?void 0:d.members)??[]].sort((F,Ke)=>F.memberOrder-Ke.memberOrder),m=i.findIndex(F=>F.id===a.id),j=l==="up"?m-1:m+1;if(j<0||j>=i.length)return;const k=i[j];try{await Promise.all([fetch(`/api/org/members/${a.id}/order`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({memberOrder:k.memberOrder})}),fetch(`/api/org/members/${k.id}/order`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({memberOrder:a.memberOrder})})]),s.invalidateQueries({queryKey:["/api/org"]})}catch{r({variant:"destructive",title:"Fel",description:"Kunde inte ändra ordning"})}}async function Re(){Y(!0);try{const a={name:n.name,companyName:n.companyName||null,orgNr:n.orgNr||null,slug:n.slug,address:n.address||null,zipCode:n.zipCode||null,city:n.city||null,phone:n.phone||null,companyEmail:n.companyEmail||null,sendFromEmail:n.sendFromEmail||null,accentColor:n.accentColor||null,darkColor:n.darkColor||null,recoUrl:n.recoUrl||null,recoVenueId:n.recoVenueId||null,signingMethod:n.signingMethod||"native",termsUrl:n.termsUrl||null,validityDays:n.validityDays?parseInt(n.validityDays,10):30,paymentTermsNote:n.paymentTermsNote||null,offerTheme:n.offerTheme||"varm"},l=await fetch("/api/org",{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(a)}),i=await l.json();if(!l.ok)throw new Error(i.error||"Kunde inte spara");s.invalidateQueries({queryKey:["/api/org"]}),s.invalidateQueries({queryKey:["/api/user"]}
1),r({title:"Sparat",description:"Organisationsinformation uppdaterad"}),P(!1)}catch(a){r({variant:"destructive",title:"Fel",description:a.message})}finally{Y(!1)}}async function z(a){E(!0);try{const l=new FormData;l.append("logo",a);const i=await fetch("/api/org/logo",{method:"POST",body:l,credentials:"include"}),m=await i.json();if(!i.ok)throw new Error(m.error||"Uppladdning misslyckades");s.invalidateQueries({queryKey:["/api/org"]}),s.invalidateQueries({queryKey:["/api/user"]}),r({title:"Logotyp uppladdad"})}catch(l){r({variant:"destructive",title:"Fel",description:l.message})}finally{E(!1)}}async function Be(){E(!0);try{const a=await fetch("/api/org/logo",{method:"DELETE",credentials:"include"}),l=await a.json();if(!a.ok)throw new Error(l.error||"Borttagning misslyckades");s.invalidateQueries({queryKey:["/api/org"]}),s.invalidateQueries({queryKey:["/api/user"]}),r({title:"Logotyp borttagen"})}catch(a){r({variant:"destructive",title:"Fel",description:a.message})}finally{E(!1)}}async function Oe(a){U(!0);try{const l=new FormData;l.append("portrait",a);const i=await fetch("/api/org/portrait",{method:"POST",body:l,credentials:"include"}),m=await i.json();if(!i.ok)throw new Error(m.error||"Uppladdning misslyckades");s.invalidateQueries({queryKey:["/api/org"]}),s.invalidateQueries({queryKey:["/api/user"]}),r({title:"Profilfoto uppladdad"})}catch(l){r({variant:"destructive",title:"Fel",description:l.message})}finally{U(!1)}}async function Le(){U(!0);try{const a=await fetch("/api/org/portrait",{method:"DELETE",credentials:"include"}),l=await a.json();if(!a.ok)throw new Error(l.error||"Borttagning misslyckades");s.invalidateQueries({queryKey:["/api/org"]}),s.invalidateQueries({queryKey:["/api/user"]}),r({title:"Profilfoto borttaget"})}catch(a){r({variant:"destructive",title:"Fel",description:a.message})}finally{U(!1)}}async function Ie(){te(!0);try{const a=await fetch("/api/user/sync-reco",{method:"POST",credentials:"include"}),l=await a.json();if(!a.ok)throw new Error(l.error||"Kunde inte synkronisera");s.invalidateQueries({queryKey:["/api/org"]}),s.invalidateQueries({queryKey:["/api/user"]}),r({title:"Reco synkroniserad",description:`Betyg: ${l.recoScore} · ${l.recoCount} omdömen hämtade`})}catch(a){r({variant:"destructive",title:"Fel",description:a.message})}finally{te(!1)}}const A=[...(d==null?void 0:d.members)??[]].sort((a,l)=>a.memberOrder-l.memberOrder),t=d==null?void 0:d.org;return O?e.jsx("div",{className:"flex-1 flex items-center justify-center bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 dark:from-slate-950 dark:via-slate-900 dark:to-indigo-950",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"relative w-12 h-12 mx-auto mb-4",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-blue-500 to-indigo-500 rounded-full animate-spin"}),e.jsx("div",{className:"absolute inset-1 bg-white dark:bg-slate-900 rounded-full"})]}),e.jsx("p",{className:"text-slate-600 dark:text-slate-400 animate-pulse",children:"Laddar team..."})]})}):e.jsxs("div",{className:"flex-1 bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 dark:from-slate-950 dark:via-slate-900 dark:to-indigo-950 p-6 overflow-auto",children:[e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h1",{className:"text-4xl font-bold bg-gradient-to-r from-blue-600 to-indigo-600 dark:from-blue-400 dark:to-indigo-400 bg-clip-text text-transparent",children:(t==null?void 0:t.name)??"Mitt team"}),N&&e.jsxs(h,{onClick:()=>w(!0),className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),"Bjud in medlem"]})]}),e.jsxs(oe,{className:"border border-slate-200/50 dark:border-slate-800/50 bg-white/60 dark:bg-slate-900/40 backdrop-blur-xl shadow-sm",children:[e.jsx(ce,{className:"pb-4",children:e.jsxs(xe,{className:"flex items-center gap-2 text-lg font-semibold text-slate-900 dark:text-slate-100",children:[e.jsx($e,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"}),"Medlemmar"]})}),e.jsx(me,{children:A.length===0?e.jsx("p",{className:"text-sm text-slate-400 text-center py-6",children:"Inga medlemmar"}):e.jsxs(ye,{children:[e.jsx(ke,{children:e.jsxs(V,{children:[e.jsx(v,{children:"Namn"}),e.jsx(v,{children:"Användarnamn"}),e.jsx(v,{children:"Roll"}),e.jsx(v,{className:"text-center",children:"Prioritet"}),N&&e.jsx(v,{className:"text-right",children:"Ã
tgärder"})]})}),e.jsx(Ne,{children:A.map((a,l)=>e.jsxs(V,{children:[e.jsx(y,{className:"font-medium text-slate-900 dark:text-slate-100",children:a.fullName||"â"}
1),e.jsx(y,{className:"text-slate-600 dark:text-slate-400 text-sm",children:a.username}),e.jsx(y,{children:e.jsx(Je,{variant:a.orgRole==="owner"?"default":"secondary",className:a.orgRole==="owner"?"bg-indigo-100 dark:bg-indigo-900/30 text-indigo-700 dark:text-indigo-300 border-0":"bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400 border-0",children:a.orgRole==="owner"?"Ãgare":"Medlem"})}),e.jsx(y,{className:"text-center text-sm text-slate-600 dark:text-slate-400",children:a.memberOrder}),N&&e.jsx(y,{className:"text-right",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:a.id!==G&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>se(a,"up"),disabled:l===0,className:"h-7 w-7 p-0 text-slate-400 hover:text-slate-700 dark:hover:text-slate-200",title:"Flytta upp",children:e.jsx(Me,{className:"h-4 w-4"})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>se(a,"down"),disabled:l===A.length-1,className:"h-7 w-7 p-0 text-slate-400 hover:text-slate-700 dark:hover:text-slate-200",title:"Flytta ner",children:e.jsx(Qe,{className:"h-4 w-4"})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>T(a),className:"h-7 w-7 p-0 text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Ta bort",children:e.jsx(ze,{className:"h-4 w-4"})})]})})})]},a.id))})]})})]}),N&&e.jsxs(oe,{className:"border border-slate-200/50 dark:border-slate-800/50 bg-white/60 dark:bg-slate-900/40 backdrop-blur-xl shadow-sm",children:[e.jsx(ce,{className:"pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xe,{className:"text-lg font-semibold text-slate-900 dark:text-slate-100",children:"Organisationsinställningar"}),!X&&e.jsxs(h,{variant:"outline",size:"sm",onClick:Ee,className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Redigera"]})]})}),e.jsx(me,{children:X?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Grundinfo"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(u,{label:"Organisationsnamn",value:n.name,onChange:x("name"),placeholder:"Ditt företagsnamn"}),e.jsx(u,{label:"Juridiskt företagsnamn",value:n.companyName,onChange:x("companyName"),placeholder:"AB Företaget"}),e.jsx(u,{label:"Organisationsnummer",value:n.orgNr,onChange:x("orgNr"),placeholder:"556000-0000"}),e.jsx(u,{label:"Slug (URL-identifierare)",value:n.slug,onChange:x("slug"),placeholder:"ditt-foretag"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Kontaktuppgifter"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(u,{label:"Adress",value:n.address,onChange:x("address"),placeholder:"Gatuadress 1"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(u,{label:"Postnummer",value:n.zipCode,onChange:x("zipCode"),placeholder:"12345"}),e.jsx(u,{label:"Stad",value:n.city,onChange:x("city"),placeholder:"Stockholm"})]}),e.jsx(u,{label:"Telefon",value:n.phone,onChange:x("phone"),placeholder:"070-000 00 00"}),e.jsx(u,{label:"Företagets e-post",value:n.companyEmail,onChange:x("companyEmail"),placeholder:"[email protected]"}),e.jsx(u,{label:"Skicka offerter frÃ¥n (e-post)",value:n.sendFromEmail,onChange:x("sendFromEmail"),placeholder:"[email protected]"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Utseende"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Accentfärg"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"color",value:n.accentColor,onChange:a=>x("accentColor")(a.target.value),className:"w-12 h-10 rounded-lg border border-slate-200 dark:border-slate-700 cursor-pointer p-0.5 bg-white dark:bg-slate-800"}),e.jsx("span",{className:"text-xs font-mono text-slate-500 uppercase",children:n.accentColor})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Mörk färg"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"color",value:n.darkColor,onChange:a=>x("darkColor")(a.target.value),className:"w-12 h-10 rounded-lg border border-slate-200 dark:border-slate-700 cursor-pointer p-0.5 bg-white dark:bg-slate-800"}),e.jsx("span",{className:"text-xs font-mono text-slate-500 uppercase",children:n.darkColor})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Logotyp"}),d!=null&&d.org.logoUrl?e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-slate-50 dark:bg-slate-800 rounded-lg border border-slate-200 dark:border-slate-700",children:e.jsx("img",{src:d.org.logoUrl,alt:"Logotyp",className:"max-h-12 max-w-[140px] object-contain"})}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(h,{type:"button",variant:"outline",size:"sm",disabled:S,asChild:!0,children:e.jsx("span",{children:S?"
1Laddar uppâ¦":"Byt logotyp"})}),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/svg+xml,image/webp",className:"sr-only",onChange:a=>{var i;const l=(i=a.target.files)==null?void 0:i[0];l&&z(l),a.target.value=""}})]}),e.jsx("button",{type:"button",onClick:Be,disabled:S,className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 underline text-left",children:"Ta bort"})]})]}):e.jsxs("label",{onDragOver:a=>{a.preventDefault(),$(!0)},onDragLeave:()=>$(!1),onDrop:a=>{var i;a.preventDefault(),$(!1);const l=(i=a.dataTransfer.files)==null?void 0:i[0];l&&z(l)},className:`flex flex-col items-center justify-center gap-1 w-full py-6 rounded-lg border-2 border-dashed cursor-pointer transition-colors ${Ce?"border-blue-400 bg-blue-50 dark:bg-blue-950/20":"border-slate-200 dark:border-slate-700 hover:border-slate-400 dark:hover:border-slate-500 bg-slate-50 dark:bg-slate-800/50"}`,children:[S?e.jsx("span",{className:"text-sm text-slate-500",children:"Laddar uppâ¦"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Dra och släpp eller klicka för att ladda upp"}),e.jsx("span",{className:"text-xs text-slate-400",children:"PNG, JPG, SVG, WEBP"})]}),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/svg+xml,image/webp",className:"sr-only",onChange:a=>{var i;const l=(i=a.target.files)==null?void 0:i[0];l&&z(l),a.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:["Profilfoto"," ",e.jsx("span",{className:"font-normal normal-case text-slate-400",children:"(visas i vissa teman)"})]}),(d==null?void 0:d.org.portraitBase64)&&e.jsxs("div",{className:"flex items-start gap-3 mb-2",children:[e.jsx("img",{src:d.org.portraitBase64,alt:"Profilfoto",style:{width:80,height:100,objectFit:"cover",borderRadius:6,border:"1px solid #e2e8f0"}}),e.jsx("button",{type:"button",onClick:Le,disabled:M,className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 underline mt-1",children:"Ta bort foto"})]}),e.jsx("input",{type:"file",accept:"image/jpeg,image/png",disabled:M,onChange:a=>{var i;const l=(i=a.target.files)==null?void 0:i[0];l&&Oe(l),a.target.value=""},className:"block w-full text-sm text-slate-500 dark:text-slate-400 file:mr-3 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-xs file:font-medium file:bg-slate-100 dark:file:bg-slate-800 file:text-slate-700 dark:file:text-slate-300 hover:file:bg-slate-200 dark:hover:file:bg-slate-700 cursor-pointer"}),M&&e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Laddar uppâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Standard tema för offerter"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Object.entries(pe).map(([a,{label:l}])=>{const i=n.offerTheme===a;return e.jsxs("button",{type:"button",onClick:()=>q(m=>({...m,offerTheme:a})),style:{padding:0,border:i?"2px solid #6366f1":"2px solid #e2e8f0",borderRadius:8,overflow:"hidden",background:"none",cursor:"pointer",outline:"none",boxShadow:i?"0 0 0 3px #ede9fe":"none",transition:"border-color 120ms, box-shadow 120ms"},children:[e.jsx("div",{style:{width:"100%",height:44,background:Xe(a,n.accentColor||"#6366f1")}}),e.jsx("div",{style:{padding:"5px 8px",textAlign:"left",fontSize:12,fontWeight:i?600:400,color:i?"#4338ca":"#374151",background:i?"#f5f3ff":"#fff"},children:l})]},a)})})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Reco-widget"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(u,{label:"Reco URL",value:n.recoUrl,onChange:x("recoUrl"),placeholder:"https://www.reco.se/foretaget"}),e.jsx(h,{type:"button",variant:"outline",size:"sm",disabled:!n.recoUrl||ae,onClick:Ie,className:"w-full",children:ae?"Hämtar omdömenâ¦":"Synkronisera Reco-data"}),e.jsx(u,{label:"Reco venue-ID",value:n.recoVenueId,onChange:x("recoVenueId"),placeholder:"12345"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Offertinställningar"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Signeringsmetod"}),e.jsxs("select",{value:n.signingMethod,onChange:a=>x("signingMethod")(a.target.value),className:"w-full px-3 py-2 border border-slate-200 dark:border-slate-700 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"native",children:"Inbyggd (portalen)"}),e.jsx("option",{value:"cling",children:"Cling e-signering"})]})]}),e.jsx(u,{label:"Giltighetstid (dagar)",value:n.validityDays,onChange:x("validityDays"),type:"number",placeholder:"30"}),e.jsx(u,{label:"Villkors-URL",value:n.termsUrl,onChange:x("termsUrl"),placeholder:"https://foretag.se/villkor"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Betal
1ningsvillkor"}),e.jsx("textarea",{value:n.paymentTermsNote,onChange:a=>x("paymentTermsNote")(a.target.value),rows:3,placeholder:"T.ex. 30 dagars betalningsvillkor, faktura skickas separat",className:"w-full px-3 py-2 border border-slate-200 dark:border-slate-700 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]}),g.length>0&&e.jsxs("div",{className:"pt-4 border-t border-slate-100 dark:border-slate-800",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1",children:"Hero-bilder"}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mb-3",children:"Visas som bakgrundsbild i offerten. Valfritt â en standardbild används annars."}),e.jsx("div",{className:"space-y-2",children:g.map(a=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 h-10 rounded-md overflow-hidden bg-slate-100 dark:bg-slate-800 shrink-0 border border-slate-200 dark:border-slate-700",children:e.jsx("img",{src:ue(a.offerType,a.heroImageUrl)??void 0,alt:a.label,className:"w-full h-full object-cover",onError:l=>{l.target.style.display="none"}})}),e.jsx("span",{className:"text-sm text-slate-700 dark:text-slate-300 flex-1 min-w-0 truncate",children:a.label}),e.jsxs("label",{className:"cursor-pointer px-2.5 py-1.5 rounded-lg text-xs font-medium bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors border border-slate-200 dark:border-slate-700 shrink-0",children:[Z===a.offerType?"Laddar upp...":"Byt bild",e.jsx("input",{type:"file",accept:"image/*",className:"sr-only",disabled:Z!==null,onChange:async l=>{var m;const i=(m=l.target.files)==null?void 0:m[0];if(i){ee(a.offerType);try{const j=new FormData;j.append("image",i);const k=await fetch(`/api/offer-types/${a.id}/hero-image`,{method:"POST",body:j,credentials:"include"});if(!k.ok)throw new Error(await k.text());s.invalidateQueries({queryKey:["/api/offer-types"]}),r({title:"Hero-bild uppdaterad"})}catch{r({title:"Kunde inte ladda upp bild",variant:"destructive"})}finally{ee(null),l.target.value=""}}}})]})]},a.id))})]}),e.jsxs("div",{className:"pt-4 border-t border-slate-100 dark:border-slate-800",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1",children:"Bildbibliotek"}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mb-3",children:"Bilder härifrÃ¥n kan användas i offertens bildgalleri. Max 30 bilder."}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 mb-3",children:[Q.map(a=>e.jsxs("div",{className:"relative group aspect-square rounded-lg overflow-hidden bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700",children:[e.jsx("img",{src:a.url,alt:a.caption??"",className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>Se(a.id),className:"absolute top-1 right-1 p-1 rounded-full bg-black/50 text-white opacity-0 group-hover:opacity-100 transition-opacity",title:"Ta bort",children:e.jsx(Ve,{size:12})})]},a.id)),Q.length<30&&e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-slate-200 dark:border-slate-700 flex flex-col items-center justify-center cursor-pointer hover:border-slate-400 dark:hover:border-slate-500 transition-colors bg-slate-50 dark:bg-slate-800/50",children:[e.jsx(de,{size:20,className:"text-slate-400 mb-1"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Lägg till"}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"sr-only",onChange:Te})]})]}),e.jsxs("p",{className:"text-xs text-slate-400",children:[Q.length,"/30 bilder"]})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-2 border-t border-slate-200 dark:border-slate-700",children:[e.jsxs(h,{onClick:Re,disabled:D,className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4"}),D?"Sparar...":"Spara ändringar"]}),e.jsx(h,{variant:"outline",onClick:()=>P(!1),disabled:D,children:"Avbryt"})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Grundinfo"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx(p,{label:"Organisationsnamn",value:t==null?void 0:t.name}),e.jsx(p,{label:"Företagsnamn",value:t==null?void 0:t.companyName}),e.jsx(p,{label:"Org.nummer",value:t==null?void 0:t.orgNr}),e.jsx(p,{label:"Slug",value:t==null?void 0:t.slug})]})]}),((t==null?void 0:t.address)||(t==null?void 0:t.city)||(t==null?void 0:t.phone)||(t==null?void 0:t.companyEmail)||(t==null?void 0:t.sendFromEmail))&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Kontakt"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx(p,{label:"Adress",value:[t==null?void 0:t.address,t==null?void 0:t.zipCode,t==null?void 0:t.city].filter(
1Boolean).join(", ")}),e.jsx(p,{label:"Telefon",value:t==null?void 0:t.phone}),e.jsx(p,{label:"Företagets e-post",value:t==null?void 0:t.companyEmail}),e.jsx(p,{label:"Skicka från",value:t==null?void 0:t.sendFromEmail})]})]}),((t==null?void 0:t.accentColor)||(t==null?void 0:t.darkColor)||(t==null?void 0:t.logoUrl)||(t==null?void 0:t.portraitBase64)||(t==null?void 0:t.offerTheme))&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Utseende"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[(t==null?void 0:t.accentColor)&&e.jsxs("div",{className:"p-3 bg-slate-50/50 dark:bg-slate-800/50 rounded-lg border border-slate-200/50 dark:border-slate-700/50",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:"Accentfärg"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("div",{className:"w-5 h-5 rounded border border-slate-200",style:{backgroundColor:t.accentColor}}),e.jsx("span",{className:"text-xs font-mono text-slate-700 dark:text-slate-300 uppercase",children:t.accentColor})]})]}),(t==null?void 0:t.darkColor)&&e.jsxs("div",{className:"p-3 bg-slate-50/50 dark:bg-slate-800/50 rounded-lg border border-slate-200/50 dark:border-slate-700/50",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:"Mörk färg"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("div",{className:"w-5 h-5 rounded border border-slate-200",style:{backgroundColor:t.darkColor}}),e.jsx("span",{className:"text-xs font-mono text-slate-700 dark:text-slate-300 uppercase",children:t.darkColor})]})]}),(t==null?void 0:t.logoUrl)&&e.jsxs("div",{className:"p-3 bg-slate-50/50 dark:bg-slate-800/50 rounded-lg border border-slate-200/50 dark:border-slate-700/50",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:"Logotyp"}),e.jsx("img",{src:t.logoUrl,alt:"Logotyp",className:"mt-2 max-h-16 max-w-xs object-contain rounded",onError:a=>{var l;a.target.style.display="none",(l=a.target.nextElementSibling)==null||l.classList.remove("hidden")}}),e.jsx("p",{className:"hidden text-xs text-slate-400 font-mono break-all mt-1",children:t.logoUrl})]}),(t==null?void 0:t.portraitBase64)&&e.jsxs("div",{className:"p-3 bg-slate-50/50 dark:bg-slate-800/50 rounded-lg border border-slate-200/50 dark:border-slate-700/50",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:"Profilfoto"}),e.jsx("img",{src:t.portraitBase64,alt:"Profilfoto",className:"mt-2 rounded object-cover",style:{width:60,height:75}})]}),(t==null?void 0:t.offerTheme)&&e.jsxs("div",{className:"p-3 bg-slate-50/50 dark:bg-slate-800/50 rounded-lg border border-slate-200/50 dark:border-slate-700/50",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider",children:"Standard tema"}),e.jsx("p",{className:"text-sm font-medium text-slate-800 dark:text-slate-200 mt-0.5",children:((ie=pe[t.offerTheme])==null?void 0:ie.label)??t.offerTheme})]})]})]}),((t==null?void 0:t.recoUrl)||(t==null?void 0:t.recoVenueId))&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Reco-widget"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx(p,{label:"Reco URL",value:t==null?void 0:t.recoUrl}),e.jsx(p,{label:"Reco venue-ID",value:t==null?void 0:t.recoVenueId})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Offertinställningar"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx(p,{label:"Signeringsmetod",value:(t==null?void 0:t.signingMethod)==="cling"?"Cling e-signering":"Inbyggd (portalen)"}),e.jsx(p,{label:"Giltighetstid",value:(t==null?void 0:t.validityDays)!=null?`${t.validityDays} dagar`:void 0}),e.jsx(p,{label:"Villkors-URL",value:t==null?void 0:t.termsUrl}),e.jsx(p,{label:"Betalningsvillkor",value:t==null?void 0:t.paymentTermsNote})]}),g.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-2",children:"Hero-bilder"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(a=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-8 h-6 rounded overflow-hidden bg-slate-100 dar
1k:bg-slate-800 border border-slate-200 dark:border-slate-700",children:e.jsx("img",{src:ue(a.offerType,a.heroImageUrl)??void 0,alt:a.label,className:"w-full h-full object-cover",onError:l=>{l.target.style.display="none"}})}),e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:a.label})]},a.id))})]})]})]})})]})]}),e.jsx(he,{open:we,onOpenChange:w,children:e.jsxs(be,{className:"max-w-sm",children:[e.jsx(fe,{children:e.jsx(ge,{children:"Bjud in ny medlem"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Fullständigt namn"}),e.jsx(B,{value:C,onChange:a=>H(a.target.value),placeholder:"Förnamn Efternamn"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Användarnamn (e-post)"}),e.jsx(B,{type:"email",value:L,onChange:a=>J(a.target.value),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-wider mb-1.5",children:"Lösenord"}),e.jsx(B,{type:"password",value:I,onChange:a=>_(a.target.value),placeholder:"Minst 8 tecken"})]})]}),e.jsxs(je,{children:[e.jsx(h,{variant:"outline",onClick:()=>w(!1),disabled:K,children:"Avbryt"}),e.jsx(h,{onClick:Ue,disabled:K,children:K?"Lägger till...":"Lägg till"})]})]})}),e.jsx(he,{open:!!b,onOpenChange:a=>{a||T(null)},children:e.jsxs(be,{className:"max-w-sm",children:[e.jsx(fe,{children:e.jsx(ge,{children:"Ta bort medlem"})}),e.jsxs("div",{className:"py-2 space-y-2",children:[e.jsxs("p",{className:"text-sm text-slate-700 dark:text-slate-300",children:["Ãr du säker pÃ¥ att du vill ta bort"," ",e.jsx("strong",{children:(b==null?void 0:b.fullName)||(b==null?void 0:b.username)})," frÃ¥n teamet?"]}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-400 font-medium",children:"Bokningar tilldelas om till övriga teammedlemmar."})]}),e.jsxs(je,{children:[e.jsx(h,{variant:"outline",onClick:()=>T(null),children:"Avbryt"}),e.jsx(h,{variant:"destructive",onClick:()=>b&&Fe(b),children:"Ta bort"})]})]})})]})}export{Ze as default};
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.