import{i as M,x as B,c as n,a as e,t as r,g as z,d,v,F,k as V,e as p,y as j,w as $,A as N,T as U,s as y,r as u,h as E,o,f as S}from"./index-DWNalbut.js";import{u as T}from"./index-DeJ0q2c_.js";const H={class:"p-4 sm:p-6"},A={class:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6"},D={class:"text-pulse-muted text-sm"},L={class:"mb-6"},_={class:"relative w-full sm:max-w-md"},q={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4"},G=["onClick"],I={class:"flex items-start gap-3 sm:gap-4"},K={class:"w-10 h-10 sm:w-12 sm:h-12 rounded-xl bg-purple-600/20 flex items-center justify-center text-purple-400 font-bold text-base sm:text-lg flex-shrink-0"},R={class:"flex-1 min-w-0"},W={class:"font-semibold text-white truncate"},J={key:0,class:"text-sm text-pulse-muted truncate"},O={class:"flex flex-wrap items-center gap-2 mt-2"},P={key:0,class:"badge-gray text-xs"},Q={key:1,class:"text-xs text-pulse-muted"},X={key:0,class:"card p-8 sm:p-12 text-center"},Y={key:0,class:"fixed inset-0 z-50 flex items-end sm:items-center justify-center p-0 sm:p-4"},Z={class:"relative card w-full sm:max-w-lg rounded-b-none sm:rounded-b-xl max-h-[90vh] overflow-y-auto"},ee={class:"px-4 sm:px-6 py-4 border-b border-pulse-border sticky top-0 bg-pulse-card z-10"},te={class:"flex items-center justify-between"},se={class:"flex flex-col-reverse sm:flex-row gap-3 pt-2"},ie={__name:"CompaniesView",setup(le){const b=E(),c=u([]),x=u(!0),f=u({total:0,page:1}),m=u(""),a=u(!1),l=u({name:"",website:"",industry:"",size:""});async function w(i={}){x.value=!0;try{const t=await y.get("/api/v1/companies",{params:i});c.value=t.data.data,f.value=t.data.meta}catch(t){console.error("Error:",t)}finally{x.value=!1}}M(()=>w());const g=T(()=>{w({search:m.value})},300);B(m,g);async function C(){if(l.value.name)try{const i=await y.post("/api/v1/companies",l.value);a.value=!1,l.value={name:"",website:"",industry:"",size:""},b.push(`/companies/${i.data.data.id}`)}catch(i){console.error("Error:",i)}}return(i,t)=>(o(),n("div",H,[e("div",A,[e("div",null,[t[10]||(t[10]=e("h1",{class:"text-xl sm:text-2xl font-bold text-white"},"Firmen",-1)),e("p",D,r(f.value.total)+" Firmen",1)]),e("button",{onClick:t[0]||(t[0]=s=>a.value=!0),class:"btn-primary w-full sm:w-auto"},[...t[11]||(t[11]=[e("svg",{class:"w-5 h-5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),z(" Neue Firma ",-1)])])]),e("div",L,[e("div",_,[t[12]||(t[12]=e("svg",{class:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-pulse-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})],-1)),d(e("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>m.value=s),type:"text",class:"input pl-10 w-full",placeholder:"Suchen..."},null,512),[[v,m.value]])])]),e("div",q,[(o(!0),n(F,null,V(c.value,s=>{var k,h;return o(),n("div",{key:s.id,class:"card p-4 sm:p-5 cursor-pointer hover:border-primary-500 active:scale-[0.98] transition-all",onClick:oe=>S(b).push(`/companies/${s.id}`)},[e("div",I,[e("div",K,r((h=(k=s.name)==null?void 0:k[0])==null?void 0:h.toUpperCase()),1),e("div",R,[e("h3",W,r(s.name),1),s.industry?(o(),n("p",J,r(s.industry),1)):p("",!0),e("div",O,[s.size?(o(),n("span",P,r(s.size),1)):p("",!0),s.contactCount?(o(),n("span",Q,r(s.contactCount)+" Kontakte ",1)):p("",!0)])]),t[13]||(t[13]=e("svg",{class:"w-5 h-5 text-pulse-muted flex-shrink-0 hidden sm:block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1))])],8,G)}),128))]),!x.value&&!c.value.length?(o(),n("div",X,[t[14]||(t[14]=e("svg",{class:"w-12 sm:w-16 h-12 sm:h-16 mx-auto mb-4 text-pulse-muted opacity-50",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})],-1)),t[15]||(t[15]=e("p",{class:"text-pulse-muted"},"Noch keine Firmen vorhanden",-1)),e("button",{onClick:t[2]||(t[2]=s=>a.value=!0),class:"btn-primary mt-4"}," Erste Firma anlegen ")])):p("",!0),(o(),j(U,{to:"body"},[a.value?(o(),n("div",Y,[e("div",{class:"absolute inset-0 bg-black/60",onClick:t[3]||(t[3]=s=>a.value=!1)}),e("div",Z,[e("div",ee,[e("div",te,[t[17]||(t[17]=e("h2",{class:"text-lg font-semibold text-white"},"Neue Firma",-1)),e("button",{onClick:t[4]||(t[4]=s=>a.value=!1),class:"p-2 text-pulse-muted hover:text-white sm:hidden"},[...t[16]||(t[16]=[e("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])])]),e("form",{onSubmit:$(C,["prevent"]),class:"p-4 sm:p-6 space-y-4"},[e("div",null,[t[18]||(t[18]=e("label",{class:"label"},"Firmenname *",-1)),d(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>l.value.name=s),type:"text",class:"input",required:""},null,512),[[v,l.value.name]])]),e("div",null,[t[19]||(t[19]=e("label",{class:"label"},"Website",-1)),d(e("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>l.value.website=s),type:"url",class:"input",placeholder:"https://..."},null,512),[[v,l.value.website]])]),e("div",null,[t[20]||(t[20]=e("label",{class:"label"},"Branche",-1)),d(e("input",{"onUpdate:modelValue":t[7]||(t[7]=s=>l.value.industry=s),type:"text",class:"input",placeholder:"z.B. IT, Handel"},null,512),[[v,l.value.industry]])]),e("div",null,[t[22]||(t[22]=e("label",{class:"label"},"Größe",-1)),d(e("select",{"onUpdate:modelValue":t[8]||(t[8]=s=>l.value.size=s),class:"input"},[...t[21]||(t[21]=[e("option",{value:""},"-- Auswählen --",-1),e("option",{value:"1-10"},"1-10 Mitarbeiter",-1),e("option",{value:"11-50"},"11-50 Mitarbeiter",-1),e("option",{value:"51-200"},"51-200 Mitarbeiter",-1),e("option",{value:"201-1000"},"201-1000 Mitarbeiter",-1),e("option",{value:"1000+"},"1000+ Mitarbeiter",-1)])],512),[[N,l.value.size]])]),e("div",se,[e("button",{type:"button",onClick:t[9]||(t[9]=s=>a.value=!1),class:"btn-secondary flex-1"}," Abbrechen "),t[23]||(t[23]=e("button",{type:"submit",class:"btn-primary flex-1"}," Erstellen ",-1))])],32)])])):p("",!0)]))]))}};export{ie as default};