PageSourceSearch

https://careerworld.ai/assets/MitKarriereSite-DsSLrx7f.js

js careerworld.ai collected 2026-10-05 14:27:16 UTC 661,278 bytes, 279 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/paginateAndExport-DmOgoqOK.js","assets/index-7TyBHU2Z.js","assets/index-DcVRW5T9.css","assets/extractProfile-Bhj0bfp7.js","assets/logUploadError-Bn1ZEOAz.js"])))=>i.map(i=>d[i]);
2import{a as xt,r as i,aN as Wo,j as e,Y as jt,aO as Ti,n as Nl,u as Je,f as ye,w as ge,o as je,T as ka,I as ue,l as h,al as Et,X as mt,a3 as Ht,aP as at,aQ as nt,aR as rt,aS as it,aT as lt,aU as ot,aV as ct,aW as Ys,y as C,ac as J,t as Ct,s as $a,i as Te,aX as wl,e as xs,aD as zs,p as $s,aK as Qt,ak as as,aE as ta,aF as aa,aG as na,aH as dt,az as kl,ay as Ar,aY as ar,v as ht,B as ut,C as ba,ai as ma,G as Ms,a8 as se,am as Cl,an as _l,E as Ts,ap as Sl,aq as Jn,ar as Ya,as as Gs,at as qs,au as Js,K as ns,Q as rs,V as os,W as is,aj as Qs,aZ as Bt,a_ as js,F as Fs,aJ as Wn,$ as Ut,x as Ca,b as ja,U as tt,ao as nr,O as cn,aw as dn,ax as va,a$ as Go,J as wt,d as Ps,S as Cn,aL as _n,N as Na,M as ua,aC as ra,D as Yn,aA as ia,b0 as xn,ah as jn,g as Jt,h as Yt,k as yt,b1 as Dl,P as zi,aa as Qn,b2 as Pl,b3 as qo,b4 as Jo,aI as st,b5 as Yo,b6 as Fl,L as Oi,a0 as Qo,b7 as Xn,b8 as Xo,b9 as Ea,R as rr,H as Al,ba as Zo,bb as ec,bc as Vi,bd as Mi,_ as sc,a1 as tc,a2 as ac,a5 as nc}from"./index-7TyBHU2Z.js";import{c as rc,d as ic,e as lc,f as oc,g as cc,h as $i,S as dc,C as mc,a as uc,b as hc}from"./CareerSidebar-C7hu280B.js";import{M as xc}from"./MobileBottomNav-DPCnvRLf.js";import{K as Il}from"./KompletAnalyseNudge-BOU0d3Am.js";import{C as Kt}from"./checkbox-L6Lh0h0_.js";import{c as pt,i as Nt,A as Br,D as pc,a as gc,b as fc}from"./DashboardNetworkOverview-DTWoQvfJ.js";import{t as Rs,c as yn,s as bn,g as Ri,m as vc,a as jc,b as da,h as Ui,e as Sn,i as yc,j as Kr,k as bc,l as Nc,f as _s,n as Ll,d as ir}from"./da-BakeXJ3m.js";import{e as Wr,d as Nn}from"./endOfMonth-DHUGiJ0u.js";import{C as wc}from"./chevron-left-DJWXQiQA.js";import{H as wn}from"./history-DgBxTwKV.js";import{P as Ma}from"./pencil-CrVi3otE.js";import{T as Ss}from"./trash-2-CWfeTY9j.js";import{E as Hn}from"./external-link-BpTwpzHk.js";import{P as fs}from"./plus-CsvZrWK8.js";import{P as ya}from"./pen-line-CQShXMjg.js";import{L as El}from"./list-checks-B8hZl_jl.js";import{C as gt}from"./calendar-CcqZl5R4.js";import{c as bt}from"./cleanMarkdown-DiRBZFNv.js";import{u as Xa,a as lr,L as Tl}from"./useCareerDocuments-BDSHIUUE.js";import{F as Ja,n as qt,C as kc,Z as Cc,P as zl,u as Ol,M as sa}from"./notifyCvDataChanged-CoSkZjXP.js";import{C as wa}from"./circle-alert-B6GVTtQ5.js";import{C as Zn}from"./clipboard-paste-BuE5ZCYd.js";import{I as ha}from"./info-BAgej7-M.js";import{C as Lt}from"./copy-BhODk2Xy.js";import{T as Gr,a as qr,b as za,c as Oa}from"./tabs-CSyCm-G4.js";import{C as Mt,a as $t,b as Rt}from"./collapsible-CYYhHAUD.js";import{u as Jr}from"./usePersonalityAnalyses-B_DzhUe2.js";import{l as _c}from"./index-BddMhCC9.js";import{S as Qa}from"./square-pen-B3BWJQI0.js";import{C as Hi}from"./circle-user-BTGxW_wW.js";import{C as Ir}from"./circle-x-DrTRMGLj.js";import{M as Lr}from"./message-circle-BSPU-Jjm.js";import{P as or}from"./phone-595VeX4d.js";import{H as kn}from"./heart-CKv_aDI0.js";import{S as Pt,a as Ft,b as At,c as It,d as Ue}from"./select-DLaSeIoW.js";import{F as Vl}from"./filter-CPt0W-kj.js";import{i as Gn,t as pn,c as Sc,a as Ml,b as Er,B as Dc,H as Pc,U as $l,C as Tr}from"./CVPreview-B6JgGvlx.js";import{u as Fc,a as Bi,s as Ac,K as Ic,P as Lc,p as fa,t as Ki,e as Ec,c as Tc,b as zc,T as Wi,f as Oc,A as Vc,d as Mc,S as $c,g as Rc,h as Uc,i as Hc,D as Bc,j as Kc,k as Wc,v as Gc,l as qc,C as Jc,m as Yc}from"./designConfig-lippV_sr.js";import{A as Gi,a as qi}from"./alert-CYolsx78.js";import{W as la}from"./wand-sparkles-7m4s7XUn.js";import{S as Qc}from"./shield-alert-Bvxvlj29.js";import{R as Rl,a as gn}from"./radio-group-Dm0skVAZ.js";import{S as Ta}from"./switch-TB4kdOd8.js";import{L as Xc}from"./list-BdiSXqzc.js";import{M as zr}from"./minus-DW10rg1r.js";import{P as er}from"./palette-BGfh6Q8w.js";import{C as cr}from"./chevron-up-BnhjOUOY.js";import{K as fn}from"./KandidatbriefPreview-Rw5dcqdf.js";import{B as Or}from"./BulletIndentText-DxoJpC4s.js";import{B as Va}from"./bot-dgffS54U.js";import{L as vn}from"./languages-CRJa1u9t.js";import{B as Ji}from"./BIG5Results-C1p0XPNk.js";import{B as Yi}from"./BIG5JobResults-DXF9-OcI.js";import{K as Qi}from"./KompletAnalysisResults-B4Htec0R.js";import{F as Xi}from"./FutureAnalysisResults-DkfkwMVU.js";import{A as Ul,a as mn,b as un,c as hn}from"./accordion-qs4DUd3q.js";import{L as Zc}from"./layers-DOzBGJHT.js";import{M as ed}from"./monitor-HEi-gkMY.js";import{D as sd}from"./dollar-sign-CU62iwIE.js";import{M as td}from"./moon-C33DZ5Zd.js";import{s as ad}from"./safeStorageUpload-C8PU7c_g.js";import{S as nd}from"./SectionErrorBoundary-zOy9arPl.js";import"./handshake-B-lMQc33.js";import"./ellipsis-BmfTkSwG.js";import"./index-S4--ZQxw.js";import"./logUploadError-Bn1ZEOAz.js";import"./index-BdxMIC7v.js";import"./trophy-Qyd5xPz6.js";import"./arrow-left-right-SQChxHCt.js";import"./TestDisclaimer-D5RxLQvE.js";import"./table-BF3LGeZ7.js";import"./scale-D3GiuNqq.js";import"./DOCXExportButton-Fn5BgS0f.js";import"./NormGroupSelector-DnIGHuq7.js";import"./building-DSavfrNw.js";import"./activity-B7lhx8WO.js";import"./discFromBig5-DM3_3t_V.js";import"./useLocalizedData-CPk8TZO9.js";import"./cvfData-C5gOGfZ7.js";import"./flask-conical-D-8XC2pX.js";import"./arrow-right-left-DM1jXPql.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const rd=xt("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const id=xt("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
13 * @license lucide-react v0.462.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const ld=xt("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
18 * @license lucide-react v0.462.0 - ISC
19 *
20 * This source code is licensed under the ISC license.
21 * See the LICENSE file in the root directory of this source tree.
22 */const od=xt("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
23 * @license lucide-react v0.462.0 - ISC
24 *
25 * This source code is licensed under the ISC license.
26 * See the LICENSE file in the root directory of this source tree.
27 */const Zi=xt("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/**
28 * @license lucide-react v0.462.0 - ISC
29 *
30 * This source code is licensed under the ISC license.
31 * See the LICENSE file in the root directory of this source tree.
32 */const cd=xt("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);/**
33 * @license lucide-react v0.462.0 - ISC
34 *
35 * This source code is licensed under the ISC license.
36 * See the LICENSE file in the root directory of this source tree.
37 */const Hl=xt("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/**
38 * @license lucide-react v0.462.0 - ISC
39 *
40 * This source code is licensed under the ISC license.
41 * See the LICENSE file in the root directory of this source tree.
42 */const el=xt("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
43 * @license lucide-react v0.462.0 - ISC
44 *
45 * This source code is licensed under the ISC license.
46 * See the LICENSE file in the root directory of this source tree.
47 */const dd=xt("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/**
48 * @license lucide-react v0.462.0 - ISC
49 *
50 * This source code is licensed under the ISC license.
51 * See the LICENSE file in the root directory of this source tree.
52 */const md=xt("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
53 * @license lucide-react v0.462.0 - ISC
54 *
55 * This source code is licensed under the ISC license.
56 * See the LICENSE file in the root directory of this source tree.
57 */const ud=xt("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/**
58 * @license lucide-react v0.462.0 - ISC
59 *
60 * This source code is licensed under the ISC license.
61 * See the LICENSE file in the root directory of this source tree.
62 */const Yr=xt("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/**
63 * @license lucide-react v0.462.0 - ISC
64 *
65 * This source code is licensed under the ISC license.
66 * See the LICENSE file in the root directory of this source tree.
67 */const sl=xt("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
68 * @license lucide-react v0.462.0 - ISC
69 *
70 * This source code is licensed under the ISC license.
71 * See the LICENSE file in the root directory of this source tree.
72 */const Vr=xt("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/**
73 * @license lucide-react v0.462.0 - ISC
74 *
75 * This source code is licensed under the ISC license.
76 * See the LICENSE file in the root directory of this source tree.
77 */const hd=xt("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/**
78 * @license lucide-react v0.462.0 - ISC
79 *
80 * This source code is licensed under the ISC license.
81 * See the LICENSE file in the root directory of this source tree.
82 */const xd=xt("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function tl({i18n:s,defaultNS:a,children:t}){const r=i.useMemo(()=>({i18n:s,defaultNS:a}),[s,a]);return i.createElement(Wo.Provider,{value:r},t)}function Xt(s,a){const t=Rs(s);if(isNaN(a))return yn(s,NaN);if(!a)return t;const r=t.getDate(),n=yn(s,t.getTime());n.setMonth(t.getMonth()+a+1,0);const d=n.getDate();return r>=d?n:(t.setFullYear(n.getFullYear(),n.getMonth(),r),t)}function Mr(s,a){const t=a*7;return pt(s,t)}function pd(s,a){return Xt(s,a*12)}function gd(s){let a;return s.forEach(function(t){const r=Rs(t);(a===void 0||a<r||isNaN(Number(r)))&&(a=r)}),a||new Date(NaN)}function fd(s){let a;return s.forEach(t=>{const r=Rs(t);(!a||a>r||isNaN(+r))&&(a=r)}),a||new Date(NaN)}function vd(s,a,t){const r=bn(s,t),n=bn(a,t),d=+r-Ri(r),m=+n-Ri(n);return Math.round((d-m)/vc)}function kt(s){const a=Rs(s);return a.setDate(1),a.setHours(0,0,0,0),a}function Qr(s,a){var c,l,f,p;const t=jc(),r=(a==null?void 0:a.weekStartsOn)??((l=(c=a==null?void 0:a.locale)==null?void 0:c.options)==null?void 0:l.weekStartsOn)??t.weekStartsOn??((p=(f=t.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,n=Rs(s),d=n.getDay(),m=(d<r?-7:0)+6-(d-r);return n.setDate(n.getDate()+m),n.setHours(23,59,59,999),n}function Bl(s){return Qr(s,{weekStartsOn:1})}function jd(s){const a=Rs(s),t=a.getFullYear(),r=a.getMonth(),n=yn(s,0);return n.setFullYear(t,r+1,0),n.setHours(0,0,0,0),n.getDate()}function yd(s){return Math.trunc(+Rs(s)/1e3)}function bd(s){const a=Rs(s),t=a.getMonth();return a.setFullYear(a.getFullYear(),t+1,0),a.setHours(0,0,0,0),a}function Nd(s,a){return vd(bd(s),kt(s),a)+1}function $r(s,a){const t=Rs(s),r=Rs(a);return t.getTime()>r.getTime()}function Kl(s,a){const t=Rs(s),r=Rs(a);return+t<+r}function Xr(s,a){const t=Rs(s),r=Rs(a);return t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()}function wd(s,a){const t=Rs(s),r=Rs(a);return t.getFullYear()===r.getFullYear()}function jr(s,a){return pt(s,-a)}function yr(s,a){const t=Rs(s),r=t.getFullYear(),n=t.getDate(),d=yn(s,0);d.setFullYear(r,a,15),d.setHours(0,0,0,0);const m=jd(d);return t.setMonth(a,Math.min(n,m)),t}function al(s,a){const t=Rs(s);return isNaN(+t)?yn(s,NaN):(t.setFullYear(a),t)}var We=function(){return We=Object.assign||function(a){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var d in t)Object.prototype.hasOwnProperty.call(t,d)&&(a[d]=t[d])}return a},We.apply(this,arguments)};function kd(s,a){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&a.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)a.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function Wl(s,a,t){for(var r=0,n=a.length,d;r<n;r++)(d||!(r in a))&&(d||(d=Array.prototype.slice.call(a,0,r)),d[r]=a[r]);return s.concat(d||Array.prototype.slice.call(a))}function Dn(s){return s.mode==="multiple"}function Pn(s){return s.mode==="range"}function dr(s){return s.mode==="single"}var Cd={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rd
82p-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function _d(s,a){return _s(s,"LLLL y",a)}function Sd(s,a){return _s(s,"d",a)}function Dd(s,a){return _s(s,"LLLL",a)}function Pd(s){return"".concat(s)}function Fd(s,a){return _s(s,"cccccc",a)}function Ad(s,a){return _s(s,"yyyy",a)}var Id=Object.freeze({__proto__:null,formatCaption:_d,formatDay:Sd,formatMonthCaption:Dd,formatWeekNumber:Pd,formatWeekdayName:Fd,formatYearCaption:Ad}),Ld=function(s,a,t){return _s(s,"do MMMM (EEEE)",t)},Ed=function(){return"Month: "},Td=function(){return"Go to next month"},zd=function(){return"Go to previous month"},Od=function(s,a){return _s(s,"cccc",a)},Vd=function(s){return"Week n. ".concat(s)},Md=function(){return"Year: "},$d=Object.freeze({__proto__:null,labelDay:Ld,labelMonthDropdown:Ed,labelNext:Td,labelPrevious:zd,labelWeekNumber:Vd,labelWeekday:Od,labelYearDropdown:Md});function Rd(){var s="buttons",a=Cd,t=Sn,r={},n={},d=1,m={},c=new Date;return{captionLayout:s,classNames:a,formatters:Id,labels:$d,locale:t,modifiersClassNames:r,modifiers:n,numberOfMonths:d,styles:m,today:c,mode:"default"}}function Ud(s){var a=s.fromYear,t=s.toYear,r=s.fromMonth,n=s.toMonth,d=s.fromDate,m=s.toDate;return r?d=kt(r):a&&(d=new Date(a,0,1)),n?m=Wr(n):t&&(m=new Date(t,11,31)),{fromDate:d?Ui(d):void 0,toDate:m?Ui(m):void 0}}var Gl=i.createContext(void 0);function Hd(s){var a,t=s.initialProps,r=Rd(),n=Ud(t),d=n.fromDate,m=n.toDate,c=(a=t.captionLayout)!==null&&a!==void 0?a:r.captionLayout;c!=="buttons"&&(!d||!m)&&(c="buttons");var l;(dr(t)||Dn(t)||Pn(t))&&(l=t.onSelect);var f=We(We(We({},r),t),{captionLayout:c,classNames:We(We({},r.classNames),t.classNames),components:We({},t.components),formatters:We(We({},r.formatters),t.formatters),fromDate:d,labels:We(We({},r.labels),t.labels),mode:t.mode||r.mode,modifiers:We(We({},r.modifiers),t.modifiers),modifiersClassNames:We(We({},r.modifiersClassNames),t.modifiersClassNames),onSelect:l,styles:We(We({},r.styles),t.styles),toDate:m});return e.jsx(Gl.Provider,{value:f,children:s.children})}function ks(){var s=i.useContext(Gl);if(!s)throw new Error("useDayPicker must be used within a DayPickerProvider.");return s}function ql(s){var a=ks(),t=a.locale,r=a.classNames,n=a.styles,d=a.formatters.formatCaption;return e.jsx("div",{className:r.caption_label,style:n.caption_label,"aria-live":"polite",role:"presentation",id:s.id,children:d(s.displayMonth,{locale:t})})}function Bd(s){return e.jsx("svg",We({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},s,{children:e.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Jl(s){var a,t,r=s.onChange,n=s.value,d=s.children,m=s.caption,c=s.className,l=s.style,f=ks(),p=(t=(a=f.components)===null||a===void 0?void 0:a.IconDropdown)!==null&&t!==void 0?t:Bd;return e.jsxs("div",{className:c,style:l,children:[e.jsx("span",{className:f.classNames.vhidden,children:s["aria-label"]}),e.jsx("select",{name:s.name,"aria-label":s["aria-label"],className:f.classNames.dropdown,style:f.styles.dropdown,value:n,onChange:r,children:d}),e.jsxs("div",{className:f.classNames.caption_label,style:f.styles.caption_label,"aria-hidden":"true",children:[m,e.jsx(p,{className:f.classNames.dropdown_icon,style:f.styles.dropdown_icon})]})]})}function Kd(s){var a,t=ks(),r=t.fromDate,n=t.toDate,d=t.styles,m=t.locale,c=t.formatters.formatMonthCaption,l=t.classNames,f=t.components,p=t.labels.labelMonthDropdown;if(!r)return e.jsx(e.Fragment,{});if(!n)return e.jsx(e.Fragment,{});var j=[];if(wd(r,n))for(var g=kt(r),P=r.getMonth();P<=n.getMonth();P++)j.push(yr(g,P));else for(var g=kt(new Date),P=0;P<=11;P++)j.push(yr(g,P));var N=function(S){var A=Number(S.target.value),y=yr(kt(s.displayMonth),A);s.onChange(y)},w=(a=f==null?void 0:f.Dropdown)!==null&&a!==void 0?a:Jl;return e.jsx(w,{name:"months","aria-label":p(),className:l.dropdown_month,style:d.dropdown_month,onChange:N,value:s.displayMonth.getMonth(),c
82aption:c(s.displayMonth,{locale:m}),children:j.map(function(S){return e.jsx("option",{value:S.getMonth(),children:c(S,{locale:m})},S.getMonth())})})}function Wd(s){var a,t=s.displayMonth,r=ks(),n=r.fromDate,d=r.toDate,m=r.locale,c=r.styles,l=r.classNames,f=r.components,p=r.formatters.formatYearCaption,j=r.labels.labelYearDropdown,g=[];if(!n)return e.jsx(e.Fragment,{});if(!d)return e.jsx(e.Fragment,{});for(var P=n.getFullYear(),N=d.getFullYear(),w=P;w<=N;w++)g.push(al(yc(new Date),w));var S=function(y){var D=al(kt(t),Number(y.target.value));s.onChange(D)},A=(a=f==null?void 0:f.Dropdown)!==null&&a!==void 0?a:Jl;return e.jsx(A,{name:"years","aria-label":j(),className:l.dropdown_year,style:c.dropdown_year,onChange:S,value:t.getFullYear(),caption:p(t,{locale:m}),children:g.map(function(y){return e.jsx("option",{value:y.getFullYear(),children:p(y,{locale:m})},y.getFullYear())})})}function Gd(s,a){var t=i.useState(s),r=t[0],n=t[1],d=a===void 0?r:a;return[d,n]}function qd(s){var a=s.month,t=s.defaultMonth,r=s.today,n=a||t||r||new Date,d=s.toDate,m=s.fromDate,c=s.numberOfMonths,l=c===void 0?1:c;if(d&&Nn(d,n)<0){var f=-1*(l-1);n=Xt(d,f)}return m&&Nn(n,m)<0&&(n=m),kt(n)}function Jd(){var s=ks(),a=qd(s),t=Gd(a,s.month),r=t[0],n=t[1],d=function(m){var c;if(!s.disableNavigation){var l=kt(m);n(l),(c=s.onMonthChange)===null||c===void 0||c.call(s,l)}};return[r,d]}function Yd(s,a){for(var t=a.reverseMonths,r=a.numberOfMonths,n=kt(s),d=kt(Xt(n,r)),m=Nn(d,n),c=[],l=0;l<m;l++){var f=Xt(n,l);c.push(f)}return t&&(c=c.reverse()),c}function Qd(s,a){if(!a.disableNavigation){var t=a.toDate,r=a.pagedNavigation,n=a.numberOfMonths,d=n===void 0?1:n,m=r?d:1,c=kt(s);if(!t)return Xt(c,m);var l=Nn(t,s);if(!(l<d))return Xt(c,m)}}function Xd(s,a){if(!a.disableNavigation){var t=a.fromDate,r=a.pagedNavigation,n=a.numberOfMonths,d=n===void 0?1:n,m=r?d:1,c=kt(s);if(!t)return Xt(c,-m);var l=Nn(c,t);if(!(l<=0))return Xt(c,-m)}}var Yl=i.createContext(void 0);function Zd(s){var a=ks(),t=Jd(),r=t[0],n=t[1],d=Yd(r,a),m=Qd(r,a),c=Xd(r,a),l=function(j){return d.some(function(g){return Xr(j,g)})},f=function(j,g){l(j)||(g&&Kl(j,g)?n(Xt(j,1+a.numberOfMonths*-1)):n(j))},p={currentMonth:r,displayMonths:d,goToMonth:n,goToDate:f,previousMonth:c,nextMonth:m,isDateDisplayed:l};return e.jsx(Yl.Provider,{value:p,children:s.children})}function Fn(){var s=i.useContext(Yl);if(!s)throw new Error("useNavigation must be used within a NavigationProvider");return s}function nl(s){var a,t=ks(),r=t.classNames,n=t.styles,d=t.components,m=Fn().goToMonth,c=function(p){m(Xt(p,s.displayIndex?-s.displayIndex:0))},l=(a=d==null?void 0:d.CaptionLabel)!==null&&a!==void 0?a:ql,f=e.jsx(l,{id:s.id,displayMonth:s.displayMonth});return e.jsxs("div",{className:r.caption_dropdowns,style:n.caption_dropdowns,children:[e.jsx("div",{className:r.vhidden,children:f}),e.jsx(Kd,{onChange:c,displayMonth:s.displayMonth}),e.jsx(Wd,{onChange:c,displayMonth:s.displayMonth})]})}function em(s){return e.jsx("svg",We({width:"16px",height:"16px",viewBox:"0 0 120 120"},s,{children:e.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function sm(s){return e.jsx("svg",We({width:"16px",height:"16px",viewBox:"0 0 120 120"},s,{children:e.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var sr=i.forwardRef(function(s,a){var t=ks(),r=t.classNames,n=t.styles,d=[r.button_reset,r.button];s.className&&d.push(s.className);var m=d.join(" "),c=We(We({},n.button_reset),n.button);return s.style&&Object.assign(c,s.style),e.jsx("button",We({},s,{ref:a,type:"button",className:m,style:c}
82))});function tm(s){var a,t,r=ks(),n=r.dir,d=r.locale,m=r.classNames,c=r.styles,l=r.labels,f=l.labelPrevious,p=l.labelNext,j=r.components;if(!s.nextMonth&&!s.previousMonth)return e.jsx(e.Fragment,{});var g=f(s.previousMonth,{locale:d}),P=[m.nav_button,m.nav_button_previous].join(" "),N=p(s.nextMonth,{locale:d}),w=[m.nav_button,m.nav_button_next].join(" "),S=(a=j==null?void 0:j.IconRight)!==null&&a!==void 0?a:sm,A=(t=j==null?void 0:j.IconLeft)!==null&&t!==void 0?t:em;return e.jsxs("div",{className:m.nav,style:c.nav,children:[!s.hidePrevious&&e.jsx(sr,{name:"previous-month","aria-label":g,className:P,style:c.nav_button_previous,disabled:!s.previousMonth,onClick:s.onPreviousClick,children:n==="rtl"?e.jsx(S,{className:m.nav_icon,style:c.nav_icon}):e.jsx(A,{className:m.nav_icon,style:c.nav_icon})}),!s.hideNext&&e.jsx(sr,{name:"next-month","aria-label":N,className:w,style:c.nav_button_next,disabled:!s.nextMonth,onClick:s.onNextClick,children:n==="rtl"?e.jsx(A,{className:m.nav_icon,style:c.nav_icon}):e.jsx(S,{className:m.nav_icon,style:c.nav_icon})})]})}function rl(s){var a=ks().numberOfMonths,t=Fn(),r=t.previousMonth,n=t.nextMonth,d=t.goToMonth,m=t.displayMonths,c=m.findIndex(function(N){return Xr(s.displayMonth,N)}),l=c===0,f=c===m.length-1,p=a>1&&(l||!f),j=a>1&&(f||!l),g=function(){r&&d(r)},P=function(){n&&d(n)};return e.jsx(tm,{displayMonth:s.displayMonth,hideNext:p,hidePrevious:j,nextMonth:n,previousMonth:r,onPreviousClick:g,onNextClick:P})}function am(s){var a,t=ks(),r=t.classNames,n=t.disableNavigation,d=t.styles,m=t.captionLayout,c=t.components,l=(a=c==null?void 0:c.CaptionLabel)!==null&&a!==void 0?a:ql,f;return n?f=e.jsx(l,{id:s.id,displayMonth:s.displayMonth}):m==="dropdown"?f=e.jsx(nl,{displayMonth:s.displayMonth,id:s.id}):m==="dropdown-buttons"?f=e.jsxs(e.Fragment,{children:[e.jsx(nl,{displayMonth:s.displayMonth,displayIndex:s.displayIndex,id:s.id}),e.jsx(rl,{displayMonth:s.displayMonth,displayIndex:s.displayIndex,id:s.id})]}):f=e.jsxs(e.Fragment,{children:[e.jsx(l,{id:s.id,displayMonth:s.displayMonth,displayIndex:s.displayIndex}),e.jsx(rl,{displayMonth:s.displayMonth,id:s.id})]}),e.jsx("div",{className:r.caption,style:d.caption,children:f})}function nm(s){var a=ks(),t=a.footer,r=a.styles,n=a.classNames.tfoot;return t?e.jsx("tfoot",{className:n,style:r.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:t})})}):e.jsx(e.Fragment,{})}function rm(s,a,t){for(var r=t?Kr(new Date):bn(new Date,{locale:s,weekStartsOn:a}),n=[],d=0;d<7;d++){var m=pt(r,d);n.push(m)}return n}function im(){var s=ks(),a=s.classNames,t=s.styles,r=s.showWeekNumber,n=s.locale,d=s.weekStartsOn,m=s.ISOWeek,c=s.formatters.formatWeekdayName,l=s.labels.labelWeekday,f=rm(n,d,m);return e.jsxs("tr",{style:t.head_row,className:a.head_row,children:[r&&e.jsx("td",{style:t.head_cell,className:a.head_cell}),f.map(function(p,j){return e.jsx("th",{scope:"col",className:a.head_cell,style:t.head_cell,"aria-label":l(p,{locale:n}),children:c(p,{locale:n})},j)})]})}function lm(){var s,a=ks(),t=a.classNames,r=a.styles,n=a.components,d=(s=n==null?void 0:n.HeadRow)!==null&&s!==void 0?s:im;return e.jsx("thead",{style:r.head,className:t.head,children:e.jsx(d,{})})}function om(s){var a=ks(),t=a.locale,r=a.formatters.formatDay;return e.jsx(e.Fragment,{children:r(s.date,{locale:t})})}var Zr=i.createContext(void 0);function cm(s){if(!Dn(s.initialProps)){var a={selected:void 0,modifiers:{disabled:[]}};return e.jsx(Zr.Provider,{value:a,children:s.children})}return e.jsx(dm,{initialProps:s.initialProps,children:s.children})}function dm(s){var a=s.initialProps,t=s.children,r=a.selected,n=a.min,d=a.max,m=function(f,p,j){var g,P;(g=a.onDayClick)===null||g===void 0||g.call(a,f,p,j);var N=!!(p.selected&&n&&(r==null?void 0:r.length)===n);if(!N){var w=!!(!p.selected&&d&&(r==null?void 0:r.length)===d);if(!w){var S=r?Wl([],r):[];if(p.selected){var A=S.findIndex(function(y){return Nt(f,y)});S.splice(A,1)}else S.push(f);(P=a.onSelect)===null||P===void 0||P.call(a,S,f,p,j)}}},c={disabled:[]};r&&c.disabled.push(function(f){var p=d&&r.length>d-1,j=r.some(function(g){return Nt(g,f)});return!!(p&&!j)});var l={selected:r,onDayClick:m,modifiers:c};return e.jsx(Zr.Provider,{value:l,children:t})}function ei(){var s=i.useContext(Zr);if(!s)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return s}function mm(s,a){var t=a||{},r=t.from,n=t.to;
82return r&&n?Nt(n,s)&&Nt(r,s)?void 0:Nt(n,s)?{from:n,to:void 0}:Nt(r,s)?void 0:$r(r,s)?{from:s,to:n}:{from:r,to:s}:n?$r(s,n)?{from:n,to:s}:{from:s,to:n}:r?Kl(s,r)?{from:s,to:r}:{from:r,to:s}:{from:s,to:void 0}}var si=i.createContext(void 0);function um(s){if(!Pn(s.initialProps)){var a={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(si.Provider,{value:a,children:s.children})}return e.jsx(hm,{initialProps:s.initialProps,children:s.children})}function hm(s){var a=s.initialProps,t=s.children,r=a.selected,n=r||{},d=n.from,m=n.to,c=a.min,l=a.max,f=function(P,N,w){var S,A;(S=a.onDayClick)===null||S===void 0||S.call(a,P,N,w);var y=mm(P,r);(A=a.onSelect)===null||A===void 0||A.call(a,y,P,N,w)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(d?(p.range_start=[d],m?(p.range_end=[m],Nt(d,m)||(p.range_middle=[{after:d,before:m}])):p.range_end=[d]):m&&(p.range_start=[m],p.range_end=[m]),c&&(d&&!m&&p.disabled.push({after:jr(d,c-1),before:pt(d,c-1)}),d&&m&&p.disabled.push({after:d,before:pt(d,c-1)}),!d&&m&&p.disabled.push({after:jr(m,c-1),before:pt(m,c-1)})),l){if(d&&!m&&(p.disabled.push({before:pt(d,-l+1)}),p.disabled.push({after:pt(d,l-1)})),d&&m){var j=da(m,d)+1,g=l-j;p.disabled.push({before:jr(d,g)}),p.disabled.push({after:pt(m,g)})}!d&&m&&(p.disabled.push({before:pt(m,-l+1)}),p.disabled.push({after:pt(m,l-1)}))}return e.jsx(si.Provider,{value:{selected:r,onDayClick:f,modifiers:p},children:t})}function ti(){var s=i.useContext(si);if(!s)throw new Error("useSelectRange must be used within a SelectRangeProvider");return s}function qn(s){return Array.isArray(s)?Wl([],s):s!==void 0?[s]:[]}function xm(s){var a={};return Object.entries(s).forEach(function(t){var r=t[0],n=t[1];a[r]=qn(n)}),a}var Zt;(function(s){s.Outside="outside",s.Disabled="disabled",s.Selected="selected",s.Hidden="hidden",s.Today="today",s.RangeStart="range_start",s.RangeEnd="range_end",s.RangeMiddle="range_middle"})(Zt||(Zt={}));var pm=Zt.Selected,ca=Zt.Disabled,gm=Zt.Hidden,fm=Zt.Today,br=Zt.RangeEnd,Nr=Zt.RangeMiddle,wr=Zt.RangeStart,vm=Zt.Outside;function jm(s,a,t){var r,n=(r={},r[pm]=qn(s.selected),r[ca]=qn(s.disabled),r[gm]=qn(s.hidden),r[fm]=[s.today],r[br]=[],r[Nr]=[],r[wr]=[],r[vm]=[],r);return s.fromDate&&n[ca].push({before:s.fromDate}),s.toDate&&n[ca].push({after:s.toDate}),Dn(s)?n[ca]=n[ca].concat(a.modifiers[ca]):Pn(s)&&(n[ca]=n[ca].concat(t.modifiers[ca]),n[wr]=t.modifiers[wr],n[Nr]=t.modifiers[Nr],n[br]=t.modifiers[br]),n}var Ql=i.createContext(void 0);function ym(s){var a=ks(),t=ei(),r=ti(),n=jm(a,t,r),d=xm(a.modifiers),m=We(We({},n),d);return e.jsx(Ql.Provider,{value:m,children:s.children})}function Xl(){var s=i.useContext(Ql);if(!s)throw new Error("useModifiers must be used within a ModifiersProvider");return s}function bm(s){return!!(s&&typeof s=="object"&&"before"in s&&"after"in s)}function Nm(s){return!!(s&&typeof s=="object"&&"from"in s)}function wm(s){return!!(s&&typeof s=="object"&&"after"in s)}function km(s){return!!(s&&typeof s=="object"&&"before"in s)}function Cm(s){return!!(s&&typeof s=="object"&&"dayOfWeek"in s)}function _m(s,a){var t,r=a.from,n=a.to;if(r&&n){var d=da(n,r)<0;d&&(t=[n,r],r=t[0],n=t[1]);var m=da(s,r)>=0&&da(n,s)>=0;return m}return n?Nt(n,s):r?Nt(r,s):!1}function Sm(s){return Ll(s)}function Dm(s){return Array.isArray(s)&&s.every(Ll)}function Pm(s,a){return a.some(function(t){if(typeof t=="boolean")return t;if(Sm(t))return Nt(s,t);if(Dm(t))return t.includes(s);if(Nm(t))return _m(s,t);if(Cm(t))return t.dayOfWeek.includes(s.getDay());if(bm(t)){var r=da(t.before,s),n=da(t.after,s),d=r>0,m=n<0,c=$r(t.before,t.after);return c?m&&d:d||m}return wm(t)?da(s,t.after)>0:km(t)?da(t.before,s)>0:typeof t=="function"?t(s):!1})}function ai(s,a,t){var r=Object.keys(a).reduce(function(d,m){var c=a[m];return Pm(s,c)&&d.push(m),d},[]),n={};return r.forEach(function(d){return n[d]=!0}),t&&!Xr(s,t)&&(n.outside=!0),n}function Fm(s,a){for(var t=kt(s[0]),r=Wr(s[s.length-1]),n,d,m=t;m<=r;){var c=ai(m,a),l=!c.disabled&&!c.hidden;if(!l){m=pt(m,1);continue}if(c.selected)return m;c.today&&!d&&(d=m),n||(n=m),m=pt(m,1)}return d||n}var Am=365;function Zl(s,a){var t=a.moveBy,r=a.direction,n=a.context,d=a.modifiers,m=a.retry,c=m
82===void 0?{count:0,lastFocused:s}:m,l=n.weekStartsOn,f=n.fromDate,p=n.toDate,j=n.locale,g={day:pt,week:Mr,month:Xt,year:pd,startOfWeek:function(S){return n.ISOWeek?Kr(S):bn(S,{locale:j,weekStartsOn:l})},endOfWeek:function(S){return n.ISOWeek?Bl(S):Qr(S,{locale:j,weekStartsOn:l})}},P=g[t](s,r==="after"?1:-1);r==="before"&&f?P=gd([f,P]):r==="after"&&p&&(P=fd([p,P]));var N=!0;if(d){var w=ai(P,d);N=!w.disabled&&!w.hidden}return N?P:c.count>Am?c.lastFocused:Zl(P,{moveBy:t,direction:r,context:n,modifiers:d,retry:We(We({},c),{count:c.count+1})})}var eo=i.createContext(void 0);function Im(s){var a=Fn(),t=Xl(),r=i.useState(),n=r[0],d=r[1],m=i.useState(),c=m[0],l=m[1],f=Fm(a.displayMonths,t),p=n??(c&&a.isDateDisplayed(c))?c:f,j=function(){l(n),d(void 0)},g=function(S){d(S)},P=ks(),N=function(S,A){if(n){var y=Zl(n,{moveBy:S,direction:A,context:P,modifiers:t});Nt(n,y)||(a.goToDate(y,n),g(y))}},w={focusedDay:n,focusTarget:p,blur:j,focus:g,focusDayAfter:function(){return N("day","after")},focusDayBefore:function(){return N("day","before")},focusWeekAfter:function(){return N("week","after")},focusWeekBefore:function(){return N("week","before")},focusMonthBefore:function(){return N("month","before")},focusMonthAfter:function(){return N("month","after")},focusYearBefore:function(){return N("year","before")},focusYearAfter:function(){return N("year","after")},focusStartOfWeek:function(){return N("startOfWeek","before")},focusEndOfWeek:function(){return N("endOfWeek","after")}};return e.jsx(eo.Provider,{value:w,children:s.children})}function ni(){var s=i.useContext(eo);if(!s)throw new Error("useFocusContext must be used within a FocusProvider");return s}function Lm(s,a){var t=Xl(),r=ai(s,t,a);return r}var ri=i.createContext(void 0);function Em(s){if(!dr(s.initialProps)){var a={selected:void 0};return e.jsx(ri.Provider,{value:a,children:s.children})}return e.jsx(Tm,{initialProps:s.initialProps,children:s.children})}function Tm(s){var a=s.initialProps,t=s.children,r=function(d,m,c){var l,f,p;if((l=a.onDayClick)===null||l===void 0||l.call(a,d,m,c),m.selected&&!a.required){(f=a.onSelect)===null||f===void 0||f.call(a,void 0,d,m,c);return}(p=a.onSelect)===null||p===void 0||p.call(a,d,d,m,c)},n={selected:a.selected,onDayClick:r};return e.jsx(ri.Provider,{value:n,children:t})}function so(){var s=i.useContext(ri);if(!s)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return s}function zm(s,a){var t=ks(),r=so(),n=ei(),d=ti(),m=ni(),c=m.focusDayAfter,l=m.focusDayBefore,f=m.focusWeekAfter,p=m.focusWeekBefore,j=m.blur,g=m.focu
82s,P=m.focusMonthBefore,N=m.focusMonthAfter,w=m.focusYearBefore,S=m.focusYearAfter,A=m.focusStartOfWeek,y=m.focusEndOfWeek,D=function(E){var F,O,ee,Le;dr(t)?(F=r.onDayClick)===null||F===void 0||F.call(r,s,a,E):Dn(t)?(O=n.onDayClick)===null||O===void 0||O.call(n,s,a,E):Pn(t)?(ee=d.onDayClick)===null||ee===void 0||ee.call(d,s,a,E):(Le=t.onDayClick)===null||Le===void 0||Le.call(t,s,a,E)},B=function(E){var F;g(s),(F=t.onDayFocus)===null||F===void 0||F.call(t,s,a,E)},M=function(E){var F;j(),(F=t.onDayBlur)===null||F===void 0||F.call(t,s,a,E)},Y=function(E){var F;(F=t.onDayMouseEnter)===null||F===void 0||F.call(t,s,a,E)},R=function(E){var F;(F=t.onDayMouseLeave)===null||F===void 0||F.call(t,s,a,E)},Q=function(E){var F;(F=t.onDayPointerEnter)===null||F===void 0||F.call(t,s,a,E)},k=function(E){var F;(F=t.onDayPointerLeave)===null||F===void 0||F.call(t,s,a,E)},$=function(E){var F;(F=t.onDayTouchCancel)===null||F===void 0||F.call(t,s,a,E)},K=function(E){var F;(F=t.onDayTouchEnd)===null||F===void 0||F.call(t,s,a,E)},re=function(E){var F;(F=t.onDayTouchMove)===null||F===void 0||F.call(t,s,a,E)},ve=function(E){var F;(F=t.onDayTouchStart)===null||F===void 0||F.call(t,s,a,E)},ze=function(E){var F;(F=t.onDayKeyUp)===null||F===void 0||F.call(t,s,a,E)},xe=function(E){var F;switch(E.key){case"ArrowLeft":E.preventDefault(),E.stopPropagation(),t.dir==="rtl"?c():l();break;case"ArrowRight":E.preventDefault(),E.stopPropagation(),t.dir==="rtl"?l():c();break;case"ArrowDown":E.preventDefault(),E.stopPropagation(),f();break;case"ArrowUp":E.preventDefault(),E.stopPropagation(),p();break;case"PageUp":E.preventDefault(),E.stopPropagation(),E.shiftKey?w():P();break;case"PageDown":E.preventDefault(),E.stopPropagation(),E.shiftKey?S():N();break;case"Home":E.preventDefault(),E.stopPropagation(),A();break;case"End":E.preventDefault(),E.stopPropagation(),y();break}(F=t.onDayKeyDown)===null||F===void 0||F.call(t,s,a,E)},I={onClick:D,onFocus:B,onBlur:M,onKeyDown:xe,onKeyUp:ze,onMouseEnter:Y,onMouseLeave:R,onPointerEnter:Q,onPointerLeave:k,onTouchCancel:$,onTouchEnd:K,onTouchMove:re,onTouchStart:ve};return I}function Om(){var s=ks(),a=so(),t=ei(),r=ti(),n=dr(s)?a.selected:Dn(s)?t.selected:Pn(s)?r.selected:void 0;return n}function Vm(s){return Object.values(Zt).includes(s)}function Mm(s,a){var t=[s.classNames.day];return Object.keys(a).forEach(function(r){var n=s.modifiersClassNames[r];if(n)t.push(n);else if(Vm(r)){var d=s.classNames["day_".concat(r)];d&&t.push(d)}}),t}function $m(s,a){var t=We({},s.styles.day);return Object.keys(a).forEach(function(r){var n;t=We(We({},t),(n=s.modifiersStyles)===null||n===void 0?void 0:n[r])}),t}function Rm(s,a,t){var r,n,d,m=ks(),c=ni(),l=Lm(s,a),f=zm(s,l),p=Om(),j=!!(m.onDayClick||m.mode!=="default");i.useEffect(function(){var Y;l.outside||c.focusedDay&&j&&Nt(c.focusedDay,s)&&((Y=t.current)===null||Y===void 0||Y.focus())},[c.focusedDay,s,t,j,l.outside]);var g=Mm(m,l).join(" "),P=$m(m,l),N=!!(l.outside&&!m.showOutsideDays||l.hidden),w=(d=(n=m.components)===null||n===void 0?void 0:n.DayContent)!==null&&d!==void 0?d:om,S=e.jsx(w,{date:s,displayMonth:a,activeModifiers:l}),A={style:P,className:g,children:S,role:"gridcell"},y=c.focusTarget&&Nt(c.focusTarget,s)&&!l.outside,D=c.focusedDay&&Nt(c.focusedDay,s),B=We(We(We({},A),(r={disabled:l.disabled,role:"gridcell"},r["aria-selected"]=l.selected,r.tabIndex=D||y?0:-1,r)),f),M={isButton:j,isHidden:N,activeModifiers:l,selectedDays:p,buttonProps:B,divProps:A};return M}function Um(s){var a=i.useRef(null),t=Rm(s.date,s.displayMonth,a);return t.isHidden?e.jsx("div",{role:"gridcell"}):t.isButton?e.jsx(sr,We({name:"day",ref:a},t.buttonProps)):e.jsx("div",We({},t.divProps))}function Hm(s){var a=s.number,t=s.dates,r=ks(),n=r.onWeekNumberClick,d=r.styles,m=r.classNames,c=r.locale,l=r.labels.labelWeekNumber,f=r.formatters.formatWeekNumber,p=f(Number(a),{locale:c});if(!n)return e.jsx("span",{className:m.weeknumber,style:d.weeknumber,children:p});var j=l(Number(a),{locale:c}),g=function(P){n(a,t,P)};return e.jsx(sr,{name:"week-number","aria-label":j,className:m.weeknumber,style:d.weeknumber,onClick:g,children:p})}function Bm(s){var a,t,r=ks(),n=r.styles,d=r.classNames,m=r.showWeekNumber,c=r.components,l=(a=c==null?void 0:c.Day)!==null&&a!==void 0?a:Um,f=(t=c==null?void 0:c.WeekNumber)!==null&&t!==void 0?t:Hm,p;return m&&(p=e.jsx("td",{className:d.cell,style:n.cell,children:e.jsx(f,{number:s.weekNumber,dates:s.dates})})),e.jsxs("tr",{className:d.row,style:n.row,children:[p,s.dates.map(function(j){return e.jsx("td",{className:d.cell,style:n.cell,role:"presentation",children:e.jsx(l,{displayMonth:s.displayMonth,date:j})},yd(j))})]})}function il(s,a,t){for(var r=t!=null&&t.ISOWeek?Bl(a):Qr(a,t),n=t!=null&&t.ISOWeek?Kr(s):bn(s,t),d=da(r,n),m=[],c=0;c<=d;c++)m.push(pt(n,c));var l=m.reduce(function(f,p){var j=t!=null&&t.ISOWeek?bc(p):Nc(p,t),g=f.find(function(P){return P.weekNumber===j});return g?(g.dates.push(p),f):(f.push({weekNumber:j,dates:[p]}),f)},[]);return l}function Km(s,a){var t=il(kt(s),Wr(s),a);if(a!=null&&a.useFixedWeeks){var r=Nd(s,a);if(r<6){var n=t[t.length-1],d=n.dates[n.dates.length-1],m=Mr(d,6-r),c=il(Mr(d,1),m,a);t.push.apply(t,c)}}return t}function Wm(s){var a,t,r,n=ks(),d=n.locale,m=n.classNames,c=n.styles,l=n.hideHead,f=n.fixedWeeks,p=n.components,j=n.weekStartsOn,g=n.firstWeekContainsDate,P=n.ISOWeek,N=Km(s.displayMonth,{useFixedWeeks:!!f,ISOWeek:P,locale:d,weekStartsOn:j,firstWeekContainsDate:g}),w=(a=p==null?void 0:p.Head)!==null&&a!==void 0?a:lm,S=(t=p==null?void 0:p.Row)!==null&&t!==void 0?t:Bm,A=(r=p==null?void 0:p.Footer)!==null&&r!==void 0?r:nm;return e.jsxs("table",{id:s.id,className:m.table,style:c.table,role:"grid","aria-labelledby":s["aria-labelledby"],children:[!l&&e.jsx(w,{}),e.jsx("tbody",{className:m.tbody,style:c.tbody,children:N.map(function(y){return e.jsx(S,{displayMonth:s.displayMonth,dates:y.dates,weekNumber:y.weekNumber},y.weekNumber)})}),e.jsx(A,{displayMonth:s.displayMonth})]})}function Gm(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var qm=Gm()?i.useLayoutEffect:i.useEffect,kr=!1,Jm=0;function ll(){return"react-day-picker-".concat(++Jm)}function Ym(s){var a,t=s??(kr?ll():null),r=i.useState(t),n=r[0],d=r[1];return qm(function(){n===null&&d(ll())},[]),i.useEffect(function(){kr===!1&&(kr=!0)},[]),(a=s??n)!==null&&a!==void 0?a:void 0}function Qm(s){var a,t,r=ks(),n=r.dir,d=r.classNames,m=r.styles,c=r.components,l=Fn().displayMonths,f=Ym(r.id?"".concat(r.id,"-").concat(s.displayIndex):void 0),p=r.id?"".concat(r.id,"-grid-").concat(s.displayIndex):void 0,j=[d.month],g=m.month,P=s.displayIndex===0,N=s.displayIndex===l.length-1,w=!P&&!N;n==="rtl"&&(a=[P,N],N=a[0],P=a[1]),P&&(j.push(d.caption_start),g=We(We({},g),m.caption_start)),N&&(j.push(d.caption_end),g=We(We({},g),m.caption_end)),w&&(j.push(d.caption_between),g=We(We({},g),m.caption_between));var S=(t=c==null?void 0:c.Caption)!==null&&t!==void 0?t:am;return e.jsxs("div",{className:j.join(" "),style:g,children:[e.jsx(S,{id:f,displayMonth:s.displayMonth,displayIndex:s.displayIndex}),e.jsx(Wm,{id:p,"aria-labelledby":f,displayMonth:s.displayMonth})]},s.displayIndex)}function Xm(s){var a=ks(),t=a.classNames,r=a.styles;return e.jsx("div",{className:t.months,style:r.months,children:s.children})}function Zm(s){var a,t,r=s.initialProps,n=ks(),d=ni(),m=Fn(),c=i.useState(!1),l=c[0],f=c[1];i.useEffect(function(){n.initialFocus&&d.focusTarget&&(l||(d.focus(d.focusTarget),f(!0)))}
82,[n.initialFocus,l,d.focus,d.focusTarget,d]);var p=[n.classNames.root,n.className];n.numberOfMonths>1&&p.push(n.classNames.multiple_months),n.showWeekNumber&&p.push(n.classNames.with_weeknumber);var j=We(We({},n.styles.root),n.style),g=Object.keys(r).filter(function(N){return N.startsWith("data-")}).reduce(function(N,w){var S;return We(We({},N),(S={},S[w]=r[w],S))},{}),P=(t=(a=r.components)===null||a===void 0?void 0:a.Months)!==null&&t!==void 0?t:Xm;return e.jsx("div",We({className:p.join(" "),style:j,dir:n.dir,id:n.id,nonce:r.nonce,title:r.title,lang:r.lang},g,{children:e.jsx(P,{children:m.displayMonths.map(function(N,w){return e.jsx(Qm,{displayIndex:w,displayMonth:N},w)})})}))}function eu(s){var a=s.children,t=kd(s,["children"]);return e.jsx(Hd,{initialProps:t,children:e.jsx(Zd,{children:e.jsx(Em,{initialProps:t,children:e.jsx(cm,{initialProps:t,children:e.jsx(um,{initialProps:t,children:e.jsx(ym,{children:e.jsx(Im,{children:a})})})})})})})}function su(s){return e.jsx(eu,We({},s,{children:e.jsx(Zm,{initialProps:s})}))}function Rr({className:s,classNames:a,showOutsideDays:t=!0,...r}){return e.jsx(su,{showOutsideDays:t,className:jt("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:jt(Ti({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:jt(Ti({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...a},components:{IconLeft:({...n})=>e.jsx(wc,{className:"h-4 w-4"}),IconRight:({...n})=>e.jsx(Nl,{className:"h-4 w-4"})},...r})}Rr.displayName="Calendar";const tu=({activeId:s,refreshKey:a=0,onLoad:t})=>{const{t:r,i18n:n}=Je(),[d,m]=i.useState([]),[c,l]=i.useState(!0),[f,p]=i.useState(null),[j,g]=i.useState(null),[P,N]=i.useState(null),[w,S]=i.useState(""),[A,y]=i.useState(!1),D=async()=>{l(!0);const{data:{user:Q}}=await C.auth.getUser();if(!Q){l(!1);return}const{data:k,error:$}=await C.from("action_plans").select("id, title, strategy_text, items, created_at").eq("user_id",Q.id).order("created_at",{ascending:!1});$?console.error($):m(k||[]),l(!1)};i.useEffect(()=>{D()},[a,s]);const B=async()=>{if(!j)return;p(j);const{error:Q}=await C.from("action_plans").delete().eq("id",j);Q?J.error(Q.message):(J.success(r("jobStrategy.history.deleted","Plan slettet")),m(k=>k.filter($=>$.id!==j))),p(null),g(null)},M=Q=>{N(Q.id),S(Q.title||"")},Y=()=>{N(null),S("")},R=async()=>{if(!P||!w.trim())return;y(!0);const{error:Q}=await C.from("action_plans").update({title:w.trim()}).eq("id",P);Q?J.error(Q.message):(m(k=>k.map($=>$.id===P?{...$,title:w.trim()}:$)),J.success(r("common.renamed","Omdøbt")),Y()),y(!1)};return c?e.jsx(ye,{className:"p-5",children:e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(ge,{className:"w-5 h-5 animate-spin text-muted-foreground"})})}):d.length<=1?null:e.jsxs(e.Fragment,{children:[e.jsxs(ye,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(wn,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-foreground",children:r("jobStrategy.history.title","Tidligere oplæg")}),e.jsx(je,{variant:"secondary",className:"text-xs",children:d.length})]}),e.jsx("div",{className:"space-y-2",children:d.map((Q,k)=>{const $=d.length-k,K=k===0,re=s===Q.id,ve=P===Q.id,ze=Q.title||r("jobStrategy.history.untitled","Jobsøgningsplan");return e.jsx("div",{className:`flex flex-col gap-2 p-3 rounded-lg border bg-card hover:bg-accent/30 transition-colors ${re?"border-primary/40":""}`,children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(ka,{className:"w-4 h-4 text-muted-foreground shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[ve?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ue,{value:w,onChange:xe=>S(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&R(),xe.key==="Escape"&&Y()},autoFocus:!0,className:"h-7 text-sm"}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-primary",disabled:A||!w.trim(),onClick:R,children:A?e.jsx(ge,{className:"w-3 h-3 animate-spin"}):e.jsx(Et,{className:"w-3 h-3"})}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:Y,children:e.jsx(mt,{className:"w-3 h-3"})})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground shrink-0",children:["#",$]}),e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:ze}),K&&e.jsx(je,{variant:"default",className:"text-[10px] h-4 px-1.5",children:r("common.latest","Seneste")}),re&&e.jsx(je,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-primary/40 text-primary",children:r("jobStrategy.history.active","Aktiv")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(Q.created_at).toLocaleStr
82ing(n.language)})]})]}),e.jsx("div",{className:"flex items-center gap-1 shrink-0",children:!ve&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>M(Q),title:r("common.rename","Omdøb"),children:e.jsx(Ma,{className:"w-3 h-3"})}),e.jsxs(h,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",onClick:()=>t(Q),disabled:re,children:[e.jsx(Ht,{className:"w-3 h-3"}),r("jobStrategy.history.load","Indlæs")]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",disabled:f===Q.id,onClick:()=>g(Q.id),children:f===Q.id?e.jsx(ge,{className:"w-3 h-3 animate-spin"}):e.jsx(Ss,{className:"w-3 h-3"})})]})})]})},Q.id)})})]}),e.jsx(at,{open:!!j,onOpenChange:Q=>!Q&&g(null),children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:r("jobStrategy.history.deleteTitle","Slet plan?")}),e.jsx(lt,{children:r("jobStrategy.history.deleteDesc","Denne handling kan ikke fortrydes.")})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:r("common.cancel","Annuller")}),e.jsx(Ys,{onClick:B,children:r("common.delete","Slet")})]})]})})]})},ol=[kl],cl=(s,a)=>{const t=s.toLowerCase(),r=(n,d)=>a?a(n):d;return t.includes("mine dokumenter")||t.includes("karriereprofil")||t.includes("cv")||t.includes("linkedin profil")||t.includes("kandidatbrief")||t.includes("career profile")||t.includes("my documents")?{label:r("jobStrategy.careerSammyLinks.careerProfile","Karriereprofil"),path:"/mit-karrieresite?tab=karriereprofil"}:t.includes("mine valg")||t.includes("præferencer")||t.includes("branchepræferencer")||t.includes("my choices")||t.includes("preferences")?{label:r("jobStrategy.careerSammyLinks.myChoicesLink","Mine valg"),path:"/mit-karrieresite?tab=mine-input"}:t.includes("mit netværk")||t.includes("netværk")||t.includes("my network")||t.includes("network")?{label:r("jobStrategy.careerSammyLinks.myNetwork","Mit netværk"),path:"/mit-karrieresite?tab=netvaerk"}:t.includes("uopfordret")||t.includes("virksomhedskontakt")||t.includes("direkte henvendelse")||t.includes("drømmevirksomhed")||t.includes("dream company")||t.includes("unsolicited")?{label:r("jobStrategy.careerSammyLinks.unsolicited","Uopfordret/uopfordret/virksomheder"),path:"/mit-karrieresite?tab=uopfordret"}:t.includes("headhunter")||t.includes("rekruttering")||t.includes("recruitment")?{label:r("jobStrategy.careerSammyLinks.headhuntersLink","Headhuntere"),path:"/mit-karrieresite?tab=headhuntere"}:t.includes("jobforslag")||t.includes("jobliste")||t.includes("stillinger")||t.includes("job suggestions")||t.includes("job list")?{label:r("jobStrategy.careerSammyLinks.jobSuggestions","Jobforslag"),path:"/jobliste"}:null},et=s=>Array.isArray(s)?s:[],au=()=>{const{t:s,i18n:a}=Je();return i.useMemo(()=>[{id:"entry",title:s("strategyLevels.entry.title"),subtitle:s("strategyLevels.entry.subtitle"),icon:Ar,color:"text-green-500",bgColor:"bg-green-500/10",focus:et(s("strategyLevels.entry.focus",{returnObjects:!0})),channels:et(s("strategyLevels.entry.channels",{returnObjects:!0})),weeklyActions:et(s("strategyLevels.entry.weeklyActions",{returnObjects:!0})),tips:et(s("strategyLevels.entry.tips",{returnObjects:!0}))},{id:"mid",title:s("strategyLevels.mid.title"),subtitle:s("strategyLevels.mid.subtitle"),icon:ar,color:"text-blue-500",bgColor:"bg-blue-500/10",focus:et(s("strategyLevels.mid.focus",{returnObjects:!0})),channels:et(s("strategyLevels.mid.channels",{returnObjects:!0})),weeklyActions:et(s("strategyLevels.mid.weeklyActions",{returnObjects:!0})),tips:et(s("strategyLevels.mid.tips",{returnObjects:!0}))},{id:"senior",title:s("strategyLevels.senior.title"),subtitle:s("strategyLevels.senior.subtitle"),icon:ht,color:"text-purple-500",bgColor:"bg-purple-500/10",focus:et(s("strategyLevels.senior.focus",{returnObjects:!0})),channels:et(s("strategyLevels.senior.channels",{returnObjects:!0})),weeklyActions:et(s("strategyLevels.senior.weeklyActions",{returnObjects:!0})),tips:et(s("strategyLevels.senior.tips",{returnObjects:!0}))},{id:"executive",title:s("strategyLevels.executive.title"),subtitle:s("strategyLevels.executive.subtitle"),icon:ut,color:"text-rose-500",bgColor:"bg-rose-500/10",focus:et(s("strategyLevels.executive.focus",{returnObjects:!0})),channels:et(s("strategyLevels.executive.channels",{returnObjects:!0})),weeklyActions:et(s("strategyLevels.executive.weeklyActions",{returnObjects:!0})),tips:et(s("strategyLevels.executive.tips",{returnObjects:!0}))}],[s])},nu=()=>{const{t:s,i18n:a}=Je();return i.useMemo(()=>{const t=s("ninetyDayPlan",{returnObjects:!0}),r=Array.isArray(t)?t:[],n=["bg-blue-500","bg-purple-500","bg-green-500"];return r.map((d,m)=>({...d,color:n[m]||"bg-gray-500"}))},[s])},vt=({label:s,done:a,readyLabel:t="✓ Klar"})=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a?e.jsx($s,{className:"w-4 h-4 text-green-500 shrink-0"}):e.jsx(ba,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:a?"text-foreground":"text-muted-foreground",children:s}),a&&e.jsx(je,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-green-600 border-green-500/30 ml-auto",children:t})]}),Cr=s=>s?s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"$1").replace(/`([^`]+)`/g,"$1"):"",ru=()=>{const{t:s,i18n:a}=Je(),{toast:t}
82=Ct(),r=$a(),n=Te(a.language)?ir:Sn,d=wl(),[m,c]=i.useState("mid"),[l,f]=i.useState(!1),[p,j]=i.useState(null);i.useState(0);const[g,P]=i.useState(!1),[N,w]=i.useState(""),[S,A]=i.useState(""),[y,D]=i.useState(!1),[B,M]=i.useState([]),[Y,R]=i.useState(!1),[Q,k]=i.useState(new Set),[$,K]=i.useState(null),[re,ve]=i.useState(!0),[ze,xe]=i.useState(!1),[I,E]=i.useState(!1),[F,O]=i.useState(null),[ee,Le]=i.useState(null),[pe,Oe]=i.useState(null),[he,we]=i.useState(!0);i.useState(""),i.useState(!1),i.useState(!0),i.useState(null);const[T,ae]=i.useState([]),[me,Ae]=i.useState(null),[oe,Ve]=i.useState({title:"",body:""}),[Xe,cs]=i.useState(null),[hs,ps]=i.useState(""),[ms,De]=i.useState(void 0),_=i.useMemo(()=>ol[Math.floor(Math.random()*ol.length)],[]),Z=i.useRef(null),[H,ne]=i.useState(!1),x=async()=>{if(!(!Z.current||H)){ne(!0);try{const{exportElementAsPdf:ie}=await ma(async()=>{const{exportElementAsPdf:V}=await import("./paginateAndExport-DmOgoqOK.js");return{exportElementAsPdf:V}},__vite__mapDeps([0,1,2])),o=Z.current.cloneNode(!0);o.classList.remove("hidden"),o.style.position="fixed",o.style.left="-99999px",o.style.top="0",o.style.width="794px",o.style.background="#ffffff",o.style.display="block",o.querySelectorAll("[data-no-print]").forEach(V=>V.remove()),document.body.appendChild(o),await new Promise(V=>setTimeout(V,300));try{await ie({host:o,fileName:s("jobStrategy.myActionPlan"),bleedSidebar:!1,safeZoneMm:14,docType:"action_plan"})}finally{o.remove()}}catch(ie){console.error("Job strategy PDF export error:",ie)}finally{ne(!1)}}},z=au();nu();const b=z.find(ie=>ie.id===m);i.useEffect(()=>{(async()=>{var o,V,W,be,Me,Be;try{const{data:{user:ss}}=await C.auth.getUser();if(!ss){we(!1);return}const{data:$e}=await C.from("profiles").select("preferred_geography, preferred_job_function, preferred_industries, preferred_position_level, education, languages, it_skills, cv_url, linkedin_url").eq("id",ss.id).maybeSingle();$e&&Le({geografi:(((o=$e.preferred_geography)==null?void 0:o.length)??0)>0,funktion:(((V=$e.preferred_job_function)==null?void 0:V.length)??0)>0,brancher:(((W=$e.preferred_industries)==null?void 0:W.length)??0)>0,niveau:(((be=$e.preferred_position_level)==null?void 0:be.length)??0)>0,uddannelse:!!$e.education,sprog:(((Me=$e.languages)==null?void 0:Me.length)??0)>0,itFaerdigheder:(((Be=$e.it_skills)==null?void 0:Be.length)??0)>0,cvUploaded:!!$e.cv_url,linkedIn:!!$e.linkedin_url});const{data:es}=await C.from("career_documents").select("document_type").eq("user_id",ss.id),bs=(es==null?void 0:es.map(Xs=>Xs.document_type))||[];Oe({cv:bs.includes("cv"),linkedin:bs.includes("linkedin"),cover_letter:bs.includes("cover_letter"),email:bs.includes("email"),kandidatbrief:bs.includes("kandidatbrief")})}catch(ss){console.error("Error loading status:",ss)}finally{we(!1)}})()},[]),i.useEffect(()=>{(async()=>{try{const{data:{user:o}}=await C.auth.getUser();if(!o){ve(!1);return}const{data:V,error:W}=await C.from("action_plans").select("*").eq("user_id",o.id).order("updated_at",{ascending:!1}).limit(1).maybeSingle();if(W)console.error("Error loading action plan:",W);else if(V){K(V.id),j(V.strategy_text),w(V.strategy_text);const be=Array.isArray(V.items)?V.items:[];M(be),R(!0),E(!1),O(V.updated_at?new Date(V.updated_at):new Date)}}catch(o){console.error("Error loading action plan:",o)}finally{ve(!1)}})()},[]),i.useEffect(()=>{if(!$){ae([]);return}try{const ie=localStorage.getItem(`promoteAdditions:${$}`);if(ie){const o=JSON.parse(ie);if(Array.isArray(o)&&o.length>0){ae(o);return}}}catch{}ae([])},[$]);const U=()=>{if($)try{localStorage.removeItem(`promoteAdditions:${$}`)}catch{}ae([])};i.useEffect(()=>{!re&&d.hash==="#action-plan-section"&&setTimeout(()=>{const ie=document.getElementById("action-plan-section");ie&&ie.scrollIntoView({behavior:"smooth",block:"start"})},100)},[re,d.hash]);const te=async(ie,o,V)=>{try{const{data:{user:W}}=await C.auth.getUser();if(!W)return t({title:s("jobStrategy.error","Fejl"),description:s("jobStrategy.notLoggedIn","Du skal være logget ind for at gemme planen."),variant:"destructive"}),!1;if(xe(!0),$){const{error:be}=await C.from("action_plans").update({strategy_text:o,items:JSON.parse(JSON.stringify(ie))}).eq("id",$);if(be)throw be}else{const{data:be,error:Me}=await C.from("action_plans").insert([{user_id:W.id,strategy_text:o,items:JSON.parse(JSON.stringify(ie))}]).select().single();if(Me)throw Me;K(be.id)}return E(!1),O(new Date),V!=null&&V.silent||t({title:s("jobStrategy.planSaved","Plan gemt"),description:s("jobStrategy.planSavedToast","Dine ændringer er gemt.")}),!0}catch(W){return console.error("Error saving action plan:",W),t({title:s("jobStrategy.error","Fejl"),description:s("jobStrategy.couldNotSavePlan","Kunne ikke gemme planen. Prøv igen — kontakt support hvis problemet fortsætter.")+(W instanceof Error?` (${W.message})`:""),variant:"destructive"}),!1}finally{xe(!1)}},fe=async()=>
82{if(p)try{const{data:{user:ie}}=await C.auth.getUser();if(!ie){t({title:s("jobStrategy.error","Fejl"),description:s("jobStrategy.notLoggedIn","Du skal være logget ind for at gemme planen."),variant:"destructive"});return}xe(!0);const o=g?N:p,{data:V,error:W}=await C.from("action_plans").insert([{user_id:ie.id,strategy_text:o,items:JSON.parse(JSON.stringify(B))}]).select().single();if(W)throw W;K(V.id),E(!1),O(new Date),t({title:s("jobStrategy.newPlanSaved","Ny plan oprettet"),description:s("jobStrategy.newPlanSavedDesc","Din nye jobsøgningsplan er gemt.")})}catch(ie){console.error("Error saving new plan:",ie),t({title:s("jobStrategy.error","Fejl"),description:s("jobStrategy.couldNotSavePlan","Kunne ikke gemme planen. Prøv igen — kontakt support hvis problemet fortsætter.")+(ie instanceof Error?` (${ie.message})`:""),variant:"destructive"})}finally{xe(!1)}},Se=async ie=>{const o=[];let V="Generelt";const W=new Date,be=Me=>{const Be=Me.toLowerCase();let ss=7;Be.includes("1-4")||Be.includes("fundamentet")||Be.includes("forberedelse")?ss=Math.floor(Math.random()*21)+7:Be.includes("5-8")||Be.includes("aktivering")?ss=Math.floor(Math.random()*21)+35:Be.includes("9-12")||Be.includes("acceleration")?ss=Math.floor(Math.random()*21)+63:Be.includes("daglig")&&(ss=3);const $e=new Date(W);return $e.setDate($e.getDate()+ss),$e.toISOString()};ie.split(`
83`).forEach((Me,Be)=>{const ss=Me.replace(/\*\*/g,"").replace(/^#+\s*/,"").trim();if((ss.match(/^(uge|fase|dag)/i)||Me.startsWith("##")||Me.startsWith("#"))&&(V=ss),(Me.trim().startsWith("- ")||Me.trim().startsWith("* "))&&ss.length>5){const $e=ss.replace(/^[-*]\s*/,"");o.push({id:`action-${Date.now()}-${Be}`,text:$e,completed:Ee($e),phase:V,deadline:be(V)})}}),M(o),R(!0),await te(o,ie,{silent:!0})},G=async()=>{f(!0),R(!1),M([]),P(!1);try{const{data:ie,error:o}=await C.functions.invoke("generate-strategy",{body:{language:a.language,level:m,experience:b.subtitle}}
83);if(o)throw o;j(ie.strategy),w(ie.strategy),await Se(ie.strategy),t({title:s("jobStrategy.strategyGenerated"),description:s("jobStrategy.strategyGeneratedDesc")})}catch(ie){console.error("Error generating strategy:",ie);const o=s("jobStrategy.fallbackStrategy",{level:b.title,subtitle:b.subtitle});j(o),w(o),await Se(o),t({title:s("jobStrategy.strategyGenerated"),description:s("jobStrategy.strategyGeneratedDesc")})}finally{f(!1)}},Fe=async()=>{if(!S.trim()){t({title:s("jobStrategy.writeFeedback"),description:s("jobStrategy.writeFeedbackDesc"),variant:"destructive"});return}D(!0);try{const{data:ie,error:o}=await C.functions.invoke("generate-strategy",{body:{language:a.language,level:m,experience:b.subtitle,currentStrategy:p,feedback:S}});if(o)throw o;j(ie.strategy),w(ie.strategy),A(""),await Se(ie.strategy),t({title:s("jobStrategy.strategyUpdated"),description:s("jobStrategy.strategyUpdatedDesc")})}catch(ie){console.error("Error refining strategy:",ie),t({title:s("jobStrategy.couldNotUpdate"),description:s("jobStrategy.tryAgainLater"),variant:"destructive"})}finally{D(!1)}},Ee=ie=>{const o=ie.toLowerCase();return!!(ee&&(o.includes("cv")&&!o.includes("linkedin")&&(ee.cvUploaded||pe!=null&&pe.cv)||o.includes("linkedin")&&(ee.linkedIn||pe!=null&&pe.linkedin)||(o.includes("geografi")||o.includes("område"))&&ee.geografi||(o.includes("branche")||o.includes("industri"))&&ee.brancher||(o.includes("funktion")||o.includes("jobfunktion"))&&ee.funktion||(o.includes("niveau")||o.includes("stillingsniveau"))&&ee.niveau||o.includes("uddannelse")&&ee.uddannelse||o.includes("sprog")&&ee.sprog||o.includes("it-færdighed")&&ee.itFaerdigheder||(o.includes("præference")||o.includes("mine valg"))&&ee.geografi&&ee.brancher&&ee.funktion)||pe&&(o.includes("kandidatbrief")&&pe.kandidatbrief||o.includes("cover letter")&&pe.cover_letter||o.includes("ansøgningsemail")&&pe.email)||o.includes("✓")||o.includes("allerede klar")||o.includes("allerede tilgængelig"))},qe=ie=>{M(o=>{const V=o.map(W=>W.id===ie?{...W,completed:!W.completed}:W);return E(!0),V})},Ge=(ie,o)=>{M(V=>{const W=V.map(be=>be.id===ie?{...be,deadline:o==null?void 0:o.toISOString()}:be);return E(!0),W})},He=ie=>{M(o=>o.filter(V=>V.id!==ie)),E(!0)},Ze=(ie,o,V)=>{const W=o.trim();if(!W)return;const be={id:`action-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,text:W,completed:!1,phase:ie,deadline:V?V.toISOString():void 0};M(Me=>[...Me,be]),E(!0)},Us=(ie,o,V)=>{if(!p)return null;const W=p.split(`
84`),be=[];let Me=null,Be=!1;if(W.forEach((q,Ce)=>{const Ie=q.replace(/\*\*/g,"").replace(/^#+\s*/,"").trim();(q.startsWith("##")||q.startsWith("#")||q.startsWith("**")&&q.endsWith("**")||Ie.match(/^(uge|fase|dag)/i))&&Ie?(Me&&(Me.end=Ce-1,be.push(Me)),Me={start:Ce,end:W.length-1,title:Ie}):!Me&&Ie&&(Be||(Be=!0,Me={start:Ce,end:W.length-1,title:s("jobStrategy.introduction")}))}),Me&&be.push(Me),ie<0||ie>=be.length)return null;const ss=be[ie],$e=Be&&ie===0&&ss.title===s("jobStrategy.introduction"),es=$e?V.split(`
85`):[`## ${o}`,...V.split(`
86`)],bs=W.slice(0,ss.start),Xs=W.slice(ss.end+1),Ks=[...bs,...es,...Xs].join(`
87`);return j(Ks),w(Ks),!$e&&o!==ss.title&&M(q=>q.map(Ce=>Ce.phase===ss.title?{...Ce,phase:o}:Ce)),E(!0),Ks},le=B.filter(ie=>ie.completed).length;B.reduce((ie,o)=>(ie[o.phase]||(ie[o.phase]=[]),ie[o.phase].push(o),ie),{});const X=new Date;X.setHours(0,0,0,0);const L=new Date(X);L.setDate(L.getDate()+3);const ce=new Date(X);ce.setDate(ce.getDate()+7);const ys=B.filter(ie=>!ie.completed&&ie.deadline).map(ie=>({...ie,deadlineDate:new Date(ie.deadline)})).filter(ie=>ie.deadlineDate<=ce).sort((ie,o)=>ie.deadlineDate.getTime()-o.deadlineDate.getTime());ys.filter(ie=>ie.deadlineDate<X),ys.filter(ie=>{const o=ie.deadlineDate;return o>=X&&o<new Date(X.getTime()+24*60*60*1e3)}),ys.filter(ie=>{const o=ie.deadlineDate;return o>=new Date(X.getTime()+24*60*60*1e3)&&o<=ce});const Hs=ee?Object.values(ee).filter(Boolean).length:0,Os=ee?Object.keys(ee).length:9,Ls=pe?Object.values(pe).filter(
87Boolean).length:0,Bs=pe?Object.keys(pe).length:5;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Il,{context:"strategy"}),T.length>0&&e.jsx(ye,{className:"p-4 border-primary/30 bg-primary/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/15 flex items-center justify-center shrink-0",children:e.jsx(xs,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:s("jobStrategy.promoteAddedTitle",{count:T.length,defaultValue:"{{count}} ny handling tilføjet fra Promoveringsplaner"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("jobStrategy.promoteAddedDesc","Du finder de nye handlinger længere nede i din jobsøgningsplan, grupperet under følgende fase(r):")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:Array.from(new Set(T.map(ie=>ie.phase))).map(ie=>e.jsx(je,{variant:"outline",className:"text-xs border-primary/40 text-primary",children:ie},ie))}),e.jsxs("ul",{className:"mt-2 space-y-1",children:[T.slice(0,3).map((ie,o)=>e.jsxs("li",{className:"text-xs text-muted-foreground line-clamp-1",children:["• ",ie.text]},o)),T.length>3&&e.jsx("li",{className:"text-xs text-muted-foreground",children:s("jobStrategy.promoteAddedMore",{count:T.length-3,defaultValue:"+ {{count}} mere"})})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(h,{size:"sm",variant:"outline",onClick:()=>{var ie;(ie=document.getElementById("action-plan-section"))==null||ie.scrollIntoView({behavior:"smooth",block:"start"})},children:s("jobStrategy.promoteAddedGoTo","Gå til handlingerne")}),e.jsx(h,{size:"sm",variant:"ghost",onClick:U,children:s("jobStrategy.promoteAddedDismiss","Skjul")})]})]})]})}),!re&&p&&e.jsx(ye,{className:jt("p-4 border",I?"border-amber-500/40 bg-amber-500/5":"border-green-500/30 bg-green-500/5"),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:jt("w-10 h-10 rounded-xl flex items-center justify-center shrink-0",I?"bg-amber-500/20":"bg-green-500/20"),children:e.jsx(zs,{className:jt("w-5 h-5",I?"text-amber-600":"text-green-600")})}),e.jsxs("div",{className:"flex-1 min-w-[180px]",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:$?s("jobStrategy.savedStrategy"):s("jobStrategy.unsavedPlan","Ugemt plan")}),I?e.jsx(je,{variant:"outline",className:"text-amber-600 border-amber-500/40 text-xs",children:s("jobStrategy.unsavedChanges","Ugemte ændringer")}):$?e.jsxs(je,{variant:"outline",className:"text-green-600 border-green-500/30 text-xs",children:[e.jsx($s,{className:"w-3 h-3 mr-1"}),s("jobStrategy.active")]}):null]}),e.jsxs("p",{className:"text-muted-foreground text-xs mt-0.5",children:[F?s("jobStrategy.lastSavedAt","Sidst gemt {{time}}",{time:_s(F,"HH:mm",{locale:n})}):s("jobStrategy.notSavedYet","Ikke gemt endnu"),B.length>0&&le>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-green-600 font-medium",children:s("jobStrategy.activitiesCompleted",{completed:le,total:B.length,percentage:Math.round(le/B.length*100)})})]})]})]})]})}),!re&&p&&!$&&e.jsx("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-900 dark:text-amber-200",children:s("jobStrategy.unsavedWarning","Husk at gemme planen for at beholde den — ellers forsvinder den, hvis du forlader siden.")}),!re&&e.jsx(tu,{activeId:$,onLoad:ie=>{K(ie.id),j(ie.strategy_text),w(ie.strategy_text);const o=Array.isArray(ie.items)?ie.items:[];M(o),R(!0),E(!1),O(ie.updated_at?new Date(ie.updated_at):new Date)}}),!he&&(ee||pe)&&e.jsxs(ye,{className:"p-6 border-muted",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground mb-4 flex items-center gap-2",children:[e.jsx($s,{className:"w-5 h-5 text-green-500"}),s("jobStrategy.careerSammyStatus")]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-medium text-foreground text-sm",children:s("jobStrategy.myChoices")}),e.jsxs(je,{variant:Hs===Os?"default":"secondary",className:"text-xs",children:[Hs,"/",Os," ",s("jobStrategy.filled")]})]}),e.jsx("div",{className:"space-y-2",children:ee&&e.jsxs(e.Fragment,{children:[e.jsx(vt,{label:s("jobStrategy.geography"),done:ee.geografi,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.jobFunction"),done:ee.funktion,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.industries"),done:ee.brancher,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.positionLevel"),done:ee.niveau,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.education"),done:ee.uddannelse,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.languages"),done:ee.sprog,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.itSkills"),done:ee.itFaerdigheder,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.cvUploaded"),done:ee.cvUploaded,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.linkedInUrl"),done:ee.linkedIn,readyLabel:s("jobStrategy.ready")})]})}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>r("/mit-karrieresite?tab=mine-input"),className:"mt-3 text-primary text-xs gap-1",children:[e.jsx(Hn,{className:"w-3 h-3"}
87),s("jobStrategy.goToMyChoices")]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-medium text-foreground text-sm",children:s("jobStrategy.myDocuments")}),e.jsxs(je,{variant:Ls===Bs?"default":"secondary",className:"text-xs",children:[Ls,"/",Bs," ",s("jobStrategy.created")]})]}),e.jsx("div",{className:"space-y-2",children:pe&&e.jsxs(e.Fragment,{children:[e.jsx(vt,{label:s("jobStrategy.cv"),done:pe.cv,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.linkedInProfile"),done:pe.linkedin,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.coverLetter"),done:pe.cover_letter,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.applicationEmail"),done:pe.email,readyLabel:s("jobStrategy.ready")}),e.jsx(vt,{label:s("jobStrategy.candidateBrief"),done:pe.kandidatbrief,readyLabel:s("jobStrategy.ready")})]})}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>r("/mit-karrieresite?tab=karriereprofil"),className:"mt-3 text-primary text-xs gap-1",children:[e.jsx(Hn,{className:"w-3 h-3"}),s("jobStrategy.goToCareerProfile")]})]})]})]}),e.jsx(ye,{id:"action-plan-section",className:"p-6 bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:jt("w-14 h-14 rounded-full overflow-hidden shrink-0 ring-offset-2 ring-offset-background relative",l?"ring-4 ring-primary/50 animate-pulse":"ring-2 ring-primary/30"),children:[e.jsx("img",{src:_,alt:"Sammy",className:jt("w-full h-full object-cover transition-transform duration-300",l&&"scale-105")}),l&&e.jsx("div",{className:"absolute inset-0 bg-primary/10 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap mb-2",children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:s(l?"jobStrategy.sammyThinking":"jobStrategy.strategyAndPlan")}),!l&&p&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(h,{size:"sm",onClick:()=>te(B,g?N:p||""),disabled:ze||!I&&!!$,className:"gap-2",children:[ze?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(zs,{className:"w-4 h-4"}),$?s("jobStrategy.saveInExisting","Gem i eksisterende plan"):s("jobStrategy.savePlan","Gem plan")]}),$&&e.jsxs(h,{size:"sm",variant:"outline",onClick:fe,disabled:ze,className:"gap-2",children:[e.jsx(fs,{className:"w-4 h-4"}),s("jobStrategy.saveAsNew","Gem som ny plan")]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:x,disabled:H,className:"gap-2 text-muted-foreground",children:[e.jsx(Qt,{className:"w-4 h-4"}),H?s("jobStrategy.downloading","Henter…"):s("jobStrategy.download")]})]})]}),e.jsx("p",{className:"text-muted-foreground mb-4",children:s(l?"jobStrategy.sammyAnalyzing":"jobStrategy.getPersonalStrategy")}),p?e.jsxs("div",{className:"space-y-4",children:[g?e.jsx(as,{value:N,onChange:ie=>w(ie.target.value),className:"min-h-[300px] font-mono text-sm",placeholder:s("jobStrategy.editPlaceholder")}):e.jsxs(e.Fragment,{children:[(()=>{const ie=[];let o=null;return p.split(`
88`).forEach(V=>{const W=V.replace(/\*\*/g,"").replace(/^#+\s*/,"").trim();(V.startsWith("##")||V.startsWith("#")||V.startsWith("**")&&V.endsWith("**")||W.match(/^(uge|fase|dag)/i))&&W?(o&&ie.push(o),o={title:W,content:[]}):o&&W?o.content.push(V):!o&&W&&((!ie.length||ie[0].title!==s("jobStrategy.introduction"))&&ie.unshift({title:s("jobStrategy.introduction"),content:[]}),ie[0].content.push(V))}),o&&ie.push(o),ie.map((V,W)=>{const be=V.title.toLowerCase(),Me=B.filter($e=>{var bs,Xs,Ks,q;const es=$e.phase.toLowerCase();return es===be||es.includes(be)||be.includes(es)||be.match(/uge\s*(\d+)/i)&&es.match(/uge\s*(\d+)/i)&&((bs=be.match(/uge\s*(\d+)/i))==null?void 0:bs[0])===((Xs=es.match(/uge\s*(\d+)/i))==null?void 0:Xs[0])||be.match(/fase\s*(\d+)/i)&&es.match(/fase\s*(\d+)/i)&&((Ks=be.match(/fase\s*(\d+)/i))==null?void 0:Ks[0])===((q=es.match(/fase\s*(\d+)/i))==null?void 0:q[0])}),Be=Q.has(W),ss=Me.filter($e=>$e.completed).length;return e.jsxs(ye,{className:"p-5 bg-background border-l-4 border-l-primary/30",children:[me===W?e.jsxs("div",{className:"space-y-2 mb-3",children:[e.jsx(ue,{value:oe.title,onChange:$e=>Ve(es=>({...es,title:$e.target.value})),className:"font-semibold text-base",placeholder:s("jobStrategy.sectionTitlePlaceholder","Overskrift")}),e.jsx(as,{value:oe.body,onChange:$e=>Ve(es=>({...es,body:$e.target.value})),className:"min-h-[120px] text-sm",placeholder:s("jobStrategy.sectionBodyPlaceholder","Beskrivelse...")}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{size:"sm",variant:"outline",onClick:()=>Ae(null),children:s("jobStrategy.cancelEdit","Annullér")})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[e.jsx("h4",{className:"font-semibold text-foreground text-base flex-1",children:V.title}),e.jsxs(h,{size:"sm",variant:"ghost",className:"shrink-0 h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Ae(W),Ve({title:V.title,body:V.content.join(`
89`)})},children:[e.jsx(ya,{className:"w-3.5 h-3.5 mr-1"}),s("jobStrategy.editSection","Rediger")]})]}),e.jsx("div",{className:"space-y-2",children:V.content.map(($e,es)=>{const bs=$e.replace(/\*\*/g,"").trim();return $e.trim().startsWith("- ")||$e.trim().startsWith("* ")?e.jsxs("div",{className:"flex items-start gap-2 text-muted-foreground text-sm",children:[e.jsx("span",{className:"text-primary mt-1",children:"•"}),e.jsx("span",{children:$e.replace(/^[\s-*]+/,"").replace(/\*\*/g,"")})]},es):bs?e.jsx("p",{className:"text-muted-foreground text-sm",children:bs},es):null})})]}),e.jsxs("div",{className:"mt-4 space-y-3",children:[Me.length>0&&e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>{k($e=>{const es=new Set($e);return es.has(W)?es.delete(W):es.add(W),es})},className:"gap-2 text-primary border-primary/30 hover:bg-primary/10",children:[e.jsx(El,{className:"w-4 h-4"}),s(Be?"jobStrategy.hideActivitySuggestions":"jobStrategy.showActivitySuggestions"),e.jsxs(je,{variant:"secondary",className:"text-xs ml-1",children:[ss,"/",Me.length]})]}),(Be||Me.length===0)&&e.jsxs("div",{className:"space-y-2 pl-1",children:[Me.map($e=>{const es=cl($e.text,s);return e.jsxs("div",{className:jt("flex items-center gap-2 text-sm p-2.5 rounded-lg border transition-colors",$e.completed?"bg-green-500/5 border-green-500/20":"bg-muted/30 border-border/50 hover:bg-muted/50"),children:[e.jsx(Kt,{checked:$e.completed,onCheckedChange:()=>qe($e.id),className:"shrink-0"}),e.jsx("span",{className:jt("flex-1",$e.completed&&"line-through text-muted-foreground"),children:$e.text}),es&&e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>r(es.path),className:"shrink-0 text-xs text-primary gap-1 h-7 px-2",children:[e.jsx(Hn,{className:"w-3 h-3"}),es.label]}),e.jsxs(ta,{children:[e.jsx(aa,{asChild:!0,children:e.jsxs(h,{variant:"ghost",size:"sm",className:"shrink-0 h-7 px-2 text-xs text-muted-foreground gap-1",children:[e.jsx(gt,{className:"w-3 h-3"}),$e.deadline?_s(new Date($e.deadline),"d. MMM",{locale:n}):s("jobStrategy.pickDate","Vælg dato")]})}),e.jsx(na,{className:"w-auto p-0",align:"end",children:e.jsx(Rr,{mode:"single",selected:$e.deadline?new Date($e.deadline):void 0,onSelect:bs=>Ge($e.id,bs),initialFocus:!0,className:jt("p-3 pointer-events-auto")})})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"shrink-0 h-7 w-7 p-0 text-muted-foreground hover:text-destructive",onClick:()=>He($e.id),"aria-label":s("jobStrategy.deleteItem","Slet handling"),children:e.jsx(Ss,{className:"w-3.5 h-3.5"})})]},$e.id)}),Xe===W?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 p-2.5 rounded-lg border border-dashed border-primary/40 bg-primary/5",children:[e.jsx(ue,{value:hs,onChange:$e=>ps($e.target.value),placeholder:s("jobStrategy.newItemPlaceholder","Beskriv handling..."),className:"flex-1 min-w-[200px] h-9",autoFocus:!0}),e.jsxs(ta,{children:[e.jsx(aa,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(gt,{className:"w-3.5 h-3.5"}),ms?_s(ms,"d. MMM",{locale:n}):s("jobStrategy.pickDate","Vælg dato")]})}),e.jsx(na,{className:"w-auto p-0",align:"end",children:e.jsx(Rr,{mode:"single",selected:ms,onSelect:De,initialFocus:!0,className:jt("p-3 pointer-events-auto")})})]}),e.jsx(h,{size:"sm",onClick:()=>{Ze(V.title,hs,ms),ps(""),De(void 0),cs(null),Q.has(W)||k($e=>new Set($e).add(W))},disabled:!hs.trim(),children:s("jobStrategy.add","Tilføj")}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>{cs(null),ps(""),De(void 0)},children:s("jobStrategy.cancelEdit","Annullér")})]}):e.jsxs(h,{variant:"ghost",size:"sm",className:"gap-1 text-primary hover:bg-primary/10",onClick:()=>{cs(W),ps(""),De(void 0)},children:[e.jsx(fs,{className:"w-3.5 h-3.5"}),s("jobStrategy.addAction","Tilføj handling")]})]}),(I||me===W)&&e.jsx("div",{className:"flex justify-end pt-2 border-t border-border/40",children:e.jsxs(h,{size:"sm",variant:"default",onClick:async()=>{let $e=B,es=p||"";if(me===W){const bs=oe.title.trim()||V.title;es=Us(W,bs,oe.body)??es,V.title!==bs&&($e=B.map(Ks=>Ks.phase===V.title?{...Ks,phase:bs}:Ks)),Ae(null)}await te($e,es)},disabled:ze,className:"gap-1",children:[ze?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(zs,{className:"w-3.5 h-3.5"}),s("jobStrategy.saveBoxChanges","Gem ændringer")]})})]})]},W)})})(),(()=>{const ie=B.filter(o=>o.source==="promote-yourself");return ie.length===0?null:e.jsxs(ye,{id:"action-plan-section",className:"p-5 bg-background border-l-4 border-l-primary",children:[e.jsxs("h4",{className:"font-semibold text-foreground mb-1 text-base flex items-center gap-2",children:[e.jsx(xs,{className:"w-4 h-4 text-primary"}),s("jobStrategy.promoteSectionTitle","Fra Promoveringsplaner")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("jobStrategy.promoteSectionDesc","Handlinger du har tilføjet fra dine promover
89ingsplaner.")}),e.jsx("div",{className:"space-y-2",children:ie.map(o=>{const V=cl(o.text,s);return e.jsxs("div",{className:jt("flex items-center gap-2 text-sm p-2.5 rounded-lg border transition-colors",o.completed?"bg-green-500/5 border-green-500/20":"bg-muted/30 border-border/50 hover:bg-muted/50"),children:[e.jsx(Kt,{checked:o.completed,onCheckedChange:()=>qe(o.id),className:"shrink-0"}),e.jsx("span",{className:jt("flex-1",o.completed&&"line-through text-muted-foreground"),children:o.text}),o.phase&&e.jsx(je,{variant:"outline",className:"text-[10px] shrink-0 border-primary/30 text-primary",children:o.phase}),V&&e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>r(V.path),className:"shrink-0 text-xs text-primary gap-1 h-7 px-2",children:[e.jsx(Hn,{className:"w-3 h-3"}),V.label]}),o.deadline&&e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:_s(new Date(o.deadline),"d. MMM",{locale:n})})]},o.id)})})]})})()]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{variant:"outline",onClick:G,disabled:l,className:"gap-2",children:[e.jsx(dt,{className:`w-4 h-4 ${l?"animate-spin":""}`}),s("jobStrategy.generateNewStrategy")]}),g?e.jsxs(e.Fragment,{children:[e.jsxs(h,{onClick:async()=>{j(N),P(!1),await te(B,N),t({title:s("jobStrategy.strategySaved"),description:s("jobStrategy.strategySavedDesc")})},className:"gap-2",children:[e.jsx(zs,{className:"w-4 h-4"}),s("jobStrategy.saveChanges")]}),e.jsx(h,{variant:"outline",onClick:()=>{w(p||""),P(!1)},className:"gap-2",children:s("jobStrategy.cancelEdit")})]}):e.jsxs(h,{variant:"outline",onClick:()=>P(!0),className:"gap-2",children:[e.jsx(ya,{className:"w-4 h-4"}),s("jobStrategy.editManually")]})]}),e.jsxs(ye,{className:"p-4 bg-muted/30 border-dashed",children:[e.jsxs("h4",{className:"font-medium text-foreground mb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden",children:e.jsx("img",{src:_,alt:"Sammy",className:"w-full h-full object-cover"})}),s("jobStrategy.customizeWithSammy")]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:s("jobStrategy.writeChanges")}),e.jsx(as,{value:S,onChange:ie=>A(ie.target.value),placeholder:s("jobStrategy.feedbackPlaceholder"),className:"mb-3",rows:3}),e.jsx(h,{onClick:Fe,disabled:y||!S.trim(),variant:"secondary",className:"gap-2",children:y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),s("jobStrategy.updating")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-4 h-4"}),s("jobStrategy.customizeStrategy")]})})]})]}):e.jsx(h,{onClick:G,disabled:l,className:"gap-2",children:l?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),s("jobStrategy.generatingStrategy")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-4 h-4"}),s("jobStrategy.generateMyStrategy")]})})]})]})}),B.length>0&&e.jsxs("div",{ref:Z,"aria-hidden":"true",className:"jobstrategy-print",style:{position:"fixed",left:"-99999px",to
89p:0,width:"794px",background:"#ffffff",color:"#111",fontSize:"11pt",lineHeight:1.5,padding:"16px",pointerEvents:"none",textDecoration:"none",textDecorationLine:"none",WebkitTextDecorationLine:"none"},children:[e.jsx("style",{children:`
90            .jobstrategy-print, .jobstrategy-print * {
91              text-decoration: none !important;
92              text-decoration-line: none !important;
93              -webkit-text-decoration-line: none !important;
94              border-bottom: 0 !important;
95              box-shadow: none !important;
96            }
97          `}),e.jsx("h1",{style:{fontSize:"22pt",margin:"0 0 6pt",fontWeight:700},children:s("jobStrategy.myActionPlan")}),e.jsxs("p",{style:{fontSize:"10pt",color:"#666",margin:"0 0 16pt"},children:[s("jobStrategy.generated")," ",_s(new Date,"d. MMMM yyyy",{locale:n})," • ",le," ",s("jobStrategy.of")," ",B.length]}),p&&(()=>{const ie=[];let o=null;return(g?N:p).split(`
98`).forEach(V=>{const W=V.replace(/\*\*/g,"").replace(/^#+\s*/,"").trim();(V.startsWith("##")||V.startsWith("#")||V.startsWith("**")&&V.endsWith("**")||!!W.match(/^(uge|fase|dag|week|phase|day)/i))&&W?(o&&ie.push(o),o={title:W,content:[]}):o&&W?o.content.push(V):!o&&W&&((!ie.length||ie[0].title!==s("jobStrategy.introduction"))&&ie.unshift({title:s("jobStrategy.introduction"),content:[]}),ie[0].content.push(V))}),o&&ie.push(o),ie.length?e.jsx("div",{style:{marginBottom:"18pt"},children:ie.map((V,W)=>e.jsxs("div",{"data-pdf-break":W===0?void 0:"section",style:{marginTop:W===0?0:"12pt"},children:[e.jsx("h2",{style:{fontSize:"13pt",fontWeight:700,margin:"0 0 6pt",color:"#1a3a5c"},children:Cr(V.title)}),V.content.map((be,Me)=>e.jsx("p",{style:{margin:"0 0 4pt",fontSize:"10.5pt",color:"#333",whiteSpace:"pre-wrap"},children:Cr(be)},Me))]},W))}):null})(),e.jsx("h2",{"data-pdf-break":"section",style:{fontSize:"14pt",fontWeight:700,margin:"18pt 0 8pt",color:"#1a3a5c"},children:s("jobStrategy.myActionPlan")}),Object.entries(B.reduce((ie,o)=>{const V=o.phase||s("actionPlan.allActivities");return(ie[V]||(ie[V]=[])).push(o),ie},{})).map(([ie,o],V)=>e.jsxs("div",{style:{marginTop:V===0?0:"14pt"},children:[e.jsx("h3",{"data-pdf-break":V===0?void 0:"section",style:{fontSize:"10pt",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"#555",margin:"0 0 8pt"},children:ie}),o.map(W=>e.jsxs("div",{"data-pdf-break":"bullet",style:{display:"flex",gap:"8pt",padding:"8pt 10pt",marginBottom:"6pt",borderRadius:"6pt",border:"1px solid #e5e5e5",background:W.completed?"#f0fdf4":"#fafafa"},children:[e.jsx("span",{style:{flexShrink:0,color:W.completed?"#16a34a":"#999"},children:W.completed?"✓":"○"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{textDecoration:W.completed?"line-through":"none"},children:Cr(W.text)}),W.deadline&&e.jsx("div",{style:{fontSize:"9pt",color:"#888",marginTop:"2pt"},children:_s(new Date(W.deadline),"d. MMM yyyy",{locale:n})}),W.notes&&W.notes.length>0&&e.jsx("ul",{style:{margin:"4pt 0 0",paddingLeft:"16pt",fontSize:"10pt",color:"#444"},children:W.notes.map((be,Me)=>e.jsx("li",{children:String(be)},Me))})]})]},W.id))]},ie))]})]})},iu=({children:s}={})=>{const{t:a,i18n:t}=Je(),{toast:r}=Ct(),[n,d]=i.useState(null),[m,c]=i.useState(!1),[l,f]=i.useState(!1),[p,j]=i.useState(""),[g,P]=i.useState(!1),[N,w]=i.useState(!1),S=i.useRef(null);i.useEffect(()=>{(async()=>{const{data:{user:O}}=await C.auth.getUser();if(!O)return;const{data:ee}=await C.from("profiles").select("linkedin_url").eq("id",O.id).maybeSingle();ee!=null&&ee.linkedin_url&&d(ee.linkedin_url)})()},[]);const[A,y]=i.useState(null),D=i.useRef(null),B=(F,O)=>{y({title:F,description:O}),r({title:F,description:O,variant:"destructive"}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>y(null),8e3)},M=()=>{D.current&&clearTimeout(D.current),y(null)};i.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const Y=F=>{if(!F.size||F.size===0)return B(a("myChoices.dropEmptyFile"),a("myChoices.dropEmptyFileDesc",{name:F.name||"—"})),!1;const O=F.type==="application/pdf",ee=/\.pdf$/i.test(F.name||"");return!O&&!ee?(B(a("myChoices.dropInvalidType"),a("myChoices.dropInvalidTypeDesc",{name:F.name||"—",type:F.type||"ukendt"})),!1):!0},R=async F=>{if(M(),!Y(F))return;const{validateUploadFile:O,extractProfileFromFile:ee}=await ma(async()=>{const{validateUploadFile:pe,extractProfileFromFile:Oe}=await import("./extractProfile-Bhj0bfp7.js");return{validateUploadFile:pe,extractProfileFromFile:Oe}},__vite__mapDeps([3,1,2,4])),Le=O(F);if(!Le.ok){B(a("myChoices.error"),Le.error||a("myChoices.maxFileSize"));return}w(!0);try{const{data:{user:pe}}=await C.auth.getUser();if(!pe){B(a("myChoices.notLoggedIn"),a("myChoices.mustBeLoggedIn"));return}r({title:a("myChoices.analyzingLinkedInPdf")});const Oe=await ee({file:F,language:t.language,context:"profile"});if(!Oe.ok){B(a("myChoices.error"),Oe.error||a("myChoices.couldNotAnalyzePdf"));return}if(Oe.data){const he=Oe.data.full_name,we=he?`LinkedIn PDF: ${he}`:"LinkedIn PDF";d(we),await C.from("profiles").update({linkedin_url:we}).eq("id",pe.id),qt(),c(!1),r({title:a("myChoices.linkedInPdfImported"),description:a("myChoices.linkedInPdfImportedDesc",{count:Oe.workExperiencesSaved||0})})}else B(a("myChoices.error"),a("myChoices.couldNotExtractPdf"))}catch(pe){console.error("Error uploading LinkedIn PDF:",pe),B(a("myChoices.error"),a("myChoices.errorOccurred"))}finally{w(!1),S.current&&(S.current.value="")}},Q=async F=>{var ee;const O=(ee=F.target.files)==null?void 0:ee[0];O&&await R(O)},[k,$]=i.useState(!1),K=i.useRef(0),re=F=>{var O,ee;n||N||(ee=(O=F.dataTransfer)==null?void 0:O.types)!=null&&ee.includes("Files")&&(F.preventDefault(),K.current+=1,$(!0))},ve=F=>{var O,ee;n||N||(ee=(O=F.dataTransfer)==null?void 0:O.types)!=null&&ee.includes("Files")&&(F.preventDefault(),F.dataTransfer.dropEffect="copy")},ze=F=>{n||N||(F.preventDefault(),K.current=Math.max(0,K.current-1),K.current===0&&$(!1))},xe=async F=>{var ee;if(n||N)return;F.preventDefault(),K.current=0,$(!1);const O=(ee=F.dataTransfer.files)==null?void 0:ee[0];if(!O){B(a("myChoices.error"),a("myChoices.uploadPdfFile"));return}await R(O)},I=async()=>
98{if(!p.trim()||p.trim().length<50){r({title:a("myChoices.error"),description:a("myChoices.minChars"),variant:"destructive"});return}P(!0);try{const{data:{user:F}}=await C.auth.getUser();if(!F){r({title:a("myChoices.notLoggedIn"),variant:"destructive"});return}const{data:O,error:ee}=await C.functions.invoke("extract-profile-data",{body:{language:t.language,cvContent:p,userId:F.id}});if(ee)r({title:a("myChoices.error"),description:a("myChoices.couldNotAnalyzeText"),variant:"destructive"});else if(O!=null&&O.data){const Le=O.data.full_name?`LinkedIn: ${O.data.full_name}`:a("myChoices.linkedInPastedText");d(Le),await C.from("profiles").update({linkedin_url:Le}).eq("id",F.id),qt(),f(!1),j(""),r({title:a("myChoices.linkedInTextImported"),description:a("myChoices.linkedInTextImportedDesc",{count:O.workExperiencesSaved||0})})}}catch(F){console.error("Error processing LinkedIn text:",F),r({title:a("myChoices.error"),description:a("myChoices.errorOccurred"),variant:"destructive"})}finally{P(!1)}},E=async()=>{try{const{data:{user:F}}=await C.auth.getUser();if(!F)return;const{error:O}=await C.from("profiles").update({linkedin_url:null}).eq("id",F.id);if(O)throw O;d(null),qt(),r({title:a("myChoices.linkedInRemoved"),description:a("myChoices.linkedInRemovedDesc")})}catch(F){console.error("Error removing LinkedIn:",F),r({title:a("myChoices.error"),description:a("myChoices.couldNotRemoveLinkedIn"),variant:"destructive"})}};return e.jsxs(e.Fragment,{children:[e.jsxs(ye,{className:`p-6 relative transition-colors ${k?"ring-2 ring-[#0077B5] bg-[#0077B5]/5":""}`,onDragEnter:re,onDragOver:ve,onDragLeave:ze,onDrop:xe,children:[e.jsxs("h3",{className:"font-semibold text-foreground text-lg mb-4 flex items-center gap-2",children:[e.jsx(Ms,{className:"w-5 h-5 text-[#0077B5]"}),"LinkedIn"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(se,{className:"text-sm font-medium",children:a("myChoices.linkedInProfile")}),A&&e.jsxs("div",{role:"alert","aria-live":"assertive",className:"flex items-start gap-3 p-3 rounded-lg border border-destructive/40 bg-destructive/10 text-destructive",children:[e.jsx(wa,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold",children:A.title}),e.jsx("p",{className:"text-xs mt-0.5 break-words opacity-90",children:A.description})]}),e.jsx("button",{type:"button",onClick:M,"aria-label":a("myChoices.dropTryAgain"),className:"shrink-0 rounded p-0.5 hover:bg-destructive/20",children:e.jsx(mt,{className:"w-3.5 h-3.5"})})]}),n?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Ms,{className:"w-5 h-5 text-[#0077B5]"}),e.jsx("span",{className:"text-sm font-medium flex-1 truncate",children:a("myChoices.linkedInImported")}),e.jsx(h,{size:"sm",variant:"ghost",onClick:E,className:"text-destructive hover:text-destructive",children:e.jsx(Ss,{className:"w-4 h-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(Cl,{children:[e.jsx(_l,{asChild:!0,children:e.jsxs(h,{className:"flex-1 bg-[#0077B5] hover:bg-[#0077B5]/90 text-white",children:[e.jsx(Ms,{className:"mr-2 h-4 w-4"}),a("myChoices.importLinkedIn"),e.jsx(Ts,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(Sl,{align:"start",className:"w-64 bg-popover z-50",children:[e.jsxs(Jn,{onClick:()=>c(!0),children:[e.jsx(Ja,{className:"mr-2 h-4 w-4"}),a("myChoices.pdfFromLinkedIn")]}),e.jsxs(Jn,{onClick:()=>f(!0),children:[e.jsx(Zn,{className:"mr-2 h-4 w-4"}),a("myChoices.pasteText")]})]})]}),e.jsx(Ya,{children:e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(ha,{className:"h-4 w-4 text-muted-foreground shrink-0 cursor-help"})}),e.jsx(Js,{side:"top",className:"max-w-[220px] text-xs",children:a("myChoices.linkedInTooltip")})]})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[e.jsx(Ja,{className:"h-3 w-3"}),a("myChoices.dropPdfHint",{defaultValue:"Eller træk og slip din LinkedIn PDF her"})]})]})]}),k&&e.jsx("div",{className:"absolute inset-0 rounded-xl bg-[#0077B5]/10 border-2 border-dashed border-[#0077B5] flex items-center justify-center pointer-events-none z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-[#0077B5]",children:[e.jsx(Ja,{className:"h-8 w-8"}),e.jsx("p",{className:"font-medium text-sm",children:a("myChoices.dropPdfActive",{defaultValue:"Slip PDF for at importere"})})]})}),N&&e.jsx("div",{className:"absolute inset-0 rounded-xl bg-background/70 flex items-center justify-center pointer-events-none z-10",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-foreground",children:[e.jsx(ge,{className:"h-6 w-6 animate-spin text-[#0077B5]"}),e.jsx("p",{className:"text-sm font-medium",children:a("myChoices.analyzingPdf")})]})}),s&&e.jsx("div",{className:"mt-6 pt-6 border-t border-border",children:s})]}),e.jsx(ns,{open:m,onOpenChange:c,children:e.jsxs(rs,{className:"sm:max-w-md",children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-5 w-5 text-[#0077B5]"}),a("myChoices.importLinkedInTitle")]}),e.jsx(Qs,{children:a("myChoices.importLinkedInDesc")})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:a("myChoices.howToExport")}),e.jsxs("ol",{className:"text-xs text-muted-foreground space-y-1 list-decimal pl-4",children:[e.jsx("li",{children:a("myChoices.exportStep1")}),e.jsx("li",{children:a("myChoices.exportStep2")}),e.jsx("li",{children:a("myChoices.exportStep3")}),e.jsx("li",{children:a("myChoices.exportStep4")})]})]}),e.jsx("input",{type:"file",ref:S,onChange:Q,accept:".pdf",className:"hidden"}),e.jsx(h,{onClick:()=>{var F;return(F=S.current)==null?void 0:F.click()},disabled:N,className:"w-full bg-[#0077B5] hover:bg-[#0077B5]/90",children:N?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"mr-2 h-4 w-4 animate-spin"}),a("myChoices.analyzingPdf")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ja,{className:"mr-2 h-4 w-4"}),a("myChoices.uploadLinkedInPdf")]})})]})]})}),e.jsx(ns,{open:l,onOpenChange:f,children:e.jsxs(rs,{className:"sm:max-w-lg",children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5 text-[#0077B5]"}),a("myChoices.pasteLinkedInTitle")]}),e.jsx(Qs,{children:a("myChoices.pasteLinkedInDesc")})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:a("myChoices.howToCopy")}),e.jsxs("ol",{className:"text-xs text-muted-foreground space-y-1 list-decimal pl-4",children:[e.jsx("li",{children:a("myChoices.copyStep1")}),e.jsx("li",{children:a("myChoices.copyStep2")}),e.jsx("li",{children:a("myChoices.copyStep3")}),e.jsx("li",{children:a("myChoices.copyStep4")})]})]}),e.jsx(as,{placeholder:a("myChoices.pasteLinkedInPlaceholder"),value:p,onChange:F=>j(F.target.value),rows:10,className:"resize-none"}),e.jsx(h,{onClick:I,disabled:g||!p.trim(),className:"w-full bg-[#0077B5] hover:bg-[#0077B5]/90",children:g?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"mr-2 h-4 w-4 animate-spin"}),a("myChoices.analyzingText")]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{className:"mr-2 h-4 w-4"}),a("myChoices.analyzeAndFill")]})})]})]})})]})},lu=["linkedin_profile","linkedin_profile_en"],ou={headline:"Headline",about:"Om mig",services:"Services",experience:"Erfaring",education:"Uddannelse",licenses:"Licenser & certificeringer",volunteering:"Frivilligt arbejde",skills:"Færdigheder",languages:"Sprog",keywords:"Vigtige keywords",openToWork:"Open to work",visibility:"Synlighedstips"},cu={headline:"Headline",about:"About",services:"Services",experience:"Experience",education:"Education",licenses:"Licenses & certifications",volunteering:"Volunteering",skills:"Skills",languages:"Languages",keywords:"Important keywords",openToWork:"Open to work",visibility:"Visibility tips"},to=(s,a)=>(js(a)?cu:ou)[s]||s,dl=(s,a)=>
98{if(!s)return{version:2,sections:[]};try{const t=JSON.parse(s);if(t&&t.version===2&&Array.isArray(t.sections))return t}catch{}return{version:2,sections:[{key:"legacy",title:js(a)?"Content":"Indhold",content:s}]}},Bn=s=>JSON.stringify({version:2,sections:s}),du=(s,a)=>{var m,c,l,f,p,j,g,P,N,w,S,A;const t=js(a),r=y=>to(y,a),n=[];if((m=s.headline)!=null&&m.suggestion&&n.push({key:"headline",title:r("headline"),content:String(s.headline.suggestion).trim()}),(c=s.about)!=null&&c.suggestion&&n.push({key:"about",title:r("about"),content:String(s.about.suggestion).trim()}),(l=s.services)!=null&&l.suggestion&&n.push({key:"services",title:r("services"),content:String(s.services.suggestion).trim()}),Array.isArray(s.experienceDescriptions)&&s.experienceDescriptions.length){const y=s.experienceDescriptions.map(D=>{const Y=[[[D.title,D.company].filter(Boolean).join(" — "),D.years].filter(Boolean).join("  ·  ")];if(D.companyDescription&&Y.push(String(D.companyDescription).trim()),Array.isArray(D.bullets)&&D.bullets.length)for(const R of D.bullets){const Q=String(R||"").trim().replace(/^[-•]\s*/,"");Q&&Y.push(`- ${Q}`)}else D.description&&Y.push(String(D.description).trim());return Y.filter(Boolean).join(`
99`)}).join(`
100
101`);y.trim()&&n.push({key:"experience",title:r("experience"),content:y})}if(Array.isArray(s.education)&&s.education.length){const y=s.education.map(D=>[[D.degree,D.institution].filter(Boolean).join(" — "),D.description].filter(Boolean).join(`
102`)).join(`
103
104`);y.trim()&&n.push({key:"education",title:r("education"),content:y})}if(Array.isArray(s.licensesCertifications)&&s.licensesCertifications.length){const y=s.licensesCertifications.map(D=>[[D.name,D.issuer].filter(Boolean).join(" — "),D.description].filter(Boolean).join(`
105`)).join(`
106
107`);y.trim()&&n.push({key:"licenses",title:r("licenses"),content:y})}if(Array.isArray(s.volunteering)&&s.volunteering.length){const y=s.volunteering.map(D=>[[D.role,D.organization].filter(Boolean).join(" — "),D.description].filter(Boolean).join(`
108`)).join(`
109
110`);y.trim()&&n.push({key:"volunteering",title:r("volunteering"),content:y})}if(s.skills){const y=[];(f=s.skills.topSkills)!=null&&f.length&&y.push(`${t?"Top skills":"Topkompetencer"}: ${s.skills.topSkills.join(", ")}`),(p=s.skills.technicalSkills)!=null&&p.length&&y.push(`${t?"Technical":"Tekniske"}: ${s.skills.technicalSkills.join(", ")}`),(j=s.skills.softSkills)!=null&&j.length&&y.push(`${t?"Soft skills":"Personlige"}: ${s.skills.softSkills.join(", ")}`),y.length&&n.push({key:"skills",title:r("skills"),content:y.join(`
111`)})}if(Array.isArray(s.languages)&&s.languages.length){const y=s.languages.map(D=>[D.language,D.proficiency].filter(Boolean).join(" — ")).filter(Boolean).join(`
112`);y.trim()&&n.push({key:"languages",title:r("languages"),content:y})}const d=(g=s.importantKeywords)!=null&&g.length?s.importantKeywords:((P=s.searchOptimization)==null?void 0:P.primaryKeywords)||[];if(d.length&&n.push({key:"keywords",title:r("keywords"),content:d.join(", ")}),(N=s.openToWork)!=null&&N.suggestion||(w=s.openToWork)!=null&&w.recruitersOnly||(S=s.openToWork)!=null&&S.publicRing||(A=s.openToWork)!=null&&A.advice){const y=s.openToWork,D=[];y.suggestion&&D.push(String(y.suggestion).trim()),y.recruitersOnly&&D.push(`${t?"Visible to recruiters only":"Kun synlig for recruiters"}:
113${String(y.recruitersOnly).trim()}`),y.publicRing&&D.push(`${t?"Public #OpenToWork ring":"Den grønne #OpenToWork-ring (synlig for alle)"}:
114${String(y.publicRing).trim()}`),y.advice&&D.push(`${t?"Our advice for you":"Vores anbefaling til dig"}:
115${String(y.advice).trim()}`),n.push({key:"openToWork",title:r("openToWork"),content:D.join(`
116
117`)})}if(Array.isArray(s.visibilityTips)&&s.visibilityTips.length){const y=s.visibilityTips.slice(0,6).map((D,B)=>{const M=D.category?`${D.category}: `:"",Y=D.impact?` [${D.impact}]`:"";return`${B+1}. ${M}${D.tip||""}${Y}`.trim()});n.push({key:"visibility",title:r("visibility"),content:y.join(`
118`)})}return n},mu=()=>{var x;const{t:s,i18n:a}=Je(),t=Te(a.language)?ir:Sn,r=Te(a.language)?"":`_${a.language}`,n=z=>`${z}${r}`,{documents:d,getDocumentByType:m,saveDocument:c,deleteDocument:l,renameDocument:f}=Xa(),[p,j]=i.useState(!1),[g,P]=i.useState(null),[N,w]=i.useState([]),[S,A]=i.useState(""),[y,D]=i.useState(null),[B,M]=i.useState(!1),[Y,R]=i.useState(!1),[Q,k]=i.useState(""),[$,K]=i.useState(!1),[re,ve]=i.useState(null),[ze,xe]=i.useState(!1),[I,E]=i.useState(""),[F,O]=i.useState(!1),[ee,Le]=i.useState(""),[pe,Oe]=i.useState(!1),he=i.useMemo(()=>d.filter(z=>lu.includes(z.document_type)||z.document_type.startsWith("linkedin_profile")),[d]);i.useEffect(()=>{var z;if(!g&&he.length>0){const b=m(n("linkedin_profile"))||he[0];P(b.id)}g&&!he.find(b=>b.id===g)&&P(((z=he[0])==null?void 0:z.id)??null)},[he,g]);const we=i.useMemo(()=>he.find(z=>z.id===g)||null,[he,g]);i.useEffect(()=>{if(we){const z=dl(we.content,a.language);w(z.sections),A(Bn(z.sections)),D(null)}},[we==null?void 0:we.id]);const T=i.useMemo(()=>Bn(N),[N]),ae=!!we&&T!==S,me=(z,b)=>{w(U=>U.map(te=>te.key===z?{...te,content:b}:te))},Ae=async()=>{j(!0);try{const{data:{session:z}}=await C.auth.getSession();if(!z)return;const b=async U=>{const te=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/generate-linkedin-profile",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z.access_token}`},body:JSON.stringify({language:U})});if(!te.ok)throw new Error("Kunne ikke generere LinkedIn-profil");const fe=await te.json(),Se=U==="da"?"linkedin_profile":`linkedin_profile_${U}`,G=du(fe.linkedinProfile,U),Fe=Bn(G);await c(Se,s("careerDocs.linkedInProfileTitle"),Fe)};await Promise.all([b("en"),b("da")]),J.success(s("careerDocs.linkedInSuggestionSaved"))}catch(z){console.error("Error generating LinkedIn profile:",z),J.error(s("common.error",{defaultValue:"Der opstod en fejl"}))}finally{j(!1)}},oe=z=>z.endsWith("_en")?{sibling:z.replace(/_en$/,""),sourceLang:"en",targetLang:"da"}:{sibling:`${z}_en`,sourceLang:"da",targetLang:"en"},Ve=async(z,b,U)=>{try{const{sibling:te,sourceLang:fe,targetLang:Se}=oe(z.document_type),{data:{session:G}}=await C.auth.getSession();if(!G)return;const Fe=dl(b,fe).sections,Ee=[];for(const Ze of Fe){const Us=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/translate-document",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${G.access_token}`},body:JSON.stringify({content:Ze.content,sourceLanguage:fe,targetLanguage:Se,documentType:"linkedin_profile"})}),le=await Us.json();Ee.push({key:Ze.key,title:to(Ze.key,Se),content:Us.ok&&le.translatedContent?le.translatedContent:Ze.content})}
118const qe=Bn(Ee),Ge=he.find(Ze=>Ze.document_type===te&&Ze.title===z.title),{data:{user:He}}=await C.auth.getUser();if(!He)return;Ge?await C.from("career_documents").update({title:U,content:qe}).eq("id",Ge.id):await C.from("career_documents").insert({user_id:He.id,document_type:te,title:U,content:qe});try{window.dispatchEvent(new Event("career-documents-changed"))}catch{}}catch(te){console.warn("[LinkedIn auto-translate] error",te)}},Xe=async()=>{if(!we)return;M(!0);const z=we.title;await c(we.document_type,z,T,void 0,we.id)&&(J.success(s("careerDocs.documentUpdated")),A(T),D(null),J.message(s("careerDocs.translatingSibling",{defaultValue:"Synkroniserer den anden sprogversion…"})),await Ve(we,T,z),J.success(s("careerDocs.siblingSynced",{defaultValue:"Begge sprogversioner er opdateret"}))),M(!1)},cs=async()=>{if(!we)return;const z=we.document_type,b=I.trim()||`${we.title} (kopi)`;M(!0);const{data:{user:U}}=await C.auth.getUser();if(!U){M(!1);return}const{error:te}=await C.from("career_documents").insert({user_id:U.id,document_type:z,title:b,content:T});if(te){M(!1),J.error(s("common.error",{defaultValue:"Der opstod en fejl"}));return}try{window.dispatchEvent(new Event("career-documents-changed"))}catch{}J.success(s("jobStrategy.newPlanSaved",{defaultValue:"Nyt oplæg gemt"})),J.message(s("careerDocs.translatingSibling",{defaultValue:"Opretter den anden sprogversion…"})),await Ve({...we,title:b},T,b),J.success(s("careerDocs.siblingSynced",{defaultValue:"Begge sprogversioner er oprettet"})),M(!1),xe(!1),E("")},hs=z=>{ve(z),k(""),R(!0)},ps=async()=>{if(!we||!Q.trim()||!re)return;const z=N.find(b=>b.key===re);if(z){K(!0);try{const{data:{session:b}}=await C.auth.getSession();if(!b)throw new Error("not auth");const U=we.document_type.endsWith("_en")||js(a.language),te=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/edit-document-with-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.access_token}`},body:JSON.stringify({content:z.content,instructions:`Sektion: "${z.title}". ${Q}`,documentType:"linkedin",language:U?"en":"da"})}),fe=await te.json();if(!te.ok||!fe.editedContent)throw new Error(fe.error||"AI fejl");me(re,fe.editedContent),R(!1),k(""),ve(null),J.success(s("careerDocs.documentUpdatedWithAI",{defaultValue:"AI-redigering gennemført"}))}catch(b){console.error(b),J.error((b==null?void 0:b.message)||s("common.error",{defaultValue:"Der opstod en fejl"}))}finally{K(!1)}}},ms=async()=>{if(!we||!ee.trim())return;await f(we.id,ee.trim())&&O(!1)},De=async()=>{if(!we)return;await l(we.id)&&(Oe(!1),P(null))},_=z=>z.document_type.endsWith("_en")?"🇬🇧":"🇩🇰",Z=z=>{navigator.clipboard.writeText(bt(z.content)).then(()=>J.success(s("careerDocs.copied",{defaultValue:"Kopieret"})))},H=()=>{const z=N.map(b=>`${b.title}
119${bt(b.content)}`).join(`
120
121`);navigator.clipboard.writeText(z).then(()=>J.success(s("careerDocs.copied",{defaultValue:"Kopieret"})))},ne=he.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:s("careerDocs.documentsCount",{count:he.length})})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:he.map(z=>e.jsxs("button",{type:"button",onClick:()=>P(z.id),className:`px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${g===z.id?"bg-primary text-primary-foreground border-primary":"bg-background text-foreground border-border hover:bg-muted"}`,children:[e.jsx("span",{className:"mr-1",children:_(z)}),z.title]},z.id))}),we&&e.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4 bg-muted/20",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm",children:_(we)}),e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:we.title}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:["· ",_s(new Date(we.updated_at),"d. MMM yyyy",{locale:t})]}),ae&&e.jsxs(je,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Ma,{className:"w-3 h-3"}),s("jobStrategy.unsavedChanges",{defaultValue:"Ugemte ændringer"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-8 text-xs",onClick:H,children:[e.jsx(Lt,{className:"w-3 h-3"})," ",s("careerDocs.copy",{defaultValue:"Kopiér alt"})]}),e.jsx(h,{size:"sm",variant:"ghost",className:"gap-1 h-8 text-xs",onClick:()=>{Le(we.title),O(!0)},children:s("hooks.renamed",{defaultValue:"Omdøb"})}),e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-8 text-xs text-destructive hover:text-destructive",onClick:()=>Oe(!0),children:[e.jsx(Ss,{className:"w-3 h-3"}),s("careerDocs.delete")]})]})]}),N.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:s("careerDocs.noContent",{defaultValue:"Intet indhold endnu — generer et nyt oplæg."})}):e.jsx("div",{className:"space-y-3",children:N.map(z=>{const b=y===z.key;return e.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsx("h5",{className:"text-sm font-semibold text-foreground",children:z.title}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-7 text-xs",onClick:()=>D(b?null:z.key),children:[e.jsx(Ma,{className:"w-3 h-3"}),b?s("careerDocs.close",{defaultValue:"Luk"}):s("careerDocs.edit",{defaultValue:"Rediger"})]}),e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-7 text-xs",onClick:()=>hs(z.key),children:[e.jsx(xs,{className:"w-3 h-3"}),s("careerDocs.editWithAI",{defaultValue:"AI"})]}),e.jsx(h,{size:"sm",variant:"ghost",className:"gap-1 h-7 text-xs",onClick:()=>Z(z),children:e.jsx(Lt,{className:"w-3 h-3"})})]})]}),b?e.jsx(as,{value:z.content,onChange:U=>me(z.key,U.target.value),className:"min-h-[140px] text-sm"}):e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:bt(z.content)})]},z.key)})}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-end pt-2 border-t border-border/60",children:[e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>{E(`${we.title} (kopi)`),xe(!0)},children:[e.jsx(Zi,{className:"w-4 h-4"}),s("careerDocs.saveAsNewOplaeg",{defaultValue:"Gem som nyt oplæg"})]}),e.jsxs(h,{size:"sm",className:"gap-2",disabled:!ae||B,onClick:Xe,children:[B?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(zs,{className:"w-4 h-4"}),s("careerDocs.saveChanges",{defaultValue:"Gem ændringer"})]})]})]})]}):null;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:s("sidebar.linkedinProfile")}),e.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto mt-1",children:s("sidebar.linkedinProfileDesc")})]}),e.jsx(ye,{className:"p-5",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 roun
121ded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Ms,{className:"w-7 h-7 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:s("careerDocs.linkedInProfileTitle")}),p?e.jsxs(je,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20 gap-1",children:[e.jsx(ge,{className:"w-3 h-3 animate-spin"}),s("careerDocs.generating")]}):he.length>0?e.jsxs(je,{className:"bg-green-500/10 text-green-600 border-green-500/20 gap-1",children:[e.jsx($s,{className:"w-3 h-3"}),he.length," ",s("careerDocs.documentsCount",{count:he.length,defaultValue:"oplæg"})]}):null]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line",children:s("careerDocs.linkedInProfileDescription")})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:p,onClick:Ae,children:[p?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4"}),s("careerDocs.generateNewSuggestion")]})})]})}),e.jsx(Il,{context:"linkedin"}),e.jsx(iu,{children:ne}),e.jsx(ns,{open:Y,onOpenChange:R,children:e.jsxs(rs,{children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(xs,{className:"w-4 h-4 text-primary"}),s("careerDocs.editWithAI"),re&&e.jsxs("span",{className:"text-sm text-muted-foreground font-normal",children:["· ",(x=N.find(z=>z.key===re))==null?void 0:x.title]})]}),e.jsx(Qs,{children:s("careerDocs.aiEditLabel")})]}),e.jsx(as,{value:Q,onChange:z=>k(z.target.value),placeholder:s("careerDocs.aiEditPlaceholder"),className:"min-h-[120px]"}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"ghost",onClick:()=>R(!1),disabled:$,children:s("careerDocs.cancel")}),e.jsxs(h,{onClick:ps,disabled:$||!Q.trim(),className:"gap-2",children:[$?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(xs,{className:"w-4 h-4"}),s($?"careerDocs.aiEditing":"careerDocs.runAIEdit")]})]})]})}),e.jsx(ns,{open:ze,onOpenChange:xe,children:e.jsxs(rs,{children:[e.jsxs(os,{children:[e.jsx(is,{children:s("careerDocs.saveAsNewOplaeg",{defaultValue:"Gem som nyt oplæg"})}),e.jsx(Qs,{children:s("jobStrategy.saveAsNew",{defaultValue:"Giv det nye oplæg en titel"})})]}),e.jsx(ue,{value:I,onChange:z=>E(z.target.value),placeholder:s("careerDocs.linkedInProfileTitle")}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"ghost",onClick:()=>xe(!1),disabled:B,children:s("careerDocs.cancel")}),e.jsxs(h,{onClick:cs,disabled:B||!I.trim(),className:"gap-2",children:[B?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(Zi,{className:"w-4 h-4"}),s("careerDocs.saveAsNewOplaeg",{defaultValue:"Gem som nyt oplæg"})]})]})]})}),e.jsx(ns,{open:F,onOpenChange:O,children:e.jsxs(rs,{children:[e.jsx(os,{children:e.jsx(is,{children:s("hooks.renamed",{defaultValue:"Omdøb"})})}),e.jsx(ue,{value:ee,onChange:z=>Le(z.target.value)}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"ghost",onClick:()=>O(!1),children:s("careerDocs.cancel")}),e.jsx(h,{onClick:ms,disabled:!ee.trim(),children:s("careerDocs.saveChanges",{defaultValue:"Gem"})})]})]})}),e.jsx(ns,{open:pe,onOpenChange:Oe,children:e.jsxs(rs,{children:[e.jsxs(os,{children:[e.jsx(is,{children:s("careerDocs.deleteDocTitle")}),e.jsx(Qs,{children:s("careerDocs.deleteDocDescription",{title:(we==null?void 0:we.title)||""})})]}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"ghost",onClick:()=>Oe(!1),children:s("careerDocs.cancel")}),e.jsxs(h,{variant:"destructive",onClick:De,className:"gap-2",children:[e.jsx(Ss,{className:"w-4 h-4"}),s("careerDocs.delete")]})]})]})})]})},uu={D:"bg-red-500",I:"bg-yellow-500",S:"bg-green-500",C:"bg-blue-500"},ao=({open:s=!0,onOpenChange:a,embedded:t=!1})=>{var V,W,be,Me,Be,ss,$e,es,bs,Xs,Ks;const{t:r,i18n:n}=Je(),[d,m]=i.useState(""),[c,l]=i.useState(""),[f,p]=i.useState(""),[j,g]=i.useState([]),[P,N]=i.useState(!1),[w,S]=i.useState(!1),[A,y]=i.useState(!1),[D,B]=i.useState(null),[M,Y]=i.useState("saved"),[R,Q]=i.useState(null),[k,$]=i.useState(null),[K,re]=i.useState(!1),[ve,ze]=i.useState(!1),[xe,I]=i.useState(null),[E,F]=i.useState([]),[O,ee]=i.useState(null),[Le,pe]=i.useState(""),[Oe,he]=i.useState(""),[we,T]=i.useState([]),[ae,me]=i.useState([]),[Ae,oe]=i.useState(!1),[Ve,Xe]=i.useState(!1),[cs,hs]=i.useState([]),ps=i.useRef(null),{getPrimaryAnalysis:ms}=Jr(),{cvs:De}=lr(),{saveDocument:_,getDocumentsByType:Z,deleteDocument:H,refetch:ne}=Xa(),x=ms(),z=De.find(q=>q.is_primary)||De[0],b=Z("cv"),U=b.length>0?[...b].sort((q,Ce)=>new Date(Ce.updated_at||Ce.created_at).getTime()-new Date(q.updated_at||q.created_at).getTime())[0]:null,te=!!z||!!U,fe=Z("interview_preparation"),Se=fe.filter(q=>{var Ie,ds;let Ce=null;try{Ce=JSON.parse(q.content)}catch{return!1}if(O&&!((Ie=Ce==null?void 0:Ce.tags)!=null&&Ie.includes(O)))return!1;if(Le.trim()){const Ns=Le.toLowerCase(),Ds=q.title.toLowerCase().includes(Ns),_t=(ds=Ce==null?void 0:Ce.jobDescription)==null?void 0:ds.toLowerCase().includes(Ns);if(!Ds&&!_t)return!1}return!0}),G=[...new Set(fe.flatMap(q=>{try{return JSON.parse(q.content).tags||[]}catch{return[]}}))];i.useEffect(()=>{if(!s)return;(async()=>{const{data:{user:Ce}}=await C.auth.getUser();if(!Ce)return;const{data:Ie}=await C.from("profiles").select("linkedin_url").eq("id",Ce.id).maybeSingle();if(Ie!=null&&Ie.linkedin_url&&$(Ie.linkedin_url),z){re(!0);try{const{data:ds}=await C.storage.from("cvs").createSignedUrl(z.file_path,60);if(ds!=null&&ds.signedUrl){const{data:Ns}=await C.functions.invoke("extract-profile-data",{body:{language:n.language,cvUrl:ds.signedUrl,fileName:z.file_name}});Ns!=null&&Ns.extractedText&&Q(Ns.extractedText)}}catch(ds){console.error("Error fetching CV text:",ds)}finally{re(!1)}}else U!=null&&U.content&&Q(U.content)})()},[z,U==null?void 0:U.id,s]);const Fe=_c.useReactToPrint({contentRef:ps,documentTitle:r("interviewPrep.documentTitle")}),Ee=()=>{g(q=>[...q,{id:crypto.randomUUID(),linkedinUrl:"",profileText:"",name:"",title:""}])},qe=(q,Ce,Ie)=>{g(ds=>ds.map(Ns=>Ns.id===q?{...Ns,[Ce]:Ie}:Ns))},Ge=q=>{g(Ce=>Ce.filter(Ie=>Ie.id!==q))},He=async()=>{var Ns;const q=x==null?void 0:x.big5_results;if(!q){J.error(r("interviewPrep.devQuestionsNoProfile"));return}const Ce=q.traits||q.big5_estimates||q,Ie=Ds=>{const _t=Number(Ds);return Number.isFinite(_t)?_t>5?_t/20:_t:null},ds={openness:Ie(Ce.openness),conscientiousness:Ie(Ce.conscientiousness),extraversion:Ie(Ce.extraversion),agreeableness:Ie(Ce.agreeableness),neuroticism:Ie(Ce.neuroticism)};if(Object.values(ds).some(Ds=>Ds===null)){J.error(r("interviewPrep.devQuestionsNoProfile"));return}oe(!0);try{const{data:Ds,error:_t}=await C.functions.invoke("generate-interview-questions",{body:{language:n.language,big5Scores:ds,jobFunction:(x==null?void 0:x.job_function)||void 0,positionLevel:(x==null?void 0:x.position_level)||void 0,jobAdText:c||void 0,jobDescription:d||void 0,jobAdLink:f||void 0}});if(_t)throw _t;if(Ds!=null&&Ds.error)throw new Error(Ds.error);T(Ds.questions||[]),me(Ds.gaps||[]),Xe(!0),(Ns=Ds.questions)!=null&&Ns.length?J.success(r("interviewPrep.prepGenerated")):J.info(r("interviewPrep.devQuestionsNoGaps"))}catch(Ds){console.error("Error generating dev questions:",Ds),J.error(r("interviewPrep.devQuestionsError"))}finally{oe(!1)}},Ze=q=>{hs(Ce=>Ce.includes(q)?Ce.filter(Ie=>Ie!==q):[...Ce,q])},Us=async()=>{var q;if(D){S(!0);try{const Ce=((q=d.split(`
122`)[0])==null?void 0:q.slice(0,50))||r("interviewPrep.defaultTitle"),Ie=JSON.stringify({analysis:D,jobDescription:d,jobAdText:c,jobAdLink:f,createdAt:new Date().toISOString(),tags:E,interviewers:j,developmentQuestions:we.length>0?we:void 0});await _("interview_preparation",`Interview: ${Ce}`,Ie)?(y(!0),I(null),ze(!1),J.success(r("interviewPrep.prepSaved")),setTimeout(()=>y(!1),3e3)):J.error(r("interviewPrep.saveError"))}catch(Ce){console.error("Error saving:",Ce),J.error(r("interviewPrep.saveError"))}finally{S(!1)}}},le=async()=>{var q,Ce,Ie;if(!d.trim()&&!c.trim()&&!f.trim()){J.error(r("interviewPrep.fillAtLeastOne"));return}N(!0),y(!1);try{const ds=x==null?void 0:x.big5_results;let Ns=null;if(ds){const Cs=ds.traits||ds.big5_estimates||ds,Wt=Za=>{const xa=Number(Za);return Number.isFinite(xa)?xa>5?xa/20:xa:null},Sa={openness:Wt(Cs.openness),conscientiousness:Wt(Cs.conscientiousness),extraversion:Wt(Cs.extraversion),agreeableness:Wt(Cs.agreeableness),neuroticism:Wt(Cs.neuroticism)};Object.values(Sa).some(Za=>Za===null)||(Ns=Sa)}const Ds=C.functions.invoke("prepare-interview",{body:{language:n.language,jobDescription:d.trim(),jobAdText:c.trim(),jobAdLink:f.trim(),personalityAnalysis:x?{big5Results:x.big5_results,jobFunction:x.job_function,positionLevel:x.position_level}:null,cvText:R||null,linkedinText:k||null,interviewers:j.filter(Cs=>Cs.profileText.trim()||Cs.name.trim()).map(Cs=>({linkedinUrl:"",profileText:Cs.profileText,name:Cs.name,title:Cs.title}))}}),_t=Ns?C.functions.invoke("generate-interview-questions",{body:{language:n.language,big5Scores:Ns,jobFunction:(x==null?void 0:x.job_function)||void 0,positionLevel:(x==null?void 0:x.position_level)||void 0,jobAdText:c||void 0,jobDescription:d||void 0,jobAdLink:f||void 0}}):Promise.resolve({data:null,error:null}),[Ra,Es]=await Promise.all([Ds,_t]);if(Ra.error)throw Ra.error;const In=Ra.data;B(In),Y("results"),J.success(r("interviewPrep.prepGenerated"));let _a=[];Es&&!Es.error&&Es.data&&!Es.data.error?(_a=Es.data.questions||[],T(_a),me(Es.data.gaps||[]),Xe(!0)):(Es!=null&&Es.error||(q=Es==null?void 0:Es.data)!=null&&q.error)&&console.error("Dev questions generation failed:",Es.error||((Ce=Es.data)==null?void 0:Ce.error));try{const Cs=((Ie=d.split(`
123`)[0])==null?void 0:Ie.slice(0,50))||r("interviewPrep.defaultTitle"),Wt=JSON.stringify({analysis:In,jobDescription:d,jobAdText:c,jobAdLink:f,createdAt:new Date().toISOString(),tags:E,interviewers:j,developmentQuestions:_a.length>0?_a:void 0});await _("interview_preparation",`Interview: ${Cs}`,Wt)&&(y(!0),await ne())}catch(Cs){console.error("Auto-save failed:",Cs)}}catch(ds){console.error("Error preparing interview:",ds),J.error(r("interviewPrep.analyzeError"))}finally{N(!1)}},X=q=>{var Ce;try{const Ie=JSON.parse(q.content);
123B(Ie.analysis),m(Ie.jobDescription||""),l(Ie.jobAdText||""),p(Ie.jobAdLink||""),F(Ie.tags||[]),g(Ie.interviewers||[]),T(Ie.developmentQuestions||[]),Xe(!!((Ce=Ie.developmentQuestions)!=null&&Ce.length)),me([]),I(q.id),ze(!0),Y("results")}catch{J.error(r("interviewPrep.loadError"))}},L=async q=>{await H(q)&&xe===q&&Os()},ce=q=>{F(Ce=>Ce.includes(q)?Ce.filter(Ie=>Ie!==q):[...Ce,q]),y(!1)},ys=()=>{const q=Oe.trim();q&&!E.includes(q)&&(F(Ce=>[...Ce,q]),he(""))},Hs=q=>{F(Ce=>Ce.filter(Ie=>Ie!==q))},Os=()=>{m(""),l(""),p(""),B(null),Y("saved"),y(!1),ze(!1),I(null),F([]),pe(""),he(""),g([]),T([]),me([]),Xe(!1),hs([])},Ls=()=>{const q=r("demo.interviewFull",{returnObjects:!0}),Ce=q.analysis;B(Ce),m(q.jobDescription),p(q.jobAdLink),g(q.interviewers),F(q.tags),Y("results")},Bs=()=>{m(""),l(""),p(""),B(null),ze(!1),I(null),F([]),g([]),T([]),me([]),Xe(!1),hs([]),Y("input")};i.useEffect(()=>{if(s)ne();else{const q=setTimeout(Os,300);return()=>clearTimeout(q)}},[s]);const ie=q=>{try{return new Date(q).toLocaleDateString(r("common.locale"),{day:"numeric",month:"short",year:"numeric"})}catch{return""}},o=e.jsxs(e.Fragment,{children:[!t&&e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2 text-xl",children:[e.jsx(ht,{className:"w-5 h-5 text-primary"}),r("interviewPrep.dialogTitle")]}),e.jsx(Qs,{children:r("interviewPrep.dialogDescription")})]}),e.jsxs(Gr,{value:M,onValueChange:Y,className:"mt-4",children:[M==="results"&&e.jsx("div",{className:"mb-3",children:e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>Y("saved"),className:"gap-2",children:[e.jsx(Ts,{className:"w-4 h-4 rotate-90"}),r("interviewPrep.backToOverview",{defaultValue:"Tilbage til oversigt"})]})}),e.jsxs(qr,{className:"grid w-full grid-cols-3",children:[e.jsxs(za,{value:"saved",children:[e.jsx(wn,{className:"w-4 h-4 mr-2"}),r("interviewPrep.savedTab")," (",Se.length,")"]}),e.jsxs(za,{value:"input",disabled:P,children:[e.jsx(Fs,{className:"w-4 h-4 mr-2"}),r("interviewPrep.newPreparation")]}),e.jsxs(za,{value:"results",disabled:!D,children:[e.jsx(xs,{className:"w-4 h-4 mr-2"}),r("interviewPrep.result")]})]}),e.jsx(Oa,{value:"saved",className:"mt-4",children:e.jsxs(Wn,{className:"h-[60vh] pr-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-4",children:[e.jsxs(h,{onClick:Bs,className:"gap-2",children:[e.jsx(fs,{className:"w-4 h-4"}),r("interviewPrep.createNew2")]}),e.jsxs(h,{variant:"outline",onClick:Ls,className:"gap-2",children:[e.jsx(xs,{className:"w-4 h-4"}),r("interviewPrep.seeExample")]})]}),e.jsxs("div",{className:"mb-4 relative",children:[e.jsx(Ut,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ue,{placeholder:r("interviewPrep.searchPlaceholder"),value:Le,onChange:q=>pe(q.target.value),className:"pl-9"})]}),G.length>0&&e.jsxs("div",{className:"mb-4 flex gap-2 flex-wrap",children:[e.jsx(je,{variant:O===null?"default":"outline",className:"cursor-pointer",onClick:()=>ee(null),children:r("interviewPrep.all")}),G.map(q=>e.jsx(je,{variant:O===q?"default":"outline",className:"cursor-pointer",onClick:()=>ee(O===q?null:q),children:q},q))]}),Se.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(wn,{className:"w-12 h-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:r("interviewPrep.noSaved")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:r("interviewPrep.noSavedDescription")}),e.jsxs(h,{onClick:Bs,children:[e.jsx(fs,{className:"w-4 h-4 mr-2"}),r("interviewPrep.createNew")]})]}):e.jsx("div",{className:"space-y-4",children:Se.map(q=>{let Ce=null;try{Ce=JSON.parse(q.content)}catch{}return e.jsx(ye,{className:"p-4 hover:bg-muted/50 transition-colors cursor-pointer",onClick:()=>X(q),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium truncate",children:q.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-muted-foreground",children:[e.jsx(gt,{className:"w-3 h-3"}),e.jsx("span",{children:ie((Ce==null?void 0:Ce.createdAt)||q.created_at)})]}),(Ce==null?void 0:Ce.tags)&&Ce.tags.length>0&&e.jsx("div",{className:"flex gap-1 mt-2 flex-wrap",children:Ce.tags.map(Ie=>e.jsxs(je,{variant:"secondary",className:"text-xs",children:[e.jsx(sl,{className:"w-2.5 h-2.5 mr-1"}),Ie]}
123,Ie))})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:Ie=>{Ie.stopPropagation(),X(q)},children:e.jsx(Qa,{className:"w-4 h-4"})}),e.jsx(h,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:Ie=>{Ie.stopPropagation(),L(q.id)},children:e.jsx(Ss,{className:"w-4 h-4"})})]})]})},q.id)})})]})}),e.jsx(Oa,{value:"input",className:"mt-4",children:e.jsx(Wn,{className:"h-[60vh] pr-4",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ye,{className:"p-4 bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:[e.jsxs("h4",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(Ca,{className:"w-4 h-4 text-primary"}),r("interviewPrep.profileBasis")]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(je,{variant:x?"default":"secondary",className:"flex items-center gap-1",children:[e.jsx(ja,{className:"w-3 h-3"}),r(x?"interviewPrep.personalityAnalysis":"interviewPrep.noPersonalityAnalysis")]}),e.jsxs(je,{variant:te?"default":"secondary",className:"flex items-center gap-1",children:[e.jsx(Fs,{className:"w-3 h-3"}),K?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-3 h-3 animate-spin"}),r("interviewPrep.fetchingCV")]}):r(R?"interviewPrep.cvReady":te?"interviewPrep.cvUploaded":"interviewPrep.noCV")]}),e.jsxs(je,{variant:k?"default":"secondary",className:"flex items-center gap-1",children:[e.jsx(Ms,{className:"w-3 h-3"}),r(k?"interviewPrep.linkedInReady":"interviewPrep.noLinkedIn")]})]}),!x&&!z&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:r("interviewPrep.uploadForBetter")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(se,{htmlFor:"jobAdLink",className:"flex items-center gap-2",children:[e.jsx(Tl,{className:"w-4 h-4"}),r("interviewPrep.jobAdLink")]}),e.jsx(ue,{id:"jobAdLink",placeholder:"https://...",value:f,onChange:q=>p(q.target.value),type:"url"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(se,{htmlFor:"jobAdText",className:"flex items-center gap-2",children:[e.jsx(Fs,{className:"w-4 h-4"}),r("interviewPrep.jobAdTextLabel")]}),e.jsx(as,{id:"jobAdText",placeholder:r("interviewPrep.jobAdTextPlaceholder"),value:c,onChange:q=>l(q.target.value),className:"min-h-[120px]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(se,{htmlFor:"jobDescription",className:"flex items-center gap-2",children:[e.jsx(ht,{className:"w-4 h-4"}),r("interviewPrep.additionalNotes")]}),e.jsx(as,{id:"jobDescription",placeholder:r("interviewPrep.additionalNotesPlaceholder"),value:d,onChange:q=>m(q.target.value),className:"min-h-[80px]"})]}),e.jsxs(ye,{className:"p-4 border-dashed",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs(se,{className:"flex items-center gap-2 font-semibold",children:[e.jsx(tt,{className:"w-4 h-4"}),r("interviewPrep.interviewersOptional")]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:Ee,className:"gap-1",children:[e.jsx(fs,{className:"w-3 h-3"}),r("interviewPrep.add")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("interviewPrep.interviewersDescription")}),j.length===0?e.jsxs(h,{variant:"ghost",onClick:Ee,className:"w-full border border-dashed text-muted-foreground hover:text-foreground gap-2",children:[e.jsx(Hi,{className:"w-4 h-4"}),r("interviewPrep.addFirstInterviewer")]}):e.jsx("div",{className:"space-y-3",children:j.map((q,Ce)=>e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:[r("interviewPrep.person")," ",Ce+1]}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>Ge(q.id),children:e.jsx(mt,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[e.jsx(ue,{placeholder:r("interviewPrep.name"),value:q.name,onChange:Ie=>qe(q.id,"name",Ie.target.value)}),e.jsx(ue,{placeholder:r("interviewPrep.titlePlaceholder"),value:q.title,onChange:Ie=>qe(q.id,"title",Ie.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"w-4 h-4 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:r("interviewPrep.linkedinProfileData")})]}),e.jsx(as,{placeholder:r("interviewPrep.profileTextPlaceholder"),value:q.profileText,onChange:Ie=>qe(q.id,"profileText",Ie.target.value),rows:3,className:"resize-none text-sm"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",className:"gap-1.5 text-xs",onClick:()=>{var Ie;
123return(Ie=document.getElementById(`interviewer-pdf-${q.id}`))==null?void 0:Ie.click()},children:[e.jsx(nr,{className:"w-3 h-3"}),r("interviewPrep.uploadLinkedinPdf")]}),e.jsx("input",{id:`interviewer-pdf-${q.id}`,type:"file",accept:".pdf,.txt",className:"hidden",onChange:async Ie=>{var Ns;const ds=(Ns=Ie.target.files)==null?void 0:Ns[0];if(ds){try{const Ds=await ds.text();Ds.length>20?(qe(q.id,"profileText",Ds),J.success(r("interviewPrep.profileImported"))):J.error(r("interviewPrep.cannotReadFile"))}catch{J.error(r("interviewPrep.cannotReadFile"))}Ie.target.value=""}}})]}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx(cn,{className:"w-3 h-3 shrink-0 mt-0.5"}),r("interviewPrep.linkedinPrivacyNote")]})]})]},q.id))})]}),e.jsx(h,{onClick:le,disabled:P||!d.trim()&&!c.trim()&&!f.trim(),className:"w-full",size:"lg",children:P?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),r("interviewPrep.analyzing")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-4 h-4 mr-2"}),r("interviewPrep.generatePrep")]})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center flex items-center justify-center gap-1.5",children:[e.jsx(zs,{className:"w-3 h-3"}),r("interviewPrep.autoSaveNotice")]})]})})}),e.jsx(Oa,{value:"results",className:"mt-4",children:e.jsx(Wn,{className:"h-[60vh] pr-4",children:D&&e.jsxs("div",{ref:ps,className:"space-y-6",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap items-center",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>Fe(),className:"gap-2",children:[e.jsx(Qt,{className:"w-4 h-4"}),r("interviewPrep.downloadPDF")]}),e.jsx(h,{variant:"outline",size:"sm",onClick:Us,disabled:w||A,className:"gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(dn,{className:"w-4 h-4 text-green-500"}),r("interviewPrep.savedSuccess")]}):w?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),r("interviewPrep.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{className:"w-4 h-4"}),r(ve?"interviewPrep.update":"interviewPrep.saveToProfile")]})})]}),e.jsxs(ye,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(sl,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-sm",children:r("interviewPrep.tagsOptional")})]}),E.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap mb-3",children:E.map(q=>e.jsxs(je,{variant:"default",className:"cursor-pointer",children:[q,e.jsx("button",{onClick:()=>Hs(q),className:"ml-1",children:e.jsx(mt,{className:"w-3 h-3"})})]},q))}),e.jsx("div",{className:"flex gap-2 flex-wrap mb-3",children:r("interviewPrep.availableTags",{returnObjects:!0}).filter(q=>!E.includes(q)).map(q=>e.jsxs(je,{variant:"outline",className:"cursor-pointer hover:bg-muted",onClick:()=>ce(q),children:[e.jsx(fs,{className:"w-2.5 h-2.5 mr-1"}),q]},q))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ue,{placeholder:r("interviewPrep.addCustomTag"),value:Oe,onChange:q=>he(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),ys())},className:"flex-1"}),e.jsx(h,{variant:"outline",size:"sm",onClick:ys,disabled:!Oe.trim(),children:r("interviewPrep.add")})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[(R||te)&&e.jsxs(je,{variant:"outline",className:"gap-1 text-green-600 border-green-500/30",children:[e.jsx(dn,{className:"w-3 h-3"}),r("interviewPrep.cvUsed")]}),x&&e.jsxs(je,{variant:"outline",className:"gap-1 text-green-600 border-green-500/30",children:[e.jsx(dn,{className:"w-3 h-3"}),r("interviewPrep.personalityUsed")]}),k&&e.jsxs(je,{variant:"outline",className:"gap-1 text-green-600 border-green-500/30",children:[e.jsx(dn,{className:"w-3 h-3"}),r("interviewPrep.linkedInUsed")]}),e.jsxs(ta,{children:[e.jsx(aa,{asChild:!0,children:e.jsx("button",{className:"w-6 h-6 rounded-full bg-muted flex items-center justify-center hover:bg-muted/80 transition-colors","aria-label":"Information om analysen",children:e.jsx(cn,{className:"w-4 h-4 text-muted-foreground"})})}),e.jsx(na,{className:"w-80 text-sm",side:"bottom",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(cn,{className:"w-4 h-4 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-foreground mb-1",children:r("interviewPrep.howGenerated")}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:r("interviewPrep.howGeneratedDescription")})]})]}),e.jsxs("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[e.jsx(va,{className:"w-4 h-4 text-amber-500 mt-0.5 shrink-0"}),e.jsxs("p",{className:"text-muted-foreground leading-relaxed",children:[e.jsx("span",{className:"font-medium text-foreground",children:r("interviewPrep.note")})," ",r("interviewPrep.discDisclaimer")]})]})]})})]})]}),D.interviewerProfiles&&D.interviewerProfiles.length>0&&e.jsx(Mt,{defaultOpen:!0,children:e.jsxs(ye,{className:"p-4",children:[e.jsxs($t,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"w-5 h-5 text-primary"}),e.jsxs("h3",{className:"font-semibold text-foreground",children:[r("interviewPrep.interviewerAnalysis")," (",D.interviewerProfiles.length,")"]})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]}
123),e.jsx(Rt,{children:e.jsx("div",{className:"space-y-4 mt-4",children:D.interviewerProfiles.map((q,Ce)=>e.jsxs(ye,{className:"p-4 bg-muted/30 border",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Hi,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-foreground",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.title}),q.linkedinUrl&&e.jsxs("a",{href:q.linkedinUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1 mt-1",children:[e.jsx(Ms,{className:"w-3 h-3"}),"LinkedIn"]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2 uppercase tracking-wide",children:r("interviewPrep.discProfile")}),e.jsx("div",{className:"space-y-2",children:["D","I","S","C"].map(Ie=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold w-20",children:r(`interviewPrep.discLabels.${Ie}`)}),e.jsx("div",{className:"flex-1 bg-muted rounded-full h-3 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${uu[Ie]} transition-all`,style:{width:`${q.discProfile[Ie]}%`}})}),e.jsx("span",{className:"text-xs font-medium w-8 text-right",children:q.discProfile[Ie]})]},Ie))}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsxs(je,{variant:"secondary",className:"text-xs",children:[r("interviewPrep.primary")," ",r(`interviewPrep.discLabels.${q.discProfile.primaryStyle}`,q.discProfile.primaryStyle)]}),q.discProfile.secondaryStyle&&e.jsxs(je,{variant:"outline",className:"text-xs",children:[r("interviewPrep.secondary")," ",r(`interviewPrep.discLabels.${q.discProfile.secondaryStyle}`,q.discProfile.secondaryStyle)]}),q.analysisConfidence&&e.jsx(je,{variant:q.analysisConfidence==="high"?"default":"outline",className:"text-xs",children:r(`interviewPrep.confidenceLabels.${q.analysisConfidence}`)})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"p-3 bg-blue-500/5 border border-blue-500/20 rounded-lg",children:[e.jsx("p",{className:"text-xs font-medium text-blue-700 dark:text-blue-300 mb-1",children:r("interviewPrep.communicationStyle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.communicationStyle})]}),e.jsxs("div",{className:"p-3 bg-green-500/5 border border-green-500/20 rounded-lg",children:[e.jsx("p",{className:"text-xs font-medium text-green-700 dark:text-green-300 mb-1",children:r("interviewPrep.whatTheyValue")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.whatTheyValueInCandidates})]}),e.jsxs("div",{className:"p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx(ka,{className:"w-3 h-3 text-primary"}),e.jsx("p",{className:"text-xs font-medium text-primary",children:r("interviewPrep.bestCommunication")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.howToCommunicate})]}),q.warningSignals&&e.jsxs("div",{className:"p-3 bg-red-500/5 border border-red-500/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx(va,{className:"w-3 h-3 text-red-600"}),e.jsx("p",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:r("interviewPrep.avoidThis")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.warningSignals})]})]})]},Ce))})})]})}),D.generalTips&&e.jsxs(ye,{className:"p-4 bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Go,{className:"w-5 h-5 text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:r("interviewPrep.generalTips")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:D.generalTips.introduction}),((V=D.generalTips.keyAreas)==null?void 0:V.length)>0&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-4",children:D.generalTips.keyAreas.map((q,Ce)=>e.jsxs("div",{className:"bg-background/50 rounded-lg p-3",children:[e.jsx("p",{className:"font-medium text-sm text-foreground",children:q.area}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:q.description})]},Ce))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[((W=D.generalTips.dos)==null?void 0:W.length)>0&&e.jsxs("div",{className:"bg-green-500/5 border border-green-500/20 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx($s,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"font-medium text-sm text-green-700",children:r("interviewPrep.doThis")})]}),e.jsx("ul",{className:"space-y-1",children:D.generalTips.dos.map((q,Ce)=>e.jsxs("li",{className:"text-xs text-muted-foreground flex items-start gap-2",children:[e.jsx("span",{className:"text-green-500 mt-1",children:"•"}),e.jsx("span",{children:q})]},Ce))})]}),((be=D.generalTips.donts)==null?void 0:be.length)>0&&e.jsxs("div",{className:"bg-red-500/5 border border-red-500/20 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ir,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"font-medium text-sm text-red-700",children:r("interviewPrep.avoidThis")})]}),e.jsx("ul",{className:"space-y-1",children:D.generalTips.donts.map((q,Ce)=>e.jsxs("li",{className:"text-xs text-muted-foreground flex items-start gap-2",children:[e.jsx("span",{className:"text-red-500 mt-1",children:"•"}),e.jsx("span",{children:q})]},Ce))})]})]})]}),e.jsx(Mt,{children:e.jsxs(ye,{className:"p-4",children:[e.jsxs($t,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wt,{className:"w-5 h-5 text-yellow-500"}),e.jsx("h3",{className:"font-semibold text-foreground",children:r("interviewPrep.starMethod")})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(Rt,{children:e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"S"})," – ",r("interviewPrep.starSituation").replace(/^(Situation):\s*/i,"")]}),e.jsxs("p",{children:[e.jsx("strong",{children:"T"})," – ",r("interviewPrep.starTask").replace(/^(Opgave|Task):\s*/i,"")]}),e.jsxs("p",{children:[e.jsx("strong",{children:"A"})," – ",r("interviewPrep.starAction").replace(/^(Handling|Action):\s*/i,"")]}),e.jsxs("p",{children:[e.jsx("strong",{children:"R"})," – ",r("interviewPrep.starResult").replace(/^(Resultat|Result):\s*/i,"")]}),e.jsx("p",{className:"text-xs mt-2 italic",children:r("interviewPrep.starTip")}
123)]})})]})}),e.jsx(Mt,{defaultOpen:!0,children:e.jsxs(ye,{className:"p-4",children:[e.jsxs($t,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lr,{className:"w-5 h-5 text-blue-500"}),e.jsx("h3",{className:"font-semibold text-foreground",children:r("interviewPrep.questionsToAsk",{count:((Me=D.questionsToAsk)==null?void 0:Me.length)||0})})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(Rt,{children:e.jsx("div",{className:"space-y-3 mt-4",children:(Be=D.questionsToAsk)==null?void 0:Be.map((q,Ce)=>e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"font-medium text-sm text-foreground",children:q.question}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[e.jsx("span",{className:"font-medium",children:r("interviewPrep.why")}),q.why]})]},Ce))})})]})}),e.jsx(Mt,{defaultOpen:!0,children:e.jsxs(ye,{className:"p-4",children:[e.jsxs($t,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cn,{className:"w-5 h-5 text-orange-500"}),e.jsxs("h3",{className:"font-semibold text-foreground",children:[r("interviewPrep.expectedQuestions")," (",((ss=D.questionsToExpect)==null?void 0:ss.length)||0,")"]})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(Rt,{children:e.jsx("div",{className:"space-y-3 mt-4",children:($e=D.questionsToExpect)==null?void 0:$e.map((q,Ce)=>e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"font-medium text-sm text-foreground",children:q.question}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[e.jsx("span",{className:"font-medium",children:r("interviewPrep.suggestedAnswer")}),q.suggestedAnswer]})]},Ce))})})]})}),e.jsx(Mt,{defaultOpen:!0,children:e.jsxs(ye,{className:"p-4",children:[e.jsxs($t,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{className:"w-5 h-5 text-green-500"}),e.jsxs("h3",{className:"font-semibold text-foreground",children:[r("interviewPrep.yourStrengths")," (",((es=D.strengths)==null?void 0:es.length)||0,")"]})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(Rt,{children:e.jsx("div",{className:"space-y-3 mt-4",children:(bs=D.strengths)==null?void 0:bs.map((q,Ce)=>e.jsxs("div",{className:"p-3 bg-green-500/5 border border-green-500/20 rounded-lg",children:[e.jsx("p",{className:"font-medium text-sm text-foreground",children:q.strength}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:q.relevance})]},Ce))})})]})}),e.jsx(Mt,{defaultOpen:!0,children:e.jsxs(ye,{className:"p-4",children:[e.jsxs($t,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(va,{className:"w-5 h-5 text-yellow-500"}),e.jsxs("h3",{className:"font-semibold text-foreground",children:[r("interviewPrep.attentionPoints")," (",((Xs=D.weaknesses)==null?void 0:Xs.length)||0,")"]})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(Rt,{children:e.jsx("div",{className:"space-y-3 mt-4",children:(Ks=D.weaknesses)==null?void 0:Ks.map((q,Ce)=>e.jsxs("div",{className:"p-3 bg-yellow-500/5 border border-yellow-500/20 rounded-lg",children:[e.jsx("p",{className:"font-medium text-sm text-foreground",children:q.area}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:q.mitigation})]},Ce))})})]})}),x&&e.jsx(Mt,{defaultOpen:Ve,children:e.jsxs(ye,{className:"p-4",children:[e.jsxs($t,{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ja,{className:"w-5 h-5 text-rose-500"}),e.jsxs("h3",{className:"font-semibold text-foreground",children:[r("interviewPrep.developmentAreas")," ",we.length>0?`(${we.length})`:""]})]}),e.jsx(Ts,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(Rt,{children:e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:r("interviewPrep.devDescription")}),ae.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:ae.map(q=>e.jsxs(je,{variant:"secondary",className:"gap-1",children:[e.jsx(va,{className:"w-3 h-3"}),q.trait," (",q.score.toFixed(1),")"]},q.trait))}),!Ve&&!Ae&&e.jsx(ye,{className:"bg-gradient-to-br from-rose-500/5 to-orange-500/5 border-rose-500/20",children:e.jsxs("div",{className:"p-4 text-center",children:[e.jsx(xs,{className:"w-6 h-6 text-rose-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:r("interviewPrep.devAIDescription")}),e.jsxs(h,{onClick:He,className:"rounded-xl gap-2",children:[e.jsx(ja,{className:"w-4 h-4"}),r("interviewPrep.generateQuestions")]})]})}),Ae&&e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("interviewPrep.analyzingDevAreas")})]}),Ve&&!Ae&&we.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(h,{size:"sm",variant:"ghost",onClick:He,className:"rounded-xl gap-1",children:[e.jsx(dt,{className:"w-3 h-3"}),r("interviewPrep.generateNew")]})}),we.map((q,Ce)=>{const Ie=`dev-${Ce}`,ds=cs.includes(Ie);return e.jsx(Mt,{open:ds,onOpenChange:()=>Ze(Ie),children:e.jsxs(ye,{className:"overflow-hidden",children:[e.jsx($t,{className:"w-full text-left p-3 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-primary/10 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:Ce+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(je,{variant:"outline",className:"text-xs shrink-0",children:q.category}),e.jsx(je,{variant:"secondary",className:"text-xs shrink-0",children:q.trait})]}),e.jsx("p",{className:"font-medium text-sm text-foreground",children:q.question})]}),e.jsx(Ts,{className:`w-4 h-4 text-muted-foreground shrink-0 transition-transform duration-200 ${ds?"rotate-180":""}`})]})}),e.jsx(Rt,{children:e.jsxs("div",{className:"px-3 pb-3 space-y-2 border-t pt-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1",children:[e.jsx(va,{className:"w-3 h-3"})," ",r("interviewPrep.whyAsked")]}),e.jsx("p",{className:"text-sm text-foreground",children:q.why})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1",children:[e.jsx(wt,{className:"w-3 h-3"})," ",r("interviewPrep.suggestedApproach")]}),e.jsx("p",{className:"text-sm text-foreground",children:q.suggestedApproach})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:r("interviewPrep.exampleAnswer")}),e.jsx("p",{className:"text-sm text-foreground italic",children:q.exampleAnswer})]})]})})]})},Ie)})]}),Ve&&!Ae&&we.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:r("interviewPrep.noDevAreas")})]})})]})}),e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg text-sm text-muted-foreground",children:[e.jsx("strong",{children:r("interviewPrep.tips")})," ",r("interviewPrep.tipFooter")]})]})})})]})]});return t?e.jsx("div",{className:"w-full",children:o}):e.jsx(ns,{open:s,onOpenChange:a,children:e.jsx(rs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:o})})},hu=()=>{const[s,a]=i.useState(""),[t,r]=i.useState(!1),[n,d]=i.useState([]),[m,c]=i.useState(!1),l=i.useRef(null),{t:f,i18n:p}=Je(),j=i.useMemo(()=>kl,[]);ht,f("sammyChat.interviewTopic"),f("sammyChat.interviewDesc"),Fs,f("sammyChat.cvTopic"),f("sammyChat.cvDesc"),tt,f("sammyChat.networkTopic"),f("sammyChat.networkDesc"),ka,f("sammyChat.strategyTopic"),f("sammyChat.strategyDesc"),ar,f("sammyChat.brandingTopic"),f("sammyChat.brandingDesc"),i.useEffect(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},[n]);const g=async()=>
123{if(!s.trim()||t)return;const w={role:"user",content:s.trim(),timestamp:new Date};d(S=>[...S,w]),a(""),r(!0);try{const S=n.map(D=>({role:D.role,content:D.content})),{data:A,error:y}=await C.functions.invoke("career-chat",{body:{language:p.language,question:w.content,conversationHistory:S}});if(y)throw y;d(D=>[...D,{role:"assistant",content:A.answer||f("sammyChat.couldNotGenerate"),timestamp:new Date}])}catch(S){console.error("Error calling career-chat:",S),d(A=>[...A,{role:"assistant",content:f("sammyChat.errorOccurred"),timestamp:new Date}])}finally{r(!1)}},P=w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),g())},N=Te(p.language)?"da-DK":"en-US";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsxs("div",{className:"relative inline-block",children:[e.jsx("div",{className:"w-24 h-24 mx-auto rounded-full p-1 shadow-lg animate-fade-in",children:e.jsx("img",{src:j,alt:"Sammy",className:"w-full h-full object-cover rounded-full",loading:"lazy",decoding:"async"})}),e.jsx("div",{className:"absolute -bottom-1 -right-1 w-7 h-7 bg-green-500 rounded-full border-2 border-background flex items-center justify-center",children:e.jsx(xs,{className:"w-4 h-4 text-white"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:f("sammyChat.title")}),e.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:f("sammyChat.intro")})]})]}),n.length===0&&e.jsx(ye,{className:"p-4 bg-gradient-to-r from-primary/5 to-accent/5 border-primary/20",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full p-0.5 shrink-0",children:e.jsx("img",{src:j,alt:"Sammy",className:"w-full h-full object-cover rounded-full",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-foreground mb-1",children:"Sammy"}),e.jsx("p",{className:"text-foreground",children:f("sammyChat.welcomeMessage")})]})]})}),e.jsxs("div",{className:"bg-muted/50 border border-border rounded-lg p-4 flex items-start gap-3",children:[e.jsx(ha,{className:"w-5 h-5 text-primary shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{className:"text-foreground",children:f("sammyChat.scopeTitle")})," ",f("sammyChat.scopeDescription")]})]}),n.length>0&&e.jsx(ye,{className:"border-primary/20",children:e.jsx(Wn,{className:"h-[400px] p-4",ref:l,children:e.jsxs("div",{className:"space-y-4",children:[n.map((w,S)=>e.jsxs("div",{className:`flex gap-3 ${w.role==="user"?"justify-end":"justify-start"}`,children:[w.role==="assistant"&&e.jsx("div",{className:"w-10 h-10 rounded-full p-0.5 shrink-0",children:e.jsx("img",{src:j,alt:"Sammy",className:"w-full h-full object-cover rounded-full",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:`max-w-[80%] rounded-lg p-3 ${w.role==="user"?"bg-primary text-primary-foreground":"bg-muted"}`,children:[w.role==="assistant"&&e.jsx("p",{className:"font-medium text-foreground text-sm mb-1",children:"Sammy"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:w.content}),e.jsx("p",{className:`text-xs mt-1 ${w.role==="user"?"text-primary-foreground/70":"text-muted-foreground"}`,children:w.timestamp.toLocaleTimeString(N,{hour:"2-digit",minute:"2-digit"})})]}),w.role==="user"&&e.jsx("div",{className:"w-10 h-10 rounded-full bg-secondary flex items-center justify-center shrink-0",children:e.jsx(Ca,{className:"w-5 h-5 text-secondary-foreground"})})]},S)),t&&e.jsxs("div",{className:"flex gap-3 justify-start",children:[e.jsx("div",{className:"w-10 h-10 rounded-full p-0.5 shrink-0",children:e.jsx("img",{src:j,alt:"Sammy",className:"w-full h-full object-cover rounded-full"})}),e.jsxs("div",{className:"bg-muted rounded-lg p-3 flex items-center gap-2",children:[e.jsx(ge,{className:"w-4 h-4 animate-spin text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:f("sammyChat.sammyThinking")})]})]})]})})}),e.jsx(ye,{className:"p-6 border-primary/20 bg-gradient-to-r from-primary/5 to-primary/10",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(as,{placeholder:f("sammyChat.placeholder"),value:s,onChange:w=>a(w.target.value),onKeyDown:P,className:"min-h-[100px] resize-none bg-background"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:f("sammyChat.enterToSend")}),e.jsx(h,{onClick:g,disabled:!s.trim()||t,className:"gap-2",children:t?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),f("sammyChat.sending")]}):e.jsxs(e.Fragment,{children:[e.jsx(Cn,{className:"w-4 h-4"}),f("sammyChat.sendQuestion")]})})]})]})}),n.length>0&&e.jsx("div",{className:"flex justify-center",children:e.jsx(h,{variant:"outline",size:"sm",onClick:()=>d([]),children:f("sammyChat.newConversation")})}),e.jsx(ao,{open:m,onOpenChange:c})]})},xu=({companyName:s,companyId:a,onBack:t,onAddToFavorites:r})=>{const{t:n,i18n:d}=Je(),[m,c]=i.useState([]),[l,f]=i.useState(!0),[p,j]=i.useState(null),[g,P]=i.useState(!1),[N,w]=i.useState(null),[S,A]=i.useState(!1),[y,D]=i.useState(null),{toast:B}=Ct(),[M,Y]=i.useState({name:"",title:"",phone:"",email:"",contact_date:"",follow_up_date:"",status:"",specialer:""});i.useEffect(()=>{R()},[a]),i.useEffect(()=>{m.length>0&&Q()},[m]);const R=async()=>{try{const{data:{user:I}}=await C.auth.getUser();if(!I){f(!1);return}const{data:E,error:F}=await C.from("headhunter_contacts").select("*").eq("company_id",a).eq("user_id",I.id).order("created_at",{ascending:!1});if(F)throw F;c(E||[])}catch(I){console.error("Error fetching contacts:",I),B({title:n("headhunterContacts.toast.error"),description:n("headhunterContacts.toast.couldNotFetchContacts"),variant:"destructive"})}finally{f(!1)}},Q=()=>{const I=new Date,E=m.filter(F=>
123{if(!F.follow_up_date)return!1;const ee=new Date(F.follow_up_date).getTime()-I.getTime(),Le=Math.ceil(ee/(1e3*60*60*24));return Le>=0&&Le<=7});if(E.length>0){const F=E.filter(ee=>new Date(ee.follow_up_date)<=I).length,O=E.length-F;F>0?B({title:n("headhunterContacts.toast.overdueFollowUps"),description:n("headhunterContacts.toast.overdueFollowUpsDesc",{count:F}),variant:"destructive"}):O>0&&B({title:n("headhunterContacts.toast.upcomingFollowUps"),description:n("headhunterContacts.toast.upcomingFollowUpsDesc",{count:O})})}},k=async()=>{if(!M.name.trim()){B({title:n("headhunterContacts.toast.error"),description:n("headhunterContacts.toast.nameRequired"),variant:"destructive"});return}A(!0);try{const{data:{user:I}}=await C.auth.getUser();if(!I)throw new Error("Not logged in");const{data:E,error:F}=await C.from("headhunter_contacts").insert({user_id:I.id,company_id:a,company_name:s,name:M.name,title:M.title||null,phone:M.phone||null,email:M.email||null,contact_date:M.contact_date||null,follow_up_date:M.follow_up_date||null,status:M.status||null,specialer:M.specialer||null}).select().single();if(F)throw F;c(O=>[E,...O]),Y({name:"",title:"",phone:"",email:"",contact_date:"",follow_up_date:"",status:"",specialer:""}),P(!1),r&&r(),B({title:n("headhunterContacts.toast.contactAdded"),description:n("headhunterContacts.toast.contactAddedDesc",{name:E.name})})}catch(I){console.error("Error adding contact:",I),B({title:n("headhunterContacts.toast.error"),description:n("headhunterContacts.toast.couldNotAddContact"),variant:"destructive"})}finally{A(!1)}},$=async()=>{if(N){A(!0);try{const{error:I}=await C.from("headhunter_contacts").update({name:N.name,title:N.title,phone:N.phone,email:N.email,contact_date:N.contact_date,follow_up_date:N.follow_up_date,status:N.status,specialer:N.specialer}).eq("id",N.id);if(I)throw I;c(E=>E.map(F=>F.id===N.id?N:F)),w(null),B({title:n("headhunterContacts.toast.contactUpdated"),description:n("headhunterContacts.toast.contactUpdatedDesc")})}catch(I){console.error("Error updating contact:",I),B({title:n("headhunterContacts.toast.error"),description:n("headhunterContacts.toast.couldNotUpdateContact"),variant:"destructive"})}finally{A(!1)}}},K=async(I,E)=>{try{const{error:F}=await C.from("headhunter_contacts").delete().eq("id",I);if(F)throw F;c(O=>O.filter(ee=>ee.id!==I)),B({title:n("headhunterContacts.toast.contactDeleted"),description:n("headhunterContacts.toast.contactDeletedDesc",{name:E})})}catch(F){console.error("Error deleting contact:",F),B({title:n("headhunterContacts.toast.error"),description:n("headhunterContacts.toast.couldNotUpdateContact"),variant:"destructive"})}},re=async I=>{try{const{error:E}=await C.from("headhunter_contacts").update({needs_review:!1,needs_review_since:null}).eq("id",I);if(E)throw E;c(F=>F.map(O=>O.id===I?{...O,needs_review:!1,needs_review_since:null}:O)),B({title:js(d.language)?"Review dismissed":"Advarsel fjernet"})}catch(E){console.error("Error dismissing review:",E)}},ve=async(I,E)=>{try{const{error:F}=await C.from("headhunter_contacts").update({is_selected:!E}).eq("id",I);if(F)throw F;c(O=>O.map(ee=>ee.id===I?{...ee,is_selected:!E}:ee)),B({title:n(E?"contactDashboard.removedFromDashboard":"contactDashboard.addedToDashboard")})}catch(F){console.error("Error toggling selected:",F)}},ze=async(I,E)=>{try{const{error:F}=await C.from("headhunter_contacts").update({status:E}).eq("id",I);if(F)throw F;c(O=>O.map(ee=>ee.id===I?{...ee,status:E}:ee))}catch(F){console.error("Error updating status:",F)}},xe=I=>{if(!I)return null;const E=new Date;E.setHours(0,0,0,0);const F=new Date(I);F.setHours(0,0,0,0);const O=F.getTime()-E.getTime(),ee=Math.ceil(O/(1e3*60*60*24));return ee<0?e.jsxs(je,{variant:"destructive",className:"gap-1",children:[e.jsx(wa,{className:"w-3 h-3"}),n("headhunterContacts.overdue",{days:Math.abs(ee)})]}):ee===0?e.jsxs(je,{className:"bg-orange-500/10 text-orange-600 border-orange-500/20 gap-1",children:[e.jsx(ra,{className:"w-3 h-3"}),n("headhunterContacts.today")]}):ee<=7?e.jsxs(je,{className:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20 gap-1",children:[e.jsx(ra,{className:"w-3 h-3"}),ee>1?n("headhunterContacts.inDays",{days:ee}):n("headhunterContacts.inDay",{days:ee})]}):null};return l?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(h,{variant:"ghost",size:"sm",onClick:t,className:"gap-2",children:[e.jsx(_n,{className:"w-4 h-4"}),n("headhunterContacts.back")]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(ut,{className:"w-5 h-5 text-primary"}),n("headhunterContacts.contactsAt",{name:s})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("headhunterContacts.manageContacts")}
123)]})]}),e.jsxs(ns,{open:g,onOpenChange:P,children:[e.jsx(Na,{asChild:!0,children:e.jsxs(h,{className:"gap-2",children:[e.jsx(fs,{className:"w-4 h-4"}),n("headhunterContacts.addNewContact")]})}),e.jsxs(rs,{className:"max-w-md",children:[e.jsx(os,{children:e.jsx(is,{children:n("headhunterContacts.addContactTitle")})}),e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"name",children:n("headhunterContacts.nameRequired")}),e.jsx(ue,{id:"name",value:M.name,onChange:I=>Y(E=>({...E,name:I.target.value})),placeholder:n("headhunterContacts.enterName")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"title",children:n("headhunterContacts.title")}),e.jsx(ue,{id:"title",value:M.title,onChange:I=>Y(E=>({...E,title:I.target.value})),placeholder:n("headhunterContacts.titlePlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"phone",children:n("headhunterContacts.phone")}),e.jsx(ue,{id:"phone",value:M.phone,onChange:I=>Y(E=>({...E,phone:I.target.value})),placeholder:"+45..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"email",children:n("headhunterContacts.emailLabel")}),e.jsx(ue,{id:"email",type:"email",value:M.email,onChange:I=>Y(E=>({...E,email:I.target.value})),placeholder:"[email protected]"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"contact_date",children:n("headhunterContacts.contactDate")}),e.jsx(ue,{id:"contact_date",type:"date",value:M.contact_date,onChange:I=>Y(E=>({...E,contact_date:I.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"follow_up_date",children:n("headhunterContacts.nextFollowUp")}),e.jsx(ue,{id:"follow_up_date",type:"date",value:M.follow_up_date,onChange:I=>Y(E=>({...E,follow_up_date:I.target.value}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"specialer",children:n("headhunterContacts.specialties")}),e.jsx(as,{id:"specialer",value:M.specialer,onChange:I=>Y(E=>({...E,specialer:I.target.value})),placeholder:n("headhunterContacts.specialtiesPlaceholder"),className:"min-h-[60
123px]"})]}),e.jsxs(h,{onClick:k,className:"w-full",disabled:S,children:[S?e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):null,n("headhunterContacts.addContact")]})]})]})]}),e.jsx(ns,{open:!!N,onOpenChange:I=>!I&&w(null),children:e.jsxs(rs,{className:"max-w-md",children:[e.jsx(os,{children:e.jsx(is,{children:n("headhunterContacts.editContactTitle")})}),N&&e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-name",children:n("headhunterContacts.nameRequired")}),e.jsx(ue,{id:"edit-name",value:N.name,onChange:I=>w(E=>E?{...E,name:I.target.value}:null)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-title",children:n("headhunterContacts.title")}),e.jsx(ue,{id:"edit-title",value:N.title||"",onChange:I=>w(E=>E?{...E,title:I.target.value}:null)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-phone",children:n("headhunterContacts.phone")}),e.jsx(ue,{id:"edit-phone",value:N.phone||"",onChange:I=>w(E=>E?{...E,phone:I.target.value}:null)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-email",children:n("headhunterContacts.emailLabel")}),e.jsx(ue,{id:"edit-email",type:"email",value:N.email||"",onChange:I=>w(E=>E?{...E,email:I.target.value}:null)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-contact_date",children:n("headhunterContacts.contactDate")}),e.jsx(ue,{id:"edit-contact_date",type:"date",value:N.contact_date||"",onChange:I=>w(E=>E?{...E,contact_date:I.target.value}:null)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-follow_up_date",children:n("headhunterContacts.nextFollowUp")}),e.jsx(ue,{id:"edit-follow_up_date",type:"date",value:N.follow_up_date||"",onChange:I=>w(E=>E?{...E,follow_up_date:I.target.value}:null)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-specialer",children:n("headhunterContacts.specialties")}),e.jsx(as,{id:"edit-specialer",value:N.specialer||"",onChange:I=>w(E=>E?{...E,specialer:I.target.value}:null),placeholder:n("headhunterContacts.specialtiesPlaceholder"),className:"min-h-[60
123px]"})]}),e.jsxs(h,{onClick:$,className:"w-full",disabled:S,children:[S?e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):null,n("headhunterContacts.saveChanges")]})]})]})}),m.length===0?e.jsxs(ye,{className:"p-8 text-center border-dashed border-2",children:[e.jsx(Ca,{className:"w-12 h-12 text-muted-foreground mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-foreground mb-2",children:n("headhunterContacts.noContactsYet")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:n("headhunterContacts.addFirstContact",{name:s})})]}):e.jsx("div",{className:"space-y-4",children:m.map(I=>e.jsxs(ye,{className:`p-5 ${I.needs_review?"border-amber-400/50 bg-amber-50/30 dark:bg-amber-500/5":""}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground text-lg",children:I.name}),I.title&&e.jsx("p",{className:"text-sm text-muted-foreground",children:I.title}),I.needs_review&&e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-amber-600 dark:text-amber-400",children:[e.jsx(wa,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs font-medium",children:js(d.language)?"Check if this person is still at the company":"Obs: Check om personen stadig er i virksomheden"})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-5 px-1.5 text-[10px] text-muted-foreground hover:text-foreground",onClick:()=>re(I.id),children:"✓ OK"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[xe(I.follow_up_date),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>ve(I.id,I.is_selected),title:I.is_selected?n("contactDashboard.removeFromDashboard"):n("contactDashboard.addedToDashboard"),children:e.jsx(Ps,{className:`w-4 h-4 ${I.is_selected?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>w(I),children:e.jsx(Qa,{className:"w-4 h-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>D({id:I.id,name:I.name}),children:e.jsx(Ss,{className:"w-4 h-4 text-destructive"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-4",children:[I.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(or,{className:"w-4 h-4"}),I.phone]}),I.email&&e.jsxs("a",{href:`mailto:${I.email}`,className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[e.jsx(ua,{className:"w-4 h-4"}),I.email]}),I.contact_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(gt,{className:"w-4 h-4"}),n("headhunterContacts.contacted"),": ",new Date(I.contact_date).toLocaleDateString(Te(d.language)?"da-DK":"en-US")]}),I.follow_up_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(gt,{className:"w-4 h-4 text-primary"}),n("headhunterContacts.followUp"),": ",new Date(I.follow_up_date).toLocaleDateString(Te(d.language)?"da-DK":"en-US"),e.jsx(Br,{title:`${n("headhunterContacts.followUp")}: ${I.name} (${s})`,date:I.follow_up_date,description:`${js(d.language)?"Follow up with":"Opfølgning med"} ${I.name} ${js(d.language)?"at":"hos"} ${s}`})]})]}),I.specialer&&e.jsxs("div",{className:"mb-4 p-3 rounded-md bg-muted/30",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:n("headhunterContacts.specialties")}),e.jsx("p",{className:"text-sm text-foreground",children:I.specialer})]}),e.jsxs(Mt,{open:p===I.id,onOpenChange:E=>j(E?I.id:null),children:[e.jsx($t,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center justify-between p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:n("headhunterContacts.statusAndNotes")}),I.status&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",I.status.substring(0,30),I.status.length>30?"...":"",")"]})]}),e.jsx(Ts,{className:`w-4 h-4 text-muted-foreground transition-transform ${p===I.id?"rotate-180":""}`})]})}),e.jsx(Rt,{className:"pt-3",children:e.jsx(as,{placeholder:n("headhunterContacts.statusPlaceholder"),value:
123I.status||"",onChange:E=>ze(I.id,E.target.value),className:"min-h-[100px]"})})]})]},I.id))})]}),e.jsx(at,{open:!!y,onOpenChange:I=>!I&&D(null),children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:n("headhunterContacts.deleteContactTitle")}),e.jsx(lt,{children:n("headhunterContacts.deleteContactConfirm",{name:y==null?void 0:y.name})})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:n("headhunterContacts.cancelDelete")}),e.jsx(Ys,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{y&&(K(y.id,y.name),D(null))},children:n("headhunterContacts.confirmDelete")})]})]})})]})},pu=({onSelectCompany:s})=>{const[a,t]=i.useState([]),[r,n]=i.useState(!0),{toast:d}=Ct(),{t:m,i18n:c}=Je();i.useEffect(()=>{l()},[]);const l=async()=>{try{const{data:{user:w}}=await C.auth.getUser();if(!w){n(!1);return}const{data:S,error:A}=await C.from("headhunter_contacts").select("id, name, company_name, company_id, follow_up_date, contact_date, title").eq("user_id",w.id).not("follow_up_date","is",null).order("follow_up_date",{ascending:!0});if(A)throw A;t(S||[])}catch(w){console.error("Error fetching follow-ups:",w),d({title:m("followUp.error"),description:m("followUp.couldNotFetch"),variant:"destructive"})}finally{n(!1)}},f=w=>{const S=new Date;S.setHours(0,0,0,0);const A=new Date(w);A.setHours(0,0,0,0);const y=A.getTime()-S.getTime(),D=Math.ceil(y/(1e3*60*60*24));return D<0?{status:"overdue",label:m("followUp.daysOverdue",{count:Math.abs(D)}),color:"destructive"}:D===0?{status:"today",label:m("followUp.today"),color:"default"}:D<=7?{status:"upcoming",label:D>1?m("followUp.inDaysPlural",{count:D}):m("followUp.inDays",{count:D}),color:"secondary"}:{status:"future",label:m("followUp.inDaysPlural",{count:D}),color:"outline"}},p=a.filter(w=>f(w.follow_up_date).status==="overdue"),j=a.filter(w=>f(w.follow_up_date).status==="today"),g=a.filter(w=>f(w.follow_up_date).status==="upcoming"),P=a.filter(w=>f(w.follow_up_date).status==="future");if(r)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary"})});const N=w=>{const S=f(w.follow_up_date),A=Te(c.language)?"da-DK":"en-US";return e.jsx(ye,{className:"p-4 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ca,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-foreground",children:w.name}),w.title&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["• ",w.title]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-2",children:[e.jsx(ut,{className:"w-4 h-4"}),w.company_name]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(gt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{children:new Date(w.follow_up_date).toLocaleDateString(A,{weekday:"long",day:"numeric",month:"long"})})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsxs(je,{variant:S.color,className:"gap-1",children:[S.status==="overdue"&&e.jsx(wa,{className:"w-3 h-3"}),S.status==="today"&&e.jsx(ra,{className:"w-3 h-3"}),S.label]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>s({id:w.company_id,name:w.company_name}),className:"gap-1",children:[e.jsx(Yn,{className:"w-3 h-3"}),m("followUp.viewContact")]})]})]})},w.id)};return a.length===0?e.jsxs(ye,{className:"p-8 text-center border-dashed border-2",children:[e.jsx(gt,{className:"w-12 h-12 text-muted-foreground mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-foreground mb-2",children:m("followUp.noFollowUps")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("followUp.noFollowUpsDesc")})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-destructive",children:p.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:m("followUp.overdue")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-orange-500",children:j.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:m("followUp.todayLabel")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:g.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:m("followUp.next7days")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-muted-foreground",children:P.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:m("followUp.later")})]})]}),p.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-destructive flex items-center gap-2",children:[e.jsx(wa,{className:"w-5 h-5"}),m("followUp.overdueFollowUps",{count:p.length})]}),e.jsx("div",{className:"space-y-2",children:p.map(N)})]}),j.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-orange-500 flex items-center gap-2",children:[e.jsx(ra,{className:"w-5 h-5"}),m("followUp.todayFollowUps",{count:j.length})]}),e.jsx("div",{className:"space-y-2",children:j.map(N)})]}),g.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-yellow-600 flex items-center gap-2",children:[e.jsx(gt,{className:"w-5 h-5"}),m("followUp.next7daysFollowUps",{count:g.length})]}),e.jsx("div",{className:"space-y-2",children:g.map(N)})]}),P.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-muted-foreground flex items-center gap-2",children:[e.jsx($s,{className:"w-5 h-5"}),m("followUp.laterFollowUps",{count:P.length})]}),e.jsx("div",{className:"space-y-2",children:P.map(N)})]})]})},gu=()=>{var Bs,ie;const{t:s,i18n:a}=Je(),[t,r]=i.useState("alle"),[n,d]=i.useState(!1),[m,c]=i.useState(!1),[l,f]=i.useState(""),[p,j]=i.useState([]),[g,P]=i.useState(!1),[N,w]=i.useState([]),[S,A]=i.useState(!1),[y,D]=i.useState([]),[B,M]=i.useState(null),[Y,R]=i.useState(!0),[Q,k]=i.useState(!1),[$,K]=i.useState(!1),[re,ve]=i.useState([]),[ze,xe]=i.useState([]);i.useState(!1),i.useState(!1),i.useState(!1),i.useState(!1),i.useState([]);const[I,E]=i.useState(!1),[F,O]=i.useState(null),[ee,Le]=i.useState(null),[pe,Oe]=i.useState({open:!1,headhunter:null,employees:[]}),[he,we]=i.useState(null),[T,ae]=i.useState(null),[me,Ae]=i.useState(null),[oe,Ve]=i.useState([]),[Xe,cs]=i.useState(!1),[hs,ps]=i.useState(!1),[ms,De]=i.useState(!1),[_,Z]=i.useState(!1),[H,ne]=i.useState({name:"",website:"",type:"Executive Search",location:"",notes:""});i.useState({name:"",type:"Executive Search",specialer:"",lokation:"",email:"",website:"",linkedin:"",linkedin_employees:"",niche:"",cv_database:""});const{toast:x}=Ct();i.useEffect(()=>{te(),fe(),Se(),b(),z()},[]);const z=async()=>{try{const{data:{user:o}}=await C.auth.getUser();if(!o)return;const{data:V}=await C.from("headhunter_favorites").select("company_id").eq("user_id",o.id
123).not("company_id","is",null);if(!V)return;j(V.map(W=>W.company_id))}catch(o){console.error("Error fetching favorites:",o)}},b=async()=>{try{const{data:{user:o}}=await C.auth.getUser();if(!o)return;const{data:V}=await C.from("headhunter_recent_views").select("company_id, custom_headhunter_id, viewed_at").eq("user_id",o.id).order("viewed_at",{ascending:!1}).limit(20);if(!V)return;const W=V.map(be=>be.company_id!==null&&be.company_id!==void 0?be.company_id:be.custom_headhunter_id?parseInt(String(be.custom_headhunter_id).replace(/-/g,"").substring(0,8),16):null).filter(be=>be!==null);w(W)}catch(o){console.error("Error fetching recent views:",o)}},U=async o=>{jn("headhunter_view_details","headhunter",o);try{const{data:{user:V}}=await C.auth.getUser();if(!V)return;const W=o.companyId!==void 0?o.companyId:o.customHeadhunterId?parseInt(o.customHeadhunterId.replace(/-/g,"").substring(0,8),16):null;W!==null&&w(Be=>[W,...Be.filter(ss=>ss!==W)].slice(0,20));const be={user_id:V.id,viewed_at:new Date().toISOString()},Me=o.companyId!==void 0?"user_id,c
123ompany_id":"user_id,custom_headhunter_id";o.companyId!==void 0&&(be.company_id=o.companyId),o.customHeadhunterId&&(be.custom_headhunter_id=o.customHeadhunterId),await C.from("headhunter_recent_views").upsert(be,{onConflict:Me})}catch(V){console.error("Error tracking headhunter view:",V)}},te=async()=>{try{const{data:{user:o}}=await C.auth.getUser();if(!o){R(!1);return}const{data:V,error:W}=await C.from("headhunter_contacted_status").select("company_id").eq("user_id",o.id);if(W)throw W;D((V==null?void 0:V.map(be=>be.company_id))||[])}catch(o){console.error("Error fetching contacted status:",o)}finally{R(!1)}},fe=async()=>{try{const{data:{user:o}}=await C.auth.getUser();if(!o)return;const{data:V,error:W}=await C.from("custom_headhunters").select("*").eq("user_id",o.id).order("created_at",{ascending:!1});if(W)throw W;ve(V||[])}catch(o){console.error("Error fetching custom headhunters:",o)}},Se=async()=>{try{const{data:o,error:V}=await C.from("global_headhunters_safe").select("*").order("name",{ascending:!0});if(V)throw V;xe((o||[]).map(W=>({...W,email:null,isGlobal:!0})))}catch(o){console.error("Error fetching global headhunters:",o)}},G=async o=>{if(!o.website){x({title:s("headhunters.toast.noWebsite"),description:s("headhunters.toast.addWebsiteToSearch"),variant:"destructive"});return}Le(o.id);try{const{data:V,error:W}=await C.functions.invoke("analyze-headhunter-website",{body:{language:a.language,websiteUrl:o.website}});if(W){x({title:s("headhunters.toast.error"),description:W.message||s("headhunters.toast.couldNotSearchEmployees"),variant:"destructive"});return}V!=null&&V.employees&&Array.isArray(V.employees)&&V.employees.length>0?Oe({open:!0,headhunter:o,employees:V.employees.map(be=>({...be,selected:!0}))}):x({title:s("headhunters.toast.noEmployeesFound"),description:s("headhunters.toast.noEmployeesFoundDesc")})}catch(V){console.error("Error searching employees:",V),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotSearchEmployees"),variant:"destructive"})}finally{Le(null)}},Fe=async o=>{if(!o.website){x({title:s("headhunters.toast.noWebsite"),description:s("headhunters.toast.addWebsiteToSearch"),variant:"destructive"});return}O(o.id);try{const{data:V,error:W}=await C.functions.invoke("analyze-headhunter-website",{body:{language:a.language,websiteUrl:o.website}});if(W){x({title:s("headhunters.toast.error"),description:W.message||s("headhunters.toast.couldNotSearchEmployees"),variant:"destructive"});return}if(V!=null&&V.employees&&Array.isArray(V.employees)&&V.employees.length>0){const{data:{user:be}}=await C.auth.getUser();if(!be)throw new Error("Not logged in");const Me=V.employees.map(ss=>({user_id:be.id,company_id:o.id,company_name:o.name,name:ss.name,title:ss.title||null,email:ss.email||null,status:null,contact_date:null,follow_up_date:null,specialer:null})),{error:Be}=await C.from("headhunter_contacts").insert(Me);
123if(Be)throw Be;x({title:s("headhunters.toast.employeesImported"),description:s("headhunters.toast.employeesImportedCount",{count:V.employees.length,name:o.name})}),M({id:o.id,name:o.name})}else x({title:s("headhunters.toast.noEmployeesFound"),description:s("headhunters.toast.noEmployeesFoundDesc")})}catch(V){console.error("Error analyzing and adding contacts:",V),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotSearchEmployees"),variant:"destructive"})}finally{O(null)}},Ee=async()=>{if(!pe.headhunter)return;const o=pe.employees.filter(V=>V.selected);if(o.length===0){x({title:s("headhunters.toast.noneSelected"),description:s("headhunters.toast.selectAtLeastOne"),variant:"destructive"});return}E(!0);try{const{data:{user:V}}=await C.auth.getUser();if(!V)throw new Error("Not logged in");const W=parseInt(pe.headhunter.id.replace(/-/g,"").substring(0,8),16),be=o.map(Be=>({user_id:V.id,company_id:W,company_name:pe.headhunter.name,name:Be.name,title:Be.title||null,email:Be.email||null,linkedin:Be.linkedin||null,status:null,contact_date:null,follow_up_date:null,specialer:null})),{error:Me}=await C.from("headhunter_contacts").insert(be);if(Me)throw Me;x({title:s("headhunters.toast.employeesImported"),description:s("headhunters.toast.employeesImportedCount",{count:o.length,name:pe.headhunter.name})}),Oe({open:!1,headhunter:null,employees:[]})}catch(V){console.error("Error importing employees:",V),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotImportEmployees"),variant:"destructive"})}finally{E(!1)}},qe=o=>{we(o),ae(o),Ae(null),Ve([])},Ge=async()=>{if(he){cs(!0);try{const{error:o}=await C.from("custom_headhunters").update({name:he.name,type:he.type,specialer:he.specialer,lokation:he.lokation,email:he.email,website:he.website,linkedin:he.linkedin,linkedin_employees:he.linkedin_employees,niche:he.niche,cv_database:he.cv_database}).eq("id",he.id);if(o)throw o;ve(V=>V.map(W=>W.id===he.id?he:W)),we(null),x({title:s("headhunters.toast.changesSaved"),description:s("headhunters.toast.changesSavedDesc",{name:he.name})})}catch(o){console.error("Error updating headhunter:",o),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotSaveChanges"),variant:"destructive"})}finally{cs(!1)}}},He=async()=>{if(!(he!=null&&he.website)){x({title:s("headhunters.toast.noWebsite"),description:s("headhunters.toast.addWebsiteToReanalyze"),variant:"destructive"});return}cs(!0);try{const{data:o,error:V}=await C.functions.invoke("analyze-headhunter-website",{body:{language:a.language,websiteUrl:he.website}});if(V){x({title:s("headhunters.toast.error"),description:V.message||s("headhunters.toast.couldNotReanalyze"),variant:"destructive"});return}if(o!=null&&o.success&&(o!=null&&o.data)){const W=o.data,be={};W.name&&W.name!==he.name&&(be.name=W.name),W.type&&W.type!==he.type&&(be.type=W.type),Array.isArray(W.specialer)&&JSON.stringify(W.specialer)!==JSON.stringify(he.specialer)&&(be.specialer=W.specialer),W.lokation&&W.lokation!==he.lokation&&(be.lokation=W.lokation),W.niche&&W.niche!==he.niche&&(be.niche=W.niche),W.email&&W.email!==he.email&&(be.email=W.email),W.cv_database&&W.cv_database!==he.cv_database&&(be.cv_database=W.cv_database),Object.keys(be).length>0?(Ae(be),x({title:s("headhunters.toast.newDataFoundToast"),description:s("headhunters.toast.newDataFoundDesc",{count:Object.keys(be).length})})):x({title:s("headhunters.toast.noChanges"),description:s("headhunters.toast.noChangesDesc")}),o.employees&&Array.isArray(o.employees)&&o.employees.length>0&&Ve(o.employees.map(Me=>({...Me,selected:!0})))}}catch(o){console.error("Error reanalyzing website:",o),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotReanalyze"),variant:"destructive"})}finally{cs(!1)}},Ze=async()=>{if(!(he!=null&&he.website)){x({title:s("headhunters.toast.noWebsite"),description:s("headhunters.toast.addWebsiteToSearch"),variant:"destructive"});return}ps(!0);try{const{data:o,error:V}=await C.functions.invoke("analyze-headhunter-website",{body:{language:a.language,websiteUrl:he.website}});if(V){x({title:s("headhunters.toast.error"),description:V.message||s("headhunters.toast.couldNotSearchEmployees"),variant:"destructive"});return}o!=null&&o.employees&&Array.isArray(o.employees)&&o.employees.length>0?(Ve(o.employees.map(W=>({...W,selected:!0}))),x({title:s("headhunters.toast.employeesFoundCount"),description:s("headhunters.toast.employeesFoundCountDesc",{count:o.employees.length})}
123)):x({title:s("headhunters.toast.noEmployeesFound"),description:s("headhunters.toast.noEmployeesFoundWebsite")})}catch(o){console.error("Error searching employees:",o),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotSearchEmployees"),variant:"destructive"})}finally{ps(!1)}},Us=o=>{if(!me||!he)return;const V=me[o];if(V!==void 0){we({...he,[o]:V});const W={...me};delete W[o],Ae(Object.keys(W).length>0?W:null)}},le=o=>{if(!me)return;const V={...me};delete V[o],Ae(Object.keys(V).length>0?V:null)},X=()=>{!me||!he||(we({...he,...me}),Ae(null))},L=async()=>{if(!(!he||oe.filter(o=>o.selected).length===0)){E(!0);try{const{data:{user:o}}=await C.auth.getUser();if(!o)throw new Error("Not logged in");const V=parseInt(he.id.replace(/-/g,"").substring(0,8),16),W=oe.filter(Be=>Be.selected),be=W.map(Be=>({user_id:o.id,company_id:V,company_name:he.name,name:Be.name,title:Be.title||null,email:Be.email||null,linkedin:Be.linkedin||null,status:null,contact_date:null,follow_up_date:null,specialer:null})),{error:Me}=await C.from("headhunter_contacts").insert(be);if(Me)throw Me;x({title:s("headhunters.toast.employeesImported"),description:s("headhunters.toast.employeesImportedCount",{count:W.length,name:he.name})}),Ve([])}catch(o){console.error("Error importing employees:",o),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotImportEmployees"),variant:"destructive"})}finally{E(!1)}}},ce=async(o,V)=>{try{const{error:W}=await C.from("custom_headhunters").delete().eq("id",o);if(W)throw W;ve(be=>be.filter(Me=>Me.id!==o)),x({title:s("headhunters.toast.headhunterDeleted"),description:s("headhunters.toast.headhunterDeletedDesc",{name:V})})}catch(W){console.error("Error deleting headhunter:",W),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotDeleteHeadhunter"),variant:"destructive"})}},ys=ze.map((o,V)=>({id:V+1,name:o.name,type:o.type,specialer:o.specialer||[],lokation:o.lokation||"",kontakt:"",email:o.email||"",status:"Aktiv",match:85,website:o.website||"",linkedin:o.linkedin||"",linkedinEmployees:o.linkedin_employees||"",niche:o.niche||"",cvDatabase:o.cv_database||"",globalId:o.id})),Hs=o=>{switch(o){case"Aktiv":return"bg-green-500/10 text-green-600 border-green-500/20";case"Pause":return"bg-yellow-500/10 text-yellow-600 border-yellow-500/20";case"Ny":return"bg-blue-500/10 text-blue-600 border-blue-500/20";default:return"bg-muted text-muted-foreground"}},Os=async o=>{const V=p.includes(o);jn(V?"headhunter_favorite_removed":"headhunter_favorite_added","headhunter",{company_id:o}),j(W=>V?W.filter(be=>be!==o):[...W,o]),x({title:s(V?"headhunters.toast.removedFromFavorites":"headhunters.toast.addedToFavorites"),description:s(V?"headhunters.toast.removedFromFavoritesDesc":"headhunters.toast.addedToFavoritesDesc")});try{const{data:{user:W}}=await C.auth.getUser();if(!W){j(be=>V?[...be,o]:be.filter(Me=>Me!==o)),x({title:s("headhunters.toast.notLoggedIn"),description:s("headhunters.toast.loginToSave"),variant:"destructive"});return}V?await C.from("headhunter_favorites").delete().eq("user_id",W.id).eq("company_id",o):await C.from("headhunter_favorites").upsert({user_id:W.id,company_id:o},{onConflict:"user_id,company_id"})}catch(W){console.error("Error toggling favorite:",W),j(be=>V?[...be,o]:be.filter(Me=>Me!==o))}},Ls=ys.filter(o=>{if(t!=="alle"){const W={executive:"Executive Search",selection:"Search & Selection",staffing:"Vikar & Staffing"}[t];if(W&&o.type!==W)return!1}if(g&&!p.includes(o.id)||S&&!N.includes(o.id))return!1;if(l){const V=l.toLowerCase();return o.name.toLowerCase().includes(V)||o.type.toLowerCase().includes(V)||o.lokation.toLowerCase().includes(V)||o.kontakt.toLowerCase().includes(V)||o.specialer.some(W=>W.toLowerCase().includes(V))}return!0}).sort((o,V)=>{if(!S)return 0;const W=N.indexOf(o.id),be=N.indexOf(V.id);return W-be});if($)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>K(!1),className:"gap-2",children:[e.jsx(Yn,{className:"w-4 h-4 rotate-180"}),s("headhunters.back")]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(Ps,{className:"w-5 h-5 text-yellow-500 fill-yellow-400"}),js(a.language)?"Selected Contacts":"Udvalgte Kontakter"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:js(a.language)?"Contacts marked with ★ for your dashboard":"Kontakter markeret med ★ til dit dashboard"})]})]}),e.jsx(pc,{embedded:!0})]});if(Q)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>k(!1),className:"gap-2",children:[e.jsx(Yn,{className:"w-4 h-4 rotate-180"}),s("headhunters.back")]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(gt,{className:"w-5 h-5 text-primary"}),s("headhunters.followUpTitle")]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.followUpSubtitle")})]})]}),e.jsx(pu,{onSelectCompany:o=>{k(!1),M(o)}})]});if(B){const o=()=>{p.includes(B.id)||Os(B.id)};return e.jsx(xu,{companyName:B.name,companyId:B.id,onBack:()=>M(null),onAddToFavorites:o})}return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground flex items-center justify-center gap-2",children:[e.jsx(ut,{className:"w-6 h-6 text-primary"}),s("headhunters.title")]}),e.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:s("headhunters.subtitle")}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4 text-sm text-muted-foreground max-w-2xl mx-auto bg-muted/50 border border-border/50 rounded-lg px-4 py-3",children:[e.jsx(ha,{className:"w-4 h-4 flex-shrink-0 text-primary/60"}),e.jsx("p",{className:"italic",children:s("headhunters.disclaimer")})]})]}),e.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:e.jsxs(h,{variant:"outline",className:"gap-2",onClick:()=>K(!0),children:[e.jsx(Ps,{className:"w-4 h-4 fill-yellow-400 text-yellow-500"}),js(a.language)?"Selected Contacts":"Udvalgte Kontakter"]})}),e.jsx(Mt,{open:n,onOpenChange:d,children:e.jsxs(ye,{className:"bg-gradient-to-r from-primary/5 to-primary/10 border-primary/20 overflow-hidden",children:[e.jsx($t,{asChild:!0,children:e.jsxs("button",{className:"w-full p-6 flex items-center justify-between text-left hover:bg-primary/5 transition-colors",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(wt,{className:"w-5 h-5 text-primary"}),s("headhunters.guideTitle")]}),e.jsx(Ts,{className:`w-5 h-5 text-muted-foreground transition-transform duration-200 ${n?"rotate-180":""}`})]})}),e.jsx(Rt,{children:e.jsxs("div",{className:"px-6 pb-6 space-y-6 text-foreground",children:[e.jsx("p",{className:"text-muted-foreground",children:s("headhunters.guide.intro")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.guide.section1Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:s("headhunters.guide.section1P1")}}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.section1P2")}),e.jsx("p",{className:"text-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:s("headhunters.guide.section1P3")}})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.guide.section2Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.section2P1")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.section2P2")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.guide.section2Li1")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.guide.section2Li2")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.guide.section2Li3")}})]}),e.jsx("p",{className:"text-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:s("headhunters.guide.section2P3")}})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.guide.section3Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.section3Intro")}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"font-medium text-primary",children:s("headhunters.guide.contact1Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.contact1P1")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.contact1P2")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.guide.contact1Li1")}),e.jsx("li",{children:s("headhunters.guide.contact1Li2")}),e.jsx("li",{children:s("headhunters.guide.contact1Li3")}),e.jsx("li",{children:s("headhunters.guide.contact1Li4")}
123)]})]}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"font-medium text-primary",children:s("headhunters.guide.contact2Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.contact2P1")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.guide.contact2Li1")}),e.jsx("li",{children:s("headhunters.guide.contact2Li2")}),e.jsx("li",{children:s("headhunters.guide.contact2Li3")}),e.jsx("li",{children:s("headhunters.guide.contact2Li4")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.contact2P2")})]}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"font-medium text-primary",children:s("headhunters.guide.contact3Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.contact3P1")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.guide.contact3Li1")}),e.jsx("li",{children:s("headhunters.guide.contact3Li2")}),e.jsx("li",{children:s("headhunters.guide.contact3Li3")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.contact3P2")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.guide.combinedTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.combinedIntro")}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:s("headhunters.guide.col1Title")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[e.jsx("li",{children:s("headhunters.guide.col1Li1")}),e.jsx("li",{children:s("headhunters.guide.col1Li2")}),e.jsx("li",{children:s("headhunters.guide.col1Li3")})]})]}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:s("headhunters.guide.col2Title")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[e.jsx("li",{children:s("headhunters.guide.col2Li1")}),e.jsx("li",{children:s("headhunters.guide.col2Li2")}),e.jsx("li",{children:s("headhunters.guide.col2Li3")})]})]}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:s("headhunters.guide.col3Title")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[e.jsx("li",{children:s("headhunters.guide.col3Li1")}),e.jsx("li",{children:s("headhunters.guide.col3Li2")}),e.jsx("li",{children:s("headhunters.guide.col3Li3")})]})]})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("headhunters.guide.conclusionTitle")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 mt-2",children:[e.jsx("li",{children:s("headhunters.guide.conclusionLi1")}),e.jsx("li",{children:s("headhunters.guide.conclusionLi2")}),e.jsx("li",{children:s("headhunters.guide.conclusionLi3")})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.guide.section4Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.section4P1")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.guide.section4Li1")}),e.jsx("li",{children:s("headhunters.guide.section4Li2")}),e.jsx("li",{children:s("headhunters.guide.section4Li3")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.guide.section4P2")})]})]})})]})}),e.jsx(Mt,{open:m,onOpenChange:c,children:e.jsxs(ye,{className:"bg-gradient-to-r from-primary/5 to-primary/10 border-primary/20 overflow-hidden",children:[e.jsx($t,{asChild:!0,children:e.jsxs("button",{className:"w-full p-6 flex items-center justify-between text-left hover:bg-primary/5 transition-colors",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(ht,{className:"w-5 h-5 text-primary"}),s("headhunters.staffingGuideTitle")]}),e.jsx(Ts,{className:`w-5 h-5 text-muted-foreground transition-transform duration-200 ${m?"rotate-180":""}`})]})}),e.jsx(Rt,{children:e.jsxs("div",{className:"px-6 pb-6 space-y-6 text-foreground",children:[e.jsx("p",{className:"text-muted-foreground",children:s("headhunters.staffingGuide.intro")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.staffingGuide.section1Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section1P1")}}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section1P2")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section1Li1")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section1Li2")}}),e.jsx("li",{children:s("headhunters.staffingGuide.section1Li3")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section1P3")}})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.staffingGuide.section2Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section2P1")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section2Li1")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section2Li2")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section2Li3")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section2Li4")}})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section2P2")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.staffingGuide.section3Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section3P1")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section3Li1")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section3Li2")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section3Li3")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.section3Li4")}})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section3P2")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.staffingGuide.section4Title")}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"font-medium text-primary",children:s("headhunters.staffingGuide.contact1Title")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.staffingGuide.contact1Li1")}),e.jsx("li",{children:s("headhunters.staffingGuide.contact1Li2")}),e.jsx("li",{children:s("headhunters.staffingGuide.contact1Li3")})]})]}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"font-medium text-primary",children:s("headhunters.staffingGuide.contact2Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.contact2P1")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.staffingGuide.contact2Li1")}),e.jsx("li",{children:s("headhunters.staffingGuide.contact2Li2")}),e.jsx("li",{children:s("headhunters.staffingGuide.contact2Li3")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.contact2P2")})]}),e.jsxs("div",{className:"bg-background rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"font-medium text-primary",children:s("headhunters.staffingGuide.contact3Title")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.staffingGuide.contact3Li1")}),e.jsx("li",{children:s("headhunters.staffingGuide.contact3Li2")}),e.jsx("li",{children:s("headhunters.staffingGuide.contact3Li3")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",dangerouslySetInnerHTML:{__html:s("headhunters.staffingGuide.contact3P1")}})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.staffingGuide.section5Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section5P1")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section5P2")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.staffingGuide.section5Li1")}),e.jsx("li",{children:s("headhunters.staffingGuide.section5Li2")}),e.jsx("li",{children:s("headhunters.staffingGuide.section5Li3")}),e.jsx("li",{children:s("headhunters.staffingGuide.section5Li4")}
123)]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section5P3")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-base font-semibold",children:s("headhunters.staffingGuide.section6Title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section6P1")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 ml-4",children:[e.jsx("li",{children:s("headhunters.staffingGuide.section6Li1")}),e.jsx("li",{children:s("headhunters.staffingGuide.section6Li2")}),e.jsx("li",{children:s("headhunters.staffingGuide.section6Li3")}),e.jsx("li",{children:s("headhunters.staffingGuide.section6Li4")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.staffingGuide.section6P2")})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-4 mt-4",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("headhunters.staffingGuide.summaryTitle")}),e.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 mt-2",children:[e.jsx("li",{children:s("headhunters.staffingGuide.summaryLi1")}),e.jsx("li",{children:s("headhunters.staffingGuide.summaryLi2")}),e.jsx("li",{children:s("headhunters.staffingGuide.summaryLi3")}),e.jsx("li",{children:s("headhunters.staffingGuide.summaryLi4")})]})]})]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ut,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ue,{placeholder:s("headhunters.searchPlaceholder"),value:l,onChange:o=>f(o.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:t==="alle"?"default":"outline",size:"sm",onClick:()=>r("alle"),children:s("headhunters.all")}),e.jsx(h,{variant:t==="executive"?"default":"outline",size:"sm",onClick:()=>r("executive"),children:"Executive Search"}),e.jsx(h,{variant:t==="selection"?"default":"outline",size:"sm",onClick:()=>r("selection"),children:"Search & Selection"}),e.jsx(h,{variant:t==="staffing"?"default":"outline",size:"sm",onClick:()=>r("staffing"),children:s("headhunters.vikarStaffing")}),e.jsx("div",{className:"w-px bg-border mx-1"}),e.jsxs(h,{variant:g?"default":"outline",size:"sm",onClick:()=>P(!g),className:"gap-1",children:[e.jsx(kn,{className:`w-4 h-4 ${g?"fill-current":""}`}),s("headhunters.favorites")," (",p.length,")"]}),e.jsxs(h,{variant:S?"default":"outline",size:"sm",onClick:()=>A(!S),className:"gap-1",title:js(a.language)?"Recently viewed headhunters":"Senest viste headhuntere",children:[e.jsx(ba,{className:"w-4 h-4"}),js(a.language)?"Recent":"Seneste"," (",N.length,")"]}),e.jsx("div",{className:"w-px bg-border mx-1"}),e.jsxs(h,{variant:"secondary",size:"sm",onClick:()=>De(!0),className:"gap-1",children:[e.jsx(wt,{className:"w-4 h-4"}),s("headhunters.suggest")]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(tt,{className:"w-5 h-5 text-primary"}),s("headhunters.recommendedForProfile")," (",Ls.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Ls.length===0?e.jsxs("div",{className:"col-span-full text-center py-8 text-muted-foreground",children:[e.jsx(Ut,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:s("headhunters.noHeadhuntersFound")}),e.jsx("p",{className:"text-sm",children:s("headhunters.noHeadhuntersFoundSub")})]}):Ls.map(o=>e.jsxs(ye,{className:"p-5 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-foreground text-lg",children:o.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(je,{variant:"secondary",className:"text-xs",children:o.type}),o.niche&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",o.niche]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>Os(o.id),className:"p-1.5 rounded-full hover:bg-muted transition-colors",title:p.includes(o.id)?s("headhunters.removeFavorite"):s("headhunters.addToFavorites"),children:e.jsx(kn,{className:`w-5 h-5 transition-colors ${p.includes(o.id)?"fill-red-500 text-red-500":"text-muted-foreground hover:text-red-500"}`})}),e.jsx(je,{className:Hs(o.status),children:s(`headhunters.statusLabels.${o.status}`,o.status)}),e.jsxs(je,{className:"bg-primary/10 text-primary border-primary/20",children:[o.match,"% ",s("headhunters.match")]})]})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ia,{className:"w-4 h-4"}),o.lokation]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2 border-t border-border/50",children:[o.website&&e.jsxs("a",{href:o.website,target:"_blank",rel:"noopener noreferrer",onClick:()=>U({companyId:o.id}),className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(xn,{className:"w-3 h-3"}),"Website"]}),o.linkedin&&e.jsxs("a",{href:o.linkedin,target:"_blank",rel:"noopener noreferrer",onClick:()=>U({companyId:o.id}),className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(Ms,{className:"w-3 h-3"}),"LinkedIn"]}),o.linkedinEmployees&&e.jsxs("a",{href:o.linkedinEmployees,target:"_blank",rel:"noopener noreferrer",onClick:()=>U({companyId:o.id}),className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(tt,{className:"w-3 h-3"}),s("headhunters.seeEmployees")]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:o.specialer.map((V,W)=>e.jsx(je,{variant:"outline",className:"text-xs",children:V},W))}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.website&&e.jsxs(h,{size:"sm",variant:"outline",className:"w-full gap-2",disabled:F===o.id,onClick:()=>Fe({id:o.id,name:o.name,website:o.website,globalId:o.globalId}),children:[F===o.id?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(Ut,{className:"w-4 h-4"}),F===o.id?s("headhunters.analyzing"):s("headhunters.analyzeAndAddContacts")]}),e.jsxs(h,{size:"sm",className:"w-full gap-2",onClick:()=>{U({companyId:o.id}),M({id:o.id,name:o.name})},children:[e.jsx(tt,{className:"w-4 h-4"}),s("headhunters.addPersonsAndStatus")]})]})]},o.id))})]}),ze.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(ut,{className:"w-5 h-5 text-primary"}),s("headhunters.recommendedHeadhunters")," (",ze.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:ze.map(o=>e.jsxs(ye,{className:"p-5 hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-foreground text-lg",children:o.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(je,{variant:"secondary",className:"text-xs",children:o.type}),o.niche&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",o.niche]})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[o.lokation&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ia,{className:"w-4 h-4"}),o.lokation]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2 border-t border-border/50",children:[o.website&&e.jsxs("a",{href:o.website,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(xn,{className:"w-3 h-3"}),"Website"]}),o.linkedin&&e.jsxs("a",{href:o.linkedin,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(Ms,{className:"w-3 h-3"}),"LinkedIn"]})]})]}),o.specialer&&o.specialer.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:o.specialer.map((V,W)=>e.jsx(je,{variant:"outline",className:"text-xs",children:V},W))}),e.jsxs(h,{size:"sm",className:"w-full gap-2",onClick:()=>{U({customHeadhunterId:o.id}),M({id:parseInt(o.id.replace(/-/g,"").substring(0,8),16),name:o.name})},children:[e.jsx(tt,{className:"w-4 h-4"}),s("headhunters.addContacts")]})]},o.id))})]}),re.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Ps,{className:"w-5 h-5 text-primary"}),s("headhunters.yourOwnHeadhunters")," (",re.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:re.map(o=>e.jsxs(ye,{className:"p-5 hover:shadow-md transition-shadow border-primary/20",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-foreground text-lg",children:o.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(je,{variant:"secondary",className:"text-xs",children:o.type}),o.niche&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",o.niche]}),e.jsx(je,{className:"bg-primary/10 text-primary border-primary/20 text-xs",children:s("headhunters.own")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>qe(o),title:s("headhunters.edit"),children:e.jsx(Ma,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>ce(o.id,o.name),title:s("headhunters.delete"),children:e.jsx(Ss,{className:"w-4 h-4 text-destructive"})})]})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[o.lokation&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ia,{className:"w-4 h-4"}),o.lokation]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2 border-t border-border/50",children:[o.website&&e.jsxs("a",{href:o.website,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(xn,{className:"w-3 h-3"}),"Website"]}),o.linkedin&&e.jsxs("a",{href:o.linkedin,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(Ms,{className:"w-3 h-3"}),"LinkedIn"]}),o.linkedin_employees&&e.jsxs("a",{href:o.linkedin_employees,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(tt,{className:"w-3 h-3"}),s("headhunters.seeEmployees")]})]})]}),o.specialer&&o.specialer.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:o.specialer.map((V,W)=>e.jsx(je,{variant:"outline",className:"text-xs",children:V},W))}),e.jsxs("div",{className:"flex gap-2",children:[o.website&&e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>G(o),disabled:ee===o.id,children:[ee===o.id?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(Ut,{className:"w-4 h-4"}),s("headhunters.searchEmployees")]}),e.jsxs(h,{size:"sm",className:"flex-1 gap-2",onClick:()=>{U({customHeadhunterId:o.id}),M({id:parseInt(o.id.replace(/-/g,"").substring(0,8),16),name:o.name})},children:[e.jsx(tt,{className:"w-4 h-4"}),s("headhunters.addPersons")]})]})]},o.id))})]}),e.jsx(ns,{open:pe.open,onOpenChange:o=>{o||Oe({open:!1,headhunter:null,employees:[]})},children:e.jsxs(rs,{className:"max-w-lg",children:[e.jsx(os,{children:e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"w-5 h-5 text-primary"}),s("headhunters.foundEmployeesAt",{name:(Bs=pe.headhunter)==null?void 0:Bs.name})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.selectedOfTotal",{selected:pe.employees.filter(o=>o.selected).length,total:pe.employees.length})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:()=>Oe(o=>({...o,employees:o.employees.map(V=>({...V,selected:!0}))}
123)),children:s("headhunters.selectAll")}),e.jsx(h,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:()=>Oe(o=>({...o,employees:o.employees.map(V=>({...V,selected:!1}))})),children:s("headhunters.deselectAll")})]})]}),e.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:pe.employees.map((o,V)=>e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-md border transition-colors ${o.selected?"bg-primary/5 border-primary/30":"bg-muted/30 border-border opacity-60"}`,children:[e.jsx(Kt,{checked:o.selected,onCheckedChange:W=>{Oe(be=>({...be,employees:be.employees.map((Me,Be)=>Be===V?{...Me,selected:!!W}:Me)}))}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),o.title&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:o.title})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[o.email&&e.jsxs(je,{variant:"outline",className:"text-xs",children:[e.jsx(ua,{className:"w-3 h-3 mr-1"}),"Email"]}),o.linkedin&&e.jsxs(je,{variant:"outline",className:"text-xs",children:[e.jsx(Ms,{className:"w-3 h-3 mr-1"}),"LinkedIn"]})]})]},V))}),e.jsxs(h,{onClick:Ee,className:"w-full",disabled:I||pe.employees.filter(o=>o.selected).length===0,children:[I&&e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}),pe.employees.filter(o=>o.selected).length!==1?s("headhunters.importEmployeesCountPlural",{count:pe.employees.filter(o=>o.selected).length}):s("headhunters.importEmployeesCount",{count:1})]})]})]})}),e.jsx(ns,{open:!!he,onOpenChange:o=>{o||we(null)},children:e.jsxs(rs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(Ma,{className:"w-5 h-5 text-primary"}),s("headhunters.editHeadhunterTitle")]})}),he&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(se,{htmlFor:"edit-name",children:[s("headhunters.companyName")," *"]}),e.jsx(ue,{id:"edit-name",value:he.name,onChange:o=>we({...he,name:o.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-type",children:s("headhunters.type")}),e.jsxs("select",{id:"edit-type",value:he.type,onChange:o=>we({...he,type:o.target.value}),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"Executive Search",children:"Executive Search"}),e.jsx("option",{value:"Search & Selection",children:"Search & Selection"}),e.jsx("option",{value:"Vikar & Staffing",children:"Vikar & Staffing"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-lokation",children:s("headhunters.location")}),e.jsx(ue,{id:"edit-lokation",value:he.lokation||"",onChange:o=>we({...he,lokation:o.target.value||null}),placeholder:"F.eks. København"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-specialer",children:s("headhunters.specialties")}),e.jsx(ue,{id:"edit-specialer",value:((ie=he.specialer)==null?void 0:ie.join(", "))||"",onChange:o=>we({...he,specialer:o.target.value?o.target.value.split(",").map(V=>V.trim()):[]}),placeholder:"IT, Finans, Ledelse"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-niche",children:s("headhunters.niche")}),e.jsx(ue,{id:"edit-niche",value:he.niche||"",onChange:o=>we({...he,niche:o.target.value||null}),placeholder:"F.eks. Tech startups"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-email",children:s("headhunters.email")}),e.jsx(ue,{id:"edit-email",type:"email",value:he.email||"",onChange:o=>we({...he,email:o.target.value||null}),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-website",children:s("headhunters.website")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ue,{id:"edit-website",value:he.website||"",onChange:o=>we({...he,website:o.target.value||null}),placeholder:"https://...",className:"flex-1"}),e.jsx(h,{variant:"outline",size:"icon",onClick:He,disabled:Xe||!he.website,title:s("headhunters.reanalyzeWebsite"),children:Xe?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(Ut,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("headhunters.reanalyzeHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-linkedin",children:s("headhunters.linkedInCompany")}),e.jsx(ue,{id:"edit-linkedin",value:he.linkedin||"",onChange:o=>we({...he,linkedin:o.target.value||null}),placeholder:"https://linkedin.com/company/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-linkedin-employees",children:s("headhunters.linkedInEmployees")}),e.jsx(ue,{id:"edit-linkedin-employees",value:he.linkedin_employees||"",onChange:o=>we({...he,linkedin_employees:o.target.value||null}),placeholder:"https://linkedin.com/company/.../people/"})]}),me&&Object.keys(me).length>0&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 rounded-lg border border-yellow-500/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[e.jsx(ha,{className:"w-4 h-4 text-yellow-600"}),s("headhunters.newDataFound",{count:Object.keys(me).length})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:X,children:s("headhunters.acceptAll")})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(me).map(([o,V])=>{const W=s(`headhunters.fieldLabels.${o}`,o),be=T==null?void 0:T[o],Me=Array.isArray(be)?be.join(", "):be||s("headhunters.empty"),Be=Array.isArray(V)?V.join(", "):V;return e.jsxs("div",{className:"p-2 bg-background rounded border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-medium",children:W}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(h,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-green-600 hover:text-green-700",onClick:()=>Us(o),children:s("headhunters.accept")}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-destructive",onClick:()=>le(o),children:s("headhunters.reject")})]})]}),e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("div",{className:"text-muted-foreground line-through",children:Me}),e.jsx("div",{className:"text-green-600 font-medium",children:Be})]})]},o)})})]}),e.jsx("div",{className:"pt-2 border-t border-border",children:e.jsxs(h,{variant:"outline",className:"w-full gap-2",onClick:Ze,disabled:hs||!he.website,children:[hs?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(tt,{className:"w-4 h-4"}),s("headhunters.searchEmployeesOnWebsite")]})}),oe.length>0&&e.jsxs("div",{className:"p-4 bg-green-500/10 rounded-lg border border-green-500/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4 text-green-600"}),s("headhunters.foundEmployees",{count:oe.filter(o=>o.selected).length})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:()=>Ve(oe.map(o=>({...o,selected:!0}))),children:s("headhunters.selectAll")}),e.jsx(h,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:()=>Ve(oe.map(o=>({...o,selected:!1}))),children:s("headhunters.deselectAll")})]})]}),e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:oe.map((o,V)=>e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-md border transition-colors ${o.selected?"bg-background border-green-500/50":"bg-muted/30 border-border opacity-60"}`,children:[e.jsx(Kt,{checked:o.selected,onCheckedChange:W=>{Ve(oe.map((be,Me)=>Me===V?{...be,selected:!!W}:be))}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),o.title&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:o.title})]})]},V))}),e.jsxs(h,{onClick:L,className:"w-full mt-3",disabled:I||oe.filter(o=>o.selected).length===0,children:[I&&e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}),oe.filter(o=>o.selected).length!==1?s("headhunters.importEmployeesCountPlural",{c
123ount:oe.filter(o=>o.selected).length}):s("headhunters.importEmployeesCount",{count:1})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(h,{variant:"outline",onClick:()=>{we(null),ae(null),Ae(null),Ve([])},className:"flex-1",children:s("headhunters.cancel")}),e.jsxs(h,{onClick:Ge,className:"flex-1",disabled:Xe||!he.name.trim(),children:[Xe&&e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}),s("headhunters.saveChanges")]})]})]})]})}),e.jsx(ns,{open:ms,onOpenChange:o=>{o||(De(!1),ne({name:"",website:"",type:"Executive Search",location:"",notes:""}))},children:e.jsxs(rs,{className:"max-w-md max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(wt,{className:"w-5 h-5 text-primary"}),s("headhunters.suggestTitle")]})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("headhunters.suggestDescription")}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsxs(se,{children:[s("headhunters.suggestName")," *"]}),e.jsx(ue,{placeholder:s("headhunters.suggestNamePlaceholder"),value:H.name,onChange:o=>ne(V=>({...V,name:o.target.value}))})]}),e.jsxs("div",{children:[e.jsx(se,{children:s("headhunters.suggestWebsite")}),e.jsx(ue,{placeholder:"https://...",value:H.website,onChange:o=>ne(V=>({...V,website:o.target.value}))})]}),e.jsxs("div",{children:[e.jsx(se,{children:s("headhunters.suggestType")}),e.jsxs("select",{className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
123ing-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",value:H.type,onChange:o=>ne(V=>({...V,type:o.target.value})),children:[e.jsx("option",{value:"Executive Search",children:"Executive Search"}),e.jsx("option",{value:"Search & Selection",children:"Search & Selection"}),e.jsx("option",{value:"Vikar & Staffing",children:"Vikar & Staffing"})]})]}),e.jsxs("div",{children:[e.jsx(se,{children:s("headhunters.suggestLocation")}),e.jsx(ue,{placeholder:s("headhunters.suggestLocationPlaceholder"),value:H.location,onChange:o=>ne(V=>({...V,location:o.target.value}))})]}),e.jsxs("div",{children:[e.jsx(se,{children:s("headhunters.suggestNotes")}),e.jsx(ue,{placeholder:s("headhunters.suggestNotesPlaceholder"),value:H.notes,onChange:o=>ne(V=>({...V,notes:o.target.value}))})]}),e.jsxs(h,{className:"w-full",disabled:!H.name.trim()||_,onClick:async()=>{Z(!0);try{const{error:o}=await C.functions.invoke("suggest-headhunter",{body:H});if(o)throw o;x({title:s("headhunters.toast.thankYou"),description:s("headhunters.toast.thankYouDesc")}),De(!1),ne({name:"",website:"",type:"Executive Search",location:"",notes:""})}catch(o){console.error(o),x({title:s("headhunters.toast.error"),description:s("headhunters.toast.couldNotSendSuggestion"),variant:"destructive"})}finally{Z(!1)}},children:[_&&e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}),s("headhunters.sendSuggestion")]})]})]})})]})},fu=({companyName:s,companyId:a,onBack:t})=>{const{t:r,i18n:n}=Je(),[d,m]=i.useState([]),[c,l]=i.useState(!0),[f,p]=i.useState(!1),[j,g]=i.useState(null),[P,N]=i.useState(!1),{toast:w}=Ct(),[S,A]=i.useState({name:"",title:"",linkedin:"",phone:"",email:"",contact_date:"",follow_up_date:"",status:"",notes:""});i.useEffect(()=>{y()},[a]),i.useEffect(()=>{d.length>0&&D()},[d]);const y=async()=>{try{const{data:{user:k}}=await C.auth.getUser();if(!k){l(!1);return}const{data:$,error:K}=await C.from("dream_company_contacts").select("*").eq("company_id",a).eq("user_id",k.id).order("created_at",{ascending:!1});if(K)throw K;m($||[])}catch(k){console.error("Error fetching contacts:",k),w({title:r("dreamCompanyContacts.toast.error"),description:r("dreamCompanyContacts.toast.couldNotFetch"),variant:"destructive"})}finally{l(!1)}},D=()=>{const k=new Date,$=d.filter(K=>{if(!K.follow_up_date)return!1;const ve=new Date(K.follow_up_date).getTime()-k.getTime(),ze=Math.ceil(ve/(1e3*60*60*24));return ze>=0&&ze<=7});if($.length>0){const K=$.filter(re=>new Date(re.follow_up_date)<=k).length;K>0&&w({title:r("dreamCompanyContacts.toast.overdueFollowUps"),description:r("dreamCompanyContacts.toast.overdueFollowUpsDesc",{count:K}),variant:"destructive"})}},B=async()=>{if(!S.name.trim()){w({title:r("dreamCompanyContacts.toast.error"),description:r("dreamCompanyContacts.toast.nameRequired"),variant:"destructive"});return}N(!0);try{const{data:{user:k}}=await C.auth.getUser();if(!k)throw new Error(r("dreamCompanyContacts.toast.notLoggedIn"));const{data:$,error:K}=await C.from("dream_company_contacts").insert({user_id:k.id,company_id:a,name:S.name,title:S.title||null,linkedin:S.linkedin||null,phone:S.phone||null,email:S.email||null,contact_date:S.contact_date||null,follow_up_date:S.follow_up_date||null,status:S.status||null,notes:S.notes||null}).select().single();if(K)throw K;m(re=>[$,...re]),A({name:"",title:"",linkedin:"",phone:"",email:"",contact_date:"",follow_up_date:"",status:"",notes:""}),p(!1),w({title:r("dreamCompanyContacts.toast.contactAdded"),description:r("dreamCompanyContacts.toast.contactAddedDesc",{name:$.name})})}catch(k){console.error("Error adding contact:",k),w({title:r("dreamCompanyContacts.toast.error"),description:r("dreamCompanyContacts.toast.couldNotAdd"),variant:"destructive"})}finally{N(!1)}},M=async()=>{if(j){N(!0);try{const{error:k}=await C.from("dream_company_contacts").update({name:j.name,title:j.title,linkedin:j.linkedin,phone:j.phone,email:j.email,contact_date:j.contact_date,follow_up_date:j.follow_up_date,status:j.status,notes:j.notes}).eq("id",j.id);if(k)throw k;m($=>$.map(K=>K.id===j.id?j:K)),g(null),w({title:r("dreamCompanyContacts.toast.contactUpdated"),description:r("dreamCompanyContacts.toast.contactUpdatedDesc")})}catch(k){console.error("Error updating contact:",k),w({title:r("dreamCompanyContacts.toast.error"),description:r("dreamCompanyContacts.toast.couldNotUpdate"),variant:"destructive"})}finally{N(!1)}}},Y=async(k,$)=>{try{const{error:K}=await C.from("dream_company_contacts").update({is_selected:!$}).eq("id",k);if(K)throw K;m(re=>re.map(ve=>ve.id===k?{...ve,is_selected:!$}:ve)),w({title:r($?"contactDashboard.removedFromSelected":"contactDashboard.addedToSelected")})}catch(K){console.error("Error toggling selected:",K)}},R=async(k,$)=>{try{const{error:K}=await C.from("dream_company_contacts").delete().eq("id",k);if(K)throw K;m(re=>re.filter(ve=>ve.id!==k)),w({title:r("dreamCompanyContacts.toast.contactDeleted"),description:r("dreamCompanyContacts.toast.contactDeletedDesc",{name:$})})}
123catch(K){console.error("Error deleting contact:",K),w({title:r("dreamCompanyContacts.toast.error"),description:r("dreamCompanyContacts.toast.couldNotDelete"),variant:"destructive"})}},Q=k=>{if(!k)return null;const $=new Date;$.setHours(0,0,0,0);const K=new Date(k);K.setHours(0,0,0,0);const re=K.getTime()-$.getTime(),ve=Math.ceil(re/(1e3*60*60*24));return ve<0?e.jsxs(je,{variant:"destructive",className:"gap-1",children:[e.jsx(wa,{className:"w-3 h-3"}),r("dreamCompanyContacts.overdue",{days:Math.abs(ve)})]}):ve===0?e.jsxs(je,{className:"bg-orange-500/10 text-orange-600 border-orange-500/20 gap-1",children:[e.jsx(ra,{className:"w-3 h-3"}),r("dreamCompanyContacts.today")]}):ve<=7?e.jsxs(je,{className:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20 gap-1",children:[e.jsx(ra,{className:"w-3 h-3"}),ve===1?r("dreamCompanyContacts.inDay",{days:ve}):r("dreamCompanyContacts.inDays",{days:ve})]}):null};return c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(h,{variant:"ghost",size:"sm",onClick:t,className:"gap-2",children:[e.jsx(_n,{className:"w-4 h-4"}),r("dreamCompanyContacts.back")]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(ut,{className:"w-5 h-5 text-primary"}),r("dreamCompanyContacts.contactsAt",{name:s})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("dreamCompanyContacts.manageContacts")})]})]}),e.jsxs(ns,{open:f,onOpenChange:p,children:[e.jsx(Na,{asChild:!0,children:e.jsxs(h,{className:"gap-2",children:[e.jsx(fs,{className:"w-4 h-4"}),r("dreamCompanyContacts.addNewContact")]})}),e.jsxs(rs,{className:"max-w-md",children:[e.jsx(os,{children:e.jsx(is,{children:r("dreamCompanyContacts.addContactTitle")})}),e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"name",children:r("dreamCompanyContacts.nameLabel")}),e.jsx(ue,{id:"name",value:S.name,onChange:k=>A($=>({...$,name:k.target.value})),placeholder:r("dreamCompanyContacts.namePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"title",children:r("dreamCompanyContacts.titleLabel")}),e.jsx(ue,{id:"title",value:S.title,onChange:k=>A($=>({...$,title:k.target.value})),placeholder:r("dreamCompanyContacts.titlePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"linkedin",children:r("dreamCompanyContacts.linkedinLabel")}),e.jsx(ue,{id:"linkedin",value:S.linkedin,onChange:k=>A($=>({...$,linkedin:k.target.value})),placeholder:"https://linkedin.com/in/..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"phone",children:r("dreamCompanyContacts.phoneLabel")}),e.jsx(ue,{id:"phone",value:S.phone,onChange:k=>A($=>({...$,phone:k.target.value})),placeholder:"+45..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"email",children:r("dreamCompanyContacts.emailLabel")}),e.jsx(ue,{id:"email",type:"email",value:S.email,onChange:k=>A($=>({...$,email:k.target.value})),placeholder:"[email protected]"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"contact_date",children:r("dreamCompanyContacts.contactDateLabel")}),e.jsx(ue,{id:"contact_date",type:"date",value:S.contact_date,onChange:k=>A($=>({...$,contact_date:k.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"follow_up_date",children:r("dreamCompanyContacts.followUpLabel")}),e.jsx(ue,{id:"follow_up_date",type:"date",value:S.follow_up_date,onChange:k=>A($=>({...$,follow_up_date:k.target.value}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"notes",children:r("dreamCompanyContacts.notesLabel")}),e.jsx(as,{id:"notes",value:S.notes,onChange:k=>A($=>({...$,notes:k.target.value})),placeholder:r("dreamCompanyContacts.notesPlaceholder"),className:"min-h-[60
123px]"})]}),e.jsxs(h,{onClick:B,className:"w-full",disabled:P,children:[P?e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):null,r("dreamCompanyContacts.addContact")]})]})]})]}),e.jsx(ns,{open:!!j,onOpenChange:k=>!k&&g(null),children:e.jsxs(rs,{className:"max-w-md",children:[e.jsx(os,{children:e.jsx(is,{children:r("dreamCompanyContacts.editContactTitle")})}),j&&e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-name",children:r("dreamCompanyContacts.nameLabel")}),e.jsx(ue,{id:"edit-name",value:j.name,onChange:k=>g($=>$?{...$,name:k.target.value}:null)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-title",children:r("dreamCompanyContacts.titleLabel")}),e.jsx(ue,{id:"edit-title",value:j.title||"",onChange:k=>g($=>$?{...$,title:k.target.value}:null)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-linkedin",children:r("dreamCompanyContacts.linkedinLabel")}),e.jsx(ue,{id:"edit-linkedin",value:j.linkedin||"",onChange:k=>g($=>$?{...$,linkedin:k.target.value}:null)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-phone",children:r("dreamCompanyContacts.phoneLabel")}),e.jsx(ue,{id:"edit-phone",value:j.phone||"",onChange:k=>g($=>$?{...$,phone:k.target.value}:null)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-email",children:r("dreamCompanyContacts.emailLabel")}),e.jsx(ue,{id:"edit-email",type:"email",value:j.email||"",onChange:k=>g($=>$?{...$,email:k.target.value}:null)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-contact_date",children:r("dreamCompanyContacts.contactDateLabel")}),e.jsx(ue,{id:"edit-contact_date",type:"date",value:j.contact_date||"",onChange:k=>g($=>$?{...$,contact_date:k.target.value}:null)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-follow_up_date",children:r("dreamCompanyContacts.followUpLabel")}),e.jsx(ue,{id:"edit-follow_up_date",type:"date",value:j.follow_up_date||"",onChange:k=>g($=>$?{...$,follow_up_date:k.target.value}:null)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-notes",children:r("dreamCompanyContacts.notesLabel")}),e.jsx(as,{id:"edit-notes",value:j.notes||"",onChange:k=>g($=>$?{...$,notes:k.target.value}
123:null),className:"min-h-[60px]"})]}),e.jsxs(h,{onClick:M,className:"w-full",disabled:P,children:[P?e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):null,r("dreamCompanyContacts.saveChanges")]})]})]})}),d.length===0?e.jsxs(ye,{className:"p-8 text-center",children:[e.jsx(Ca,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"font-medium text-foreground mb-2",children:r("dreamCompanyContacts.noContactsYet")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:r("dreamCompanyContacts.addContactsFrom",{name:s})})]}):e.jsx("div",{className:"space-y-3",children:d.map(k=>e.jsx(ye,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-foreground",children:k.name}),k.title&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["• ",k.title]}),Q(k.follow_up_date)]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-sm",children:[k.email&&e.jsxs("a",{href:`mailto:${k.email}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(ua,{className:"w-3 h-3"}),k.email]}),k.phone&&e.jsxs("a",{href:`tel:${k.phone}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground",children:[e.jsx(or,{className:"w-3 h-3"}),k.phone]}),k.linkedin&&e.jsxs("a",{href:k.linkedin,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 hover:underline",children:[e.jsx(Ms,{className:"w-3 h-3"}),"LinkedIn"]})]}),(k.contact_date||k.follow_up_date)&&e.jsxs("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[k.contact_date&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gt,{className:"w-3 h-3"}),r("dreamCompanyContacts.contacted")," ",new Date(k.contact_date).toLocaleDateString(Te(n.language)?"da-DK":"en-US")]}),k.follow_up_date&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ra,{className:"w-3 h-3"}),r("dreamCompanyContacts.followUp")," ",new Date(k.follow_up_date).toLocaleDateString(Te(n.language)?"da-DK":"en-US"),e.jsx(Br,{title:`${r("dreamCompanyContacts.followUp")}: ${k.name}`,date:k.follow_up_date,description:`${js(n.language)?"Follow up with":"Opfølgning med"} ${k.name}`})]})]}),k.notes&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted/50 p-2 rounded",children:k.notes})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Y(k.id,k.is_selected),title:k.is_selected?r("contactDashboard.removeFromSelected"):r("contactDashboard.addToSelected"),children:e.jsx(Ps,{className:`w-4 h-4 ${k.is_selected?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>g(k),className:"h-8 w-8",children:e.jsx(Qa,{className:"w-4 h-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>R(k.id,k.name),className:"h-8 w-8 text-destructive hover:text-destructive",children:e.jsx(Ss,{className:"w-4 h-4"})})]})]})},k.id))})]})},no=s=>s>=85?"bg-green-500":s>=75?"bg-emerald-500":s>=65?"bg-yellow-500":"bg-orange-500",ml=s=>s>=85?"bg-green-500/10 text-green-700 border-green-500/30":s>=75?"bg-emerald-500/10 text-emerald-700 border-emerald-500/30":s>=65?"bg-yellow-500/10 text-yellow-700 border-yellow-500/30":"bg-orange-500/10 text-orange-700 border-orange-500/30",Kn=({label:s,icon:a,score:t,reason:r})=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(a,{className:"w-3.5 h-3.5 text-muted-foreground"}),s]}),e.jsxs("span",{className:"text-sm font-bold",children:[t,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${no(t)}`,style:{width:`${t}%`}})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]}),vu=({company:s})=>{const{t:a,i18n:t}=Je(),r=s.match_details;return e.jsxs(ta,{children:[e.jsx(aa,{asChild:!0,children:e.jsxs("button",{type:"button",className:`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-bold cursor-pointer hover:opacity-80 transition-opacity ${ml(s.match_score)}`,children:[s.match_score,"% match",e.jsx(ha,{className:"w-3 h-3 ml-1"})]})}),e.jsx(na,{className:"w-80",align:"start",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-2",children:[e.jsx("h4",{className:"font-semibold",children:a("companyRecommendations.matchScoreDetails")}),e.jsxs(je,{className:`${ml(s.match_score)}`,children:[s.match_score,"%"]})]}),r?e.jsxs("div",{className:"space-y-3",children:[e.jsx(Kn,{label:a("companyRecommendations.industry"),icon:ut,score:r.industry_match,reason:r.industry_reason}),e.jsx(Kn,{label:a("companyRecommendations.jobFunction"),icon:ht,score:r.function_match,reason:r.function_reason}),e.jsx(Kn,{label:a("companyRecommendations.geography"),icon:ia,score:r.geography_match,reason:r.geography_reason}),e.jsx(Kn,{label:a("companyRecommendations.culturePersonality"),icon:kn,score:r.culture_match,reason:r.culture_reason})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:s.why_match||a("c
123ompanyRecommendations.detailsNotAvailable")}),e.jsxs("div",{className:"border-t pt-2 text-xs text-muted-foreground",children:[e.jsx("p",{className:"font-medium mb-1",children:a("companyRecommendations.howScoreCalculated")}),e.jsx("p",{children:a("companyRecommendations.scoreWeights")})]})]})})]})},ju=({existingCompanies:s,onCompanyAdded:a})=>{const{t,i18n:r}=Je(),[n,d]=i.useState(!1),[m,c]=i.useState([]),[l,f]=i.useState(new Set),[p,j]=i.useState(!1),[g,P]=i.useState(null),[N,w]=i.useState(!1),[S,A]=i.useState(0),{toast:y}=Ct(),D=m.filter(k=>!S||k.match_score&&k.match_score>=S),B=async()=>{var k,$;d(!0),P(null),c([]),f(new Set),w(!0);try{const{data:{user:K}}=await C.auth.getUser();if(!K)throw new Error(t("companyRecommendations.toast.mustBeLoggedIn"));const{data:re}=await C.from("profiles").select("*").eq("id",K.id).single(),{data:ve}=await C.from("personality_analyses").select("*").eq("user_id",K.id).order("is_primary",{ascending:!1}).order("created_at",{ascending:!1}).limit(1),ze=(ve==null?void 0:ve[0])||null,xe=await C.functions.invoke("recommend-companies",{body:{language:r.language,profile:re,personalityAnalysis:ze,existingCompanies:s}});if(xe.error)throw new Error(xe.error.message||t("companyRecommendations.toast.couldNotFetch"));if((k=xe.data)!=null&&k.error)throw new Error(xe.data.error);const I=(($=xe.data)==null?void 0:$.companies)||[];c(I),I.length===0&&y({title:t("companyRecommendations.toast.noRecommendations"),description:t("companyRecommendations.toast.noRecommendationsDesc")})}catch(K){console.error("Error fetching recommendations:",K);const re=K instanceof Error?K.message:t("companyRecommendations.toast.couldNotFetch");P(re),y({title:t("companyRecommendations.toast.error"),description:re,variant:"destructive"})}finally{d(!1)}},M=k=>{f($=>{const K=new Set($);return K.has(k)?K.delete(k):K.add(k),K})},Y=async k=>{if(k.length!==0){j(!0);try{const{data:{user:$}}=await C.auth.getUser();if(!$)throw new Error(t("companyRecommendations.toast.mustBeLoggedIn"));for(const re of k)await C.from("dream_companies").insert({user_id:$.id,name:re.name,industry:re.industry||null,location:re.location||null,employees:re.employees||null,website:re.website||null,why_interested:re.why_match||null,status:"Ønskeliste",priority:"medium"});y({title:t("companyRecommendations.toast.companiesAdded"),description:t("companyRecommendations.toast.companiesAddedDesc",{count:k.length})});const K=new Set(k.map(re=>re.name));c(re=>re.filter(ve=>!K.has(ve.name))),f(new Set),a()}catch($){console.error("Error adding companies:",$),y({title:t("companyRecommendations.toast.error"),description:t("companyRecommendations.toast.couldNotAdd"),variant:"destructive"})}finally{j(!1)}}},R=async()=>{const k=m.filter($=>l.has($.name));await Y(k)},Q=async()=>{await Y(D)};return e.jsxs(ye,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-secondary/10 border-primary/20",children:[e.jsx(Jt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(Yt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(xs,{className:"w-5 h-5 text-primary"}),t("companyRecommendations.title")]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("companyRecommendations.subtitle")})]}),e.jsxs(h,{variant:"outline",size:"sm",className:"gap-1 shrink-0",onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),children:[e.jsx(ld,{className:"w-4 h-4"}),t("companyRecommendations.toTop")]})]})}),e.jsx(yt,{className:"space-y-4",children:N?n?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:t("companyRecommendations.analyzingProfile")})]}):g?e.jsxs("div",{className:"text-center py-6",children:[e.jsx(wa,{className:"w-12 h-12 text-destructive mx-auto mb-4"}),e.jsx("p",{className:"text-destructive mb-4",children:g}),e.jsxs(h,{onClick:B,variant:"outline",className:"gap-2",children:[e.jsx(dt,{className:"w-4 h-4"}),t("companyRecommendations.tryAgain")]})]}):m.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx(ut,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("companyRecommendations.noRecommendations")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("companyRecommendations.updateProfile")}),e.jsxs(h,{onClick:B,variant:"outline",className:"gap-2",children:[e.jsx(dt,{className:"w-4 h-4"}),t("companyRecommendations.searchAgain")]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col gap-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:t("companyRecommendations.companiesOf",{filtered:D.length,total:m.length})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:t("companyRecommendations.minMatch")}),e.jsxs(Pt,{value:S.toString(),onValueChange:k=>A(parseInt(k)),children:[e.jsx(Ft,{className:"w-[100px] h-8 text-xs",children:e.jsx(At,{})}),e.jsxs(It,{children:[e.jsx(Ue,{value:"0",children:t("companyRecommendations.all")}),e.jsx(Ue,{value:"60",children:"60%+"}),e.jsx(Ue,{value:"70",children:"70%+"}),e.jsx(Ue,{value:"75",children:"75%+"}),e.jsx(Ue,{value:"80",children:"80%+"}),e.jsx(Ue,{value:"85",children:"85%+"}),e.jsx(Ue,{value:"90",children:"90%+"})]})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(h,{onClick:B,variant:"outline",size:"sm",className:"gap-2",disabled:n,children:[e.jsx(dt,{className:"w-4 h-4"}),t("companyRecommendations.searchAgain")]}),l.size>0&&e.jsxs(h,{onClick:R,size:"sm",className:"gap-2",disabled:p,children:[p?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(fs,{className:"w-4 h-4"}),t("companyRecommendations.addSelected",{count:l.size})]}),e.jsxs(h,{onClick:Q,size:"sm",className:"gap-2",disabled:p||D.length===0,children:[p?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx($s,{className:"w-4 h-4"}),t("companyRecommendations.addAll",{count:D.length})]})]})]})}),D.length===0?e.jsxs("div",{className:"text-center py-6 bg-muted/30 rounded-lg",children:[e.jsx(ka,{className:"w-10 h-10 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:t("companyRecommendations.noCompaniesMatchFilter")}),e.jsx(h,{variant:"link",size:"sm",onClick:()=>A(0),className:"mt-1",children:t("companyRecommendations.resetFilter")})]}):e.jsx("div",{className:"space-y-3",children:D.map((k,$)=>e.jsx("div",{className:`p-4 bg-background rounded-lg border transition-all ${l.has(k.name)?"border-primary ring-1 ring-primary/20":"border-border hover:border-primary/50"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Kt,{checked:l.has(k.name),onCheckedChange:()=>M(k.name),className:"mt-1"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:k.name}),k.match_score&&e.jsx(vu,{company:k})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[k.industry&&e.jsx(je,{variant:"secondary",className:"text-xs",children:k.industry}),k.location&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ia,{className:"w-3 h-3"}),k.location]}),k.employees&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(tt,{className:"w-3 h-3"}),k.employees]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k.match_score&&e.jsx("div",{className:"hidden sm:flex items-center gap-1",children:e.jsx("div",{className:"w-16 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${no(k.match_score)}`,style:{width:`${k.match_score}%`}})})}),k.website&&e.jsx("a",{href:k.website.startsWith("http")?k.website:`https://${k.website}`,target:"_blank",rel:"noopener noreferrer",onClick:K=>K.stopPropagation(),children:e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(xn,{className:"w-4 h-4"})})})]})]}),k.why_match&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:t("companyRecommendations.whyMatch")}),k.why_match]})]})]})},`${k.name}-${$}`))}),l.size>0&&e.jsx("div",{className:"flex items-center justify-center pt-2",children:e.jsx(h,{onClick:R,className:"gap-2",disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),t("companyRecommendations.adding")]}):e.jsxs(e.Fragment,{children:[e.jsx($s,{className:"w-4 h-4"}),t("companyRecommendations.addToDreamList",{count:l.size})]})})})]}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(ut,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("companyRecommendations.letAiFind")}),e.jsx(h,{onClick:B,disabled:n,className:"gap-2",children:n?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),t("companyRecommendations.searching")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-4 h-4"}),t("companyRecommendations.findMatching")]})})]})})]})},yu=({open:s,onOpenChange:a,templateType:t,companies:r,defaultCompanyId:n})=>{const{t:d,i18n:m}=Je(),{toast:c}=Ct(),[l,f]=i.useState(""),[p,j]=i.useState(""),[g,P]=i.useState(""),[N,w]=i.useState(""),[S,A]=i.useState(!1),[y,D]=i.useState(""),[B,M]=i.useState(""),Y=t==="network-intro",R=i.useMemo(()=>t?{"network-intro":d("dreamCompanies.template1Name"),direct:d("dreamCompanies.template2Name"),"follow-up":d("dreamCompanies.template3Name")}[t]:"",[t,d]);i.useEffect(()=>{var K;s&&(f(n||((K=r[0])==null?void 0:K.id)||""),j(""),P(""),w(""),D(""),M(""))},[s,n,r]);const Q=async()=>
123{if(!l||!t)return;const K=r.find(re=>re.id===l);if(K){A(!0);try{const{data:re,error:ve}=await C.functions.invoke("generate-outreach-email",{body:{templateType:t,company:K,contactName:p.trim()||void 0,mutualContact:Y&&g.trim()||void 0,userNote:N.trim()||void 0,language:m.language}});if(ve)throw ve;if(!(re!=null&&re.ok))throw new Error((re==null?void 0:re.error)||"Generation failed");jn("outreach_email_generated","outreach",{templateType:t}),D(re.subject||""),M(re.body||"")}catch(re){console.error("generate-outreach-email error:",re),c({title:d("dreamCompanies.outreachGenerateError"),variant:"destructive"})}finally{A(!1)}}},k=async K=>{try{await navigator.clipboard.writeText(K),c({title:d("dreamCompanies.outreachCopied")})}catch{}},$=()=>{r.find(ve=>ve.id===l);const K=new URLSearchParams;y&&K.set("subject",y),B&&K.set("body",B);const re=`mailto:?${K.toString()}`;window.open(re,"_blank")};return e.jsx(ns,{open:s,onOpenChange:a,children:e.jsxs(rs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(xs,{className:"w-5 h-5 text-primary"}),d("dreamCompanies.outreachDialogTitle"),R&&e.jsxs("span",{className:"text-muted-foreground font-normal",children:["— ",R]})]}),e.jsx(Qs,{children:d("dreamCompanies.outreachDialogDesc")})]}),r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:d("dreamCompanies.outreachNoCompanies")}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:d("dreamCompanies.outreachSelectCompany")}),e.jsxs(Pt,{value:l,onValueChange:f,children:[e.jsx(Ft,{children:e.jsx(At,{placeholder:d("dreamCompanies.outreachSelectCompanyPlaceholder")})}),e.jsx(It,{children:r.map(K=>e.jsx(Ue,{value:K.id,children:K.name},K.id))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:d("dreamCompanies.outreachContactName")}),e.jsx(ue,{value:p,onChange:K=>j(K.target.value),placeholder:d("dreamCompanies.outreachContactNamePlaceholder")})]}),Y&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:d("dreamCompanies.outreachMutualContact")}),e.jsx(ue,{value:g,onChange:K=>P(K.target.value),placeholder:d("dreamCompanies.outreachMutualContactPlaceholder")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:d("dreamCompanies.outreachExtraNote")}),e.jsx(as,{value:N,onChange:K=>w(K.target.value),placeholder:d("dreamCompanies.outreachExtraNotePlaceholder"),rows:2})]}),e.jsxs(h,{onClick:Q,disabled:S||!l,className:"gap-2",children:[S?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(xs,{className:"w-4 h-4"}),d(y?"dreamCompanies.outreachRegenerate":"dreamCompanies.outreachGenerate")]}),(y||B)&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground bg-muted/50 rounded-md p-2",children:[e.jsx(ha,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{children:d("dreamCompanies.outreachAiHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(se,{children:d("dreamCompanies.outreachSub
123ject")}),e.jsxs(h,{size:"sm",variant:"ghost",className:"h-7 gap-1",onClick:()=>k(y),children:[e.jsx(Lt,{className:"w-3 h-3"})," ",d("dreamCompanies.outreachCopy")]})]}),e.jsx(ue,{value:y,onChange:K=>D(K.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(se,{children:d("dreamCompanies.outreachBody")}),e.jsxs(h,{size:"sm",variant:"ghost",className:"h-7 gap-1",onClick:()=>k(B),children:[e.jsx(Lt,{className:"w-3 h-3"})," ",d("dreamCompanies.outreachCopy")]})]}),e.jsx(as,{value:B,onChange:K=>M(K.target.value),rows:14,className:"font-sans"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{variant:"outline",className:"gap-2",onClick:()=>k(`${y}
124
125${B}`),children:[e.jsx(Lt,{className:"w-4 h-4"})," ",d("dreamCompanies.outreachCopyAll")]}),e.jsxs(h,{variant:"outline",className:"gap-2",onClick:$,children:[e.jsx(ua,{className:"w-4 h-4"})," ",d("dreamCompanies.outreachOpenInMail")]})]})]})]})]})})},bu=()=>{var H,ne;const{t:s,i18n:a}=Je(),[t,r]=i.useState(!1),[n,d]=i.useState([]),[m,c]=i.useState(!0),[l,f]=i.useState(!1),[p,j]=i.useState(null),[g,P]=i.useState(null),[N,w]=i.useState(""),[S,A]=i.useState(!1),[y,D]=i.useState("all"),[B,M]=i.useState("all"),[Y,R]=i.useState("created_desc"),{toast:Q}=Ct(),[k,$]=i.useState(""),[K,re]=i.useState(!1),[ve,ze]=i.useState(null),[xe,I]=i.useState([]),[E,F]=i.useState([]),[O,ee]=i.useState({name:"",industry:"",location:"",employees:"",website:"",linkedin_url:"",notes:"",why_interested:"",next_action:"",priority:"medium"});i.useEffect(()=>{Le()},[]);const Le=async()=>{try{const{data:{user:x}}=await C.auth.getUser();if(!x){c(!1);return}const{data:z,error:b}=await C.from("dream_companies").select("*").eq("user_id",x.id).order("created_at",{ascending:!1});if(b)throw b;d(z||[])}catch(x){console.error("Error fetching companies:",x),Q({title:s("dreamCompanies.errorTitle"),description:s("dreamCompanies.couldNotFetchCompanies"),variant:"destructive"})}finally{c(!1)}},pe=[{icon:ka,title:s("dreamCompanies.tip1Title"),description:s("dreamCompanies.tip1Desc")},{icon:Lr,title:s("dreamCompanies.tip2Title"),description:s("dreamCompanies.tip2Desc")},{icon:tt,title:s("dreamCompanies.tip3Title"),description:s("dreamCompanies.tip3Desc")},{icon:wt,title:s("dreamCompanies.tip4Title"),description:s("dreamCompanies.tip4Desc")}],Oe=[{id:1,type:"network-intro",name:s("dreamCompanies.template1Name"),description:s("dreamCompanies.template1Desc")},{id:2,type:"direct",name:s("dreamCompanies.template2Name"),description:s("dreamCompanies.template2Desc")},{id:3,type:"follow-up",name:s("dreamCompanies.template3Name"),description:s("dreamCompanies.template3Desc")}],[he,we]=i.useState(!1),[T,ae]=i.useState(null),me=x=>{ae(x),we(!0)},Ae=x=>{switch(x){case"Kontaktet":return"bg-blue-500/10 text-blue-600 border-blue-500/20";case"Følger op":return"bg-yellow-500/10 text-yellow-600 border-yellow-500/20";case"Ønskeliste":return"bg-purple-500/10 text-purple-600 border-purple-500/20";case"Positiv respons":return"bg-green-500/10 text-green-600 border-green-500/20";case"Afvist":return"bg-red-500/10 text-red-600 border-red-500/20";default:return"bg-muted text-muted-foreground"}},oe=x=>{switch(x){case"high":return e.jsxs(je,{className:"bg-amber-500/20 text-amber-700 border-amber-500/30",children:[e.jsx(Ps,{className:"w-3 h-3 mr-1"}),s("dreamCompanies.high")]});case"medium":return e.jsx(je,{variant:"outline",children:s("dreamCompanies.medium")});case"low":return e.jsx(je,{variant:"secondary",children:s("dreamCompanies.low")});default:return null}},Ve=async()=>{var x,z,b,U,te;if(!k.trim()){Q({title:s("dreamCompanies.errorTitle"),description:s("dreamCompanies.urlRequired",{defaultValue:"Indtast venligst en virksomheds-URL"}),variant:"destructive"});return}re(!0),ze(null);try{const{data:{user:fe}}=await C.auth.getUser();if(!fe)throw new Error(s("dreamCompanies.notLoggedIn"));const[Se,G]=await Promise.all([C.from("profiles").select("job_title, preferred_position_level, preferred_job_function, preferred_industries").eq("id",fe.id).single(),C.from("work_experiences").select("job_title, company_name, company_domain, start_year, end_year, is_current").eq("user_id",fe.id).order("start_year",{ascending:!1}).limit(5)]),Fe={jobTitle:((x=Se.data)==null?void 0:x.job_title)||"",positionLevel:((z=Se.data)==null?void 0:z.preferred_position_level)||[],jobFunction:((b=Se.data)==null?void 0:b.preferred_job_function)||[],industries:((U=Se.data)==null?void 0:U.preferred_industries)||[],workExperiences:G.data||[]},{data:Ee,error:qe}=await C.functions.invoke("analyze-company-domain",{body:{domain:k.trim(),language:a.language,userProfile:Fe}});if(qe)throw qe;if(!(Ee!=null&&Ee.success))throw new Error((Ee==null?void 0:Ee.error)||"Analyse fejlede");const Ge=Ee.data;ze(Ge),ee(He=>({...He,name:Ge.companyName||"",industry:Ge.industry||"",location:Ge.location||"",employees:Ge.employees||"",website:k.trim()})),I(Ge.suggestedDepartments||[]),F(((te=Ge.suggestedContacts)==null?void 0:te.map((He,Ze)=>Ze))||[]),Q({title:s("dreamCompanies.analysisComplete",{defaultValue:"Analyse fuldført"}),description:s("dreamCompanies.analysisCompleteDesc",{defaultValue:"Virksomhedsdata er blevet udfyldt automatisk"})})}catch(fe){console.error("Error analyzing company:",fe),Q({title:s("dreamCompanies.errorTitle"),description:fe.message||s("dreamCompanies.analysisError",{defaultValue:"Kunne ikke analysere virksomheden"}),variant:"destructive"})}finally{re(!1)}},Xe=async()=>{var x;if(!O.name.trim()){Q({title:s("dreamCompanies.errorTitle"),description:s("dreamCompanies.companyNameRequired"),variant:"destructive"});return}f(!0);try{const{data:{user:z}}=await C.auth.getUser();if(!z)throw new Error(s("dreamCompanies.notLoggedIn"));const U=[xe.length>0?`${s("dreamCompanies.relevantDepartments",{defaultValue:"Relevante afdelinger"})}: ${xe.join(", ")}
125`:"",O.notes].filter(Boolean).join(`
126
127`),{data:te,error:fe}=await C.from("dream_companies").insert({user_id:z.id,name:O.name,industry:O.industry||null,location:O.location||null,employees:O.employees||null,website:O.website||null,linkedin_url:O.linkedin_url||null,why_interested:O.why_interested||null,next_action:O.next_action||null,notes:U||null,priority:O.priority,status:"Ønskeliste"}).select().single();if(fe)throw fe;if(((x=ve==null?void 0:ve.suggestedContacts)==null?void 0:x.length)>0){const Se=E.map(G=>ve.suggestedContacts[G]).filter(Boolean);if(Se.length>0){const G=Se.map(Fe=>({user_id:z.id,company_id:te.id,name:Fe.name||Fe.title,title:Fe.title,linkedin:Fe.linkedin||null,notes:Fe.reason||null}));await C.from("dream_company_contacts").insert(G)}}d(Se=>[te,...Se]),cs(),r(!1),Q({title:s("dreamCompanies.companyAdded"),description:s("dreamCompanies.companyAddedDesc",{name:te.name})})}catch(z){console.error("Error adding company:",z),Q({title:s("dreamCompanies.errorTitle"),description:s("dreamCompanies.couldNotAddCompany"),variant:"destructive"})}finally{f(!1)}},cs=()=>{$(""),ze(null),I([]),F([]),ee({name:"",industry:"",location:"",employees:"",website:"",linkedin_url:"",notes:"",why_interested:"",next_action:"",priority:"medium"})},hs=async x=>{try{const{error:z}=await C.from("dream_companies").delete().eq("id",x);if(z)throw z;d(b=>b.filter(U=>U.id!==x)),Q({title:s("dreamCompanies.companyDeleted"),description:s("dreamCompanies.companyDeletedDesc")})}catch(z){console.error("Error deleting company:",z),Q({title:s("dreamCompanies.errorTitle"),description:s("dreamCompanies.couldNotDeleteCompany"),variant:"destructive"})}},ps=async(x,z)=>{try{const b=z==="Kontaktet"?new Date().toISOString().split("T")[0]:void 0,U={status:z};b&&(U.last_contact=b);const{error:te}=await C.from("dream_companies").update(U).eq("id",x);if(te)throw te;d(fe=>fe.map(Se=>Se.id===x?{...Se,status:z,last_contact:b||Se.last_contact}:Se))}catch(b){console.error("Error updating status:",b),Q({title:s("dreamCompanies.errorTitle"),description:s("dreamCompanies.couldNotUpdateStatus"),variant:"destructive"})}},ms=async()=>{if(g){f(!0);try{const{error:x}=await C.from("dream_companies").update({name:g.name,industry:g.industry,location:g.location,employees:g.employees,website:g.website,linkedin_url:g.linkedin_url,why_interested:g.why_interested,next_action:g.next_action,notes:g.notes,priority:g.priority}).eq("id",g.id);if(x)throw x;d(z=>z.map(b=>b.id===g.id?g:b)),P(null),Q({title:s("dreamCompanies.companyUpdated"),description:s("dreamCompanies.companyUpdatedDesc")})}catch(x){console.error("Error updating company:",x),Q({title:s("dreamCompanies.errorTitle"),description:s("dreamCompanies.couldNotUpdateCompany"),variant:"destructive"})}finally{f(!1)}}},De=n.filter(x=>{var fe,Se,G,Fe;const z=N.toLowerCase(),b=!N||x.name.toLowerCase().includes(z)||((fe=x.industry)==null?void 0:fe.toLowerCase().includes(z))||((Se=x.location)==null?void 0:Se.toLowerCase().includes(z))||((G=x.notes)==null?void 0:G.toLowerCase().includes(z))||((Fe=x.why_interested)==null?void 0:Fe.toLowerCase().includes(z)),U=y==="all"||x.status===y,te=B==="all"||x.priority===B;return b&&U&&te}).sort((x,z)=>{const b={high:0,medium:1,low:2};switch(Y){case"name_asc":return x.name.localeCompare(z.name,"da");case"name_desc":return z.name.localeCompare(x.name,"da");case"priority_high":return(b[x.priority]??2)-(b[z.priority]??2);case"priority_low":return(b[z.priority]??2)-(b[x.priority]??2);case"created_desc":default:return 0;case"created_asc":return 0;case"last_contact_desc":return!x.last_contact&&!z.last_contact?0:x.last_contact?z.last_contact?new Date(z.last_contact).getTime()-new Date(x.last_contact).getTime():-1:1;case"last_contact_asc":return!x.last_contact&&!z.last_contact?0:x.last_contact?z.last_contact?new Date(x.last_contact).getTime()-new Date(z.last_contact).getTime():-1:1}}),_=()=>{w(""),D("all"),M("all"),R("created_desc")},Z=N||y!=="all"||B!=="all"||Y!=="created_desc";return S?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>A(!1),className:"gap-2",children:[e.jsx(_n,{className:"w-4 h-4"}),s("dreamCompanies.back",{defaultValue:js(a.language)?"Back":"Tilbage"})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(Ps,{className:"w-5 h-5 text-yellow-500 fill-yellow-400"}),js(a.language)?"Selected Contacts":"Udvalgte Kontakter"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:js(a.language)?"Contacts marked with ★ for your dashboard":"Kontakter markeret med ★ til dit dashboard"})]})]}),e.jsx(gc,{embedded:!0})]}):p?e.jsx(fu,{companyName:p.name,companyId:p.id,onBack:()=>j(null)}):m?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(ye,{className:"p-6 bg-gradient-to-r from-primary/5 to-primary/10 border-primary/20",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(ut,{className:"w-5 h-5 text-primary"}),s("dreamCompanies.title")]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s("dreamCompanies.description")}),e.jsxs("button",{type:"button",onClick:()=>{var x;(x=document.getElementById("ai-recommendations"))==null||x.scrollIntoView({behavior:"smooth",block:"start"})},className:"text-sm text-primary hover:underline mt-2 inline-flex items-center gap-1",children:[s("dreamCompanies.getRecommendations"),e.jsx(rd,{className:"w-3 h-3"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{variant:"outline",className:"gap-2",onClick:()=>A(!0),children:[e.jsx(Ps,{className:"w-4 h-4 fill-yellow-400 text-yellow-500"}),js(a.language)?"Selected contacts":"Udvalgte kontakter"]}),e.jsxs(ns,{open:t,onOpenChange:x=>{r(x),x||cs()},children:[e.jsx(Na,{asChild:!0,children:e.jsxs(h,{className:"gap-2",children:[e.jsx(fs,{className:"w-4 h-4"}),s("dreamCompanies.addCompany")]})}),e.jsxs(rs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsx(is,{children:s("dreamCompanies.addDreamCompany")})}),e.jsxs("div",{className:"space-y-5 mt-4",children:[!ve&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"companyUrl",children:s("dreamCompanies.companyUrl",{defaultValue:"Virksomhedens hjemmeside"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ue,{id:"companyUrl",value:k,onChange:x=>$(x.target.value),placeholder:"https://virksomhed.dk",disabled:K,onKeyDown:x=>x.key==="Enter"&&!K&&Ve()}),e.jsxs(h,{onClick:Ve,disabled:K||!k.trim(),className:"gap-2 shrink-0",children:[K?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(xs,{className:"w-4 h-4"}),K?s("dreamCompanies.analyzing",{defaultValue:"Analyserer..."}):s("dreamCompanies.analyze",{defaultValue:"Analysér"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dreamCompanies.analyzeHint",{defaultValue:"Indtast URL og klik Analysér – vi udfylder resten automatisk"})}),e.jsxs("div",{className:"relative py-3",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:s("dreamCompanies.orManual",{defaultValue:"eller tilføj manuelt"})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.companyName")}),e.jsx(ue,{value:O.name,onChange:x=>ee({...O,name:x.target.value}),placeholder:s("dreamCompanies.companyNamePlaceholder",{defaultValue:"Virksomhedsnavn"})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.industry")}),e.jsx(ue,{value:O.industry,onChange:x=>ee({...O,industry:x.target.value}),placeholder:s("dreamCompanies.industryPlaceholder",{defaultValue:"F.eks. IT, Finans, Sundhed"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.location")}),e.jsx(ue,{value:O.location,onChange:x=>ee({...O,location:x.target.value}),placeholder:s("dreamCompanies.locationPlaceholder",{defaultValue:"F.eks. København"})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.employees")}),e.jsx(ue,{value:O.employees,onChange:x=>ee({...O,employees:x.target.value}),placeholder:s("dreamCompanies.employeesPlaceholder",{defaultValue:"F.eks. 50-100"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.website",{defaultValue:"Hjemmeside"})}),e.jsx(ue,{value:O.website,onChange:x=>ee({...O,website:x.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.linkedinUrl",{defaultValue:"LinkedIn URL"})}),e.jsx(ue,{value:O.linkedin_url,onChange:x=>ee({...O,linkedin_url:x.target.value}),placeholder:"https://linkedin.com/company/..."})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.whyInterested",{defaultValue:"Hvorfor er du interesseret?"})}),e.jsx(as,{value:O.why_interested,onChange:x=>ee({...O,why_interested:x.target.value}),placeholder:s("dreamCompanies.whyInterestedPlaceholder",{defaultValue:"Hvad tiltrækker dig ved denne virksomhed?"}
127),className:"min-h-[60px]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:s("dreamCompanies.priority")}),e.jsxs(Pt,{value:O.priority,onValueChange:x=>ee({...O,priority:x}),children:[e.jsx(Ft,{children:e.jsx(At,{})}),e.jsxs(It,{children:[e.jsx(Ue,{value:"high",children:s("dreamCompanies.priorityHigh")}),e.jsx(Ue,{value:"medium",children:s("dreamCompanies.priorityMedium")}),e.jsx(Ue,{value:"low",children:s("dreamCompanies.priorityLow")})]})]})]}),e.jsxs(h,{className:"w-full",onClick:Xe,disabled:l||!O.name.trim(),children:[l?e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(fs,{className:"w-4 h-4 mr-2"}),s("dreamCompanies.addCompany")]})]})]}),ve&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-primary",children:[e.jsx($s,{className:"w-4 h-4"}),s("dreamCompanies.autoFilledData",{defaultValue:"Automatisk udfyldte data"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.companyName")}),e.jsx(ue,{value:O.name,onChange:x=>ee({...O,name:x.target.value})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.industry")}),e.jsx(ue,{value:O.industry,onChange:x=>ee({...O,industry:x.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.employees")}),e.jsx(ue,{value:O.employees,onChange:x=>ee({...O,employees:x.target.value})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:s("dreamCompanies.location")}),e.jsx(ue,{value:O.location,onChange:x=>ee({...O,location:x.target.value})})]})]})]}),((H=ve.suggestedDepartments)==null?void 0:H.length)>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(ut,{className:"w-4 h-4 text-primary"}),s("dreamCompanies.suggestedDepartments",{defaultValue:"Foreslåede afdelinger (baseret på din profil)"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ve.suggestedDepartments.map((x,z)=>e.jsxs("label",{className:`flex items-center gap-2 px-3 py-2 rounded-lg border cursor-pointer transition-colors ${xe.includes(x)?"border-primary bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground hover:border-primary/50"}`,children:[e.jsx(Kt,{checked:xe.includes(x),onCheckedChange:b=>{I(U=>b?[...U,x]:U.filter(te=>te!==x))}}),e.jsx("span",{className:"text-sm",children:x})]},z))})]}),((ne=ve.suggestedContacts)==null?void 0:ne.length)>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Dl,{className:"w-4 h-4 text-primary"}),s("dreamCompanies.suggestedContacts",{defaultValue:"Foreslåede kontaktpersoner"})]}),e.jsx("div",{className:"space-y-2",children:ve.suggestedContacts.map((x,z)=>e.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${E.includes(z)?"border-primary bg-primary/10":"border-border bg-card hover:border-primary/50"}`,children:[e.jsx(Kt,{checked:E.includes(z),onCheckedChange:b=>{F(U=>b?[...U,z]:U.filter(te=>te!==z))},className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm text-foreground",children:x.name||x.title}),x.name&&e.jsx(je,{variant:"secondary",className:"text-xs",children:"✓ Verificeret"}),x.department&&e.jsx(je,{variant:"outline",className:"text-xs",children:x.department})]}),x.name&&x.title&&e.jsx("p",{className:"text-xs text-muted-foreground",children:x.title}),x.linkedin&&e.jsx("a",{href:x.linkedin,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline",onClick:b=>b.stopPropagation(),children:"LinkedIn →"}),x.reason&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:x.reason})]})]},z))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:s("dreamCompanies.priority")}),e.jsxs(Pt,{value:O.priority,onValueChange:x=>ee({...O,priority:x}),children:[e.jsx(Ft,{children:e.jsx(At,{})}),e.jsxs(It,{children:[e.jsx(Ue,{value:"high",children:s("dreamCompanies.priorityHigh")}),e.jsx(Ue,{value:"medium",children:s("dreamCompanies.priorityMedium")}),e.jsx(Ue,{value:"low",children:s("dreamCompanies.priorityLow")})]})]})]}),e.jsxs(h,{className:"w-full",onClick:Xe,disabled:l||!O.name.trim(),children:[l?e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(fs,{className:"w-4 h-4 mr-2"}),s("dreamCompanies.addCompany"),E.length>0&&` + ${E.length} ${s("dreamCompanies.contacts",{defaultValue:"kontakter"})}`]})]})]})]})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-primary",children:n.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dreamCompanies.totalCompanies")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-purple-600",children:n.filter(x=>x.status==="Ønskeliste").length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dreamCompanies.onWishlist")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:n.filter(x=>x.status==="Kontaktet").length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dreamCompanies.contacted")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:n.filter(x=>x.status==="Følger op").length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dreamCompanies.followingUp")})]})]}),e.jsxs(ye,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ut,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ue,{placeholder:s("dreamCompanies.searchPlaceholder"),value:N,onChange:x=>w(x.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Pt,{value:y,onValueChange:D,children:[e.jsxs(Ft,{className:"w-[140px]",children:[e.jsx(Vl,{className:"w-4 h-4 mr-2"}),e.jsx(At,{placeholder:s("dreamCompanies.status")})]}),e.jsxs(It,{children:[e.jsx(Ue,{value:"all",children:s("dreamCompanies.allStatuses")}),e.jsx(Ue,{value:"Ønskeliste",children:s("dreamCompanies.wishlist")}),e.jsx(Ue,{value:"Kontaktet",children:s("dreamCompanies.contacted")}),e.jsx(Ue,{value:"Følger op",children:s("dreamCompanies.followingUp")}),e.jsx(Ue,{value:"Positiv respons",children:s("dreamCompanies.positiveResponse")}),e.jsx(Ue,{value:"Afvist",children:s("dreamCompanies.rejected")})]})]}),e.jsxs(Pt,{value:B,onValueChange:M,children:[e.jsxs(Ft,{className:"w-[140px]",children:[e.jsx(Ps,{className:"w-4 h-4 mr-2"}),e.jsx(At,{placeholder:s("dreamCompanies.priority")})]}),e.jsxs(It,{children:[e.jsx(Ue,{value:"all",children:s("dreamCompanies.allPriorities")}),e.jsx(Ue,{value:"high",children:s("dreamCompanies.high")}),e.jsx(Ue,{value:"medium",children:s("dreamCompanies.medium")}),e.jsx(Ue,{value:"low",children:s("dreamCompanies.low")})]})]}),e.jsxs(Pt,{value:Y,onValueChange:R,children:[e.jsxs(Ft,{className:"w-[160px]",children:[e.jsx(id,{className:"w-4 h-4 mr-2"}),e.jsx(At,{placeholder:s("dreamCompanies.sort")})]}),e.jsxs(It,{children:[e.jsx(Ue,{value:"created_desc",children:s("dreamCompanies.newestFirst")}),e.jsx(Ue,{value:"name_asc",children:s("dreamCompanies.nameAZ")}),e.jsx(Ue,{value:"name_desc",children:s("dreamCompanies.nameZA")}),e.jsx(Ue,{value:"priority_high",children:s("dreamCompanies.highe
127stPriority")}),e.jsx(Ue,{value:"priority_low",children:s("dreamCompanies.lowestPriority")}),e.jsx(Ue,{value:"last_contact_desc",children:s("dreamCompanies.lastContacted")}),e.jsx(Ue,{value:"last_contact_asc",children:s("dreamCompanies.oldestContact")})]})]}),Z&&e.jsxs(h,{variant:"ghost",size:"sm",onClick:_,className:"gap-1",children:[e.jsx(mt,{className:"w-4 h-4"}),s("dreamCompanies.clearFilters")]})]})]}),Z&&e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:s("dreamCompanies.showing",{shown:De.length,total:n.length})})]}),e.jsxs(ye,{className:"p-6 bg-muted/50",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2 mb-4",children:[e.jsx(wt,{className:"w-5 h-5 text-primary"}),s("dreamCompanies.tipsTitle")]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:pe.map((x,z)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-background rounded-lg",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(x.icon,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:x.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x.description})]})]},z))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(kn,{className:"w-5 h-5 text-primary"}),s("dreamCompanies.yourDreamCompanies")]}),n.length===0?e.jsxs(ye,{className:"p-8 text-center",children:[e.jsx(ut,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:s("dreamCompanies.noCompaniesYet")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("dreamCompanies.clickToStart")})]}):De.length===0?e.jsxs(ye,{className:"p-8 text-center",children:[e.jsx(Ut,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:s("dreamCompanies.noMatchingCompanies")}),e.jsx(h,{variant:"link",onClick:_,className:"mt-2",children:s("dreamCompanies.clearFilters")})]}):e.jsx("div",{className:"space-y-4",children:De.map(x=>e.jsxs(ye,{className:"hover:shadow-lg transition-shadow",children:[e.jsx(Jt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(Yt,{className:"text-lg flex items-center gap-2",children:[x.name,x.priority==="high"&&e.jsx(Ps,{className:"w-4 h-4 text-amber-500 fill-amber-500"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[x.industry,x.employees?` • ${s("dreamCompanies.employeesCount",{count:x.employees})}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Pt,{value:x.status||"Ønskeliste",onValueChange:z=>ps(x.id,z),children:[e.jsx(Ft,{className:`w-[140px] h-8 text-xs ${Ae(x.status)}`,children:e.jsx(At,{})}),e.jsxs(It,{children:[e.jsx(Ue,{value:"Ønskeliste",children:s("dreamCompanies.statusWishlist")}),e.jsx(Ue,{value:"Kontaktet",children:s("dreamCompanies.statusContacted")}),e.jsx(Ue,{value:"Følger op",children:s("dreamCompanies.statusFollowUp")}),e.jsx(Ue,{value:"Positiv respons",children:s("dreamCompanies.statusPositive")}),e.jsx(Ue,{value:"Afvist",children:s("dreamCompanies.statusRejected")})]})]}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>P(x),children:e.jsx(Yr,{className:"w-4 h-4"})}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>hs(x.id),children:e.jsx(Ss,{className:"w-4 h-4"})})]})]})}),e.jsxs(yt,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[x.location&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ia,{className:"w-4 h-4"}),e.jsx("span",{children:x.location})]}),x.last_contact&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{children:s("dreamCompanies.lastContactDate",{date:new Date(x.last_contact).toLocaleDateString(Te(a.language)?"da-DK":"en-US")})})]})]}),e.jsxs("div",{className:"space-y-2",children:[x.why_interested&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:s("dreamCompanies.interest")}),e.jsx("span",{className:"text-muted-foreground",children:x.why_interested})]}),x.next_action&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ba,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:x.next_action})]})]})]}),x.notes&&e.jsxs("div",{className:"text-sm text-muted-foreground border-t pt-3",children:[e.jsx(Lr,{className:"w-4 h-4 inline mr-2"}),x.notes]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2 border-t",children:[e.jsxs(h,{size:"sm",className:"gap-2",onClick:()=>j(x),children:[e.jsx(Ca,{className:"w-4 h-4"}),s("dreamCompanies.viewContacts")]}),x.website&&e.jsx("a",{href:x.website,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",children:[e.jsx(xn,{className:"w-4 h-4"}),"Website"]})}),x.linkedin_url&&e.jsx("a",{href:x.linkedin_url,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",children:[e.jsx(Ms,{className:"w-4 h-4"}),"LinkedIn"]})}),oe(x.priority)]})]})]},x.id))})]}),e.jsx("div",{id:"ai-recommendations",children:e.jsx(ju,{existingCompanies:n.map(x=>({id:x.id,name:x.name})),onCompanyAdded:Le})}),e.jsxs(ye,{className:"p-6",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2 mb-4",children:[e.jsx(ua,{className:"w-5 h-5 text-primary"}),s("dreamCompanies.emailTemplatesTitle")]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:Oe.map(x=>e.jsxs(ye,{className:"p-4 cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>me(x.type),children:[e.jsx("p",{className:"font-medium text-foreground",children:x.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x.description}),e.jsxs(h,{variant:"link",className:"p-0 h-auto mt-2 gap-1",onClick:z=>{z.stopPropagation(),me(x.type)},children:[s("dreamCompanies.useTemplate")," ",e.jsx(Yn,{className:"w-3 h-3"})]})]},x.id))})]}),e.jsx(yu,{open:he,onOpenChange:we,templateType:T,companies:n.map(x=>({id:x.id,name:x.name,industry:x.industry,location:x.location,why_interested:x.why_interested}))}),e.jsx(ns,{open:!!g,onOpenChange:x=>!x&&P(null),children:e.jsxs(rs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsx(is,{children:s("dreamCompanies.editCompany")})}
127),g&&e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-companyName",children:s("dreamCompanies.companyName")}),e.jsx(ue,{id:"edit-companyName",value:g.name,onChange:x=>P({...g,name:x.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-industry",children:s("dreamCompanies.industry")}),e.jsx(ue,{id:"edit-industry",value:g.industry||"",onChange:x=>P({...g,industry:x.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-location",children:s("dreamCompanies.location")}),e.jsx(ue,{id:"edit-location",value:g.location||"",onChange:x=>P({...g,location:x.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-employees",children:s("dreamCompanies.employees")}),e.jsx(ue,{id:"edit-employees",value:g.employees||"",onChange:x=>P({...g,employees:x.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-website",children:s("dreamCompanies.website")}),e.jsx(ue,{id:"edit-website",value:g.website||"",onChange:x=>P({...g,website:x.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-linkedin",children:"LinkedIn URL"}),e.jsx(ue,{id:"edit-linkedin",value:g.linkedin_url||"",onChange:x=>P({...g,linkedin_url:x.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:s("dreamCompanies.priority")}),e.jsxs(Pt,{value:g.priority||"medium",onValueChange:x=>P({...g,priority:x}),children:[e.jsx(Ft,{children:e.jsx(At,{})}),e.jsxs(It,{children:[e.jsx(Ue,{value:"high",children:s("dreamCompanies.priorityHigh")}),e.jsx(Ue,{value:"medium",children:s("dreamCompanies.priorityMedium")}),e.jsx(Ue,{value:"low",children:s("dreamCompanies.priorityLow")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-whyInterested",children:s("dreamCompanies.whyInterested")}),e.jsx(as,{id:"edit-whyInterested",value:g.why_interested||"",onChange:x=>P({...g,why_interested:x.target.value}),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-nextAction",children:s("dreamCompanies.nextAction")}),e.jsx(ue,{id:"edit-nextAction",value:g.next_action||"",onChange:x=>P({...g,next_action:x.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"edit-notes",children:s("dreamCompanies.notes")}),e.jsx(as,{id:"edit-notes",value:g.notes||"",onChange:x=>P({...g,notes:x.target.value}),rows:2})]}),e.jsxs(h,{className:"w-full",onClick:ms,disabled:l||!g.name.trim(),children:[l?e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"}):null,s("dreamCompanies.saveChanges")]})]})]})})]})},Nu=s=>{switch(s){case"high":return"bg-destructive/10 text-destructive border-destructive/30";case"medium":return"bg-amber-500/10 text-amber-700 dark:text-amber-400 border-amber-500/30";default:return"bg-muted text-muted-foreground border-border"}},wu=({open:s,onOpenChange:a,cvContent:t,languageVoice:r="we",languageFormality:n="formal",onCVUpdated:d})=>{const{t:m,i18n:c}=Je(),l=js(c.language),[f,p]=i.useState("intro"),[j,g]=i.useState([]),[P,N]=i.useState(new Set),[w,S]=i.useState(""),A=()=>{p("intro"),g([]),N(new Set),S("")},y=R=>{R||A(),a(R)},D=async()=>{if(!(t!=null&&t.trim())){J.error(l?"No CV content to analyze":"Intet CV-indhold at analysere");return}p("analyzing");try{const{data:{session:R}}=await C.auth.getSession();if(!R){J.error(l?"Please log in":"Log ind for at fortsætte"),p("intro");return}const Q=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/analyze-cv-anti-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R.access_token}`},body:JSON.stringify({content:t,language:l?"en":"da"})});if(!Q.ok){const K=await Q.json().catch(()=>({}));throw new Error(K.error||(l?"Analysis failed":"Analyse fejlede"))}const $=(await Q.json()).suggestions??[];g($),N(new Set($.map(K=>K.id))),p("suggestions")}catch(R){console.error(R),J.error(R instanceof Error?R.message:l?"An error occurred":"Der opstod en fejl"),p("intro")}},B=R=>{N(Q=>{const k=new Set(Q);return k.has(R)?k.delete(R):k.add(R),k})},M=async()=>{const R=j.filter($=>P.has($.id));if(R.length===0){J.error(l?"Select at least one suggestion":"Vælg mindst ét forslag");return}p("applying");const Q=R.map($=>{var K;return`- ${$.title}: ${$.description}${(K=$.examples)!=null&&K.length?` (e.g. ${$.examples.slice(0,3).join(", ")})`:""}`}
127),k=l?`Rewrite this CV to be less obviously AI-generated. Apply these specific fixes:
128
129${Q.join(`
130`)}
131
132CRITICAL RULES:
133- Preserve ALL factual content (dates, companies, titles, education, results, numbers — unless I explicitly asked to vary round numbers)
134- Preserve the overall structure and section order
135- Vary bullet length and opening words naturally
136- Replace clichés with concrete, specific phrasing
137- Remove em-dashes (—) and replace with commas, periods, or restructure sentences
138- Allow small natural imperfections in rhythm
139- DO NOT add new facts, achievements, or experience that wasn't there
140- DO NOT make the CV worse or less professional`:`Omskriv dette CV så det virker mindre tydeligt AI-genereret. Anvend disse specifikke rettelser:
141
142${Q.join(`
143`)}
144
145KRITISKE REGLER:
146- Bevar AL faktuel information (datoer, virksomheder, titler, uddannelse, resultater, tal — medmindre jeg eksplicit bad om at variere runde tal)
147- Bevar den overordnede struktur og sektionsrækkefølge
148- Varier bullet-længde og åbningsord naturligt
149- Erstat klichéer med konkrete, specifikke formuleringer
150- Fjern em-dashes (—) og erstat med kommaer, punktummer eller omformulér sætninger
151- Tillad små naturlige uregelmæssigheder i rytmen
152- TILFØJ IKKE nye fakta, resultater eller erfaring der ikke var der
153- Gør IKKE CV'et dårligere eller mindre professionelt`;try{const{data:{session:$}}=await C.auth.getSession();if(!$){J.error(l?"Please log in":"Log ind for at fortsætte"),p("suggestions");return}const K=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/edit-document-with-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$.access_token}`},body:JSON.stringify({content:t,instructions:k,documentType:"cv",language:l?"en":"da",cv_language_voice:r,cv_language_formality:n})});if(!K.ok){const ve=await K.json().catch(()=>({}));throw new Error(ve.error||(l?"Rewrite failed":"Omskrivning fejlede"))}const re=await K.json();S(re.editedContent??""),p("preview")}catch($){console.error($),J.error($ instanceof Error?$.message:l?"An error occurred":"Der opstod en fejl"),p("suggestions")}},Y=()=>{d(w),J.success(l?"CV updated":"CV opdateret"),y(!1)};return e.jsx(ns,{open:s,onOpenChange:y,children:e.jsxs(rs,{className:"max-w-2xl h-[85vh] max-h-[85vh] flex flex-col overflow-hidden min-h-0",children:[e.jsxs(os,{className:"shrink-0",children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(la,{className:"w-5 h-5 text-primary"}),l?"Make CV less AI-like":"Gør CV mindre AI-agtigt"]}),e.jsx(Qs,{children:l?"Identify and reduce typical AI fingerprints in your CV.":"Find og reducér typiske AI-fingeraftryk i dit CV."})]}),f==="intro"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Gi,{children:[e.jsx(Qc,{className:"w-4 h-4"}),e.jsx(qi,{className:"text-sm",children:l?"This tool reduces typical AI fingerprints in your CV — but no method can guarantee 100% that an experienced recruiter cannot tell. Always review the result yourself.":"Dette værktøj reducerer typiske AI-fingeraftryk i dit CV — men ingen metode kan garantere 100% at en erfaren rekrutterer ikke kan gennemskue det. Gennemse altid resultatet selv."})]}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:l?"We will analyze your CV and look for:":"Vi analyserer dit CV og kigger efter:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[e.jsx("li",{children:l?"Generic clichés and AI buzzwords":"Generiske klichéer og AI-buzzwords"}),e.jsx("li",{children:l?"Overly round numbers":"Overdrevent runde tal"}),e.jsx("li",{children:l?"Em-dashes (—) and overly perfect structure":"Em-dashes (—) og perfekt parallelstruktur"}),e.jsx("li",{children:l?"Repetitive bullet openings":"Gentagende åbninger på bullets"}),e.jsx("li",{children:l?"Missing personal voice":"Manglende personlig stemme"})]})]}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"outline",onClick:()=>y(!1),children:l?"Cancel":"Annullér"}),e.jsxs(h,{onClick:D,children:[e.jsx(xs,{className:"w-4 h-4 mr-2"}),l?"Analyze CV":"Analysér CV"]})]})]}),f==="analyzing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-3",children:[e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Analyzing your CV…":"Analyserer dit CV…"})]}),f==="suggestions"&&e.jsx("div",{className:"flex flex-col flex-1 min-h-0 gap-3",children:j.length===0?e.jsxs("div",{className:"py-8 text-center space-y-3",children:[e.jsx("p",{className:"text-sm",children:l?"No clear AI fingerprints found. Your CV already reads naturally.":"Ingen tydelige AI-fingeraftryk fundet. Dit CV læses allerede naturligt."}),e.jsx(Bt,{children:e.jsx(h,{onClick:()=>
153y(!1),children:l?"Close":"Luk"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground shrink-0",children:[e.jsx("span",{children:l?`${j.length} suggestion${j.length===1?"":"s"} found`:`${j.length} forslag fundet`}),e.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>N(P.size===j.length?new Set:new Set(j.map(R=>R.id))),children:P.size===j.length?l?"Deselect all":"Fravælg alle":l?"Select all":"Vælg alle"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-3 -mr-3",children:e.jsx("div",{className:"space-y-2 pb-1",children:j.map(R=>e.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-md border cursor-pointer transition-colors ${P.has(R.id)?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,children:[e.jsx(Kt,{checked:P.has(R.id),onCheckedChange:()=>B(R.id),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium",children:R.title}),e.jsx(je,{variant:"outline",className:`text-[10px] ${Nu(R.severity)}`,children:R.severity==="high"?l?"High":"Høj":R.severity==="medium"?l?"Medium":"Mellem":l?"Low":"Lav"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:R.description}),R.examples&&R.examples.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:R.examples.slice(0,4).map((Q,k)=>e.jsx("code",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-foreground/80",children:Q},k))})]})]},R.id))})}),e.jsxs(Bt,{className:"gap-2",children:[e.jsx(h,{variant:"outline",onClick:()=>y(!1),children:l?"Cancel":"Annullér"}),e.jsxs(h,{onClick:M,disabled:P.size===0,children:[e.jsx(la,{className:"w-4 h-4 mr-2"}),l?`Apply (${P.size})`:`Anvend (${P.size})`]})]})]})}),f==="applying"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-3",children:[e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Rewriting your CV…":"Omskriver dit CV…"})]}),f==="preview"&&e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 gap-3",children:[e.jsxs(Gi,{children:[e.jsx(ha,{className:"w-4 h-4"}),e.jsx(qi,{className:"text-xs",children:l?"Review the rewritten CV below. Accept to apply, or go back.":"Gennemse det omskrevne CV nedenfor. Acceptér for at anvende, eller gå tilbage."})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto border rounded-md p-3 bg-muted/30",children:e.jsx("pre",{className:"text-xs whitespace-pre-wrap font-sans leading-relaxed",children:w})}),e.jsxs(Bt,{className:"gap-2",children:[e.jsx(h,{variant:"outline",onClick:()=>p("suggestions"),children:l?"Back":"Tilbage"}),e.jsxs(h,{onClick:Y,children:[e.jsx(xs,{className:"w-4 h-4 mr-2"}),l?"Apply to CV":"Anvend på CV"]})]})]})]})})},Ur=500,Hr=s=>`cv-focus-instruction:${s??"anon"}`,tr=s=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Hr(s))??""}catch{return""}},ul=(s,a)=>{if(!(typeof window>"u"))try{const t=(a??"").slice(0,Ur);t?window.localStorage.setItem(Hr(s),t):window.localStorage.removeItem(Hr(s))}catch{}};function ku(s){let a=0;for(let t=0;t<s.length;t++)a=a*31+s.charCodeAt(t)|0;return String(a)}const Cu=s=>s==="high"?"bg-destructive/10 text-destructive border-destructive/30":s==="medium"?"bg-amber-500/10 text-amber-700 border-amber-500/30":"bg-muted text-muted-foreground border-border",_u=({open:s,onOpenChange:a,cvContent:t,onCVUpdated:r,languageVoice:n="we",languageFormality:d="formal"})=>{var Q,k,$,K,re,ve,ze;const{t:m,i18n:c}=Je(),[l,f]=i.useState(!1),[p,j]=i.useState(null),[g,P]=i.useState(null),[N,w]=i.useState(null),[S,A]=i.useState(null),y=i.useRef(null),D=js(c.language)?"en":"da",B=async(xe=!1)=>{if(!t||t.trim().length<20){P(m("cvImprove.tooShort","CV'et er for kort til at analysere."));return}const I=ku(t);if(!(!xe&&p&&y.current===I)){f(!0),P(null);try{const{data:{session:E}}=await C.auth.getSession();if(!E){P(m("cvImprove.loginRequired","Log ind for at fortsætte."));return}const F=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/analyze-cv-feedback",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.access_token}`},body:JSON.stringify({cvContent:t,source:"generated",language:D})});if(!F.ok){const ee=await F.json().catch(()=>({}));throw new Error(ee.error||`HTTP ${F.status}`)}const O=await F.json();j(O),y.current=I}catch(E){console.error("analyze-cv-feedback error:",E),P(E instanceof Error?E.message:m("cvImprove.genericError","Kunne ikke analysere CV'et."))}finally{f(!1)}}};i.useEffect(()=>{s&&B(!1)},[s]);const M=async(xe,I)=>{try{await navigator.clipboard.writeText(I),w(xe),J.success(m("cvImprove.copied","Forslag kopieret")),setTimeout(()=>w(null),1500)}catch{J.error(m("cvImprove.copyFailed","Kunne ikke kopiere"))}},Y=async(xe,I)=>{if(r){A(xe);try{const{data:{session:E}}=await C.auth.getSession();if(!E){J.error(m("cvImprove.loginRequired","Log ind for at fortsætte."));return}const F=D==="en"?`Apply the following improvement to the CV without inventing facts. Improvement title: "${I.title}". Description: ${I.description}. ${I.suggested_text?`Use this concrete suggested text where it fits naturally: """${I.suggested_text}"""`:""}`:`Anvend følgende forbedring i CV'et uden at opdigte fakta. Forbedringens titel: "${I.title}". Beskrivelse: ${I.description}. ${I.suggested_text?`Brug denne konkrete tekst hvor det passer naturligt: """${I.suggested_text}"""`:""}`,O=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/edit-document-with-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.access_token}`},body:JSON.stringify({content:t,instructions:F,documentType:"cv",cv_language_voice:n,cv_language_formality:d,focusInstruction:tr()||void 0})});if(!O.ok){const Le=await O.json().catch(()=>({}));throw new Error(Le.error||`HTTP ${O.status}`)}const ee=await O.json();if(ee!=null&&ee.editedContent)r(ee.editedContent),J.success(m("cvImprove.applied","Forbedring anvendt på CV'et")),y.current=null;else throw new Error("Tomt svar")}catch(E){console.error("apply improvement error:",E),J.error(E instanceof Error?E.message:m("cvImprove.applyFailed","Kunne ikke anvende forbedringen"))}finally{A(null)}}},R=xe=>xe>=80?"text-emerald-600":xe>=60?"text-amber-600":"text-destructive";return e.jsx(rc,{open:s,onOpenChange:a,children:e.jsxs(ic,{className:"w-full sm:max-w-xl overflow-y-auto",children:[e.jsxs(lc,{children:[e.jsxs(oc,{className:"flex items-center gap-2",children:[e.jsx(la,{className:"w-5 h-5 text-primary"}),m("cvImprove.title","Forbedringsforslag")]}),e.jsx(cc,{children:m("cvImprove.description","AI analyserer dit nuværende CV og foreslår konkrete forbedringer. Du kan kopiere et forslag eller anvende det direkte med AI.")})]}),l&&e.jsxs("div",{className:"py-12 flex flex-col items-center justify-center gap-3 text-muted-foreground",children:[e.jsx(ge,{className:"w-6 h-6 animate-spin text-primary"}),e.jsx("p",{className:"text-sm",children:m("cvImprove.analyzing","Analyserer dit CV...")})]}),!l&&g&&e.jsxs("div",{className:"mt-6 p-4 rounded-lg border border-destructive/30 bg-destructive/5",children:[e.jsx("p",{className:"text-sm text-destructive",children:g}),e.jsxs(h,{size:"sm",variant:"outline",className:"mt-3",onClick:()=>void B(!0),children:[e.jsx(dt,{className:"w-3.5 h-3.5 mr-1.5"}),m("cvImprove.retry","Prøv igen")]})]}),!l&&!g&&p&&e.jsxs("div",{className:"mt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg border bg-card",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:m("cvImprove.overallScore","Samlet score")}),e.jsxs("p",{className:`text-2xl font-semibold ${R(p.overall_score)}`,children:[p.overall_score,e.jsx("span",{className:"text-sm text-muted-foreground",children:"/100"})]}),e.jsx(zi,{value:p.overall_score,className:"h-1.5 mt-2"})]}),e.jsxs("div",{className:"p-3 rounded-lg border bg-card",children:[e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Qn,{className:"w-3 h-3"})," ATS"]}),e.jsxs("p",{className:`text-2xl font-semibold ${R(p.ats_score)}`,children:[p.ats_score,e.jsx("span",{className:"text-sm text-muted-foreground",children:"/100"})]}),e.jsx(zi,{value:p.ats_score,className:"h-1.5 mt-2"})]})]}),p.summary&&e.jsx("div",{className:"p-3 rounded-lg bg-muted/40 text-sm leading-relaxed whitespace-pre-line",children:p.summary}),((Q=p.improvements)==null?void 0:Q.length)>0&&e.jsxs("section",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(va,{className:"w-4 h-4 text-amber-600"}),m("cvImprove.improvements","Forbedringsforslag"),e.jsx(je,{variant:"secondary",className:"ml-1",children:p.improvements.length})]}),e.jsx("div",{className:"space-y-3",children:p.improvements.map((xe,I)=>e.jsxs("div",{className:"p-3 rounded-lg border bg-card space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold",children:xe.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 leading-snug whitespace-pre-line",children:xe.description})]}),e.jsx(je,{variant:"outline",className:`text-[10px] uppercase ${Cu(xe.priority)}`,children:xe.priority})]}),xe.suggested_text&&e.jsx("div",{className:"mt-2 p-2.5 rounded-md bg-muted/60 text-xs whitespace-pre-line border border-border/60",children:xe.suggested_text}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[xe.suggested_text&&e.jsxs(h,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>M(I,xe.suggested_text),children:[N===I?e.jsx(Et,{className:"w-3 h-3 mr-1"}):e.jsx(Lt,{className:"w-3 h-3 mr-1"}),N===I?m("cvImprove.copied","Kopieret"):m("cvImprove.copy","Kopiér forslag")]}),r&&e.jsxs(h,{type:"button",size:"sm",className:"h-7 text-xs",disabled:S!==null,onClick:()=>Y(I,xe),children:[S===I?e.jsx(ge,{className:"w-3 h-3 mr-1 animate-spin"}):e.jsx(la,{className:"w-3 h-3 mr-1"}),m("cvImprove.apply","Anvend med AI")]})]})]},I))})]}),((k=p.missing_sections)==null?void 0:k.length)>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(wt,{className:"w-4 h-4 text-primary"}),m("cvImprove.missingSections","Manglende sektioner")]}),e.jsx("ul",{className:"text-xs space-y-1 text-muted-foreground list-disc pl-5",children:p.missing_sections.map((xe,I)=>e.jsx("li",{children:xe},I))})]}),(($=p.strengths)==null?void 0:$.length)>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx($s,{className:"w-4 h-4 text-emerald-600"}),m("cvImprove.strengths","Styrker")]}),e.jsx("ul",{className:"text-xs space-y-1.5",children:p.strengths.map((xe,I)=>e.jsxs("li",{className:"text-muted-foreground",children:[e.jsxs("span",{className:"font-medium text-foreground",children:[xe.title,": "]}),xe.description]},I))})]}),(((K=p.formatting_tips)==null?void 0:K.length)>0||((re=p.ats_tips)==null?void 0:re.length)>0)&&e.jsxs("section",{className:"space-y-3",children:[((ve=p.formatting_tips)==null?void 0:ve.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1.5",children:m("cvImprove.formattingTips","Layout-tips")}),e.jsx("ul",{className:"text-xs space-y-1 text-muted-foreground list-disc pl-5",children:p.formatting_tips.map((xe,I)=>e.jsx("li",{children:xe},I))})]}),((ze=p.ats_tips)==null?void 0:ze.length)>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold mb-1.5 flex items-center gap-1.5",children:[e.jsx(Qn,{className:"w-3.5 h-3.5"}),m("cvImprove.atsTips","ATS-tips")]}),e.jsx("ul",{className:"text-xs space-y-1 text-muted-foreground list-disc pl-5",children:p.ats_tips.map((xe,I)=>e.jsx("li",{children:xe},I))})]})]}),e.jsx("div",{className:"pt-2",children:e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>void B(!0),disabled:l,children:[e.jsx(dt,{className:"w-3.5 h-3.5 mr-1.5"}),m("cvImprove.reanalyze","Analysér igen")]})})]})]})})},Su=/^[A-ZÆØÅ0-9][A-ZÆØÅ0-9\s\/&.,()-]+\|\s*\d{4}\s*[–-]\s*(\d{4}|nu|present|i dag)$/i,Du=s=>{const a=s.split(`
154`),t=[];a.forEach((m,c)=>{Gn(m)&&t.push(c)});let r=-1,n=a.length;for(let m=0;m<t.length;m++){const c=t[m],l=a[c].trim().replace(/^\*\*([\s\S]+?)\*\*$/,"$1").trim();if(pn(l)==="experience"){r=c,n=m+1<t.length?t[m+1]:a.length;break}}const d=[];if(r!==-1){const m=[];for(let c=r+1;c<n;c++)Su.test(a[c].trim())&&m.push(c);for(let c=0;c<m.length;c++){const l=m[c],f=c+1<m.length?m[c+1]:n;d.push({headerLine:l,endLine:f,label:a[l].trim()})}}return{lines:a,expHeader:r,expEnd:n,jobs:d}},Pu=({open:s,onOpenChange:a,cvContent:t,onCVUpdated:r})=>{const{t:n}
154=Je(),d=i.useMemo(()=>Du(t||""),[t]),{jobs:m,expHeader:c}=d,[l,f]=i.useState(""),[p,j]=i.useState(""),[g,P]=i.useState(""),[N,w]=i.useState(""),[S,A]=i.useState("top");i.useEffect(()=>{s&&(f(""),j(""),P(""),w(""),A("top"))},[s]);const y=()=>{const B=(l||n("cvAddJob.placeholderCompany","FIRMANAVN")).toUpperCase().trim(),M=(p||n("cvAddJob.placeholderPeriod","ÅÅÅÅ – nu")).trim().replace(/\s*[-–—]\s*/g," – ").replace(/\s+/g," "),Y=(g||n("cvAddJob.placeholderRole","Stillingsbetegnelse")).trim(),R=N.split(`
155`).map(Q=>Q.trim()).filter(Boolean).map(Q=>Q.startsWith("•")||Q.startsWith("-")?`• ${Q.replace(/^[•-]\s*/,"")}`:`• ${Q}`);return R.length===0&&R.push(`• ${n("cvAddJob.placeholderBullet","Beskriv dit ansvar og resultater her")}`),[`${B} | ${M}`,Y,...R].join(`
156`)},D=()=>{const B=y(),M=[...d.lines];if(c===-1){const re=`${M.join(`
157`).replace(/\s+$/,"")}
158
159${n("cvAddJob.experienceHeader","ERHVERVSERFARING")}
160${B}
161`;r(re.replace(/\n{3,}/g,`
162
163`)),a(!1);return}let Y;if(S==="top")for(Y=c+1;Y<d.expEnd&&M[Y].trim()==="";)Y++;else if(S==="bottom")for(Y=d.expEnd;Y>c+1&&M[Y-1].trim()==="";)Y--;else if(S.startsWith("after:")){const K=parseInt(S.slice(6),10),re=m[K];if(!re)Y=d.expEnd;else for(Y=re.endLine;Y>re.headerLine+1&&M[Y-1].trim()==="";)Y--}else Y=d.expEnd;const R=M.slice(0,Y),Q=M.slice(Y),k=["",B,""],$=[...R,...k,...Q].join(`
164`).replace(/\n{3,}/g,`
165
166`);r($),a(!1)};return e.jsx(ns,{open:s,onOpenChange:a,children:e.jsxs(rs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(os,{children:[e.jsx(is,{children:n("cvAddJob.title","Tilføj job til Erhvervserfaring")}),e.jsx(Qs,{children:n("cvAddJob.description","Udfyld jobbet og vælg, hvor det skal placeres. Du kan altid redigere det bagefter.")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{htmlFor:"cv-add-job-company",className:"text-xs",children:n("cvAddJob.company","Firma")}),e.jsx(ue,{id:"cv-add-job-company",value:l,onChange:B=>f(B.target.value),placeholder:n("cvAddJob.companyPlaceholder","ACME CORP")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{htmlFor:"cv-add-job-period",className:"text-xs",children:n("cvAddJob.period","Periode")}),e.jsx(ue,{id:"cv-add-job-period",value:p,onChange:B=>j(B.target.value),placeholder:n("cvAddJob.periodPlaceholder","2022 – nu")})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{htmlFor:"cv-add-job-role",className:"text-xs",children:n("cvAddJob.role","Stilling")}),e.jsx(ue,{id:"cv-add-job-role",value:g,onChange:B=>P(B.target.value),placeholder:n("cvAddJob.rolePlaceholder","Senior Project Manager")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{htmlFor:"cv-add-job-bullets",className:"text-xs",children:n("cvAddJob.bullets","Bullets (én pr. linje)")}),e.jsx(as,{id:"cv-add-job-bullets",value:N,onChange:B=>w(B.target.value),placeholder:n("cvAddJob.bulletsPlaceholder",`Ledede team på 8 personer
167Leverede projekt 20% under budget`),rows:4})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:n("cvAddJob.placement","Placering")}),e.jsxs(Rl,{value:S,onValueChange:A,className:"gap-1",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm py-1 cursor-pointer",children:[e.jsx(gn,{value:"top",id:"cv-add-job-top"}),e.jsx("span",{children:n("cvAddJob.placeTop","Øverst (nyeste)")})]}),m.map((B,M)=>{if(M===m.length-1)return null;const Y=m[M+1];return e.jsxs("label",{className:"flex items-center gap-2 text-sm py-1 cursor-pointer",children:[e.jsx(gn,{value:`after:${M}`,id:`cv-add-job-after-${M}`}),e.jsxs("span",{children:[n("cvAddJob.placeBetween","Mellem")," ",e.jsx("span",{className:"font-medium",children:B.label.split("|")[0].trim()})," ",n("cvAddJob.and","og")," ",e.jsx("span",{className:"font-medium",children:Y.label.split("|")[0].trim()})]})]},`between-${M}`)}),m.length>0&&e.jsxs("label",{className:"flex items-center gap-2 text-sm py-1 cursor-pointer",children:[e.jsx(gn,{value:"bottom",id:"cv-add-job-bottom"}),e.jsx("span",{children:n("cvAddJob.placeBottom","Nederst (ældste)")})]})]})]}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"ghost",onClick:()=>a(!1),children:n("common.cancel","Annullér")}),e.jsx(h,{onClick:D,children:n("cvAddJob.insert","Tilføj job")})]})]})})}
167,Fu={full_name:"",email:"",phone:"",street_address:"",postal_code:"",city:"",country:"",linkedin_url:"",cv_header_show_address:!1,cv_header_show_postal_code:!1,cv_header_show_country:!1,cv_header_show_linkedin:!1},ro=()=>{const{t:s}=Je(),[a,t]=i.useState(Fu),[r,n]=i.useState(!0),[d,m]=i.useState(!1),[c,l]=i.useState(!1),f=Pl();i.useEffect(()=>{(async()=>{const{data:{user:g}}=await C.auth.getUser();if(!g){n(!1);return}const{data:P}=await C.from("profiles").select("full_name, email, phone, street_address, postal_code, city, country, linkedin_url, cv_header_show_address, cv_header_show_postal_code, cv_header_show_country, cv_header_show_linkedin").eq("id",g.id).maybeSingle();P&&t({full_name:P.full_name||"",email:P.email||g.email||"",phone:P.phone||"",street_address:P.street_address||"",postal_code:P.postal_code||"",city:P.city||"",country:P.country||"",linkedin_url:P.linkedin_url||"",cv_header_show_address:P.cv_header_show_address??!1,cv_header_show_postal_code:P.cv_header_show_postal_code??!1,cv_header_show_country:P.cv_header_show_country??!1,cv_header_show_linkedin:P.cv_header_show_linkedin??!1}),n(!1)})()},[]),i.useEffect(()=>{r||window.dispatchEvent(new CustomEvent("cv-header-updated",{detail:{profile:{full_name:a.full_name||null,email:a.email||null,phone:a.phone||null,city:a.city||null,street_address:a.street_address||null,postal_code:a.postal_code||null,country:a.country||null,linkedin_url:a.linkedin_url||null,cv_header_show_address:a.cv_header_show_address,cv_header_show_postal_code:a.cv_header_show_postal_code,cv_header_show_country:a.cv_header_show_country,cv_header_show_linkedin:a.cv_header_show_linkedin}}}))},[a,r]),i.useEffect(()=>{if(r)return;const g=setTimeout(async()=>{m(!0);const{data:{user:P}}=await C.auth.getUser();if(!P){m(!1);return}const{error:N}=await C.from("profiles").update({full_name:a.full_name||null,phone:a.phone||null,street_address:a.street_address||null,postal_code:a.postal_code||null,city:a.city||null,country:a.country||null,linkedin_url:a.linkedin_url||null,cv_header_show_address:a.cv_header_show_address,cv_header_show_postal_code:a.cv_header_show_postal_code,cv_header_show_country:a.cv_header_show_country,cv_header_show_linkedin:a.cv_header_show_linkedin}).eq("id",P.id);m(!1),N&&J.error(s("common.error",{defaultValue:"Kunne ikke gemme"}))},400);return()=>clearTimeout(g)},[a]);const p=(g,P)=>{t(N=>({...N,[g]:P}))},j=async()=>{if(await f({title:s("cvHeaderData.applyAll.confirmTitle",{defaultValue:"Opdatér alle eksisterende CV'er?"}),description:s("cvHeaderData.applyAll.confirmDescription",{defaultValue:"Den øverste kontakt-blok (navn, adresse, telefon, e-mail osv.) bliver erstattet i alle dine gemte CV'er med de aktuelle indstillinger. Selve indholdet (profil, erhvervserfaring, uddannelse …) bevares uændret."}),confirmLabel:s("cvHeaderData.applyAll.confirm",{defaultValue:"Ja, opdatér alle CV'er"})})){l(!0);try{const P={full_name:a.full_name||null,email:a.email||null,phone:a.phone||null,city:a.city||null,street_address:a.street_address||null,postal_code:a.postal_code||null,country:a.country||null,linkedin_url:a.linkedin_url||null,cv_header_show_address:a.cv_header_show_address,cv_header_show_postal_code:a.cv_header_show_postal_code,cv_header_show_country:a.cv_header_show_country,cv_header_show_linkedin:a.cv_header_show_linkedin},N=qo(P).trim();if(!N){J.error(s("cvHeaderData.applyAll.emptyHeader",{defaultValue:"Kan ikke opdatere — kontakt-headeren er tom."}));return}const{data:{user:w}}=await C.auth.getUser();if(!w)return;const{data:S,error:A}=await C.from("career_documents").select("id, document_type, content").eq("user_id",w.id).in("document_type",["cv","cv_en"]);if(A)throw A;if(!(S!=null&&S.length)){J.info(s("cvHeaderData.applyAll.noDocs",{defaultValue:"Du har ingen gemte CV'er at opdatere endnu."}));return}const y=/^(profil|profile|resum[eé]|summary|erhvervserfaring|work\s+experience|professional\s+experience|experience|kompetencer|skills|core\s+competencies|uddannelse|education|kvalifikationer|qualifications|sprog|languages?|it-?kompetencer|it\s+skills|kurser|courses|certificeringer|certifications)\s*:?\s*$/i;let D=0,B=0;for(const M of S){const Y=(M.content||"").replace(/\r\n/g,`
168`),R=Y.split(`
169`);let Q=-1;const k=Math.min(R.length,40);for(let ze=0;ze<k;ze++)if(y.test(R[ze].trim())){Q=ze;break}if(Q<0){B+=1;continue}let $=Q;for(;$>0&&R[$-1].trim()==="";)$-=1;const K=R.slice($).join(`
170`),re=`${N}
171
172${K}`;if(re===Y)continue;const{error:ve}=await C.from("career_documents").update({content:re,updated_at:new Date().toISOString()}).eq("id",M.id);if(ve)throw ve;D+=1}window.dispatchEvent(new CustomEvent("career-documents-changed")),D===0&&B===0?J.success(s("cvHeaderData.applyAll.allUpToDate",{defaultValue:"Alle CV'er er allerede opdaterede ✓"})):J.success(s("cvHeaderData.applyAll.done",{defaultValue:"Opdaterede {{updated}} CV'er. Sprunget over: {{skipped}}.",updated:D,skipped:B}))}catch(P){console.error("[CvHeaderDataCard] applyHeaderToAllCvs failed",P),J.error(s("cvHeaderData.applyAll.error",{defaultValue:"Kunne ikke opdatere alle CV'er. Prøv igen."}))}finally{l(!1)}}};return e.jsxs(ye,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"font-semibold text-foreground text-lg flex items-center gap-2",children:[e.jsx(Hl,{className:"w-5 h-5 text-primary"}),s("cvHeaderData.title",{defaultValue:"Navn og kontaktdata til CV og Kandidatbrief"})]}),d&&e.jsx(ge,{className:"w-4 h-4 animate-spin text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6 whitespace-pre-line",children:s("cvHeaderData.description",{defaultValue:"Vælg hvilke data, der skal stå i headeren på dit CV og din Kandidatbrief. Navn, by, telefon og e-mail vises altid."})}),r?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ge,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(se,{htmlFor:"hd-name",children:s("cvHeaderData.name",{defaultValue:"Navn"})}),e.jsx(je,{variant:"secondary",className:"text-[10px]",children:s("cvHeaderData.alwaysShown",{defaultValue:"Vises altid"})})]}),e.jsx(ue,{id:"hd-name",value:a.full_name,onChange:g=>p("full_name",g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(se,{htmlFor:"hd-city",children:s("cvHeaderData.city",{defaultValue:"By"})}),e.jsx(je,{variant:"secondary",className:"text-[10px]",children:s("cvHeaderData.alwaysShown",{defaultValue:"Vises altid"})})]}),e.jsx(ue,{id:"hd-city",value:a.city,onChange:g=>p("city",g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(se,{htmlFor:"hd-phone",children:s("cvHeaderData.phone",{defaultValue:"Telefon"})}),e.jsx(je,{variant:"secondary",className:"text-[10px]",children:s("cvHeaderData.alwaysShown",{defaultValue:"Vises altid"})})]}
172),e.jsx(ue,{id:"hd-phone",value:a.phone,onChange:g=>p("phone",g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(se,{htmlFor:"hd-email",children:s("cvHeaderData.email",{defaultValue:"E-mail"})}),e.jsx(je,{variant:"secondary",className:"text-[10px]",children:s("cvHeaderData.alwaysShown",{defaultValue:"Vises altid"})})]}),e.jsx(ue,{id:"hd-email",type:"email",value:a.email,disabled:!0,className:"bg-muted"})]})]}),e.jsxs("div",{className:"border-t border-border pt-5 space-y-4",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("cvHeaderData.optionalTitle",{defaultValue:"Valgfri felter"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(se,{htmlFor:"hd-address",children:s("cvHeaderData.address",{defaultValue:"Adresse"})}),e.jsx(Ta,{checked:a.cv_header_show_address,onCheckedChange:g=>p("cv_header_show_address",g)})]}),e.jsx(ue,{id:"hd-address",value:a.street_address,onChange:g=>p("street_address",g.target.value),placeholder:s("cvHeaderData.addressPlaceholder",{defaultValue:"Vej og nummer"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(se,{htmlFor:"hd-postal",children:s("cvHeaderData.postalCode",{defaultValue:"Postnummer"})}),e.jsx(Ta,{checked:a.cv_header_show_postal_code,onCheckedChange:g=>p("cv_header_show_postal_code",g)})]}),e.jsx(ue,{id:"hd-postal",value:a.postal_code,onChange:g=>p("postal_code",g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(se,{htmlFor:"hd-country",children:s("cvHeaderData.country",{defaultValue:"Land"})}),e.jsx(Ta,{checked:a.cv_header_show_country,onCheckedChange:g=>p("cv_header_show_country",g)})]}),e.jsx(ue,{id:"hd-country",value:a.country,onChange:g=>p("country",g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(se,{htmlFor:"hd-linkedin",children:s("cvHeaderData.linkedin",{defaultValue:"LinkedIn-profil URL"})}),e.jsx(Ta,{checked:a.cv_header_show_linkedin,onCheckedChange:g=>p("cv_header_show_linkedin",g)})]}),e.jsx(ue,{id:"hd-linkedin",type:"url",value:a.linkedin_url,onChange:g=>p("linkedin_url",g.target.value),placeholder:"https://www.linkedin.com/in/..."})]})]}),e.jsx("div",{className:"border-t border-border pt-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:s("cvHeaderData.applyAll.hint",{defaultValue:"Ændringer ovenfor gælder automatisk for nye CV'er. Vil du også opdatere kontakt-headeren i alle dine eksisterende CV'er?"})}),e.jsxs(h,{type:"button",variant:"outline",onClick:j,disabled:c||r,className:"shrink-0",children:[c?e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(dt,{className:"w-4 h-4 mr-2"}),s("cvHeaderData.applyAll.button",{defaultValue:"Opdatér alle mine CV'er"})]})]})})]})]})},hl=40,Au=({open:s,onOpenChange:a,cvContent:t,presentSectionKeys:r,displayNameForKey:n,onCVUpdated:d,onSectionAdded:m})=>{const{t:c}=Je(),[l,f]=i.useState(""),[p,j]=i.useState(""),[g,P]=i.useState("end"),[N,w]=i.useState("");i.useEffect(()=>{s&&(f(""),j(""),P("end"),w(r[r.length-1]??""))},[s,r]);const S=()=>{const A=l.trim();if(!A){J.error(c("cvCustomSection.titleRequired","Angiv en titel til sektionen"));return}if(A.length>hl){J.error(c("cvCustomSection.titleTooLong","Titlen må maksimalt være 40 tegn"));return}if(pn(A)){J.error(c("cvCustomSection.titleCollision","Der findes allerede en standard-sektion med den titel. Brug 'Foreslå sektion' i stedet."));return}const y=Sc(A);if(r.includes(y)){J.error(c("cvCustomSection.titleDuplicate","Der findes allerede en sektion med den titel"));return}const D=p.trim()||c("cvCustomSection.emptyPlaceholder","• [Tilføj indhold her]"),B=g==="after"&&N?Ml(t,N,A,D):Er(t,A,D);d(B),m==null||m(y),J.success(c("cvCustomSection.added","Egen sektion indsat i CV'et")),a(!1)};return e.jsx(ns,{open:s,onOpenChange:a,children:e.jsxs(rs,{className:"sm:max-w-lg",children:[e.jsxs(os,{children:[e.jsx(is,{children:c("cvCustomSection.title","Opret egen sektion")}),e.jsx(Qs,{children:c("cvCustomSection.description","Giv sektionen en titel og skriv selv indholdet. Sektionen vises i alle CV-designs og kan flyttes, redigeres og slettes som alle andre.")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(se,{htmlFor:"custom-section-title",className:"text-xs",children:c("cvCustomSection.titleLabel","Titel")}),e.jsx(ue,{id:"custom-section-title",value:l,maxLength:hl,onChange:A=>f(A.target.value),placeholder:c("cvCustomSection.titlePlaceholder","Fx 'Publikationer', 'Foredrag', 'Tekniske interesser'"),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(se,{htmlFor:"custom-section-body",className:"text-xs",children:c("cvCustomSection.bodyLabel","Indhold (valgfrit)")}),e.jsx(as,{id:"custom-section-body",value:p,onChange:A=>j(A.target.value),placeholder:c("cvCustomSection.bodyPlaceholder","Skriv indholdet, fx bullet-punkter (• …) eller korte afsnit. Lades feltet tomt indsættes et placeholder-punkt du selv udfylder bagefter."),className:"text-sm min-h-[140px]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-xs",children:c("cvCustomSection.placementLabel","Placering")}),e.jsxs(Rl,{value:g,onValueChange:A=>P(A),className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gn,{value:"end",id:"placement-end"}),e.jsx(se,{htmlFor:"placement-end",className:"text-xs font-normal cursor-pointer",children:c("cvCustomSection.placementEnd","Nederst i CV'et")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gn,{value:"after",id:"placement-after"}),e.jsx(se,{htmlFor:"placement-after",className:"text-xs font-normal cursor-pointer",children:c("cvCustomSection.placementAfter","Efter en bestemt sektion")})]})]}),g==="after"&&e.jsxs(Pt,{value:N,onValueChange:w,children:[e.jsx(Ft,{className:"text-xs h-8",children:e.jsx(At,{placeholder:c("cvCustomSection.placementAfterPlaceholder","Vælg sektion")})}),e.jsx(It,{children:r.map(A=>e.jsx(Ue,{value:A,className:"text-xs",children:n(A)},A))})]})]})]}),e.jsxs(Bt,{className:"gap-2",children:[e.jsx(h,{type:"button",variant:"ghost",onClick:()=>a(!1),children:c("common.cancel","Annullér")}),e.jsx(h,{type:"button",onClick:S,children:c("cvCustomSection.submit","Indsæt sektion")})]})]})})},An=()=>{const s=document.activeElement;return!(s instanceof HTMLElement)||s.getAttribute("contenteditable")!=="true"||!s.closest("[data-cv-preview-root='true']")?null:s},ii=()=>{const s=window.getSelection();if(!s||s.rangeCount===0)return null;const a=An();if(!a)return null;let t=s.getRangeAt(0).startContainer;for(;t&&t!==a;){if(t instanceof HTMLElement&&t.dataset.editLine==="true")return t;t=t.parentNode}return null},mr=s=>{s.dispatchEvent(new Event("input",{bubbles:!0}))},xl=s=>{const a=An();a&&(document.execCommand(s,!1),mr(a))},Iu=()=>{const s=ii(),a=An();if(!s||!a)return;if(s.dataset.lineType==="bullet"){const r=s.querySelector('[data-bullet-content="true"]'),n=(r==null?void 0:r.innerHTML)||"";s.removeAttribute("data-line-type"),s.removeAttribute("style"),s.innerHTML=n||"<br/>"}else{const r=s.innerHTML||"<br/>";s.dataset.lineType="bullet",s.style.display="flex",s.style.alignItems="start",s.style.gap="0.35em";const n=document.createElement("span");n.dataset.bulletMarker="true",n.setAttribute("contenteditable","false"),n.style.flexShrink="0",n.textContent="•";const d=document.createElement("span");d.dataset.bulletContent="true",d.innerHTML=r,s.innerHTML="",s.append(n,d)}mr(a),a.focus()},Lu=()=>{const s=ii(),a=An();if(!s||!a)return;const t=(s.textContent||"").trim();if(!t)return;t===t.toUpperCase()&&/[A-ZÆØÅ]/.test(t)?s.textContent=t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():s.textContent=t.toUpperCase(),mr(a),a.focus()},Eu=()=>{const s=ii(),a=An();if(!a)return;const t=document.createElement("div");t.dataset.editLine="true",t.textContent="———",s&&s.parentNode?s.insertAdjacentElement("afterend",t):a.appendChild(t),mr(a),a.focus()},pl=["black","navy","slate","sage","dustyRose","warmTaupe","charcoal","steelBlue","burgundy","forest","plum","terracotta","ocean","mauve","olive","copper","midnight","lavender","clay","teal","espresso"],Ka={black:"#000000",navy:"#1e3a5f",slate:"#47
1725569",sage:"#5f7a6a",dustyRose:"#b07d8e",warmTaupe:"#8b7d6b",charcoal:"#2d3436",steelBlue:"#4a7c9b",burgundy:"#722f37",forest:"#2d5a3d",plum:"#5b3256",terracotta:"#a0522d",ocean:"#2e6b7b",mauve:"#7a5980",olive:"#6b7042",copper:"#8b5e3c",midnight:"#1a1a2e",lavender:"#7b6b8a",clay:"#9b7653",teal:"#3a7d7e",espresso:"#3c2415"},Tu=["compact","normal","spacious"],zu=["line","thick","dotted","none"],Ou=[{id:"white",hex:"#ffffff"},{id:"cream",hex:"#fdf8f0"},{id:"light-gray",hex:"#f5f5f4"}],Vu=["none","outline","filled"],Mu=new Set(["minimal","minimalistisk","board","compact","swiss","magazine","executive","executive-board","premium","fotohoved","tidslinje","timeline","timeline-vertical","storyteller","infographic","data-driven"]),Wa=({onClick:s,title:a,children:t})=>e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(h,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onMouseDown:r=>{r.preventDefault(),s()},children:t})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:a})})]}),Vt=({title:s,icon:a,children:t,contentClassName:r})=>e.jsxs(ta,{children:[e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(aa,{asChild:!0,children:e.jsx(h,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",children:a})})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:s})})]}),e.jsxs(na,{align:"start",className:r??"w-64 p-3 space-y-2",onOpenAutoFocus:n=>n.preventDefault(),children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:s}),t]})]}),on=({selected:s,onClick:a,children:t})=>e.jsxs("button",{type:"button",onMouseDown:r=>r.preventDefault(),onClick:a,className:`w-full flex items-center justify-between gap-2 px-2 py-1.5 rounded-md text-left text-xs transition-colors ${s?"bg-primary/10 text-foreground":"hover:bg-muted text-foreground"}`,children:[e.jsx("span",{className:"truncate",children:t}),s&&e.jsx(Et,{className:"w-3.5 h-3.5 text-primary shrink-0"})]}),$u=({rawId:s,onToggle:a,onDelete:t})=>{const{t:r}=Je(),{id:n,disabled:d}=fa(s),{attributes:m,listeners:c,setNodeRef:l,transform:f,transition:p,isDragging:j}=qc({id:s}),g={transform:Jc.Transform.toString(f),transition:p},P=n.startsWith("custom_")?n.slice(7).replace(/_/g," ").replace(/^\w/,N=>N.toUpperCase()):r(`cvCustomization.sectionNames.${n}`);return e.jsxs("div",{ref:l,style:g,className:`flex items-center gap-2 px-2 py-1.5 rounded-md border text-xs ${j?"border-primary bg-primary/5":d?"border-border/50 bg-muted/30":"border-border bg-background"}`,children:[e.jsx("div",{...m,...c,className:"cursor-grab",children:e.jsx(Fl,{className:"w-3 h-3 text-muted-foreground shrink-0"})}),e.jsx("span",{className:`flex-1 ${d?"text-muted-foreground line-through":""}`,children:P}),e.jsx("button",{type:"button",onMouseDown:N=>N.preventDefault(),onClick:()=>a(s),className:"text-[10px] px-1.5 py-0.5 rounded border border-border hover:bg-muted",title:d?r("cvCustomization.show","Vis"):r("cvCustomization.hide","Skjul"),children:d?r("cvCustomization.show","Vis"):r("cvCustomization.hide","Skjul")}),e.jsx("button",{type:"button",onMouseDown:N=>N.preventDefault(),onClick:()=>t(s),className:"text-[10px] px-1.5 py-0.5 rounded border border-destructive/40 text-destructive hover:bg-destructive/10",title:r("cvCustomization.delete","Slet"),"aria-label":r("cvCustomization.delete","Slet"),children:e.jsx(Ss,{className:"w-3 h-3"})})]})},Ru=["kronologisk","funktionelt","kombineret","akademisk"],Uu=s=>{const{t:a,i18n:t}=Je(),[r,n]=i.useState(!1),[d,m]=i.useState(null),[c,l]=i.useState(""),[f,p]=i.useState(""),[j,g]=i.useState(!1),[P,N]=i.useState(!1),[w,S]=i.useState(!1),[A,y]=i.useState(null),[D,B]=i.useState(!1),[M,Y]=i.useState(!1),[R,Q]=i.useState(!1),[k,$]=i.useState(!1),[K,re]=i.useState(!1),[ve,ze]=i.useState(()=>tr()),{data:xe}=Jo(),I=Fc(Bi(Lc,{activationConstraint:{distance:5}}),Bi(Ic,{coordinateGetter:Ac})),E=async()=>{var _;if(!f.trim()||!s.cvContent){J.error(a("cvCustomization.writeChangeError","Skriv venligst en ændring"));return}g(!0);try{const{data:{session:Z}}=await C.auth.getSession();if(!Z){J.error(a("cvCustomization.loginRequired","Log ind for at fortsætte"));return}const H=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/edit-document-with-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Z.access_token}`},body:JSON.stringify({content:s.cvContent,instructions:f,documentType:"cv",cv_language_voice:s.languageVoice??"we",cv_language_formality:s.languageFormality??"formal",focu
172sInstruction:ve||void 0})});if(!H.ok){const x=await H.json().catch(()=>({}));throw new Error(x.error||a("cvCustomization.aiEditError","Kunne ikke opdatere CV"))}const ne=await H.json();(_=s.onCVUpdated)==null||_.call(s,ne.editedContent),J.success(a("cvCustomization.aiEditSuccess","CV opdateret")),p("")}catch(Z){console.error("AI edit error:",Z),J.error(Z instanceof Error?Z.message:a("cvCustomization.genericError","Der opstod en fejl"))}finally{g(!1)}},F=_=>{var Z;(Z=s.onDesignChange)==null||Z.call(s,_)},ee=(t.language||"da").toLowerCase().startsWith("en")?"en":"da",Le=async()=>{var _;if(!(!s.cvContent||!s.onCVUpdated)){y("personality"),B(!1);try{const{data:{session:Z}}=await C.auth.getSession();if(!Z){J.error(a("cvCustomization.loginRequired","Log ind for at fortsætte"));return}const{data:H,error:ne}=await C.functions.invoke("generate-cv-personality-section",{body:{language:ee}});if(ne)throw ne;if(!(H!=null&&H.ok)||!(H!=null&&H.text)){J.error((H==null?void 0:H.error)||a("cvSectionSuggest.personalityError","Kunne ikke generere personlighedstekst"));return}const x=a("cvSectionSuggest.personalityHeader","Min personlighed"),z=Ml(s.cvContent,["profile","career_goals"],x,H.text);s.onCVUpdated(z);const b=T.slice(),U=b.map(te=>fa(te).id);if(!U.includes("personality")){const te=U.indexOf("career_goals"),fe=U.indexOf("profile"),Se=(te!==-1?te:fe)+1;Se>0?b.splice(Se,0,"personality"):b.push("personality"),(_=s.onSectionOrderChange)==null||_.call(s,b)}H.isKomplet?J.success(a("cvSectionSuggest.personalityAdded","Personlighedssektion indsat")):J.success(a("cvSectionSuggest.personalityAddedFallback","Sektionen er indsat. Tip: Tag den Komplette Personanalyse for endnu mere præcis tekst."),{duration:6e3})}catch(Z){console.error("insertPersonalitySection error:",Z),J.error(a("cvSectionSuggest.personalityError","Kunne ikke generere personlighedstekst"))}finally{y(null)}}},pe=()=>{var ne;if(!s.cvContent||!s.onCVUpdated)return;B(!1);const _=a("cvSectionSuggest.privateHeader","Privat / Fritid"),Z=a("cvSectionSuggest.privatePlaceholder",`Civilstand: [redigér her]
173Børn: [redigér her]
174
175Fritidsinteresser og hobbyer:
176• [Tilføj din interesse]
177• [Tilføj din interesse]
178• [Tilføj din interesse]`),H=Er(s.cvContent,_,Z);s.onCVUpdated(H),T.includes("private_life")||(ne=s.onSectionOrderChange)==null||ne.call(s,[...T,"private_life"]),J.success(a("cvSectionSuggest.privateAdded","Privat/Fritid-sektion indsat. Udfyld selv felterne."))},Oe=async(_,Z,H)=>{var ne;if(!(!s.cvContent||!s.onCVUpdated)){y(_),B(!1);try{const{data:{session:x}}=await C.auth.getSession();if(!x){J.error(a("cvCustomization.loginRequired","Log ind for at fortsætte"));return}const{data:z,error:b}=await C.functions.invoke("extract-cv-section",{body:{kind:_,language:ee}});if(b)throw b;if(!(z!=null&&z.ok)||!(z!=null&&z.text)){J.error((z==null?void 0:z.error)||a("cvSectionSuggest.extractError","Kunne ikke generere sektionen"));return}const U=Er(s.cvContent,H,z.text);s.onCVUpdated(U),T.includes(Z)||(ne=s.onSectionOrderChange)==null||ne.call(s,[...T,Z]),z.source==="lorem"?J.success(a("cvSectionSuggest.addedLorem","Sektionen er indsat med en skabelon. Udfyld selv felterne."),{duration:6e3}):J.success(a("cvSectionSuggest.addedFromData","Sektionen er indsat fra dine data"))}catch(x){console.error("insertExtractedSection error:",x),J.error(a("cvSectionSuggest.extractError","Kunne ikke generere sektionen"))}finally{y(null)}}},he=_=>{var Z;(Z=s.onCVTypeChange)==null||Z.call(s,_)},we=(()=>{if(!s.cvContent)return[];const _=new Set,Z=[];for(const H of s.cvContent.split(`
179`)){if(!Gn(H))continue;const ne=H.trim().replace(/^\*\*([\s\S]+?)\*\*$/,"$1").trim();let x=pn(ne);x||(x="custom_"+ne.toLowerCase().replace(/[^a-zæøå0-9]+/gi,"_").replace(/^_|_$/g,"")),_.has(x)||(_.add(x),Z.push(x))}return _.has("contact")||Z.unshift("contact"),Z})(),T=(()=>{var H;const _=new Map,Z=(H=s.sectionOrder)!=null&&H.length?s.sectionOrder:[];for(const ne of Z){const{id:x,disabled:z,column:b}=fa(ne),U=x==="summary"?"profile":x;_.set(U,Ki(U,z,b))}return we.map(ne=>_.get(ne)??ne)})(),ae=(_,Z)=>{const H=_.split(`
180`),ne=[];
180if(H.forEach((te,fe)=>{Gn(te)&&ne.push(fe)}),ne.length<2)return _;const x=H.slice(0,ne[0]),z=[];for(let te=0;te<ne.length;te++){const fe=ne[te],Se=te+1<ne.length?ne[te+1]:H.length,G=H.slice(fe,Se),Fe=G[0].trim().replace(/^\*\*([\s\S]+?)\*\*$/,"$1").trim(),Ee=pn(Fe)??"custom_"+Fe.toLowerCase().replace(/[^a-zæøå0-9]+/gi,"_").replace(/^_|_$/g,"");z.push({key:Ee,raw:G})}const b=[],U=new Set;for(const te of Z){if(te==="contact")continue;const fe=z.findIndex((Se,G)=>!U.has(G)&&Se.key===te);fe!==-1&&(b.push(z[fe]),U.add(fe))}return z.forEach((te,fe)=>{U.has(fe)||b.push(te)}),[...x,...b.flatMap(te=>te.raw)].join(`
181`)},me=_=>{var b;const{active:Z,over:H}=_;if(!H||Z.id===H.id)return;const ne=T.indexOf(Z.id),x=T.indexOf(H.id);if(ne===-1||x===-1)return;const z=Yc(T,ne,x);if((b=s.onSectionOrderChange)==null||b.call(s,z),s.cvContent&&s.onCVUpdated){const U=z.map(fe=>fa(fe).id),te=ae(s.cvContent,U);te!==s.cvContent&&s.onCVUpdated(te)}},Ae=_=>{var z;const{id:Z,disabled:H,column:ne}=fa(_),x=Ki(Z,!H,ne);(z=s.onSectionOrderChange)==null||z.call(s,T.map(b=>b===_?x:b))},oe=_=>{var H;const{id:Z}=fa(_);if(Z!=="contact"){if(s.cvContent&&s.onCVUpdated){const ne=s.cvContent.split(`
182`),x=[];ne.forEach((U,te)=>{Gn(U)&&x.push(te)});let z=-1,b=ne.length;for(let U=0;U<x.length;U++){const te=x[U],fe=ne[te].trim().replace(/^\*\*([\s\S]+?)\*\*$/,"$1").trim();if((pn(fe)??"custom_"+fe.toLowerCase().replace(/[^a-zæøå0-9]+/gi,"_").replace(/^_|_$/g,""))===Z){z=te,b=U+1<x.length?x[U+1]:ne.length;break}}if(z!==-1){const U=[...ne.slice(0,z),...ne.slice(b)].join(`
183`).replace(/\n{3,}/g,`
184
185`).replace(/\s+$/,"")+`
186`;s.onCVUpdated(U)}}(H=s.onSectionOrderChange)==null||H.call(s,T.filter(ne=>ne!==_))}},Ve=_=>{const{id:Z}=fa(_);Z!=="contact"&&m(_)},Xe=T.map(_=>fa(_).id),cs=Ec.filter(_=>!Xe.includes(_)),hs=_=>{if(!s.cvContent||!s.onCVUpdated)return;const H=s.cvContent.replace(/\s+$/,""),ne=a("cvCustomization.newSectionPlaceholder.paragraph1","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."),x=a("cvCustomization.newSectionPlaceholder.paragraph2","Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."),z=a("cvCustomization.newSectionPlaceholder.bullet1","Duis aute irure dolor in reprehenderit in voluptate velit esse."),b=a("cvCustomization.newSectionPlaceholder.bullet2","Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia."),U=`${ne}
187
188${x}
189
190• ${z}
191• ${b}`,te=`${H}
192
193${_.toUpperCase()}
194${U}
195`;s.onCVUpdated(te)},ps=_=>{var H;const Z=a(`cvCustomization.sectionNames.${_}`,_);hs(Z),(H=s.onSectionOrderChange)==null||H.call(s,[...T,_]),n(!1),l("")},ms=()=>{var H;const _=c.trim();if(!_)return;const Z="custom_"+_.toLowerCase().replace(/[^a-zæøå0-9]+/gi,"_").replace(/^_|_$/g,"");Xe.includes(Z)||(hs(_),(H=s.onSectionOrderChange)==null||H.call(s,[...T,Z]),n(!1),l(""))},De=!!(s.onFontPairChange||s.onFontSizeChange||s.onLineSpacingChange||s.onAccentColorChange||s.onHeaderColorChange||s.onPaperColorChange||s.onSeparatorStyleChange||s.onIconStyleChange||s.onSectionOrderChange);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sticky top-0 z-20 flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/40 backdrop-blur-sm flex-wrap rounded-t-lg",children:[e.jsx("span",{className:"text-xs text-muted-foreground mr-2 ml-1 hidden sm:inline",children:a("cvPreview.toolbarHint","Klik i CV'et og formatér:")}),s.onTogglePhotoPanel&&e.jsxs(e.Fragment,{children:[e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(h,{type:"button",variant:s.showPhotoPanel?"default":"ghost",size:"icon",className:"h-8 w-8",onMouseDown:_=>{var Z;_.preventDefault(),(Z=s.onTogglePhotoPanel)==null||Z.call(s)},children:e.jsx(kc,{className:"w-4 h-4"})})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:a("careerDocs.portraitPhoto","Portrætbillede")})})]}),e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(h,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onMouseDown:_=>{_.preventDefault(),$(!0)},children:e.jsx(Hl,{className:"w-4 h-4"})})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs max-w-[220px]",children:a("cvHeaderData.tooltip","Redigér navn, adresse, e-mail og LinkedIn — vises i CV-headeren.")})})]})]}),e.jsx(ns,{open:k,onOpenChange:$,children:e.jsxs(rs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsx(is,{children:a("cvHeaderData.dialogTitle","Kontaktdata i CV-header")})}),e.jsx(ro,{})]})}),e.jsx(Wa,{onClick:()=>xl("bold"),title:a("careerDocs.bold","Fed"),children:e.jsx(Dc,{className:"w-4 h-4"})}),e.jsx(Wa,{onClick:()=>xl("italic"),title:a("careerDocs.italic","Kursiv"),children:e.jsx(dd,{className:"w-4 h-4"})}),e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsx(Wa,{onClick:Lu,title:a("careerDocs.sectionHeader","Sektionsoverskrift"),children:e.jsx(Pc,{className:"w-4 h-4"})}),e.jsx(Wa,{onClick:Iu,title:a("careerDocs.bulletList","Punktliste"),children:e.jsx(Xc,{className:"w-4 h-4"})}),e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsx(Wa,{onClick:Eu,title:a("careerDocs.divider","Vandret linje"),children:e.jsx(zr,{className:"w-4 h-4"})}),s.onUndo&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsxs(h,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",disabled:!s.undoCount,onMouseDown:_=>{var Z;_.preventDefault(),(Z=s.onUndo)==null||Z.call(s)},children:[e.jsx($l,{className:"w-4 h-4"}),!!s.undoCount&&e.jsx(je,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:s.undoCount})]})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:a("careerDocs.undo","Fortryd")})})]})]}),(s.onCVUpdated||s.onDesignChange||s.onCVTypeChange)&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),s.onDesignChange&&e.jsxs(ns,{open:P,onOpenChange:N,children:[e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(Na,{asChild:!0,children:e.jsx(h,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(er,{className:"w-4 h-4"})})})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:a("cvCustomization.tabDesign","Design")})})]}),e.jsxs(rs,{className:"max-w-5xl max-h-[85vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsx(is,{children:a("cvDesignSelector.title","Vælg CV-design")})}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-6 pt-2",children:Tc.map(_=>{const Z={id:_,name:a(`cvDesignSelector.designs.${_}.name`,_),description:a(`cvDesignSelector.designs.${_}.description`,""),...zc[_]};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Yo,{design:Z,isSelected:s.selectedDesign===_,onClick:()=>{F(_),N(!1)},cvData:xe}),e.jsx("p",{className:"text-center text-sm font-medium text-foreground",children:Z.name})]},_)})})]})]}),s.onCVTypeChange&&e.jsx(Vt,{title:a("cvCustomization.tabType","CV-type"),icon:e.jsx(md,{className:"w-4 h-4"}),contentClassName:"w-64 p-2 space-y-1",children:Ru.map(_=>e.jsx(on,{selected:s.selectedCVType===_,onClick:()=>he(_),children:a(`cvCustomization.cvTypeFallbacks.${_}.title`,_)},_))}),s.onCvPagesChange&&e.jsxs(Vt,{title:a("careerDocs.cvLengthLabel","Ønsket CV-længde (A4-sider)"),icon:e.jsx(cd,{className:"w-4 h-4"}),contentClassName:"w-64 p-3 space-y-2",children:[e.jsx("div",{className:"grid grid-cols-4 gap-1",children:[1,2,3,4].map(_=>e.jsx(h,{type:"button",size:"sm",variant:s.selectedCvPages===_?"default":"outline",className:"text-xs h-8",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{var Z;return(Z=s.onCvPagesChange)==null?void 0:Z.call(s,s.selectedCvPages===_?null:_)},children:a(`careerDocs.cvPages${_}`,`${_} side${_>1?"r":""}`)},_))}),s.onRegenerateCV&&e.jsx(h,{type:"button",size:"sm",className:"w-full gap-2",disabled:s.isRegeneratingCV,onMouseDown:_=>_.preventDefault(),onClick:()=>{var _;return(_=s.onRegenerateCV)==null?void 0:_.call(s,s.selectedCvPages??null)},children:s.isRegeneratingCV?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}),a("careerDocs.regenerating","Genererer...")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-3.5 h-3.5"}),a("careerDocs.regenerateWithLength","Generér CV med valgt længde")]})})]}),s.onLanguageVoiceChange&&e.jsxs(Vt,{title:a("cvCustomization.languageStyle","Sprogstil"),icon:e.jsx(ud,{className:"w-4 h-4"}),contentClassName:"w-72 p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:a("cvCustomization.languageVoice","Personligt udtryk")}),e.jsx("div",{className:"grid grid-cols-2 gap-1",children:["we","i"].map(_=>e.jsx(h,{type:"button",size:"sm",variant:s.languageVoice===_?"default":"outline",className:"text-xs h-8",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{var Z;return(Z=s.onLanguageVoiceChange)==null?void 0:Z.call(s,_)},children:_==="we"?a("cvCustomization.voiceWe","Vi-sprog (neutralt)"):a("cvCustomization.voiceI","Jeg-sprog (personligt)")},_))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:a("cvCustomization.languageFormality","Tone")}),e.jsx("div",{className:"grid grid-cols-2 gap-1",children:["formal","informal"].map(_=>e.jsx(h,{type:"button",size:"sm",variant:s.languageFormality===_?"default":"outline",className:"text-xs h-8",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{var Z;return(Z=s.onLanguageFormalityChange)==null?void 0:Z.call(s,_)},children:_==="formal"?a("cvCustomization.formalityFormal","Formel"):a("cvCustomization.formalityInformal","Uformel")},_))})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground leading-snug",children:a("cvCustomization.languageStyleHint","Bruges når CV'et genereres eller redigeres med AI.")})]}),s.cvContent&&s.onCVUpdated&&e.jsx(Wa,{title:a("cvCustomization.antiAITitle","Gør mindre AI-agtigt"),onClick:()=>S(!0),children:e.jsx(la,{className:"w-4 h-4"})})]}),De&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),s.onFontPairChange&&e.jsx(Vt,{title:a("cvCustomization.fontType","Skrifttype"),icon:e.jsx(Wi,{className:"w-4 h-4"}),contentClassName:"w-64 p-2 space-y-1 max-h-80 overflow-y-auto",children:Oc.map(_=>e.jsx(on,{selected:s.fontPair===_.id,onClick:()=>{var Z;return(Z=s.onFontPairChange)==null?void 0:Z.call(s,_.id)},children:e.jsx("span",{style:{fontFamily:_.heading},children:a(`cvCustomization.fontPairs.${_.id}.name`)})},_.id))}),s.onFontSizeChange&&e.jsx(Vt,{title:a("cvCustomization.fontSize","Skriftstørrelse"),icon:e.jsx(Vc,{className:"w-4 h-4"}),contentClassName:"w-52 p-2 space-y-1",children:Mc.map(_=>e.jsxs(on,{selected:s.fontSize===_.id,onClick:()=>{var Z;return(Z=s.onFontSizeChange)==null?void 0:Z.call(s,_.id)},children:[a(`cvCustomization.fontSizes.${_.id}.name`)," · ",_.bodySize]},_.id))}),s.onLineSpacingChange&&e.jsx(Vt,{title:a("cvCustomization.lineSpacing","Linjeafstand"),icon:e.jsx($c,{
195className:"w-4 h-4"}),contentClassName:"w-52 p-2 space-y-1",children:Tu.map(_=>e.jsx(on,{selected:s.lineSpacing===_,onClick:()=>{var Z;return(Z=s.onLineSpacingChange)==null?void 0:Z.call(s,_)},children:a(`cvCustomization.lineSpacings.${_}.name`)},_))}),e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),s.onAccentColorChange&&e.jsx(Vt,{title:a("cvCustomization.accentColor","Accentfarve"),icon:e.jsxs("div",{className:"relative",children:[e.jsx(Rc,{className:"w-4 h-4"}),e.jsx("span",{className:"absolute -bottom-0.5 left-0 right-0 h-1 rounded-sm",style:{backgroundColor:s.accentColor||"#1e3a5f"}})]}),contentClassName:"w-64 p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[pl.map(_=>e.jsx("button",{type:"button",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{var Z;return(Z=s.onAccentColorChange)==null?void 0:Z.call(s,Ka[_])},className:`w-6 h-6 rounded-full border-2 transition-all ${s.accentColor===Ka[_]?"border-foreground scale-110":"border-transparent"}`,style:{backgroundColor:Ka[_]},title:a(`cvCustomization.presetColors.${_}`)},_)),e.jsx(ue,{type:"color",value:s.accentColor||"#1e3a5f",onChange:_=>{var Z;return(Z=s.onAccentColorChange)==null?void 0:Z.call(s,_.target.value)},className:"w-6 h-6 p-0 border-0 rounded-full cursor-pointer"})]})}),s.onHeaderColorChange&&e.jsx(Vt,{title:a("cvCustomization.headerColor","Headerfarve"),icon:e.jsxs("div",{className:"relative",children:[e.jsx(Wi,{className:"w-4 h-4"}),e.jsx("span",{className:"absolute -bottom-0.5 left-0 right-0 h-1 rounded-sm",style:{backgroundColor:s.headerColor||"#2d3436"}})]}),contentClassName:"w-64 p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[pl.map(_=>e.jsx("button",{type:"button",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{var Z;return(Z=s.onHeaderColorChange)==null?void 0:Z.call(s,Ka[_])},className:`w-6 h-6 rounded-full border-2 transition-all ${s.headerColor===Ka[_]?"border-foreground scale-110":"border-transparent"}`,style:{backgroundColor:Ka[_]},title:a(`cvCustomization.presetColors.${_}`)},_)),e.jsx(ue,{type:"color",value:s.headerColor||"#2d3436",onChange:_=>{var Z;return(Z=s.onHeaderColorChange)==null?void 0:Z.call(s,_.target.value)},className:"w-6 h-6 p-0 border-0 rounded-full cursor-pointer"})]})}),s.onPaperColorChange&&e.jsx(Vt,{title:a("cvCustomization.paperColor","Papirfarve"),icon:e.jsx(Fs,{className:"w-4 h-4"}),contentClassName:"w-52 p-2 space-y-1",children:Ou.map(_=>e.jsxs("button",{type:"button",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{var Z;return(Z=s.onPaperColorChange)==null?void 0:Z.call(s,_.id)},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-xs transition-colors ${s.paperColor===_.id?"bg-primary/10":"hover:bg-muted"}`,children:[e.jsx("div",{className:"w-5 h-5 rounded border border-border shadow-sm",style:{backgroundColor:_.hex}}),e.jsx("span",{className:"flex-1",children:a(`cvCustomization.paperColors.${_.id}.name`)}),s.paperColor===_.id&&e.jsx(Et,{className:"w-3.5 h-3.5 text-primary"})]},_.id))}),e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),s.onSeparatorStyleChange&&e.jsx(Vt,{title:a("cvCustomization.separatorStyle","Sektionsseparator"),icon:e.jsx(Uc,{className:"w-4 h-4"}),contentClassName:"w-56 p-2 space-y-1",children:zu.map(_=>e.jsxs("button",{type:"button",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{var Z;return(Z=s.onSeparatorStyleChange)==null?void 0:Z.call(s,_)},className:`w-full flex flex-col gap-1 px-2 py-1.5 rounded-md text-left text-xs transition-colors ${s.separatorStyle===_?"bg-primary/10":"hover:bg-muted"}`,children:[e.jsxs("span",{className:"flex items-center justify-between",children:[a(`cvCustomization.separatorStyles.${_}.name`),s.separatorStyle===_&&e.jsx(Et,{className:"w-3.5 h-3.5 text-primary"})]}),_==="line"&&e.jsx("div",{className:"border-t border-muted-foreground/30"}),_==="thick"&&e.jsx("div",{className:"border-t-2 border-muted-foreground/50"}),_==="dotted"&&e.jsx("div",{className:"border-t border-dotted border-muted-foreground/40"}),_==="none"&&e.jsx("div",{className:"h-px"})]},_))}),s.onIconStyleChange&&!Mu.has(s.selectedDesign??"")&&e.jsx(Vt,{title:a("cvCustomization.iconStyle","Ikonstil"),icon:e.jsx(Hc,{className:"w-4 h-4"}),contentClassName:"w-52 p-2 space-y-1",children:Vu.map(_=>e.jsx(on,{selected:s.iconStyle===_,onClick:()=>{var Z;return(Z=s.onIconStyleChange)==null?void 0:Z.call(s,_)},children:a(`cvCustomization.iconStyles.${_}.name`)},_))}),s.onSectionOrderChange&&e.jsxs(Vt,{title:a("cvCustomization.sectionOrder","Sektionsrækkefølge"),icon:e.jsx(Fl,{className:"w-4 h-4"}),contentClassName:"w-72 p-3 space-y-2 max-h-96 overflow-y-auto",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:a("cvCustomization.sectionOrderHint","Træk for at omarrangere. Slå til/fra for at vise/skjule.")}),e.jsx(Bc,{sensors:I,collisionDetection:Kc,onDragEnd:me,children:e.jsx(Wc,{items:T,strategy:Gc,children:e.jsx("div",{className:"space-y-1",children:T.map(_=>e.jsx($u,{rawId:_,onToggle:Ae,onDelete:Ve},_))})})}),e.jsxs(ta,{open:r,onOpenChange:n,children:[e.jsx(aa,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"w-full h-7 gap-1 text-xs",children:[e.jsx(fs,{className:"w-3 h-3"}),a("cvCustomization.addSection","Tilføj sektion")]})}),e.jsxs(na,{align:"end",className:"w-60 p-3 space-y-2",children:[cs.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:a("cvCustomization.predefinedSections","Foreslåede sektioner")}),e.jsx("div",{className:"flex flex-wrap gap-1",children:cs.map(_=>e.jsx("button",{type:"button",onClick:()=>ps(_),className:"px-2 py-0.5 text-[11px] rounded-md border border-border bg-background hover:bg-muted",children:a(`cvCustomization.sectionNames.${_}`)},_))})]}),e.jsxs("div",{className:"space-y-1 pt-1 border-t border-border",children:[e.jsx(se,{className:"text-[11px] text-muted-foreground",children:a("cvCustomization.customSection","Egen sektion")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(ue,{value:c,onChange:_=>l(_.target.value),placeholder:a("cvCustomization.customSectionPlaceholder","F.eks. Projekter"),className:"h-7 text-xs",onKeyDown:_=>_.key==="Enter"&&ms()}),e.jsx(h,{size:"sm",className:"h-7 px-2",onClick:ms,disabled:!c.trim(),children:e.jsx(fs,{className:"w-3 h-3"})})]})]})]})]})]})]}),s.onCVUpdated&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsxs(ta,{open:D,onOpenChange:B,children:[e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(aa,{asChild:!0,children:e.jsxs(h,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 gap-1 text-xs",children:[e.jsx(wt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:a("cvSectionSuggest.button","Foreslå sektion")})]})})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:a("cvSectionSuggest.tooltip","Forslag til ekstra sektioner")})})]}),e.jsxs(na,{align:"end",className:"w-72 p-3 space-y-2",onOpenAutoFocus:_=>_.preventDefault(),children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:a("cvSectionSuggest.title","Foreslåede sektioner")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:a("cvSectionSuggest.description","Tilføj en færdig sektion til dit CV. Du kan flytte, redigere og slette den som alle andre sektioner.")}),(()=>{const _=a("cvSectionSuggest.languagesHeader","Sprog"),Z=a("cvSectionSuggest.certifications
195Header","Kurser & Certificeringer"),H=a("cvSectionSuggest.projectsHeader","Projekter"),ne=a("cvSectionSuggest.volunteeringHeader","Frivilligt arbejde"),x=a("cvSectionSuggest.referencesHeader","Referencer"),z=a("cvSectionSuggest.honorsHeader","Priser & Udmærkelser"),b=a("cvSectionSuggest.hobbiesHeader","Fritidsinteresser"),U=[{presentKey:"personality",key:"personality",titleKey:"cvSectionSuggest.personalityTitle",defaultTitle:"Min personlighed",descKey:"cvSectionSuggest.personalityDesc",defaultDesc:"5–7 linjer om dine personlighedsstyrker baseret på din personanalyse. Mest præcist med en Komplet personanalyse.",icon:"sparkles",loading:A==="personality",onClick:Le},{presentKey:"languages",key:"languages",titleKey:"cvSectionSuggest.languagesTitle",defaultTitle:"Sprog",descKey:"cvSectionSuggest.languagesDesc",defaultDesc:"Hentes fra dine profiloplysninger. Udfyld selv hvis ingen sprog er angivet.",icon:"sparkles",loading:A==="languages",onClick:()=>Oe("languages","languages",_)},{presentKey:"certifications",key:"certifications",titleKey:"cvSectionSuggest.certificationsTitle",defaultTitle:"Kurser & Certificeringer",descKey:"cvSectionSuggest.certificationsDesc",defaultDesc:"Hentes fra dit oprindelige CV eller LinkedIn-profil. Ellers indsættes en skabelon.",icon:"sparkles",loading:A==="certifications",onClick:()=>Oe("certifications","certifications",Z)},{presentKey:"projects",key:"projects",titleKey:"cvSectionSuggest.projectsTitle",defaultTitle:"Projekter",descKey:"cvSectionSuggest.projectsDesc",defaultDesc:"Konkrete projekter fra dine kilder. Ellers indsættes en skabelon.",icon:"sparkles",loading:A==="projects",onClick:()=>Oe("projects","projects",H)},{presentKey:"volunteering",key:"volunteering",titleKey:"cvSectionSuggest.volunteeringTitle",defaultTitle:"Frivilligt arbejde",descKey:"cvSectionSuggest.volunteeringDesc",defaultDesc:"Frivilligt arbejde nævnt i dit CV/LinkedIn. Ellers en skabelon.",icon:"sparkles",loading:A==="volunteering",onClick:()=>Oe("volunteering","volunteering",ne)},{presentKey:"honors",key:"honors",titleKey:"cvSectionSuggest.honorsTitle",defaultTitle:"Priser & Udmærkelser",descKey:"cvSectionSuggest.honorsDesc",defaultDesc:"Priser eller anerkendelser fra dine kilder. Ellers en skabelon.",icon:"sparkles",loading:A==="honors",onClick:()=>Oe("honors","honors",z)},{presentKey:"references",key:"references",titleKey:"cvSectionSuggest.referencesTitle",defaultTitle:"Referencer",descKey:"cvSectionSuggest.referencesDesc",defaultDesc:"Standardlinje 'Referencer udleveres efter aftale' eller konkrete navne fra dine kilder.",icon:"sparkles",loading:A==="references",onClick:()=>Oe("references","references",x)},{presentKey:"hobbies",key:"hobbies",titleKey:"cvSectionSuggest.hobbiesTitle",defaultTitle:"Fritidsinteresser",descKey:"cvSectionSuggest.hobbiesDesc",defaultDesc:"Fritidsinteresser fra dine kilder. Ellers en skabelon.",icon:"sparkles",loading:A==="hobbies",onClick:()=>Oe("hobbies","hobbies",b)},{presentKey:"private_life",key:"private_life",titleKey:"cvSectionSuggest.privateTitle",defaultTitle:"Privat / Fritid",descKey:"cvSectionSuggest.privateDesc",defaultDesc:"Indsæt en skabelon med civilstand, børn og fritidsinteresser, som du selv udfylder.",icon:"plus",loading:!1,onClick:pe}],te=new Set(we),fe=U.filter(G=>!te.has(G.presentKey)),Se=e.jsx("button",{type:"button",onMouseDown:G=>G.preventDefault(),onClick:()=>{B(!1),re(!0)},disabled:A!==null,className:"w-full text-left p-2.5 rounded-lg border border-dashed border-primary/50 hover:border-primary hover:bg-primary/5 transition-colors disabled:opacity-60",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-md bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(fs,{className:"w-3.5 h-3.5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:a("cvCustomSection.button","Egen sektion")}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug mt-0.5",children:a("cvCustomSection.buttonDesc","Lav en helt fri sektion med din egen titel og dit eget indhold.")})]})]})},"__custom__");return fe.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[11px] text-muted-foreground italic px-1 py-2",children:a("cvSectionSuggest.allAdded","Alle foreslåede sektioner er allerede en del af dit CV.")}
195),Se]}):e.jsxs(e.Fragment,{children:[fe.map(G=>e.jsx("button",{type:"button",onMouseDown:Fe=>Fe.preventDefault(),onClick:G.onClick,disabled:G.loading||A!==null,className:"w-full text-left p-2.5 rounded-lg border border-border hover:border-primary/40 hover:bg-primary/5 transition-colors disabled:opacity-60 disabled:cursor-wait",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-md bg-primary/10 flex items-center justify-center shrink-0",children:G.loading?e.jsx(ge,{className:"w-3.5 h-3.5 text-primary animate-spin"}):G.icon==="sparkles"?e.jsx(xs,{className:"w-3.5 h-3.5 text-primary"}):e.jsx(fs,{className:"w-3.5 h-3.5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:a(G.titleKey,G.defaultTitle)}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug mt-0.5",children:a(G.descKey,G.defaultDesc)})]})]})},G.key)),Se]})})()]})]})]}),s.onCVUpdated&&s.cvContent&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsxs(h,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 gap-1 text-xs",onClick:()=>Q(!0),children:[e.jsx(ht,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:a("cvAddJob.button","Tilføj job")})]})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs max-w-[220px]",children:a("cvAddJob.tooltip","Tilføj et nyt job til Erhvervserfaring og vælg, hvor det skal placeres.")})})]}),e.jsx(Pu,{open:R,onOpenChange:Q,cvContent:s.cvContent,onCVUpdated:s.onCVUpdated})]}),s.onCVUpdated&&s.cvContent&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsxs(h,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 gap-1 text-xs",onClick:()=>Y(!0),children:[e.jsx(El,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:a("cvImprove.button","Forbedringsforslag")})]})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs max-w-[220px]",children:a("cvImprove.tooltip","Analysér dit CV og få konkrete forbedringsforslag, du kan kopiere eller anvende med AI.")})})]}),e.jsx(_u,{open:M,onOpenChange:Y,cvContent:s.cvContent,onCVUpdated:s.onCVUpdated,languageVoice:s.languageVoice,languageFormality:s.languageFormality})]}),s.onCVUpdated&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsxs(ta,{children:[e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(aa,{asChild:!0,children:e.jsxs(h,{type:"button",variant:"ghost",size:"sm",className:`h-8 px-2 gap-1 text-xs ${ve?"text-primary":""}`,children:[e.jsx(ka,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:a("cvFocus.button","Fokus")})]})})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs max-w-[240px]",children:a("cvFocus.tooltip","Fortæl AI hvad der skal fremhæves — fx et karriereskift. Bruges automatisk næste gang AI'en redigerer CV'et.")})})]}),e.jsxs(na,{align:"end",className:"w-96 p-3 space-y-2",onOpenAutoFocus:_=>_.preventDefault(),children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:a("cvFocus.title","Fokus for AI-forbedringer")}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug",children:a("cvFocus.description","Beskriv hvad AI'en skal fremhæve — fx et karriereskift, en bestemt målgruppe eller kompetencer der skal tones op/ned. Teksten sendes automatisk med til alle AI-forbedringer af dette CV. Den låser IKKE nye sektioner op og opdigter ikke fakta.")}),e.jsx(as,{id:"toolbar-focus",placeholder:a("cvFocus.placeholder","Fx: Jeg skifter retning fra juridisk sagsbehandling til projektledelse — fremhæv ledelses- og koordinerings­erfaring og tone jura ned."),value:ve,maxLength:Ur,onChange:_=>ze(_.target.value),onBlur:()=>ul(null,ve),className:"min-h-[120px] text-xs"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[ve.length,"/",Ur]}),ve&&e.jsx("button",{type:"button",onMouseDown:_=>_.preventDefault(),onClick:()=>{ze(""),ul(null,""),J.success(a("cvFocus.cleared","Fokus-instruks ryddet"))},className:"text-[11px] text-muted-foreground hover:text-foreground underline underline-offset-2",children:a("cvFocus.clear","Ryd")})]})]})]})]}),s.onCVUpdated&&e.jsxs(e.Fragment,{children:[e.jsx(st,{orientation:"vertical",className:"h-6 mx-1"}),e.jsxs(ta,{children:[e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(aa,{asChild:!0,children:e.jsx(h,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs font-semibold",children:"AI"})})}),e.jsx(Js,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:a("cvCustomization.tabAi","AI")})})]}),e.jsxs(na,{align:"end",className:"w-80 p-3 space-y-2",onOpenAutoFocus:_=>_.preventDefault(),children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:a("cvCustomization.tabAi","AI")}),e.jsx(se,{htmlFor:"toolbar-ai",className:"text-xs",children:a("cvCustomization.aiLabel","Beskriv hvad AI skal ændre")}),e.jsx(as,{id:"toolbar-ai",placeholder:a("cvCustomization.aiPlaceholder","F.eks. Gør profilen kortere og mere salgsorienteret"),value:f,onChange:_=>p(_.target.value),className:"min-h-[100px] text-xs"}),e.jsx(h,{size:"sm",className:"w-full gap-2",onClick:E,disabled:j||!f.trim(),children:j?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}
195),a("cvCustomization.aiUpdating","Opdaterer...")]}):e.jsxs(e.Fragment,{children:[e.jsx(Cn,{className:"w-3.5 h-3.5"}),a("cvCustomization.aiUpdateBtn","Opdater CV med AI")]})})]})]})]})]}),s.cvContent&&s.onCVUpdated&&e.jsx(wu,{open:w,onOpenChange:S,cvContent:s.cvContent,languageVoice:s.languageVoice,languageFormality:s.languageFormality,onCVUpdated:s.onCVUpdated}),s.cvContent&&s.onCVUpdated&&e.jsx(Au,{open:K,onOpenChange:re,cvContent:s.cvContent,presentSectionKeys:we,displayNameForKey:_=>_.startsWith("custom_")?_.slice(7).replace(/_/g," ").replace(/^\w/,Z=>Z.toUpperCase()):a(`cvCustomization.sectionNames.${_}`,_),onCVUpdated:s.onCVUpdated,onSectionAdded:_=>{var Z;T.includes(_)||(Z=s.onSectionOrderChange)==null||Z.call(s,[...T,_])}}),e.jsx(at,{open:d!==null,onOpenChange:_=>{_||m(null)},children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:a("cvCustomization.deleteSection","Slet sektion")}),e.jsx(lt,{children:a("cvCustomization.deleteSectionConfirm","Slet denne sektion og alt dens indhold fra CV'et?")})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:a("common.cancel","Annullér")}),e.jsx(Ys,{onClick:()=>{const _=d;m(null),_&&oe(_)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:a("common.delete","Slet")})]})]})})]})},_r="cv-find",Sr="cv-find-active",gl=()=>typeof CSS<"u"&&typeof CSS.highlights<"u"&&typeof window.Highlight<"u",Hu=({containerRef:s})=>{const[a,t]=i.useState(!1),[r,n]=i.useState(""),[d,m]=i.useState([]),[c,l]=i.useState(0),f=i.useRef(null);i.useEffect(()=>{const N="cv-find-style";if(document.getElementById(N))return;const w=document.createElement("style");w.id=N,w.textContent=`
196      ::highlight(${_r}) { background-color: hsl(var(--primary) / 0.25); color: inherit; }
197      ::highlight(${Sr}) { background-color: hsl(var(--primary) / 0.55); color: hsl(var(--primary-foreground)); }
198    `,document.head.appendChild(w)},[]);const p=i.useCallback(()=>{gl()&&(CSS.highlights.delete(_r),CSS.highlights.delete(Sr))},[]),j=i.useCallback(N=>{if(!N||!s.current)return[];const w=s.current,S=N.toLowerCase(),A=[],y=document.createTreeWalker(w,NodeFilter.SHOW_TEXT,{acceptNode:B=>{const M=B.parentElement;if(!M||M.closest("[data-cv-find-bar]"))return NodeFilter.FILTER_REJECT;const Y=B.nodeValue||"";return Y.trim()?Y.toLowerCase().includes(S)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_REJECT}});let D;for(;D=y.nextNode();){const M=(D.nodeValue||"").toLowerCase();let Y=0;for(;;){const R=M.indexOf(S,Y);if(R===-1)break;const Q=document.createRange();Q.setStart(D,R),Q.setEnd(D,R+N.length),A.push({range:Q,element:D.parentElement}),Y=R+N.length}}return A},[s]),g=i.useCallback((N,w)=>{if(!gl()||(p(),N.length===0))return;const S=[];N.forEach((A,y)=>{y!==w&&S.push(A.range)}),CSS.highlights.set(_r,new window.Highlight(...S)),N[w]&&CSS.highlights.set(Sr,new window.Highlight(N[w].range))},[p]);i.useEffect(()=>{var w;if(!a)return;const N=j(r.trim());m(N),l(0),g(N,0),(w=N[0])!=null&&w.element&&N[0].element.scrollIntoView({block:"center",behavior:"smooth"})},[r,a,j,g]),i.useEffect(()=>(a||p(),()=>p()),[a,p]),i.useEffect(()=>{const N=w=>{(w.ctrlKey||w.metaKey)&&w.key.toLowerCase()==="f"?s.current&&document.activeElement&&(s.current.contains(document.activeElement)||a)&&(w.preventDefault(),t(!0),setTimeout(()=>{var A;return(A=f.current)==null?void 0:A.focus()},0)):w.key==="Escape"&&a&&t(!1)};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[s,a]);const P=i.useCallback(N=>{var S;if(d.length===0)return;const w=(c+N+d.length)%d.length;l(w),g(d,w),(S=d[w].element)==null||S.scrollIntoView({block:"center",behavior:"smooth"})},[d,c,g]);return i.useMemo(()=>r?d.length===0?"0 / 0":`${c+1} / ${d.length}`:"Find i CV…",[r,d,c]),a?e.jsxs("div",{"data-cv-find-bar":!0,className:"inline-flex items-center gap-1 rounded-md border border-border bg-popover px-1.5 py-1 shadow-sm",children:[e.jsx(Ut,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("input",{ref:f,value:r,onChange:N=>n(N.target.value),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),P(N.shiftKey?-1:1))},placeholder:"Find…",className:"bg-transparent outline-none text-sm w-32 placeholder:text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums min-w-[3rem] text-right pr-1",children:r?`${d.length===0?0:c+1} / ${d.length}`:""}),e.jsx("button",{type:"button",onClick:()=>P(-1),disabled:d.length===0,title:"Forrige",className:"p-1 rounded hover:bg-accent text-foreground disabled:opacity-40",children:e.jsx(cr,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>P(1),disabled:d.length===0,title:"Næste (Enter)",className:"p-1 rounded hover:bg-accent text-foreground disabled:opacity-40",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>t(!1),title:"Luk (Esc)",className:"p-1 rounded hover:bg-accent text-foreground",children:e.jsx(mt,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{t(!0),setTimeout(()=>{var N;return(N=f.current)==null?void 0:N.focus()},0)},title:"Find i CV (Ctrl/Cmd+F)",className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded border border-border bg-background hover:bg-accent text-foreground",children:[e.jsx(Ut,{className:"h-3.5 w-3.5"}),"Find"]})}
198,Ga=794,Ia=1123,Bu=({open:s,onOpenChange:a,content:t,designId:r,profilePhotoUrl:n,showPhoto:d,photoShape:m,photoSize:c,photoPosition:l,photoBackground:f,photoCustomColor:p,photoFit:j,fontPair:g,fontSize:P,accentColor:N,headerColor:w,paperColor:S,cvPages:A=2})=>{const{t:y}=Je(),D=i.useRef(null),[B,M]=i.useState(1),[Y,R]=i.useState(.75),Q=A,k=i.useCallback(()=>{const K=D.current;if(!K)return;const re=K.scrollTop,ve=Ia*Y+48*Y,ze=Math.floor(re/ve)+1;M(Math.min(ze,Q))},[Y,Q]);i.useEffect(()=>{const K=D.current;if(!(!K||!s))return K.addEventListener("scroll",k),()=>K.removeEventListener("scroll",k)},[s,k]),i.useEffect(()=>{s&&(M(1),setTimeout(()=>{var K;return(K=D.current)==null?void 0:K.scrollTo({top:0})},50))},[s]);const $=K=>{const re=D.current;if(!re)return;const ve=Ia*Y+48*Y;re.scrollTo({top:(K-1)*ve,behavior:"smooth"})};return e.jsx(ns,{open:s,onOpenChange:a,children:e.jsxs(rs,{className:"max-w-[95vw] w-[95vw] h-[95vh] max-h-[95vh] p-0 gap-0 overflow-hidden [&>button]:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted/50 shrink-0",children:[e.jsx("h3",{className:"text-sm font-medium",children:y("careerDocs.fullPreview","Fuldt CV-preview")}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[y("careerDocs.page","Side")," ",B," / ",Q]}),e.jsxs("div",{className:"flex flex-col ml-1",children:[e.jsx("button",{onClick:()=>$(Math.max(1,B-1)),disabled:B<=1,className:"p-0.5 hover:text-foreground disabled:opacity-30",children:e.jsx(cr,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>$(Math.min(Q,B+1)),disabled:B>=Q,className:"p-0.5 hover:text-foreground disabled:opacity-30",children:e.jsx(Ts,{className:"w-3 h-3"})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 border-l pl-3",children:[e.jsx(h,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>R(K=>Math.max(.4,K-.1)),children:e.jsx(xd,{className:"w-3.5 h-3.5"})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10 text-center",children:[Math.round(Y*100),"%"]}),e.jsx(h,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>R(K=>Math.min(1.5,K+.1)),children:e.jsx(Cc,{className:"w-3.5 h-3.5"})})]}),e.jsx(h,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>a(!1),children:e.jsx(mt,{className:"w-4 h-4"})})]})]}),e.jsx("div",{ref:D,className:"flex-1 overflow-auto bg-muted/30 py-8",children:e.jsx("div",{className:"mx-auto flex flex-col items-center",style:{width:Ga*Y+64},children:e.jsxs("div",{className:"relative",style:{width:Ga*Y,height:Ia*Y*Q+(Q-1)*48*Y},children:[Array.from({length:Q}).map((K,re)=>e.jsx("div",{className:"absolute left-0 bg-white shadow-xl border border-border/40 rounded-sm",style:{top:re*(Ia*Y+48*Y),width:Ga*Y,height:Ia*Y},children:e.jsxs("div",{className:"absolute -bottom-6 right-1 text-[11px] text-muted-foreground font-medium",children:[y("careerDocs.page","Side")," ",re+1," / ",Q]})},`sheet-${re}`)),e.jsx("div",{className:"absolute top-0 left-0",style:{width:Ga*Y,height:Ia*Y*Q},children:e.jsx("div",{style:{width:Ga,transform:`scale(${Y})`,transformOrigin:"top left"},children:e.jsx(Tr,{content:t,designId:r,profilePhotoUrl:n,showPhoto:d,photoShape:m,photoSize:c,photoPosition:l,photoBackground:f,photoCustomColor:p,photoFit:j,fontPair:g,fontSize:P,accentColor:N,headerColor:w,paperColor:S})})}),Array.from({length:Q-1}).map((K,re)=>e.jsx("div",{className:"absolute -left-4 bg-muted/30 pointer-events-none",style:{top:(re+1)*Ia*Y+re*48*Y,width:Ga*Y+32,height:48*Y}},`gap-${re}`))]})})})]})})},fl=20;function Ku(){const s=i.useRef([]),[a,t]=i.useState(0),r=i.useCallback(()=>t(s.current.length),[]),n=i.useCallback(l=>{const f=[...s.current,l];f.length>fl&&f.splice(0,f.length-fl),s.current=f,r()},[r]),d=i.useCallback(()=>{if(s.current.length===0)return null;const l=s.current[s.current.length-1];return s.current=s.current.slice(0,-1),r(),l},[r]),m=i.useCallback(()=>{s.current=[],r()},[r]),c=i.useCallback(()=>s.current.length===0?null:s.current[s.current.length-1],[]);return{push:n,pop:d,peek:c,clear:m,count:a}}const Wu=(s,a)=>{try{return new Date(s).toLocaleDateString(a==="en"?"en-GB":"da-DK",{day:"numeric",month:"short",year:"numeric"})}catch{return s}},Gu=({readOnly:s=!1,embedded:a=!1,onViewEdit:t,onDownloadPdf:r})=>{const{t:n,i18n:d}=Je(),m=i.useRef(null),{cvs:c,loading:l,downloadCV:f,deleteCV:p,setPrimaryCV:j,renameCV:g,uploadCV:P}=lr(),{documents:N,loading:w,deleteDocument:S,renameDocument:A}=Xa(),[y,D]=i.useState(null),[B,M]=i.useState(""),[Y,R]=i.useState(null),[Q,k]=i.useState(!1);i.useState(null);const $=i.useMemo(()=>N.filter(O=>O.document_type==="cv"||O.document_type==="cv_en"),[N]),K=i.useMemo(()=>{const O=c.map(Le=>({id:Le.id,title:Le.title,source:"uploaded",createdAt:Le.created_at,isPrimary:!!Le.is_primary,filePath:Le.file_path,fileName:Le.file_name})),ee=$.map(Le=>({id:Le.id,title:Le.title,source:"generated",createdAt:Le.created_at,documentType:Le.document_type,content:Le.content}));return[...O,...ee].sort((Le,pe)=>new Date(pe.createdAt).getTime()-new Date(Le.createdAt).getTime())},[c,$]),re=l||w,ve=async O=>{var Le;const ee=(Le=O.target.files)==null?void 0:Le[0];ee&&(k(!0),await P(ee,ee.name.replace(/\.[^.]+$/,"")),k(!1),m.current&&(m.current.value=""))},ze=async()=>{!y||!B.trim()||(y.source==="uploaded"?await g(y.id,B.trim()):await A(y.id,B.trim()),D(null))},xe=async()=>{Y&&(Y.source==="uploaded"&&Y.filePath?await p(Y.id,Y.filePath):Y.source==="generated"&&await S(Y.id),R(null))},I=O=>{if(!O.content)return;if(r){r({id:O.id,title:O.title,content:O.content,documentType:O.documentType});return}const ee=window.open("","_blank");if(!ee)return;const Le=bt(O.content).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");ee.document.write(`<!DOCTYPE html>
199<html lang="${d.language}">
200<head>
201  <meta charset="UTF-8">
202  <title>${O.title}</title>
203  <style>
204    body { max-width: 800px; margin: 40px auto; padding: 20px; color: #333; line-height: 1.6; font-family: 'Segoe UI', Arial, sans-serif; }
205    pre { white-space: pre-wrap; word-wrap: break-word; font-family: inherit; font-size: 12pt; }
206    @media print {
207      body { margin: 0; padding: 20px; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
208      @page { size: A4; margin: 22.5mm; }
209    }
210  </style>
211</head>
212<body><pre>${Le}</pre></body>
213</html>`),ee.document.close(),setTimeout(()=>ee.print(),500)},E=()=>e.jsx("ul",{className:"divide-y divide-border/60 border rounded-lg bg-background/50",children:[0,1,2].map(O=>e.jsxs("li",{className:"flex items-center gap-3 p-3 animate-pulse",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-muted shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsx("div",{className:"h-3.5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted/70 rounded w-1/3"})]}),e.jsx("div",{className:"h-7 w-20 bg-muted rounded shrink-0"})]},O))}),F=({children:O})=>a?e.jsx("div",{className:"space-y-3",children:O}):e.jsx("div",{className:"bg-card border rounded-xl p-5 shadow-sm hover:shadow-md transition-shadow",children:O});return e.jsxs(F,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fs,{className:"w-4 h-4 text-primary"}),e.jsx("h4",{className:"text-sm font-medium text-foreground",children:n("dashboardCvs.title","Dine CV'er")}),!re&&e.jsx(je,{variant:"secondary",className:"text-xs",children:K.length})]}),!s&&e.jsxs("div",{children:[e.jsx("input",{ref:m,type:"file",accept:".pdf,.doc,.docx,.txt",className:"hidden",onChange:ve}),e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>{var O;return(O=m.current)==null?void 0:O.click()},disabled:Q||re,className:"gap-1.5",children:[Q?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(nr,{className:"w-3.5 h-3.5"}),n("dashboardCvs.upload","Upload CV")]})]})]}),re?e.jsxs(e.Fragment,{children:[E(),e.jsxs("p",{className:"text-xs text-muted-foreground italic mt-2 flex items-center gap-1.5",children:[e.jsx(ge,{className:"w-3 h-3 animate-spin"}),n("dashboardCvs.loading","Henter dine dokumenter…")]})]}):K.length===0?e.jsxs("div",{className:"text-center py-8 text-sm text-muted-foreground",children:[e.jsx("p",{className:"mb-3",children:n("dashboardCvs.empty","Du har endnu ingen CV'er.")}),!s&&e.jsx(h,{asChild:!0,size:"sm",variant:"default",className:"gap-1.5",children:e.jsxs(Oi,{to:"/mit-karrieresite?tab=karriereprofil#section-cv",children:[e.jsx(xs,{className:"w-3.5 h-3.5"}),n("dashboardCvs.create","Opret dit første CV")]})})]}):e.jsx("ul",{className:"divide-y divide-border/60 border rounded-lg bg-background/50",children:K.map(O=>e.jsxs("li",{className:"flex items-center gap-3 p-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-muted flex items-center justify-center shrink-0",children:O.source==="generated"?e.jsx(xs,{className:"w-4 h-4 text-primary"}):e.jsx(Fs,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:O.title}),O.isPrimary&&e.jsxs(je,{variant:"default",className:"text-[10px] gap-1 px-1.5 py-0",children:[e.jsx(Ps,{className:"w-2.5 h-2.5"}),n("dashboardCvs.primary","Primært")]}),e.jsx(je,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:O.source==="generated"?n("dashboardCvs.aiGenerated","AI-genereret"):n("dashboardCvs.uploaded","Uploadet")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Wu(O.createdAt,d.language)})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 flex-wrap justify-end",children:[O.source==="uploaded"&&O.filePath&&O.fileName?e.jsxs(h,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>f(O.filePath,O.fileName),children:[e.jsx(Qt,{className:"w-3.5 h-3.5"}),n("dashboardCvs.download","Download")]}):e.jsxs(e.Fragment,{children:[t?e.jsxs(h,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>t({id:O.id,documentType:O.documentType}),children:[e.jsx(Ht,{className:"w-3.5 h-3.5"}),n("careerDocs.seeAndEditCV","Se og redigér CV")]}):e.jsx(h,{asChild:!0,size:"sm",variant:"outline",className:"gap-1.5",children:e.jsxs(Oi,{to:"/mit-karrieresite?tab=karriereprofil#section-cv",children:[e.jsx(Ht,{className:"w-3.5 h-3.5"}),n("careerDocs.seeAndEditCV","Se og redigér CV")]})}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>I(O),children:[e.jsx(Qt,{className:"w-3.5 h-3.5"}),"PDF"]})]}),!s&&O.source==="uploaded"&&!O.isPrimary&&e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>j(O.id),title:n("dashboardCvs.setPrimary","Sæt som primært"),children:e.jsx(Ps,{className:"w-4 h-4"})}),!s&&e.jsxs(e.Fragment,{children:[e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>{D(O),M(O.title)},title:n("dashboardCvs.rename","Omdøb"),children:e.jsx(Ma,{className:"w-4 h-4"})}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>R(O),title:n("dashboardCvs.delete","Slet"),className:"text-destructive hover:text-destructive",children:e.jsx(Ss,{className:"w-4 h-4"})})]})]})]},`${O.source}-${O.id}`))}),e.jsx(ns,{open:!!y,onOpenChange:O=>!O&&D(null),children:e.jsxs(rs,{children:[e.jsx(os,{children:e.jsx(is,{children:n("dashboardCvs.renameTitle","Omdøb CV")})}),e.jsx(ue,{value:B,onChange:O=>M(O.target.value),placeholder:n("dashboardCvs.titlePlaceholder","Titel"),autoFocus:!0}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"outline",onClick:()=>D(null),children:n("common.cancel","Annullér")}),e.jsx(h,{onClick:ze,disabled:!B.trim(),children:n("common.save","Gem")})]})]})}),e.jsx(at,{open:!!Y,onOpenChange:O=>!O&&R(null),children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:n("dashboardCvs.deleteTitle","Slet CV?")}),e.jsx(lt,{children:n("dashboardCvs.deleteDesc","Denne handling kan ikke fortrydes. CV'et bliver slettet permanent.")})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:n("common.cancel","Annullér")}),e.jsx(Ys,{onClick:xe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:n("common.delete","Slet")})]})]})})]})},Dr={webm:"/cv-demo-da.webm?v=20260621c",mp4:"/cv-demo-da.mp4?v=20260621c"};function qu(){const{t:s}
213=Je(),[a,t]=i.useState(!1),r=i.useRef(null),n=i.useCallback(()=>t(!0),[]);return i.useEffect(()=>{if(!a&&r.current)try{r.current.pause(),r.current.currentTime=0}catch{}},[a]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:n,className:"gap-2 border-primary/30 text-primary hover:text-primary hover:bg-primary/5","aria-label":s("cvDemo.watch","Se demo: sådan retter du dit CV"),children:[e.jsx(Qo,{className:"w-3.5 h-3.5",fill:"currentColor"}),s("cvDemo.watch","Se demo: sådan retter du dit CV")]}),e.jsx(ns,{open:a,onOpenChange:t,children:e.jsxs(rs,{className:"max-w-4xl p-0 overflow-hidden bg-black border-0",children:[e.jsx(is,{className:"sr-only",children:s("cvDemo.title","Demo: sådan retter du dit CV")}),e.jsx("div",{className:"relative aspect-video w-full bg-black",children:a&&e.jsxs("video",{ref:r,className:"absolute inset-0 w-full h-full",controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",children:[e.jsx("source",{src:Dr.webm,type:"video/webm"}),e.jsx("source",{src:Dr.mp4,type:"video/mp4"}),e.jsx("track",{kind:"captions"})]},Dr.webm)})]})})]})}const Pr=({initialValue:s,onSave:a,onCancel:t,inputClassName:r="h-7 text-sm w-40",iconSize:n="sm",wrapperClassName:d="flex items-center gap-1"})=>{const[m,c]=i.useState(s),l=i.useRef(null);i.useEffect(()=>{var g,P;(g=l.current)==null||g.focus(),(P=l.current)==null||P.select()},[]);const f=()=>{const g=m.trim();g&&a(g)},p=n==="sm"?"w-3 h-3":"w-3.5 h-3.5",j=n==="sm"?"h-6 w-6 p-0":"h-7 w-7 p-0";return e.jsxs("div",{className:d,children:[e.jsx(ue,{ref:l,value:m,onChange:g=>c(g.target.value),className:r,onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),f()):g.key==="Escape"&&(g.preventDefault(),t())}}),e.jsx(h,{size:"sm",variant:"ghost",className:j,onClick:f,children:e.jsx(zs,{className:p})}),e.jsx(h,{size:"sm",variant:"ghost",className:j,onClick:t,children:e.jsx(mt,{className:p})})]})},Ju=({currentDesign:s,briefContent:a,briefContentStandard:t,onDesignChange:r,onBriefUpdated:n,onSubmitChanges:d})=>{const{t:m}=Je(),[c,l]=i.useState(s||"executive-search"),[f,p]=i.useState(""),[j,g]=i.useState(!1),[P,N]=i.useState(!1),[w,S]=i.useState(""),[A,y]=i.useState(!0),[D,B]=i.useState(!1),[M,Y]=i.useState(null),[R,Q]=i.useState(null),k={id:"executive-search",title:m("applicationPackage.tabBrief"),description:m("kandidatbriefCustomization.designDescription"),icon:ht,colors:"from-slate-700 to-slate-900"},$=()=>c==="executive-search"?a||"":t||a||"",K=async()=>{if(!f.trim()){J.error(m("kandidatbriefCustomization.writeChangeError"));return}if(!a){J.error(m("kandidatbriefCustomization.noContentError"));return}g(!0),N(!1);try{const{data:{session:xe}}=await C.auth.getSession();if(!xe){J.error(m("kandidatbriefCustomization.loginRequired"));return}const I=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/edit-document-with-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xe.access_token}`},body:JSON.stringify({content:$(),instructions:f,documentType:"kandidatbrief"})});if(!I.ok){const F=await I.json();throw new Error(F.error||m("kandidatbriefCustomization.aiEditError"))}const E=await I.json();n==null||n(E.editedContent),d==null||d(f),N(!0),J.success(m("kandidatbriefCustomization.aiEditSuccess")),p("")}catch(xe){console.error("Error AI editing kandidatbrief:",xe),J.error(xe instanceof Error?xe.message:m("kandidatbriefCustomization.genericError"))}finally{g(!1)}},re=async()=>{if(!w.trim()){J.error(m("kandidatbriefCustomization.describeDesignError"));return}B(!0),Y(null),Q(null);try{const{data:{session:xe}}=await C.auth.getSession();if(!xe){J.error(m("kandidatbriefCustomization.loginRequired"));return}const I=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/generate-cv-design",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xe.access_token}`},body:JSON.stringify({designDescription:`Kandidatbrief design: ${w}`,generateImage:A,documentContent:a,documentType:"kandidatbrief"})});if(!I.ok){const F=await I.json();throw new Error(F.error||m("kandidatbriefCustomization.couldNotGenerateDesign"))}const E=await I.json();Y(E.textSuggestion),E.imageUrl&&Q(E.imageUrl),J.success(m("kandidatbriefCustomization.designGenerated"))}catch(xe){console.error("Error generating design:",xe),J.error(xe instanceof Error?xe.message:m("kandidatbriefCustomization.genericError"))}finally{B(!1)}}
213,ve=xe=>xe.replace(/\*+/g,""),ze=xe=>xe.split(`
214`).map((I,E)=>I.startsWith("**")&&I.endsWith("**")?e.jsx("h4",{className:"font-semibold mt-3 mb-1",children:ve(I)},E):I.startsWith("##")?e.jsx("h3",{className:"text-lg font-semibold mt-4 mb-2",children:ve(I.replace(/^##\s*/,""))},E):I.startsWith("#")?e.jsx("h2",{className:"text-xl font-bold mt-4 mb-2",children:ve(I.replace(/^#\s*/,""))},E):I.startsWith("- ")?e.jsx("li",{className:"ml-4",children:ve(I.replace(/^-\s*/,""))},E):I.match(/^\d+\.\s/)?e.jsx("li",{className:"ml-4 list-decimal",children:ve(I.replace(/^\d+\.\s*/,""))},E):I.trim()===""?e.jsx("br",{},E):e.jsx("p",{className:"mb-1",children:ve(I)},E));return e.jsx(ye,{className:"p-6 bg-muted/30 border-primary/20",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:m("kandidatbriefCustomization.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("kandidatbriefCustomization.subtitle")})]}),e.jsxs(Gr,{defaultValue:"changes",className:"w-full",children:[e.jsxs(qr,{className:"grid w-full grid-cols-2",children:[e.jsxs(za,{value:"changes",className:"gap-2",children:[e.jsx(Fs,{className:"w-4 h-4"}),m("kandidatbriefCustomization.tabChanges")]}),e.jsxs(za,{value:"design",className:"gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),m("kandidatbriefCustomization.tabDesign")]})]}),e.jsxs(Oa,{value:"changes",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"brief-change-request",children:m("kandidatbriefCustomization.changeLabel")}),e.jsx(as,{id:"brief-change-request",placeholder:m("kandidatbriefCustomization.changePlaceholder"),value:f,onChange:xe=>p(xe.target.value),className:"min-h-[120px]"})]}),P&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 border border-green-500/20 rounded-lg",children:[e.jsx($s,{className:"w-5 h-5 text-green-600"}),e.jsx("span",{className:"text-sm text-green-700",children:m("kandidatbriefCustomization.changeUpdated")})]}),e.jsx(h,{onClick:K,disabled:j||!f.trim(),className:"w-full gap-2",children:j?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),m("kandidatbriefCustomization.aiUpdating")]}):e.jsxs(e.Fragment,{children:[e.jsx(Cn,{className:"w-4 h-4"}),m("kandidatbriefCustomization.aiUpdateBtn")]})})]}),e.jsxs(Oa,{value:"design",className:"mt-4 space-y-6",children:[$()&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ht,{className:"w-5 h-5 text-primary"}),e.jsx("h4",{className:"font-semibold text-foreground",children:m("kandidatbriefCustomization.livePreview")}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",k.title,")"]})]}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto rounded-lg border",children:e.jsx(fn,{content:$(),designId:"executive-search"})})]}),e.jsx("div",{className:"p-4 rounded-lg border bg-muted/30",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-12 h-12 rounded-lg bg-gradient-to-br ${k.colors} flex items-center justify-center`,children:e.jsx(k.icon,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-foreground",children:k.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:k.description})]})]})}),e.jsxs("div",{className:"space-y-4 p-4 border rounded-lg bg-gradient-to-br from-primary/5 to-primary/10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xs,{className:"w-5 h-5 text-primary"}),e.jsx("h4",{className:"font-semibold text-foreground",children:m("kandidatbriefCustomization.aiDesignTitle")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"brief-design-description",children:m("kandidatbriefCustomization.aiDesignLabel")}),e.jsx(as,{id:"brief-design-description",placeholder:m("kandidatbriefCustomization.aiDesignPlaceholder"),value:w,onChange:xe=>S(xe.target.value),className:"min-h-[80px]"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Kt,{id:"generate-brief-mockup",checked:A,onCheckedChange:xe=>y(xe===!0)}),e.jsxs("label",{htmlFor:"generate-brief-mockup",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 flex items-center gap-2",children:[e.jsx(el,{className:"w-4 h-4"}),m("kandidatbriefCustomization.generateMockup")]})]}),e.jsx(h,{onClick:re,disabled:D||!w.trim(),className:"w-full gap-2",variant:"default",children:D?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),m(A?"kandidatbriefCustomization.generatingWithMockup":"kandidatbriefCustomization.generatingOnly")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-4 h-4"}),m("kandidatbriefCustomization.getDesignSuggestion")]})}),M&&e.jsxs("div",{className:"mt-4 space-y-4",children:[$()&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ht,{className:"w-5 h-5 text-primary"}),e.jsx("h5",{className:"font-semibold text-foreground",children:m("kandidatbriefCustomization.livePreviewAi")})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto rounded-lg border",children:e.jsx(fn,{content:$(),designId:"ai-custom"})})]}),e.jsxs("div",{className:"p-4 bg-background rounded-lg border",children:[e.jsxs("h5",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(er,{className:"w-4 h-4 text-primary"}),m("kandidatbriefCustomization.designSuggestion")]}),e.jsx("div",{className:"text-sm text-foreground prose prose-sm max-w-none",children:ze(M)})]}),R&&e.jsxs("div",{className:"p-4 bg-background rounded-lg border",children:[e.jsxs("h5",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(el,{className:"w-4 h-4 text-primary"}),m("kandidatbriefCustomization.visualMockup")]}),e.jsx("img",{src:R,alt:"Kandidatbrief Design Mockup",className:"w-full rounded-lg border shadow-sm",loading:"lazy",decoding:"async"})]})]})]})]})]})]})})},Yu=(s,a)=>{const t=[];return t.push(`# ${a("cvFeedbackDialog.title")}
214`),t.push(`
215${a("cvFeedbackDialog.overallScore")}: ${s.overall_score}/100`),t.push(`${a("cvFeedbackDialog.atsScore")}: ${s.ats_score}/100`),t.push(`
216${s.summary}`),s.strengths.length&&(t.push(`
217## ${a("cvFeedbackDialog.strengths")}`),s.strengths.forEach(r=>t.push(`✓ ${r.title}: ${r.description}`))),s.improvements.length&&(t.push(`
218## ${a("cvFeedbackDialog.improvements")}`),s.improvements.forEach(r=>t.push(`⚠ [${r.priority}] ${r.title}: ${r.description}`))),s.missing_sections.length&&(t.push(`
219## ${a("cvFeedbackDialog.missingSections")}`),s.missing_sections.forEach(r=>t.push(`- ${r}`))),s.formatting_tips.length&&(t.push(`
220## ${a("cvFeedbackDialog.formattingTips")}`),s.formatting_tips.forEach(r=>t.push(`💡 ${r}`))),s.ats_tips.length&&(t.push(`
221## ATS Tips`),s.ats_tips.forEach(r=>t.push(`🛡 ${r}`))),t.join(`
222`)},io=({generatedCVContent:s,savedCVs:a=[],uploadedCVs:t,triggerButton:r,onSaveFeedback:n,onApplyImprovements:d,controlledOpen:m,onControlledOpenChange:c})=>{const{t:l,i18n:f}=Je(),[p,j]=i.useState(!1),g=m!==void 0,P=g?m:p,N=H=>{g?c==null||c(H):j(H)},[w,S]=i.useState("choose"),[A,y]=i.useState(null),[D,B]=i.useState(null),[M,Y]=i.useState(!1),[R,Q]=i.useState(new Set),[k,$]=i.useState(null),[K,re]=i.useState(null),[ve,ze]=i.useState(null),[xe,I]=i.useState(null),E=i.useRef(null),[F,O]=i.useState("edit"),[ee,Le]=i.useState(""),[pe,Oe]=i.useState(!1),[he,we]=i.useState(""),[T,ae]=i.useState([]),[me,Ae]=i.useState(!1),oe=()=>{S("choose"),y(null),B(null),Q(new Set),$(null),ze(null),I(null),O("none"),Le(""),ae([]),we("")},Ve=async(H,ne)=>{S("loading"),B(ne),ze(H);try{const{data:x,error:z}=await C.functions.invoke("analyze-cv-feedback",{body:{cvContent:H,source:ne,language:f.language}});if(z)throw z;if(x!=null&&x.error)throw new Error(x.error);jn("cv_feedback_analyzed","cv",{source:ne}),y(x),S("result")}catch(x){console.error("CV feedback error:",x),J.error(l("cvFeedbackDialog.errorAnalyzing")),S("choose")}},Xe=()=>{s&&Ve(s,"generated")},cs=H=>{if(!H.content){J.error(l("cvFeedbackDialog.cannotReadFile"));return}Ve(H.content,`saved:${H.id}`)},hs=async H=>{try{S("loading"),B("original");const{data:ne,error:x}=await C.storage.from("cvs").download(H);if(x)throw x;const z=await ne.text();if(z.length<30){J.error(l("cvFeedbackDialog.cannotReadFile")),S("choose");return}await Ve(z,"original")}catch(ne){console.error("Error reading uploaded CV:",ne),J.error(l("cvFeedbackDialog.cannotReadFile")),S("choose")}},ps=async H=>{var x;const ne=(x=H.target.files)==null?void 0:x[0];if(ne){if(ne.size>10*1024*1024){J.error(l("careerDocs.fileTooLargeError"));return}S("loading"),B("uploaded");try{const z=await ne.text();if(z.length<30){J.error(l("cvFeedbackDialog.cannotReadFile")),S("choose");return}await Ve(z,"uploaded")}catch(z){console.error("Error reading file:",z),J.error(l("cvFeedbackDialog.cannotReadFile")),S("choose")}E.current&&(E.current.value="")}},ms=H=>H>=80?"text-green-600":H>=60?"text-amber-600":"text-red-500",De=H=>H>=80?"bg-green-500":H>=60?"bg-amber-500":"bg-red-500",_=H=>{const ne={high:"bg-red-500/10 text-red-600 border-red-500/20",medium:"bg-amber-500/10 text-amber-600 border-amber-500/20",low:"bg-blue-500/10 text-blue-600 border-blue-500/20"},x={high:l("cvFeedbackDialog.priorityHigh"),medium:l("cvFeedbackDialog.priorityMedium"),low:l("cvFeedbackDialog.priorityLow")};return e.jsx(je,{className:ne[H]||"",children:x[H]||H})},Z=async()=>{if(!he.trim()||me||!ve)return;const H=he.trim();we(""),ae(ne=>[...ne,{role:"user",content:H}]),Ae(!0);try{const{data:ne,error:x}=await C.functions.invoke("career-chat",{body:{question:`Kontekst - mit CV:
223${ve}
224
225Feedback:
226${(A==null?void 0:A.summary)||""}
227
228Mit spørgsmål: ${H}`,conversationHistory:T,language:f.language}});if(x)throw x;ae(z=>[...z,{role:"assistant",content:(ne==null?void 0:ne.answer)||"..."}])}catch(ne){console.error("Ask AI error:",ne),J.error(l("cvFeedbackDialog.askError")),ae(x=>x.slice(0,-1))}finally{Ae(!1)}};return e.jsxs(ns,{open:P,onOpenChange:H=>{N(H),H||oe()},children:[!g&&e.jsx(Na,{asChild:!0,children:r||e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",children:[e.jsx(Xn,{className:"w-4 h-4"}),l("cvFeedbackDialog.triggerButton")]})}),e.jsxs(rs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(Va,{className:"w-5 h-5 text-primary"}),l("cvFeedbackDialog.title")]})}),w==="choose"&&e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:l("cvFeedbackDialog.chooseDescription")}),e.jsxs("div",{className:"grid gap-3",children:[a.length>0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:l("cvFeedbackDialog.yourGeneratedCVs","Dine gemte CV'er")}),a.map(H=>e.jsxs("button",{onClick:()=>cs(H),className:"flex items-start gap-3 p-4 rounded-lg border border-border hover:border-primary/50 hover:bg-primary/5 transition-colors text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Va,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:H.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("cvFeedbackDialog.generatedCVDesc")})]})]},H.id))]}):s&&e.jsxs("button",{onClick:Xe,className:"flex items-start gap-3 p-4 rounded-lg border border-border hover:border-primary/50 hover:bg-primary/5 transition-colors text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Va,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:l("cvFeedbackDialog.generatedCV")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("cvFeedbackDialog.generatedCVDesc")})]})]}),t.length>0?t.map(H=>e.jsxs("button",{onClick:()=>hs(H.file_path),className:"flex items-start gap-3 p-4 rounded-lg border border-border hover:border-primary/50 hover:bg-primary/5 transition-colors text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(Fs,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:H.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:H.file_name})]})]},H.id)):e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg border border-dashed border-muted-foreground
228/30 bg-muted/30",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(Fs,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("div",{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:l("cvFeedbackDialog.noUploadedCVs")})})]}),e.jsxs("button",{onClick:()=>{var H;return(H=E.current)==null?void 0:H.click()},className:"flex items-start gap-3 p-4 rounded-lg border border-dashed border-border hover:border-primary/50 hover:bg-primary/5 transition-colors text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(nr,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:l("cvFeedbackDialog.uploadNew")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("cvFeedbackDialog.uploadNewDesc")})]})]}),e.jsx("input",{type:"file",ref:E,onChange:ps,accept:".txt,.doc,.docx,.pdf",className:"hidden"})]})]}),w==="loading"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(ge,{className:"w-10 h-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:l("cvFeedbackDialog.analyzing")})]}),w==="result"&&A&&e.jsxs("div",{className:"space-y-6 py-2",children:[e.jsxs("div",{className:"p-5 rounded-xl bg-gradient-to-r from-primary/5 to-primary/10 border border-primary/20 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:l("cvFeedbackDialog.overallScore")}),e.jsxs("span",{className:`text-3xl font-bold ${ms(A.overall_score)}`,children:[A.overall_score,"/100"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-3 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-1000 ${De(A.overall_score)}`,style:{width:`${A.overall_score}%`}})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:A.summary})]}),e.jsxs("div",{className:"p-4 rounded-lg border border-border space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"font-medium text-foreground flex items-center gap-2",children:[e.jsx(Qn,{className:"w-4 h-4 text-primary"}),l("cvFeedbackDialog.atsScore")]}),e.jsxs("span",{className:`text-xl font-bold ${ms(A.ats_score)}`,children:[A.ats_score,"/100"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${De(A.ats_score)}`,style:{width:`${A.ats_score}%`}})}),A.ats_tips.length>0&&e.jsx("ul",{className:"space-y-1 mt-2",children:A.ats_tips.map((H,ne)=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[e.jsx(wt,{className:"w-3.5 h-3.5 text-amber-500 shrink-0 mt-0.5"}),H]},ne))})]}),A.strengths.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"font-medium text-foreground flex items-center gap-2",children:[e.jsx(Ps,{className:"w-4 h-4 text-green-600"}),l("cvFeedbackDialog.strengths")]}),e.jsx("div",{className:"space-y-2",children:A.strengths.map((H,ne)=>e.jsxs("div",{className:"p-3 rounded-lg bg-green-500/5 border border-green-500/20",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground flex items-start gap-2",children:[e.jsx($s,{className:"w-4 h-4 text-green-600 shrink-0 mt-0.5"}),H.title]}),e.jsx("p",{className:"text-sm text-muted-foreground ml-6",children:H.description})]},ne))})]}),A.improvements.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"font-medium text-foreground flex items-center gap-2",children:[e.jsx(va,{className:"w-4 h-4 text-amber-600"}),l("cvFeedbackDialog.improvements")]}),A.improvements.some(H=>H.suggested_text)&&e.jsx("span",{className:"text-xs text-muted-foreground",children:l("cvFeedbackDialog.clickToSeeSuggestion")})]}),e.jsx("div",{className:"space-y-2",children:A.improvements.map((H,ne)=>e.jsxs("div",{className:`p-3 rounded-lg border transition-colors cursor-pointer ${R.has(ne)?"bg-primary/5 border-primary/30":"bg-amber-500/5 border-amber-500/20"}`,onClick:()=>$(k===ne?null:ne),children:[e.jsxs("div",{className:"flex items-start gap-2",children:[H.suggested_text&&e.jsx(Kt,{checked:R.has(ne),onCheckedChange:x=>{const z=new Set(R);x?z.add(ne):z.delete(ne),Q(z)},onClick:x=>x.stopPropagation(),className:"mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:H.title}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[_(H.priority),H.suggested_text&&(k===ne?e.jsx(cr,{className:"w-3.5 h-3.5 text-muted-foreground"}):e.jsx(Ts,{className:"w-3.5 h-3.5 text-muted-foreground"}))]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:H.description})]})]}),H.suggested_text&&k===ne&&e.jsxs("div",{className:"mt-3 ml-6 p-3 rounded-md bg-muted/50 border border-border relative group",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[e.jsx(wt,{className:"w-3 h-3"}),l("cvFeedbackDialog.suggestedText")]}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:async x=>{x.stopPropagation(),await navigator.clipboard.writeText(H.suggested_text),re(ne),setTimeout(()=>re(null),2e3),J.success(l("cvFeedbackDialog.copiedToClipboard"))},children:K===ne?e.jsx(Et,{className:"w-3.5 h-3.5 text-green-600"}):e.jsx(Lt,{className:"w-3.5 h-3.5"})})]}),e.jsx(as,{value:H.suggested_text,onChange:x=>{if(!A)return;const z={...A,improvements:A.improvements.map((b,U)=>U===ne?{...b,suggested_text:x.target.value}:b)};y(z)},onClick:x=>x.stopPropagation(),className:"text-sm min-h-[100px] bg-background"})]})]},ne))}),ve&&d&&e.jsxs("div",{className:"sticky bottom-0 -mx-1 px-1 pt-3 pb-2 mt-2 border-t border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:R.size>0?l("cvFeedbackDialog.selectedCount",{count:R.size}):l("cvFeedbackDialog.selectImprovementsHint",{defaultValue:"Vælg de forbedringer du vil indarbejde i dit CV"})}),e.jsxs(h,{className:"w-full gap-2",disabled:R.size===0,onClick:async()=>
228{if(!(!A||!ve)){S("applying");try{const H=A.improvements.filter((z,b)=>R.has(b)),{data:ne,error:x}=await C.functions.invoke("apply-cv-improvements",{body:{cvContent:ve,improvements:H,language:f.language,focusInstruction:tr()||void 0}});if(x)throw x;if(ne!=null&&ne.error)throw new Error(ne.error);I(ne.improvedCV),S("preview")}catch(H){console.error("Apply improvements error:",H),J.error(l("cvFeedbackDialog.applyError")),S("result")}}},children:[e.jsx($s,{className:"w-4 h-4"}),l("cvFeedbackDialog.applySelectedImprovements")]})]})]}),A.missing_sections.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-foreground",children:l("cvFeedbackDialog.missingSections")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:A.missing_sections.map((H,ne)=>e.jsx(je,{variant:"outline",className:"bg-red-500/5 text-red-600 border-red-500/20",children:H},ne))})]}),A.formatting_tips.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-foreground",children:l("cvFeedbackDialog.formattingTips")}),e.jsx("ul",{className:"space-y-1.5",children:A.formatting_tips.map((H,ne)=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[e.jsx(wt,{className:"w-3.5 h-3.5 text-primary shrink-0 mt-0.5"}),H]},ne))})]}),ve&&e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border border-primary/20 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(la,{className:"w-4 h-4 text-primary"}),e.jsx("h4",{className:"font-medium text-foreground",children:l("cvFeedbackDialog.aiActionsTitle")})]}),T.length>0&&e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-2 rounded-lg border border-border bg-background p-3",children:[T.map((H,ne)=>e.jsx("div",{className:`flex ${H.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-sm ${H.role==="user"?"bg-primary text-primary-foreground":"bg-muted text-foreground"}`,children:e.jsx("p",{className:"whitespace-pre-wrap",children:H.content})})},ne)),me&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"bg-muted rounded-lg px-3 py-2",children:e.jsx(ge,{className:"w-4 h-4 animate-spin text-muted-foreground"})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ue,{value:F==="edit"?ee:he,onChange:H=>F==="edit"?Le(H.target.value):we(H.target.value),placeholder:l(F==="edit"?"cvFeedbackDialog.editPlaceholder":"cvFeedbackDialog.askPlaceholder"),onKeyDown:H=>{var ne;H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),F==="edit"?(ne=document.getElementById("cv-ai-action-btn"))==null||ne.click():Z())},disabled:pe||me,className:"flex-1"}),F==="edit"?e.jsxs(h,{id:"cv-ai-action-btn",size:"sm",className:"gap-1.5 shrink-0",disabled:!ee.trim()||pe,onClick:async()=>{if(!(!ve||!ee.trim())){Oe(!0);try{const{data:H,error:ne}=await C.functions.invoke("edit-document-with-ai",{body:{content:ve,instructions:ee,documentType:"cv",language:f.language,focusInstruction:tr()||void 0}});if(ne)throw ne;if(H!=null&&H.error)throw new Error(H.error);H!=null&&H.editedContent&&(I(H.editedContent),S("preview"),O("none"),Le(""))}catch(H){console.error("AI edit error:",H),J.error(l("cvFeedbackDialog.editError"))}finally{Oe(!1)}}},children:[pe?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(la,{className:"w-4 h-4"}),l("cvFeedbackDialog.applyEdit")]}):e.jsx(h,{size:"icon",onClick:Z,disabled:!he.trim()||me,className:"shrink-0",children:e.jsx(Cn,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex gap-1.5 justify-center",children:[e.jsxs(h,{variant:F==="edit"?"default":"ghost",size:"sm",className:"gap-1.5 h-7 text-xs",onClick:()=>O("edit"),children:[e.jsx(la,{className:"w-3 h-3"}),l("cvFeedbackDialog.editWithAI")]}),e.jsxs(h,{variant:F==="ask"?"default":"ghost",size:"sm",className:"gap-1.5 h-7 text-xs",onClick:()=>O("ask"),children:[e.jsx(cn,{className:"w-3 h-3"}),l("cvFeedbackDialog.askAI")]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[n&&e.jsxs(h,{className:"flex-1 gap-2",disabled:M,onClick:async()=>
228{if(!A)return;Y(!0);const H=Yu(A,l),ne=await n(H);Y(!1),ne&&J.success(l("cvFeedbackDialog.saved"))},children:[M?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(Fs,{className:"w-4 h-4"}),l("cvFeedbackDialog.saveAsDocument")]}),e.jsx(h,{variant:"outline",className:"flex-1",onClick:oe,children:l("cvFeedbackDialog.analyzeAnother")})]})]}),w==="applying"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(ge,{className:"w-10 h-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:l("cvFeedbackDialog.applyingImprovements")})]}),w==="preview"&&xe&&e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($s,{className:"w-5 h-5 text-green-600"}),e.jsx("h3",{className:"font-semibold text-foreground",children:l("cvFeedbackDialog.previewTitle")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("cvFeedbackDialog.previewDescription")}),e.jsx("div",{className:"max-h-[50vh] overflow-y-auto rounded-lg border border-border bg-muted/20 p-4",children:e.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:e.jsx(Xo,{children:xe})})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{className:"flex-1 gap-2",disabled:M,onClick:async()=>{if(!xe||!d)return;Y(!0);const H=D!=null&&D.startsWith("saved:")?D.slice(6):void 0,ne=await d(xe,H);Y(!1),ne&&(J.success(l("cvFeedbackDialog.appliedSuccess")),N(!1),oe())},children:[M?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(zs,{className:"w-4 h-4"}),l("cvFeedbackDialog.saveImprovedCV")]}),e.jsx(h,{variant:"outline",className:"gap-2",onClick:()=>S("result"),children:l("cvFeedbackDialog.backToFeedback")})]})]})]})]})},Fr=()=>{var Si,Di;const s=$a(),a=wl(),{t,i18n:r}=Je(),n=Te(r.language)?ir:Sn,d=(Si=r.language)!=null&&Si.startsWith("da")?"da":"en",m=d==="da"?"":`_${d}`,c=u=>`${u}${m}`;i.useState("personanalyser");const[l,f]=i.useState(null),[p,j]=i.useState(null),[g,P]=i.useState(null),[N,w]=i.useState(null),[S,A]=i.useState(""),[y,D]=i.useState(null),[B,M]=i.useState(null),[Y,R]=i.useState(!1),[Q,k]=i.useState(null),[$,K]=i.useState(""),[re,ve]=i.useState(null),[ze,xe]=i.useState(null),[I,E]=i.useState(null),[F,O]=i.useState(""),[ee,Le]=i.useState(!1),[pe,Oe]=i.useState(null),[he,we]=i.useState(null);i.useState(!1);const[T,ae]=i.useState(null);i.useState(!1);const[me,Ae]=i.useState(null),[oe,Ve]=i.useState(null),Xe=i.useRef(!1),[cs,hs]=i.useState(!1),[ps,ms]=i.useState(!1),[De,_]=i.useState(null),[Z,H]=i.useState(""),[ne,x]=i.useState([]),[z,b]=i.useState(!0),[U,te]=i.useState("circular"),[fe,Se]=i.useState("medium"),[G,Fe]=i.useState("left"),[Ee,qe]=i.useState("none"),[Ge,He]=i.useState(null),[Ze,Us]=i.useState("cover"),[le,X]=i.useState("klassisk"),[L,ce]=i.useState("kronologisk"),[ys,Hs]=i.useState("we"),[Os,Ls]=i.useState("formal"),[Bs,ie]=i.useState("modern"),[o,V]=i.useState("standard"),[W,be]=i.useState(null),[Me,Be]=i.useState(null),[ss,$e]=i.useState("normal"),[es,bs]=i.useState("line"),[Xs,Ks]=i.useState("white"),[q,Ce]=i.useState("none"),Ie=u=>u==="filled"||u==="outline"?u:"none",[ds,Ns]=i.useState(void 0),[Ds,_t]=i.useState(null),[Ra,Es]=i.useState({}),[In,_a]=i.useState(!1),[Cs,Wt]=i.useState(null),Sa=Ku(),[Za,xa]=i.useState(!1),[li,lo]=i.useState([]),[oo,oi]=i.useState(!1),[ci,di]=i.useState(null),Ln=i.useRef(null),Ua=i.useRef(null),ur=i.useRef(null),{analyses:co,loading:ph,deleteAnalysis:gh,setPrimaryAnalysis:fh,translateAnalysis:vh}=Jr();i.useState(null),i.useState("da");const{documents:mi,loading:mo,getDocumentByType:Zs,getDocumentsByType:En,saveDocument:ft,saveDocumentAsCopy:Ha,deleteDocument:ui,renameDocument:hi}=Xa(),{cvs:en,loading:jh,downloadCV:uo,deleteCV:ho,setPrimaryCV:xo,uploadCV:po,renameCV:go}=lr(),xi=u=>u==="cv"||u==="cv_en",ls=(Ds?mi.find(u=>u.id===Ds&&xi(u.document_type)):void 0)||Zs(c("cv"))||Zs("cv"),pi=u=>u&&xi(u.document_type)?u.id:(u==null?void 0:u.document_type)??"",fo=[...En("cv"),...En("cv_en")].filter(u=>u==null?void 0:u.content).sort((u,de)=>(de.updated_at||"").localeCompare(u.updated_at||"")).map(u=>({id:u.id,title:`${u.title}${u.document_type==="cv_en"?" (EN)":""}`,content:u.content,updated_at:u.updated_at}));i.useEffect(()=>{Ln.current=(ls==null?void 0:ls.content)??null},[ls==null?void 0:ls.id,ls==null?void 0:ls.content]);const gi=i.useRef(null);i.useEffect(()=>{const u=ls;if(!u||gi.current===u.id)return;gi.current=u.id;const de=u.design_settings??{};X(de.cv_design??"klassisk"),ce(de.cv_type??"kronologisk"),ie(de.cv_font_pair??"modern"),V(de.cv_font_size??"standard"),be(de.cv_accent_color??null),Be(de.cv_header_color??null),$e(de.cv_line_spacing??"n
228ormal"),bs(de.cv_separator_style??"line"),Ks(de.cv_paper_color??"white"),Ce(Ie(de.cv_icon_style)),Ns(de.cv_section_order??void 0),b(typeof de.show_photo_in_cv=="boolean"?de.show_photo_in_cv:!0),te(de.cv_photo_shape??"circular"),Se(de.cv_photo_size??"medium"),Fe(de.cv_photo_position??"left"),qe(de.cv_photo_background??"none"),He(de.cv_photo_custom_color??null),Us(de.cv_photo_fit??"cover")},[mi,r.language,ls==null?void 0:ls.id]);const fi=[{type:"cv",title:t("careerDocs.yourCVs"),description:t("careerDocs.cvDescription"),icon:Fs},{type:"cover_letter",title:t("careerDocs.coverLetterTitle"),description:t("careerDocs.coverLetterDescription"),icon:Fs,allowMultiple:!0},{type:"email",title:t("careerDocs.emailTitle"),description:t("careerDocs.emailDescription"),icon:ua,allowMultiple:!0},{type:"kandidatbrief",title:t("careerDocs.kandidatbriefTitle"),description:t("careerDocs.kandidatbriefDescription"),icon:Fs,fallbackType:"kandidatbrief_standard",allowMultiple:!0}],Tn=i.useRef(null);i.useRef(null),i.useRef(null);const[hr,vi]=i.useState(!1);i.useState(!1),i.useState(!1);const[yh,vo]=i.useState(null),[bh,jo]=i.useState(null),[yo,xr]=i.useState(null),[bo,No]=i.useState(""),[pr,Ba]=i.useState(null),[ji,yi]=i.useState(""),[Ye,wo]=i.useState(null),[gr,bi]=i.useState(!1),[Ni,wi]=i.useState([]);i.useState(!1),i.useState(""),i.useState(!1),i.useEffect(()=>{(async()=>{const{data:{user:de}}=await C.auth.getUser();if(!de)return;const{data:ke}=await C.from("cv_design_presets").select("*").eq("user_id",de.id).order("created_at",{ascending:!1});ke&&wi(ke)})()},[]);const ko=async u=>{u.cv_design&&X(u.cv_design),u.cv_type&&ce(u.cv_type),u.cv_font_pair&&ie(u.cv_font_pair),u.cv_font_size&&V(u.cv_font_size),be(u.cv_accent_color??null),Be(u.cv_header_color??null),u.cv_line_spacing&&$e(u.cv_line_spacing),u.cv_separator_style&&bs(u.cv_separator_style),u.cv_paper_color&&Ks(u.cv_paper_color),u.cv_icon_style!==void 0&&Ce(Ie(u.cv_icon_style)),u.cv_section_order&&Ns(u.cv_section_order),u.show_photo_in_cv!==null&&b(u.show_photo_in_cv),u.cv_photo_shape&&te(u.cv_photo_shape),u.cv_photo_size&&Se(u.cv_photo_size),u.cv_photo_position&&Fe(u.cv_photo_position),u.cv_photo_background&&qe(u.cv_photo_background),u.cv_photo_custom_color&&He(u.cv_photo_custom_color),await St({cv_design:u.cv_design,cv_type:u.cv_type,cv_font_pair:u.cv_font_pair,cv_font_size:u.cv_font_size,cv_accent_color:u.cv_accent_color,cv_header_color:u.cv_header_color,cv_line_spacing:u.cv_line_spacing,cv_separator_style:u.cv_separator_style,cv_paper_color:u.cv_paper_color,cv_icon_style:Ie(u.cv_icon_style),cv_section_order:u.cv_section_order,show_photo_in_cv:u.show_photo_in_cv,cv_photo_shape:u.cv_photo_shape,cv_photo_size:u.cv_photo_size,cv_photo_position:u.cv_photo_position,cv_photo_background:u.cv_photo_background,cv_photo_custom_color:u.cv_photo_custom_color}
228),J.success(t("careerDocs.presetLoaded","Designskabelon indlæst!"))},Co=async u=>{try{const{error:de}=await C.from("cv_design_presets").delete().eq("id",u);if(de)throw de;wi(ke=>ke.filter(Pe=>Pe.id!==u)),J.success(t("careerDocs.presetDeleted","Designskabelon slettet"))}catch(de){console.error("Error deleting preset:",de),J.error(t("careerDocs.presetDeleteError","Kunne ikke slette skabelon"))}},ki=u=>{Sa.push(u)},sn=async(u,de={})=>{var ws;const ke=document.activeElement,Pe=!!(ke!=null&&ke.isContentEditable&&((ws=ur.current)!=null&&ws.contains(ke))),ts=!!Ua.current;return Pe&&(ke.blur(),await new Promise(Re=>setTimeout(Re,0))),Ua.current&&await Ua.current,((de.preferLatestRef??!0)||Pe||ts)&&Ln.current||u},_o=async()=>{const u=Sa.pop();if(u===null)return;const de=ls;de&&(await ft(de.document_type,de.title,u,void 0,de.id),J.success(t("careerDocs.undoSuccess","Ændring fortrudt")))},Ci=async()=>{oi(!0);try{const{data:{user:u}}=await C.auth.getUser();if(!u)return;const de=ls;if(!de)return;const{data:ke,error:Pe}=await C.from("cv_versions").select("id, content, version_label, created_at").eq("document_id",de.id).eq("user_id",u.id).order("created_at",{ascending:!1}).limit(20);if(Pe)throw Pe;lo(ke||[])}catch(u){console.error("Error loading CV versions:",u)}finally{oi(!1)}},fr=async(u,de,ke)=>{try{const{data:{user:Pe}}=await C.auth.getUser();if(!Pe)return;await C.from("cv_versions").insert({user_id:Pe.id,document_id:u,content:de,version_label:ke||null})}catch(Pe){console.error("Error saving CV version:",Pe)}},So=async u=>{di(u.id);try{const de=ls;if(de&&await fr(de.id,de.content,t("careerDocs.beforeRestore","Før gendannelse")),!de)return;await ft(de.document_type,de.title,u.content,void 0,de.id)&&(J.success(t("careerDocs.versionRestored","Version gendannet")),xa(!1),await Ci())}catch(de){console.error("Error restoring version:",de),J.error(t("careerDocs.versionRestoreError","Kunne ikke gendanne version"))}finally{di(null)}},Do=async u=>{var Pe;const de=(Pe=u.target.files)==null?void 0:Pe[0];if(!de)return;if(!["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"].includes(de.type)){J.error(t("careerDocs.uploadPdfOrWordError"));return}if(de.size>10*1024*1024){J.error(t("careerDocs.fileTooLargeError"));return}vi(!0),await po(de,"Originalt CV"),vi(!1),Tn.current&&(Tn.current.value="")};i.useEffect(()=>{(async()=>{const{data:{user:de}}=await C.auth.getUser();if(!de)return;const{data:ke}=await C.from("profiles").select("profile_photo_url, show_photo_in_cv, cv_photo_shape, cv_photo_size, cv_photo_position, cv_photo_background, cv_photo_custom_color, cv_photo_fit, cv_design, cv_type, cv_font_pair, cv_font_size, cv_accent_color, cv_header_color, cv_pages, cv_line_spacing, cv_separator_style, cv_paper_color, cv_icon_style, cv_section_order, exam_certificate_url, recommendation_url, full_name, city, email, phone").eq("id",de.id).single();if(ke){H(ke.full_name??"");const Pe=[];ke.city&&Pe.push(String(ke.city)),ke.email&&Pe.push(String(ke.email)),ke.phone&&Pe.push(String(ke.phone)),x(Pe)}if(ke!=null&&ke.exam_certificate_url){const Pe=ke.exam_certificate_url.split("/");vo(decodeURIComponent(Pe[Pe.length-1]))}if(ke!=null&&ke.recommendation_url){const Pe=ke.recommendation_url.split("/");jo(decodeURIComponent(Pe[Pe.length-1]))}if(ke!=null&&ke.profile_photo_url){const{data:Pe}=await C.storage.from("profile-photos").createSignedUrl(ke.profile_photo_url,3600);Pe!=null&&Pe.signedUrl&&_(Pe.signedUrl)}Hs((ke==null?void 0:ke.cv_language_voice)??"we"),Ls((ke==null?void 0:ke.cv_language_formality)??"formal"),Ve((ke==null?void 0:ke.cv_pages)??null),Xe.current=!0})()},[]),i.useEffect(()=>{if(!Xe.current)return;(async()=>{const{data:{user:de}}=await C.auth.getUser();de&&await C.from("profiles").update({cv_pages:oe}).eq("id",de.id)})()},[oe]),i.useEffect(()=>{const u=a.hash||window.location.hash;if(!u)return;const de=u==="#cv-feedback"?"cv-feedback":u.slice(1),ke=setTimeout(()=>{const Pe=document.getElementById(de);Pe&&Pe.scrollIntoView({behavior:"smooth",block:"start"})},500);return()=>clearTimeout(ke)},[a.hash]);const Po=async()=>{bi(!0);try{const{data:{session:u}}=await C.auth.getSession();if(!u)return;const de=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/generate-linkedin-profile",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u.access_token}`},body:JSON.stringify({})});if(!de.ok)throw new Error("Kunne ikke generere LinkedIn-profil");const ke=await de.json();wo(ke.linkedinProfile)}catch(u){console.error("Error generating LinkedIn profile:",u)}finally{bi(!1)}},Fo=u=>{var ke,Pe,ts,Ke,ws,Re,vs,gs,us;const de=[];return(ke=u.headline)!=null&&ke.suggestion&&de.push(`${t("careerDocs.linkedInHeadline")}
229${u.headline.suggestion}`),(Pe=u.about)!=null&&Pe.suggestion&&de.push(`
230${t("careerDocs.linkedInAbout")}
231${u.about.suggestion}`),((ts=u.experienceDescriptions)==null?void 0:ts.length)>0&&(de.push(`
232${t("careerDocs.linkedInExperience")}`),u.experienceDescriptions.forEach(Ne=>{de.push(`
233${Ne.title} — ${Ne.company}
234${Ne.description}`)}
234)),u.skills&&(de.push(`
235${t("careerDocs.linkedInSkills")}`),(Ke=u.skills.topSkills)!=null&&Ke.length&&de.push(`${t("jobStrategy.topSkills")}: ${u.skills.topSkills.join(", ")}`),(ws=u.skills.technicalSkills)!=null&&ws.length&&de.push(`${t("careerDocs.linkedInTechnical")}: ${u.skills.technicalSkills.join(", ")}`),(Re=u.skills.softSkills)!=null&&Re.length&&de.push(`${t("jobStrategy.softSkills")}: ${u.skills.softSkills.join(", ")}`)),u.searchOptimization&&(de.push(`
236${t("careerDocs.linkedInSearchOpt")}`),(vs=u.searchOptimization.primaryKeywords)!=null&&vs.length&&de.push(`${t("careerDocs.linkedInPrimaryKeywordsLabel")}: ${u.searchOptimization.primaryKeywords.join(", ")}`),(gs=u.searchOptimization.jobTitlesToTarget)!=null&&gs.length&&de.push(`${t("careerDocs.linkedInTargetPositions")}: ${u.searchOptimization.jobTitlesToTarget.join(", ")}`)),((us=u.visibilityTips)==null?void 0:us.length)>0&&(de.push(`
237${t("careerDocs.linkedInVisibilityTips")}`),u.visibilityTips.forEach(Ne=>{de.push(`[${Ne.impact}] ${Ne.category}: ${Ne.tip}`)})),de.join(`
238`)},Ao=u=>{b(u)},Io=u=>{te(u)},Lo=u=>{Se(u)},Eo=u=>{Fe(u)},To=u=>{qe(u)},zo=u=>{He(u)},zn=(u={})=>({cv_design:le,cv_type:L,cv_font_pair:Bs,cv_font_size:o,cv_accent_color:W,cv_header_color:Me,cv_line_spacing:ss,cv_separator_style:es,cv_paper_color:Xs,cv_icon_style:q,cv_section_order:ds,show_photo_in_cv:z,cv_photo_shape:U,cv_photo_size:fe,cv_photo_position:G,cv_photo_background:Ee,cv_photo_custom_color:Ge,cv_photo_fit:Ze,...u}),St=async(u={})=>!0,Oo=u=>{Us(u)},Vo=(u,de)=>{k(u),E(null),K(de)},Mo=async(u,de)=>{await ft(c(u),de,$)&&(J.success(t("careerDocs.documentUpdated")),k(null),K(""))},$o=()=>{k(null),K("")},Ro=u=>u.replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g," ").trim().slice(0,120)||"dokument",Uo=async u=>{const{data:de,error:ke}=await C.from("career_documents").select("*").eq("id",u.id).maybeSingle();return ke?(console.warn("Could not refresh document before PDF export:",ke),u):de?{...u,...de}:u},_i=async u=>{var nn,Aa,rn;Ae(u.id);const ke=u.document_type==="kandidatbrief"||u.document_type==="kandidatbrief_en"||u.document_type==="kandidatbrief_standard"?window.open("","_blank"):null;
238ke&&(ke.document.write('<!doctype html><html lang="da"><head><meta charset="utf-8" /><title>Forbereder PDF</title></head><body style="font-family: system-ui, -apple-system, sans-serif; padding: 32px; color: #1f2937;"><h1 style="font-size: 20px; margin: 0 0 12px;">Forbereder PDF…</h1><p>Dit kandidatbrief gøres klar til download.</p></body></html>'),ke.document.close());let Pe=await Uo(u);const ts=Pe.document_type==="kandidatbrief"||Pe.document_type==="kandidatbrief_en"||Pe.document_type==="kandidatbrief_standard",Ke=Pe.document_type==="cv"||Pe.document_type==="cv_en";if(Ke&&(ls==null?void 0:ls.id)===Pe.id){const ga=await sn(Pe.content||u.content,{preferLatestRef:!1});Pe={...Pe,content:ga}}const ws=Pe,Re=(ws==null?void 0:ws.design_settings)??{},vs=Re.cv_design??le,gs=Re.cv_font_pair??Bs,us=Re.cv_font_size??o,Ne=Re.cv_accent_color??W,As=Re.cv_header_color??Me,Ws=Re.cv_paper_color??Xs,oa=Re.cv_separator_style??es,pa=Re.cv_icon_style??q,Da=Re.cv_line_spacing??ss,tn=Re.cv_section_order??ds,Pa=typeof Re.show_photo_in_cv=="boolean"?Re.show_photo_in_cv:z,an=Re.cv_photo_shape??U,Dt=Re.cv_photo_size??fe,Gt=Re.cv_photo_position??G,Vn=Re.cv_photo_background??Ee,zt="cv_photo_custom_color"in Re?Re.cv_photo_custom_color:Ge,Mn=Re.cv_photo_fit??Ze;let Fa=null;try{const{createRoot:ga}=await ma(async()=>{const{createRoot:ea}=await import("./index-7TyBHU2Z.js").then(Rn=>Rn.c);return{createRoot:ea}},__vite__mapDeps([1,2])),{exportElementAsPdf:$n}=await ma(async()=>{const{exportElementAsPdf:ea}=await import("./paginateAndExport-DmOgoqOK.js");return{exportElementAsPdf:ea}},__vite__mapDeps([0,1,2])),Vs=document.createElement("div");Vs.setAttribute("data-pdf-offscreen-host","true"),Vs.style.position="static",Vs.style.width="794px",Vs.style.maxWidth="794px",Vs.style.margin="0 auto",Vs.style.height="auto",Vs.style.maxHeight="none",Vs.style.overflow="visible",Vs.style.opacity="0",Vs.style.visibility="hidden",Vs.style.pointerEvents="none",Vs.style.background="#ffffff",document.body.appendChild(Vs);const ln=ga(Vs);await new Promise(ea=>{ln.render(ts?e.jsx(fn,{content:Pe.content,designId:"executive-search"}):Ke?e.jsx(Tr,{content:Pe.content,designId:vs,defaultName:Z,defaultContactInfo:ne,profilePhotoUrl:De,showPhoto:Pa,photoShape:an,photoSize:Dt,photoPosition:Gt,photoBackground:Vn,photoCustomColor:zt,photoFit:Mn,fontPair:gs,fontSize:us,accentColor:Ne??void 0,headerColor:As??void 0,paperColor:Ws,separatorStyle:oa,iconStyle:pa,lineSpacing:Da,sectionOrder:tn}):e.jsx("div",{"data-pdf-break":"section",style:{width:794,padding:72,fontFamily:"Roboto, Arial, sans-serif",whiteSpace:"pre-wrap",color:"#333",lineHeight:1.6},children:bt(Pe.content)})),requestAnimationFrame(()=>requestAnimationFrame(()=>ea()))}),await((rn=(Aa=(nn=document.fonts)==null?void 0:nn.ready)==null?void 0:Aa.catch)==null?void 0:rn.call(Aa,()=>{})),await new Promise(ea=>setTimeout(ea,750)),Fa=()=>{ln.unmount(),Vs.remove()},await $n({host:Vs,fileName:Ro(Pe.title),fallbackWindow:ke,bleedSidebar:Ke,safeZoneMm:ts?18:12,docType:Pe.document_type||(Ke?"cv":ts?"kandidatbrief":"other")}),J.success(t("careerDocs.pdfDownloaded","PDF downloadet"))}catch(ga){console.error("PDF export error:",ga),ke&&!ke.closed&&ke.close()}finally{Fa==null||Fa(),Ae(null)}},Ho=async u=>{D(u.id);try{const de=u.document_type.replace(/_en$/,""),{data:{session:ke}}=await C.auth.getSession();if(!ke)throw new Error("No session");const ts=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/export-cv-docx",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ke.access_token}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR2b3ZvemtoamVpY3lodXl3cGRmIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQ5NzAxNzEsImV4cCI6MjA4MDU0NjE3MX0.UK7HJ3pvKEjdzU0bVuz9WWXYvIKC-tqK93skUsLBMzk"},body:JSON.stringify({content:u.content,fileName:u.title,documentType:de})});if(!ts.ok){const gs=await ts.text();throw new Error(`Export failed: ${ts.status} ${gs}`)}const Ke=await ts.blob(),ws=new Blob([Ke],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}),Re=URL.createObjectURL(ws),vs=document.createElement("a");vs.href=Re,vs.download=`${u.title}.docx`,document.body.appendChild(vs),vs.click(),document.body.removeChild(vs),setTimeout(()=>URL.revokeObjectURL(Re),1e3),J.success(t("careerDocs.docxExported"))}catch(de){console.error("DOCX export error:",de),J.error(t("careerDocs.docxExportError"))}finally{D(null)}}
238,Tt=async(u,de,ke,Pe)=>{if(!ke){const ts=u==="cv"?ls:Zs(c(u))||Zs(u);if(ts&&ts.content&&ts.content.trim().length>0){we({docType:u,title:de,targetLanguage:ke,cvPages:Pe});return}}return On(u,de,ke,Pe)},On=async(u,de,ke,Pe)=>{const Ke=(ke||d).startsWith("da")?"da":"en",ws=Ke==="da"?"":`_${Ke}`,Re=`${u}${ws}`;Oe(ke?`${u}_alt`:u);try{const{data:{session:vs}}=await C.auth.getSession();if(!vs){J.error(t("careerDocs.loginRequiredShort"));return}if(u==="cv"&&ke&&(ls!=null&&ls.content)){J.info(t("careerDocs.translatingDoc"));const us=Ke==="en"?"da":"en",Ne=Ln.current??Ra[pi(ls)]??ls.content,{data:As,error:Ws}=await C.functions.invoke("translate-cv",{body:{cvContent:Ne,sourceLanguage:us,targetLanguage:Ke}});if(Ws||!(As!=null&&As.translatedContent))throw new Error((As==null?void 0:As.error)||(Ws==null?void 0:Ws.message)||t("careerDocs.couldNotGenerateDocs"));const oa=As.translatedContent,tn=`${(ls.title||de).replace(/\s*\((English|Dansk|Danish)\)\s*$/i,"").trim()} ${Ke==="en"?"(English)":"(Dansk)"}`,Pa=ls.design_settings??null;if(await Ha(Re,tn,oa,Pa)){J.success(t("careerDocs.documentGeneratedInLang",{lang:Ke==="en"?"English":"Dansk"})),j(u);const Dt=d.startsWith("da")?"da":"en";M(Ke!==Dt?u:null)}return}J.info(t("careerDocs.generatingNewDoc"));let gs=null;
238if(u==="kandidatbrief"){const{data:us,error:Ne}=await C.functions.invoke("generate-kandidatbrief",{body:{language:Ke}});if(Ne||!(us!=null&&us.ok)||!(us!=null&&us.content))throw new Error((us==null?void 0:us.error)||(Ne==null?void 0:Ne.message)||t("careerDocs.couldNotGenerateDocs"));gs=us.content}else{const us={language:Ke};Pe&&(us.cv_pages=Pe),us.cv_language_voice=ys,us.cv_language_formality=Os,u==="cv"&&(us.cv_type=L);const Ne=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/generate-career-suggestions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vs.access_token}`},body:JSON.stringify(us)});if(!Ne.ok)throw new Error(t("careerDocs.couldNotGenerateDocs"));const Ws=(await Ne.json()).suggestions,pa={cv:"cv",cover_letter:"coverLetter",email:"email",kandidatbrief_standard:"kandidatbriefStandard"}[u];gs=pa?(Ws==null?void 0:Ws[pa])??null:null}if(gs){const us=u==="cv"&&!ke,Ne=Re.endsWith("_en")&&!/\(English\)/i.test(de)?`${de} (English)`:de;if(us)Es(As=>({...As,[(ls==null?void 0:ls.id)??Re]:gs})),j(u),J.success(t("careerDocs.cvRegeneratedChooseSave","Nyt CV genereret. Vælg 'Gem i nuværende CV' for at overskrive eller 'Gem som nyt CV' for at bevare det gamle."));else if(Es(Ws=>({...Ws,[Re]:gs})),await ft(Re,Ne,gs))if(J.success(ke?t("careerDocs.documentGeneratedInLang",{lang:ke==="en"?"English":"Dansk"}):t("careerDocs.documentUpdatedWithProfile")),!ke)j(u);else{j(u);const Ws=d.startsWith("da")?"da":"en";M(Ke!==Ws?u:null)}}else J.error(t("careerDocs.documentContentError"))}catch(vs){console.error("Error regenerating document:",vs),J.error(t("careerDocs.regenerateError"))}finally{Oe(null)}},vr=async(u,de)=>{if(!(u!=null&&u.content)||u.content.trim().length<10){J.error(t("careerDocs.documentContentError"));return}const ke=`${u.id}_${de}`;ae(ke);try{const{data:{session:Pe}}=await C.auth.getSession();if(!Pe){J.error(t("careerDocs.loginRequiredShort"));return}const ts=u.document_type.replace(/_en$/,"").replace(/_da$/,"");J.info(t("careerDocs.translatingDoc"));const{data:Ke,error:ws}=await C.functions.invoke("translate-document",{body:{content:u.content,targetLanguage:de,sourceLanguage:de==="en"?"da":"en",documentType:ts}});if(ws||!(Ke!=null&&Ke.ok)||!(Ke!=null&&Ke.translatedContent)){console.error("translate-document error:",ws||(Ke==null?void 0:Ke.error)),J.error((Ke==null?void 0:Ke.error)||t("careerDocs.docTranslateError"));return}const Re=de==="en"?ts.endsWith("_en")?ts:`${ts}_en`:ts,vs=de==="en"?"(English)":"(Dansk)",us=`${u.title.replace(/\s*\((English|Dansk|Danish)\)\s*$/i,"").trim()} ${vs}`;await Ha(Re,us,Ke.translatedContent)&&J.success(t("careerDocs.docTranslatedAsCopy"))}catch(Pe){console.error("Error translating document:",Pe),J.error(t("careerDocs.docTranslateError"))}finally{ae(null)}},Bo=async(u,de)=>{var Pe;const ke=u==="cv"?ls:Zs(c(u))||Zs(u);if(!ke||!((Pe=ke.content)!=null&&Pe.trim())||u==="kandidatbrief")return On(u,de);Oe(u);try{const{data:{session:ts}}=await C.auth.getSession();if(!ts){J.error(t("careerDocs.loginRequiredShort"));return}J.info(t("careerDocs.refreshingWithProfile","Opdaterer dokumentet med din nyeste profildata…"));const Ke=t("careerDocs.refreshInstructionPrompt","Opdater dette dokument med den nyeste information fra min profil (jobtitler, erfaringer, kompetencer, kontaktinfo, sprog, uddannelse, certificeringer). Bevar ALLE mine manuelle ændringer, omformuleringer, struktur, rækkefølge, formatering og tilføjede sektioner. Tilføj kun nye oplysninger fra profilen hvor det er relevant – fjern eller omskriv aldrig mine egne formuleringer. Returnér dokumentet i samme format som input."),ws=u==="cv"?t("careerDocs.cvTypeRefreshInstruction","CV-typen er nu sat til: {{cvType}}. Omstrukturér CV'et, så det tydeligt følger denne CV-type. Bevar brugerens egne formuleringer og fakta så vidt muligt, men flyt gerne afsnit og grupper indholdet anderledes, når det er nødvendigt for den valgte CV-type.",{cvType:L}):"",Re=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/edit-document-with-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ts.access_token}`},body:JSON.stringify({content:ke.content,instructions:[Ke,ws].filter(
238Boolean).join(`
239
240`),documentType:u,language:r.language,cv_language_voice:ys,cv_language_formality:Os})});if(!Re.ok){const gs=await Re.json().catch(()=>({}));throw new Error(gs.error||t("careerDocs.regenerateError"))}const vs=await Re.json();if(vs.editedContent){const gs=c(u);Es(us=>({...us,[u==="cv"?ke.id:gs]:vs.editedContent})),u==="cv"?(j(u),J.success(t("careerDocs.cvRegeneratedChooseSave","Nyt CV genereret. Vælg 'Gem i nuværende CV' for at overskrive eller 'Gem som nyt CV' for at bevare det gamle."))):await ft(gs,de,vs.editedContent)&&(J.success(t("careerDocs.documentUpdatedKeepingEdits","Dokumentet er opdateret – dine manuelle rettelser er bevaret.")),j(u))}else J.error(t("careerDocs.documentContentError"))}catch(ts){console.error("Error refreshing document:",ts),J.error(ts instanceof Error?ts.message:t("careerDocs.regenerateError"))}finally{Oe(null)}},Ko=async(u,de,ke)=>{if(F.trim()){Le(!0);try{const{data:{session:Pe}}=await C.auth.getSession();if(!Pe){J.error(t("careerDocs.loginRequiredShort"));return}const ts=await fetch("https://dvovozkhjeicyhuywpdf.supabase.co/functions/v1/edit-document-with-ai",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Pe.access_token}`},body:JSON.stringify({content:ke,instructions:F,documentType:u,language:r.language})});if(!ts.ok){const Re=await ts.json();throw new Error(Re.error||t("careerDocs.regenerateError"))}const Ke=await ts.json();await ft(c(u),de,Ke.editedContent)&&(E(null),O(""),J.success(t("careerDocs.documentUpdatedWithAI")))}catch(Pe){console.error("Error AI editing:",Pe),J.error(Pe instanceof Error?Pe.message:t("careerDocs.regenerateError"))}finally{Le(!1)}}};return co.find(u=>u.id===l),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:t("careerDocs.title")}),e.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto whitespace-pre-line",children:t("careerDocs.description")})]}),mo?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ge,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid gap-4",children:fi.map((u,de)=>{var Mn,Fa,nn,Aa,rn,ga,$n,Vs,ln,ea,Rn,Pi,Fi,Ai,Ii,Li,Ei;const ke={cv:{id:"section-cv",label:t("sidebar.yourCV")},kandidatbrief:{id:"section-kandidatbrief",label:t("sidebar.kandidatbrief")},cover_letter:{id:"section-coverletter",label:t("sidebar.coverLetter")},email:{id:"section-ansogningsmail",label:t("sidebar.applicationEmail")},cv_feedback:{id:"cv-feedback",label:t("sidebar.cvFeedback")}},Pe=ke[u.type],ts=Pe&&!fi.slice(0,de).some(v=>{var _e;return((_e=ke[v.type])==null?void 0:_e.id)===Pe.id}),Ke=u.isLinkedInProfile,ws=u.fallbackType,Re=u.allowMultiple,vs=Re?(()=>{const v=En(u.type),_e=En(`${u.type}_en`),Qe=[...v,..._e],Is=new Set;return Qe.filter(Ot=>Is.has(Ot.id)?!1:(Is.add(Ot.id),!0))})():[],gs=u.type==="cv",us=Zs(c(u.type))||Zs(u.type)||(ws?Zs(c(ws))||Zs(ws):void 0),Ne=gs&&ls||us,As=Ke?Ne:void 0,Ws=gs?(Ne?1:0)+en.length:0,oa=Ke?!!Ye||!!As:gs?Ws>0:Re?vs.length>0:!!Ne,pa=d==="da"?`${u.type}_en`:u.type,Da=ws?d==="da"?`${ws}_en`:ws:void 0,tn=!!Zs(pa)||(Da?!!Zs(Da):!1),Pa=Zs(pa)||(Da?Zs(Da):void 0),an=B===u.type,Dt=gs?Ne:an&&Pa?Pa:Ne,Gt=Ra[pi(Dt)]??(Dt==null?void 0:Dt.content),Vn=Q===u.type,zt=p===u.type;return e.jsxs(i.Fragment,{children:[ts&&Pe&&e.jsx("div",{id:Pe.id,className:"pt-6 first:pt-0 scroll-mt-24",children:e.jsx("h3",{className:"text-lg font-semibold text-foreground border-b border-border/50 pb-2",children:Pe.label})}),e.jsxs(ye,{className:"p-5 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(u.icon,{className:"w-7 h-7 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:u.title}),Ke?gr?e.jsxs(je,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20 gap-1",children:[e.jsx(ge,{className:"w-3 h-3 animate-spin"}),t("careerDocs.generating")]}):As?e.jsxs(je,{className:"bg-green-500/10 text-green-600 border-green-500/20 gap-1",children:[e.jsx($s,{className:"w-3 h-3"}),t("careerDocs.saved")]}):Ye?e.jsxs(je,{className:"bg-green-500/10 text-green-600 border-green-500/20 gap-1",children:[e.jsx($s,{className:"w-3 h-3"}),t("careerDocs.ready")]}):e.jsxs(je,{className:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20 gap-1",children:[e.jsx(ba,{className:"w-3 h-3"}),t("careerDocs.notGenerated")]}):oa?e.jsxs(je,{className:"bg-green-500/10 text-green-600 border-green-500/20 gap-1",children:[e.jsx($s,{className:"w-3 h-3"}),gs?t("careerDocs.cvCount_other",{count:Ws}):Re?t("careerDocs.savedCount",{count:vs.length}):t("careerDocs.saved")]}):e.jsxs(je,{className:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20 gap-1",children:[e.jsx(ba,{className:"w-3 h-3"}),t("careerDocs.notCreated")]}),tn&&e.jsx(je,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20 gap-1 text-[10px] px-1.5 py-0.5 cursor-pointer hover:bg-blue-500/20 transition-colors",onClick:v=>{v.stopPropagation(),B===u.type?(M(null),j(null)):(M(u.type),j(u.type))},children:Te(r.language)?"🇬🇧 EN":"🇩🇰 DA"}),!gs&&!Re&&Ne&&(pr===Ne.id?e.jsx(Pr,{initialValue:ji||Ne.title,onSave:v=>{hi(Ne.id,v),Ba(null)},onCancel:()=>Ba(null)}):e.jsx(h,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{Ba(Ne.id),yi(Ne.title)},children:e.jsx(ya,{className:"w-3 h-3"})}))]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),!Ke&&(Re?vs.length>0:Ne)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Re?t("careerDocs.documentsCount",{count:vs.length}):`${t("careerDocs.lastUpdated")} ${_s(new Date(Ne.updated_at),"d. MMM yyyy",{locale:n})}`}),Ke&&As&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t("careerDocs.lastSaved")," ",_s(new Date(As.updated_at),"d. MMM yyyy",{locale:n})]})]})]}),gs&&e.jsxs("div",{className:"pl-0 sm:pl-[4.5rem] space-y-3",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(qu,{})}),e.jsx(Gu,{embedded:!0,onDownloadPdf:v=>_i({id:v.id,title:v.title,content:v.content,document_type:v.documentType||c("cv")}),onViewEdit:v=>{_t(v.id);const _e=v.documentType||u.type,Qe=c(u.type),Is=_e!==Qe,Ot=zt&&(ls==null?void 0:ls.id)===v.id&&B===u.type===Is;j(Ot?null:u.type),M(!Ot&&Is?u.type:null)}})]}),u.type==="cv_feedback"&&e.jsx("div",{className:"pl-0 sm:pl-[4.5rem]",children:e.jsxs(h,{size:"sm",className:"gap-2",onClick:()=>R(!0),children:[e.jsx(Xn,{className:"w-4 h-4"}),t("careerDocs.getNewCvFeedback","Få ny feedback på et CV")]})}),e.jsx("div",{className:`flex flex-wrap gap-2 pl-0 sm:pl-[4.5rem] ${gs&&oa?"hidden":""} ${u.type==="cv_feedback"?"hidden":""}`,children:Ke?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>{j(zt?null:u.type),zt&&M(null)},children:[e.jsx(Ht,{className:"w-4 h-4"}),t(zt?"careerDocs.close":"careerDocs.seeSuggestion")]}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:gr,onClick:()=>Po(),children:[gr?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4"}),t("careerDocs.generateNewSuggestion")]}),Ye&&e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:async()=>{const v=Fo(Ye);await ft(c("linkedin_profile"),t("careerDocs.linkedInProfileTitle"),v)&&J.success(t("careerDocs.linkedInSuggestionSaved"))},children:[e.jsx(zs,{className:"w-4 h-4"}
240),t("careerDocs.saveAsDocument")]})]}):oa?e.jsxs(e.Fragment,{children:[e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>{j(zt?null:u.type),zt&&M(null)},children:[e.jsx(Ht,{className:"w-4 h-4"}),t(zt?"careerDocs.close":gs?"careerDocs.seeAndEditCV":"careerDocs.see")]}),!Re&&Ne&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>{const v=()=>{let _e="";return document.querySelectorAll('link[rel="stylesheet"]').forEach(Qe=>{_e+=Qe.outerHTML+`
241`}),document.querySelectorAll("style").forEach(Qe=>{_e+=Qe.outerHTML+`
242`}),_e};if(u.type==="cv"||u.type==="kandidatbrief")zt||j(u.type),setTimeout(()=>{const _e=document.getElementById(`preview-${u.type}`);if(_e){const Qe=window.open("","_blank");if(Qe){const Is=v(),Ot=_e.cloneNode(!0);Ot.querySelectorAll('[data-pdf-exclude="true"], .cv-formatting-toolbar, [data-radix-popper-content-wrapper]').forEach(Un=>Un.remove()),Qe.document.write(`<!DOCTYPE html>
243<html lang="da">
244<head>
245  <meta charset="UTF-8">
246  <title>${u.title}</title>
247  ${Is}
248  <style>
249    @media print {
250      @page { size: A4; margin: 15mm; }
251      body { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
252      [data-pdf-exclude="true"], .cv-formatting-toolbar { display: none !important; }
253    }
254  </style>
255</head>
256<body class="bg-white">${Ot.innerHTML}</body>
257</html>`),Qe.document.close(),setTimeout(()=>Qe.print(),800)}}},300);else{const _e=window.open("","_blank");if(_e){const Qe=v();_e.document.write(`<!DOCTYPE html>
258<html lang="da">
259<head>
260  <meta charset="UTF-8">
261  <title>${u.title}</title>
262  ${Qe}
263  <style>
264    body { max-width: 800px; margin: 40px auto; padding: 20px; color: #333; line-height: 1.6; }
265    pre { white-space: pre-wrap; word-wrap: break-word; font-family: 'Segoe UI', Arial, sans-serif; font-size: 12pt; }
266    @media print {
267      body { margin: 0; padding: 20px; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
268      @page { size: A4; margin: 22.5mm; }
269    }
270  </style>
271</head>
272<body>
273  <pre>${bt(Ne.content).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>
274</body>
275</html>`),_e.document.close(),setTimeout(()=>_e.print(),500)}}},children:[e.jsx(Qt,{className:"w-4 h-4"}),"PDF"]}),e.jsxs(at,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",children:e.jsx(Ss,{className:"w-4 h-4"})})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:t("careerDocs.deleteDocTitle")}),e.jsx(lt,{children:t("careerDocs.deleteDocDescription",{title:Ne.title||u.title})})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:t("careerDocs.cancel")}),e.jsx(Ys,{onClick:()=>ui(Ne.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:t("careerDocs.delete")})]})]})]})]}),!Re&&u.type!=="cv"&&u.type!=="kandidatbrief"&&e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:pe===`${u.type}_alt`,onClick:()=>{const v=Te(r.language)?"en":"da";Tt(u.type,u.title,v)},children:[pe===`${u.type}_alt`?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx("span",{className:"text-sm",children:Te(r.language)?"🇬🇧":"🇩🇰"}),pe===`${u.type}_alt`?t("careerDocs.generatingDoc"):Te(r.language)?"Generate in English":"Generér på dansk"]}),!Re&&u.type!=="cv"&&u.type!=="kandidatbrief"&&(Ne==null?void 0:Ne.content)&&(()=>{const v=Te(r.language)?"en":"da",_e=`${Ne.id}_${v}`,Qe=T===_e;return e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:Qe,onClick:()=>vr(Ne,v),title:t("careerDocs.translateAsCopyHint","Oversætter den nuværende tekst (bevarer rettelser) og gemmer som ny kopi."),children:[Qe?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(vn,{className:"w-4 h-4"}),t(Qe?"careerDocs.translatingDoc":v==="en"?"careerDocs.translateToEnglish":"careerDocs.translateToDanish")]})})()]}):e.jsxs("div",{className:"space-y-3",children:[u.type==="cv"&&e.jsxs("div",{className:"p-3 border rounded-lg bg-muted/20 space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:t("careerDocs.cvLengthLabel","Ønsket CV-længde (A4-sider)")}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ya,{delayDuration:200,children:[1,2,3,4].map(v
275=>{const _e={1:t("cvDesignSelector.pageHint1","Bedst til nyuddannede eller kandidater med under 5 års erfaring. Kort og præcist – tvinger dig til at prioritere det vigtigste."),2:t("cvDesignSelector.pageHint2","Den mest anbefalede længde. Ideel til kandidater med 5-15 års erfaring. Giver plads til relevante resultater uden at miste læserens opmærksomhed."),3:t("cvDesignSelector.pageHint3","Til executive-/lederprofiler eller akademiske CV'er med 15+ års erfaring, bestyrelsesposter eller publikationer. Brug kun hvis indholdet virkelig kræver det."),4:t("cvDesignSelector.pageHint4","Kun til meget erfarne profiler med 20+ års karriere, omfattende publikationslister eller akademiske CV'er. De fleste rekrutteringsfolk foretrækker kortere CV'er – brug kun 4 sider hvis indholdet er strengt relevant.")};return e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(h,{size:"sm",variant:oe===v?"default":"outline",className:"flex-1 text-xs",onClick:()=>Ve(oe===v?null:v),children:t(`careerDocs.cvPages${v}`,`${v} side${v>1?"r":""}`)})}),e.jsx(Js,{side:"bottom",className:"max-w-xs text-xs",children:_e[v]})]},v)})})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("careerDocs.cvLengthHintOptional","Valgfrit – standard er 1-3 sider")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:pe===u.type,onClick:()=>Tt(u.type,u.title,void 0,oe||void 0),children:[pe===u.type?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4"}),pe===u.type?t("careerDocs.generatingDoc"):t("careerDocs.generateFirst")]}),!Re&&u.type!=="cv"&&e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:pe===`${u.type}_alt`,onClick:()=>{const v=Te(r.language)?"en":"da";Tt(u.type,u.title,v)},children:[pe===`${u.type}_alt`?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx("span",{className:"text-sm",children:Te(r.language)?"🇬🇧":"🇩🇰"}),pe===`${u.type}_alt`?t("careerDocs.generatingDoc"):Te(r.language)?"Generate in English":"Generér på dansk"]})]})]})})]}),Ke&&zt&&(Ye||As)&&e.jsx("div",{className:"mt-4 space-y-6",children:Ye?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-2",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Ca,{className:"w-4 h-4 text-primary"}),"Headline"]}),e.jsx("p",{className:"text-sm text-foreground",children:(Mn=Ye.headline)==null?void 0:Mn.suggestion}),((nn=(Fa=Ye.headline)==null?void 0:Fa.keywords)==null?void 0:nn.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:Ye.headline.keywords.map((v,_e)=>e.jsx(je,{variant:"secondary",className:"text-xs",children:v},_e))}),((Aa=Ye.headline)==null?void 0:Aa.explanation)&&e.jsx("p",{className:"text-xs text-muted-foreground italic mt-1",children:Ye.headline.explanation}),e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-7 text-xs mt-1",onClick:()=>{var v;return navigator.clipboard.writeText(((v=Ye.headline)==null?void 0:v.suggestion)||"").then(()=>J.success(t("careerDocs.copied")))},children:[e.jsx(Lt,{className:"w-3 h-3"})," ",t("careerDocs.copy")]})]}),e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-2",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Fs,{className:"w-4 h-4 text-primary"}),"Om mig"]}),e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:(rn=Ye.about)==null?void 0:rn.suggestion}),((ga=Ye.about)==null?void 0:ga.tips)&&e.jsxs("p",{className:"text-xs text-muted-foreground italic mt-2",children:["💡 ",Ye.about.tips]}),e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-7 text-xs mt-1",onClick:()=>{var v;return navigator.clipboard.writeText(((v=Ye.about)==null?void 0:v.suggestion)||"").then(()=>J.success(t("careerDocs.copied")))},children:[e.jsx(Lt,{className:"w-3 h-3"})," ",t("careerDocs.copy")]})]}),(($n=Ye.experienceDescriptions)==null?void 0:$n.length)>0&&e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-3",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(ht,{className:"w-4 h-4 text-primary"}),t("careerDocs.experience")]}),Ye.experienceDescriptions.map((v,_e)=>{var Qe;return e.jsxs("div",{className:"border-l-2 border-primary/30 pl-3 space-y-1",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground",children:[v.title," — ",v.company]}),e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:v.description}),((Qe=v.keywords)==null?void 0:Qe.length)>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:v.keywords.map((Is,Ot)=>e.jsx(je,{variant:"outline",className:"text-xs",children:Is},Ot))})]},_e)}),e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-7 text-xs",onClick:()=>{const v=Ye.experienceDescriptions.map(_e=>`${_e.title} — ${_e.company}
276${_e.description}`).join(`
277
278`);navigator.clipboard.writeText(v).then(()=>J.success(t("careerDocs.copied")))},children:[e.jsx(Lt,{className:"w-3 h-3"})," ",t("careerDocs.copy")," ",t("careerDocs.copyAll")]})]}),Ye.skills&&e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-3",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(ar,{className:"w-4 h-4 text-primary"}),t("careerDocs.skills")]}),((Vs=Ye.skills.topSkills)==null?void 0:Vs.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:t("jobStrategy.topSkills")}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ye.skills.topSkills.map((v,_e)=>e.jsx(je,{className:"text-xs",children:v},_e))})]}
278),((ln=Ye.skills.technicalSkills)==null?void 0:ln.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:t("careerDocs.technicalSkills")}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ye.skills.technicalSkills.map((v,_e)=>e.jsx(je,{variant:"secondary",className:"text-xs",children:v},_e))})]}),((ea=Ye.skills.softSkills)==null?void 0:ea.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:t("jobStrategy.softSkills")}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ye.skills.softSkills.map((v,_e)=>e.jsx(je,{variant:"outline",className:"text-xs",children:v},_e))})]}),e.jsxs(h,{size:"sm",variant:"ghost",className:"gap-1 h-7 text-xs",onClick:()=>{const v=[...Ye.skills.topSkills||[],...Ye.skills.technicalSkills||[],...Ye.skills.softSkills||[],...Ye.skills.industryKeywords||[]].join(", ");navigator.clipboard.writeText(v).then(()=>J.success(t("careerDocs.copied")))},children:[e.jsx(Lt,{className:"w-3 h-3"})," ",t("careerDocs.copyAllSkills")]})]}),Ye.searchOptimization&&e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-3",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Ut,{className:"w-4 h-4 text-primary"}),t("careerDocs.searchOptimization")]}),((Rn=Ye.searchOptimization.primaryKeywords)==null?void 0:Rn.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:t("careerDocs.primaryKeywords")}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ye.searchOptimization.primaryKeywords.map((v,_e)=>e.jsx(je,{className:"text-xs",children:v},_e))})]}),((Pi=Ye.searchOptimization.jobTitlesToTarget)==null?void 0:Pi.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:t("careerDocs.targetPositions")}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ye.searchOptimization.jobTitlesToTarget.map((v,_e)=>e.jsx(je,{variant:"secondary",className:"text-xs",children:v},_e))})]})]}),((Fi=Ye.visibilityTips)==null?void 0:Fi.length)>0&&e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-2",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(wt,{className:"w-4 h-4 text-primary"}),t("careerDocs.visibilityTips")]}),e.jsx("ul",{className:"space-y-2",children:Ye.visibilityTips.map((v,_e)=>{var Qe;return e.jsxs("li",{className:"text-sm text-foreground flex items-start gap-2",children:[e.jsx(je,{variant:((Qe=v.impact)==null?void 0:Qe.toLowerCase())==="høj"?"default":"secondary",className:"text-xs shrink-0 mt-0.5",children:v.impact}),e.jsxs("span",{children:[e.jsxs("strong",{children:[v.category,":"]})," ",v.tip]})]},_e)})})]}),((Ai=Ye.customURL)==null?void 0:Ai.suggestion)&&e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-1",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Tl,{className:"w-4 h-4 text-primary"}),t("careerDocs.suggestedProfileUrl")]}),e.jsxs("p",{className:"text-sm text-foreground font-mono",children:["linkedin.com/in/",Ye.customURL.suggestion]}),e.jsx("p",{className:"text-xs text-muted-foreground italic",children:Ye.customURL.explanation})]}),((Li=(Ii=Ye.featuredSection)==null?void 0:Ii.suggestions)==null?void 0:Li.length)>0&&e.jsxs("div",{className:"p-4 bg-muted/30 rounded-lg space-y-2",children:[e.jsxs("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Ps,{className:"w-4 h-4 text-primary"}),t("careerDocs.featuredSection")]}),e.jsx("ul",{className:"list-disc list-inside text-sm text-foreground space-y-1",children:Ye.featuredSection.suggestions.map((v,_e)=>e.jsx("li",{children:v},_e))}),Ye.featuredSection.explanation&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:Ye.featuredSection.explanation})]})]}):As?e.jsx("div",{className:"p-4 bg-muted/30 rounded-lg",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:bt(As.content)})}):null}),!Ke&&zt&&oa&&!Vn&&e.jsxs("div",{className:"mt-4 space-y-4",children:[an&&Pa&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 p-3 bg-blue-500/10 border border-blue-500/20 rounded-lg",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm text-blue-700 dark:text-blue-300 font-medium",children:Te(r.language)?"🇬🇧 Viser engelsk version":"🇩🇰 Showing Danish version"}),e.jsx("span",{className:"text-xs text-blue-700/80 dark:text-blue-300/80",children:Te(r.language)?`Den er automatisk gemt som et selvstændigt CV under "Dine CV'er".`:'It has been saved automatically as a separate CV under "Your CVs".'})]}),e.jsxs(h,{size:"sm",variant:"ghost",className:"h-7 px-2 text-blue-600 self-start sm:self-auto",onClick:()=>M(null),children:[e.jsx(mt,{className:"w-3.5 h-3.5 mr-1"}),Te(r.language)?"Vis dansk":"Show English"]})]}
278),u.type==="kandidatbrief"&&Ne&&(()=>{const v=(r.language||"da").toLowerCase().startsWith("da");return e.jsxs("div",{className:"p-4 rounded-lg border border-primary/20 bg-primary/5 flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:v?"Har du opdateret dit CV?":"Have you updated your CV?"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:v?"Opdater dit kandidatbrief, så det matcher dit nye CV. Det nuværende kandidatbrief erstattes. Hvis briefet ikke rammer helt rigtigt eller mangler noget, så generér igen.":"Refresh your candidate brief to match your latest CV. The current brief will be replaced. If the brief is not quite right or missing something, just regenerate it."})]}),e.jsxs(h,{size:"sm",className:"gap-2 shrink-0",disabled:pe===u.type,onClick:()=>Tt(u.type,u.title),children:[pe===u.type?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4"}),pe===u.type?v?"Opdaterer...":"Updating...":v?"Opdater kandidatbrief til dit nye CV":"Update candidate brief to your new CV"]})]})})(),!Re&&Ne&&u.type!=="cv"&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[!1,u.type==="cv"?null:e.jsxs(e.Fragment,{children:[e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>{Vo(u.type,Ne.content)},children:[e.jsx(Qa,{className:"w-4 h-4"}),t("careerDocs.editManually")]}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>{if(u.type==="kandidatbrief"){const v=ze!==u.type;xe(v?u.type:null),E(null),v&&setTimeout(()=>{var _e;(_e=document.getElementById("kandidatbrief-customization-panel"))==null||_e.scrollIntoView({behavior:"smooth",block:"start"})},100)}else{const v=I!==u.type;E(v?u.type:null),xe(null)}k(null),O("")},children:[e.jsx(Va,{className:"w-4 h-4"}),t("careerDocs.editWithAI")]})]}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:pe===u.type,onClick:()=>Tt(u.type,u.title,void 0,oe||void 0),children:[pe===u.type?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4"}),pe===u.type?t("careerDocs.generatingDoc"):t("careerDocs.generateAgain")]}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:pe===`${u.type}_alt`,onClick:()=>{const v=Te(r.language)?"en":"da";Tt(u.type,u.title,v)},children:[pe===`${u.type}_alt`?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx("span",{className:"text-sm",children:Te(r.language)?"🇬🇧":"🇩🇰"}),pe===`${u.type}_alt`?t("careerDocs.generatingDoc"):Te(r.language)?"Generate in English":"Generér på dansk"]}),u.type!=="cv"&&(Ne==null?void 0:Ne.content)&&(()=>{const v=Te(r.language)?"en":"da",_e=`${Ne.id}_${v}`,Qe=T===_e;return e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:Qe,onClick:()=>vr(Ne,v),title:t("careerDocs.translateAsCopyHint"),children:[Qe?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(vn,{className:"w-4 h-4"}),t(Qe?"careerDocs.translatingDoc":v==="en"?"careerDocs.translateToEnglish":"careerDocs.translateToDanish")]})})()]}),Re?e.jsx("div",{className:"space-y-2",children:vs.map((v,_e)=>{const Qe=g===v.id;return e.jsxs("div",{className:"bg-muted/30 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 p-3",children:[pr===v.id?e.jsx(Pr,{initialValue:ji||v.title,onSave:Is=>{hi(v.id,Is),Ba(null)},onCancel:()=>Ba(null),inputClassName:"h-7 text-sm flex-1",iconSize:"md",wrapperClassName:"flex items-center gap-2 flex-1 min-w-0"}):e.jsxs("button",{type:"button",className:"flex items-center gap-2 flex-1 min-w-0 text-left",onClick:()=>P(Qe?null:v.id),children:[e.jsx(Fs,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:v.title})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:_s(new Date(v.updated_at),"d. MMM yyyy",{locale:n})}),e.jsxs(h,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1",onClick:()=>_i(v),disabled:me===v.id,title:"Download PDF",children:[me===v.id?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Qt,{className:"w-3.5 h-3.5"}),"PDF"]}),u.type!=="cv"&&u.type!=="kandidatbrief"&&e.jsxs(h,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1",onClick:()=>Ho(v),disabled:y===v.id,title:"Download Word",children:[y===v.id?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Qt,{className:"w-3.5 h-3.5"}),"Word"]}),v.content&&(()=>{const Is=Te(r.language)?"en":"da",Ot=`${v.id}_${Is}`,Un=T===Ot;return e.jsxs(h,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1",disabled:Un,onClick:()=>vr(v,Is),title:t("careerDocs.translateAsCopyHint"),children:[Un?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(vn,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:Is==="en"?"EN":"DA"})]})})(),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>{Qe?(P(null),N===v.id&&(w(null),A(""))):P(v.id)},children:Qe?t("careerDocs.hide",{defaultValue:"Skjul"}):t("careerDocs.show",{defaultValue:"Vis"})}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>{N===v.id?(w(null),A("")):(P(v.id),w(v.id),A(v.content))},children:N===v.id?t("careerDocs.closeEditor",{defaultValue:"Luk redigering"}):t("careerDocs.edit",{defaultValue:"Rediger"})}),pr!==v.id&&e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{Ba(v.id),yi(v.title)},children:e.jsx(ya,{className:"w-3.5 h-3.5"})}),e.jsxs(at,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive h-7 w-7 p-0",children:e.jsx(Ss,{className:"w-3.5 h-3.5"})})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:t("careerDocs.deleteDocTitle")}),e.jsx(lt,{children:t("careerDocs.deleteDocDescription",{title:"{doc.title}"})})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:t("careerDocs.cancel")}),e.jsx(Ys,{onClick:()=>{g===v.id&&P(null),ui(v.id)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Slet"})]})]})]})]})]}),Qe&&e.jsx("div",{className:"px-4 pb-4 pt-1 border-t border-border/40",children:N===v.id?e.jsxs("div",{className:"space-y-3 pt-3",children:[e.jsx(as,{value:S,onChange:Is=>A(Is.target.value),className:"min-h-[300px] font-mono text-sm"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",onClick:()=>{w(null),A("")},disabled:y===v.id,children:t("careerDocs.cancel",{defaultValue:"Annullér"})}),e.jsxs(h,{size:"sm",onClick:async()=>{D(v.id);const{error:Is}=await C.from("career_documents").update({content:S,updated_at:new Date().toISOString()}).eq("id",v.id);if(D(null),Is)J.error(t("careerDocs.saveFailed",{defaultValue:"Kunne ikke gemme"}));else{J.success(t("careerDocs.documentUpdated",{defaultValue:"Dokumentet er opdateret"})),w(null),A("");try{window.dispatchEvent(new Event("career-documents-changed"))}catch{}}},disabled:y===v.id,children:[y===v.id?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin mr-1"}):e.jsx(zs,{className:"w-3.5 h-3.5 mr-1"}),t("careerDocs.save",{defaultValue:"Gem"})]})]})]}
278):u.type==="kandidatbrief"?e.jsx(fn,{content:v.content,designId:"executive-search"}):e.jsx(Or,{text:bt(v.content)})})]},v.id)})}):u.type==="cv"?e.jsxs("div",{className:"space-y-4",children:[en.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:t("careerDocs.uploadedCVs")}),en.map(v=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Fs,{className:"w-5 h-5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[yo===v.id?e.jsx(Pr,{initialValue:bo||v.title,onSave:_e=>{go(v.id,_e),xr(null)},onCancel:()=>xr(null),iconSize:"md",wrapperClassName:"flex items-center gap-2"}):e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:v.title}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[v.file_name," · ",_s(new Date(v.created_at),"d. MMM yyyy",{locale:n})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[v.is_primary?e.jsxs(je,{className:"bg-primary/10 text-primary border-primary/20 gap-1",children:[e.jsx(Ps,{className:"w-3 h-3"}),"Primært"]}):e.jsxs(h,{size:"sm",variant:"ghost",className:"text-xs gap-1",onClick:()=>xo(v.id),children:[e.jsx(Ps,{className:"w-3 h-3"}),"Gør primært"]}),e.jsx(h,{size:"sm",variant:"ghost",className:"gap-1",onClick:()=>{xr(v.id),No(v.title)},children:e.jsx(ya,{className:"w-4 h-4"})}),e.jsx(h,{size:"sm",variant:"ghost",className:"gap-1",onClick:()=>uo(v.file_path,v.file_name),children:e.jsx(Qt,{className:"w-4 h-4"})}),e.jsxs(at,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",children:e.jsx(Ss,{className:"w-4 h-4"})})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:t("careerDocs.deleteCVTitle")}),e.jsx(lt,{children:t("careerDocs.deleteDocDescription",{title:"{cv.title}"})})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:t("careerDocs.cancel")}),e.jsx(Ys,{onClick:()=>ho(v.id,v.file_path),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Slet"})]})]})]})]})]},v.id))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"file",ref:Tn,onChange:Do,accept:".pdf,.doc,.docx,.txt,.rtf,.odt",className:"hidden"}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2 border-dashed flex-1",onClick:()=>{var v;return(v=Tn.current)==null?void 0:v.click()},disabled:hr,children:[hr?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(nr,{className:"w-4 h-4"}),t(hr?"careerDocs.uploading":"careerDocs.uploadCV")]}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2 flex-1",onClick:()=>s("/opret-cv?from=dashboard"),children:[e.jsx(fs,{className:"w-4 h-4"}),t("careerDocs.createNewCV")]})]}),Ne&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:t("careerDocs.aiGeneratedCV")}),cs&&e.jsxs("div",{className:"p-4 border rounded-lg bg-muted/20 space-y-5",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>hs(!1),children:e.jsx(mt,{className:"w-4 h-4"})})}),e.jsx(zl,{profilePhotoUrl:De,onPhotoChange:v=>_(v)}),De&&e.jsxs("div",{className:"space-y-4 border-t border-border pt-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:t("careerDocs.photoSettingsInCV")}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:t("careerDocs.showPhotoInCV")}),e.jsx("button",{onClick:()=>Ao(!z),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${z?"bg-primary":"bg-muted-foreground/30"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${z?"translate-x-6":"translate-x-1"}`})})]}),z&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:t("careerDocs.photoShape")}),e.jsx("div",{className:"flex gap-2",children:[["circular",t("careerDocs.circular")],["square",t("careerDocs.square")],["rounded",t("careerDocs.rounded")]].map(([v,_e])=>e.jsx(h,{size:"sm",variant:U===v?"default":"outline",onClick:()=>Io(v),className:"text-xs",children:_e},v))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:t("careerDocs.photoSize")}),e.jsx("div",{className:"flex gap-2",children:[["small",t("careerDocs.small")],["medium",t("careerDocs.medium")],["large",t("careerDocs.large")]].map(([v,_e])=>e.jsx(h,{size:"sm",variant:fe===v?"default":"outline",onClick:()=>Lo(v),className:"text-xs",children:_e},v))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:t("careerDocs.photoFill")}),e.jsx("div",{className:"flex gap-2",children:[["cover",t("careerDocs.fillOut")],["contain",t("careerDocs.fitWithin")]].map(([v,_e])=>e.jsx(h,{size:"sm",variant:Ze===v?"default":"outline",onClick:()=>Oo(v),className:"text-xs",children:_e},v))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:t("careerDocs.position")}),e.jsx("div",{className:"flex gap-2",children:[["left",t("careerDocs.left")],["center",t("careerDocs.center")],["right",t("careerDocs.right")]].map(([v,_e])=>e.jsx(h,{size:"sm",variant:G===v?"default":"outline",onClick:()=>Eo(v),className:"text-xs",children:_e},v))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:t("careerDocs.background")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["none",t("careerDocs.none")],["primary",t("careerDocs.primaryColor")],["secondary",t("careerDocs.secondaryColor")],["gradient-blue",t("careerDocs.blueGradient")],["gradient-purple",t("careerDocs.purpleGradient")],["gradient-green",t("careerDocs.greenGradient")],["dark",t("careerDocs.dark")],["light",t("careerDocs.light")],["custom",t("careerDocs.custom")]].map(([v,_e])=>e.jsx(h,{size:"sm",variant:Ee===v?"default":"outline",onClick:()=>To(v),className:"text-xs",children:_e},v))})]}),Ee==="custom"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:t("careerDocs.color")}),e.jsx("input",{type:"color",value:Ge||"#ffffff",onChange:v=>zo(v.target.value),className:"h-8 w-12 rounded border border-input cursor-pointer"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ge||"#ffffff"})]})]})]})]}),e.jsx("div",{className:"hidden lg:flex justify-end mb-2 gap-2",children:e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2 text-xs",onClick:()=>ms(!0),children:[e.jsx(Ht,{className:"w-3.5 h-3.5"}),t("careerDocs.fullPreview","Fuldt preview (scroll sider)")]})}),e.jsxs("div",{id:"preview-cv",children:[e.jsxs("div",{"data-pdf-exclude":"true",className:"mx-auto max-w-3xl mb-3 rounded-md border border-amber-200 dark:border-amber-800 bg-amber-50/70 dark:bg-amber-950/30 px-4 py-3 text-xs text-amber-900 dark:text-amber-100",children:[e.jsx("p",{className:"font-semibold mb-1",children:t("careerDocs.cvDisclaimerTitle",'Et oplæg kan komme ud forkert. Prøv at tr
278ykke "Generer igen".')}),e.jsx("p",{className:"leading-relaxed",children:t("careerDocs.cvDisclaimerBody","Når vi genererer dit CV, så kommer vi med oplæg, hvor vi tilpasser arbejds- og ansvarsområder mv. Der kan være fejl i antagelser. Læs igennem og tilpas. Du kan rette manuelt eller med AI i toolbar.")})]}),Ne&&e.jsxs("div",{"data-pdf-exclude":"true",className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:pe===u.type,onClick:()=>Tt(u.type,u.title,void 0,oe||void 0),children:[pe===u.type?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4"}),pe===u.type?t("careerDocs.generatingDoc"):t("careerDocs.generateAgain")]}),e.jsxs(h,{size:"sm",variant:"outline",className:"gap-2",disabled:pe===`${u.type}_alt`,onClick:()=>{const v=Te(r.language)?"en":"da";Tt(u.type,u.title,v)},children:[pe===`${u.type}_alt`?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx("span",{className:"text-sm",children:Te(r.language)?"🇬🇧":"🇩🇰"}),pe===`${u.type}_alt`?t("careerDocs.generatingDoc"):Te(r.language)?"Generate in English":"Generér på dansk"]}),e.jsxs(ta,{children:[e.jsx(aa,{asChild:!0,children:e.jsxs(h,{size:"sm",variant:"default",className:"gap-2",children:[e.jsx(zs,{className:"w-4 h-4"}),t("careerDocs.save","Gem"),e.jsx(Ts,{className:"w-3 h-3"})]})}),e.jsxs(na,{align:"end",className:"w-56 p-1",onOpenAutoFocus:v=>v.preventDefault(),children:[e.jsxs("button",{type:"button",onClick:async()=>{const v=await sn(Gt||Ne.content);Ne&&await fr(Ne.id,Ne.content,_s(new Date,"d. MMM yyyy HH:mm",{locale:n})),await ft(Ne.document_type,Ne.title,v,zn(),Ne.id)&&J.success(t("careerDocs.cvUpdated"))},className:"w-full flex items-center gap-2 px-2 py-2 rounded-md text-left text-xs hover:bg-muted",children:[e.jsx(zs,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("span",{className:"flex-1",children:t("careerDocs.saveInCurrentCV","Gem i nuværende CV")})]}),e.jsxs("button",{type:"button",onClick:async()=>{const v=await sn(Gt||Ne.content);await Ha(Ne.document_type,Ne.title,v,zn())&&J.success(t("careerDocs.savedAsCopy","Gemt som ny kopi!"))},className:"w-full flex items-center gap-2 px-2 py-2 rounded-md text-left text-xs hover:bg-muted",children:[e.jsx(Lt,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("span",{className:"flex-1",children:t("careerDocs.saveAsNewCV","Gem som nyt CV")})]})]})]})]}),e.jsx("div",{"data-pdf-exclude":"true",className:"cv-formatting-toolbar",children:e.jsx(Uu,{fontPair:Bs,onFontPairChange:v=>{ie(v),St({cv_font_pair:v})},fontSize:o,onFontSizeChange:v=>{V(v),St({cv_font_size:v})},lineSpacing:ss,onLineSpacingChange:v=>{$e(v),St({cv_line_spacing:v})},accentColor:W,onAccentColorChange:v=>{be(v),St({cv_accent_color:v})},headerColor:Me,onHeaderColorChange:v=>{Be(v),St({cv_header_color:v})},paperColor:Xs,onPaperColorChange:v=>{Ks(v),St({cv_paper_color:v})},separatorStyle:es,onSeparatorStyleChange:v=>{bs(v),St({cv_separator_style:v})},iconStyle:q,onIconStyleChange:v=>{const _e=Ie(v);Ce(_e),St({cv_icon_style:_e})},sectionOrder:ds,onUndo:_o,undoCount:Sa.count,onSectionOrderChange:v=>{Ns(v),St({cv_section_order:v})},cvContent:Gt??Ne.content,onCVUpdated:async v=>{const _e=Gt||Ne.content;_e&&_e!==v&&ki(_e),Es(Qe=>({...Qe,[Ne.id]:v})),await ft(Ne.document_type,Ne.title,v,void 0,Ne.id)},selectedDesign:le,onDesignChange:v=>{X(v),St({cv_design:v})},selectedCVType:L,onCVTypeChange:async v=>{ce(v),await St({cv_type:v}),await Tt(u.type,u.title,void 0,oe||void 0)},selectedCvPages:oe,onCvPagesChange:v=>Ve(v),onRegenerateCV:v=>Tt(u.type,u.title,void 0,v||void 0),isRegeneratingCV:pe===u.type,showPhotoPanel:cs,onTogglePhotoPanel:()=>hs(!cs),languageVoice:ys,onLanguageVoiceChange:async v=>{Hs(v);const{data:{user:_e}}=await C.auth.getUser();_e&&await C.from("profiles").update({cv_language_voice:v}).eq("id",_e.id),J.info(t("careerDocs.languageStyleChanged","Sprogstil opdateret. Genererer CV på ny...")),await Tt(u.type,u.title,void 0,oe||void 0)},languageFormality:Os,onLanguageFormalityChange:async v=>{Ls(v);const{data:{user:_e}}=await C.auth.getUser();_e&&await C.from("profiles").update({cv_language_formality:v}).eq("id",_e.id),J.info(t("careerDocs.languageStyleChanged","Sprogstil opdateret. Genererer CV på ny...")),await Tt(u.type,u.title,void 0,oe||void 0)},onSaveCurrent:async()=>{const v=await sn(Gt||Ne.content);Ne&&await fr(Ne.id,Ne.content,_s(new Date,"d. MMM yyyy HH:mm",{locale:n})),await ft(Ne.document_type,Ne.title,v,zn(),Ne.id)&&J.success(t("careerDocs.cvUpdated"))},onSaveAsNew:async()=>{const v=await sn(Gt||Ne.content);await Ha(Ne.document_type,Ne.title,v,zn())&&J.success(t("careerDocs.savedAsCopy","Gemt som ny kopi!"))}})}),e.jsx("div",{ref:ur,children:e.jsx(Tr,{content:Gt??Ne.content,designId:le,defaultName:Z,defaultContactInfo:ne,profilePhotoUrl:De,showPhoto:z,photoShape:U,photoSize:fe,photoPosition:G,photoBackgroun
278d:Ee,photoCustomColor:Ge,photoFit:Ze,fontPair:Bs,fontSize:o,accentColor:W??void 0,headerColor:Me??void 0,paperColor:Xs,separatorStyle:es,iconStyle:q,lineSpacing:ss,sectionOrder:ds,onSectionOrderChange:v=>{Ns(v),St({cv_section_order:v})},onContentChange:async v=>{const _e=Gt||Ne.content;_e&&_e!==v&&ki(_e),Ln.current=v,Es(Is=>({...Is,[Ne.id]:v}));const Qe=ft(Ne.document_type,Ne.title,v,void 0,Ne.id);Ua.current=Qe;try{await Qe}finally{Ua.current===Qe&&(Ua.current=null)}}},(Dt==null?void 0:Dt.id)??Ne.id)})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:t("careerDocs.undoHint","Tip: Brug Cmd/Ctrl+Z i CV'et for at fortryde — virker mange skridt tilbage som i Word.")}),e.jsx(Hu,{containerRef:ur})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-3",children:e.jsxs(h,{className:"flex-1 gap-2",variant:"outline",onClick:()=>{Ci(),xa(!0)},children:[e.jsx(wn,{className:"w-4 h-4"}),t("careerDocs.versionHistory","Versionshistorik")]})})]}),e.jsx(Bu,{open:ps,onOpenChange:ms,content:Gt||Ne.content,designId:le,profilePhotoUrl:De,showPhoto:z,photoShape:U,photoSize:fe,photoPosition:G,photoBackground:Ee,photoCustomColor:Ge,photoFit:Ze,fontPair:Bs,fontSize:o,accentColor:W??void 0,headerColor:Me??void 0,paperColor:Xs,cvPages:oe??2})]}),!Ne&&en.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("careerDocs.noCVsYet")})]}):u.type==="kandidatbrief"?e.jsx("div",{id:"preview-kandidatbrief",children:e.jsx(fn,{content:(Dt||Ne).content,designId:"executive-search"})}):e.jsx("div",{className:"p-4 bg-muted/30 rounded-lg border",children:e.jsx(Or,{text:bt((Dt||Ne).content)})}),I===u.type&&e.jsxs("div",{className:"p-4 border rounded-lg bg-muted/20 space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:t("careerDocs.describeAIChanges")}),e.jsx(as,{value:F,onChange:v=>O(v.target.value),className:"min-h-[100px] text-sm",placeholder:t("careerDocs.aiEditPlaceholder")}),u.type==="cv"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:t("careerDocs.cvLengthLabel","Ønsket CV-længde (A4-sider)")}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ya,{delayDuration:200,children:[1,2,3,4].map(v=>{const _e={1:t("cvDesignSelector.pageHint1","Bedst til nyuddannede eller kandidater med under 5 års erfaring. Kort og præcist – tvinger dig til at prioritere det vigtigste."),2:t("cvDesignSelector.pageHint2","Den mest anbefalede længde. Ideel til kandidater med 5-15 års erfaring. Giver plads til relevante resultater uden at miste læserens opmærksomhed."),3:t("cvDesignSelector.pageHint3","Til executive-/lederprofiler eller akademiske CV'er med 15+ års erfaring, bestyrelsesposter eller publikationer. Brug kun hvis indholdet virkelig kræver det."),4:t("cvDesignSelector.pageHint4","Kun til meget erfarne profiler med 20+ års karriere, omfattende publikationslister eller akademiske CV'er. De fleste rekrutteringsfolk foretrækker kortere CV'er – brug kun 4 sider hvis indholdet er strengt relevant.")};return e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"outline",className:"flex-1 text-xs",onClick:()=>{const Qe=Te(r.language)?`Tilpas CV'et til ca. ${v} A4-side${v>1?"r":""}. ${v===1?"Vær kortfattet og inkluder kun det vigtigste.":v===2?"Inkluder relevant detalje men vær stadig fokuseret.":v===3?"Vær detaljeret med fyldige beskrivelser af ansvar og resultater.":"Vær meget detaljeret med omfattende beskrivelser af alle stillinger, ansvar, resultater og kompetencer."}`:`Adjust the CV to approximately ${v} A4 page${v>1?"s":""}. ${v===1?"Be concise and include only the essentials.":v===2?"Include relevant detail but stay focused.":v===3?"Be detailed with thorough descriptions of responsibilities and results.":"Be very detailed with comprehensive descriptions of all positions, responsibilities, results and competencies."}`;O(Qe)},children:t(`careerDocs.cvPages${v}`,`${v} side${v>1?"r":""}`)})}),e.jsx(Js,{side:"bottom",className:"max-w-xs text-xs",children:_e[v]})]},v)})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{size:"sm",className:"gap-2",disabled:!F.trim()||ee,onClick:()=>{Ne&&Ko(u.type,u.title,Ne.content)},children:[ee?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(Cn,{className:"w-4 h-4"}),t(ee?"careerDocs.aiEditing":"careerDocs.runAIEdit")]}),e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>{E(null),O("")},children:[e.jsx(mt,{className:"w-4 h-4"}),t("careerDocs.cancelAction")]})]})]}),u.type==="cv"&&re===u.type&&Ne&&e.jsxs("div",{id:"cv-customization-panel",className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 gap-6",children:e.jsx("div",{className:"space-y-4 min-w-0",children:e.jsxs("div",{className:"p-4 border rounded-lg bg-muted/20 space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:t("careerDocs.cvLengthLabel","Ønsket CV-længde (A4-sider)")}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ya,{delayDuration:200,children:[1,2,3,4].map(v
278=>{const _e={1:t("cvDesignSelector.pageHint1","Bedst til nyuddannede eller kandidater med under 5 års erfaring. Kort og præcist – tvinger dig til at prioritere det vigtigste."),2:t("cvDesignSelector.pageHint2","Den mest anbefalede længde. Ideel til kandidater med 5-15 års erfaring. Giver plads til relevante resultater uden at miste læserens opmærksomhed."),3:t("cvDesignSelector.pageHint3","Til executive-/lederprofiler eller akademiske CV'er med 15+ års erfaring, bestyrelsesposter eller publikationer. Brug kun hvis indholdet virkelig kræver det."),4:t("cvDesignSelector.pageHint4","Kun til meget erfarne profiler med 20+ års karriere, omfattende publikationslister eller akademiske CV'er. De fleste rekrutteringsfolk foretrækker kortere CV'er – brug kun 4 sider hvis indholdet er strengt relevant.")};return e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"outline",className:"flex-1 text-xs",onClick:()=>{const Qe=Te(r.language)?`Tilpas CV'et til ca. ${v} A4-side${v>1?"r":""}. ${v===1?"Vær kortfattet og inkluder kun det vigtigste.":v===2?"Inkluder relevant detalje men vær stadig fokuseret.":v===3?"Vær detaljeret med fyldige beskrivelser af ansvar og resultater.":"Vær meget detaljeret med omfattende beskrivelser af alle stillinger, ansvar, resultater og kompetencer."}`:`Adjust the CV to approximately ${v} A4 page${v>1?"s":""}. ${v===1?"Be concise and include only the essentials.":v===2?"Include relevant detail but stay focused.":v===3?"Be detailed with thorough descriptions of responsibilities and results.":"Be very detailed with comprehensive descriptions of all positions, responsibilities, results and competencies."}`;O(Qe),E(u.type)},children:t(`careerDocs.cvPages${v}`,`${v} side${v>1?"r":""}`)})}),e.jsx(Js,{side:"bottom",className:"max-w-xs text-xs",children:_e[v]})]},v)})})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("careerDocs.cvLengthHint","Klik på en længde for automatisk at tilpasse dit CV")})]})})}),Ni.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),t("careerDocs.savedPresets","Gemte designskabeloner")]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:Ni.map(v=>e.jsxs(ye,{className:"p-3 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:v.preset_name}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(h,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>ko(v),children:e.jsx(Ht,{className:"w-3.5 h-3.5"})}),e.jsxs(at,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(h,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",children:e.jsx(Ss,{className:"w-3.5 h-3.5"})})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:t("careerDocs.deletePresetTitle","Slet skabelon?")}),e.jsx(lt,{children:t("careerDocs.deletePresetDesc","Er du sikker på at du vil slette denne designskabelon?")})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:t("careerDocs.cancelAction")}),e.jsx(Ys,{onClick:()=>Co(v.id),children:t("careerDocs.delete","Slet")})]})]})]})]})]}),e.jsxs("div",{className:"flex gap-1.5 flex-wrap",children:[v.cv_design&&e.jsx(je,{variant:"secondary",className:"text-[10px]",children:v.cv_design}),v.cv_font_pair&&e.jsx(je,{variant:"outline",className:"text-[10px]",children:v.cv_font_pair})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:_s(new Date(v.created_at),"d. MMM yyyy",{locale:n})})]},v.id))})]})]}),u.type==="kandidatbrief"&&Ne&&ze===u.type&&e.jsx("div",{id:"kandidatbrief-customization-panel",className:"scroll-mt-24",children:e.jsx(Ju,{briefContent:Ne.content,briefContentStandard:(Ei=Zs(c("kandidatbrief_standard")))==null?void 0:Ei.content,onBriefUpdated:async v=>{await ft(c(u.type),u.title,v)},onSubmitChanges:v=>{console.log("Kandidatbrief changes requested:",v)},onDesignChange:v=>{console.log("Kandidatbrief design changed to:",v)}})})]}),Vn&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx(as,{value:$,onChange:v=>K(v.target.value),className:"min-h-[200px]",placeholder:t("careerDocs.editPlaceholder")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{size:"sm",onClick:()=>Mo(u.type,u.title),className:"gap-2",children:[e.jsx(zs,{className:"w-4 h-4"}),t("careerDocs.saveChanges")]}),e.jsxs(h,{size:"sm",variant:"outline",onClick:$o,className:"gap-2",children:[e.jsx(mt,{className:"w-4 h-4"}),t("careerDocs.cancelAction")]})]})]})]})]},u.type)})}),e.jsx(io,{generatedCVContent:(Di=Zs(c("cv")))==null?void 0:Di.content,savedCVs:fo,uploadedCVs:en,controlledOpen:Y,onControlledOpenChange:u=>R(u),onSaveFeedback:async u=>{const de=await Ha(c("cv_feedback"),t("cvFeedbackDialog.title"),u);return de&&J.success(t("careerDocs.cvFeedbackSaved","Feedback gemt under 'Feedback på dit CV'.")),de},onApplyImprovements:async(u,de)=>await ft(c("cv"),"CV",u,void 0,de)}),e.jsx(at,{open:In,onOpenChange:_a,children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:t("careerDocs.saveAsDialogTitle","Gem ændringer")}),e.jsx(lt,{children:t("careerDocs.saveAsDialogDescription","Vil du overskrive dit nuværende CV eller gemme ændringerne som en ny kopi?")})]}),e.jsxs(ot,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(ct,{onClick:()=>Wt(null),children:t("careerDocs.saveAsCancel","Annuller")}),e.jsxs(h,{variant:"outline",onClick:async()=>{Cs&&await Ha(Cs.docType,Cs.title,Cs.content)&&J.success(t("careerDocs.savedAsCopy","Gemt som ny kopi!")),_a(!1),Wt(null)},children:[e.jsx(Lt,{className:"w-4 h-4 mr-2"}),t("careerDocs.saveAsCopy","Gem som kopi")]}),e.jsxs(Ys,{onClick:async()=>{Cs&&await ft(Cs.docType,Cs.title,Cs.content)&&J.success(t("careerDocs.cvUpdated")),Wt(null)},children:[e.jsx(zs,{className:"w-4 h-4 mr-2"}),t("careerDocs.overwriteExisting","Opdater nuværende")]})]})]})}),e.jsx(ns,{open:Za,onOpenChange:xa,children:e.jsxs(rs,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"w-5 h-5"}),t("careerDocs.versionHistory","Versionshistorik")]}),e.jsx(Qs,{children:t("careerDocs.versionHistoryDescription","Tidligere gemte versioner af dit CV. Klik 'Gendan' for at gå tilbage til en version.")})]}),e.jsx("div",{className:"space-y-3 mt-2",children:oo?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ge,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):li.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:t("careerDocs.noVersions","Ingen gemte versioner endnu. Versioner oprettes automatisk når du gemmer dit CV.")}
278):li.map(u=>e.jsx(ye,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:u.version_label||_s(new Date(u.created_at),"d. MMMM yyyy, HH:mm",{locale:n})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_s(new Date(u.created_at),"d. MMM yyyy HH:mm",{locale:n})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[u.content.length," ",t("careerDocs.characters","tegn")]})]}),e.jsxs(h,{size:"sm",variant:"outline",disabled:ci===u.id,onClick:()=>So(u),className:"shrink-0 gap-1.5",children:[ci===u.id?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx($l,{className:"w-3.5 h-3.5"}),t("careerDocs.restore","Gendan")]})]})},u.id))})]})}),e.jsx(at,{open:he!==null,onOpenChange:u=>{u||we(null)},children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:t("careerDocs.regenerateConfirmTitle","Hvordan vil du opdatere dokumentet?")}),e.jsx(lt,{children:t("careerDocs.regenerateConfirmDescription","Du har lavet manuelle ændringer i dette dokument. Vælg hvordan Sammy skal opdatere det:")})]}),e.jsxs(ot,{className:"flex-col sm:flex-col sm:space-x-0 gap-2",children:[e.jsx(Ys,{className:"w-full",onClick:()=>{const u=he;we(null),u&&Bo(u.docType,u.title)},children:t("careerDocs.regenerateKeepEdits","Behold mine rettelser og opdater med AI")}),e.jsx(Ys,{className:"w-full bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{const u=he;we(null),u&&On(u.docType,u.title,u.targetLanguage,u.cvPages)},children:t("careerDocs.regenerateFromScratch","Lav nyt fra bunden")}),e.jsx(ct,{className:"w-full mt-0",children:t("careerDocs.regenerateConfirmCancel","Annullér")})]})]})})]})},Qu="/assets/pdf.worker-B1D2UnXD.mjs",vl=!1,Xu={komplet:{icon:xs,color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/30"},combined:{icon:Zc,color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/30"},big5_standard:{icon:ja,color:"text-muted-foreground",bgColor:"bg-muted/50",borderColor:"border-muted"},big5_100:{icon:ar,color:"text-amber-600",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/30"},big5_job:{icon:ht,color:"text-emerald-600",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-500/30"},cvf:{icon:kn,color:"text-pink-600",bgColor:"bg-pink-500/10",borderColor:"border-pink-500/30"},future:{icon:rr,color:"text-cyan-600",bgColor:"bg-cyan-500/10",borderColor:"border-cyan-500/30"},big5_work:{icon:ja,color:"text-muted-foreground",bgColor:"bg-muted/50",borderColor:"border-muted"},uploaded:{icon:Fs,color:"text-blue-600",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30"}},Zu={icon:ja,color:"text-primary",bgColor:"bg-primary/10",borderColor:"border-primary/30"},eh=({sourceUrl:s})=>{const{i18n:a}=Je(),t=Te(a.language),r=i.useRef(null),[n,d]=i.useState([]),[m,c]=i.useState(null),[l,f]=i.useState(null);return i.useEffect(()=>{let p=!1;return d([]),c(null),f(null),(async()=>{var j;try{const g=await ma(()=>import("./pdf-BBO_BrAh.js"),[]);g.GlobalWorkerOptions.workerSrc=Qu;const N=await g.getDocument(s).promise;if(p)return;c(N.numPages);const w=[],S=Math.max(320,Math.min(((j=r.current)==null?void 0:j.clientWidth)??760,920));for(let A=1;A<=N.numPages;A+=1){const y=await N.getPage(A);if(p)return;const D=y.getViewport({scale:1}),B=Math.min(2,S/D.width)*(window.devicePixelRatio>1?1.2:1),M=y.getViewport({scale:B}),Y=document.createElement("canvas"),R=Y.getContext("2d");if(!R)throw new Error("Canvas context unavailable");Y.width=Math.floor(M.width),Y.height=Math.floor(M.height),await y.render({canvas:Y,canvasContext:R,viewport:M}).promise,w.push({pageNumber:A,src:Y.toDataURL("image/png")}),p||d([...w])}N.destroy()}catch(g){console.error("PDF preview render error:",g),p||f(t?"PDF'en kunne ikke forhåndsvises her. Brug Åbn i ny fane eller Download.":"The PDF could not be previewed here. Use Open in new tab or Download.")}})(),()=>{p=!0}},[s,t]),e.jsxs("div",{ref:r,className:"rounded-md border bg-muted/20 p-3",children:[n.length===0&&!l&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-sm text-muted-foreground",children:[e.jsx(ge,{className:"w-5 h-5 animate-spin"}),t?"Indlæser original rapport…":"Loading original report…"]}),l&&e.jsx(ye,{className:"p-6 text-sm text-destructive",children:l}),e.jsx("div",{className:"space-y-4",children:n.map(p=>e.jsx("div",{className:"mx-auto max-w-full overflow-hidden rounded-sm bg-background shadow-sm",children:e.jsx("img",{src:p.src,alt:t?`Original analyse side ${p.pageNumber}`:`Original analysis page ${p.pageNumber}`,className:"h-auto w-full"})},p.pageNumber))}),m&&n.length<m&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-xs text-muted-foreground",children:[e.jsx(ge,{className:"w-4 h-4 animate-spin"}),t?`Indlæser side ${n.length+1} af ${m}…`:`Loading page ${n.length+1} of ${m}…`]})]})},sh=()=>{const{t:s}
278=Je();return e.jsx(ye,{className:"p-5 bg-gradient-to-r from-cyan-500/10 via-blue-500/10 to-purple-500/10 border-cyan-500/30",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-gradient-to-br from-cyan-500/30 to-blue-500/30 flex items-center justify-center shrink-0",children:e.jsx(rr,{className:"w-7 h-7 text-cyan-600"})}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h2",{className:"text-xl font-bold text-foreground",children:s("myAnalyses.futureHeader")}),e.jsx("p",{className:"text-muted-foreground text-sm",dangerouslySetInnerHTML:{__html:s("myAnalyses.futureDescription")}}),e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-3 mt-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(va,{className:"w-4 h-4 text-amber-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",dangerouslySetInnerHTML:{__html:s("myAnalyses.futureImportant")}}),e.jsx(Ul,{type:"single",collapsible:!0,className:"mt-2",children:e.jsxs(mn,{value:"ai-info",className:"border-none",children:[e.jsx(un,{className:"text-xs py-1 text-amber-700 dark:text-amber-400 hover:no-underline gap-1",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Va,{className:"h-3 w-3"}),s("myAnalyses.aboutAiAnalysis")]})}),e.jsx(hn,{className:"pt-1 pb-0",children:e.jsxs("div",{className:"space-y-2 text-xs text-amber-800 dark:text-amber-200",children:[e.jsx("p",{dangerouslySetInnerHTML:{__html:s("myAnalyses.aiGenerated")}}),e.jsxs("ul",{className:"space-y-1 ml-3",children:[e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-500 mt-0.5",children:"•"}),e.jsx("span",{dangerouslySetInnerHTML:{__html:s("myAnalyses.aiNotClinical")}})]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-500 mt-0.5",children:"•"}),e.jsx("span",{dangerouslySetInnerHTML:{__html:s("myAnalyses.aiHypotheses")}})]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-500 mt-0.5",children:"•"}),e.jsx("span",{dangerouslySetInnerHTML:{__html:s("myAnalyses.aiConsult")}})]})]}),e.jsx("div",{className:"p-2 bg-amber-100/50 dark:bg-amber-900/30 rounded border border-amber-200 dark:border-amber-800",children:e.jsxs("p",{className:"flex items-center gap-1.5",children:[e.jsx(ha,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:s("myAnalyses.aiSelfReflection")})]})})]})})]})})]})]})})]})]})})},th=({filePath:s})=>{const{i18n:a}=Je(),t=Te(a.language),[r,n]=i.useState(null),[d,m]=i.useState(!1),[c,l]=i.useState(null),f=!!s&&/\.pdf($|\?)/i.test(s);return i.useEffect(()=>{if(!s)return;let p=!1;return(async()=>{m(!0),l(null);try{const{supabase:j}=await ma(async()=>{const{supabase:N}=await import("./index-7TyBHU2Z.js").then(w=>
278w.cj);return{supabase:N}},__vite__mapDeps([1,2])),{data:g,error:P}=await j.storage.from("uploaded-analyses").createSignedUrl(s,60*30);if(p)return;if(P||!(g!=null&&g.signedUrl)){l(t?"Kunne ikke hente original fil.":"Could not fetch original file.");return}n(g.signedUrl)}catch{p||l(t?"Kunne ikke hente original fil.":"Could not fetch original file.")}finally{p||m(!1)}})(),()=>{p=!0}},[s,t]),s?d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):c||!r?e.jsx(ye,{className:"p-6 text-sm text-destructive",children:c}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Ht,{className:"w-4 h-4 mr-1"}),t?"Åbn i ny fane":"Open in new tab"]})}),e.jsx(h,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs("a",{href:r,download:!0,children:[e.jsx(Qt,{className:"w-4 h-4 mr-1"}),"Download"]})})]}),f?e.jsx(eh,{sourceUrl:r}):e.jsx(ye,{className:"p-6 text-sm text-muted-foreground",children:t?"Forhåndsvisning er ikke tilgængelig for Word-dokumenter. Brug Download eller Åbn i ny fane for at se den originale fil.":"Preview is not available for Word documents. Use Download or Open in new tab to view the original file."})]}):e.jsx(ye,{className:"p-6 text-sm text-muted-foreground",children:t?"Ingen original fil gemt for denne analyse (uploadet som indsat tekst).":"No original file stored for this analysis (uploaded as pasted text)."})},jl=({analysis:s})=>{const{i18n:a}=Je(),t=Te(a.language),r=s.big5_results??null,n=s.disc_results??null,d=(n==null?void 0:n.disc_profile)??null,m=n==null?void 0:n.mapping_confidence,c=!!s.source_file_path,[l,f]=i.useState(c?"original":"mapped"),p=e.jsxs("div",{className:"space-y-6",children:[e.jsx(ye,{className:"p-4 bg-blue-500/5 border-blue-500/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Fs,{className:"w-5 h-5 text-blue-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-foreground",children:[t?"AI-fortolkning af din uploadede rapport":"AI interpretation of your uploaded report",s.source_framework?` — ${s.source_framework}`:""]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t?"Bruges af CV, kandidatbrief, jobmatch m.m. Den originale rapport ændres ikke.":"Used by CV, candidate brief, job match, etc. Your original report is not modified."}),m&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t?"Mapping-sikkerhed:":"Mapping confidence:"," ",m,m==="approximate"&&e.jsx("span",{className:"ml-1",children:t?" — vejledende mapping fra et rammeværk uden direkte DISC/Big Five.":" — approximate mapping from a framework without direct DISC/Big Five."})]})]})]})}),r&&Object.keys(r).length>0&&e.jsxs(ye,{className:"p-4",children:[e.jsx("h4",{className:"font-semibold mb-3",children:"Big Five (1-5)"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 text-sm",children:Object.entries(r).map(([j,g])=>e.jsxs("div",{className:"flex justify-between border-b py-1",children:[e.jsx("span",{className:"capitalize text-muted-foreground",children:j}),e.jsx("span",{className:"font-mono",children:typeof g=="number"?g.toFixed(1):"—"})]},j))})]}),d&&e.jsxs(ye,{className:"p-4",children:[e.jsx("h4",{className:"font-semibold mb-2",children:"DISC"}),d.scores&&e.jsx("div",{className:"grid grid-cols-4 gap-2 text-sm mb-3",children:["D","I","S","C"].map(j=>{var g,P;return e.jsxs("div",{className:"text-center border rounded p-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:j}),e.jsx("div",{className:"font-mono",children:((P=(g=d.scores)==null?void 0:g[j])==null?void 0:P.toFixed(1))??"—"})]},j)})}),(d.dominant_style||d.secondary_style)&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Dominant",": ",e.jsx("strong",{children:d.dominant_style}),d.secondary_style?` · ${t?"Sekundær":"Secondary"}: ${d.secondary_style}`:""]}),d.style_description&&e.jsx("p",{className:"text-sm mt-2 whitespace-pre-line",children:d.style_description}),Array.isArray(d.communication_tips)&&d.communication_tips.length>0&&e.jsx("ul",{className:"text-sm mt-3 space-y-1 list-disc list-inside text-muted-foreground",children:d.communication_tips.map((j,g)=>e.jsx("li",{children:j},g))})]}),s.ai_analysis&&e.jsxs(ye,{className:"p-4",children:[e.jsx("h4",{className:"font-semibold mb-2",children:t?"Resumé":"Summary"}),e.jsx("p",{className:"text-sm whitespace-pre-line text-muted-foreground",children:s.ai_analysis})]})]});return e.jsxs(Gr,{value:l,onValueChange:j=>
278f(j),className:"w-full",children:[e.jsxs(qr,{className:"grid grid-cols-2 w-full max-w-md",children:[e.jsx(za,{value:"original",disabled:!c,children:t?"Original rapport":"Original report"}),e.jsx(za,{value:"mapped",children:t?"AI-fortolkning":"AI interpretation"})]}),e.jsx(Oa,{value:"original",className:"mt-4",children:e.jsx(th,{filePath:s.source_file_path??null})}),e.jsx(Oa,{value:"mapped",className:"mt-4",children:p})]})},ah=()=>{const{t:s,i18n:a}=Je(),t=$a(),{analyses:r,loading:n,deleteAnalysis:d,setPrimaryAnalysis:m,isLoggedIn:c,translateAnalysis:l,refetch:f}=Jr(),[p,j]=i.useState(null),[g,P]=i.useState(null);i.useState(!1);const N=i.useMemo(()=>a.cloneInstance({lng:"en",fallbackLng:"en"}),[a]),w=i.useMemo(()=>a.cloneInstance({lng:"da",fallbackLng:"da"}),[a]);i.useEffect(()=>{const M=()=>f();return window.addEventListener("personality-analyses-changed",M),()=>window.removeEventListener("personality-analyses-changed",M)},[f]);const S=M=>/\(English\)\s*$/i.test(M)?"en":/\(Dansk\)\s*$/i.test(M)?"da":null,A=(M,Y)=>{const R=S(M);return R==="en"?e.jsx(tl,{i18n:N,children:Y}):R==="da"?e.jsx(tl,{i18n:w,children:Y}):Y},y=async(M,Y)=>{P(M);try{await l(M,Y)}finally{P(null)}},D=r.find(M=>M.id===p),B=M=>{const Y=Xu[M]||Zu,R=s(`myAnalyses.typeLabels.${M}`,s("myAnalyses.typeLabels.default"));return{...Y,label:R}};return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-semibold text-foreground flex items-center gap-2",children:[e.jsx(ja,{className:"w-5 h-5 text-primary"}),s("myAnalyses.title")]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("myAnalyses.subtitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3 whitespace-pre-line max-w-3xl",children:s("myAnalyses.subtitleInfo")})]})}),e.jsxs(ye,{className:"p-5 space-y-4",children:[e.jsxs("h3",{className:"font-semibold text-foreground flex items-center gap-2",children:[e.jsx(fs,{className:"w-4 h-4 text-primary"}),s("myAnalyses.takeNew")]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(h,{variant:"outline",className:"h-auto p-4 flex flex-col items-start gap-2 text-left whitespace-normal break-words overflow-hidden",onClick:()=>t("/komplet-personanalyse"),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(xs,{className:"w-5 h-5 text-purple-600 shrink-0"}),e.jsx("span",{className:"font-semibold text-sm",children:s("myAnalyses.kompletLabel")})]}),e.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:s("myAnalyses.kompletDesc")})]}),e.jsxs(h,{variant:"outline",className:"h-auto p-4 flex flex-col items-start gap-2 text-left whitespace-normal break-words overflow-hidden",onClick:()=>t("/personanalyse-auto"),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(rr,{className:"w-5 h-5 text-cyan-600 shrink-0"}),e.jsx("span",{className:"font-semibold text-sm",children:s("myAnalyses.futureLabel")})]}),e.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:s("myAnalyses.futureDesc")})]}),vl]})]}),vl,r.length===0?e.jsxs(ye,{className:"p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-muted rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(ja,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-foreground mb-2",children:s("myAnalyses.noSaved")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 max-w-md mx-auto",children:s("myAnalyses.noSavedDesc")})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:s("myAnalyses.completedAnalyses")}),r.length>1&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("myAnalyses.completedAnalysesHint")})]}),r.map(M=>{const Y=B(M.analysis_type),R=Y.icon;return e.jsx(ye,{className:`p-5 ${Y.bgColor} ${Y.borderColor} ${M.is_primary?"ring-2 ring-amber-500/50 shadow-lg shadow-amber-500/10":""}`,children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`w-12 h-12 rounded-full ${Y.bgColor} flex items-center justify-center shrink-0`,children:e.jsx(R,{className:`w-6 h-6 ${Y.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:M.title}),M.is_primary&&e.jsxs(je,{className:"gap-1 text-xs bg-amber-500/20 text-amber-600 border-amber-500/40 font-semibold",children:[e.jsx(Ps,{className:"w-3 h-3 fill-amber-500"}),s("myAnalyses.primaryAnalysis")]}),e.jsx(je,{variant:"secondary",className:"text-xs",children:Y.label})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ba,{className:"w-4 h-4"}),new Date(M.created_at).toLocaleDateString(Te(a.language)?"da-DK":"en-US",{day:"numeric",month:"short",year:"numeric"})]}),M.job_function&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ht,{className:"w-4 h-4"}),M.job_function]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[!M.is_primary&&e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>m(M.id),className:"gap-1 text-xs",children:[e.jsx(Ps,{className:"w-3 h-3"}),s("myAnalyses.makePrimary")]}),e.jsxs(ns,{children:[e.jsx(Na,{asChild:!0,children:e.jsxs(h,{size:"sm",variant:"outline",className:"gap-1 text-xs",onClick:()=>j(M.id),children:[e.jsx(Ht,{className:"w-3 h-3"}),s("myAnalyses.view")]})}),e.jsxs(rs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsx(is,{children:M.title})}),D&&D.id===M.id&&e.jsx("div",{className:"mt-4",children:A(D.title,D.analysis_type==="uploaded"?e.jsx(jl,{analysis:D}):D.analysis_type==="future"?e.jsxs("div",{className:"space-y-6",children:[e.jsx(sh,{}),e.jsx(Xi,{data:D.big5_results,onReset:()=>j(null),showContinueButton:!1})]}
278):D.analysis_type==="komplet"?(()=>{const Q=D.big5_results;return e.jsx(Qi,{big5Scores:Q.traits||{},competencyScores:Q.competencies||{},cultureScores:Q.culture||{},discProfileOverride:D.disc_results,jobFunction:D.job_function||"",positionLevel:D.position_level||"",onReset:()=>j(null),showContinueButton:!1,isSaving:!1,isSaved:!0,onBack:()=>j(null)})})():D.analysis_type==="big5_job"?e.jsx(Yi,{results:D.big5_results,jobFunction:D.job_function||"",positionLevel:D.position_level||"",discProfileOverride:D.disc_results,onReset:()=>j(null),savedAnalysis:D.ai_analysis||void 0,showContinueButton:!1,onBack:()=>j(null)}):e.jsx(Ji,{results:D.big5_results,onReset:()=>j(null),showContinueButton:!1,onBack:()=>j(null)}))})]})]}),e.jsxs(ns,{children:[e.jsx(Na,{asChild:!0,children:e.jsxs(h,{size:"sm",variant:"outline",className:"gap-1 text-xs",children:[e.jsx(Qt,{className:"w-3 h-3"}),s("myAnalyses.downloadPdf")]})}),e.jsxs(rs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsxs(is,{children:[M.title," - ",s("myAnalyses.downloadPdf")]})}),e.jsx("div",{className:"mt-4",children:A(M.title,M.analysis_type==="uploaded"?e.jsx(jl,{analysis:M}):M.analysis_type==="future"?e.jsx(Xi,{data:M.big5_results,onReset:()=>{},showContinueButton:!1}):M.analysis_type==="komplet"?(()=>{const Q=M.big5_results;return e.jsx(Qi,{big5Scores:Q.traits||{},competencyScores:Q.competencies||{},cultureScores:Q.culture||{},discProfileOverride:M.disc_results,jobFunction:M.job_function||"",positionLevel:M.position_level||"",onReset:()=>{},showContinueButton:!1,isSaving:!1,isSaved:!0})})():M.analysis_type==="big5_job"?e.jsx(Yi,{results:M.big5_results,jobFunction:M.job_function||"",positionLevel:M.position_level||"",discProfileOverride:M.disc_results,onReset:()=>{},savedAnalysis:M.ai_analysis||void 0,showContinueButton:!1}):e.jsx(Ji,{results:M.big5_results,onReset:()=>{},showContinueButton:!1}))})]})]}),(()=>{const k=/\(English\)\s*$/i.test(M.title)?"da":"en",$=s(k==="en"?"myAnalyses.translateToEnglish":"myAnalyses.translateToDanish"),K=g===M.id;return e.jsx(h,{size:"sm",variant:"outline",className:"gap-1 text-xs",disabled:K,onClick:()=>y(M.id,k),children:K?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-3 h-3 animate-spin"}),s("myAnalyses.translating")]}):e.jsxs(e.Fragment,{children:[e.jsx(vn,{className:"w-3 h-3"}),$]})})})(),e.jsxs(at,{children:[e.jsx(Ea,{asChild:!0,children:e.jsxs(h,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-destructive hover:text-destructive hover:bg-destructive/10",children:[e.jsx(Ss,{className:"w-3 h-3"}),s("myAnalyses.delete")]})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:s("myAnalyses.deleteTitle")}),e.jsx(lt,{children:s("myAnalyses.deleteDescription")})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:s("myAnalyses.cancel")}),e.jsx(Ys,{onClick:()=>d(M.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:s("myAnalyses.delete")})]})]})]})]})]})]})},M.id)})]}),!c&&e.jsx(ye,{className:"p-4 bg-amber-500/10 border-amber-500/30",children:e.jsxs("p",{className:"text-sm text-amber-700",children:[e.jsx("strong",{children:"Tip:"})," ",s("myAnalyses.loginTip")]})})]})},nh=({slotAfterSection:s,slotAfterLinkedIn:a,hideLinkedIn:t}={})=>{$a();const{toast:r}=Ct(),{t:n,i18n:d}=Je(),[m,c]=i.useState(null),[l,f]=i.useState({}),[p,j]=i.useState(""),[g,P]=i.useState(!1),[N,w]=i.useState(null),[S,A]=i.useState(!1),[y,D]=i.useState({fastLoen:"",harProvision:"",provisionType:"",provisionNiveau:"",harAarsbonus:"",aarsbonusNiveau:"",pensionVirksomhed:"",pensionEgen:"",harBilordning:""}),[B,M]=i.useState([]),[Y,R]=i.useState(!0),[Q,k]=i.useState(!1),[$,K]=i.useState(null);i.useState(!1);const[re,ve]=i.useState(!1),[ze,xe]=i.useState(!1),[I,E]=i.useState(""),[F,O]=i.useState(!1),[ee,Le]=i.useState(!1),pe=i.useRef(null),[Oe,he]=i.useState(!1),[we,T]=i.useState(!1),[ae,me]=i.useState(!1);i.useEffect(()=>{(async()=>{const{data:{user:X}}=await C.auth.getUser();if(!X)return;const{data:L}=await C.from("profiles").select("linkedin_url, education, education_institution, languages, working_hours, flexibility, preferred_geography, preferred_position_level, preferred_job_function, preferred_industries, it_skills, cv_type, use_salary_matching, share_salary_applications, share_salary_recruiters, notice_period, has_clauses, fast_loen, har_provision, provision_type, provision_niveau, har_aarsbonus, aarsbonus_niveau, pension_virksomhed, pension_egen, har_bilordning").eq("id",X.id).maybeSingle();
278L!=null&&L.linkedin_url&&K(L.linkedin_url),_(ce=>({...ce,uddannelse:(L==null?void 0:L.education)||ce.uddannelse,uddannelsessted:(L==null?void 0:L.education_institution)||ce.uddannelsessted,sprog:L!=null&&L.languages&&L.languages.length>0?L.languages:ce.sprog,arbejdstid:L!=null&&L.working_hours&&L.working_hours.length>0?L.working_hours:ce.arbejdstid,fleksibilitet:L!=null&&L.flexibility&&L.flexibility.length>0?L.flexibility:ce.fleksibilitet,geografi:L!=null&&L.preferred_geography&&L.preferred_geography.length>0?L.preferred_geography:ce.geografi,funktion:L!=null&&L.preferred_job_function&&L.preferred_job_function.length>0?L.preferred_job_function:ce.funktion,brancher:L!=null&&L.preferred_industries&&L.preferred_industries.length>0?L.preferred_industries:ce.brancher,niveau:L!=null&&L.preferred_position_level&&L.preferred_position_level.length>0?L.preferred_position_level.join(", "):ce.niveau,itFaerdigheder:L!=null&&L.it_skills&&L.it_skills.length>0?L.it_skills:ce.itFaerdigheder,cvType:(L==null?void 0:L.cv_type)||ce.cvType,opsigelse:(L==null?void 0:L.notice_period)||ce.opsigelse,klausuler:(L==null?void 0:L.has_clauses)||ce.klausuler,fastLoen:(L==null?void 0:L.fast_loen)||ce.fastLoen,harProvision:(L==null?void 0:L.har_provision)||ce.harProvision,provisionType:(L==null?void 0:L.provision_type)||ce.provisionType,provisionNiveau:(L==null?void 0:L.provision_niveau)||ce.provisionNiveau,harAarsbonus:(L==null?void 0:L.har_aarsbonus)||ce.harAarsbonus,aarsbonusNiveau:(L==null?void 0:L.aarsbonus_niveau)||ce.aarsbonusNiveau,pensionVirksomhed:(L==null?void 0:L.pension_virksomhed)||ce.pensionVirksomhed,pensionEgen:(L==null?void 0:L.pension_egen)||ce.pensionEgen,harBilordning:(L==null?void 0:L.har_bilordning)||ce.harBilordning})),he((L==null?void 0:L.use_salary_matching)??!1),T((L==null?void 0:L.share_salary_applications)??!1),me((L==null?void 0:L.share_salary_recruiters)??!1)})()},[]);const Ae=i.useCallback(async()=>{const{data:{user:le}}=await C.auth.getUser();if(!le){R(!1);return}const{data:X,error:L}=await C.from("educations").select("*").eq("user_id",le.id).order("display_order",{ascending:!0});!L&&X&&M(X.map(ce=>({id:ce.id,degree:ce.degree,institution:ce.institution||"",field_of_study:ce.field_of_study||"",start_year:ce.start_year,end_year:ce.end_year,is_current:ce.is_current||!1}))),R(!1)},[]);i.useEffect(()=>{Ae()},[Ae]);const oe=()=>{M(le=>[...le,{degree:"",institution:"",field_of_study:"",start_year:null,end_year:null,is_current:!1}])},Ve=(le,X,L)=>{M(ce=>ce.map((ys,Hs)=>Hs===le?{...ys,[X]:L}:ys))},Xe=async le=>{const X=B[le];if(X.id){const{error:L}=await C.from("educations").delete().eq("id",X.id);if(L){r({title:n("myChoices.error"),variant:"destructive"});return}}M(L=>L.filter((ce,ys)=>ys!==le)),qt()},cs=async()=>{const{data:{user:le}}=await C.auth.getUser();if(le){k(!0);try{for(const X of B){if(!X.degree.trim())continue;const L={user_id:le.id,degree:X.degree,institution:X.institution||null,field_of_study:X.field_of_study||null,start_year:X.start_year,end_year:X.end_year,is_current:X.is_current};if(X.id)await C.from("educations").update(L).eq("id",X.id);else{const{data:ce}=await C.from("educations").insert(L).select().single();ce&&(X.id=ce.id)}}qt(),r({title:n("myChoices.saved"),description:n("myChoices.savedDesc")})}catch{r({title:n("myChoices.error"),variant:"destructive"})}k(!1)}},hs=async le=>{var Hs;const X=(Hs=le.target.files)==null?void 0:Hs[0];if(!X)return;if(X.type!=="application/pdf"){r({title:n("myChoices.error"),description:n("myChoices.uploadPdfFile"),variant:"destructive"});return}const{validateUploadFile:L,extractProfileFromFile:ce}=await ma(async()=>{const{validateUploadFile:Os,extractProfileFromFile:Ls}=await import("./extractProfile-Bhj0bfp7.js");return{validateUploadFile:Os,extractProfileFromFile:Ls}},__vite__mapDeps([3,1,2,4])),ys=L(X);if(!ys.ok){r({title:n("myChoices.error"),description:ys.error||n("myChoices.maxFileSize"),variant:"destructive"});return}Le(!0);try{const{data:{user:Os}}=await C.auth.getUser();if(!Os){r({title:n("myChoices.notLoggedIn"),description:n("myChoices.mustBeLoggedIn"),variant:"destructive"});return}r({title:n("myChoices.analyzingLinkedInPdf")});const Ls=await ce({file:X,language:d.language,context:"profile"});
278if(!Ls.ok){console.error("LinkedIn PDF analysis failed:",Ls.error),r({title:n("myChoices.error"),description:Ls.error||n("myChoices.couldNotAnalyzePdf"),variant:"destructive"});return}if(Ls.data){const Bs=Ls.data.full_name,ie=Bs?`LinkedIn PDF: ${Bs}`:"LinkedIn PDF";K(ie),await C.from("profiles").update({linkedin_url:ie}).eq("id",Os.id),ve(!1),r({title:n("myChoices.linkedInPdfImported"),description:n("myChoices.linkedInPdfImportedDesc",{count:Ls.workExperiencesSaved||0})})}else r({title:n("myChoices.error"),description:n("myChoices.couldNotExtractPdf"),variant:"destructive"})}catch(Os){console.error("Error uploading LinkedIn PDF:",Os),r({title:n("myChoices.error"),description:n("myChoices.errorOccurred"),variant:"destructive"})}finally{Le(!1),pe.current&&(pe.current.value="")}},ps=async()=>{if(!I.trim()||I.trim().length<50){r({title:n("myChoices.error"),description:n("myChoices.minChars"),variant:"destructive"});return}O(!0);try{const{data:{user:le}}=await C.auth.getUser();if(!le){r({title:n("myChoices.notLoggedIn"),variant:"destructive"});return}const{data:X,error:L}=await C.functions.invoke("extract-profile-data",{body:{language:d.language,cvContent:I,userId:le.id}});if(L)console.error("Error extracting LinkedIn text data:",L),r({title:n("myChoices.error"),description:n("myChoices.couldNotAnalyzeText"),variant:"destructive"});else if(X!=null&&X.data){const ce=X.data.full_name?`LinkedIn: ${X.data.full_name}`:n("myChoices.linkedInPastedText");K(ce);const{data:{user:ys}}=await C.auth.getUser();ys&&await C.from("profiles").update({linkedin_url:ce}).eq("id",ys.id),xe(!1),E(""),r({title:n("myChoices.linkedInTextImported"),description:n("myChoices.linkedInTextImportedDesc",{count:X.workExperiencesSaved||0})})}}catch(le){console.error("Error processing LinkedIn text:",le),r({title:n("myChoices.error"),description:n("myChoices.errorOccurred"),variant:"destructive"})}finally{O(!1)}},ms=async()=>{try{const{data:{user:le}}=await C.auth.getUser();if(!le)return;await C.from("profiles").update({linkedin_url:null}).eq("id",le.id),K(null),r({title:n("myChoices.linkedInRemoved"),description:n("myChoices.linkedInRemovedDesc")})}catch(le){console.error("Error removing LinkedIn:",le),r({title:n("myChoices.error"),description:n("myChoices.couldNotRemoveLinkedIn"),variant:"destructive"})}},[De,_]=i.useState({uddannelse:"Cand.merc. i Marketing",uddannelsessted:"Handelshøjskolen",arbejdstid:["Fuldtid"],fleksibilitet:["Hybrid"],geografi:["København","Sjælland","Remote"],funktion:["Opsøgende salg","Account Management","Business Development"],niveau:"Senior",brancher:["Tech","SaaS","Fintech","E-commerce"],sprog:["Dansk (modersmål)","Engelsk (flydende)","Tysk (basis)"],itFaerdigheder:["Salesforce","HubSpot","Microsoft Office","Google Analytics"],cvType:"Kronologisk CV",loenforventning:"600.000 - 800.000 DKK",opsigelse:"",klausuler:"",fastLoen:"",harProvision:"",provisionType:"",provisionNiveau:"",harAarsbonus:"",aarsbonusNiveau:"",pensionVirksomhed:"",pensionEgen:"",harBilordning:""}),{geografiOptions:Z,niveauOptions:H,funktionOptions:ne,brancheOptions:x,arbejdstidOptions:z,fleksibilitetOptions:b,sprogOptions:U,itFaerdighederOptions:te}=Ol(),fe=async(le,X,L)=>{_(ce=>({...ce,[le]:L}));try{const{data:{user:ce}}=await C.auth.getUser();if(!ce)return;await C.from("profiles").update({[X]:L.length>0?L:null}).eq("id",ce.id)}catch(ce){console.error("Save error:",ce)}},Se=[{id:"personlig",title:n("myChoices.education"),icon:Al,isEducation:!0}
278,{id:"arbejde",title:n("myChoices.workPreferences"),icon:ht,isCombobox:!0},{id:"geografi",title:n("myChoices.geography"),icon:ia,isCombobox:!0},{id:"funktion",title:n("profil.preferences.jobFunction"),icon:ht,isCombobox:!0},{id:"brancher",title:n("profil.preferences.industries"),icon:ut,isCombobox:!0},{id:"sprog",title:n("myChoices.languages"),icon:vn,isCombobox:!0},{id:"it",title:n("myChoices.itSkills"),icon:ed,isCombobox:!0},{id:"klausuler",title:n("myChoices.clausesAndNotice"),icon:ba,isClausesSection:!0},{id:"loendata",title:n("myChoices.salaryData"),icon:sd,isSalaryPreferences:!0,salaryFields:[{key:"fastLoen",label:n("myChoices.baseSalary"),value:De.fastLoen||n("myChoices.notSpecified")},{key:"harProvision",label:n("myChoices.commission"),value:De.harProvision==="ja"?`${n("myChoices.yes")} (${De.provisionType==="maanedlig"?n("myChoices.monthly"):De.provisionType==="kvartal"?n("myChoices.quarterly"):""}, ${De.provisionNiveau||""})`:De.harProvision==="nej"?n("myChoices.no"):n("myChoices.notSpecified")},{key:"harAarsbonus",label:n("myChoices.annualBonus"),value:De.harAarsbonus==="ja"?`${n("myChoices.yes")} (${De.aarsbonusNiveau||""})`:De.harAarsbonus==="nej"?n("myChoices.no"):n("myChoices.notSpecified")},{key:"pension",label:n("myChoices.pension"),value:De.pensionVirksomhed||De.pensionEgen?`${n("myChoices.companyPension")}: ${De.pensionVirksomhed||"-"}, ${n("myChoices.ownContribution")}: ${De.pensionEgen||"-"}`:n("myChoices.notSpecified")},{key:"harBilordning",label:n("myChoices.carAllowance"),value:De.harBilordning==="ja"?n("myChoices.yes"):De.harBilordning==="nej"?n("myChoices.no"):n("myChoices.notSpecified")}]}],G=le=>{const X=Se.find(L=>L.id===le);if("fields"in X&&Array.isArray(X.fields)){const L={};X.fields.forEach(ce=>{L[ce.key]=ce.value}),f(L)}c(le)},Fe=(le,X)=>{f(L=>({...L,[le]:X}))},Ee=async()=>{const le={...De,...l};_(le),f({}),c(null);try{const{data:{user:X}}=await C.auth.getUser();if(!X)return;const{error:L}=await C.from("profiles").update({education:le.uddannelse||null,education_institution:le.uddannelsessted||null,working_hours:le.arbejdstid.length>0?le.arbejdstid:null,flexibility:le.fleksibilitet.length>0?le.fleksibilitet:null,cv_type:le.cvType||null,notice_period:le.opsigelse||null,has_clauses:le.klausuler||null}).eq("id",X.id);if(L)throw L;qt(),r({title:n("myChoices.saved"),description:n("myChoices.savedDesc")})}catch(X){console.error("Error saving profile:",X),r({title:n("myChoices.error"),description:n("myChoices.couldNotSave"),variant:"destructive"})}},qe=()=>{f({}),c(null)},Ge=async()=>{if(!p.trim()||!N)return;const X={geografi:"geografi",funktion:"funktion",brancher:"brancher",sprog:"sprog",it:"itFaerdigheder"}[N];if(X){const L=[...De[X],p.trim()];_(ce=>({...ce,[X]:L}));try{const{data:{user:ce}}=await C.auth.getUser();if(ce){const Hs={geografi:"preferred_geography",funktion:"preferred_job_function",brancher:"preferred_industries",sprog:"languages",it:"it_skills"}[N];Hs&&(await C.from("profiles").update({[Hs]:L}).eq("id",ce.id),qt())}}catch(ce){console.error("Error adding tag:",ce)}}P(!1),j(""),w(null),r({title:n("myChoices.added"),description:n("myChoices.tagAdded",{tag:p.trim()})})},He=async(le,X)=>{le==="use_salary_matching"&&he(X),le==="share_salary_applications"&&T(X),le==="share_salary_recruiters"&&me(X);try{const{data:{user:L}}=await C.auth.getUser();if(!L)return;const{error:ce}=await C.from("profiles").update({[le]:X}).eq("id",L.id);if(ce)throw ce;qt(),r({title:n("myChoices.saved"),description:n("myChoices.preferenceSaved")})}catch(L){console.error("Error updating salary preference:",L),r({title:n("myChoices.error"),description:n("myChoices.couldNotSavePreference"),variant:"destructive"})}},Ze=()=>{D({fastLoen:De.fastLoen||"",harProvision:De.harProvision||"",provisionType:De.provisionType||"",provisionNiveau:De.provisionNiveau||"",harAarsbonus:De.harAarsbonus||"",aarsbonusNiveau:De.aarsbonusNiveau||"",pensionVirksomhed:De.pensionVirksomhed||"",pensionEgen:De.pensionEgen||"",harBilordning:De.harBilordning||""}),A(!0)},Us=async()=>{try{const{data:{user:le}}=await C.auth.getUser();if(!le)return;const{error:X}=await C.from("profiles").update({fast_loen:y.fastLoen||null,har_provision:y.harProvision||null,provision_type:y.provisionType||null,provision_niveau:y.provisionNiveau||null,har_aarsbonus:y.harAarsbonus||null,aarsbonus_niveau:y.aarsbonusNiveau||null,pension_virksomhed:y.pensionVirksomhed||null,pension_egen:y.pensionEgen||null,har_bilordning:y.harBilordning||null}).eq("id",le.id);if(X)throw X;_(L=>({...L,...y})),A(!1),qt(),r({title:n("myChoices.saved"),description:n("myChoices.salaryDataSaved")})}catch(le){console.error("Error saving salary data:",le),r({title:n("myChoices.error"),description:n("myChoices.couldNotSaveSalary"),variant:"destructive"})}};return i.useEffect(()=>{if(!m||Object.keys(l).length===0)return;const le=setTimeout(async()=>{try{const{data:{user:X}}=await C.auth.getUser();if(!X)return;const L={...De,...l};await C.from("profiles").update({education:L.uddannelse||null,education_institution:L.uddannelsessted||null,working_hours:L.arbejdstid.length>0?L.arbejdstid:null,flexibility:L.fleksibilitet.length>0?L.fleksibilitet:null,cv_type:L.cvType||null,notice_period:L.opsigelse||null,has_clauses:L.klausuler||null}).eq("id",X.id),qt()}catch(X){console.error("Auto-save (editedFields) failed:",X)}},800);return()=>clearTimeout(le)},[l,m]),i.useEffect(()=>{if(!S)return;const le=setTimeout(async()=>{try{const{data:{user:X}}=await C.auth.getUser();if(!X)return;await C.from("profiles").update({fast_loen:y.fastLoen||null,har_provision:y.harProvision||null,provision_type:y.provisionType||null,provision_niveau:y.provisionNiveau||null,har_aarsbonus:y.harAarsbonus||null,aarsbonus_niveau:y.aarsbonusNiveau||null,pension_virksomhed:y.pensionVirksomhed||null,pension_egen:y.pensionEgen||null,har_bilordning:y.harBilordning||null}).eq("id",X.id),_(L=>({...L,...y})),qt()}catch(X){console.error("Auto-save (salary) failed:",X)}},800);return()=>clearTimeout(le)},[y,S]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:n("myChoices.title")}),e.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:n("myChoices.description")})]}),!t&&e.jsxs(ye,{className:"p-6",children:[e.jsxs("h3",{className:"font-semibold text-foreground text-lg mb-4 flex items-center gap-2",children:[e.jsx(Ms,{className:"w-5 h-5 text-[#0077B5]"}),"LinkedIn"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(se,{className:"text-sm font-medium",children:n("myChoices.linkedInProfile")}),$?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Ms,{className:"w-5 h-5 text-[#0077B5]"}),e.jsx("span",{className:"text-sm font-medium flex-1 truncate",children:n("myChoices.linkedInImported")}),e.jsx("div",{className:"flex gap-2",children:e.jsx(h,{size:"sm",variant:"ghost",onClick:ms,className:"text-destructive hover:text-destructive",children:e.jsx(Ss,{className:"w-4 h-4"})})})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(Cl,{children:[e.jsx(_l,{asChild:!0,children:e.jsxs(h,{className:"flex-1 bg-[#0077B5] hover:bg-[#0077B5]/90 text-white",children:[e.jsx(Ms,{className:"mr-2 h-4 w-4"}),n("myChoices.importLinkedIn"),e.jsx(Ts,{className:"ml-2 h-4 w-4"})]})}),e.jsxs(Sl,{align:"start",className:"w-64 bg-popover z-50",children:[e.jsxs(Jn,{onClick:()=>ve(!0),children:[e.jsx(Ja,{className:"mr-2 h-4 w-4"}),n("myChoices.pdfFromLinkedIn")]}),e.jsxs(Jn,{onClick:()=>xe(!0),children:[e.jsx(Zn,{className:"mr-2 h-4 w-4"}),n("myChoices.pasteText")]})]})]}),e.jsx(Ya,{children:e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(ha,{className:"h-4 w-4 text-muted-foreground shrink-0 cursor-help"})}),e.jsx(Js,{side:"top",className:"max-w-[220px] text-xs",children:n("myChoices.linkedInTooltip")})]})})]})]})]}),a,!t&&e.jsx(ns,{open:re,onOpenChange:ve,children:e.jsxs(rs,{className:"sm:max-w-md",children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-5 w-5 text-[#0077B5]"}),n("myChoices.importLinkedInTitle")]}),e.jsx(Qs,{children:n("myChoices.importLinkedInDesc")})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-3",children:[e.jsx("p",{className:"text-sm font-medium",children:n("myChoices.howToExport")}),e.jsxs("ol",{className:"text-xs text-muted-foreground space-y-1 list-decimal pl-4",children:[e.jsx("li",{children:n("myChoices.exportStep1")}),e.jsx("li",{children:n("myChoices.exportStep2")}),e.jsx("li",{children:n("myChoices.exportStep3")}),e.jsx("li",{children:n("myChoices.exportStep4")})]})]}
278),e.jsx("input",{type:"file",ref:pe,onChange:hs,accept:".pdf",className:"hidden"}),e.jsx(h,{onClick:()=>{var le;return(le=pe.current)==null?void 0:le.click()},disabled:ee,className:"w-full bg-[#0077B5] hover:bg-[#0077B5]/90",children:ee?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"mr-2 h-4 w-4 animate-spin"}),n("myChoices.analyzingPdf")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ja,{className:"mr-2 h-4 w-4"}),n("myChoices.uploadLinkedInPdf")]})})]})]})}),!t&&e.jsx(ns,{open:ze,onOpenChange:xe,children:e.jsxs(rs,{className:"sm:max-w-lg",children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(Zn,{className:"h-5 w-5 text-[#0077B5]"}),n("myChoices.pasteLinkedInTitle")]}),e.jsx(Qs,{children:n("myChoices.pasteLinkedInDesc")})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:n("myChoices.howToCopy")}),e.jsxs("ol",{className:"text-xs text-muted-foreground space-y-1 list-decimal pl-4",children:[e.jsx("li",{children:n("myChoices.copyStep1")}),e.jsx("li",{children:n("myChoices.copyStep2")}),e.jsx("li",{children:n("myChoices.copyStep3")}),e.jsx("li",{children:n("myChoices.copyStep4")})]})]}),e.jsx(as,{placeholder:n("myChoices.pasteLinkedInPlaceholder"),value:I,onChange:le=>E(le.target.value),rows:10,className:"resize-none"}),e.jsx(h,{onClick:ps,disabled:F||!I.trim(),className:"w-full bg-[#0077B5] hover:bg-[#0077B5]/90",children:F?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"mr-2 h-4 w-4 animate-spin"}),n("myChoices.analyzingText")]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{className:"mr-2 h-4 w-4"}),n("myChoices.analyzeAndFill")]})})]})]})}),e.jsx("div",{className:"grid gap-4",children:Se.map(le=>e.jsxs(Zo.Fragment,{children:[e.jsxs(ye,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-primary/10",children:e.jsx(le.icon,{className:"w-5 h-5 text-primary"})}),e.jsx("h3",{className:"font-semibold text-foreground text-lg",children:le.title})]}),!le.isSalaryPreferences&&!("isEducation"in le&&le.isEducation)&&!("isCombobox"in le&&le.isCombobox)&&!("isClausesSection"in le&&le.isClausesSection)&&(m===le.id?e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{size:"sm",variant:"outline",onClick:qe,className:"gap-1",children:[e.jsx(mt,{className:"w-4 h-4"}),n("myChoices.cancel")]}),e.jsxs(h,{size:"sm",onClick:Ee,className:"gap-1",children:[e.jsx(zs,{className:"w-4 h-4"}),n("myChoices.save")]})]}):e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>G(le.id),className:"gap-1",children:[e.jsx(Qa,{className:"w-4 h-4"}),n("myChoices.edit")]}))]}),"isEducation"in le&&le.isEducation&&e.jsx("div",{className:"space-y-4",children:Y?e.jsxs("div",{className:"flex items-center justify-center py-4 text-muted-foreground text-sm",children:[e.jsx(ge,{className:"w-4 h-4 animate-spin mr-2"})," ",n("profileEducation.loading","Henter uddannelser...")]}):B.length===0?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:n("profileEducation.noEducations","Ingen uddannelser tilføjet endnu")}),e.jsxs(h,{variant:"outline",size:"sm",onClick:oe,children:[e.jsx(fs,{className:"w-3 h-3 mr-1"})," ",n("profileEducation.add","Tilføj uddannelse")]})]}):e.jsxs("div",{className:"space-y-3",children:[B.map((X,L)=>e.jsx("div",{className:"border border-border/50 rounded-md p-3 space-y-3 bg-muted/30",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 flex-1",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:n("profileEducation.degreeTitle","Grad / titel")}),e.jsx(ue,{value:X.degree,onChange:ce=>Ve(L,"degree",ce.target.value),placeholder:n("profileEducation.degreePlaceholder","F.eks. Cand.merc."),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:n("profileEducation.institutionLabel","Uddannelsessted")}),e.jsx(ue,{value:X.institution,onChange:ce=>Ve(L,"institution",ce.target.value),placeholder:n("profileEducation.institutionPlaceholder","F.eks. CBS"),
278className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-xs",children:n("profileEducation.fieldOfStudy","Fagretning")}),e.jsx(ue,{value:X.field_of_study,onChange:ce=>Ve(L,"field_of_study",ce.target.value),placeholder:n("profileEducation.fieldPlaceholder","F.eks. Marketing"),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(se,{className:"text-xs",children:n("profileEducation.from","Fra")}),e.jsx(ue,{type:"number",value:X.start_year??"",onChange:ce=>Ve(L,"start_year",ce.target.value?parseInt(ce.target.value):null),placeholder:"2010",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(se,{className:"text-xs",children:n("profileEducation.to","Til")}),e.jsx(ue,{type:"number",value:X.end_year??"",onChange:ce=>Ve(L,"end_year",ce.target.value?parseInt(ce.target.value):null),placeholder:"2012",className:"h-8 text-sm",disabled:X.is_current})]})]})]}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive/70 hover:text-destructive ml-2 shrink-0",onClick:()=>Xe(L),children:e.jsx(Ss,{className:"w-3.5 h-3.5"})})]})},X.id||`new-${L}`)),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:oe,children:[e.jsx(fs,{className:"w-3 h-3 mr-1"})," ",n("profileEducation.add","Tilføj")]}),e.jsx(h,{size:"sm",onClick:cs,disabled:Q,children:Q?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-3 h-3 animate-spin mr-1"})," ",n("myChoices.saving","Gemmer...")]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{className:"w-3 h-3 mr-1"})," ",n("profileEducation.saveEducations","Gem uddannelser")]})})]})]})}),le.isSalaryPreferences&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3 pb-4 border-b border-border",children:[e.jsx("p",{className:"text-sm font-medium text-foreground mb-2",children:n("myChoices.yourSalaryData")}),S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"fastLoen",className:"text-sm",children:n("myChoices.baseSalary")}),e.jsx(ue,{id:"fastLoen",value:y.fastLoen,onChange:X=>D(L=>({...L,fastLoen:X.target.value})),placeholder:n("myChoices.salaryPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"harProvision",className:"text-sm",children:n("myChoices.commission")}),e.jsxs("select",{id:"harProvision",value:y.harProvision,onChange:X=>D(L=>({...L,harProvision:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.choose")}),e.jsx("option",{value:"ja",children:n("myChoices.yes")}),e.jsx("option",{value:"nej",children:n("myChoices.no")})]})]}),y.harProvision==="ja"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"provisionType",className:"text-sm",children:n("myChoices.payout")}),e.jsxs("select",{id:"provisionType",value:y.provisionType,onChange:X=>D(L=>({...L,provisionType:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.choose")}),e.jsx("option",{value:"maanedlig",children:n("myChoices.monthly")}),e.jsx("option",{value:"kvartal",children:n("myChoices.quarterly")})]})]}),e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(se,{htmlFor:"provisionNiveau",className:"text-sm",children:n("myChoices.commissionLevel")}),e.jsxs("select",{id:"provisionNiveau",value:y.provisionNiveau,onChange:X=>D(L=>({...L,provisionNiveau:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.chooseLevel")}),e.jsx("option",{value:"0-10%",children:"0-10%"}),e.jsx("option",{value:"10-20%",children:"10-20%"}),e.jsx("option",{value:"20-30%",children:"20-30%"}),e.jsx("option",{value:"30-50%",children:"30-50%"}),e.jsx("option",{value:"50%+",children:"50%+"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"harAarsbonus",className:"text-sm",children:n("myChoices.annualBonus")}),e.jsxs("select",{id:"harAarsbonus",value:y.harAarsbonus,onChange:X=>D(L=>({...L,harAarsbonus:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.choose")}),e.jsx("option",{value:"ja",children:n("myChoices.yes")}),e.jsx("option",{value:"nej",children:n("myChoices.no")})]})]}),y.harAarsbonus==="ja"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"aarsbonusNiveau",className:"text-sm",children:n("myChoices.bonusLevel")}),e.jsxs("select",{id:"aarsbonusNiveau",value:y.aarsbonusNiveau,onChange:X=>D(L=>({...L,aarsbonusNiveau:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.chooseLevel")}),e.jsx("option",{value:"1-månedsløn",children:n("myChoices.oneMonth")}),e.jsx("option",{value:"2-månedslønninger",children:n("myChoices.twoMonths")}),e.jsx("option",{value:"3-månedslønninger",children:n("myChoices.threeMonths")}),e.jsx("option",{value:"4+-månedslønninger",children:n("myChoices.fourPlusMonths")}),e.jsx("option",{value:"10-20%",children:n("myChoices.percentOfAnnual10_20")}),e.jsx("option",{value:"20%+",children:n("myChoices.percentOfAnnual20plus")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-sm",children:n("myChoices.pension")}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{htmlFor:"pensionVirksomhed",className:"text-xs text-muted-foreground",children:n("myChoices.companyPension")}),e.jsxs("select",{id:"pensionVirksomhed",value:y.pensionVirksomhed,onChange:X=>D(L=>({...L,pensionVirksomhed:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.choosePercent")}),[...Array(21)].map((X,L)=>e.jsxs("option",{value:`${L}%`,children:[L,"%"]},L))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{htmlFor:"pensionEgen",className:"text-xs text-muted-foreground",children:n("myChoices.ownContribution")}),e.jsxs("select",{id:"pensionEgen",value:y.pensionEgen,onChange:X=>D(L=>({...L,pensionEgen:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.choosePercent")}),[...Array(21)].map((X,L)=>e.jsxs("option",{value:`${L}%`,children:[L,"%"]},L))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"harBilordning",className:"text-sm",children:n("myChoices.carAllowance")}),e.jsxs("select",{id:"harBilordning",value:y.harBilordning,onChange:X=>D(L=>({...L,harBilordning:X.target.value})),className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("myChoices.choose")}),e.jsx("option",{value:"ja",children:n("myChoices.yes")}),e.jsx("option",{value:"nej",children:n("myChoices.no")})]})]}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsxs(h,{size:"sm",onClick:Us,children:[e.jsx(zs,{className:"w-4 h-4 mr-1"}),n("myChoices.save")]}),e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>A(!1),children:[e.jsx(mt,{className:"w-4 h-4 mr-1"}),n("myChoices.cancel")]})]})]}):e.jsxs(e.Fragment,{children:[le.salaryFields&&le.salaryFields.map(X=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:X.label}),e.jsx("span",{className:"font-medium text-foreground text-right",children:X.value})]},X.key)),e.jsxs(h,{variant:"outline",size:"sm",className:"mt-2",onClick:Ze,children:[e.jsx(Qa,{className:"w-4 h-4 mr-1"}),n("myChoices.editSalaryData")]})]})]}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:n("myChoices.sharingPreferences")}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx(se,{htmlFor:"useSalaryMatching",className:"text-sm leading-relaxed flex-1 cursor-pointer",children:n("myChoices.salary
278MatchingLabel")}),e.jsx(Ta,{id:"useSalaryMatching",checked:Oe,onCheckedChange:X=>He("use_salary_matching",X)})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx(se,{htmlFor:"shareSalaryApplications",className:"text-sm leading-relaxed flex-1 cursor-pointer",children:n("myChoices.shareWithApplications")}),e.jsx(Ta,{id:"shareSalaryApplications",checked:we,onCheckedChange:X=>He("share_salary_applications",X)})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx(se,{htmlFor:"shareSalaryRecruiters",className:"text-sm leading-relaxed flex-1 cursor-pointer",children:n("myChoices.shareWithRecruiters")}),e.jsx(Ta,{id:"shareSalaryRecruiters",checked:ae,onCheckedChange:X=>He("share_salary_recruiters",X)})]})]}),"fields"in le&&le.fields&&e.jsxs("div",{className:"space-y-3",children:[le.fields.map(X=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:X.label}),m===le.id?e.jsx(ue,{className:"max-w-xs",value:l[X.key]??X.value,onChange:L=>Fe(X.key,L.target.value)}):e.jsx("span",{className:"font-medium text-foreground",children:X.value})]},X.key)),"action"in le&&le.action&&e.jsxs(h,{variant:"link",className:"p-0 h-auto gap-1 text-primary",onClick:le.action.onClick,children:[le.action.label,e.jsx(Nl,{className:"w-4 h-4"})]})]}),"isClausesSection"in le&&le.isClausesSection&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-sm",children:n("myChoices.clauses")}),e.jsxs("select",{value:De.klausuler,onChange:async X=>{const L=X.target.value;_(ce=>({...ce,klausuler:L}));try{const{data:{user:ce}}=await C.auth.getUser();ce&&await C.from("profiles").update({has_clauses:L||null}).eq("id",ce.id)}catch(ce){console.error(ce)}},className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("profileSalary.select")}),e.jsx("option",{value:"ja",children:n("profileSalary.yes")}),e.jsx("option",{value:"nej",children:n("profileSalary.no")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-sm",children:n("myChoices.noticePeriod")}),e.jsxs("select",{value:De.opsigelse,onChange:async X=>{const L=X.target.value;_(ce=>({...ce,opsigelse:L}));try{const{data:{user:ce}}=await C.auth.getUser();ce&&await C.from("profiles").update({notice_period:L||null}).eq("id",ce.id)}catch(ce){console.error(ce)}},className:"w-full h-10 px-3 rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[e.jsx("option",{value:"",children:n("profileSalary.select")}),e.jsx("option",{value:"løbende+1",children:n("profileSalary.noticePlus1")}),e.jsx("option",{value:"løbende+2",children:n("profileSalary.noticePlus2")}),e.jsx("option",{value:"løbende+3",children:n("profileSalary.noticePlus3")}),e.jsx("option",{value:"løbende+4",children:n("profileSalary.noticePlus4")}),e.jsx("option",{value:"løbende+5",children:n("profileSalary.noticePlus5")}),e.jsx("option",{value:"løbende+6",children:n("profileSalary.noticePlus6")}),e.jsx("option",{value:"andet",children:n("profileSalary.noticeOther")})]})]})]}),"isCombobox"in le&&le.isCombobox&&e.jsxs("div",{className:"space-y-4",children:[le.id==="arbejde"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-sm",children:n("myChoices.desiredWorkHours")}),e.jsx(sa,{options:z,value:De.arbejdstid,onChange:X=>fe("arbejdstid","working_hours",X),placeholder:n("profil.preferences.selectWorkingHours"),searchPlaceholder:n("profil.preferences.searchWorkingHours"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterWorkingHours")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-sm",children:n("myChoices.flexibility")}),e.jsx(sa,{options:b,value:De.fleksibilitet,onChange:X=>fe("fleksibilitet","flexibility",X),placeholder:n("profil.preferences.selectFlexibility"),searchPlaceholder:n("profil.preferences.searchFlexibility"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterFlexibility")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{className:"text-sm",children:n("myChoices.level")}),e.jsx(sa,{options:H,value:typeof De.niveau=="string"?De.niveau.split(", ").filter(
278Boolean):[],onChange:X=>{const L=X.join(", ");_(ce=>({...ce,niveau:L})),C.auth.getUser().then(({data:{user:ce}})=>{ce&&C.from("profiles").update({preferred_position_level:X.length>0?X:null}).eq("id",ce.id)})},placeholder:n("profil.preferences.selectLevel"),searchPlaceholder:n("profil.preferences.searchLevel"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterLevel")})]})]}),le.id==="geografi"&&e.jsx(sa,{options:Z,value:De.geografi,onChange:X=>fe("geografi","preferred_geography",X),placeholder:n("profil.preferences.selectGeography"),searchPlaceholder:n("profil.preferences.searchLocation"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterLocation")}),le.id==="funktion"&&e.jsx(sa,{options:ne,value:De.funktion,onChange:X=>fe("funktion","preferred_job_function",X),placeholder:n("profil.preferences.selectFunction"),searchPlaceholder:n("profil.preferences.searchFunction"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterFunction")}),le.id==="brancher"&&e.jsx(sa,{options:x,value:De.brancher,onChange:X=>fe("brancher","preferred_industries",X),placeholder:n("profil.preferences.selectIndustries"),searchPlaceholder:n("profil.preferences.searchIndustry"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterIndustry")}),le.id==="sprog"&&e.jsx(sa,{options:U,value:De.sprog,onChange:X=>fe("sprog","languages",X),placeholder:n("profil.preferences.selectLanguages"),searchPlaceholder:n("profil.preferences.searchLanguage"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterLanguage")}),le.id==="it"&&e.jsx(sa,{options:te,value:De.itFaerdigheder,onChange:X=>fe("itFaerdigheder","it_skills",X),placeholder:n("profil.preferences.selectIT"),searchPlaceholder:n("profil.preferences.searchIT"),emptyMessage:n("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:n("profil.preferences.enterIT")})]})]}),s&&s.sectionId===le.id&&s.node]},le.id))}),e.jsx("div",{className:"bg-muted p-4 rounded-lg text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:n("myChoices.matchTip")})}),e.jsx(ns,{open:g,onOpenChange:P,children:e.jsxs(rs,{children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"w-5 h-5 text-primary"}),n("myChoices.addNew")]}),e.jsx(Qs,{children:n("myChoices.addNewDesc")})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"new-tag",children:n("myChoices.newValue")}),e.jsx(ue,{id:"new-tag",placeholder:n("myChoices.enterValue"),value:p,onChange:le=>j(le.target.value),onKeyDown:le=>{le.key==="Enter"&&Ge()}})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{variant:"outline",onClick:()=>P(!1),children:n("myChoices.cancel")}),e.jsx(h,{onClick:Ge,disabled:!p.trim(),children:n("myChoices.add")})]})]})]})})]})};function rh(s){const t=bt(s).split(`
279`).map(m=>m.trim()).filter(Boolean),r=[],n=[];let d="none";for(const m of t){const c=m.toLowerCase();if(c.includes("branche")&&(c.includes("forslag")||c.includes("relevante")||c.includes("foreslåede"))){d="industry";continue}if((c.includes("jobfunktion")||c.includes("stillingstitl")||c.includes("funktioner"))&&(c.includes("specifikke")||c.includes("forslag")||c.includes("foreslåede"))){d="function";continue}if(c.includes("opsummering")||c.includes("forklaring")||c.includes("hvorfor disse")){d="none";continue}const l=m.match(/^\d+\.\s*(.+?)(?:\s*[:\-–]|$)/),f=m.match(/^[-•]\s*(.+?)(?:\s*[:\-–]|$)/);if(d==="industry"&&(l||f)){const p=((l==null?void 0:l[1])||(f==null?void 0:f[1])||"").trim();p&&p.length>2&&p.length<80&&r.push(p)}else if(d==="function"&&(l||f)){const p=((l==null?void 0:l[1])||(f==null?void 0:f[1])||"").trim();p&&p.length>2&&p.length<80&&n.push(p)}}return{industries:r,functions:n}}const ih=({content:s,currentIndustries:a,currentFunctions:t,onAddIndustry:r,onRemoveIndustry:n,onAddFunction:d,onRemoveFunction:m})=>{const{t:c}=Je(),{industries:l,functions:f}=rh(s);return l.length===0&&f.length===0?e.jsx("div",{className:"p-4 bg-background rounded-lg border text-sm whitespace-pre-wrap",children:bt(s)}):e.jsxs("div",{className:"space-y-4",children:[l.length>0&&e.jsxs("div",{className:"p-4 bg-background rounded-lg border space-y-3",children:[e.jsxs("h4",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(ut,{className:"w-4 h-4 text-primary"}),c("jobPreferences.suggestedIndustries")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map((p,j)=>{const g=a.some(P=>P.toLowerCase()===p.toLowerCase());return e.jsxs("button",{onClick:()=>g?n(a.find(P=>P.toLowerCase()===p.toLowerCase())||p):r(p),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${g?"bg-primary/10 text-primary border-primary/30 hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30":"bg-muted text-muted-foreground border-border hover:bg-primary/10 hover:text-primary hover:border-primary/30"}`,children:[g?e.jsx(zr,{className:"w-3 h-3"}):e.jsx(fs,{className:"w-3 h-3"}),p,g&&e.jsx(Et,{className:"w-3 h-3"})]},j)})})]}),f.length>0&&e.jsxs("div",{className:"p-4 bg-background rounded-lg border space-y-3",children:[e.jsxs("h4",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(ht,{className:"w-4 h-4 text-primary"}),c("jobPreferences.suggestedFunctions")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((p,j)=>{const g=t.some(P=>P.toLowerCase()===p.toLowerCase());return e.jsxs("button",{onClick:()=>g?m(t.find(P=>P.toLowerCase()===p.toLowerCase())||p):d(p),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${g?"bg-primary/10 text-primary border-primary/30 hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30":"bg-muted text-muted-foreground border-border hover:bg-primary/10 hover:text-primary hover:border-primary/30"}`,children:[g?e.jsx(zr,{className:"w-3 h-3"}):e.jsx(fs,{className:"w-3 h-3"}),p,g&&e.jsx(Et,{className:"w-3 h-3"})]},j)})})]})]})},qa=({title:s,icon:a,tags:t,onRemove:r,onAdd:n,iconColor:d="text-primary",bgColor:m="bg-primary/10"})=>{const{t:c}=Je();return e.jsxs(ye,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${m}`,children:e.jsx(a,{className:`w-5 h-5 ${d}`})}),e.jsx("h3",{className:"font-semibold text-foreground text-lg",children:s})]}),e.jsxs(h,{size:"sm",variant:"outline",onClick:n,className:"gap-1",children:[e.jsx(fs,{className:"w-4 h-4"}),c("jobPreferences.add")]})]}),t.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(l=>e.jsxs(je,{variant:"secondary",className:"gap-1 px-3 py-1.5 text-sm",children:[l,e.jsx("button",{onClick:()=>r(l),className:"ml-1 hover:text-destructive",children:e.jsx(mt,{className:"w-3 h-3"})})]},l))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:c("jobPreferences.noneAdded")})]})}
279,yl=({hideSections:s=[]}={})=>{const a=ae=>s.includes(ae),{t}=Je(),{arbejdstidOptions:r,fleksibilitetOptions:n}=Ol(),{toast:d}=Ct(),{getDocumentByType:m}=Xa(),c=m("industry_suggestions"),[l,f]=i.useState(!0),[p,j]=i.useState(!1);i.useState("aktiv");const[g,P]=i.useState([]),[N,w]=i.useState([]),[S,A]=i.useState([]),[y,D]=i.useState([]),[B,M]=i.useState([]),[Y,R]=i.useState([]),[Q,k]=i.useState([]),[$,K]=i.useState([]),[re,ve]=i.useState(null),[ze,xe]=i.useState(!1),[I,E]=i.useState(!1),[F,O]=i.useState(null),[ee,Le]=i.useState("");i.useEffect(()=>{pe()},[]);const pe=async()=>{var Ve,Xe,cs,hs,ps,ms;f(!0);const{data:{user:ae}}=await C.auth.getUser();if(!ae){f(!1);return}const[me,Ae]=await Promise.all([C.from("profiles").select("preferred_job_function, preferred_industries, preferred_position_level, preferred_geography, working_hours, flexibility, fast_loen, har_provision, har_aarsbonus, use_salary_matching, job_title, desired_job_titles, desired_competencies").eq("id",ae.id).maybeSingle(),C.from("work_experiences").select("job_title, company_industry, key_achievements, responsibilities").eq("user_id",ae.id).order("start_year",{ascending:!1}).limit(5)]),oe=me.data;if(oe){(Ve=oe.preferred_job_function)!=null&&Ve.length&&P(oe.preferred_job_function),(Xe=oe.preferred_industries)!=null&&Xe.length&&w(oe.preferred_industries),(cs=oe.preferred_position_level)!=null&&cs.length&&A(oe.preferred_position_level),(hs=oe.preferred_geography)!=null&&hs.length&&D(oe.preferred_geography);{const _=(oe.working_hours||["Fuldtid"]).map(Z=>{var H;return((H=r.find(ne=>ne.value.toLowerCase()===Z.toLowerCase()))==null?void 0:H.value)||Z});k(_),oe.working_hours||Oe("working_hours",_)}{const _=(oe.flexibility||["Hybrid"]).map(Z=>{var H;return((H=n.find(ne=>ne.value.toLowerCase()===Z.toLowerCase()))==null?void 0:H.value)||Z});K(_),oe.flexibility||Oe("flexibility",_)}if((oe.fast_loen||oe.har_provision||oe.har_aarsbonus)&&ve({fastLoen:oe.fast_loen||"",harProvision:oe.har_provision||"",harAarsbonus:oe.har_aarsbonus||""}),xe(oe.use_salary_matching||!1),Array.isArray(oe.desired_job_titles))M(oe.desired_job_titles);else{const De=new Set;if(oe.job_title&&De.add(oe.job_title),(ps=Ae.data)==null||ps.forEach(_=>{_.job_title&&De.add(_.job_title)}),De.size>0){const _=Array.from(De);M(_),Oe("desired_job_titles",_)}}if(Array.isArray(oe.desired_competencies))R(oe.desired_competencies);else{const De=new Set;if((ms=Ae.data)==null||ms.forEach(_=>{var Z;(Z=_.key_achievements)==null||Z.forEach(H=>{H&&H.length>3&&H.length<60&&De.add(H)})}),De.size>0){const _=Array.from(De).slice(0,12);R(_),Oe("desired_competencies",_)}}}f(!1)},Oe=async(ae,me)=>{const{data:{user:Ae}}=await C.auth.getUser();if(!Ae)return;const oe=ae==="desired_job_titles"||ae==="desired_competencies",Ve=me.length>0?me:oe?[]:null;await C.from("profiles").update({[ae]:Ve}).eq("id",Ae.id)},he=(ae,me)=>{const oe={stillingstitler:{state:B,set:M,db:"desired_job_titles"},funktion:{state:g,set:P,db:"preferred_job_function"},brancher:{state:N,set:w,db:"preferred_industries"},niveau:{state:S,set:A,db:"preferred_position_level"},geografi:{state:y,set:D,db:"preferred_geography"},kompetencer:{state:Y,set:R,db:"desired_competencies"}}[ae];if(!oe)return;const Ve=oe.state.filter(Xe=>Xe!==me);oe.set(Ve),oe.db&&Oe(oe.db,Ve)},we=ae=>{O(ae),Le(""),E(!0)},T=async()=>{if(!ee.trim()||!F)return;const me={stillingstitler:{state:B,set:M,db:"desired_job_titles"},funktion:{state:g,set:P,db:"preferred_job_function"},brancher:{state:N,set:w,db:"preferred_industries"},niveau:{state:S,set:A,db:"preferred_position_level"},geografi:{state:y,set:D,db:"preferred_geography"},kompetencer:{state:Y,set:R,db:"desired_competencies"}}[F];if(!me)return;const Ae=[...me.state,ee.trim()];me.set(Ae),me.db&&await Oe(me.db,Ae),Le(""),E(!1),d({title:t("jobPreferences.added"),description:t("jobPreferences.addedDescription",{value:ee.trim()})})};return l?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(ge,{className:"w-6 h-6 animate-spin text-primary mr-3"}),e.jsx("span",{className:"text-muted-foreground",children:t("jobPreferences.loading")})]}):e.jsxs("div",{className:"space-y-6",children:[!a("header")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:t("jobPreferences.title")}),e.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:t("jobPreferences.description")})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[e.jsx(xs,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsx("span",{children:t("jobPreferences.autoFilledHint")})]})]}),e.jsxs("div",{className:"grid gap-4",children:[!a("stillingstitler")&&e.jsx(qa,{title:t("jobPreferences.desiredTitles"),icon:ka,tags:B,onRemove:ae=>he("stillingstitler",ae),onAdd:()=>we("stillingstitler")}),!a("niveau")&&e.jsx(qa,{title:t("jobPreferences.desiredLevel"),icon:Ar,tags:S,onRemove:ae=>he("niveau",ae),onAdd:()=>we("niveau"),iconColor:"text-indigo-600",bgColor:"bg-indigo-500/10"}),!a("funktion")&&e.jsx(qa,{title:t("jobPreferences.desiredFunctions"),icon:ht,tags:g,onRemove:ae=>he("funktion",ae),onAdd:()=>we("funktion")}),!a("brancher")&&e.jsx(qa,{title:t("jobPreferences.desiredIndustries"),icon:ut,tags:N,onRemove:ae=>he("brancher",ae),onAdd:()=>we("brancher")}),!a("kompetencer")&&e.jsx(qa,{title:t("jobPreferences.coreCompetencies"),icon:ec,tags:Y,onRemove:ae=>
279he("kompetencer",ae),onAdd:()=>we("kompetencer"),iconColor:"text-emerald-600",bgColor:"bg-emerald-500/10"}),!a("geografi")&&e.jsx(qa,{title:t("jobPreferences.desiredGeography"),icon:ia,tags:y,onRemove:ae=>he("geografi",ae),onAdd:()=>we("geografi"),iconColor:"text-blue-600",bgColor:"bg-blue-500/10"}),!a("workFlexibility")&&e.jsxs(ye,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-violet-500/10",children:e.jsx(ba,{className:"w-5 h-5 text-violet-600"})}),e.jsx("h3",{className:"font-semibold text-foreground text-lg",children:t("jobPreferences.workFlexibility")})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-muted-foreground",children:[t("jobPreferences.workingHours")," ",e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",t("profil.preferences.selectOne"),")"]})]}),e.jsx(sa,{options:r,value:Q,onChange:ae=>{k(ae),Oe("working_hours",ae)},placeholder:t("jobPreferences.workingHoursPlaceholder"),searchPlaceholder:t("profil.preferences.searchWorkingHours"),emptyMessage:t("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:t("profil.preferences.enterWorkingHours")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-muted-foreground",children:[t("jobPreferences.flexibility")," ",e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",t("profil.preferences.selectOne"),")"]})]}),e.jsx(sa,{options:n,value:$,onChange:ae=>{K(ae),Oe("flexibility",ae)},placeholder:t("jobPreferences.flexibilityPlaceholder"),searchPlaceholder:t("profil.preferences.searchFlexibility"),emptyMessage:t("profil.preferences.noResults"),allowCustom:!0,customPlaceholder:t("profil.preferences.enterFlexibility")})]})]})]}),!a("salary")&&re&&e.jsxs(ye,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-green-500/10",children:e.jsx(Ar,{className:"w-5 h-5 text-green-600"})}),e.jsx("h3",{className:"font-semibold text-foreground text-lg",children:t("jobPreferences.salaryExpectation")}),ze&&e.jsx(je,{variant:"outline",className:"text-xs text-green-600 border-green-300",children:t("jobPreferences.activeInJobMatch")})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-sm text-muted-foreground",children:[re.fastLoen&&e.jsxs("span",{children:[t("jobPreferences.baseSalary")," ",e.jsx("strong",{className:"text-foreground",children:re.fastLoen})]}),re.harProvision==="ja"&&e.jsxs("span",{children:["• ",t("jobPreferences.commission")]}),re.harAarsbonus==="ja"&&e.jsxs("span",{children:["• ",t("jobPreferences.annualBonus")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:t("jobPreferences.editSalaryHint")})]}),!a("industrySuggestions")&&e.jsxs(ye,{className:"p-5 bg-gradient-to-r from-amber-500/10 to-orange-500/10 border-amber-500/20",children:[e.jsx("div",{className:"flex items-start justify-between mb-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-amber-500/20",children:e.jsx(wt,{className:"w-5 h-5 text-amber-600"})}),e.jsx("h3",{className:"font-semibold text-foreground text-lg",children:t("jobPreferences.industrySuggestions")})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("jobPreferences.industrySuggestionsDescription")}),c?e.jsxs("div",{className:"space-y-4",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>j(!p),className:"gap-2",children:[p?e.jsx(cr,{className:"w-4 h-4"}):e.jsx(Ts,{className:"w-4 h-4"}),t(p?"jobPreferences.hideSuggestions":"jobPreferences.showSuggestions")]}),p&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(ih,{content:c.content,currentIndustries:N,currentFunctions:g,onAddIndustry:async ae=>{const me=[...N,ae];w(me),await Oe("preferred_industries",me),d({title:t("jobPreferences.added"),description:t("jobPreferences.addedToIndustries",{value:ae})})},onRemoveIndustry:async ae=>{const me=N.filter(Ae=>Ae!==ae);w(me),await Oe("preferred_industries",me),d({title:t("jobPreferences.removed"),description:t("jobPreferences.removedFromIndustries",{value:ae})})},onAddFunction:async ae=>{const me=[...g,ae];P(me),await Oe("preferred_job_function",me),d({title:t("jobPreferences.added"),description:t("jobPreferences.addedToFunctions",{value:ae})})},onRemoveFunction:async ae=>{const me=g.filter(Ae=>Ae!==ae);P(me),await Oe("preferred_job_function",me),d({title:t("jobPreferences.removed"),description:t("jobPreferences.removedFromFunctions",{value:ae})})}}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground text-xs",children:t("jobPreferences.showFullText")}),e.jsx("div",{className:"p-4 bg-background rounded-lg border text-sm whitespace-pre-wrap mt-2",children:bt(c.content)})]})]})]}):e.jsx("p",{className:"text-xs text-amber-600",children:t("jobPreferences.noSuggestionsYet")})]})]})]}),e.jsx(ns,{open:I,onOpenChange:E,children:e.jsxs(rs,{className:"sm:max-w-md",children:[e.jsxs(os,{children:[e.jsx(is,{children:t("jobPreferences.addNewDialogTitle",{section:t("jobPreferences.sectionLabels."+(F||""),"")})}),e.jsx(Qs,{children:t("jobPreferences.addNewDialogDescription",{section:t("jobPreferences.sectionLabels."+(F||""),"")})})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsx(ue,{value:ee,onChange:ae=>Le(ae.target.value),placeholder:t(F==="stillingstitler"?"jobPreferences.placeholders.stillingstitler":F==="funktion"?"jobPreferences.placeholders.funktion":F==="brancher"?"jobPreferences.placeholders.brancher":F==="niveau"?"jobPreferences.placeholders.niveau":F==="geografi"?"jobPreferences.placeholders.geografi":F==="kompetencer"?"jobPreferences.placeholders.kompetencer":"jobPreferences.enterValue"),onKeyDown:ae=>ae.key==="Enter"&&T()}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{variant:"outline",onClick:()=>E(!1),children:t("jobPreferences.cancel")}),e.jsx(h,{onClick:T,disabled:!ee.trim(),children:t("jobPreferences.add")})]})]})]})})]})},lh=()=>{Je();const[s,a]=i.useState(null),[t,r]=i.useState(!0);return i.useEffect(()=>{(async()=>{const{data:{user:n}}=await C.auth.getUser();if(!n){r(!1);return}const{data:d}=await C.from("profiles").select("profile_photo_url").eq("id",n.id).maybeSingle();if(d!=null&&d.profile_photo_url){const{data:m}=await C.storage.from("profile-photos").createSignedUrl(d.profile_photo_url,3600);a((m==null?void 0:m.signedUrl)??null)}r(!1)})()},[]),t?null:e.jsx(zl,{profilePhotoUrl:s,onPhotoChange:a})},oh=()=>e.jsxs("div",{className:"space-y-12",children:[e.jsx(nh,{hideLinkedIn:!0,slotAfterLinkedIn:e.jsxs("div",{className:"space-y-6",children:[e.jsx(lh,{}),e.jsx(ro,{})]}),slotAfterSection:{sectionId:"geografi",node:e.jsx(yl,{hideSections:["header","niveau","funktion","brancher","geografi","workFlexibility","salary","industrySuggestions"]})}}),e.jsx("div",{className:"border-t border-border pt-8",children:e.jsx(yl,{hideSections:["header","stillingstitler","niveau","funktion","brancher","kompetencer","geografi","workFlexibility","salary"]})})]}),ch=({open:s,onOpenChange:a})=>{const{t}=Je(),[r,n]=i.useState(""),[d,m]=i.useState(!1),[c,l]=i.useState(!1),[f,p]=i.useState(""),j=async P=>{if(P.preventDefault(),!!r.trim()){m(!0);try{const{data:{session:N}}=await C.auth.getSession();if(!N){J.error(t("voucherRedeem.notLoggedIn"));return}const{data:w,error:S}=await C.functions.invoke("redeem-voucher",{body:{code:r.trim()}});if(S)throw S;if(w!=null&&w.error){const A=w.error_key;A==="not_found"?J.error(t("voucherRedeem.notFound")):A==="already_redeemed"?J.error(t("voucherRedeem.alreadyRedeemed")):A==="expired"?J.error(t("voucherRedeem.expired")):J.error(w.error);return}p(w.subscription_end),l(!0),J.success(t("voucherRedeem.success"))}catch(N){J.error(N.message||t("voucherRedeem.error"))}finally{m(!1)}}},g=()=>{a(!1),c&&window.location.reload(),setTimeout(()=>{n(""),l(!1),p("")},300)};return e.jsx(ns,{open:s,onOpenChange:g,children:e.jsxs(rs,{className:"max-w-md",children:[e.jsxs(os,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(Vr,{className:"w-5 h-5 text-primary"}
279),t("voucherRedeem.title")]}),e.jsx(Qs,{children:t(c?"voucherRedeem.redeemedDescription":"voucherRedeem.description")})]}),c?e.jsxs("div",{className:"space-y-4 text-center py-4",children:[e.jsx(dn,{className:"w-16 h-16 text-green-500 mx-auto"}),e.jsx("p",{className:"font-medium text-foreground",children:t("voucherRedeem.activatedMessage")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("voucherRedeem.validUntil",{date:new Date(f).toLocaleDateString("da-DK")})}),e.jsx(h,{onClick:g,className:"w-full",children:t("voucherRedeem.continue")})]}):e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"voucherCode",children:t("voucherRedeem.codeLabel")}),e.jsx(ue,{id:"voucherCode",value:r,onChange:P=>n(P.target.value.toUpperCase()),placeholder:"CS-XXXXXXXX",className:"font-mono text-center text-lg tracking-wider",maxLength:12})]}),e.jsx(h,{type:"submit",className:"w-full",disabled:d||!r.trim(),children:d?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),t("voucherRedeem.redeeming")]}):t("voucherRedeem.redeemButton")})]})]})})},dh=()=>{var U,te,fe,Se;const s=$a(),[a,t]=i.useState(!1),[r,n]=i.useState(!1),[d,m]=i.useState(!0),{toast:c}=Ct(),{t:l,i18n:f}=Je(),[p,j]=i.useState(!1),[g,P]=i.useState(""),[N,w]=i.useState(""),[S,A]=i.useState(!1),[y,D]=i.useState("");i.useState(!1),i.useState("json"),i.useState(!1);const[B,M]=i.useState(!1),[Y,R]=i.useState(!1),[Q,k]=i.useState(""),[$,K]=i.useState(!1),[re,ve]=i.useState([]),[ze,xe]=i.useState(null),[I,E]=i.useState(null),[F,O]=i.useState({firstName:"",lastName:"",email:"",phone:"",address:"",postalCode:"",city:"",country:l("subscription.defaultCountry")});i.useEffect(()=>{(async()=>{var He;const{data:{user:Fe}}=await C.auth.getUser();if(!Fe){m(!1);return}const{data:Ee}=await C.from("profiles").select("full_name, email, phone, street_address, postal_code, city").eq("id",Fe.id).maybeSingle(),{data:qe}=await C.from("user_subscriptions").select("subscription_status, trial_start, trial_end, paid_subscription_started_at, scheduled_deletion_date").eq("user_id",Fe.id).maybeSingle();if(qe&&E(qe),Ee){const Ze=((He=Ee.full_name)==null?void 0:He.split(" "))||[];O(Us=>({...Us,firstName:Ze[0]||"",lastName:Ze.slice(1).join(" ")||"",email:Ee.email||Fe.email||"",phone:Ee.phone||"",address:Ee.street_address||"",postalCode:Ee.postal_code||"",city:Ee.city||""}))}else O(Ze=>({...Ze,email:Fe.email||""}));const{data:Ge}=await C.from("outplacement_access").select("id, consultant_email, is_active, created_at").eq("candidate_user_id",Fe.id);Ge&&ve(Ge),m(!1)})()},[]);const ee=async G=>{xe(G);try{const{error:Fe}=await C.from("outplacement_access").update({is_active:!1}).eq("id",G);if(Fe)throw Fe;ve(Ee=>Ee.map(qe=>qe.id===G?{...qe,is_active:!1}:qe)),J.success(l("subscription.consultantAccessRevoked"))}catch(Fe){console.error("Error revoking access:",Fe),J.error(l("subscription.couldNotRevokeAccess"))}finally{xe(null)}},pe=(()=>{if(!I)return{plan:l("subscription.freeTrial"),status:"trial",statusLabel:l("subscription.trialStatus","Prøveperiode"),trialEnd:"",daysLeft:0};const G=new Date(I.trial_end),Fe=new Date,Ee=Math.max(0,Math.ceil((G.getTime()-Fe.getTime())/(1e3*60*60*24))),qe=new Intl.DateTimeFormat(Te(f.language)?"da-DK":"en-GB",{day:"numeric",month:"long",year:"numeric"});return I.subscription_status==="active"?{plan:Te(f.language)?"Månedligt abonnement":"Monthly subscription",status:"active",statusLabel:l("subscription.active"),trialEnd:"",daysLeft:0}:I.subscription_status==="paused"?{plan:Te(f.language)?"Dvale-abonnement":"Dormant subscription",status:"dormant",statusLabel:Te(f.language)?"Dvale":"Dormant",trialEnd:"",daysLeft:0}:I.subscription_status==="expired"?{plan:"Udløbet",status:"expired",statusLabel:"Udløbet",trialEnd:qe.format(G),daysLeft:0}:{plan:"Gratis prøveperiode",status:"trial",statusLabel:l("subscription.trialStatus","Prøveperiode"),trialEnd:qe.format(G),daysLeft:Ee}})(),Oe={name:l("subscription.monthlyPlanName"),price:l("subscription.monthlyPrice"),period:l("subscription.monthlyPeriod"),features:l("subscription.monthlyFeatures",{returnObjects:!0})},[he,we]=i.useState(!1),[T,ae]=i.useState(!1),[me,Ae]=i.useState(!1),[oe,Ve]=i.useState(!1),[Xe,cs]=i.useState("dormant"),hs=async()=>{Ae(!0);try{const{data:G,error:Fe}=await C.functions.invoke("change-subscription-plan",{body:{targetPlan:Xe}});if(Fe)throw Fe;if((G==null?void 0:G.ok)===!1)throw new Error(G.error||"Plan change failed");E(Ee=>Ee&&{...Ee,subscription_status:Xe==="monthly"?"active":"paused"}),J.success(Xe==="dormant"?Te(f.language)?"Skifter til dvale ved næste fakturer
279ing":"Switching to dormant at next billing":Te(f.language)?"Opgraderer til månedligt ved næste fakturering":"Upgrading to monthly at next billing"),Ve(!1)}catch(G){console.error("Change plan error:",G),c({title:l("subscription.error"),description:Te(f.language)?"Kunne ikke skifte abonnement. Prøv igen.":"Could not change plan. Try again.",variant:"destructive"})}finally{Ae(!1)}},ps=async()=>{we(!0);try{const{data:G,error:Fe}=await C.functions.invoke("cancel-subscription",{body:{action:"cancel"}});if(Fe)throw Fe;if((G==null?void 0:G.ok)===!1)throw new Error(G.error||"Cancel failed");const Ee=G!=null&&G.access_until?new Date(G.access_until):null;J.success(Ee?Te(f.language)?`Opsagt. Du har adgang frem til ${new Intl.DateTimeFormat("da-DK",{day:"numeric",month:"long",year:"numeric"}).format(Ee)}.`:`Cancelled. You have access until ${new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",year:"numeric"}).format(Ee)}.`:l("subscription.subscriptionCancelled")),ae(!1)}catch(G){console.error("Cancel error:",G),c({title:l("subscription.error"),description:l("subscription.cancelError","Kunne ikke opsige. Prøv igen."),variant:"destructive"})}finally{we(!1)}},[ms,De]=i.useState(!1),[_,Z]=i.useState(!1),H=async()=>{De(!0);try{const{data:G,error:Fe}=await C.functions.invoke("create-checkout");if(Fe)throw Fe;if(G!=null&&G.url)window.open(G.url,"_blank");else throw new Error("No checkout URL returned")}catch(G){console.error("Checkout error:",G),c({title:l("subscription.error"),description:l("subscription.checkoutError"),variant:"destructive"})}finally{De(!1)}},ne=async()=>{Z(!0);try{const{data:G,error:Fe}=await C.functions.invoke("customer-portal");if(Fe)throw Fe;if(G!=null&&G.url)window.open(G.url,"_blank");else throw new Error("No portal URL returned")}catch(G){console.error("Portal error:",G),c({title:l("subscription.error"),description:l("subscription.portalError"),variant:"destructive"})}finally{Z(!1)}};i.useEffect(()=>{const G=async()=>{try{const{data:Ee,error:qe}=await C.functions.invoke("check-stripe-subscription");if(qe||!Ee)return;Ee.subscribed&&E(Ge=>Ge&&{...Ge,subscription_status:"active",paid_subscription_started_at:Ge.paid_subscription_started_at||new Date().toISOString(),scheduled_deletion_date:null})}catch(Ee){console.error("Check subscription error:",Ee)}};G(),new URLSearchParams(window.location.search).get("checkout")==="success"&&(G(),J.success(l("subscription.paymentComplete")))},[]);const x=async()=>{n(!0);const{data:{user:G}}=await C.auth.getUser();if(!G){c({title:l("subscription.error"),description:l("subscription.mustBeLoggedIn"),variant:"destructive"}),n(!1);return}const Fe=`${F.firstName} ${F.lastName}`.trim(),{error:Ee}=await C.from("profiles").update({full_name:Fe,phone:F.phone,email:F.email,street_address:F.address,postal_code:F.postalCode,city:F.city}).eq("id",G.id);Ee?c({title:l("subscription.saveErrorTitle"),description:l("subscription.saveError"),variant:"destructive"}):(c({title:l("subscription.save"),description:l("subscription.savedProfile")}),t(!1)),n(!1)},z=async()=>{if(D(""),g.length<6){D(l("subscription.passwordMinLength"));return}if(g!==N){D(l("subscription.passwordMismatch"));return}A(!0);try{const{error:G}=await C.auth.updateUser({password:g});if(G)throw G;J.success(l("subscription.passwordUpdated")),j(!1),P(""),w("")}catch(G){console.error("Error changing password:",G),D(G.message||l("subscription.couldNotChangePassword"))}finally{A(!1)}},b=async()=>{if(Q===l("subscription.deleteConfirmText")){R(!0);try{const{data:{session:G}}=await C.auth.getSession();if(!G){c({title:l("subscription.error"),description:l("subscription.mustBeLoggedInDelete"),variant:"destructive"});return}const Fe=await C.functions.invoke("delete-user-account");if(Fe.error)throw Fe.error;await C.auth.signOut(),J.success(l("subscription.accountDeleted")),s("/")}catch(G){console.error("Delete error:",G),c({title:l("subscription.deleteErrorTitle"),description:l("subscription.deleteError"),variant:"destructive"})}finally{R(!1),M(!1),k("")}}};return d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ye,{children:[e.jsxs(Jt,{className:"flex flex-row items-center justify-between",children:[e.jsxs(Yt,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Ca,{className:"w-5 h-5 text-primary"}),l("subscription.personalInfo")]}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>a?x():t(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),l("subscription.saving")]}):a?e.jsxs(e.Fragment,{children:[e.jsx(Et,{className:"w-4 h-4 mr-2"}),l("subscription.save")]}):e.jsxs(e.Fragment,{children:[e.jsx(Yr,{className:"w-4 h-4 mr-2"}),l("subscription.edit")]})})]}),e.jsx(yt,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"firstName",children:l("subscription.firstName")}
279),e.jsx(ue,{id:"firstName",value:F.firstName,onChange:G=>O({...F,firstName:G.target.value}),disabled:!a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"lastName",children:l("subscription.lastName")}),e.jsx(ue,{id:"lastName",value:F.lastName,onChange:G=>O({...F,lastName:G.target.value}),disabled:!a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"email",children:l("subscription.email")}),e.jsxs("div",{className:"relative",children:[e.jsx(ua,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ue,{id:"email",type:"email",value:F.email,onChange:G=>O({...F,email:G.target.value}),disabled:!a,className:"pl-10"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"phone",children:l("subscription.phone")}),e.jsxs("div",{className:"relative",children:[e.jsx(or,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ue,{id:"phone",value:F.phone,onChange:G=>O({...F,phone:G.target.value}),disabled:!a,className:"pl-10"})]})]}),e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(se,{htmlFor:"address",children:l("subscription.address")}),e.jsxs("div",{className:"relative",children:[e.jsx(ia,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ue,{id:"address",value:F.address,onChange:G=>O({...F,address:G.target.value}),disabled:!a,className:"pl-10",placeholder:l("subscription.addressPlaceholder")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"postalCode",children:l("subscription.postalCode")}),e.jsx(ue,{id:"postalCode",value:F.postalCode,onChange:G=>O({...F,postalCode:G.target.value}),disabled:!a,placeholder:"1234"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"city",children:l("subscription.city")}),e.jsx(ue,{id:"city",value:F.city,onChange:G=>O({...F,city:G.target.value}),disabled:!a,placeholder:l("subscription.cityPlaceholder")})]})]})})]}),e.jsxs(ye,{className:`border-primary/30 ${pe.status==="expired"?"bg-gradient-to-r from-destructive/5 to-destructive/10 border-destructive/30":"bg-gradient-to-r from-primary/5 to-primary/10"}`,children:[e.jsx(Jt,{children:e.jsxs(Yt,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx($i,{className:"w-5 h-5 text-primary"}),l("subscription.currentPlan")]})}),e.jsx(yt,{children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl font-bold text-foreground",children:pe.plan}),e.jsx(je,{className:pe.status==="active"?"bg-green-500/20 text-green-700 border-green-500/30":pe.status==="expired"?"bg-red-500/20 text-red-700 border-red-500/30":"bg-blue-500/20 text-blue-700 border-blue-500/30",children:pe.statusLabel})]}),pe.status==="trial"&&e.jsx("p",{className:"text-muted-foreground",children:pe.daysLeft>0?`${pe.daysLeft} dage tilbage · Udløber ${pe.trialEnd}`:`Udløbet ${pe.trialEnd}`}),pe.status==="active"&&e.jsx("p",{className:"text-muted-foreground",children:"99 kr./md. · Kan opsiges til udløb af en måned"}),pe.status==="expired"&&(I==null?void 0:I.scheduled_deletion_date)&&e.jsxs("p",{className:"text-destructive text-sm font-medium",children:["⚠️ Din profil og data slettes ",new Intl.DateTimeFormat(Te(f.language)?"da-DK":"en-GB",{day:"numeric",month:"long",year:"numeric"}).format(new Date(I.scheduled_deletion_date)),". Download dine dokumenter inden da."]})]}),pe.status==="trial"&&e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsxs("span",{children:["Prøveperiode udløber: ",pe.trialEnd]})]}),e.jsx("p",{className:"text-xs",children:"Herefter 99 kr./md."})]})]})})]}),pe.status!=="active"&&e.jsx(ye,{className:"border-dashed border-primary/30",children:e.jsx(yt,{className:"py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Vr,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:l("subscription.hasVoucher")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("subscription.hasVoucherDesc")})]})]}),e.jsxs(h,{variant:"outline",onClick:()=>K(!0),className:"gap-2",children:[e.jsx(Vr,{className:"w-4 h-4"}),l("subscription.redeemVoucher")]})]})})}),pe.status!=="active"&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:l("subscription.changePlan")}),e.jsxs(ye,{className:"border-primary shadow-lg max-w-md",children:[e.jsxs(Jt,{className:"text-center pb-2",children:[e.jsx(Yt,{className:"text-lg",children:Oe.name}),e.jsxs("div",{className:"mt-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:Oe.price}),e.jsx("span",{className:"text-muted-foreground",children:Oe.period})]})]}),e.jsxs(yt,{children:[e.jsx("ul",{className:"space-y-2 mb-4",children:Oe.features.map((G,Fe)=>e.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Et,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),e.jsx("span",{children:G})]},Fe))}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3 text-center",children:l("subscription.canCancelMonthly")}),e.jsx(h,{className:"w-full",onClick:H,disabled:ms,children:ms?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),l("subscription.openingCheckout")]}):l("subscription.selectPlan")})]})]})]}),(pe.status==="active"||pe.status==="dormant")&&e.jsxs(ye,{children:[e.jsx(Jt,{children:e.jsxs(Yt,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Vi,{className:"w-5 h-5 text-primary"}),l("subscription.manageSubscription")]})}),e.jsxs(yt,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:l("subscription.manageSubDesc")}),pe.status==="dormant"&&e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-950/30 dark:border-amber-900 p-3 text-sm text-amber-900 dark:text-amber-100",children:Te(f.language)?"Du er på dvale-abonnement (29 kr/md). Du har kun adgang til din profil og denne side. Opgradér til månedligt abonnement for at få fuld adgang igen.":"You are on the dormant plan (29 DKK/mo). You only have access to your profile and this page. Upgrade to monthly to regain full access."}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(h,{variant:"outline",onClick:ne,disabled:_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),l("subscription.openingPortal")]}):e.jsxs(e.Fragment,{children:[e.jsx($i,{className:"w-4 h-4 mr-2"}),l("subscription.manageBilling")]})}),pe.status==="active"?e.jsxs(h,{variant:"outline",onClick:()=>{cs("dormant"),Ve(!0)},children:[e.jsx(td,{className:"w-4 h-4 mr-2"}),Te(f.language)?"Skift til dvale (29 kr/md)":"Switch to dormant (29 DKK/mo)"]}):e.jsxs(h,{variant:"default",onClick:()=>{cs("monthly"),Ve(!0)},children:[e.jsx(od,{className:"w-4 h-4 mr-2"}),Te(f.language)?"Opgradér til månedligt (99 kr/md)":"Upgrade to monthly (99 DKK/mo)"]}),e.jsxs(h,{variant:"destructive",onClick:()=>ae(!0),children:[e.jsx(Ir,{className:"w-4 h-4 mr-2"}),l("subscription.cancelButton")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Te(f.language)?"Plan-ændringer træder i kraft ved næste fakturer
279ing. Opsigelse træder i kraft ved udløbet af din nuværende periode — du beholder adgang indtil da.":"Plan changes take effect at next billing. Cancellation takes effect at the end of your current period — you keep access until then."})]})]}),e.jsxs(ye,{children:[e.jsx(Jt,{children:e.jsxs(Yt,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Qn,{className:"w-5 h-5 text-primary"}),(U=f.language)!=null&&U.startsWith("da")?"Mine data & rettigheder":"My data & rights"]})}),e.jsx(yt,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground font-medium",children:(te=f.language)!=null&&te.startsWith("da")?"Administrér dine data ét sted":"Manage your data in one place"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(fe=f.language)!=null&&fe.startsWith("da")?"Download dine CV'er, kandidatbriefs, cover letters, ansøgningsmails, personanalyser og netværkskontakter — se din samtykke-historik, eller slet din konto permanent.":"Download your CVs, candidate briefs, cover letters, application emails, personality analyses and network contacts — view your consent history, or permanently delete your account."})]}),e.jsx(h,{variant:"outline",onClick:()=>s("/mine-data"),className:"shrink-0",children:(Se=f.language)!=null&&Se.startsWith("da")?"Åbn Mine data":"Open My data"})]})})]}),e.jsxs(ye,{children:[e.jsx(Jt,{children:e.jsxs(Yt,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Vi,{className:"w-5 h-5 text-primary"}),l("subscription.settings")]})}),e.jsxs(yt,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground font-medium",children:l("subscription.changePassword")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("subscription.updatePassword")})]}),e.jsx(h,{variant:"outline",onClick:()=>j(!0),children:l("subscription.changePasswordButton")})]}),e.jsx(st,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground font-medium",children:l("subscription.resetOnboarding")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("subscription.resetOnboardingDesc")})]}),e.jsx(h,{variant:"outline",onClick:()=>{localStorage.removeItem("hasSeenOnboarding"),J.success(l("subscription.onboardingReset"))},children:l("subscription.reset")})]}),e.jsx(st,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-foreground font-medium",children:l("subscription.clearSearchHistory")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("subscription.clearSearchHistoryDesc")})]}),e.jsx(h,{variant:"outline",onClick:()=>{localStorage.removeItem("recentSearches"),J.success(l("subscription.searchHistoryCleared"))},children:l("subscription.clear")})]}),re.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(st,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-foreground font-medium flex items-center gap-2",children:[e.jsx(hd,{className:"w-4 h-4"}),Te(f.language)?"Outplacement-konsulent adgang":"Outplacement consultant access"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:Te(f.language)?"Konsulenter med læseadgang til din profil. Du kan til enhver tid fjerne deres adgang.":"Consultants with read access to your profile. You can revoke their access at any time."})]}),re.map(G=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ua,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:G.consultant_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:G.is_active?Te(f.language)?"Aktiv adgang":"Active access":Te(f.language)?"Adgang fjernet":"Access revoked"})]})]}),G.is_active?e.jsxs(h,{variant:"destructive",size:"sm",onClick:()=>ee(G.id),disabled:ze===G.id,children:[ze===G.id?e.jsx(ge,{className:"w-3 h-3 animate-spin mr-1"}):e.jsx(Ir,{className:"w-3 h-3 mr-1"}),Te(f.language)?"Fjern adgang":"Revoke"]}):e.jsx(je,{variant:"secondary",children:Te(f.language)?"Fjernet":"Revoked"})]},G.id))]})]})]})]}),e.jsx(ns,{open:p,onOpenChange:j,children:e.jsxs(rs,{className:"sm:max-w-md",children:[e.jsxs(os,{children:[e.jsx(is,{children:l("subscription.changePasswordTitle")}),e.jsx(Qs,{children:l("subscription.changePasswordDesc")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"new-password",children:l("subscription.newPassword")}),e.jsx(ue,{id:"new-password",type:"password",placeholder:l("subscription.newPasswordPlaceholder"),value:g,onChange:G=>{P(G.target.value),D("")}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"confirm-password",children:l("subscription.confirmPassword")}),e.jsx(ue,{id:"confirm-password",type:"password",placeholder:l("subscription.confirmPasswordPlaceholder"),value:N,onChange:G=>{w(G.target.value),D("")}})]}),y&&e.jsx("p",{className:"text-sm text-destructive",children:y})]}),e.jsxs(Bt,{children:[e.jsx(h,{variant:"outline",onClick:()=>{j(!1),P(""),w(""),D("")},children:l("subscription.cancel")}),e.jsx(h,{onClick:z,disabled:S,children:l(S?"subscription.savingPassword":"subscription.savePassword")})]})]})}),e.jsx(at,{open:B,onOpenChange:M,children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{className:"text-destructive",children:l("subscription.deleteDialogTitle")}),e.jsxs(lt,{className:"space-y-4",children:[e.jsx("p",{children:l("subscription.deleteDialogDesc")}),e.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm",children:l("subscription.deleteItems",{returnObjects:!0}).map((G,Fe)=>e.jsx("li",{children:G},Fe))}),e.jsx("p",{className:"font-medium text-destructive",children:l("subscription.deleteWarning")}),e.jsxs("div",{className:"pt-4",children:[e.jsx(se,{htmlFor:"delete-confirm",children:l("subscription.typeToConfirm",{text:l("subscription.deleteConfirmText")})}),e.jsx(ue,{id:"delete-confirm",value:Q,onChange:G=>k(G.target.value),placeholder:l("subscription.deleteConfirmPlaceholder"),className:"mt-2"})]})]})]}),e.jsxs(ot,{children:[e.jsx(ct,{onClick:()=>k(""),children:l("subscription.cancel")}),e.jsx(Ys,{onClick:b,disabled:Q!==l("subscription.deleteConfirmText")||Y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Y?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),l("subscription.deleting")]}):l("subscription.deleteForever")})]})]})}),e.jsx(at,{open:oe,onOpenChange:Ve,children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:Xe==="dormant"?Te(f.language)?"Skift til dvale-abonnement?":"Switch to dormant plan?":Te(f.language)?"Opgradér til månedligt abonnement?":"Upgrade to monthly plan?"}),e.jsx(lt,{children:Xe==="dormant"?Te(f.language)?"Dvale-abonnementet koster 29 kr/md og giver kun adgang til login og din profil. Ændringen træder i kraft ved næste fakturer
279ing — du beholder fuld adgang resten af din nuværende periode. Du kan opgradere igen når som helst.":"The dormant plan costs 29 DKK/mo and only grants access to login and your profile. The change takes effect at next billing — you keep full access for the rest of your current period. You can upgrade again at any time.":Te(f.language)?"Du opgraderes til månedligt abonnement (99 kr/md) med fuld adgang. Ændringen træder i kraft ved næste fakturering — du beholder dvale-adgang indtil da.":"You will be upgraded to the monthly plan (99 DKK/mo) with full access. The change takes effect at next billing — you keep dormant access until then."})]}),e.jsxs(ot,{children:[e.jsx(ct,{disabled:me,children:Te(f.language)?"Fortryd":"Cancel"}),e.jsx(Ys,{onClick:hs,disabled:me,children:me?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),Te(f.language)?"Behandler...":"Processing..."]}):Xe==="dormant"?Te(f.language)?"Ja, skift til dvale":"Yes, switch to dormant":Te(f.language)?"Ja, opgradér":"Yes, upgrade"})]})]})}),e.jsx(at,{open:T,onOpenChange:ae,children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{className:"text-destructive",children:Te(f.language)?"Opsig abonnement?":"Cancel subscription?"}),e.jsxs(lt,{className:"space-y-3",children:[e.jsx("p",{children:Te(f.language)?"Er du sikker på, at du vil opsige dit abonnement?":"Are you sure you want to cancel your subscription?"}),e.jsx("p",{children:Te(f.language)?"Opsigelsen træder i kraft ved udløbet af din nuværende periode — du beholder fuld adgang indtil da. Herefter slettes din profil og alle data permanent efter den almindelige slette-frist.":"Cancellation takes effect at the end of your current period — you keep full access until then. After that, your profile and all data will be permanently deleted per the standard deletion policy."})]})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:l("subscription.cancel")}),e.jsx(Ys,{onClick:ps,disabled:he,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:he?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),Te(f.language)?"Opsiger...":"Cancelling..."]}):l("subscription.cancelButton")})]})]})}),e.jsx(ch,{open:$,onOpenChange:K})]})},bl={name:"",email:"",phone:"",linkedin:"",company:"",title:"",relationship:"",notes:"",contact_date:"",follow_up_date:"",can_help_with:[],priority:"medium"},mh=()=>{const{t:s,i18n:a}=Je(),[t,r]=i.useState(!1),[n,d]=i.useState(!1),[m,c]=i.useState(null),[l,f]=i.useState(!1),[p,j]=i.useState([]),[g,P]=i.useState(!0),[N,w]=i.useState(!1),[S,A]=i.useState(bl),[y,D]=i.useState(null),[B,M]=i.useState(""),[Y,R]=i.useState("all"),[Q,k]=i.useState("all"),$=["jobOpportunities","potentialEmployer","introductions","reference","mentor","industryInsight","startupOpportunities","advice"],K=T=>s(`network.helpOptions.${T}`);i.useEffect(()=>{re()},[]);const re=async()=>{try{const{data:{user:T}}=await C.auth.getUser();if(!T){P(!1);return}const{data:ae,error:me}=await C.from("network_contacts").select("*").order("created_at",{ascending:!1});if(me)throw me;j(ae||[])}catch(T){console.error("Error fetching contacts:",T),J.error(s("network.toast.couldNotFetch"))}finally{P(!1)}},ve=T=>{if(!T)return null;const ae=new Date;ae.setHours(0,0,0,0);const me=new Date(T);me.setHours(0,0,0,0);const Ae=Math.ceil((me.getTime()-ae.getTime())/(1e3*60*60*24));return Ae<0?{type:"overdue",days:Math.abs(Ae),label:s("network.daysOverdue",{days:Math.abs(Ae)})}:Ae===0?{type:"today",days:0,label:s("network.today")}:Ae<=3?{type:"soon",days:Ae,label:Ae===1?s("network.inDay",{days:Ae}):s("network.inDays",{days:Ae})}:Ae<=7?{type:"upcoming",days:Ae,label:s("network.inDays",{days:Ae})}:null},ze=i.useMemo(()=>p.filter(T=>{const ae=ve(T.follow_up_date);return ae&&(ae.type==="overdue"||ae.type==="today"||ae.type==="soon")}).sort((T,ae)=>{const me=new Date(T.follow_up_date||""),Ae=new Date(ae.follow_up_date||"");return me.getTime()-Ae.getTime()}),[p]),xe=i.useMemo(()=>p.filter(T=>{var ae,me,Ae,oe;if(B){const Ve=B.toLowerCase();if(!(T.name.toLowerCase().includes(Ve)||((ae=T.company)==null?void 0:ae.toLowerCase().includes(Ve))||((me=T.title)==null?void 0:me.toLowerCase().includes(Ve))||((Ae=T.email)==null?void 0:Ae.toLowerCase().includes(Ve))||((oe=T.relationship
279)==null?void 0:oe.toLowerCase().includes(Ve))))return!1}return!(Y!=="all"&&T.priority!==Y||Q!=="all"&&!(T.can_help_with||[]).includes(Q))}),[p,B,Y,Q]),I=T=>{switch(T){case"high":return e.jsxs(je,{className:"bg-amber-500/20 text-amber-700 border-amber-500/30",children:[e.jsx(Ps,{className:"w-3 h-3 mr-1"}),s("network.priorityHigh")]});case"medium":return e.jsx(je,{variant:"outline",children:s("network.priorityMedium")});case"low":return e.jsx(je,{variant:"secondary",children:s("network.priorityLow")});default:return null}},E=T=>{const ae=ve(T);if(!ae)return null;switch(ae.type){case"overdue":return e.jsxs(je,{className:"bg-destructive/20 text-destructive border-destructive/30",children:[e.jsx(wa,{className:"w-3 h-3 mr-1"}),ae.label]});case"today":return e.jsxs(je,{className:"bg-orange-500/20 text-orange-700 border-orange-500/30",children:[e.jsx(ra,{className:"w-3 h-3 mr-1"}),ae.label]});case"soon":return e.jsxs(je,{className:"bg-yellow-500/20 text-yellow-700 border-yellow-500/30",children:[e.jsx(ra,{className:"w-3 h-3 mr-1"}),ae.label]});default:return null}},F=async()=>{if(S.name.trim()){w(!0);try{const{data:{user:T}}=await C.auth.getUser();if(!T){J.error(s("network.toast.mustBeLoggedIn"));return}const{error:ae}=await C.from("network_contacts").insert({user_id:T.id,name:S.name.trim(),email:S.email||null,phone:S.phone||null,linkedin:S.linkedin||null,company:S.company||null,title:S.title||null,relationship:S.relationship||null,notes:S.notes||null,contact_date:S.contact_date||null,follow_up_date:S.follow_up_date||null,can_help_with:S.can_help_with,priority:S.priority});if(ae)throw ae;J.success(s("network.toast.contactAdded")),A(bl),r(!1),re()}catch(T){console.error("Error adding contact:",T),J.error(s("network.toast.couldNotAdd"))}finally{w(!1)}}},O=async()=>{if(!(!y||!y.name.trim())){w(!0);try{const{error:T}=await C.from("network_contacts").update({name:y.name.trim(),email:y.email||null,phone:y.phone||null,linkedin:y.linkedin||null,company:y.company||null,title:y.title||null,relationship:y.relationship||null,notes:y.notes||null,contact_date:y.contact_date||null,follow_up_date:y.follow_up_date||null,can_help_with:y.can_help_with,priority:y.priority}).eq("id",y.id);if(T)throw T;J.success(s("network.toast.contactUpdated")),D(null),d(!1),re()}catch(T){console.error("Error updating contact:",T),J.error(s("network.toast.couldNotUpdate"))}finally{w(!1)}}},ee=async T=>{try{const{error:ae}=await C.from("network_contacts").delete().eq("id",T);if(ae)throw ae;J.success(s("network.toast.contactDeleted")),j(p.filter(me=>me.id!==T))}catch(ae){console.error("Error deleting contact:",ae),J.error(s("network.toast.couldNotDelete"))}},Le=async T=>{const ae=!T.is_selected;j(me=>me.map(Ae=>Ae.id===T.id?{...Ae,is_selected:ae}:Ae));try{const{error:me}=await C.from("network_contacts").update({is_selected:ae}).eq("id",T.id);if(me)throw me;J.success(ae?js(a.language)?"Added to selected":"Tilføjet til udvalgte":js(a.language)?"Removed from selected":"Fjernet fra udvalgte")}catch(me){console.error("Error toggling selected:",me),j(Ae=>Ae.map(oe=>oe.id===T.id?{...oe,is_selected:!ae}:oe))}},pe=async(T,ae)=>{j(p.map(me=>me.id===T?{...me,notes:ae}:me));try{const{error:me}=await C.from("network_contacts").update({notes:ae}).eq("id",T);if(me)throw me}catch(me){console.error("Error updating notes:",me)}},Oe=(T,ae=!1)=>{if(ae&&y){const me=y.can_help_with||[];me.includes(T)?D({...y,can_help_with:me.filter(Ae=>Ae!==T)}):D({...y,can_help_with:[...me,T]})}else S.can_help_with.includes(T)?A({...S,can_help_with:S.can_help_with.filter(me=>me!==T)}):A({...S,can_help_with:[...S.can_help_with,T]})},he=T=>{D(T),d(!0)},we=T=>{var Ae;const ae=T?y:S,me=T?oe=>D(Ve=>Ve?{...Ve,...oe}:null):oe=>A(Ve=>({...Ve,...oe}));return ae?e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-name":"name",children:s("network.nameLabel")}),e.jsx(ue,{id:T?"edit-name":"name",value:ae.name||"",onChange:oe=>me({name:oe.target.value}),placeholder:s("network.namePlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-title":"title",children:s("network.titleLabel")}),e.jsx(ue,{id:T?"edit-title":"title",value:ae.title||"",onChange:oe=>me({title:oe.target.value}),placeholder:s("network.titlePlaceholder")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-company":"company",children:s("network.companyLabel")}),e.jsx(ue,{id:T?"edit-company":"company",value:ae.company||"",onChange:oe=>me({company:oe.target.value}),placeholder:s("network.companyPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-relationship":"relationship",children:s("network.relationLabel")}),e.jsx(ue,{id:T?"edit-relationship":"relationship",value:ae.relationship||"",onChange:oe=>me({relationship:oe.target.value}),placeholder:s("network.relationPlaceholder")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-linkedin":"linkedin",children:s("network.linkedinLabel")}),e.jsx(ue,{id:T?"edit-linkedin":"linkedin",value:ae.linkedin||"",onChange:oe=>me({linkedin:oe.target.value}),placeholder:"https://linkedin.com/in/..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-phone":"phone",children:s("network.phoneLabel")}),e.jsx(ue,{id:T?"edit-phone":"phone",value:ae.phone||"",onChange:oe=>me({phone:oe.target.value}),placeholder:"+45 12 34 56 78"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-email":"email",children:s("network.emailLabel")}),e.jsx(ue,{id:T?"edit-email":"email",type:"email",value:ae.email||"",onChange:oe=>me({email:oe.target.value}),placeholder:"[email protected]"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-contactDate":"contactDate",children:s("network.contactDateLabel")}),e.jsx(ue,{id:T?"edit-contactDate":"contactDate",type:"date",value:ae.contact_date||"",onChange:oe=>me({contact_date:oe.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-followUpDate":"followUpDate",children:s("network.followUpDateLabel")}),e.jsx(ue,{id:T?"edit-followUpDate":"followUpDate",type:"date",value:ae.follow_up_date||"",onChange:oe=>me({follow_up_date:oe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:s("network.priorityLabel")}),e.jsxs(Pt,{value:ae.priority||"medium",onValueChange:oe=>me({priority:oe}),children:[e.jsx(Ft,{children:e.jsx(At,{})}),e.jsxs(It,{children:[e.jsx(Ue,{value:"high",children:s("network.priorityHigh")}),e.jsx(Ue,{value:"medium",children:s("network.priorityMedium")}),e.jsx(Ue,{value:"low",children:s("network.priorityLow")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:s("network.c
279anHelpWith")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:$.map(oe=>{const Ve=K(oe);return e.jsx(je,{variant:(ae.can_help_with||[]).includes(oe)?"default":"outline",className:"cursor-pointer",onClick:()=>Oe(oe,T),children:Ve},oe)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:T?"edit-notes":"notes",children:s("network.notesLabel")}),e.jsx(as,{id:T?"edit-notes":"notes",value:ae.notes||"",onChange:oe=>me({notes:oe.target.value}),placeholder:s("network.notesPlaceholder"),rows:3})]}),e.jsxs(h,{className:"w-full",onClick:T?O:F,disabled:!((Ae=ae.name)!=null&&Ae.trim())||N,children:[N?e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(fs,{className:"w-4 h-4 mr-2"}),s(T?"network.saveChanges":"network.addContact")]})]}):null};return g?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-8 h-8 animate-spin text-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(ye,{className:"p-6 bg-gradient-to-r from-primary/5 to-primary/10 border-primary/20",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(tt,{className:"w-5 h-5 text-primary"}),s("network.title")]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s("network.subtitle")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{variant:l?"default":"outline",className:"gap-2",onClick:()=>f(!l),children:[e.jsx(Ps,{className:`w-4 h-4 ${l?"fill-current":""}`}),js(a.language)?"Selected contacts":"Udvalgte kontakter"]}),e.jsxs(ns,{open:t,onOpenChange:r,children:[e.jsx(Na,{asChild:!0,children:e.jsxs(h,{className:"gap-2",children:[e.jsx(Dl,{className:"w-4 h-4"}),s("network.addContact")]})}),e.jsxs(rs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsx(is,{children:s("network.addNewContact")})}),we(!1)]})]})]})]})}),l?e.jsxs("div",{className:"space-y-4",children:[e.jsxs(h,{variant:"ghost",className:"gap-2 text-sm",onClick:()=>f(!1),children:[e.jsx(_n,{className:"w-4 h-4"}),js(a.language)?"Back to all contacts":"Tilbage til alle kontakter"]}),e.jsx(fc,{embedded:!0})]}):e.jsxs(e.Fragment,{children:[ze.length>0&&e.jsxs(ye,{className:"p-4 bg-orange-50 dark:bg-orange-950/20 border-orange-200 dark:border-orange-800",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ra,{className:"w-5 h-5 text-orange-600"}),e.jsx("h3",{className:"font-semibold text-orange-800 dark:text-orange-200",children:s("network.followUpReminders")}),e.jsx(je,{variant:"secondary",className:"ml-auto",children:ze.length})]}),e.jsx("div",{className:"space-y-2",children:ze.map(T=>{const ae=ve(T.follow_up_date);return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-background/80 hover:bg-background cursor-pointer",onClick:()=>he(T),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-medium",children:T.name}),T.company&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["- ",T.company]})]}),ae&&E(T.follow_up_date)]},T.id)})})]}),e.jsxs(ye,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ut,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ue,{placeholder:s("network.searchPlaceholder"),value:B,onChange:T=>M(T.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Pt,{value:Y,onValueChange:R,children:[e.jsxs(Ft,{className:"w-[140px]",children:[e.jsx(Vl,{className:"w-4 h-4 mr-2"}),e.jsx(At,{placeholder:s("network.priorityLabel")})]}),e.jsxs(It,{children:[e.jsx(Ue,{value:"all",children:s("network.allPriorities")}),e.jsx(Ue,{value:"high",children:s("network.priorityHigh")}),e.jsx(Ue,{value:"medium",children:s("network.priorityMedium")}),e.jsx(Ue,{value:"low",children:s("network.priorityLow")})]})]}),e.jsxs(Pt,{value:Q,onValueChange:k,children:[e.jsx(Ft,{className:"w-[180px]",children:e.jsx(At,{placeholder:s("network.c
279anHelpWith")})}),e.jsxs(It,{children:[e.jsx(Ue,{value:"all",children:s("network.allCategories")}),$.map(T=>e.jsx(Ue,{value:T,children:K(T)},T))]})]})]})]}),(B||Y!=="all"||Q!=="all")&&e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("network.showingOf",{filtered:xe.length,total:p.length})}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>{M(""),R("all"),k("all")},children:s("network.resetFilters")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-primary",children:p.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("network.totalContacts")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-600",children:p.filter(T=>T.priority==="high").length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("network.highPriority")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-green-600",children:p.filter(T=>(T.can_help_with||[]).includes("potentialEmployer")).length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("network.potentialEmployers")})]}),e.jsxs(ye,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:p.filter(T=>(T.can_help_with||[]).includes("introductions")).length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("network.canIntroduce")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:s("network.yourContacts")}),xe.length===0?e.jsxs(ye,{className:"p-8 text-center",children:[e.jsx(tt,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),p.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground",children:s("network.noContactsYet")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("network.clickAddContact")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground",children:s("network.noContactsMatch")}),e.jsx(h,{variant:"outline",className:"mt-4",onClick:()=>{M(""),R("all"),k("all")},children:s("network.resetFilters")})]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:xe.map(T=>e.jsxs(ye,{className:"hover:shadow-lg transition-shadow",children:[e.jsx(Jt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(Yt,{className:"text-lg flex items-center gap-2",children:[T.name,T.priority==="high"&&e.jsx(Ps,{className:"w-4 h-4 text-amber-500 fill-amber-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:T.title})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Le(T),title:js(a.language)?T.is_selected?"Remove from selected":"Add to selected":T.is_selected?"Fjern fra udvalgte":"Tilføj til udvalgte",children:e.jsx(Ps,{className:`w-4 h-4 ${T.is_selected?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`})}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>he(T),children:e.jsx(Yr,{className:"w-4 h-4"})}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>ee(T.id),children:e.jsx(Ss,{className:"w-4 h-4"})})]})]})}),e.jsxs(yt,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[T.company&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ut,{className:"w-4 h-4"}),e.jsx("span",{children:T.company})]}),T.relationship&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ht,{className:"w-4 h-4"}),e.jsx("span",{children:T.relationship})]})]}),e.jsxs("div",{className:"space-y-2",children:[T.linkedin&&e.jsxs("a",{href:T.linkedin,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[e.jsx(Ms,{className:"w-4 h-4"}),s("network.linkedinProfile")]}),T.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(or,{className:"w-4 h-4"}),T.phone]}
279),T.email&&e.jsxs("a",{href:`mailto:${T.email}`,className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[e.jsx(ua,{className:"w-4 h-4"}),T.email]}),T.contact_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(gt,{className:"w-4 h-4"}),s("network.contacted")," ",new Date(T.contact_date).toLocaleDateString(Te(a.language)?"da-DK":"en-US")]}),T.follow_up_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(gt,{className:"w-4 h-4 text-primary"}),s("network.followUp")," ",new Date(T.follow_up_date).toLocaleDateString(Te(a.language)?"da-DK":"en-US"),e.jsx(Br,{title:`${s("network.followUp")}: ${T.name}${T.company?` (${T.company})`:""}`,date:T.follow_up_date,description:`${js(a.language)?"Follow up with":"Opfølgning med"} ${T.name}${T.company?` ${js(a.language)?"at":"hos"} ${T.company}`:""}`}),E(T.follow_up_date)&&e.jsx("span",{className:"ml-2",children:E(T.follow_up_date)})]})]}),(T.can_help_with||[]).length>0&&e.jsxs("div",{className:"p-3 rounded-md bg-muted/30",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:s("network.canHelpWith")}),e.jsx("div",{className:"flex flex-wrap gap-1",children:(T.can_help_with||[]).map((ae,me)=>e.jsx(je,{variant:"secondary",className:"text-xs",children:s(`network.helpOptions.${ae}`,ae)},me))})]}),e.jsxs(Mt,{open:m===T.id,onOpenChange:ae=>c(ae?T.id:null),children:[e.jsx($t,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center justify-between p-3 rounded-md bg-muted/50 hover:bg-muted transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:s("network.statusAndNotes")}),T.notes&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",T.notes.substring(0,30),T.notes.length>30?"...":"",")"]})]}),e.jsx(Ts,{className:`w-4 h-4 text-muted-foreground transition-transform ${m===T.id?"rotate-180":""}`})]})}),e.jsx(Rt,{className:"pt-3",children:e.jsx(as,{placeholder:s("network.notesSectionPlaceholder"),value:T.notes||"",onChange:ae=>pe(T.id,ae.target.value),className:"min-h-[100px]"})})]}),e.jsx("div",{className:"flex justify-end",children:I(T.priority)})]})]},T.id))})]}),e.jsx(ns,{open:n,onOpenChange:d,children:e.jsxs(rs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(os,{children:e.jsx(is,{children:s("network.editContact")})}),we(!0)]})})]})]})},La={direction:{energy_work:"",industries:"",target_level:""},current_position:{competencies:"",experience_summary:"",strengths:"",development_areas:""},goals_short:"",goals_mid:"",goals_long:"",competence_development:{professional_skills:"",leadership:"",industry_insight:"",network:""},actions:[],visibility_positioning:"",review_notes:[],is_ai_generated:!1,ai_source_data:[]},uh=[{key:"profile",labelKey:"careerPlan.sourceProfile",icon:"👤"},{key:"cv",labelKey:"careerPlan.sourceCV",icon:"📄"},{key:"linkedin",labelKey:"careerPlan.sourceLinkedIn",icon:"💼"},{key:"personality",labelKey:"careerPlan.sourcePersonality",icon:"🧠"},{key:"jobpreferences",labelKey:"careerPlan.sourceJobPrefs",icon:"❤️"},{key:"educations",labelKey:"careerPlan.sourceEducation",icon:"🎓"}],hh=()=>{const{t:s,i18n:a}=Je(),{toast:t}=Ct(),r=Pl(),n=$a(),[d,m]=i.useState([]),[c,l]=i.useState(null),[f,p]=i.useState(!0),[j,g]=i.useState(!1),[P,N]=i.useState(!1),[w,S]=i.useState(!1),[A,y]=i.useState(["profile","cv","personality","jobpreferences"]),[D,B]=i.useState(!0),[M,Y]=i.useState(""),[R,Q]=i.useState(null),[k,$]=i.useState(""),[K,re]=i.useState(!1),[ve,ze]=i.useState({}),[xe,I]=i.useState(null),[E,F]=i.useState(!1),[O,ee]=i.useState(!1),Le=(b,U)=>{var te;U.stopPropagation(),Q(b.id),$(b.title||((te=b.direction)==null?void 0:te.industries)||"Karriereplan")},pe=b=>{b==null||b.stopPropagation(),Q(null),$("")},Oe=async b=>{if(b==null||b.stopPropagation(),!R||!k.trim())return;re(!0);const{error:U}=await C.from("career_plans").update({title:k.trim()}).eq("id",R);U?t({title:s("common.error","Fejl"),description:U.message,variant:"destructive"}):(m(te=>te.map(fe=>fe.id===R?{...fe,title:k.trim()}:fe)),t({title:s("common.renamed","Omdøbt")}),Q(null),$("")),re(!1)};i.useEffect(()=>{(async()=>{const{data:{user:U}}=await C.auth.getUser();if(!U)return;const{data:te,error:fe}=await C.from("career_plans").select("*").eq("user_id",U.id).order("updated_at",{ascending:!1});if(te&&te.length>0){const Se=te.map(G=>({id:G.id,title:G.title||void 0,created_at:G.created_at||void 0,direction:G.direction||La.direction,current_position:G.current_position||La.current_position,goals_short:G.goals_short||"",goals_mid:G.goals_mid||"",goals_long:G.goals_long||"",competence_development:G.competence_development||La.competence_development,actions:G.actions||[],visibility_positioning:G.visibility_positioning||"",review_notes:G.review_notes||[],is_ai_generated:G.is_ai_generated||!1,ai_source_data:G.ai_source_data||[],last_reviewed_at:G.last_reviewed_at||void 0}));m(Se)}else B(!0);p(!1)})()},[]);const he=async()=>{g(!0);try{const{data:{session:b}}=await C.auth.getSession();if(!b)throw new Error("Not authenticated");const{data:U,error:te}=await C.functions.invoke("generate-career-plan",{body:{sources:A,language:a.language}}
279);if(te)throw te;if(U!=null&&U.plan){const fe={id:U.plan.id,direction:U.plan.direction||La.direction,current_position:U.plan.current_position||La.current_position,goals_short:U.plan.goals_short||"",goals_mid:U.plan.goals_mid||"",goals_long:U.plan.goals_long||"",competence_development:U.plan.competence_development||La.competence_development,actions:U.plan.actions||[],visibility_positioning:U.plan.visibility_positioning||"",review_notes:U.plan.review_notes||[],is_ai_generated:!0,ai_source_data:A};l(fe),m(Se=>[fe,...Se]),B(!1),t({title:s("careerPlan.generated","Karriereplan genereret!")})}}catch(b){console.error(b),t({title:s("careerPlan.generateError","Fejl ved generering"),description:b.message,variant:"destructive"})}finally{g(!1)}},we=async()=>{const{data:{user:b}}=await C.auth.getUser();if(!b)return;const U={...La},{data:te,error:fe}=await C.from("career_plans").insert([{user_id:b.id}]).select().single();if(te){const Se={...U,id:te.id};l(Se),m(G=>[Se,...G]),B(!1),S(!0),t({title:s("careerPlan.blankCreated","Karriereplan oprettet")})}else fe&&(console.error("createBlankPlan error:",fe),t({title:s("careerPlan.error","Fejl"),description:fe.message,variant:"destructive"}))},T=async()=>{if(c!=null&&c.id){N(!0);try{const b={direction:c.direction,current_position:c.current_position,goals_short:c.goals_short,goals_mid:c.goals_mid,goals_long:c.goals_long,competence_development:c.competence_development,actions:c.actions,visibility_positioning:c.visibility_positioning,review_notes:c.review_notes},{error:U}=await C.from("career_plans").update(b).eq("id",c.id);if(U)throw U;t({title:s("careerPlan.saved","Karriereplan gemt")}),S(!1)}catch(b){t({title:s("common.error","Fejl"),description:b.message,variant:"destructive"})}finally{N(!1)}}},ae=async b=>{const{error:U}=await C.from("career_plans").delete().eq("id",b);U||(m(te=>te.filter(fe=>fe.id!==b)),(c==null?void 0:c.id)===b&&(l(null),B(!0)),t({title:s("careerPlan.deleted","Karriereplan slettet")}))},me=()=>{c!=null&&c.id&&ae(c.id)},Ae=b=>{if(!c)return;const U=[...c.actions];U[b]={...U[b],completed:!U[b].completed},l({...c,actions:U})},oe=()=>{c&&l({...c,actions:[...c.actions,{category:"",action:"",timeline:"",completed:!1}]})},Ve=async()=>{if(!(!c||c.actions.length>0&&!await r({title:s("careerPlan.sammySuggestActionsConfirmTitle","Skal Sammy tilføje forslag til handlinger?"),description:s("careerPlan.sammySuggestActionsConfirmDesc","Sammy foreslår 5-7 konkrete handlinger baseret på din plan og baggrund. De TILFØJES til dine eksisterende handlinger — intet bliver slettet."),confirmLabel:s("careerPlan.sammySuggestActionsConfirm","Foreslå handlinger"),cancelLabel:s("common.cancel","Annullér")}))){ee(!0);try{const U={direction:c.direction,current_position:c.current_position,goals_short:c.goals_short,goals_mid:c.goals_mid,goals_long:c.goals_long,competence_development:c.competence_development,visibility_positioning:c.visibility_positioning},{data:te,error:fe}=await C.functions.invoke("suggest-career-plan-actions",{body:{plan:U,existingActions:c.actions.map(G=>({category:G.category,action:G.action,timeline:G.timeline})),count:6,language:a.language}}
279);if(fe)throw fe;if(!(te!=null&&te.ok))throw new Error((te==null?void 0:te.error)||"AI fejlede");const Se=(te.actions||[]).map(G=>({category:G.category||"",action:G.action||"",timeline:G.timeline||"",completed:!1}));if(Se.length===0){t({title:s("careerPlan.sammySuggestActionsNone","Sammy fandt ingen nye forslag"),description:s("careerPlan.sammySuggestActionsNoneDesc","Prøv at udfylde mere af planen først.")});return}l({...c,actions:[...c.actions,...Se]}),t({title:s("careerPlan.sammySuggestActionsDone","Sammy tilføjede {{count}} handlinger",{count:Se.length}),description:s("careerPlan.sammySuggestActionsDoneDesc","Du kan redigere eller slette dem — husk at gemme planen.")})}catch(U){console.error("suggestActionsWithSammy error",U),t({title:s("careerPlan.sammySuggestActionsError","Sammy kunne ikke foreslå handlinger"),description:(U==null?void 0:U.message)||String(U),variant:"destructive"})}finally{ee(!1)}}},Xe=b=>{c&&l({...c,actions:c.actions.filter((U,te)=>te!==b)})},cs=()=>{if(!c||!M.trim())return;const b={date:new Date().toISOString().split("T")[0],note:M.trim()};l({...c,review_notes:[b,...c.review_notes]}),Y("")},hs=(b,U)=>{if(!c)return;const te=b.split(".");if(te.length===1)l({...c,[te[0]]:U});else if(te.length===2){const fe=te[0],Se=c[fe];l({...c,[fe]:{...Se,[te[1]]:U}})}},ps=b=>{var U,te,fe,Se,G,Fe,Ee,qe,Ge,He,Ze;return b?{"direction.energy_work":((U=b.direction)==null?void 0:U.energy_work)||"","direction.industries":((te=b.direction)==null?void 0:te.industries)||"","direction.target_level":((fe=b.direction)==null?void 0:fe.target_level)||"","current_position.competencies":((Se=b.current_position)==null?void 0:Se.competencies)||"","current_position.experience_summary":((G=b.current_position)==null?void 0:G.experience_summary)||"","current_position.strengths":((Fe=b.current_position)==null?void 0:Fe.strengths)||"","current_position.development_areas":((Ee=b.current_position)==null?void 0:Ee.development_areas)||"",goals_short:b.goals_short||"",goals_mid:b.goals_mid||"",goals_long:b.goals_long||"","competence_development.professional_skills":((qe=b.competence_development)==null?void 0:qe.professional_skills)||"","competence_development.leadership":((Ge=b.competence_development)==null?void 0:Ge.leadership)||"","competence_development.industry_insight":((He=b.competence_development)==null?void 0:He.industry_insight)||"","competence_development.network":((Ze=b.competence_development)==null?void 0:Ze.network)||"",visibility_positioning:b.visibility_positioning||""}:{}},ms=()=>c!=null&&c.id?ve[c.id]||new Set:new Set,De=b=>{c!=null&&c.id&&ze(U=>{const te=new Set(U[c.id]||[]);return te.add(b),{...U,[c.id]:te}})},_=async(b,U,te,fe)=>{if(c){I(b);try{const Se=b.includes(".")?b.split(".").pop():b,G=z(b),Fe=ps(c),{data:Ee,error:qe}=await C.functions.invoke("complete-career-plan-field",{body:{sectionKey:U,fieldKey:Se,fieldPath:b,fieldLabel:fe,sectionTitle:te,currentValue:G,otherFields:Fe,language:a.language}}
279);if(qe)throw qe;if(!(Ee!=null&&Ee.ok))throw new Error((Ee==null?void 0:Ee.error)||"AI fejlede");const Ge=(Ee.suggestion||"").trim();if(!Ge)throw new Error("Tomt svar fra AI");hs(b,Ge),De(b),t({title:s("careerPlan.sammyFieldDone","Sammy færdiggjorde feltet")})}catch(Se){console.error("completeOneFieldWithSammy error",Se),t({title:s("careerPlan.sammyFieldError","Sammy kunne ikke færdiggøre feltet"),description:(Se==null?void 0:Se.message)||String(Se),variant:"destructive"})}finally{I(null)}}},Z=async()=>{var b,U,te,fe,Se,G,Fe,Ee,qe,Ge,He;if(c){F(!0);try{const Ze=Array.from(ms()),Us={direction:c.direction,current_position:c.current_position,goals_short:c.goals_short,goals_mid:c.goals_mid,goals_long:c.goals_long,competence_development:c.competence_development,visibility_positioning:c.visibility_positioning},{data:le,error:X}=await C.functions.invoke("complete-career-plan-draft",{body:{plan:Us,skipPaths:Ze,language:a.language}});if(X)throw X;if(!(le!=null&&le.ok))throw new Error((le==null?void 0:le.error)||"AI fejlede");const L=le.plan||{},ce=new Set(Ze),ys={...c,direction:{energy_work:ce.has("direction.energy_work")?c.direction.energy_work:((b=L.direction)==null?void 0:b.energy_work)??c.direction.energy_work,industries:ce.has("direction.industries")?c.direction.industries:((U=L.direction)==null?void 0:U.industries)??c.direction.industries,target_level:ce.has("direction.target_level")?c.direction.target_level:((te=L.direction)==null?void 0:te.target_level)??c.direction.target_level},current_position:{competencies:ce.has("current_position.competencies")?c.current_position.competencies:((fe=L.current_position)==null?void 0:fe.competencies)??c.current_position.competencies,experience_summary:ce.has("current_position.experience_summary")?c.current_position.experience_summary:((Se=L.current_position)==null?void 0:Se.experience_summary)??c.current_position.experience_summary,strengths:ce.has("current_position.strengths")?c.current_position.strengths:((G=L.current_position)==null?void 0:G.strengths)??c.current_position.strengths,development_areas:ce.has("current_position.development_areas")?c.current_position.development_areas:((Fe=L.current_position)==null?void 0:Fe.development_areas)??c.current_position.development_areas},goals_short:ce.has("goals_short")?c.goals_short:L.goals_short??c.goals_short,goals_mid:ce.has("goals_mid")?c.goals_mid:L.goals_mid??c.goals_mid,goals_long:ce.has("goals_long")?c.goals_long:L.goals_long??c.goals_long,competence_development:{professional_skills:ce.has("competence_development.professional_skills")?c.competence_development.professional_skills:((Ee=L.competence_development)==null?void 0:Ee.professional_skills)??c.competence_development.professional_skills,leadership:ce.has("competence_development.leadership")?c.competence_development.leadership:((qe=L.competence_development)==null?void 0:qe.leadership)??c.competence_development.leadership,industry_insight:ce.has("competence_development.industry_insight")?c.competence_development.industry_insight:((Ge=L.competence_development)==null?void 0:Ge.industry_insight)??c.competence_development.industry_insight,network:ce.has("competence_development.network")?c.competence_development.network:((He=L.competence_development)==null?void 0:He.network)??c.competence_development.network},visibility_positioning:ce.has("visibility_positioning")?c.visibility_positioning:L.visibility_positioning??c.visibility_positioning};
279l(ys),t({title:s("careerPlan.sammyBulkDone","Sammy færdiggjorde planen"),description:Ze.length>0?s("careerPlan.sammyBulkSkipped","{{count}} felter du allerede havde færdiggjort blev ikke rørt.",{count:Ze.length}):void 0})}catch(Ze){console.error("completeWholePlanWithSammy error",Ze),t({title:s("careerPlan.sammyBulkError","Sammy kunne ikke færdiggøre planen"),description:(Ze==null?void 0:Ze.message)||String(Ze),variant:"destructive"})}finally{F(!1)}}},H=(c==null?void 0:c.actions.filter(b=>b.completed).length)||0,ne=(c==null?void 0:c.actions.length)||0;if(f)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"w-6 h-6 animate-spin text-primary"})});if(D)return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center",children:e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>n("/dashboard"),className:"text-muted-foreground hover:text-foreground -ml-2",children:[e.jsx(_n,{className:"h-4 w-4 mr-1"}),s("careerPlan.backToDashboard","Tilbage til Dashboard")]})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:s("careerPlan.title","Karriereplan")}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s("careerPlan.subtitle","En struktureret ramme der hjælper dig med at træffe bedre karrierebeslutninger over tid.")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(ye,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Jt,{children:[e.jsxs(Yt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(xs,{className:"w-5 h-5 text-primary"}),s("careerPlan.aiGenerate","Lad AI lave et udkast")]}),e.jsx(Mi,{children:s("careerPlan.aiGenerateDesc","Få et personligt forslag baseret på dine data – du kan altid redigere bagefter.")})]}),e.jsxs(yt,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("careerPlan.selectSources","Vælg datakilder:")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:uh.map(b=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx(Kt,{checked:A.includes(b.key),onCheckedChange:U=>{y(te=>U?[...te,b.key]:te.filter(fe=>fe!==b.key))}}),e.jsxs("span",{children:[b.icon," ",s(b.labelKey,b.key)]})]},b.key))})]}),e.jsx(h,{onClick:he,disabled:j||A.length===0,className:"w-full",children:j?e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 mr-2 animate-spin"}),s("careerPlan.generating","Genererer...")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"w-4 h-4 mr-2"}),s("careerPlan.generateBtn","Generér karriereplan")]})})]})]}),e.jsxs(ye,{children:[e.jsxs(Jt,{children:[e.jsxs(Yt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(ya,{className:"w-5 h-5"}),s("careerPlan.manualCreate","Lav din egen")]}),e.jsx(Mi,{children:s("careerPlan.manualCreateDesc","Start med en tom skabelon og udfyld sektionerne selv.")})]}),e.jsx(yt,{children:e.jsxs(h,{variant:"outline",onClick:we,className:"w-full",children:[e.jsx(ya,{className:"w-4 h-4 mr-2"}),s("careerPlan.startBlank","Start tom karriereplan")]})})]})]}),d.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground",children:[s("careerPlan.savedPlans","Dine karriereplaner")," (",d.length,")"]}),d.map((b,U)=>{var qe,Ge;
279const te=(b.actions||[]).filter(He=>He.completed).length,fe=(b.actions||[]).length,Se=d.length-U,G=U===0,Fe=R===b.id,Ee=b.title||((qe=b.direction)==null?void 0:qe.industries)||((Ge=b.goals_short)==null?void 0:Ge.substring(0,50))||s("careerPlan.untitled","Karriereplan");return e.jsx(ye,{className:"border-primary/20 hover:border-primary/40 transition-colors cursor-pointer",onClick:()=>{Fe||(l(b),B(!1))},children:e.jsxs(yt,{className:"flex items-center justify-between py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx($s,{className:"w-5 h-5 text-primary shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[Fe?e.jsxs("div",{className:"flex items-center gap-1",onClick:He=>He.stopPropagation(),children:[e.jsx(ue,{value:k,onChange:He=>$(He.target.value),onKeyDown:He=>{He.key==="Enter"&&Oe(),He.key==="Escape"&&pe()},autoFocus:!0,className:"h-7 text-sm"}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-primary",disabled:K||!k.trim(),onClick:He=>Oe(He),children:K?e.jsx(ge,{className:"w-3 h-3 animate-spin"}):e.jsx(Et,{className:"w-3 h-3"})}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:He=>pe(He),children:e.jsx(mt,{className:"w-3 h-3"})})]}):e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground shrink-0",children:["#",Se]}),e.jsx("span",{className:"font-medium text-foreground truncate",children:Ee}),G&&e.jsx(je,{variant:"default",className:"text-[10px] h-4 px-1.5",children:s("common.latest","Seneste")}),b.is_ai_generated&&e.jsxs(je,{variant:"secondary",className:"text-xs",children:[e.jsx(xs,{className:"w-3 h-3 mr-1"})," AI"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[b.created_at&&e.jsx("span",{children:new Date(b.created_at).toLocaleString(a.language)}),fe>0&&e.jsxs("span",{children:[te,"/",fe," ",s("careerPlan.actionsCompleted","handlinger udført")]}),b.last_reviewed_at&&e.jsxs("span",{children:[s("careerPlan.lastReviewed","Senest gennemgået"),": ",new Date(b.last_reviewed_at).toLocaleDateString("da-DK")]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[!Fe&&e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground",onClick:He=>Le(b,He),title:s("common.rename","Omdøb"),children:e.jsx(Ma,{className:"w-4 h-4"})}),e.jsxs(at,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:He=>He.stopPropagation(),children:e.jsx(Ss,{className:"w-4 h-4"})})}),e.jsxs(nt,{onClick:He=>He.stopPropagation(),children:[e.jsxs(rt,{children:[e.jsx(it,{children:s("careerPlan.deleteConfirmTitle","Slet karriereplan?")}),e.jsx(lt,{children:s("careerPlan.deleteConfirmDesc","Denne handling kan ikke fortrydes. Karriereplanen slettes permanent.")})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:s("careerPlan.cancel","Annuller")}),e.jsx(Ys,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>ae(b.id),children:s("careerPlan.deleteConfirm","Slet")})]})]})]})]})]})},b.id)})]})]});const x=[{key:"direction",icon:sc,title:s("careerPlan.sec1Title","1. Retning"),hint:s("careerPlan.sec1Hint","Hvad vil du? Tænk i retning frem for endemål."),fields:[{path:"direction.energy_work",label:s("careerPlan.energyWork","Hvilken type arbejde giver dig energi?")},{path:"direction.industries",label:s("careerPlan.industries","Brancher eller funktioner der tiltaler dig")},{path:"direction.target_level",label:s("careerPlan.targetLevel","Niveau du sigter mod")}]},{key:"current_position",icon:ia,title:s("careerPlan.sec2Title","2. Nuværende position"),hint:s("careerPlan.sec2Hint","Hvor står du? Lav en ærlig status."),fields:[{path:"current_position.competencies",label:s("careerPlan.competencies","Kompetencer (faglige + personlige)")},{path:"current_position.experience_summary",label:s("careerPlan.experience","Erfaring")},{path:"current_position.strengths",label:s("careerPlan.strengths","Styrker")},{path:"current_position.development_areas",label:s("careerPlan.devAreas","Udviklingsområder")}]},{key:"goals",icon:ka,title:s("careerPlan.sec3Title","3. Mål"),hint:s("careerPlan.sec3Hint","Opdel i tidshorisonter. Hold målene realistiske og justerbare."),fields:[{path:"goals_short",label:s("careerPlan.goalsShort","Kort sigt (0-1 år)")},{path:"goals_mid",label:s("careerPlan.goalsMid","Mellem sigt (1-3 år)")},{path:"goals_long",label:s("careerPlan.goalsLong","Lang sigt (3-5+ år)")}]},{key:"competence",icon:Al,title:s("careerPlan.sec4Title","4. Kompetenceudvikling"),hint:s("careerPlan.sec4Hint",'Hvad mangler du? Vær konkret: "blive bedre til strategi" → "lede 2 strategiprojekter".'),fields:[{path:"competence_development.professional_skills",label:s("careerPlan.profSkills","Faglige skills")},{path:"competence_development.leadership",label:s("careerPlan.leadership","Ledelseskompetencer")},{path:"competence_development.industry_insight",label:s("careerPlan.industryInsight","Brancheindsigt")},{path:"competence_development.network",label:s("careerPlan.network","Netværk")}]}],z=b=>{var te;const U=b.split(".");return U.length===1?c[U[0]]||"":((te=c[U[0]])==null?void 0:te[U[1]])||""};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(h,{size:"sm",variant:"ghost",onClick:()=>{l(null),B(!0)},className:"text-muted-foreground hover:text-foreground",children:["← ",s("common.back","Tilbage")]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:s("careerPlan.title","Karriereplan")}),e.jsxs("p",{className:"text-muted-foreground mt-1",children:[c.is_ai_generated&&e.jsxs(je,{variant:"secondary",className:"mr-2 text-xs",children:[e.jsx(xs,{className:"w-3 h-3 mr-1"})," AI"]}),s("careerPlan.subtitle","En struktureret ramme der hjælper dig med at træffe bedre karrierebeslutninger over tid.")]})]})]}),e.jsx("div",{className:"flex gap-2 flex-shrink-0",children:w?e.jsxs(e.Fragment,{children:[e.jsxs(h,{size:"sm",variant:"outline",onClick:Z,disabled:E||!!xe,title:s("careerPlan.bulkSammyTooltip","Sammy udfylder tomme felter og forfiner det du har skrevet. Felter du allerede har færdiggj
279ort enkeltvis rører hun ikke."),children:[E?e.jsx(ge,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Va,{className:"w-4 h-4 mr-1"}),s("careerPlan.bulkSammy","Færdiggør med Sammy")]}),e.jsxs(h,{size:"sm",onClick:T,disabled:P,children:[P?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(zs,{className:"w-4 h-4 mr-1"}),s("common.save","Gem")]}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:s("common.cancel","Annullér")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(h,{size:"sm",variant:"outline",onClick:()=>S(!0),children:[e.jsx(ya,{className:"w-4 h-4 mr-1"})," ",s("common.edit","Rediger")]}),e.jsxs(h,{size:"sm",variant:"outline",onClick:he,disabled:j,children:[j?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(dt,{className:"w-4 h-4 mr-1"}),s("careerPlan.regenerate","Regenerér")]}),e.jsx(h,{size:"sm",variant:"ghost",className:"text-destructive",onClick:me,children:e.jsx(Ss,{className:"w-4 h-4"})})]})})]}),ne>0&&e.jsx(ye,{className:"bg-primary/5 border-primary/20",children:e.jsxs(yt,{className:"py-3 px-4 flex items-center gap-3",children:[e.jsx($s,{className:"w-5 h-5 text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"font-medium",children:s("careerPlan.actionsProgress","Handlinger")}),e.jsxs("span",{className:"text-muted-foreground",children:[H,"/",ne]})]}),e.jsx("div",{className:"h-2 rounded-full bg-primary/10 overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${ne>0?H/ne*100:0}%`}})})]})]})}),e.jsxs(Ul,{type:"multiple",defaultValue:["direction","goals"],className:"space-y-3",children:[x.map(b=>e.jsxs(mn,{value:b.key,className:"border rounded-lg px-4",children:[e.jsx(un,{className:"hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b.icon,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-semibold",children:b.title})]})}),e.jsxs(hn,{className:"space-y-4 pt-2 pb-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground italic",children:["💡 ",b.hint]}),b.fields.map(U=>{const te=ms().has(U.path),fe=xe===U.path;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1 gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:U.label}),w&&e.jsx(Ya,{delayDuration:200,children:e.jsxs(Gs,{children:[e.jsx(qs,{asChild:!0,children:e.jsxs(h,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-primary hover:text-primary",onClick:()=>_(U.path,b.key,b.title,U.label),disabled:fe||E,children:[fe?e.jsx(ge,{className:"w-3 h-3 animate-spin"}):e.jsx(la,{className:"w-3 h-3"}),te?s("careerPlan.sammyRefine","Kør Sammy igen"):s("careerPlan.sammyField","Færdiggør med Sammy")]})}),e.jsx(Js,{side:"left",className:"max-w-xs",children:te?s("careerPlan.sammyFieldDoneHint","Du har færdiggjort dette felt med Sammy. Bulk-knappen rører det ikke. Klik for at køre Sammy igen."):s("careerPlan.sammyFieldHint","Sammy udvider eller udfylder dette felt baseret på dit CV og din profil.")})]})})]}),w?e.jsx(as,{value:z(U.path),onChange:Se=>hs(U.path,Se.target.value),className:"min-h-[80px]"}):e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap bg-muted/50 rounded-md p-3 min-h-[40px]",children:z(U.path)||e.jsx("span",{className:"text-muted-foreground italic",children:s("careerPlan.notFilled","Ikke udfyldt endnu")})})]},U.path)})]})]},b.key)),e.jsxs(mn,{value:"actions",className:"border rounded-lg px-4",children:[e.jsx(un,{className:"hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(rr,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-semibold",children:s("careerPlan.sec5Title","5. Handlinger")}),ne>0&&e.jsxs(je,{variant:"outline",className:"ml-2",children:[H,"/",ne]})]})}),e.jsxs(hn,{className:"space-y-3 pt-2 pb-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground italic",children:["💡 ",s("careerPlan.sec5Hint","Planen dør uden handling. Tænk i adfærd – ikke intention.")]}),c.actions.map((b,U)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-muted/30 border",children:[e.jsx(Kt,{checked:b.completed,onCheckedChange:()=>Ae(U),className:"mt-1"}),e.jsx("div",{className:"flex-1 min-w-0",children:w?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{className:"w-full text-sm bg-background border rounded px-2 py-1",placeholder:s("careerPlan.actionCategory","Kategori"),value:b.category,onChange:te=>{const fe=[...c.actions];fe[U]={...fe[U],category:te.target.value},l({...c,actions:fe})}}
279),e.jsx(as,{className:"min-h-[60px]",placeholder:s("careerPlan.actionDesc","Handling"),value:b.action,onChange:te=>{const fe=[...c.actions];fe[U]={...fe[U],action:te.target.value},l({...c,actions:fe})}}),e.jsx("input",{className:"w-full text-sm bg-background border rounded px-2 py-1",placeholder:s("careerPlan.actionTimeline","Tidslinje"),value:b.timeline,onChange:te=>{const fe=[...c.actions];fe[U]={...fe[U],timeline:te.target.value},l({...c,actions:fe})}})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[b.category&&e.jsx(je,{variant:"outline",className:"text-xs",children:b.category}),b.timeline&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(gt,{className:"w-3 h-3"})," ",b.timeline]})]}),e.jsx("p",{className:`text-sm mt-1 ${b.completed?"line-through text-muted-foreground":""}`,children:b.action})]})}),w&&e.jsx(h,{size:"icon",variant:"ghost",className:"shrink-0",onClick:()=>Xe(U),children:e.jsx(Ss,{className:"w-4 h-4 text-destructive"})})]},U)),w&&e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:oe,children:[e.jsx(fs,{className:"w-4 h-4 mr-1"})," ",s("careerPlan.addAction","Tilføj handling")]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:Ve,disabled:O,className:"text-primary border-primary/40 hover:bg-primary/5",children:[O?e.jsx(ge,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Va,{className:"w-4 h-4 mr-1"}),s("careerPlan.sammySuggestActionsBtn","Skal Sammy tilføje forslag til handlinger?")]})]})]})]}),e.jsxs(mn,{value:"visibility",className:"border rounded-lg px-4",children:[e.jsx(un,{className:"hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ht,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-semibold",children:s("careerPlan.sec6Title","6. Synlighed og positionering")})]})}),e.jsxs(hn,{className:"space-y-4 pt-2 pb-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground italic",children:["💡 ",s("careerPlan.sec6Hint","Karriere handler ikke kun om at være dygtig – men også om at blive opfattet som det.")]}),w&&(()=>{const b="visibility_positioning",U=ms().has(b),te=xe===b;return e.jsx("div",{className:"flex justify-end",children:e.jsxs(h,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs gap-1 text-primary hover:text-primary",onClick:()=>_(b,"visibility",s("careerPlan.sec6Title","6. Synlighed og positionering"),s("careerPlan.sec6Title","Synlighed og positionering")),disabled:te||E,children:[te?e.jsx(ge,{className:"w-3 h-3 animate-spin"}):e.jsx(la,{className:"w-3 h-3"}),U?s("careerPlan.sammyRefine","Kør Sammy igen"):s("careerPlan.sammyField","Færdiggør med Sammy")]})})})(),w?e.jsx(as,{value:c.visibility_positioning,onChange:b=>l({...c,visibility_positioning:b.target.value}),className:"min-h-[100px]"}):e.jsx("p",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3 min-h-[40px]",children:c.visibility_positioning||e.jsx("span",{className:"text-muted-foreground italic",children:s("careerPlan.notFilled","Ikke udfyldt endnu")})})]})]}),e.jsxs(mn,{value:"review",className:"border rounded-lg px-4",children:[e.jsx(un,{className:"hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(dt,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-semibold",children:s("careerPlan.sec7Title","7. Review og justering")})]})}),e.jsxs(hn,{className:"space-y-4 pt-2 pb-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground italic",children:["💡 ",s("careerPlan.sec7Hint","Evaluér hver 3-6 måned. Justering er et tegn på refleksion – ikke fiasko.")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(as,{value:M,onChange:b=>Y(b.target.value),placeholder:s("careerPlan.reviewPlaceholder","Tilføj en review-note..."),className:"min-h-[60
279px]"}),e.jsx(h,{size:"sm",onClick:cs,disabled:!M.trim(),className:"self-end",children:e.jsx(fs,{className:"w-4 h-4"})})]}),c.review_notes.length>0?e.jsx("div",{className:"space-y-2",children:c.review_notes.map((b,U)=>e.jsxs("div",{className:"text-sm p-3 bg-muted/50 rounded-md border-l-2 border-primary/30",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:b.date}),e.jsx("p",{className:"mt-1",children:b.note})]},U))}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:s("careerPlan.noReviews","Ingen review-noter endnu.")})]})]})]}),w&&e.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t",children:[e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:s("common.cancel","Annullér")}),e.jsxs(h,{size:"sm",onClick:T,disabled:P,children:[P?e.jsx(ge,{className:"w-4 h-4 animate-spin"}):e.jsx(zs,{className:"w-4 h-4 mr-1"}),s("common.save","Gem")]})]})]})},xh=()=>{var M,Y;const{t:s,i18n:a}=Je(),t=Te(a.language)?ir:Sn,r=Te(a.language),n=r?"":"_en",{documents:d,getDocumentsByType:m,saveDocumentAsCopy:c,saveDocument:l,deleteDocument:f}=Xa(),{cvs:p}=lr(),[j,g]=i.useState(!1),[P,N]=i.useState(null),[w,S]=i.useState(null),A=[...m("cv_feedback"),...m("cv_feedback_en")].filter(R=>R==null?void 0:R.content).sort((R,Q)=>(Q.updated_at||"").localeCompare(R.updated_at||"")),y=[...m("cv"),...m("cv_en")].filter(R=>R==null?void 0:R.content).sort((R,Q)=>(Q.updated_at||"").localeCompare(R.updated_at||"")).map(R=>({id:R.id,title:`${R.title}${R.document_type==="cv_en"?" (EN)":""}`,content:R.content,updated_at:R.updated_at})),D=((M=d.find(R=>R.document_type===`cv${n}`))==null?void 0:M.content)||((Y=d.find(R=>R.document_type==="cv"))==null?void 0:Y.content),B=async R=>{S(R.id);try{const{createRoot:Q}=await ma(async()=>{const{createRoot:re}=await import("./index-7TyBHU2Z.js").then(ve=>ve.c);return{createRoot:re}},__vite__mapDeps([1,2])),{exportElementAsPdf:k}=await ma(async()=>{const{exportElementAsPdf:re}=await import("./paginateAndExport-DmOgoqOK.js");return{exportElementAsPdf:re}},__vite__mapDeps([0,1,2])),$=document.createElement("div");$.style.position="fixed",$.style.left="-99999px",$.style.top="0",$.style.width="794px",$.style.background="#ffffff",document.body.appendChild($);const K=Q($);await new Promise(re=>{K.render(e.jsx("div",{"data-pdf-break":"section",style:{width:794,padding:72,fontFamily:"Roboto, Arial, sans-serif",whiteSpace:"pre-wrap",color:"#333",lineHeight:1.6},children:bt(R.content)})),requestAnimationFrame(()=>requestAnimationFrame(()=>re()))}),await new Promise(re=>setTimeout(re,300)),await k({host:$,fileName:ad(R.title),bleedSidebar:!1,safeZoneMm:12,docType:"cv"}),K.unmount(),$.remove(),J.success(s("careerDocs.pdfDownloaded","PDF downloadet"))}catch(Q){console.error(Q),J.error(s("careerDocs.pdfExportError","Kunne ikke eksportere PDF"))}finally{S(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold text-foreground flex items-center gap-3",children:[e.jsx(Xn,{className:"w-7 h-7 text-primary"}),s("cvFeedbackPage.title",r?"Feedback på CV":"CV feedback")]}),e.jsx("p",{className:"text-muted-foreground mt-2 max-w-2xl",children:s("cvFeedbackPage.subtitle",r?"Få AI-drevet feedback på dine CV'er og se alle gemte feedback-rapporter samlet ét sted.":"Get AI-powered feedback on your CVs and view all saved reports in one place.")})]}),e.jsxs(h,{size:"lg",className:"gap-2 shrink-0",onClick:()=>g(!0),children:[e.jsx(fs,{className:"w-4 h-4"}),s("cvFeedbackPage.newFeedback",r?"Få ny feedback":"Get new feedback")]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-3",children:s("cvFeedbackPage.savedHeading",r?"Gemte feedback-rapporter":"Saved feedback reports")}),A.length===0?e.jsxs(ye,{className:"p-8 text-center",children:[e.jsx(Xn,{className:"w-12 h-12 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:s("cvFeedbackPage.empty",r?"Du har endnu ikke gemt nogen feedback. Klik på 'Få ny feedback' for at komme i gang.":"You haven't saved any feedback yet. Click 'Get new feedback' to start.")})]}):e.jsx("div",{className:"space-y-2",children:A.map(R=>{const Q=P===R.id;return e.jsxs(ye,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 p-4",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-3 flex-1 min-w-0 text-left",onClick:()=>N(Q?null:R.id),children:[e.jsx(Fs,{className:"w-5 h-5 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground truncate",children:[R.title,R.document_type==="cv_feedback_en"?" (EN)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_s(new Date(R.updated_at),"d. MMM yyyy",{locale:t})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(h,{size:"sm",variant:"ghost",className:"h-8 px-2 text-xs gap-1",onClick:()=>B(R),disabled:w===R.id,title:"Download PDF",children:[w===R.id?e.jsx(ge,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Qt,{className:"w-3.5 h-3.5"}),"PDF"]}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-8 px-2 text-xs",onClick:()=>N(Q?null:R.id),children:Q?s("careerDocs.hide",{defaultValue:"Skjul"}):s("careerDocs.show",{defaultValue:"Vis"})}),e.jsxs(at,{children:[e.jsx(Ea,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive h-8 w-8 p-0",children:e.jsx(Ss,{className:"w-3.5 h-3.5"})})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(it,{children:s("careerDocs.deleteDocTitle","Slet dokument?")}),e.jsx(lt,{children:r?`Er du sikker på, at du vil slette "${R.title}"?`:`Are you sure you want to delete "${R.title}"?`})]}),e.jsxs(ot,{children:[e.jsx(ct,{children:s("careerDocs.cancel","Annuller")}),e.jsx(Ys,{onClick:()=>{P===R.id&&N(null),f(R.id)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:r?"Slet":"Delete"})]})]})]})]})]}),Q&&e.jsx("div",{className:"px-4 pb-4 pt-1 border-t border-border/40",children:e.jsx("div",{className:"p-4 bg-muted/30 rounded-lg",children:e.jsx(Or,{text:bt(R.content)})})})]},R.id)})})]}),e.jsx(io,{generatedCVContent:D,savedCVs:y,uploadedCVs:p,controlledOpen:j,onControlledOpenChange:g,onSaveFeedback:async R=>{const Q=await c(`cv_feedback${n}`,s("cvFeedbackDialog.title",r?"Feedback på CV":"CV feedback"),R);return Q&&J.success(s("careerDocs.cvFeedbackSaved","Feedback gemt under 'Feedback på dit CV'.")),Q},onApplyImprovements:async(R,Q)=>await l(`cv${n}`,"CV",R,void 0,Q)})]})},Jx=()=>{const{t:s}
279=Je(),a=$a();Ct();const[t,r]=tc(),n=t.get("tab")||"karriereprofil",[d,m]=i.useState(n),[c,l]=i.useState(!0),[f,p]=i.useState(!1),[j,g]=i.useState(null);i.useEffect(()=>{let S=!0;const{data:{subscription:A}}=C.auth.onAuthStateChange((y,D)=>{S&&(p(!!(D!=null&&D.user)),l(!1),D!=null&&D.user&&setTimeout(()=>{P(D.user.id)},0))});return C.auth.getSession().then(({data:{session:y}})=>{S&&(p(!!(y!=null&&y.user)),l(!1),y!=null&&y.user&&P(y.user.id))}),()=>{S=!1,A.unsubscribe()}},[]);const P=async S=>{const{data:A}=await C.from("profiles").select("full_name, email").eq("id",S).single();if(A!=null&&A.full_name){const y=A.full_name.split(" ")[0];g(y)}else if(A!=null&&A.email){const y=A.email.split("@")[0],D=y.charAt(0).toUpperCase()+y.slice(1);g(D)}};if(i.useEffect(()=>{const S=t.get("tab");S&&S!==d&&m(S)},[t]),i.useEffect(()=>{!c&&!f&&a("/auth")},[c,f,a]),i.useEffect(()=>{!f||c||jn("karriereside_tab_view","karriereside",{tab:d})},[d,f,c]),c||!f)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const N=()=>{switch(d){case"karriereprofil":return e.jsx(Fr,{});case"ansoegningspakker":return e.jsx(Fr,{});case"mine-input":case"joboensker":case"jobindstillinger":return e.jsx(oh,{});case"personanalyser":return e.jsx(ah,{});case"jobsoegningsstrategi":return e.jsx(ru,{});case"headhuntere":return e.jsx(gu,{});case"linkedin":return e.jsx(mu,{});case"netvaerk":return e.jsx(mh,{});case"uopfordret":return e.jsx(bu,{});case"interview":return e.jsx(ao,{embedded:!0});case"karriereplan":return e.jsx(hh,{});case"cv-feedback":return e.jsx(xh,{});case"spoergsmaal":return e.jsx(hu,{});case"abonnement":return e.jsx(dh,{});default:return e.jsx(Fr,{})}},w=()=>e.jsx(nd,{name:s(`careerSite.tabs.${d}`,{defaultValue:"Sektion"}),children:N()});return s(`careerSite.tabs.${d}`,{defaultValue:s("careerSite.title")}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ac,{}),e.jsx(dc,{defaultOpen:!0,children:e.jsxs("div",{className:"flex min-h-[calc(100vh-64px)] w-full",children:[e.jsx(mc,{userFirstName:j}),e.jsxs(uc,{className:"flex-1",children:[e.jsxs("div",{className:"p-6 lg:p-10 max-w-6xl mx-auto pb-24 lg:pb-10",children:[e.jsx("div",{className:"flex items-center gap-4 mb-4 lg:hidden",children:e.jsx(hc,{})}),e.jsx("div",{className:"animate-fade-in",children:w()})]}),e.jsx(nc,{})]})]})}),e.jsx(xc,{})]})};export{Jx 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.