PageSourceSearch

https://doxxo.ai/assets/DeadlineExtractor-sFO_YOyp.js

js doxxo.ai collected 2026-10-05 12:52:04 UTC 12,138 bytes, 2 lines download raw bytes

1import{r as c,j as e}from"./vendor-react-BGSoyBC3.js";import{m as W,v as q,a as E,B as p,w as g}from"./index-CY3lR3NC.js";import{T as H}from"./ToolLayout-DPKnREsn.js";import{u as b,w as J}from"./xlsx-3SA47z_C.js";import{u as Q}from"./useRatingPrompt-1JiFOz2t.js";import{L as ee,c as re}from"./acceptedFormats-D4lt7omL.js";import{bk as y,ai as te,e as se,X as ae,L as ne,al as le,g as oe,D as ie,ao as de,aa as ce,aA as me,ae as xe,C as ue}from"./vendor-icons-0KQIW_PB.js";import"./vendor-trpc-C-BLj2ba.js";import"./vendor-react-dom-CzqU2IQt.js";import"./vendor-ui-BKDt2K1P.js";import"./vendor-router-Bky5zxn0.js";import"./vendor-charts-BBE7Gg4G.js";import"./GulfWorkspaceLayout-E_582nAN.js";import"./ServiceIcon-DMw7eqxZ.js";import"./ToolContentSkeleton-BI4eFRuM.js";const pe=["application/pdf","image/jpeg","image/png","image/webp","image/gif"],ge=/\.(pdf|jpe?g|png|webp|gif)$/i,be=20,A={overdue:{bg:"bg-red-50 dark:bg-red-950/30",border:"border-red-200 dark:border-red-800",text:"text-red-700 dark:text-red-400",dot:"bg-red-500",label:"Overdue",labelAr:"متأخر"},urgent:{bg:"bg-orange-50 dark:bg-orange-950/30",border:"border-orange-200 dark:border-orange-800",text:"text-orange-700 dark:text-orange-400",dot:"bg-orange-500",label:"Urgent",labelAr:"عاجل"},soon:{bg:"bg-yellow-50 dark:bg-yellow-950/30",border:"border-yellow-200 dark:border-yellow-800",text:"text-yellow-700 dark:text-yellow-400",dot:"bg-yellow-500",label:"Soon",labelAr:"قريباً"},upcoming:{bg:"bg-blue-50 dark:bg-blue-950/30",border:"border-blue-200 dark:border-blue-800",text:"text-blue-700 dark:text-blue-400",dot:"bg-blue-500",label:"Upcoming",labelAr:"قادم"},future:{bg:"bg-emerald-50 dark:bg-emerald-950/30",border:"border-emerald-200 dark:border-emerald-800",text:"text-emerald-700 dark:text-emerald-400",dot:"bg-emerald-500",label:"Future",labelAr:"مستقبلي"},unknown:{bg:"bg-muted/30",border:"border-border",text:"text-muted-foreground",dot:"bg-muted-foreground",label:"Unknown",labelAr:"غير محدد"}},he={expiry:"⏰",renewal:"🔄",payment:"💳",notice:"📢",delivery:"📦",review:"🔍",other:"📌"},F=["overdue","urgent","soon","upcoming","future","unknown"];function Le(){const{t:$,isRTL:t}=W(),{handleError:L,showSuccess:_}=q(),o=$.deadlineExtractor,[i,R]=c.useState(null),[S,j]=c.useState(!1),[s,N]=c.useState(null),[w,h]=c.useState(!1),[O,v]=c.useState(null),k=c.useRef(null),{triggerRatingCheck:M,ratingModalProps:P}=Q(),U=E.tools.uploadFile.useMutation(),I=E.tools.deadlineExtractor.useMutation({onSuccess:r=>{N(r.data),h(!1),M(),_({serviceKey:"deadlineExtractor",title:o.successTitle,message:t?"تم استخراج المواعيد النهائية. راجعها أدناه.":"Deadlines extracted. Review them below.",onLoop:()=>C()})},onError:r=>{h(!1),L(r,{file:i})}}),z=r=>!pe.includes(r.type)&&!ge.test(r.name)?(g.error(o.invalidFormat),!1):r.size>be*1024*1024?(g.error(o.fileTooLarge),!1):!0,T=c.useCallback(r=>{z(r)&&(R(r),N(null),v(null))},[]),B=r=>{r.preventDefault(),j(!1);const a=r.dataTransfer.files[0];a&&T(a)},G=r=>{r.target.files?.[0]&&(T(r.target.files[0]),r.target.value="")},V=async()=>{if(!i){g.error(o.needFile);return}h(!0);try{const r=await new Promise((n,d)=>{const m=new FileReader;m.onload=()=>n(m.result.split(",")[1]),m.onerror=d,m.readAsDataURL(i)}),{url:a}=await U.mutateAsync({fileName:i.name,mimeType:i.type||"application/pdf",base64:r});await I.mutateAsync({fileUrl:a,fileName:i.name,mimeType:i.type,fileSize:i.size})}catch{h(!1)}},C=()=>{R(null),N(null),v(null)},Y=()=>{if(!s)return;const r=s.deadlines.map(a=>`${a.label} — ${a.date}${a.daysRemaining!==null?` (${a.daysRemaining>=0?`${a.daysRemaining} days remaining`:`${Math.abs(a.daysRemaining)} days overdue`})`:""}`);navigator.clipboard.writeText(r.join(`
2`)),g.success(t?"تم النسخ!":"Copied!")},X=()=>{if(!s||s.deadlines.length===0)return;const r={overdue:t?"متأخر":"Overdue",urgent:t?"عاجل":"Urgent",soon:t?"قريباً":"Soon",upcoming:t?"قادم":"Upcoming",future:t?"مستقبلي":"Future",unknown:t?"غير محدد":"Unknown"},a={expiry:t?"انتهاء":"Expiry",renewal:t?"تجديد":"Renewal",payment:t?"دفعة":"Payment",notice:t?"إشعار":"Notice",delivery:t?"تسليم":"Delivery",review:t?"مراجعة":"Review",other:t?"أخرى":"Other"}
2,n=x.map(l=>({[t?"الموعد":"Deadline"]:t&&l.labelAr?l.labelAr:l.label,[t?"التاريخ":"Date"]:l.date,[t?"التاريخ (ISO)":"ISO Date"]:l.isoDate??"",[t?"النوع":"Type"]:a[l.type]??l.type,[t?"الأولوية":"Urgency"]:r[l.urgency]??l.urgency,[t?"الأيام المتبقية":"Days Remaining"]:l.daysRemaining??"",[t?"الوصف":"Description"]:l.description})),d=b.json_to_sheet(n),m=Object.keys(n[0]||{}).map(l=>({wch:Math.max(l.length,...n.map(f=>String(f[l]??"").length))+2}));d["!cols"]=m;const D=b.book_new();if(b.book_append_sheet(D,d,t?"المواعيد":"Deadlines"),s.contractTitle||s.parties?.length){const l=[{[t?"المعلومة":"Field"]:t?"اسم العقد":"Contract Title",[t?"القيمة":"Value"]:s.contractTitle??""},{[t?"المعلومة":"Field"]:t?"الأطراف":"Parties",[t?"القيمة":"Value"]:s.parties?.join(", ")??""},{[t?"المعلومة":"Field"]:t?"تاريخ العقد":"Contract Date",[t?"القيمة":"Value"]:s.contractDate??""},{[t?"المعلومة":"Field"]:t?"الملخص":"Summary",[t?"القيمة":"Value"]:s.summary??""}],f=b.json_to_sheet(l);f["!cols"]=[{wch:20},{wch:60}],b.book_append_sheet(D,f,t?"معلومات العقد":"Contract Info")}const Z=s.contractTitle?`${s.contractTitle.replace(/[^a-zA-Z0-9\u0600-\u06FF]/g,"_").slice(0,40)}_deadlines.xlsx`:"deadlines.xlsx";J(D,Z),g.success(t?"تم تصدير الملف!":"Excel file exported!")},x=s?.deadlines?[...s.deadlines].sort((r,a)=>F.indexOf(r.urgency)-F.indexOf(a.urgency)):[],u=s?.documentLanguage==="ar",K=x.reduce((r,a)=>(r[a.urgency]=(r[a.urgency]||0)+1,r),{});return e.jsxs(H,{title:o.title,description:o.description,icon:e.jsx(y,{className:"w-6 h-6"}),iconBg:"bg-primary/15",iconBorder:"border border-primary/20",iconColor:"text-primary",creditCost:4,serviceKey:"deadlineExtractor",children:[e.jsxs("div",{className:"space-y-6",children:[!i&&e.jsxs("div",{className:`bg-card border-2 border-dashed rounded-xl p-10 text-center transition-colors cursor-pointer ${S?"border-primary bg-primary/10 dark:bg-primary/20":"border-border hover:border-primary/50"}`,onDragOver:r=>{r.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:B,onClick:()=>k.current?.click(),children:[e.jsx("input",{ref:k,type:"file",accept:ee,className:"hidden",onChange:G}),e.jsx(y,{className:"w-12 h-12 mx-auto mb-3 text-primary"}),e.jsx("p",{className:"font-semibold text-foreground mb-1",children:o.dropLabel}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:re}),e.jsxs(p,{variant:"outline",size:"sm",className:"border-primary/30 text-primary hover:bg-primary/10",onClick:r=>{r.stopPropagation(),k.current?.click()},children:[e.jsx(te,{className:"w-4 h-4 me-2"}),o.uploadLabel]})]}),i&&!s&&e.jsx("div",{className:"bg-card border border-border rounded-xl p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/15 flex items-center justify-center flex-shrink-0",children:e.jsx(se,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground text-sm truncate",children:i.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(i.size/1024/1024).toFixed(1)," MB"]})]}),!w&&e.jsx("button",{onClick:C,className:"text-muted-foreground hover:text-foreground",children:e.jsx(ae,{className:"w-4 h-4"})})]})}),i&&!s&&e.jsx(p,{onClick:V,disabled:w,className:"w-full bg-primary hover:bg-primary text-white h-11",children:w?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 me-2 animate-spin"}),o.btnProcessing]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"w-4 h-4 me-2"}),o.btnProcess]})}),s&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[s.contractTitle&&e.jsx("h3",{className:"font-semibold text-foreground text-base",dir:u?"rtl":"ltr",children:s.contractTitle}),s.contractDate&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1 mt-1",children:[e.jsx(le,{className:"w-3 h-3"}),o.contractDate,": ",s.contractDate]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(p,{variant:"ghost",size:"sm",onClick:Y,className:"text-muted-foreground hover:text-foreground",children:[e.jsx(oe,{className:"w-3.5 h-3.5 me-1.5"}),o.copyAll]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:X,className:"border-emerald-300 text-emerald-700 hover:bg-emerald-50 dark:border-emerald-700 dark:text-emerald-400",children:[e.jsx(ie,{className:"w-3.5 h-3.5 me-1.5"}),o.exportExcel]})]})]}),s.parties&&s.parties.length>0&&e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(de,{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",dir:u?"rtl":"ltr",children:s.parties.join(" · ")})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["overdue","urgent","soon","upcoming","future"].map(r=>{const a=K[r];if(!a)return null;const n=A[r];return e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border ${n.bg} ${n.border} ${n.text}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),t?n.labelAr:n.label," (",a,")"]},r)})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx(y,{className:"w-4 h-4 text-primary"}),o.timelineTitle," (",x.length,")"]}),x.length===0?e.jsx("div",{className:"bg-card border border-border rounded-xl p-6 text-center text-muted-foreground text-sm",children:o.noDeadlines}):e.jsx("div",{className:"space-y-2",children:x.map((r,a)=>{const n=A[r.urgency],d=O===a;return e.jsxs("div",{className:`rounded-xl border transition-all ${n.bg} ${n.border}`,children:[e.jsxs("button",{className:"w-full text-start px-4 py-3 flex items-center gap-3",onClick:()=>v(d?null:a),children:[e.jsx("span",{className:"text-base flex-shrink-0",children:he[r.type]||"📌"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-sm text-foreground",dir:u?"rtl":"ltr",children:t&&r.labelAr?r.labelAr:r.label}),e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full border ${n.bg} ${n.border} ${n.text}`,children:t?n.labelAr:n.label})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3 flex-shrink-0"}),r.date,r.daysRemaining!==null&&e.jsx("span",{className:`ms-1 font-medium ${n.text}`,children:r.daysRemaining>=0?`· ${r.daysRemaining} ${t?"يوم متبقي":"days remaining"}`:`· ${Math.abs(r.daysRemaining)} ${t?"يوم منذ الانتهاء":"days overdue"}`})]})]}),r.description&&e.jsx("span",{className:"text-muted-foreground flex-shrink-0",children:d?e.jsx(me,{className:"w-4 h-4"}):e.jsx(xe,{className:"w-4 h-4"})})]}),d&&r.description&&e.jsx("div",{className:"px-4 pb-3 border-t border-inherit",children:e.jsx("p",{className:"text-sm text-muted-foreground pt-2 leading-relaxed",dir:u?"rtl":"ltr",children:r.description})})]},a)})})]}),s.summary&&e.jsx("div",{className:"bg-card border border-border rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ue,{className:"w-4 h-4 text-primary mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",dir:u?"rtl":"ltr",children:s.summary})]})}),e.jsx(p,{variant:"ghost",size:"sm",className:"w-full text-muted-foreground",onClick:C,children:t?"تحليل عقد آخر":"Analyze another contract"})]})]}),P]})}export{Le 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.