PageSourceSearch

https://nadlan.ai/assets/InvestmentPortfolio-B6C-6Ukw.js

js nadlan.ai collected 2026-10-05 14:38:20 UTC 86,040 bytes, 77 lines download raw bytes

1import{j as e,m as cs}from"./vendor-motion-DGLXHZ0B.js";import{r as o,L as Ds}from"./vendor-react-DUB4Vjci.js";import{s as xs,ad as Ye,ae as Ke,af as Qe,ag as Xe,aw as Ze,v as C,I as B,B as T,c as Q,ap as es,S as Re,w as Me,x as $e,y as qe,z as ae,ay as Ls,a1 as ve,L as Oe,D as Ts,a6 as pe,g as we,ar as us,as as Fs,aB as Fe,C as W,h as me,i as xe,T as Ue,a as K,j as te,A as We,ab as Ps,b as Es,k as Pe,u as Rs,a8 as Ms,aC as $s,a3 as qs,W as _e,aq as He,aD as Os,q as Us,a2 as Vs,a4 as zs,aj as Bs}from"./index-gimFOjch.js";import{T as Ws,a as Hs,b as De,c as Le}from"./tabs-BTr_byu4.js";import{S as Gs}from"./search-CCwL8nBE.js";import{S as ss}from"./star-DLJ5LIf8.js";import{R as Je}from"./refresh-cw-BcB5Fx7V.js";import{d as Js,C as Ee,P as Ys}from"./PropertyManagementModal-2C9CSFZx.js";import{R as hs,A as Ks,C as Qs,X as Xs,Y as Zs,T as ps,b as et,D as st,P as tt,d as at,e as rt}from"./vendor-charts-DZ_hHnrz.js";import{h as gs}from"./he-HReJu3jL.js";import{A as nt,b as lt,a as it}from"./alert-Ca-cAhSs.js";import{S as ct}from"./save-Djv9LtEc.js";import{H as os}from"./heart-pulse-Dpa_twLu.js";import{W as ds}from"./wallet-2eDQCvb8.js";import{S as ot}from"./shield-alert-BccFSNUN.js";import{M as dt}from"./map-pin-BsuoWXTF.js";import{S as ys}from"./sparkles-BOG37L-k.js";import{C as mt}from"./circle-check-CL2VkGfS.js";import{C as xt}from"./circle-alert-BOKkWrVn.js";import{C as ut}from"./chart-line-BZCYrv4b.js";import{P as ht}from"./pencil-C1diM48g.js";import"./vendor-pdf-ckwbz45p.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const pt=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],gt=xs("ArrowDown",pt);/**
7 * @license lucide-react v0.475.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const yt=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ft=xs("ArrowUp",yt),jt=[".TA",".TASE"],Se=r=>{if(!r||typeof r!="string")return!1;const i=r.toUpperCase();return jt.some(m=>i.endsWith(m))},_t=r=>typeof r!="number"||isNaN(r)?0:r/100,ms=(r,i)=>Se(i)?typeof r!="number"||isNaN(r)||r<=0?0:r>50?_t(r):r:r,Ge=(r,i="ILS",m={})=>{const{minimumFractionDigits:s=2,maximumFractionDigits:a=2,...h}=m,p={style:"currency",currency:i,minimumFractionDigits:s,maximumFractionDigits:a,...h};try{new Intl.NumberFormat("he-IL",p).format(0)}catch{console.warn(`Invalid currency code '${i}'. Falling back to 'ILS'.`),p.currency="ILS"}return new Intl.NumberFormat("he-IL",p).format(r||0)},bt=r=>{const{quantity:i=0,purchase_price:m=0,current_price:s=0,ticker_symbol:a="",currency:h="ILS"}=r,p=Se(a)?ms(m,a):m,y=Se(a)?ms(s,a):s,_=i*p,x=i*y,v=x-_,X=_>0?v/_*100:0;return{normalizedPurchasePrice:p,normalizedCurrentPrice:y,totalInvestment:_,currentValue:x,returnAmount:v,returnPercentage:X,currency:Se(a)?"ILS":h}},vt=async({query:r})=>{var s;const i=`
12    Search for up-to-date and accurate financial asset information for: "${r}".
13    
14    IMPORTANT GUIDELINES:
15    1. For Bitcoin/BTC or other major cryptocurrencies: Return price in USD. Set source to 'crypto'. Asset type should be 'crypto'.
16    2. For Israeli stocks (ending with .TA or traded on TASE): Return price in Agorot as displayed on the exchange. Set source to 'israeli'. Asset type should be 'stocks' or 'etf'.
17    3. For other international stocks/ETFs: Return price in their original currency. Set source to 'international'. Asset type should be 'stocks' or 'etf'.
18    4. Use real and current data from the internet.
19    5. Provide exchange name and sector where applicable. If no specific sector is found, return an empty string.
20
21    Return JSON with a list of precise matches, ordered by relevance:
22    {
23      "results": [
24        {
25          "name": "Company/Asset Name (e.g., Apple Inc., Bitcoin)",
26          "ticker": "Symbol (e.g., AAPL, BTC-USD, TASE:ELAL.TA)",
27          "current_price": real_current_price_number,
28          "currency": "USD_or_ILS_or_EUR (based on asset)",
29          "asset_type": "stocks_or_crypto_or_etf_or_bonds_or_mutual_funds",
30          "source": "israeli_or_crypto_or_international",
31          "exchange": "Exchange Name (e.g., NASDAQ, TASE, Binance)",
32          "sector": "Sector (e.g., Technology, Financials, Consumer Goods) or empty string"
33        }
34      ]
35    }
36  `,m={type:"object",properties:{results:{type:"array",items:{type:"object",properties:{name:{type:"string"},ticker:{type:"string"},current_price:{type:"number"},currency:{type:"string"},asset_type:{type:"string"},source:{type:"string",enum:["israeli","crypto","international"]},exchange:{type:"string"},sector:{type:"string"}},required:["name","ticker","current_price","currency","asset_type","source"]}}}};try{return{data:{results:((s=(await pe.InvokeLLM({prompt:i,add_context_from_internet:!0,response_json_schema:m})).results)==null?void 0:s.map(p=>{var _,x,v;const y={...p};return(_=y.ticker)!=null&&_.toUpperCase().includes("BTC")||(x=y.name)!=null&&x.toLowerCase().includes("bitcoin")?(y.asset_type="crypto",y.currency="USD",y.source="crypto"):(v=y.ticker)!=null&&v.includes(".TA")&&(y.currency="ILS",y.source="israeli"),(typeof y.current_price!="number"||isNaN(y.current_price)||y.current_price<0)&&(y.current_price=0),y}))||[]}}}catch(a){return console.error("Error invoking LLM for searchAsset:",a),{data:{results:[]}}}};function Nt({isOpen:r,onClose:i,onSave:m,editStock:s=null}
36){const[a,h]=o.useState({asset_type:"stocks",asset_name:"",ticker_symbol:"",quantity:"",purchase_price:"",current_price:"",purchase_date:new Date().toISOString().split("T")[0],currency:"USD",a10f_score:{},sector:""}),[p,y]=o.useState(""),[_,x]=o.useState([]),[v,X]=o.useState(!1),[A,M]=o.useState(null),[u,D]=o.useState(!1),[H,Z]=o.useState(!1),[ee,S]=o.useState(!1),[U,d]=o.useState(null);o.useEffect(()=>{var l,N,P;s?(h({id:s.id,asset_type:s.asset_type||"stocks",asset_name:s.asset_name||"",ticker_symbol:s.ticker_symbol||"",quantity:((l=s.quantity)==null?void 0:l.toString())||"",purchase_price:((N=s.purchase_price)==null?void 0:N.toString())||"",current_price:((P=s.current_price)==null?void 0:P.toString())||"",purchase_date:s.purchase_date||new Date().toISOString().split("T")[0],currency:s.currency||"USD",a10f_score:s.a10f_score||{},sector:s.sector||""}),s.a10f_score&&Object.keys(s.a10f_score).length>0?(d(s.a10f_score),S(!0),D(!1)):(d(null),S(!1),D(!1))):(h({asset_type:"stocks",asset_name:"",ticker_symbol:"",quantity:"",purchase_price:"",current_price:"",purchase_date:new Date().toISOString().split("T")[0],currency:"USD",a10f_score:{},sector:""}),M(null),y(""),x([]),D(!1),Z(!1),S(!1),d(null))},[s,r]);const F=async()=>{if(p.trim()){X(!0),x([]);try{const{data:l}=await vt({query:p.trim()});l&&l.results?x(l.results):x([])}catch(l){console.error("Error searching assets:",l),x([])}finally{X(!1)}}},b=l=>{M(l);let N=l.currency||"USD",P=l.current_price||0,R=l.current_price||0,J=l.asset_type||"stocks";l.source==="israeli"?N="ILS":l.source==="crypto"&&(J="crypto",N="USD"),(typeof P!="number"||isNaN(P)||P<=0)&&(console.warn(`מחיר לא תקין עבור ${l.name}: ${P}. מאפס ל-0.`),P=0,R=0),h({...a,asset_name:l.name,ticker_symbol:l.ticker,current_price:P,purchase_price:R,asset_type:J,currency:N,sector:l.sector||""}),x([]),y(""),D(!1),Z(!1),S(!1),d(null)},V=(l,N)=>{h({...a,[l]:N})},G=()=>bt({quantity:parseFloat(a.quantity)||0,purchase_price:parseFloat(a.purchase_price)||0,current_price:parseFloat(a.current_price)||0,ticker_symbol:a.ticker_symbol,currency:a.currency}),L=async l=>{if(!l.ticker_symbol||!u)return null;Z(!0),S(!1),d(null);try{const N=`
37        You are an expert equity analyst performing a 10-factor (A10F-Score) analysis for the stock with ticker: ${l.ticker_symbol} (${l.asset_name}).
38        Your task is to provide a detailed, evidence-based assessment.
39        
40        Return a single JSON object with the following structure. Do NOT include any text or explanations outside of the JSON object.
41        The analysis date is ${new Date().toISOString().split("T")[0]}.
42      `,P={type:"object",properties:{g5x_growth_potential:{type:"number",minimum:0,maximum:5},brand_clarity:{type:"number",minimum:0,maximum:5},revenue_model_clarity:{type:"number",minimum:0,maximum:5},product_quality:{type:"number",minimum:0,maximum:5},competitive_moat:{type:"number",minimum:0,maximum:5},long_term_thesis:{type:"number",minimum:0,maximum:5},founder_involvement:{type:"number",minimum:0,maximum:5},crisis_resilience:{type:"number",minimum:0,maximum:5},geographic_quality:{type:"number",minimum:0,maximum:5},public_selection:{type:"number",minimum:0,maximum:5},thesis_5y:{type:"string"},key_risks:{type:"array",items:{type:"string"}},evidence_sources:{type:"array",items:{type:"string"}},confidence_level:{type:"string",enum:["low","medium","high"]}},required:["g5x_growth_potential","brand_clarity","revenue_model_clarity","product_quality","competitive_moat","long_term_thesis","founder_involvement","crisis_resilience","geographic_quality","public_selection","thesis_5y","key_risks","evidence_sources","confidence_level"]},R=await pe.InvokeLLM({prompt:N,add_context_from_internet:!0,response_json_schema:P});if(R&&typeof R=="object"){let J=R.thesis_5y;if(R.thesis_5y)try{const k=await pe.InvokeLLM({prompt:`Translate the following investment thesis to Hebrew, keep it concise: "${R.thesis_5y}"`});k&&typeof k=="string"&&(J=k)}catch(k){console.warn("Translation failed, using original thesis:",k)}const Y={g5x_growth_potential:15,brand_clarity:10,revenue_model_clarity:10,product_quality:10,competitive_moat:15,long_term_thesis:15,founder_involvement:5,crisis_resilience:5,geographic_quality:10,public_selection:5};let ge=0,ie=0;
42for(const k in Y)typeof R[k]=="number"&&(ge+=R[k]*Y[k],ie+=5*Y[k]);const E=ie>0?ge/ie*100:0,ue=k=>k>=90?"A+":k>=85?"A":k>=80?"A-":k>=75?"B+":k>=70?"B":k>=65?"B-":k>=60?"C+":k>=55?"C":k>=50?"C-":k>=40?"D":"F",ne={...R,thesis_5y:J,weighted_score:parseFloat(E.toFixed(1)),letter_grade:ue(E),analysis_date:new Date().toISOString().split("T")[0]};return d(ne),S(!0),ne}}catch(N){console.error("AI analysis failed:",N)}finally{Z(!1)}return null},q=async l=>{l.preventDefault();const N=G();let P=a.a10f_score;if(u&&!ee&&!H){const J=await L(a);J&&(P=J)}else U&&(P=U);const R={...a,quantity:parseFloat(a.quantity),purchase_price:N.normalizedPurchasePrice,current_price:N.normalizedCurrentPrice,total_investment:N.totalInvestment,current_value:N.currentValue,return_amount:N.returnAmount,return_percentage:N.returnPercentage,currency:N.currency,sector:a.sector||"",risk_level:(s==null?void 0:s.risk_level)||"medium",a10f_score:P};m(R)},$=G(),z=Se(a.ticker_symbol);return e.jsx(Ye,{open:r,onOpenChange:i,children:e.jsxs(Ke,{className:"sm:max-w-4xl w-full max-h-[90vh] overflow-hidden p-0 rounded-xl z-[1100]",children:[e.jsxs(Qe,{className:"p-6 pb-4",children:[e.jsx(Xe,{className:"text-xl flex items-center gap-2",children:s?"עריכת השקעה":"הוספת השקעה חדשה"}),e.jsx(Ze,{children:s?"עדכן את פרטי הנכס והערך הנוכחי שלו.":"הוסף נכס חדש למעקב בתיק ההשקעות שלך."})]}),e.jsxs("form",{onSubmit:q,className:"p-6 pt-0 max-h-[85vh] overflow-y-auto pb-32 space-y-6",children:[!s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{className:"font-medium",children:"חפש מניה, ETF או קריפטו"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{value:p,onChange:l=>y(l.target.value),placeholder:"הקלד שם חברה, מניה או קריפטו (למשל: Apple, AAPL, Bitcoin)",onKeyPress:l=>l.key==="Enter"&&F(),className:"flex-1"}),e.jsx(T,{type:"button",onClick:F,disabled:v||!p.trim(),className:"bg-blue-600 hover:bg-blue-700",children:v?"מחפש...":e.jsx(Gs,{className:"w-4 h-4"})})]}),v?e.jsx("div",{className:"text-center text-gray-500 py-4",children:"מחפש נכסים בכל השווקים..."}):_.length>0&&e.jsxs("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:[e.jsx("h4",{className:"font-medium text-gray-700",children:"תוצאות חיפוש:"}),_.map((l,N)=>e.jsx("div",{onClick:()=>b(l),className:"p-3 border rounded-lg cursor-pointer hover:bg-blue-50 transition-colors",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h5",{className:"font-semibold",children:l.name}),e.jsxs("span",{className:"text-gray-600",children:["(",l.ticker,")"]}),l.source==="israeli"&&e.jsx(Q,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700",children:"🇮🇱 ישראלי"}),l.source==="crypto"&&e.jsx(Q,{variant:"outline",className:"text-xs bg-orange-50 text-orange-700",children:"₿ קריפטו"}),l.source==="international"&&e.jsx(Q,{variant:"outline",className:"text-xs bg-green-50 text-green-700",children:"🌍 בינ'ל"})]}),e.jsxs("div",{className:"text-sm text-gray-500 mt-1",children:[l.exchange," • ",l.sector||l.asset_type]})]}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-bold text-lg",children:l.current_price?e.jsxs(e.Fragment,{children:[new Intl.NumberFormat("he-IL",{style:"decimal",minimumFractionDigits:l.source==="israeli"?0:2,maximumFractionDigits:l.source==="crypto"?6:2}).format(l.current_price),e.jsx("span",{className:"text-sm text-gray-500 mr-1",children:l.currency==="ILS"?"₪":l.currency==="USD"?"$":"€"})]}):e.jsx("span",{className:"text-gray-400",children:"לא זמין"})}),l.source==="israeli"&&e.jsx("div",{className:"text-xs text-gray-500",children:"באגורות"})]})]})},N))]})]}),z&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(es,{className:"w-5 h-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold text-amber-800",children:"מניה ישראלית זוהתה"}),e.jsx("p",{className:"text-amber-700 mt-1",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(C,{children:"סוג נכס"}),e.jsxs(Re,{value:a.asset_type,onValueChange:l=>V("asset_type",l),children:[e.jsx(Me,{children:e.jsx($e,{})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"stocks",children:"מניות"}),e.jsx(ae,{value:"etf",children:"קרנות סל (ETF)"}),e.jsx(ae,{value:"bonds",children:"איגרות חוב"}),e.jsx(ae,{value:"mutual_funds",children:"קרנות נאמנות"}),e.jsx(ae,{value:"crypto",children:"קריפטו"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"מטבע"}),e.jsxs(Re,{value:a.currency,onValueChange:l=>V("currency",l),disabled:z,children:[e.jsx(Me,{children:e.jsx($e,{})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"USD",children:"דולר ($)"}),e.jsx(ae,{value:"ILS",children:"שקל (₪)"}),e.jsx(ae,{value:"EUR",children:"יורו (€)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"asset_name",children:"שם הנכס/מניה"}),e.jsx(B,{id:"asset_name",name:"asset_name",value:a.asset_name,onChange:l=>V("asset_name",l.target.value),placeholder:"שם החברה/קריפטו",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"סימול (Ticker)"}),e.jsx(B,{value:a.ticker_symbol,onChange:l=>{V("ticker_symbol",l.target.value.toUpperCase()),D(!1),Z(!1),S(!1),d(null)},placeholder:"AAPL, BTC-USD, ELAL.TA"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"סקטור"}),e.jsx(B,{value:a.sector,onChange:l=>V("sector",l.target.value),placeholder:"טכנולוגיה, פיננסים וכו'"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"כמות יחידות"}
42),e.jsx(B,{type:"number",step:"any",value:a.quantity,onChange:l=>V("quantity",l.target.value),placeholder:"10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["מחיר רכישה ליחידה",z&&e.jsx("span",{className:"text-amber-600 font-normal",children:" (באגורות כמו בבורסה)"})]}),e.jsx(B,{type:"number",step:"any",value:a.purchase_price,onChange:l=>V("purchase_price",l.target.value),placeholder:z?"15000 (באגורות)":"150.00"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["מחיר נוכחי ליחידה",z&&e.jsx("span",{className:"text-amber-600 font-normal",children:" (באגורות כמו בבורסה)"})]}),e.jsx(B,{type:"number",step:"any",value:a.current_price,onChange:l=>V("current_price",l.target.value),placeholder:z?"15500 (באגורות)":"155.00"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"תאריך רכישה"}),e.jsx(B,{type:"date",value:a.purchase_date,onChange:l=>V("purchase_date",l.target.value)})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-purple-50 to-indigo-50 p-4 rounded-lg border border-purple-200",children:[e.jsxs("div",{className:"flex items-center space-x-2 rtl:space-x-reverse mb-3",children:[e.jsx(Ls,{id:"performAnalysis",checked:u,onCheckedChange:D,disabled:!a.ticker_symbol||s!=null}),e.jsxs(C,{htmlFor:"performAnalysis",className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(ve,{className:"w-4 h-4 text-purple-600"}),"בצע ניתוח A10F-Score אוטומטי (למניות חדשות בלבד)"]})]}),e.jsx("p",{className:"text-sm text-purple-700",children:"המערכת תנתח את המניה על פי 10 קריטריונים מתקדמים ותספק ציון השקעה מקצועי. ניתוח זמין רק עבור נכסים חדשים ובעלי סימול."}),H&&e.jsxs("div",{className:"mt-4 p-3 text-center text-gray-600 flex items-center justify-center gap-2",children:[e.jsx(Oe,{className:"w-5 h-5 animate-spin"}),"מבצע ניתוח AI..."]}),!H&&ee&&U&&e.jsxs("div",{className:"mt-4 p-3 bg-white rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ss,{className:"w-4 h-4 text-yellow-500"}),e.jsxs("span",{className:"font-semibold",children:["ציון A10F: ",U.weighted_score]}),e.jsx(Q,{className:`${U.weighted_score>=80?"bg-green-100 text-green-800":U.weighted_score>=60?"bg-yellow-100 text-yellow-800":"bg-red-100 text-red-800"}`,children:U.letter_grade})]}),U.thesis_5y&&e.jsx("p",{className:"text-sm text-gray-700 line-clamp-2",children:U.thesis_5y}),e.jsx(T,{type:"button",variant:"link",className:"p-0 h-auto text-sm mt-2",onClick:()=>{D(!0),S(!1),d(null)},children:"בצע ניתוח מחדש"})]}),!H&&u&&!ee&&a.ticker_symbol&&e.jsx("div",{className:"mt-4 p-3 text-center text-gray-600",children:'לחץ "הוסף להשקעות" כדי לבצע ניתוח A10F-Score.'})]}),a.quantity&&a.purchase_price&&e.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[e.jsxs("h4",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(Ts,{className:"w-5 h-5 text-green-600"}),"סיכום ההשקעה"]}),z&&e.jsx("div",{className:"bg-blue-100 border-r-4 border-blue-500 text-blue-800 p-2 text-xs rounded-md mb-3",children:e.jsx("p",{className:"font-medium",children:"מחירים מוצגים בשקלים לאחר המרה אוטומטית מאגורות"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"סך השקעה:"}),e.jsx("p",{className:"font-bold",children:Ge($.totalInvestment,"ILS")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"שווי נוכחי:"}),e.jsx("p",{className:"font-bold",children:Ge($.currentValue,"ILS")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"רווח/הפסד:"}),e.jsxs("p",{className:`font-bold ${$.returnAmount>=0?"text-green-600":"text-red-600"}`,children:[$.returnAmount>=0?"+":"",Ge($.returnAmount,"ILS")]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-600",children:"תשואה:"}),e.jsxs("p",{className:`font-bold ${$.returnPercentage>=0?"text-green-600":"text-red-600"}`,children:[$.returnPercentage>=0?"+":"",$.returnPercentage.toFixed(2),"%"]})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(T,{type:"submit",disabled:!a.asset_name||!a.quantity||!a.purchase_price||H,className:"flex-1 bg-blue-600 hover:bg-blue-700",children:H?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 ml-2 animate-spin"}),"מבצע ניתוח ושומר..."]}):s?"עדכן השקעה":"הוסף להשקעות"}),e.jsx(T,{type:"button",variant:"outline",onClick:i,className:"flex-1",children:"ביטול"})]})]})]})})}function wt({isOpen:r,onClose:i,onSave:m,property:s}
42){const[a,h]=o.useState({property_type:"",size_sqm:"",rooms:"",location:{city:"",neighborhood:"",address:""},financial_details:{purchase_price:"",down_payment:"",loan_amount:"",monthly_rent:"",monthly_expenses:""},purchase_date:"",status:"rented",current_estimated_value:""}),[p,y]=o.useState(!1);o.useEffect(()=>{var A,M,u,D,H,Z,ee,S;h(s?{property_type:s.property_type||"",size_sqm:s.size_sqm||"",rooms:s.rooms||"",location:{city:((A=s.location)==null?void 0:A.city)||"",neighborhood:((M=s.location)==null?void 0:M.neighborhood)||"",address:((u=s.location)==null?void 0:u.address)||""},financial_details:{purchase_price:((D=s.financial_details)==null?void 0:D.purchase_price)||"",down_payment:((H=s.financial_details)==null?void 0:H.down_payment)||"",loan_amount:((Z=s.financial_details)==null?void 0:Z.loan_amount)||"",monthly_rent:((ee=s.financial_details)==null?void 0:ee.monthly_rent)||"",monthly_expenses:((S=s.financial_details)==null?void 0:S.monthly_expenses)||""},purchase_date:s.purchase_date?new Date(s.purchase_date).toISOString().split("T")[0]:"",status:s.status||"rented",current_estimated_value:s.current_estimated_value||""}:{property_type:"",size_sqm:"",rooms:"",location:{city:"",neighborhood:"",address:""},financial_details:{purchase_price:"",down_payment:"",loan_amount:"",monthly_rent:"",monthly_expenses:""},purchase_date:"",status:"rented",current_estimated_value:""})},[s,r]);const _=A=>{const{name:M,value:u}=A.target;h(D=>({...D,[M]:u}))},x=A=>{const{name:M,value:u}=A.target;h(D=>({...D,financial_details:{...D.financial_details,[M]:u}}))},v=A=>{const{name:M,value:u}=A.target;h(D=>({...D,location:{...D.location,[M]:u}}))},X=async()=>{y(!0);try{const{location:A,property_type:M,financial_details:u,purchase_date:D,size_sqm:H,rooms:Z}=a;if(!A.city||!A.neighborhood||!u.purchase_price){alert("אנא מלא את כל פרטי המיקום ומחיר הרכישה לפני שמירה."),y(!1);return}const ee=D?new Date(D).getFullYear():"",S=H?`גודל: ${H} מ"ר`:"",U=Z?`מספר חדרים: ${Z}`:"",d=`
43        מהי הערכת השווי העדכנית (שווי שוק) ומהי הערכת שכר הדירה החודשי לנכס עם המאפיינים הבאים:
44        - סוג הנכס: '${M}'
45        - עיר: '${A.city}'
46        - שכונה: '${A.neighborhood}'
47        ${S?`- ${S}`:""}
48        ${U?`- ${U}`:""}
49        - נרכש בשנת: ${ee}
50        - נרכש במחיר: ${u.purchase_price} ש"ח
51
52        בסס את הערכתך על מחירי עסקאות ושכירות שבוצעו לאחרונה באזור עבור נכסים דומים.
53        התשובה חייבת להיות בפורמט JSON, וכלול בה רק את הערכים המספריים של השווי ושל שכר הדירה בשקלים חדשים.
54        
55        פורמט JSON לדוגמה: 
56        {
57          "current_estimated_value": 3500000,
58          "estimated_monthly_rent": 7500
59        }
60      `,F=await pe.InvokeLLM({prompt:d,add_context_from_internet:!0,response_json_schema:{type:"object",properties:{current_estimated_value:{type:"number"},estimated_monthly_rent:{type:"number"}},required:["current_estimated_value","estimated_monthly_rent"]}}),{current_estimated_value:b,estimated_monthly_rent:V}=F,G={...a,financial_details:{purchase_price:parseFloat(a.financial_details.purchase_price)||0,down_payment:parseFloat(a.financial_details.down_payment)||0,loan_amount:parseFloat(a.financial_details.loan_amount)||0,monthly_rent:V||parseFloat(a.financial_details.monthly_rent)||0,monthly_expenses:parseFloat(a.financial_details.monthly_expenses)||0},current_estimated_value:b||parseFloat(a.financial_details.purchase_price)||0,purchase_date:a.purchase_date};m(G),i()}catch(A){console.error("Error fetching property estimates:",A),alert("שגיאה בקבלת הערכת שווי ודמי שכירות מהמערכת. אנא בדוק את הפרטים ונסה שוב.")}finally{y(!1)}};return r?e.jsx(Ye,{open:r,onOpenChange:i,children:e.jsxs(Ke,{className:"max-w-4xl",dir:"rtl",children:[e.jsxs(Qe,{children:[e.jsxs(Xe,{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-6 h-6 text-green-600"}),s?'עריכת נכס נדל"ן':'הוספת נכס נדל"ן לפורטפוליו']}),e.jsx(Ze,{children:"מלא את הפרטים כדי להוסיף את הנכס לתיק ההשקעות שלך."})]}),e.jsxs("div",{className:"grid gap-6 py-4 max-h-[70vh] overflow-y-auto px-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-gray-800",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(C,{htmlFor:"property_type",children:"סוג הנכס"}),e.jsxs(Re,{name:"property_type",value:a.property_type,onValueChange:A=>h({...a,property_type:A}),children:[e.jsx(Me,{children:e.jsx($e,{placeholder:"בחר סוג נכס"})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"apartment",children:"דירה"}),e.jsx(ae,{value:"house",children:"בית פרטי"}),e.jsx(ae,{value:"commercial",children:"מסחרי"}),e.jsx(ae,{value:"land",children:"קרקע"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"status",children:"סטטוס"}),e.jsxs(Re,{name:"status",value:a.status,onValueChange:A=>h({...a,status:A}),children:[e.jsx(Me,{children:e.jsx($e,{})}),e.jsxs(qe,{children:[e.jsx(ae,{value:"rented",children:"מושכר"}),e.jsx(ae,{value:"for_sale",children:"למכירה"}),e.jsx(ae,{value:"personal_use",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(C,{htmlFor:"size_sqm",children:'גודל (מ"ר)'}),e.jsx(B,{id:"size_sqm",name:"size_sqm",type:"number",placeholder:"לדוגמה: 85",value:a.size_sqm,onChange:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"rooms",children:"מספר חדרים"}),e.jsx(B,{id:"rooms",name:"rooms",type:"number",placeholder:"לדוגמה: 4",value:a.rooms,onChange:_})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-gray-800",children:"מיקום"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"city",children:"עיר"}),e.jsx(B,{id:"city",name:"city",value:a.location.city,onChange:v,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"neighborhood",children:"שכונה"}),e.jsx(B,{id:"neighborhood",name:"neighborhood",value:a.location.neighborhood,onChange:v,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"address",children:"כתובת"}),e.jsx(B,{id:"address",name:"address",value:a.location.address,onChange:v,required:!0})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-gray-800",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(C,{htmlFor:"purchase_price",children:"מחיר רכישה"}),e.jsx(B,{id:"purchase_price",name:"purchase_price",type:"number",value:a.financial_details.purchase_price,onChange:x,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"down_payment",children:"הון עצמי"}),e.jsx(B,{id:"down_payment",name:"down_payment",type:"number",value:a.financial_details.down_payment,onChange:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"loan_amount",children:"סכום משכנתא"}),e.jsx(B,{id:"loan_amount",name:"loan_amount",type:"number",value:a.financial_details.loan_amount,onChange:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"monthly_expenses",children:"הוצאות חודשיות (ללא משכנתא)"}),e.jsx(B,{id:"monthly_expenses",name:"monthly_expenses",type:"number",value:a.financial_details.monthly_expenses,onChange:x,placeholder:"ועד בית, ארנונה וכו'"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"purchase_date",children:"תאריך רכישה"}),e.jsx(B,{id:"purchase_date",name:"purchase_date",type:"date",value:a.purchase_date,onChange:_})]})]}),e.jsx("p",{className:"text-xs text-gray-500 pt-2",children:"שווי הנכס הנוכחי ודמי השכירות החודשיים יוערכו אוטומטית על ידי המערכת לפי נתוני השוק."})]})]}),e.jsxs(us,{children:[e.jsx(Fs,{asChild:!0,children:e.jsx(T,{type:"button",variant:"outline",disabled:p,children:"ביטול"})}),e.jsx(T,{type:"button",onClick:X,disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4 ml-2 animate-spin"}),"מעריך שווי ושומר..."]}):"שמור נכס"})]})]})}):null}const St=({active:r,payload:i,label:m})=>
60{if(r&&i&&i.length){const s=i[0].payload,a=new Date(s.date),h=Fe(a,"d MMMM yyyy",{locale:gs});return e.jsxs("div",{className:"p-4 bg-white/80 dark:bg-gray-900/80 backdrop-blur-sm rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 text-right",dir:"rtl",children:[e.jsx("p",{className:"font-bold text-gray-800 dark:text-gray-200",children:h}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["שווי התיק: ",e.jsx("span",{className:"font-semibold",children:new Intl.NumberFormat("he-IL",{style:"currency",currency:"ILS"}).format(s.totalValue)})]}),s.transaction&&e.jsxs("div",{className:`mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 flex items-center gap-2 ${s.transaction.type==="buy"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[s.transaction.type==="buy"?e.jsx(ft,{className:"w-4 h-4"}):e.jsx(gt,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-semibold",children:[s.transaction.type==="buy"?"קנייה":"מכירה",": ",s.transaction.name]}),e.jsxs("span",{children:["(",new Intl.NumberFormat("he-IL",{style:"currency",currency:"ILS"}).format(s.transaction.amount),")"]})]})]})}return null},kt=r=>{const{cx:i,cy:m,payload:s}=r;return s.transaction?e.jsx(st,{cx:i,cy:m,r:5,fill:s.transaction.type==="buy"?"#16a34a":"#dc2626",stroke:"#fff",strokeWidth:2}):null};function Ct({snapshots:r,transactions:i,isLoading:m}){const s=o.useMemo(()=>{if(!r||!i)return[];const h=r.map(x=>({date:Fe(new Date(x.snapshot_date),"yyyy-MM-dd"),totalValue:Number(x.total_value_ils),transaction:null})),p=i.map(x=>({date:Fe(new Date(x.transaction_date),"yyyy-MM-dd"),totalValue:Number(x.portfolio_value_after),transaction:{type:x.transaction_type,name:x.asset_name,amount:Number(x.transaction_amount)}})),y=[...h,...p].filter(x=>x.date&&typeof x.totalValue=="number"&&!isNaN(x.totalValue)).sort((x,v)=>new Date(x.date).getTime()-new Date(v.date).getTime()),_=new Map;for(const x of y)if(_.has(x.date)){const v=_.get(x.date);x.transaction?_.set(x.date,x):v.transaction||_.set(x.date,x)}else _.set(x.date,x);return Array.from(_.values()).sort((x,v)=>new Date(x.date).getTime()-new Date(v.date).getTime())},[r,i]);if(m)return e.jsx("div",{className:"flex items-center justify-center h-[400px] bg-gray-50 dark:bg-gray-800/20 rounded-xl",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"טוען את היסטוריית התיק..."})]})});if(!s||s.length<2)return e.jsxs(W,{className:"border-0 shadow-lg bg-gray-50 dark:bg-gray-800/20",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-gray-800 dark:text-gray-200",children:[e.jsx(Ue,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"}),"היסטוריית שווי התיק"]})}),e.jsx(K,{className:"h-72 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:"אין מספיק נתונים להצגת גרף."}),e.jsx("p",{className:"text-sm",children:"הוסף נכסים והיסטוריה תתחיל להצטבר."})]})})]});const a=[Math.min(...s.map(h=>h.totalValue))*.95,Math.max(...s.map(h=>h.totalValue))*1.05];return e.jsxs(W,{className:"border-0 shadow-lg bg-gray-50 dark:bg-gray-800/20",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-gray-800 dark:text-gray-200",children:[e.jsx(Ue,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),"היסטוריית שווי התיק"]})}),e.jsx(K,{className:"h-[400px] p-2",children:e.jsx(hs,{width:"100%",height:"100%",children:e.jsxs(Ks,{data:s,margin:{top:10,right:30,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorUv",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]})}),e.jsx(Qs,{strokeDasharray:"3 3",stroke:"#e0e0e0",className:"dark:stroke-gray-700"}),e.jsx(Xs,{dataKey:"date",tickFormatter:h=>Fe(new Date(h),"MMM yy",{locale:gs}
60),angle:-45,textAnchor:"end",height:60,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},axisLine:{stroke:"hsl(var(--border))"},tickLine:{stroke:"hsl(var(--border))"}}),e.jsx(Zs,{tickFormatter:h=>new Intl.NumberFormat("he-IL",{notation:"compact",style:"currency",currency:"ILS"}).format(h),domain:a,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},axisLine:{stroke:"hsl(var(--border))"},tickLine:{stroke:"hsl(var(--border))"}}),e.jsx(ps,{content:e.jsx(St,{})}),e.jsx(et,{type:"monotone",dataKey:"totalValue",name:"שווי התיק",stroke:"hsl(var(--primary))",strokeWidth:2,fillOpacity:1,fill:"url(#colorUv)",dot:e.jsx(kt,{}),activeDot:{r:8,stroke:"hsl(var(--background))",strokeWidth:2,fill:"hsl(var(--primary))"}})]})})})]})}class At{static async getValuation(i,m,s,a=!1){if(!i||!m||!s)return console.error("Missing parameters for valuation"),null;try{const h=await te.PropertyValuation.filter({property_id:i},"-valuation_date",1);if(h.length>0){const y=h[0];if(Js(new Date,new Date(y.valuation_date))<30&&!a)return console.log(`Using recent valuation for property ${i}`),y}console.log(`Fetching new AI valuation for property ${i}`);const p=await this.getAIValuation(s);return p&&p.estimated_value?await te.PropertyValuation.create({property_id:i,user_email:m,valuation_date:new Date().toISOString().split("T")[0],estimated_value:p.estimated_value,valuation_source:"ai_estimate",confidence_score:p.confidence_score,address_details:{city:s.city,neighborhood:s.neighborhood,street:s.address},market_data:{neighborhood_trend:p.trend}}):null}catch(h){return console.error(`Error getting valuation for property ${i}:`,h),null}}static async getAIValuation(i){const m=`
61      Provide an estimated market value for a residential property in:
62      City: ${i.city}
63      Neighborhood: ${i.neighborhood}
64      Address: ${i.address||"N/A"}
65      
66      Base your analysis on current market trends, recent sales in the area, and economic indicators.
67    `;try{return await pe.InvokeLLM({prompt:m,add_context_from_internet:!0,response_json_schema:{type:"object",properties:{estimated_value:{type:"number",description:"The estimated market value in ILS."},confidence_score:{type:"number",description:"Confidence score from 0 to 100."},trend:{type:"string",description:"Market trend (e.g., 'rising', 'stable', 'falling')."}},required:["estimated_value","confidence_score","trend"]}})}catch(s){return console.error("Error getting AI valuation:",s),null}}}const It=({score:r,size:i=80,strokeWidth:m=8,label:s})=>{const a=(i-m)/2,h=a*2*Math.PI,p=h-r/100*h,_=(v=>v>=80?"text-green-500":v>=60?"text-yellow-500":v>=40?"text-orange-500":"text-red-500")(r),x=_.replace("text-","stroke-");return e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs(cs.div,{className:"relative flex items-center justify-center",style:{width:i,height:i},initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:260,damping:20},children:[e.jsxs("svg",{className:"absolute top-0 left-0",width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[e.jsx("circle",{className:"stroke-gray-200",strokeWidth:m,fill:"transparent",r:a,cx:i/2,cy:i/2}),e.jsx(cs.circle,{className:x,strokeWidth:m,strokeLinecap:"round",fill:"transparent",r:a,cx:i/2,cy:i/2,style:{transform:"rotate(-90deg)",transformOrigin:"center"},strokeDasharray:h,initial:{strokeDashoffset:h},animate:{strokeDashoffset:p},transition:{duration:1,ease:"circOut"}})]}),e.jsxs("div",{className:`absolute flex items-baseline justify-center ${_}`,children:[e.jsx("span",{className:"text-2xl font-bold",children:Math.round(r)}),e.jsx("span",{className:"text-sm font-medium",children:"/100"})]})]}),s&&e.jsx("p",{className:"text-sm font-medium text-gray-700 text-center",children:s})]})},Dt=({stock:r,onScoreUpdate:i})=>{const[m,s]=o.useState({g5x_growth_potential:0,brand_clarity:0,revenue_model_clarity:0,product_quality:0,competitive_moat:0,long_term_thesis:0,founder_involvement:0,crisis_resilience:0,geographic_quality:0,public_selection:0}),[a,h]=o.useState({thesis_5y:"",key_risks:[],evidence_sources:[],confidence_level:"medium"}
67),[p,y]=o.useState(!1),[_,x]=o.useState(!1),[v,X]=o.useState(""),A={g5x_growth_potential:15,brand_clarity:10,revenue_model_clarity:10,product_quality:10,competitive_moat:15,long_term_thesis:15,founder_involvement:5,crisis_resilience:5,geographic_quality:10,public_selection:5},M=[{key:"g5x_growth_potential",name:"פוטנציאל צמיחת רווח פי 5",description:"האם רווחי החברה יכולים לצמוח פי 5 בחמש שנים?"},{key:"brand_clarity",name:"בהירות המותג",description:"עד כמה המותג ברור לצרכן הסופי?"},{key:"revenue_model_clarity",name:"שקיפות מודל הכנסות",description:"עד כמה מודל הכנסות והמימון שקוף ומובן?"},{key:"product_quality",name:"איכות מוצר/שירות",description:"רמת הפרפקציוניזם במוצר או בשירות"},{key:"competitive_moat",name:"יתרון תחרותי",description:"עד כמה קשה לחקות את מה שהחברה עושה?"},{key:"long_term_thesis",name:"תזת השקעה ל-5 שנים",description:"חוזק התזה להחזקה ארוכת טווח"},{key:"founder_involvement",name:"מעורבות מייסד",description:"רמת המעורבות והבעלות של המייסד"},{key:"crisis_resilience",name:"חוסן במשברים",description:"יכולת לעמוד במשברים או כניסה במחיר הזדמנות"},{key:"geographic_quality",name:"איכות גיאוגרפית",description:"איכות המדינות בהן החברה פועלת"},{key:"public_selection",name:"חברה ציבורית נבחרת",description:"נזילות, דיווח איכותי וממשל תאגידי"}];o.useEffect(()=>{if(r!=null&&r.a10f_score&&Object.keys(r.a10f_score).length>0){const d={};Object.keys(m).forEach(F=>{d[F]=r.a10f_score[F]||0}),s(d),h({thesis_5y:r.a10f_score.thesis_5y||"",key_risks:r.a10f_score.key_risks||[],evidence_sources:r.a10f_score.evidence_sources||[],confidence_level:r.a10f_score.confidence_level||"medium"}),x(!0)}},[r]);const u=()=>{let d=0;for(const b in m)A[b]&&(d+=m[b]*A[b]);const F=d/5;return Math.round(F*10)/10},D=d=>d>=90?"A+":d>=85?"A":d>=80?"A-":d>=75?"B+":d>=70?"B":d>=65?"B-":d>=60?"C+":d>=55?"C":d>=50?"C-":d>=40?"D":"F",H=(d,F)=>{s(b=>({...b,[d]:Math.min(5,Math.max(0,parseInt(F)||0))})),x(!0)},Z=async()=>{if(!r.ticker_symbol){X("נדרש סימול מניה (ticker) לביצוע ניתוח אוטומטי.");return}y(!0),X("");const d=`
68      You are an expert equity analyst performing a 10-factor (A10F-Score) analysis for the stock with ticker: ${r.ticker_symbol} (${r.asset_name}).
69      Your task is to provide a detailed, evidence-based assessment.
70      
71      Return a single JSON object with the following structure. Do NOT include any text or explanations outside of the JSON object.
72      The analysis date is ${new Date().toISOString().split("T")[0]}.
73    `,F={type:"object",properties:{g5x_growth_potential:{type:"number",minimum:0,maximum:5},brand_clarity:{type:"number",minimum:0,maximum:5},revenue_model_clarity:{type:"number",minimum:0,maximum:5},product_quality:{type:"number",minimum:0,maximum:5},competitive_moat:{type:"number",minimum:0,maximum:5},long_term_thesis:{type:"number",minimum:0,maximum:5},founder_involvement:{type:"number",minimum:0,maximum:5},crisis_resilience:{type:"number",minimum:0,maximum:5},geographic_quality:{type:"number",minimum:0,maximum:5},public_selection:{type:"number",minimum:0,maximum:5},thesis_5y:{type:"string"},key_risks:{type:"array",items:{type:"string"}},evidence_sources:{type:"array",items:{type:"string"}},confidence_level:{type:"string",enum:["low","medium","high"]}},required:["g5x_growth_potential","brand_clarity","revenue_model_clarity","product_quality","competitive_moat","long_term_thesis","founder_involvement","crisis_resilience","geographic_quality","public_selection","thesis_5y","key_risks","evidence_sources","confidence_level"]};try{const b=await pe.InvokeLLM({prompt:d,add_context_from_internet:!0,response_json_schema:F});if(b&&typeof b=="object"){if(b.thesis_5y){const G=await pe.InvokeLLM({prompt:`Translate the following investment thesis to Hebrew: "${b.thesis_5y}"`});G&&(b.thesis_5y=G)}const V={};for(const G in m)V[G]=Math.min(5,Math.max(0,b[G]||0));s(V),h({thesis_5y:b.thesis_5y||"",key_risks:b.key_risks||[],evidence_sources:b.evidence_sources||[],confidence_level:b.confidence_level||"medium"}),x(!0)}else throw new Error("Invalid AI response format")}catch(b){console.error("AI analysis failed:",b),X("שגיאה בניתוח האוטומטי. אנא נסה שוב או מלא ידנית.")}finally{y(!1)}},ee=()=>{const d=u(),F=D(d),b={...m,...a,weighted_score:d,letter_grade:F,analysis_date:new Date().toISOString().split("T")[0]};i(b)},S=u(),U=D(S);return e.jsx("div",{className:"flex flex-col h-full",dir:"rtl",children:e.jsxs("div",{className:"flex-grow overflow-y-auto space-y-6 pr-3 -mr-3",children:[e.jsxs(W,{children:[e.jsxs(K,{className:"p-4 flex flex-col md:flex-row gap-4",children:[" ",e.jsx(T,{onClick:Z,disabled:p,className:"w-full md:flex-1 bg-gradient-to-r from-purple-500 to-indigo-600 hover:from-purple-600 hover:to-indigo-700 text-white",children:p?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 ml-2 animate-spin"})," מבצע ניתוח AI..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-4 h-4 ml-2"})," בצע ניתוח A10F אוטומטי"]})}),e.jsxs(T,{onClick:ee,disabled:!_,className:"w-full md:flex-1 bg-green-600 hover:bg-green-700 text-white",children:[e.jsx(ct,{className:"w-5 h-5 ml-2"}),"שמור ניתוח A10F"]})]}),v&&e.jsx("p",{className:"text-red-500 text-sm px-4 pb-2 text-center",children:v})]}),e.jsxs(W,{children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-gray-800",children:[e.jsx(ss,{className:"w-5 h-5 text-yellow-500"}),"ציון A10F סופי"]})}),e.jsxs(K,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"text-3xl font-bold text-blue-600",children:S.toFixed(1)}),e.jsx(Q,{className:`text-lg px-3 py-1 ${U.startsWith("A")?"bg-green-100 text-green-800":U.startsWith("B")?"bg-yellow-100 text-yellow-800":"bg-red-100 text-red-800"}`,children:U})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-3",children:e.jsx("div",{className:"bg-gradient-to-r from-red-500 via-yellow-500 to-green-500 h-3 rounded-full transition-all duration-300",style:{width:`${Math.min(100,S)}%`}})})]})]}),e.jsxs(W,{children:[e.jsx(me,{children:e.jsx(xe,{children:"קריטריונים לניקוד"})}),e.jsx(K,{className:"space-y-4",children:M.map(d=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(C,{className:"font-medium",children:d.name}),e.jsxs(Q,{variant:"outline",className:"text-xs",children:["משקל: ",A[d.key],"%"]})]}),e.jsx("p",{className:"text-sm text-gray-600",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"0"}),e.jsx("input",{type:"range",min:"0",max:"5",value:m[d.key],onChange:F=>H(d.key,F.target.value),className:"flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer"}),e.jsx("span",{className:"text-sm font-bold text-blue-600 w-6 text-center",children:m[d.key]})]})]},d.key))})]}),e.jsxs(W,{children:[e.jsx(me,{children:e.jsx(xe,{children:"ניתוח נוסף"})}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(C,{children:"תזת השקעה ל-5 שנים"}),e.jsx(We,{value:a.thesis_5y,onChange:d=>{h(F=>({...F,thesis_5y:d.target.value})),x(!0)},placeholder:"תאר את התזה לטווח הארוך...",className:"mt-1",rows:3})]}),e.jsxs("div",{children:[e.jsx(C,{children:"סיכונים עיקריים"}),e.jsx(We,{value:Array.isArray(a.key_risks)?a.key_risks.join(`
74`):"",onChange:d=>{h(F=>({...F,key_risks:d.target.value.split(`
75`).filter(Boolean)})),x(!0)},placeholder:"רשום סיכון אחד בכל שורה...",className:"mt-1",rows:3})]}),e.jsxs("div",{children:[e.jsx(C,{children:"מקורות מידע"}),e.jsx(We,{value:Array.isArray(a.evidence_sources)?a.evidence_sources.join(`
76`):"",onChange:d=>{h(F=>({...F,evidence_sources:d.target.value.split(`
77`).filter(Boolean)})),x(!0)},placeholder:"רשום מקור אחד בכל שורה...",className:"mt-1",rows:2})]})]})]})]})})},Te=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6"],se=r=>{const i=Number(r);return isNaN(i)||!isFinite(i)?0:i},Lt=(r,i,m)=>{if(r<=0||m<=0)return 0;const s=i/100/12,a=m*12;return r*s*Math.pow(1+s,a)/(Math.pow(1+s,a)-1)},Tt=5,Ft=30;function be({icon:r,label:i,value:m,sub:s,color:a="text-gray-800",warning:h}){return e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-600",children:i})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[h&&e.jsxs(Q,{variant:"outline",className:"text-xs bg-orange-50 text-orange-700 border-orange-200",children:[e.jsx(es,{className:"w-3 h-3 ml-1"}),h]}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${a}`,children:m}),s&&e.jsx("p",{className:"text-xs text-gray-400",children:s})]})]})]})}function Pt({result:r}){if(!r)return null;const{summary:i,strengths:m=[],risks:s=[],actions:a=[]}=r,h={high:"bg-red-100 text-red-700 border-red-200",medium:"bg-orange-100 text-orange-700 border-orange-200",low:"bg-green-100 text-green-700 border-green-200"},p={high:"גבוהה",medium:"בינונית",low:"נמוכה"};return e.jsxs("div",{className:"mt-4 space-y-4 p-4 rounded-xl bg-gradient-to-br from-purple-50 to-indigo-50 border border-purple-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4 text-purple-600"}),e.jsx("h4",{className:"font-bold text-purple-800 text-sm",children:"תובנות AI לתיק"})]}),i&&e.jsx("p",{className:"text-sm text-gray-700 leading-relaxed",children:i}),m.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-green-700 mb-1",children:"חוזקות"}),e.jsx("ul",{className:"space-y-1",children:m.map((y,_)=>e.jsxs("li",{className:"flex items-start gap-1.5 text-xs text-gray-700",children:[e.jsx(mt,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:y})]},_))})]}),s.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-orange-700 mb-1",children:"סיכונים / נקודות לשיפור"}),e.jsx("ul",{className:"space-y-1",children:s.map((y,_)=>e.jsxs("li",{className:"flex items-start gap-1.5 text-xs text-gray-700",children:[e.jsx(es,{className:"w-3.5 h-3.5 text-orange-500 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:y})]},_))})]}),a.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-indigo-700 mb-1.5",children:"פעולות מומלצות"}),e.jsx("div",{className:"space-y-2",children:a.map((y,_)=>e.jsxs("div",{className:"p-2.5 rounded-lg bg-white/70 border border-purple-100",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:y.title}),e.jsx(Q,{variant:"outline",className:`text-xs ${h[y.priority]||h.medium}`,children:p[y.priority]||"בינונית"})]}),y.detail&&e.jsx("p",{className:"text-xs text-gray-600",children:y.detail})]},_))})]}),e.jsx("p",{className:"text-xs text-gray-400 italic",children:"* המידע המוצג אינו מהווה ייעוץ השקעות."})]})}function Et(){return e.jsxs("div",{className:"mt-4 space-y-3 p-4 rounded-xl bg-purple-50 border border-purple-200 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-purple-200 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-purple-100 rounded w-full"}),e.jsx("div",{className:"h-3 bg-purple-100 rounded w-5/6"}),e.jsx("div",{className:"h-20 bg-purple-100 rounded"}),e.jsx("div",{className:"h-20 bg-purple-100 rounded"})]})}function Rt({realEstateAssets:r=[],stockAssets:i=[],cashAccounts:m=[],convertCurrency:s,formatCurrency:a,displayCurrency:h="ILS",user:p,rates:y}){var V,G;
77const[_,x]=o.useState(null),[v,X]=o.useState(!1),[A,M]=o.useState(null),u=o.useMemo(()=>{const L=Array.isArray(r)?r:[],q=Array.isArray(i)?i:[],$=Array.isArray(m)?m:[],z=L.map(g=>{var j;return se(g.current_estimated_value)||se((j=g.financial_details)==null?void 0:j.purchase_price)}),l=q.map(g=>{const j=se(g.current_value)||se(g.total_investment);return s?s(j,g.currency||"ILS","ILS"):j}),N=$.map(g=>{const j=se(g.current_balance);return s?s(j,g.currency||"ILS","ILS"):j}),P=z.reduce((g,j)=>g+j,0),R=l.reduce((g,j)=>g+j,0),J=N.reduce((g,j)=>g+j,0),Y=P+R+J;if(Y===0&&L.length===0&&q.length===0&&$.length===0)return{empty:!0};const ge=Y>0?[{name:'נדל"ן',value:P,pct:P/Y*100},{name:"מניות",value:R,pct:R/Y*100},{name:"מזומן",value:J,pct:J/Y*100}].filter(g=>g.value>0):[],ie={};L.forEach((g,j)=>{var re;const O=((re=g.location)==null?void 0:re.city)||"לא ידוע";ie[O]=(ie[O]||0)+z[j]});const E=Object.entries(ie).map(([g,j])=>({city:g,value:j,pct:P>0?j/P*100:0})).sort((g,j)=>j.value-g.value),ue=P>0?E.reduce((g,j)=>g+Math.pow(j.pct,2),0):0,ne=E[0]||null;let k=0;Y>0&&(L.forEach((g,j)=>{k+=se(g.calculated_roi)*z[j]}),q.forEach((g,j)=>{k+=se(g.return_percentage)*l[j]}),k=k/Y);const ts=L.reduce((g,j)=>{var O;return g+se((O=j.financial_details)==null?void 0:O.loan_amount)},0),ke=P>0?ts/P*100:0,de={ILS:0,USD:0,EUR:0};q.forEach((g,j)=>{const O=(g.currency||"ILS").toUpperCase();de[O]||(de[O]=0),de[O]+=l[j]});const Ce=R>0?Object.entries(de).map(([g,j])=>({currency:g,pct:j/R*100})).filter(g=>g.pct>0):[],Ae=Y>0?J/Y*100:0;let ye=0,fe=!1;return L.forEach(g=>{const j=g.financial_details||{},O=se(j.monthly_rent),re=se(j.monthly_expenses),Ne=se(j.loan_amount);let oe=se(j.monthly_mortgage_payment);Ne>0&&oe<=0&&(oe=Lt(Ne,Tt,Ft),fe=!0),ye+=O-re-oe}),q.forEach(g=>{const j=se(g.annual_dividend);if(j>0)ye+=j/12;else{const O=se(g.dividend_yield),re=se(g.current_value)||se(g.total_investment);O>0&&re>0&&(ye+=re*O/100/12)}}),{empty:!1,totalNetWorth:Y,totalRE:P,totalStocks:R,totalCash:J,allocation:ge,cityBreakdown:E,hhi:ue,topCity:ne,weightedReturn:k,ltv:ke,currencyExposure:Ce,liquidityRatio:Ae,monthlyCashFlow:ye,mortgageEstimated:fe,counts:{re:L.length,stocks:q.length,cash:$.length}}},[r,i,m,s]),D=u.empty?"text-gray-800":u.weightedReturn>=5?"text-green-600":u.weightedReturn>=0?"text-orange-600":"text-red-600",H=u.empty?"text-gray-800":u.ltv<=50?"text-green-600":u.ltv<=70?"text-orange-600":"text-red-600",Z=!u.empty&&u.ltv>70?"מינוף גבוה":null,ee=!u.empty&&u.topCity&&u.topCity.pct>50?"ריכוזיות":null,S=!u.empty&&u.liquidityRatio<5&&u.totalNetWorth>0?"נמוך":null,U=async()=>{var L,q;X(!0),M(null);try{const $=await Pe.optimizePortfolio({}),z=$.data||$;z.error?M(z.error):z.ok?(x(z.ai_recommendations),z.metrics):M("שגיאה בניתוח התיק")}catch($){const z=((q=(L=$==null?void 0:$.response)==null?void 0:L.data)==null?void 0:q.error)||($==null?void 0:$.message)||"שגיאה בניתוח התיק";M(z)}finally{X(!1)}};p&&p.role!=="admin"&&(!p.subscription||((V=p.subscription)==null||V.status));const d=(G=p==null?void 0:p.subscription)==null?void 0:G.plan,F=(p==null?void 0:p.role)==="admin"||["premium","business"].includes(d);if(u.empty)return e.jsxs(W,{className:"border-0 shadow-lg",children:[e.jsx(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 text-lg",children:[e.jsx(os,{className:"w-5 h-5 text-blue-600"}),"בריאות התיק"]})}),e.jsx(K,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx(ds,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"התיק שלך ריק כרגע. הוסיפו נכסים כדי לראות ניתוח בריאות."})]})})]});const b=L=>a?a(L,h):Math.round(L).toLocaleString();return e.jsxs(W,{className:"border-0 shadow-lg",children:[e.jsx(me,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(xe,{className:"flex items-center gap-2 text-lg",children:[e.jsx(os,{className:"w-5 h-5 text-blue-600"}),"בריאות התיק"]}),e.jsxs(Q,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[u.counts.re+u.counts.stocks+u.counts.cash," נכסים"]})]})}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[u.allocation.length>0&&e.jsx("div",{className:"w-32 h-32 flex-shrink-0",children:e.jsx(hs,{width:"100%",height:"100%",children:e.jsxs(tt,{children:[e.jsx(at,{data:u.allocation,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:32,outerRadius:56,paddingAngle:2,children:u.allocation.map((L,q)=>e.jsx(rt,{fill:Te[q%Te.length]},q))}),e.jsx(ps,{formatter:L=>b(L),contentStyle:{direction:"rtl",textAlign:"right",borderRadius:"8px",fontSize:"12px"}})]})})}),e.jsxs("div",{className:"flex-1 w-full space-y-1",children:[u.allocation.map((L,q)=>e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Te[q%Te.length]}}),e.jsx("span",{className:"text-gray-600",children:L.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-semibold text-gray-800",children:[L.pct.toFixed(1),"%"]}),e.jsx("span",{className:"text-xs text-gray-400",children:b(L.value)})]})]},L.name)),u.allocation.length===0&&e.jsx("p",{className:"text-sm text-gray-400 text-center py-4",children:"אין נתוני שווי"})]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx(be,{icon:Ue,label:"תשואה משוקללת",value:`${u.weightedReturn.toFixed(2)}%`,color:D}),e.jsx(be,{icon:ot,label:"מינוף כולל (LTV)",value:`${u.ltv.toFixed(1)}%`,color:H,warning:Z}),u.topCity&&e.jsx(be,{icon:dt,label:"עיר מובילה",value:u.topCity.city,sub:`${u.topCity.pct.toFixed(1)}% מנדל"ן`,warning:ee}),u.currencyExposure.length>0&&e.jsx(be,{icon:Ee,label:"חשיפה מטבעית",value:u.currencyExposure.map(L=>`${L.currency} ${L.pct.toFixed(0)}%`).join(" / ")}),e.jsx(be,{icon:ds,label:"יחס נזילות",value:`${u.liquidityR
77atio.toFixed(1)}%`,color:u.liquidityRatio<5?"text-orange-600":"text-green-600",warning:S}),e.jsx(be,{icon:Ps,label:"תזרים חודשי נטו",value:b(u.monthlyCashFlow),sub:u.mortgageEstimated?"משכנתא משוערת":void 0,color:u.monthlyCashFlow>=0?"text-green-600":"text-red-600"})]}),e.jsx("div",{className:"pt-2 border-t border-gray-100",children:F?e.jsxs(e.Fragment,{children:[e.jsx(T,{onClick:U,disabled:v,className:"w-full bg-gradient-to-r from-purple-500 to-indigo-600 hover:from-purple-600 hover:to-indigo-700 text-white",children:v?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 ml-2 animate-spin"}),"מנתח את התיק..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"w-4 h-4 ml-2"}),"ניתוח AI של התיק"]})}),v&&e.jsx(Et,{}),A&&e.jsx("div",{className:"mt-3 p-3 rounded-lg bg-red-50 border border-red-200",children:e.jsx("p",{className:"text-sm text-red-700",children:A})}),_&&e.jsx(Pt,{result:_})]}):e.jsxs("div",{className:"p-3 rounded-lg bg-gray-50 border border-gray-200 text-center",children:[e.jsx(Es,{className:"w-5 h-5 text-gray-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 mb-1",children:"ניתוח AI של התיק"}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"זמין למנויי Premium ומעלה. שדרגו כדי לקבל תובנות מותאמות אישית."}),e.jsx(T,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:"/Pricing",children:"שדרגו עכשיו"})})]})})]})]})}function na(){var ls;const[r,i]=o.useState(null),[m,s]=o.useState([]),[a,h]=o.useState([]),[p,y]=o.useState([]),[_,x]=o.useState([]),[v,X]=o.useState([]),[A,M]=o.useState([]),[u,D]=o.useState(0),[H,Z]=o.useState(null),[ee,S]=o.useState("initializing"),[U,d]=o.use
77State(0),[F,b]=o.useState("מאתחל את המערכת..."),[V,G]=o.useState(!1),[L,q]=o.useState(""),[$,z]=o.useState(!1),[l,N]=o.useState(!1),[P,R]=o.useState(!1),[J,Y]=o.useState(null),[ge,ie]=o.useState(!1),[E,ue]=o.useState("ILS"),[ne,k]=o.useState({USD_to_ILS:3.75,EUR_to_ILS:4.05}),[ts,ke]=o.useState({}),[de,Ce]=o.useState(!1),[Ae,ye]=o.useState(null),[fe,g]=o.useState(null),{toast:j}=Rs(),[O,re]=o.useState({isOpen:!1,stockToDelete:null,isDeleting:!1}),[Ne,oe]=o.useState(null),he=o.useCallback(async t=>{var f,c;G(!1),q("");try{S("initializing"),d(10),b("מאתחל את המערכת..."),await new Promise(n=>setTimeout(n,500)),S("rates"),d(20),b("טוען שערי חליפין..."),await fs(),await new Promise(n=>setTimeout(n,300)),S("stocks"),d(35),b("טוען השקעות בשוק ההון...");try{const n=await te.InvestmentPortfolio.filter({created_by:t.email});s(n||[])}catch(n){console.warn("Failed to load stocks:",n),s([])}await new Promise(n=>setTimeout(n,400)),S("realestate"),d(50),b('טוען נכסי נדל"ן...');try{const n=await te.PortfolioProperty.filter({created_by:t.email});y(n||[])}catch(n){console.warn("Failed to load real estate:",n),y([])}await new Promise(n=>setTimeout(n,400)),S("savings"),d(65),b("טוען מטרות חסכון...");try{const n=await te.SavingsGoal.filter({created_by:t.email});h(n||[])}catch(n){console.warn("Failed to load savings goals:",n),h([])}await new Promise(n=>setTimeout(n,400)),S("cash"),d(80),b("טוען חשבונות מזומנים...");try{const n=await te.CashAccount.filter({created_by:t.email});x(n||[])}catch(n){console.warn("Failed to load cash accounts:",n),x([])}await new Promise(n=>setTimeout(n,400)),S("history"),d(90),b("טוען היסטוריית תיק...");try{const n=await te.PortfolioSnapshot.filter({user_email:t.email});X(n||[]);const I=await te.PortfolioTransaction.filter({user_email:t.email});M(I||[])}catch(n){console.warn("Failed to load portfolio history:",n),X([]),M([])}d(100),b("סוף טעינה..."),await new Promise(n=>setTimeout(n,300)),S("complete")}catch(n){console.error("Portfolio loading failed:",n),G(!0),(f=n.message)!=null&&f.includes("429")||(c=n.message)!=null&&c.includes("Rate limit")?q("השרת עמוס כרגע. אנא רענן את הדף בעוד מספר דקות."):q("אירעה שגיאה בטעינת נתוני התיק. אנא נסה שוב."),S("error")}},[]),fs=o.useCallback(async()=>{const t="exchangeRatesCache";try{const n=localStorage.getItem(t);if(n){const{rates:I,timestamp:w}=JSON.parse(n);if(Date.now()-w<36e5)return k(I),I}}catch(n){console.error("Could not read from localStorage cache",n)}const c={USD_to_ILS:3.75,EUR_to_ILS:4.05};try{const n=await te.ExchangeRate.list();if(n&&n.length>0){const I={};if(n.forEach(w=>{w.currency_pair&&typeof w.rate=="number"&&(I[w.currency_pair]=w.rate)}),I.USD_to_ILS||I.EUR_to_ILS){const w={...c,...I};k(w);try{localStorage.setItem(t,JSON.stringify({rates:w,timestamp:Date.now()}))}catch{}return w}}}catch(n){console.warn("Could not fetch ExchangeRate entity, using fallback",n)}return k(c),c},[]),Ve=o.useCallback(async()=>{var t,f;try{const c=await te.User.me();i(c),await he(c)}catch(c){console.error("Initialization failed:",c),G(!0),(t=c.message)!=null&&t.includes("401")||(f=c.message)!=null&&f.includes("Unauthorized")?q("יש להתחבר כדי לצפות בתיק ההשקעות."):q("אירעה שגיאה בטעינת הדף. אנא נסה שוב."),S("error")}},[he]);o.useEffect(()=>{Ve()},[Ve]);const as=o.useCallback(()=>!r||Ms(r)||(r==null?void 0:r.role)==="admin"?!1:p.length+m.length>=2,[r,p,m]),ze=()=>{if(as()){oe("properties");return}R(!0)},js=()=>{if(as()){oe("properties");return}N(!0),g(null)},_s=o.useCallback(async()=>{if(r){Ce(!0);try{const t=m.filter(c=>c.ticker_symbol);if(t.length>0){const{data:c}=await Pe.refreshAssetPrices({assetIds:t.map(n=>n.id)});if(c!=null&&c.success){const n=c.refreshed_at?new Date(c.refreshed_at):new Date;ye(n);const I=n.toLocaleTimeString("he-IL",{hour:"2-digit",minute:"2-digit"});try{const w=await te.InvestmentPortfolio.filter({created_by:r.email},"-updated_date");s(w)}catch(w){console.warn("Failed to reload stock assets after price refresh:",w)}j({title:"המחירים עודכנו",description:`${c.updated||0} נכסים עודכנו בהצלחה • שעת עדכון: ${I}${c.skipped?` • ${c.skipped} דילגו (מטמון עדכני)`:""}${c.failed?` • ${c.failed} נכשלו`:""}`})}else throw new Error((c==null?void 0:c.error)||"שגיאה לא צפויה")}const f=await Promise.all(p.map(async c=>{ke(n=>({...n,[c.id]:!0}));try{const n=await At.getValuation(c.id,r.email,c.location,!0);if(n&&n.estimated_value){const I={...c,current_estimated_value:n.estimated_value,last_value_update:new Date().toISOString()};return await te.PortfolioProperty.update(c.id,{current_estimated_value:n.estimated_value,last_value_update:new Date().toISOString()}),I}}catch(n){console.error(`Failed to update valuation for ${c.location.city}`,n)}finally{ke(n=>({...n,[c.id]:!1}))}return c}));y(f)}catch(t){console.error("Error refreshing asset values:",t),j({title:"שגיאה ברענון שווי הנכסים",description:t.message||"נסה שנית מאוחר יותר",variant:"destructive"})}Ce(!1)}},[r,m,p]),le=o.useCallback((t,f,c)=>{if(!ne||f===c||t===void 0||t===null)return t;const n={USD:ne.USD_to_ILS,EUR:ne.EUR_to_ILS,ILS:1},I=n[f],w=n[c];return I===void 0||w===void 0?t:t*I/w},[ne]),rs=o.useMemo(()=>
77{if(!ne)return 0;const t=m.reduce((I,w)=>I+le(w.current_value||w.total_investment||0,w.currency||"ILS",E),0),f=p.reduce((I,w)=>{var je;return I+le(w.current_estimated_value||((je=w.financial_details)==null?void 0:je.purchase_price)||0,"ILS",E)},0),c=a.reduce((I,w)=>I+le(w.current_amount||0,"ILS",E),0),n=_.reduce((I,w)=>I+le(w.current_balance||0,w.currency||"ILS",E),0);return t+f+c+n},[m,a,p,_,E,ne,le]);o.useEffect(()=>{D(rs)},[rs]);const ce=(t,f="ILS")=>{const c={style:"currency",currency:f,maximumFractionDigits:2,minimumFractionDigits:2};try{new Intl.NumberFormat("he-IL",c).format(0)}catch{c.currency="ILS"}return new Intl.NumberFormat("he-IL",c).format(t||0)},bs=({stock:t,setIsAddStockModalOpen:f,setEditingAsset:c,loadPortfolioData:n,user:I,formatCurrency:w,setDeleteConfirmDialog:je})=>{const[Ns,Ie]=o.useState(!1),ws=(t.return_percentage||0)>=0,Be=t.a10f_score&&(t.a10f_score.weighted_score>0||t.a10f_score.analysis_date),Ss=()=>{c(t),f(!0)},ks=()=>{je({isOpen:!0,stockToDelete:t,isDeleting:!1})},Cs=async is=>{try{await te.InvestmentPortfolio.update(t.id,{a10f_score:is}),Ie(!1),await n(I)}catch(Is){console.error("Error updating A10F score:",Is)}},As=async is=>{Ie(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(W,{className:"border-0 shadow-lg hover:shadow-xl transition-shadow duration-300",children:[e.jsx(me,{className:"flex flex-col space-y-0 p-5 pb-0",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center relative",children:[e.jsx(Ee,{className:"w-6 h-6 text-blue-600"}),Be&&e.jsx("div",{className:"absolute -top-1 -right-1 w-4 h-4 bg-gradient-to-r from-purple-500 to-indigo-600 rounded-full flex items-center justify-center",children:e.jsx(ve,{className:"w-2.5 h-2.5 text-white"})})]}),e.jsxs("div",{className:"text-right flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(xe,{className:"text-lg",children:t.asset_name}),t.ticker_symbol&&e.jsx(Q,{variant:"outline",children:t.ticker_symbol}),Be&&e.jsxs(Q,{className:"bg-gradient-to-r from-purple-500 to-indigo-600 text-white text-xs",children:[e.jsx(ve,{className:"w-3 h-3 mr-1"}),"ניתוח AI"]})]}),t.a10f_score&&t.a10f_score.weighted_score!==void 0&&e.jsx("div",{className:"mb-3",children:e.jsx(It,{score:t.a10f_score.weighted_score,total:100,grade:t.a10f_score.letter_grade})}),e.jsxs("div",{className:"flex flex-row gap-2 items-center justify-start mt-2",children:[e.jsx(T,{variant:"ghost",size:"sm",onClick:Ss,className:"text-gray-500 hover:text-blue-600 flex-shrink-0 h-8 px-2",children:e.jsx(ht,{className:"w-4 h-4"})}),e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>As(),className:"text-purple-500 hover:text-purple-700 flex-shrink-0 h-8 px-2",title:"ניתוח AI אוטומטי",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>Ie(!0),className:"text-blue-500 hover:text-blue-700 flex-shrink-0 h-8 px-2",title:"ניתוח A10F-Score",children:e.jsx(ss,{className:"w-4 h-4"})}),e.jsx(T,{variant:"ghost",size:"sm",onClick:ks,className:"text-red-500 hover:text-red-700 flex-shrink-0 h-8 px-2",title:"מחק מניה",children:e.jsx(Bs,{className:"w-4 h-4"})})]})]})]})}),e.jsxs(K,{className:"p-5 pt-0",children:[Be&&t.a10f_score.thesis_5y&&e.jsxs("div",{className:"mb-4 p-3 bg-gradient-to-r from-purple-50 to-indigo-50 rounded-lg border border-purple-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ve,{className:"w-4 h-4 text-purple-600"}),e.jsx("span",{className:"text-sm font-semibold text-purple-800",children:"תזת השקעה AI"})]}),e.jsx("p",{className:"text-sm text-purple-700 line-clamp-2",children:t.a10f_score.thesis_5y})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-x-4 gap-y-2 pt-4 border-t border-gray-100",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"שווי נוכחי"}),e.jsx("p",{className:"font-bold text-base text-gray-800",children:w(t.current_value||t.total_investment,t.currency||"ILS")})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"תשואה"}),e.jsx("p",{className:`font-bold text-base ${ws?"text-green-600":"text-red-600"}`,children:t.return_percentage?`${t.return_percentage.toFixed(2)}%`:"-"})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"כמות"}),e.jsxs("p",{className:"font-semibold text-base text-gray-700",children:[t.quantity," יח׳"]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-gray-500",children:"מחיר ליח׳"}),e.jsx("p",{className:"text-base text-gray-700",children:w(t.current_price||t.purchase_price,t.currency||"ILS")})]})]})]})]}),Ns&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:e.jsx("div",{className:"bg-white rounded-lg max-w-4xl w-full max-h-[90vh] overflow-y-auto",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h2",{className:"text-xl font-bold",children:["ניתוח A10F-Score - ",t.asset_name]}),e.jsx(T,{variant:"ghost",onClick:()=>Ie(!1),children:"×"})]}),e.jsx(Dt,{stock:t,onScoreUpdate:Cs})]})})})]})},vs=async()=>
77{if(O.stockToDelete){re(t=>({...t,isDeleting:!0}));try{await te.InvestmentPortfolio.delete(O.stockToDelete.id),await he(r),re({isOpen:!1,stockToDelete:null,isDeleting:!1})}catch(t){console.error("Error deleting stock:",t),alert("שגיאה במחיקת המניה. אנא נסה שוב."),re(f=>({...f,isDeleting:!1}))}}},ns=()=>{re({isOpen:!1,stockToDelete:null,isDeleting:!1})};return ee!=="complete"&&!V?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-4 md:p-8 flex items-center justify-center",children:e.jsx("div",{className:"max-w-md w-full",children:e.jsx(W,{className:"border-0 shadow-2xl bg-white/90 backdrop-blur-sm",children:e.jsxs(K,{className:"p-8 text-center",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-full bg-gradient-to-r from-blue-500 to-purple-600 flex items-center justify-center shadow-xl",children:e.jsx(Ue,{className:"w-10 h-10 text-white animate-pulse"})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-800 mb-2",children:"טוען את התיק שלך"}),e.jsx("p",{className:"text-gray-600 mb-6 text-sm",children:F}),e.jsx("div",{className:"w-full mb-4",children:e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-3 overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-purple-600 rounded-full transition-all duration-500 ease-out",style:{width:`${U}%`}})})}),e.jsxs("p",{className:"text-blue-600 font-medium text-sm",children:[U,"% הושלם"]}),e.jsx("div",{className:"mt-6 flex justify-center space-x-2 rtl:space-x-reverse",children:["stocks","realestate","savings","cash","history"].map((t,f)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors duration-300 ${ee===t?"bg-blue-500 animate-pulse":["stocks","realestate","savings","cash","history"].indexOf(ee)>f?"bg-green-500":"bg-gray-300"}`},t))})]})})})}):V?e.jsx("div",{className:"min-h-screen bg-gray-50 p-4 md:p-8 flex items-center justify-center",children:e.jsx(nt,{variant:"destructive",className:"max-w-lg text-right bg-red-50 border-red-200",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xt,{className:"h-5 w-5 mt-1 text-red-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(lt,{className:"font-bold text-red-800",children:"שגיאת תקשורת"}),e.jsxs(it,{className:"text-red-700",children:[L,e.jsx(T,{onClick:Ve,variant:"link",className:"p-0 h-auto text-red-700 font-bold ml-2",children:"נסה שוב"})]})]})]})})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-4 md:p-8 pb-32",dir:"rtl",children:[e.jsx(Nt,{isOpen:l,onClose:()=>{N(!1),g(null)},onSave:async t=>{var f,c;try{if(fe)await te.InvestmentPortfolio.update(fe.id,t);else if(!((f=(await Pe.addPortfolioAsset({asset_type:"stock",data:t})).data)!=null&&f.success))throw new Error("Failed to add asset");await he(r),N(!1),g(null)}catch(n){((c=n.response)==null?void 0:c.status)===403?(oe("properties"),N(!1),g(null)):console.error("Error saving stock:",n)}},editingStock:fe}),e.jsx(wt,{isOpen:P,onClose:()=>R(!1),onSave:async t=>{var f,c;try{(f=(await Pe.addPortfolioAsset({asset_type:"real_estate",data:t})).data)!=null&&f.success&&(await he(r),R(!1))}catch(n){((c=n.response)==null?void 0:c.status)===403?oe("properties"):console.error("Error saving real estate property:",n)}}}),J&&e.jsx(Ys,{property:J,isOpen:ge,onClose:()=>{ie(!1),Y(null)},onSuccess:async t=>{await he(r),ie(!1),Y(null),alert(t)}}),e.jsx(Ye,{open:O.isOpen,onOpenChange:t=>!t&&ns(),children:e.jsxs(Ke,{className:"sm:max-w-md",dir:"rtl",children:[e.jsxs(Qe,{children:[e.jsx(Xe,{className:"text-right",children:"מחיקת מניה"}),e.jsxs(Ze,{className:"text-right",children:["האם אתה בטוח שברצונך למחוק את המניה"," ",e.jsx("span",{className:"font-semibold",children:(ls=O.stockToDelete)==null?void 0:ls.asset_name}),"?",e.jsx("br",{}),"פעולה זו לא ניתנת לביטול."]})]}),e.jsxs(us,{className:"flex-row-reverse gap-2",children:[e.jsx(T,{variant:"destructive",onClick:vs,disabled:O.isDeleting,children:O.isDeleting?"מוחק...":"כן, מחק"}),e.jsx(T,{variant:"outline",onClick:ns,disabled:O.isDeleting,children:"ביטול"})]})]})}
77),e.jsxs("div",{className:"max-w-7xl mx-auto space-y-8 mb-8",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4 text-right mb-8",children:[e.jsxs("div",{className:"text-right pt-4 pr-4 sm:pt-0 sm:pr-0",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-extrabold text-gray-800 mb-3",children:"תיק השקעות"}),e.jsx("p",{className:"text-gray-500 text-lg md:text-xl",children:"נהלו את תיק ההשקעות שלכם בצורה חכמה ויעילה"})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2 sm:gap-4 mt-4 md:mt-0",children:[" ",e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsxs(T,{onClick:_s,disabled:de,className:"flex-shrink-0",children:[de?e.jsx(Je,{className:"w-4 h-4 ml-2 animate-spin"}):e.jsx(Je,{className:"w-4 h-4 ml-2"}),"רענן שווי נכסים"]}),Ae&&!de&&e.jsxs("span",{className:"text-xs text-gray-400",children:["עודכן: ",Ae.toLocaleTimeString("he-IL",{hour:"2-digit",minute:"2-digit"})]})]}),e.jsxs(T,{onClick:ze,children:[e.jsx(we,{className:"w-4 h-4 ml-2"}),'הוספת נכס נדל"ן']})]})]}),e.jsxs("main",{className:"space-y-8",children:[e.jsx(W,{className:"glass-effect border-0 shadow-xl",children:e.jsx(K,{className:"p-4 sm:p-6 md:p-8",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 md:w-16 md:h-16 bg-gradient-to-r from-green-500 to-blue-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx($s,{className:"w-6 h-6 md:w-8 md:h-8 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-lg sm:text-xl md:text-2xl font-bold text-gray-800 mb-2",children:"שווי התיק הכולל"}),e.jsx("p",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold text-gray-900 break-all",children:ce(u,E)})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4 sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 font-medium",children:"מטבע תצוגה:"}),e.jsxs("div",{className:"flex items-center bg-white/80 backdrop-blur-sm rounded-lg p-1 border border-gray-200 shadow-sm",children:[e.jsxs("button",{onClick:()=>ue("ILS"),className:`flex items-center gap-1 px-2 py-1 rounded-md text-sm font-semibold transition-all duration-200 ${E==="ILS"?"bg-blue-600 text-white shadow-sm":"text-gray-600 hover:bg-blue-50 hover:text-blue-600"}`,children:[e.jsx("span",{className:"text-base",children:"₪"}),e.jsx("span",{className:"text-xs",children:"ILS"})]}),e.jsxs("button",{onClick:()=>ue("USD"),className:`flex items-center gap-1 px-2 py-1 rounded-md text-sm font-semibold transition-all duration-200 ${E==="USD"?"bg-blue-600 text-white shadow-sm":"text-gray-600 hover:bg-blue-50 hover:text-blue-600"}`,children:[e.jsx("span",{className:"text-base",children:"$"}),e.jsx("span",{className:"text-xs",children:"USD"})]}),e.jsxs("button",{onClick:()=>ue("EUR"),className:`flex items-center gap-1 px-2 py-1 rounded-md text-sm font-semibold transition-all duration-200 ${E==="EUR"?"bg-blue-600 text-white shadow-sm":"text-gray-600 hover:bg-blue-50 hover:text-blue-600"}`,children:[e.jsx("span",{className:"text-base",children:"€"}),e.jsx("span",{className:"text-xs",children:"EUR"})]})]})]}),e.jsx("div",{className:"w-full sm:w-auto",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(T,{onClick:()=>N(!0),variant:"outline",className:"flex-1 sm:flex-none px-6 py-3 border-2 border-blue-200 hover:border-blue-300 hover:bg-blue-50",children:[e.jsx(ut,{className:"w-4 h-4 ml-2"}),"הוסף מניה"]}),e.jsx(Ds,{to:qs("Calculator"),className:"block flex-1 sm:flex-none",children:e.jsxs(T,{variant:"outline",className:"w-full px-6 py-3 border-2 border-blue-200 hover:border-blue-300 hover:bg-blue-50",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"הוסף נכס"]})})]})})]})]})})}),e.jsx(Ct,{snapshots:v,transactions:A,isLoading:!1}),e.jsxs(Ws,{defaultValue:"overview",className:"w-full",children:[e.jsxs(Hs,{className:"grid w-full grid-cols-4",children:[e.jsx(De,{value:"stocks",children:"שוק ההון"}),e.jsx(De,{value:"real_estate",children:"נדל״ן"}),e.jsx(De,{value:"savings",children:"חסכונות"}),e.jsx(De,{value:"overview",children:"סקירה"})]}),e.jsxs(Le,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-blue-100",children:e.jsx(Ee,{className:"w-5 h-5 text-blue-600"})}),e.jsx(Q,{variant:"outline",className:"bg-blue-50 text-blue-700 text-xs",children:"שוק ההון"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(m.reduce((t,f)=>t+le(f.current_value||f.total_investment||0,f.currency||"ILS",E),0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[m.length," נכסים"]})]})}),e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-green-100",children:e.jsx(we,{className:"w-5 h-5 text-green-600"})}),e.jsx(Q,{variant:"outline",className:"bg-green-50 text-green-700 text-xs",children:"נדל״ן"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(p.reduce((t,f)=>{var c;return t+le(f.current_estimated_value||((c=f.financial_details)==null?void 0:c.purchase_price)||0,"ILS",E)},0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[p.length," נכסים"]})]})}),e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-purple-100",children:e.jsx(He,{className:"w-5 h-5 text-purple-600"})}),e.jsx(Q,{variant:"outline",className:"bg-purple-50 text-purple-700 text-xs",children:"חסכונות"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(a.reduce((t,f)=>t+le(f.current_amount||0,"ILS",E),0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[a.length," מטרות"]})]})}),e.jsx(W,{className:"border-0 shadow-lg",children:e.jsxs(K,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"p-2 rounded-xl bg-yellow-100",children:e.jsx(Os,{className:"w-5 h-5 text-yellow-600"})}),e.jsx(Q,{variant:"outline",className:"bg-yellow-50 text-yellow-700 text-xs",children:"מזומנים"})]}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:ce(_.reduce((t,f)=>t+le(f.current_balance||0,f.currency||"ILS",E),0),E)}),e.jsxs("p",{className:"text-gray-600 text-sm",children:[_.length," חשבונות"]})]})})]}
77),e.jsx(Rt,{realEstateAssets:p,stockAssets:m,cashAccounts:_,convertCurrency:le,formatCurrency:ce,displayCurrency:E,user:r,rates:ne})]}),e.jsxs(Le,{value:"stocks",className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"השקעות בשוק ההון"}),e.jsxs(T,{onClick:js,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"הוסף השקעה"]})]}),m.length>0?e.jsx("div",{className:"space-y-4",children:m.map(t=>e.jsx(bs,{stock:t,setIsAddStockModalOpen:N,setEditingAsset:g,loadPortfolioData:he,user:r,formatCurrency:ce,setDeleteConfirmDialog:re},t.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"אין השקעות בשוק ההון"}),e.jsx("p",{className:"text-gray-500 mb-6",children:"התחל לנהל את תיק המניות והאגח שלך"}),e.jsxs(T,{onClick:()=>{N(!0),g(null)},className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"הוסף השקעה ראשונה"]})]})]}),e.jsxs(Le,{value:"real_estate",className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"נכסי נדל״ן"}),e.jsxs(T,{onClick:ze,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"הוסף נכס"]})]}),p.length>0?e.jsx("div",{className:"space-y-4",children:p.map(t=>{var f,c,n,I;return e.jsx(W,{className:"border-0 shadow-lg hover:shadow-xl transition-shadow duration-300",children:e.jsx(K,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-green-100 to-green-200 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(we,{className:"w-8 h-8 text-green-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h4",{className:"font-bold text-xl text-gray-900",children:(f=t.location)==null?void 0:f.city}),e.jsx(Q,{className:"text-xs px-2 py-1 bg-blue-100 text-blue-800",children:t.status==="for_sale"?"למכירה":t.status==="personal_use"?"שימוש אישי":"מושכר"})]}),e.jsxs("p",{className:"text-gray-600 mb-3 font-medium",children:[(c=t.location)==null?void 0:c.neighborhood,((n=t.location)==null?void 0:n.address)&&` • ${t.location.address}`]})]})]}),e.jsxs("div",{className:"w-full sm:w-auto text-center sm:text-right mt-4 pt-4 border-t border-gray-100 sm:mt-0 sm:pt-0 sm:border-0",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:"שווי נוכחי"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:ce(le(t.current_estimated_value||((I=t.financial_details)==null?void 0:I.purchase_price)||0,"ILS",E),E)})]})]})})},t.id)})}):e.jsxs(W,{className:"border-dashed border-2 text-center py-12",children:[e.jsx(we,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"אין נכסי נדל״ן"}),e.jsx("p",{className:"text-gray-500 mb-6",children:"התחל לניהל את נכסי הנדל״ן שלך"}),e.jsxs(T,{onClick:ze,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Us,{className:"w-4 h-4 ml-2"}),"הוסף נכס ראשון"]})]})]}),e.jsxs(Le,{value:"savings",className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"מטרות חסכון"}),e.jsxs(T,{className:"bg-purple-600 hover:bg-purple-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}),"הוסף מטרה"]})]}),a.length>0?e.jsx("div",{className:"space-y-4",children:a.map(t=>{const f=t.target_amount>0?t.current_amount/t.target_amount*100:0;return e.jsx(W,{className:"border-0 shadow-lg",children:e.jsx(K,{className:"p-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center",children:e.jsx(He,{className:"w-6 h-6 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-lg",children:t.goal_name}),e.jsx(Q,{className:"text-xs bg-purple-100 text-purple-800",children:t.goal_type})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-lg font-bold",children:[ce(t.current_amount||0,"ILS")," / ",ce(t.target_amount,"ILS")]}),e.jsxs("p",{className:"text-sm text-gray-500",children:[f.toFixed(1),"% הושלם"]})]})]}),e.jsx("div",{children:e.jsx(Vs,{value:f,className:"h-3"})})]})})},t.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(He,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-600 mb-2",children:"אין מטרות חסכון"}),e.jsx("p",{className:"text-gray-500 mb-6",children:"הגדר מטרות חסכון ועקוב אחרי ההתקדמות שלך"}),e.jsxs(T,{className:"bg-purple-600 hover:bg-purple-700",children:[e.jsx(_e,{className:"w-4 h-4 ml-2"}
77),"הגדר מטרה ראשונה"]})]})]})]})]}),e.jsx(zs,{isOpen:!!Ne,onClose:()=>oe(null),limitType:Ne||"properties"})]})]})}export{na 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.