1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4632],{4632:(e,a,t)=>{t.r(a),t.d(a,{default:()=>ew});var s=t(95155);t(53255);var r=t(81750),n=t(30605),l=t(92571),d=t(11012),o=t(64577),i=t(27502),c=t(2125),u=t(12363),m=t(52427),x=t(82749),p=t(65738),h=t(77618),b=t(62365),g=t(76721),f=t(12115),j=t(66609),N=t(43447),v=t(4474),w=t(3445),y=t(91337),k=t(9339);let C=(0,k.createServerReference)("40367c99ce0e3d5d12fd8fd1535e730b2b7f45a008",k.callServer,void 0,k.findSourceMapURL,"createIncomeMap"),S=(0,k.createServerReference)("70ff572755ba6535a78a987f94c09658c87218b032",k.callServer,void 0,k.findSourceMapURL,"updateIncomeMap"),A=(0,k.createServerReference)("406ffea1507163a7f9880a37618388f24437f02157",k.callServer,void 0,k.findSourceMapURL,"getIncomeMap");function I(e){return e.stripeRefs&&e.stripeRefs.length>0?e.stripeRefs:e.stripe?[e.stripe]:[]}var R=t(50430),$=t(90444),z=t(71019),P=t(78912),D=t(36672),M=t(13626),_=t(57465),H=t(53516),E=t(96550),L=t(40557),U=t(52957),F=t(80167),O=t(32939),V=t(65079),Z=t(86272);let B=[{id:"company",label:"PSYTECH",logo:"/logo_psy-tech_faraText.png",color:"#0e1c2e"},{id:"gc",label:"G\xe2ndire CriticÄ",logo:"/logos/gandire-critica.svg",color:"#1d3752"},{id:"epsi",label:"ePsihologie",logo:"/logos/epsi.png",color:"#0b4c3e"},{id:"psihopad",label:"PsihoPad",logo:"/logos/psihopad.svg",color:"#b45309"},{id:"custom",label:"Produs nou",logo:null,color:"#475569"}],J=[{id:"subscription",label:"Abonamente",Icon:z.A},{id:"recurring",label:"Recurent",Icon:P.A},{id:"evaluation",label:"EvaluÄri",Icon:D.A},{id:"course",label:"Cursuri",Icon:M.A},{id:"workshop",label:"Workshop",Icon:_.A},{id:"rental",label:"\xcenchiriere",Icon:H.A},{id:"oneoff",label:"V\xe2nzare unicÄ",Icon:E.A},{id:"content",label:"ConÈinut",Icon:L.A},{id:"event",label:"Evenimente",Icon:m.A},{id:"b2b",label:"B2B",Icon:U.A},{id:"ads",label:"Promovare",Icon:F.A},{id:"grant",label:"FinanÈare",Icon:O.A},{id:"cash",label:"\xcencasÄri",Icon:V.A},{id:"other",label:"Altele",Icon:Z.A}];function G(e){return J.find(a=>a.id===e)??J[13]}let T=["#005db1","#1d3752","#0b4c3e","#1e6e5b","#b45309","#d6594d","#7c3aed","#0e7490","#64748b"],W={version:1,name:"Harta venituri",nodes:[{id:"company",type:"brand",position:{x:460,y:220},data:{label:"PSYTECH",sublabel:"Holding",brand:"company",color:"#0e1c2e"}},{id:"gc",type:"brand",position:{x:60,y:40},data:{label:"G\xe2ndire CriticÄ",sublabel:"Produs",brand:"gc",color:"#1d3752"}},{id:"epsi",type:"brand",position:{x:60,y:220},data:{label:"ePsihologie",sublabel:"Produs",brand:"epsi",color:"#0b4c3e"}},{id:"psihopad",type:"brand",position:{x:60,y:400},data:{label:"PsihoPad",sublabel:"Produs",brand:"psihopad",color:"#b45309"}}],edges:[{id:"e-gc-company",source:"gc",target:"company"},{id:"e-epsi-company",source:"epsi",target:"company"},{id:"e-psihopad-company",source:"psihopad",target:"company"}]};var X=t(52442),K=t(51128),Q=t(7260),Y=t(39658),q=t(26518),ee=t(5772),ea=t(9005),et=t(65377),es=t(977),er=t(97454);function en({value:e,onChange:a,compact:t=!1}){let[r,n]=(0,f.useState)(e[0]?.account??null),[d,i]=(0,f.useState)(""),c=(0,$.B2)(r),u=(0,f.useMemo)(()=>{let e=c.data?.products??[],a=d.trim().toLowerCase();return a?e.filter(e=>e.name.toLowerCase().includes(a)):e},[c.data,d]),m=(a,t)=>e.some(e=>e.account===a&&e.productId===t);return(0,s.jsxs)("div",{className:"space-y-2",children:[e.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.map(t=>{let r=er.Z.find(e=>e.id===t.account);return(0,s.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border bg-muted/50 py-0.5 pl-2 pr-1 text-[11px] font-medium",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full",style:{background:r?.color??"#64748b"}}),(0,s.jsx)("span",{className:"truncate",children:t.productName}),(0,s.jsx)("button",{type:"button",onClick:()=>a(e.filter(e=>e.account!==t.account||e.productId!==t.productId)),className:"shrink-0 rounded-full p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"EliminÄ",children:(0,s.jsx)(ea.A,{className:"h-3 w-3"})})]},`${t.account}:${t.productId}`)})}):null,(0,s.jsx)("div",{className:"flex gap-1.5",children:er.Z.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>{n(e.id),i("")},className:(0,y.cn)("flex flex-1 items-center justify-center gap-1.5 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors",r===e.id?"border-transparent text-white shadow-sm":"bg-background text-muted-foreground hover:bg-muted"),style:r===e.id?{background:e.color}:void 0,children:[(0,s.jsx)(ee.default,{src:e.logo,alt:"",width:14,height:14,className:(0,y.cn)("h-3.5 w-3.5 object-contain",r===e.id&&"brightness-0 invert")}),t?null:e.label]},e.id))}),r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(et.A,{className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,s.jsx)(Y.p,{className:"h-8 pl-8 text-xs",placeholder:"CautÄ produsâ¦",value:d,onChange:e=>i(e.target.value)})]}),c.isLoading?(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"})," Se \xeencarcÄâ¦"]}):c.isError?(0,s.jsx)("p",{className:"py-4 text-center text-xs text-danger-600",children:c.error.message}):0===u.length?(0,s.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"Niciun produs gÄsit."}):(0,s.jsx)(es.F,{className:(0,y.cn)("rounded-lg border bg-background",t?"h-40":"h-44"),children:(0,s.jsx)("div",{className:"p-1",children:u.map(t=>{let n=m(r,t.id),l=t.prices.find(e=>null!=e.unit_amount);return(0,s.jsxs)("button",{type:"button",className:(0,y.cn)("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs transition-colors",n?"bg-brand-100 text-brand-900 dark:bg-brand-900/50 dark:text-brand-100":"hover:bg-muted"),onClick:()=>{var s;m((s={account:r,productId:t.id,productName:t.name}).account,s.productId)?a(e.filter(e=>e.account!==s.account||e.productId!==s.productId)):a([...e,s])},children:[(0,s.jsx)("span",{className:(0,y.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded border",n?"border-brand-600 bg-brand-600 text-white":"border-muted-foreground
1/40"),children:n?(0,s.jsx)(o.A,{className:"h-3 w-3"}):null}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:t.name}),l?(0,s.jsxs)("span",{className:"shrink-0 text-muted-foreground",children:[(l.unit_amount/100).toLocaleString("ro-RO")," ",l.currency.toUpperCase(),l.interval?`/${"month"===l.interval?"lunÄ":"an"}`:""]}):null]},t.id)})})})]}):(0,s.jsx)("p",{className:"py-1 text-center text-[11px] text-muted-foreground",children:"Alege contul Stripe ca sÄ vezi produsele live."})]})}function el({label:e,sublabel:a,icon:t,color:r,stripeName:n}){let{Icon:l}=G(t);return(0,s.jsx)("div",{className:"w-48 rounded-xl border bg-white shadow-md dark:bg-slate-900",style:{borderColor:`${r}40`},children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(0,s.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-white",style:{background:`linear-gradient(135deg, ${r}, ${r}cc)`},children:(0,s.jsx)(l,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,s.jsx)("span",{className:"truncate text-[13px] font-medium text-slate-800 dark:text-slate-200",children:e||"SursÄ de venit"}),a?(0,s.jsx)("span",{className:"truncate text-[11px] text-slate-500 dark:text-slate-400",children:a}):null,n?(0,s.jsxs)("span",{className:"mt-0.5 inline-flex items-center gap-1 truncate text-[11px] font-medium",style:{color:r},children:[(0,s.jsx)(K.A,{className:"h-3 w-3 shrink-0"})," ",n]}):null]})]})})}function ed({open:e,onOpenChange:a,brandNodes:t,onCreate:r}){let[n,l]=(0,f.useState)(""),[d,o]=(0,f.useState)(""),[i,c]=(0,f.useState)("subscription"),[u,m]=(0,f.useState)(T[0]),[x,p]=(0,f.useState)(t[0]?.id??null),[h,b]=(0,f.useState)([]);return(0,s.jsx)(Q.lG,{open:e,onOpenChange:a,children:(0,s.jsxs)(Q.Cf,{className:"sm:max-w-3xl",children:[(0,s.jsxs)(Q.c7,{children:[(0,s.jsx)(Q.L3,{children:"SursÄ de venit nouÄ"}),(0,s.jsx)(Q.rr,{children:"DefineÈte sursa, conecteaz-o la un produs de pe hartÄ Èi, opÈional, asociaz-o cu un produs real din Stripe."})]}),(0,s.jsxs)("div",{className:"grid gap-6 sm:grid-cols-[1fr_220px]",children:[(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Nume"}),(0,s.jsx)(Y.p,{placeholder:"ex: Abonamente",value:n,onChange:e=>l(e.target.value),autoFocus:!0})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Descriere scurtÄ"}),(0,s.jsx)(Y.p,{placeholder:"ex: recurent \xb7 lunar",value:d,onChange:e=>o(e.target.value)})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-start gap-6",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"IconiÈÄ"}),(0,s.jsx)("div",{className:"grid grid-cols-7 gap-1",children:J.map(({id:e,Icon:a,label:t})=>(0,s.jsx)("button",{type:"button",title:t,className:(0,y.cn)("flex h-8 w-8 items-center justify-center rounded-md border transition-colors",i===e?"border-brand-500 bg-brand-100 text-brand-800 dark:bg-brand-900/50 dark:text-brand-100":"border-transparent text-muted-foreground hover:bg-muted"),onClick:()=>c(e),children:(0,s.jsx)(a,{className:"h-4 w-4"})},e))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Culoare"}),(0,s.jsx)("div",{className:"grid grid-cols-5 gap-1.5",children:T.map(e=>(0,s.jsx)("button",{type:"button",className:(0,y.cn)("h-7 w-7 rounded-full border-2 transition-transform hover:scale-110",u===e?"border-foreground":"border-transparent"),style:{background:e},onClick:()=>m(e)},e))})]})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"ConecteazÄ la"}),(0,s.jsxs)(q.l6,{value:x??"none",onValueChange:e=>p("none"===e?null:e),children:[(0,s.jsx)(q.bq,{className:"w-full",children:(0,s.jsx)(q.yv,{placeholder:"Alege un n
1od"})}),(0,s.jsxs)(q.gC,{children:[(0,s.jsx)(q.eb,{value:"none",children:"FÄrÄ conexiune"}),t.map(e=>(0,s.jsx)(q.eb,{value:e.id,children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,s.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:e.color}}),e.label]})},e.id))]})]})]}),(0,s.jsxs)("div",{className:"space-y-2 rounded-xl border bg-muted/30 p-3",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:["Asociere produse Stripe"," ",(0,s.jsx)("span",{className:"font-normal normal-case",children:"(opÈional \xb7 poÈi alege mai multe)"})]}),(0,s.jsx)(en,{value:h,onChange:b})]})]}),(0,s.jsxs)("div",{className:"hidden sm:flex flex-col items-center gap-3 rounded-xl border bg-muted/20 p-4",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Previzualizare"}),(0,s.jsx)(el,{label:n,sublabel:d,icon:i,color:u,stripeName:0===h.length?void 0:1===h.length?h[0].productName:`${h.length} produse asociate`}),x?(0,s.jsxs)("p",{className:"text-center text-[11px] text-muted-foreground",children:["Se conecteazÄ la"," ",(0,s.jsx)("span",{className:"font-medium text-foreground",children:t.find(e=>e.id===x)?.label})]}):null]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,s.jsx)(v.$,{variant:"outline",onClick:()=>a(!1),children:"AnuleazÄ"}),(0,s.jsx)(v.$,{onClick:()=>{r({label:n.trim()||h[0]?.productName||"SursÄ de venit",sublabel:d.trim()||void 0,icon:i,color:u,targetNodeId:x,stripeRefs:h.length>0?h:void 0}),a(!1),l(""),o(""),c("subscription"),m(T[0]),p(t[0]?.id??null),b([])},children:"AdaugÄ pe hartÄ"})]})]})})}var eo=t(56205),ei=t(84111);function ec(e,a){return`${e}${a}`}function eu({nodeId:e,value:a,className:t}){let{updateNodeData:n}=(0,r.VH)(),[l,d]=(0,f.useState)(!1),[o,i]=(0,f.useState)(a);return l?(0,s.jsx)("input",{autoFocus:!0,className:(0,y.cn)("nodrag w-full rounded-md border border-white/40 bg-white/20 px-1.5 py-0.5 outline-none",t),value:o,onChange:e=>i(e.target.value),onPointerDown:e=>e.stopPropagation(),onKeyDown:t=>{t.stopPropagation(),"Enter"===t.key&&(n(e,{label:o.trim()||a}),d(!1)),"Escape"===t.key&&d(!1)},onBlur:()=>{n(e,{label:o.trim()||a}),d(!1)}}):(0,s.jsx)("span",{className:(0,y.cn)("truncate cursor-text",t),onDoubleClick:e=>{e.stopPropagation(),i(a),d(!0)},title:"Dublu-click pentru redenumire",children:a})}let em="!w-4 !h-4 !border-2 !border-white !bg-brand-500 !rounded-full shadow-md transition-transform hover:!scale-125 dark:!border-slate-900";function ex(){return(0,s.jsxs)("span",{className:"mt-0.5 inline-flex w-fit items-center gap-1 rounded-full bg-warm-100 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-warm-700 dark:bg-warm-900/40 dark:text-warm-300",children:[(0,s.jsx)(h.A,{className:"h-2.5 w-2.5"})," Planificat"]})}let ep={brand:(0,f.memo)(function({id:e,data:a,selected:t}){var l;let d=(l=a.brand,B.find(e=>e.id===l)??B[4]),o=a.color??d.color;return(0,s.jsxs)("div",{className:(0,y.cn)("group w-56 rounded-2xl shadow-lg transition-shadow overflow-hidden","bg-white dark:bg-slate-900 border",a.planned&&"border-dashed",t?"ring-2 ring-offset-2 ring-offset-background shadow-xl":"hover:shadow-xl"),style:{borderColor:ec(o,"55"),...t?{"--tw-ring-color":o}:{}},children:[(0,s.jsx)("div",{className:"h-1.5 w-full",style:{background:`linear-gradient(90deg, ${o}, ${ec(o,"66")})`}}),(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,s.jsx)("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl",style:{background:ec(o,"14")},children:d.logo?(0,s.jsx)(ee.default,{src:d.logo,alt:"",width:30,height:30,className:"h-[30px] w-[30px] object-contain"}):(0,s.jsx)("span",{className:"text-lg font-bold",style:{color:o},children:a.label.slice(0,1).toUpperCase()})}),(0,s.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,s.jsx)(eu,{nodeId:e,value:a.label,className:"text-sm font-semibold text-slate-900 dark:text-slate-100"}),a.sublabel?(0,s.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-wide",style:{color:o},children:a.sublabel}):null,a.planned?(0,s.jsx)(ex,{}):null]})]}),(0,s.jsx)(r.h7,{type:"target",position:n.yX.Left,className:em}),(0,s.jsx)(r.h7,{type:"source",position:n.yX.Right,className:em})]})}),source:(0,f.memo)(function({id:e,data:a,selected:t}){let{Icon:l}=G(a.icon),d=a.color??"#005db1",o=(0,X.Gy)(),i=(0,X.P_)(),c=I(a),u=c.length>0,m=u&&o&&i?o.revenueForRefs(c):null;return(0,s.jsxs)("div",{className:(0,y.cn)("group w-48 rounded-xl border shadow-md transition-shadow overflow-hidden","bg-white dark:bg-slate-900",a.planned&&"border-dashed",t?"ring-2 ring-offset-2 ring-offset-background shadow-lg":"hover:shadow-lg"),style:{borderColor:ec(d,"40"),...t?{"--tw-ring-color":d}:{}},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(0,s.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-white",style:{background:`linear-gradient(135deg, ${d}, ${ec(d,"cc")})`},children:(0,s.jsx)(l,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex flex-col",children:[(0,s.jsx)(eu,{nodeId:e,value:a.label,className:"text-[13px] font-medium text-slate-800 dark:text-slate-200"}),a.sublabel?(0,s.jsx)("span",{className:"truncate text-[11px] text-slate-500 dark:text-slate-400",children:a.sublabel}):null,a.planned?(0,s.jsx)(ex,{}):null]}),u?(0,s.jsx)("button",{type:"button",className:"nodrag ml-auto shrink-0 self-start rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:c.length>1?`Detalii â ${c.length} produse`:`Detalii Stripe â ${c[0].productName}`,onClick:e=>{e.stopPropagation(),o?.openDetail(c,a.label)},children:(0,s.jsx)(b.A,{className:"h-3.5 w-3.5"})}):null]}),u&&i?(0,s.jsx)("div",{className:"flex items-baseline gap-1 border-t px-3 py-1.5",style:{borderColor:ec(d,"20"),background:ec(d,"0d")},children:m?.loading?(0,s.jsx)("span",{className:"h-3.5 w-20 animate-pulse rounded bg-muted"}):m?.amount!=null?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[13px] font-bold tabular-nums",style:{color:d},children:(0,ei.BA)(m.amount,m.currency)}),(0,s.jsx)("span",{className:"text-[10px] text-slate-500 dark:text-slate-400",children:o?.chipSuffix}),c.length>1?(0,s.jsxs)("span",{className:"ml-auto text-[10px] font-medium text-slate-400",children:[c.length," produse"]}):null]}):(0,s.jsx)("span",{className:"text-[11px] text-slate-400",children:"â fÄrÄ tranzacÈii"})}):null,(0,s.jsx)(r.h7,{type:"target",position:n.yX.Left,className:em}),(0,s.jsx)(r.h7,{type:"source",position:n.yX.Right,className:em})]})})},eh="psytech:income-map:period";function eb(e){let a=5381;for(let t=0;t<e.length;t++)a=(a<<5)+a+e.charCodeAt(t)|0;return String(a>>>0)}function eg(e,a){return{version:1,name:"Harta venituri",nodes:e.map(e=>({id:e.id,type:"source"===e.type?"source":"brand",position:{x:Math.round(e.position.x),y:Math.round(e.position.y)},data:e.data})),edges:a.map(e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null,..."string"==typeof e.label&&e.label?{label:e.label}:{}}))}}
1function ef(e){return e.nodes.map(e=>({id:e.id,type:e.type,position:e.position,data:e.data}))}function ej(e){return e.edges.map(e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle??void 0,targetHandle:e.targetHandle??void 0,label:e.label}))}function eN({state:e,savedAt:a}){return"saving"===e?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-brand-100 px-3 py-1 text-xs font-medium text-brand-800 dark:bg-brand-900/60 dark:text-brand-100",children:[(0,s.jsx)(l.A,{className:"h-3 w-3 animate-spin"})," Se salveazÄâ¦"]}):"error"===e?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-danger-100 px-3 py-1 text-xs font-medium text-danger-700",children:[(0,s.jsx)(d.A,{className:"h-3 w-3"})," Eroare la salvare"]}):a?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-muted px-3 py-1 text-xs font-medium text-muted-foreground",children:[(0,s.jsx)(o.A,{className:"h-3 w-3"})," Salvat"]}):(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-muted px-3 py-1 text-xs font-medium text-muted-foreground",children:[(0,s.jsx)(i.A,{className:"h-3 w-3"})," Se salveazÄ la prima editare"]})}function ev({initialMap:e}){let a=e?.doc??W,[t,d,i]=(0,r.ck)(ef(a)),[k,z,P]=(0,r.fM)(ej(a)),[D,M]=(0,f.useState)("idle"),[_,H]=(0,f.useState)(e?new Date(e.updated_at):null),[E,L]=(0,f.useState)(!1),[U,F]=(0,f.useState)(null),[O,V]=(0,f.useState)(()=>(0,R.WI)(localStorage.getItem(eh)).id),Z=(0,R.WI)(O),{resolved:G}=(0,w.D)(),{screenToFlowPosition:K,deleteElements:Q}=(0,r.VH)(),Y=(0,f.useRef)(null),q=(0,f.useRef)(e?.id??null),ee=(0,f.useRef)(e?.rev??0),ea=(0,f.useRef)(!1),et=(0,f.useRef)(e?eb(JSON.stringify(e.doc)):null),es=(0,f.useRef)({nodes:t,edges:k});es.current={nodes:t,edges:k};let er=(0,f.useCallback)(e=>{q.current=e.id,ee.current=e.rev,et.current=eb(JSON.stringify(e.doc)),d(ef(e.doc)),z(ej(e.doc)),H(new Date(e.updated_at))},[d,z]);(0,f.useEffect)(()=>{let e=async()=>{if(ea.current)return;let e=eg(es.current.nodes,es.current.edges),a=eb(JSON.stringify(e));if(a!==et.current){ea.current=!0,M("saving");try{if(q.current){let t=await S(q.current,e,ee.current);if("ok"===t.kind)ee.current=t.rev,et.current=a,H(new Date(t.updated_at)),M("idle");else{let e=await A(q.current);e&&(er(e),j.oR.info(`Harta a fost actualizatÄ de ${t.updated_by_name??"altcineva"} â am re\xeencÄrcat versiunea de pe server.`)),M("idle")}}else{let t=await C(e);q.current=t.id,ee.current=t.rev,et.current=a,H(new Date(t.updated_at)),M("idle")}}catch{M("error")}finally{ea.current=!1}}},a=window.setInterval(e,2e3);return()=>window.clearInterval(a)},[er]),(0,f.useEffect)(()=>{let e=()=>{let e=eg(es.current.nodes,es.current.edges);eb(JSON.stringify(e))!==et.current&&q.current&&S(q.current,e,ee.current)};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]);let el=(0,f.useCallback)(e=>z(a=>(0,r.rN)({...e,id:`e-${crypto.randomUUID().slice(0,8)}`},a)),[z]),ei=(0,f.useCallback)(()=>{let e=Y.current?.getBoundingClientRect(),a=K({x:e?e.left+e.width/2:window.innerWidth/2,y:e?e.top+e.height/2:window.innerHeight/2});return{x:a.x-90+40*Math.random(),y:a.y-24+40*Math.random()}},[K]),ec=(0,f.useCallback)(e=>{let a=B.find(a=>a.id===e)??B[4];d(e=>[...e,{id:`n-${crypto.randomUUID().slice(0,8)}`,type:"brand",position:ei(),data:{label:a.label,sublabel:"company"===a.id?"Holding":"Produs",brand:a.id,color:a.color},selected:!0}])},[d,ei]),eu=(0,f.useMemo)(()=>t.filter(e=>e.selected),[t]),em=1===eu.length?eu[0]:null,ex=(0,f.useCallback)(e=>{d(a=>a.map(a=>a.selected?{...a,data:{...a.data,...e}}:a))},[d]),ew=(0,f.useCallback)(()=>{Q({nodes:eu.map(e=>({id:e.id})),edges:k.filter(e=>e.selected).map(e=>({id:e.id}))})},[Q,eu,k]),ey=(0,f.useMemo)(()=>{let e=new Set;for(let a of t)for(let t of I(a.data))e.add(t.account);return e},[t]),ek=(0,$.Jm)("epsi",O,ey.has("epsi")),eC=(0,$.Jm)("gc",O,ey.has("gc")),eS=(0,$.Jm)("psihopad",O,ey.has("psihopad")),eA=(0,f.useMemo)(()=>({epsi:ek,gc:eC,psihopad:eS}),[ek,eC,eS]),eI=(0,f.useCallback)((e,a)=>F({refs:e,nodeLabel:a}),[]),{resync:eR,isResyncing:e$}=(0,$.zF)(),ez=(0,f.useCallback)(async()=>{let e=j.oR.loading("Se descarcÄ datele Stripeâ¦"),{total:a,failed:t}=await eR({accounts:["epsi","gc","psihopad"]});0===t?j.oR.success(`Cache re\xeemprospÄtat \xb7 ${a} seturi de date`,{id:e}):j.oR.warning(`Sincronizare parÈialÄ \xb7 ${a-t}/${a} reuÈite`,{id:e})},[eR]),eP=(0,f.useMemo)(()=>({chipSuffix:Z.chipSuffix,openDetail:eI,revenueForRefs:e=>{let a=0,t=!1,s=!1,r="ron";for(let n of e){let e=eA[n.account];if(!e.data){e.isFetching&&(s=!0);continue}r=e.data.currency;let l=e.data.by_product[n.productId];null!=l&&(a+=Math.round(l/Z.divisor),t=!0)}return{amount:t?a:null,loading:s&&!t,currency:r}}}),[eA,Z,eI]),eD=(0,f.useCallback)(e=>{V(e);try{localStorage.setItem(eh,e)}catch{}},[]),eM=(0,f.useMemo)(()=>t.filter(e=>"brand"===e.type).map(e=>({id:e.id,label:e.data.label,color:e.data.color??"#1d3752"})),[t]),e_=(0,f.useCallback)(e=>{let a=`n-${crypto.randomUUID().slice(0,8)}`,t=e.targetNodeId?es.current.nodes.find(a=>
1a.id===e.targetNodeId):null,s=t?{x:t.position.x-280,y:t.position.y+120*Math.random()-40}:ei();d(t=>[...t,{id:a,type:"source",position:s,data:{label:e.label,sublabel:e.sublabel,icon:e.icon,color:e.color,...e.stripeRefs?{stripeRefs:e.stripeRefs}:{}},selected:!0}]),t&&z(e=>(0,r.rN)({id:`e-${crypto.randomUUID().slice(0,8)}`,source:a,target:t.id},e))},[d,z,ei]);return(0,s.jsx)(X.nl,{value:eP,children:(0,s.jsxs)("div",{ref:Y,className:"h-full w-full",children:[(0,s.jsxs)(r.Gc,{nodes:t,edges:k,onNodesChange:i,onEdgesChange:P,onConnect:el,onNodeClick:(e,a)=>{let t=a.data,s=I(t);"source"===a.type&&s.length>0&&eI(s,t.label)},nodeTypes:ep,colorMode:G,fitView:!0,fitViewOptions:{padding:.25,maxZoom:1.1},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},defaultEdgeOptions:{type:"smoothstep",animated:!0,style:{strokeWidth:2},markerEnd:{type:n.TG.ArrowClosed,width:16,height:16}},deleteKeyCode:["Backspace","Delete"],children:[(0,s.jsx)(r.VS,{variant:r._5.Dots,gap:24,size:1.5}),(0,s.jsx)(r.H2,{position:"bottom-left",showInteractive:!1}),(0,s.jsx)(r.of,{position:"bottom-right",pannable:!0,zoomable:!0,nodeColor:e=>e.data?.color??"#94a3b8",className:"!rounded-xl overflow-hidden"}),(0,s.jsxs)(r.Zk,{position:"top-left","data-tour":"incomemap-canvas-toolbar",className:"flex items-center gap-2",children:[(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)(v.$,{size:"sm",className:"gap-1.5 shadow-md",children:[(0,s.jsx)(c.A,{className:"h-4 w-4"})," Produs ",(0,s.jsx)(u.A,{className:"h-3.5 w-3.5 opacity-70"})]})}),(0,s.jsx)(N.SQ,{align:"start",children:B.map(e=>(0,s.jsxs)(N._2,{onSelect:()=>ec(e.id),children:[(0,s.jsx)("span",{className:"mr-2 inline-block h-2.5 w-2.5 rounded-full",style:{background:e.color}}),e.label]},e.id))})]}),(0,s.jsxs)(v.$,{size:"sm",variant:"outline",className:"gap-1.5 bg-background shadow-md",onClick:()=>L(!0),children:[(0,s.jsx)(c.A,{className:"h-4 w-4"})," SursÄ de venit"]}),(0,s.jsxs)(N.rI,{children:[(0,s.jsx)(N.ty,{asChild:!0,children:(0,s.jsxs)(v.$,{size:"sm",variant:"outline",className:"gap-1.5 bg-background shadow-md",children:[(0,s.jsx)(m.A,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:Z.label}),(0,s.jsx)("span",{className:"sm:hidden",children:"PerioadÄ"}),(0,s.jsx)(u.A,{className:"h-3.5 w-3.5 opacity-70"})]})}),(0,s.jsx)(N.SQ,{align:"start",children:R.Rz.map(e=>(0,s.jsxs)(N._2,{onSelect:()=>eD(e.id),children:[(0,s.jsx)(o.A,{className:(0,y.cn)("mr-2 h-3.5 w-3.5",e.id===O?"opacity-100":"opacity-0")}),e.label]},e.id))})]})]}),(0,s.jsx)(r.Zk,{position:"top-center","data-tour":"incomemap-salvare",children:(0,s.jsx)(eN,{state:D,savedAt:_})}),(0,s.jsxs)(r.Zk,{position:"top-right",className:"flex flex-col items-end gap-2",children:[(0,s.jsxs)(v.$,{size:"sm",variant:"outline",className:"gap-1.5 bg-background shadow-md",onClick:ez,disabled:e$,title:"DescarcÄ toate datele Stripe disponibile Èi le pune \xeen cache â click-urile urmÄtoare pe surse devin instant",children:[e$?(0,s.jsx)(l.A,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(x.A,{className:"h-4 w-4"}),e$?"Se sincronizeazÄâ¦":"Resync cache"]}),em?(0,s.jsxs)("div",{className:"max-h-[calc(100dvh-9rem)] w-60 space-y-3 overflow-y-auto rounded-xl border bg-background/95 p-3 shadow-lg backdrop-blur",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"brand"===em.type?"Produs":"SursÄ de venit"}),(0,s.jsx)(v.$,{size:"icon",variant:"ghost",className:"h-7 w-7 text-danger-600 hover:text-danger-700",onClick:ew,title:"Èterge",children:(0,s.jsx)(p.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>ex({planned:!em.data.planned}),className:(0,y.cn)("flex w-full items-center justify-between rounded-lg border px-2.5 py-1.5 text-xs font-medium transition-colors",em.data.planned?"border-warm-300 bg-warm-100/60 text-warm-700 dark:border-warm-500/40 dark:bg-warm-900/30 dark:text-warm-300":"border-border text-muted-foreground hover:bg-muted"),title:"MarcheazÄ ca planificat (viitor)",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(h.A,{className:"h-3.5 w-3.5"})," Planificat"]}),(0,s.jsx)("span",{className:(0,y.cn)("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",em.data.planned?"bg-warm-500":"bg-muted-foreground
1/30"),children:(0,s.jsx)("span",{className:(0,y.cn)("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",em.data.planned?"translate-x-3.5":"translate-x-0.5")})})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("label",{className:"text-[11px] font-medium text-muted-foreground",children:"Descriere scurtÄ"}),(0,s.jsx)("input",{className:"w-full rounded-md border bg-background px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"ex: recurent \xb7 lunar",value:em.data.sublabel??"",onChange:e=>ex({sublabel:e.target.value})})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Culoare"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:T.map(e=>(0,s.jsx)("button",{className:(0,y.cn)("h-6 w-6 rounded-full border-2 transition-transform hover:scale-110",em.data.color===e?"border-foreground":"border-transparent"),style:{background:e},onClick:()=>ex({color:e}),title:e},e))})]}),"source"===em.type?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Produse Stripe asociate"}),(0,s.jsx)(en,{value:I(em.data),onChange:e=>ex({stripeRefs:e}),compact:!0}),I(em.data).length>0?(0,s.jsxs)("button",{type:"button",onClick:()=>eI(I(em.data),em.data.label),className:"group flex w-full items-center gap-2.5 rounded-lg border border-brand-200 bg-gradient-to-br from-brand-50 to-brand-100/60 px-3 py-2 text-left transition-all hover:border-brand-300 hover:shadow-sm dark:border-brand-800 dark:from-brand-900/40 dark:to-brand-900/20",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-brand-600 text-white shadow-sm",children:(0,s.jsx)(b.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block text-xs font-semibold text-brand-900 dark:text-brand-100",children:"Vezi detalii"}),(0,s.jsxs)("span",{className:"block truncate text-[11px] text-brand-700/80 dark:text-brand-300/80",children:[I(em.data).length," produs(e) asociat(e)"]})]}),(0,s.jsx)(g.A,{className:"h-4 w-4 shrink-0 text-brand-500 transition-transform group-hover:translate-x-0.5"})]}):null]}):null,"source"===em.type?(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"IconiÈÄ"}),(0,s.jsx)("div",{className:"grid grid-cols-7 gap-1",children:J.map(({id:e,Icon:a,label:t})=>(0,s.jsx)("button",{className:(0,y.cn)("flex h-7 w-7 items-center justify-center rounded-md border transition-colors",em.data.icon===e?"border-brand-500 bg-brand-100 text-brand-800 dark:bg-brand-900/50 dark:text-brand-100":"border-transparent text-muted-foreground hover:bg-muted"),onClick:()=>ex({icon:e}),title:t,children:(0,s.jsx)(a,{className:"h-3.5 w-3.5"})},e))})]}):null]}):null]})]}),(0,s.jsx)(ed,{open:E,onOpenChange:L,brandNodes:eM,onCreate:e_}),(0,s.jsx)(eo.c,{detail:U,periodId:O,onOpenChange:e=>{e||F(null)}})]})})}function ew({initialMap:e}){return(0,s.jsx)(r.Ln,{children:(0,s.jsx)(ev,{initialMap:e})})}}}]);
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.