PageSourceSearch

https://doxxo.ai/assets/ContractDraft-C4-rvioY.js

js doxxo.ai collected 2026-10-05 12:52:12 UTC 18,408 bytes, 1 lines download raw bytes

1import{r as n,j as e}from"./vendor-react-BGSoyBC3.js";import{L as Ce}from"./vendor-router-Bky5zxn0.js";import{n as we,m as Se,v as ke,a as re,au as d,I as x,B as Te,w as C,x as De,av as Re}from"./index-CY3lR3NC.js";import{T as Le}from"./ToolLayout-DPKnREsn.js";import{T as ne}from"./textarea-C3ZyXfzW.js";import{d as Ae,G as Ee}from"./gccTaxRules-DXr3TYAt.js";import{L as le}from"./LegalDisclaimer-DyM13FAa.js";import{a as ce,e as oe}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-charts-BBE7Gg4G.js";import"./GulfWorkspaceLayout-E_582nAN.js";import"./ServiceIcon-DMw7eqxZ.js";import"./ToolContentSkeleton-BI4eFRuM.js";function Fe(r){return{draftsPerDay:r?30:5,maxInputChars:r?5e3:2e3,timeoutMs:r?9e4:3e4,maxSavedDrafts:r?50:5}}function Ie(r){const c=r&&typeof r=="object"&&"message"in r?String(r.message):"";if(!c)return null;try{const m=JSON.parse(c);if(m?.code&&m?.message)return m}catch{}return c&&c!=="Failed to generate contract"?{code:"MODEL_ERROR",message:c}:null}const ie=[{value:"rent",icon:"🏠",label:"عقد إيجار",labelEn:"Lease",fields:["عنوان العقار","دورية السداد","التأمين","مدة الإشعار"]},{value:"employment",icon:"👔",label:"عقد عمل",labelEn:"Employment",fields:["مكان العمل","تاريخ المباشرة","فترة التجربة","مدة الإشعار"]}],de="doxxo_contract_drafts";function Pe(r){return navigator.clipboard.writeText(r)}async function Oe(r,c){const m=c.replace(/[^\w\u0600-\u06FF\s-]/g,"").slice(0,40)||"contract";await De(r,`${m}.docx`)}async function $e(r,c,m){const s=await Re(r),p=new FormData;p.append("file",s,"contract.docx");const h=await fetch("/api/tools/word2pdf",{method:"POST",body:p,credentials:"include"});if(!h.ok){const u=await h.json().catch(()=>({})),y=u.message??u.detail??u.error;throw new Error(y??(m?"فشل تحويل PDF":"PDF conversion failed"))}const b=await h.blob(),w=c.replace(/[^\w\u0600-\u06FF\s-]/g,"").slice(0,40)||"contract",l=URL.createObjectURL(b),f=document.createElement("a");f.href=l,f.download=`${w}.pdf`,f.click(),URL.revokeObjectURL(l)}function Qe(){const{isAuthenticated:r}=we(),c=Fe(r),{isRTL:m}=Se(),s=m,{handleError:p,showSuccess:h}=ke(),[b,w]=n.useState("ar"),[l,f]=n.useState("rent"),[u,y]=n.useState("residential"),[P,O]=n.useState({penalty:!1,confidentiality:!1,renewal:!1}),[$,B]=n.useState(!1),[G,U]=n.useState(""),[_,me]=n.useState(!0),[S,ue]=n.useState(()=>Ae()),[k,R]=n.useState({}),[j,M]=n.useState(""),[v,J]=n.useState(""),[N,V]=n.useState(""),[L,W]=n.useState(""),[A,Y]=n.useState(""),[E,K]=n.useState(""),[F,q]=n.useState(""),[xe,I]=n.useState(!1),[o,z]=n.useState(null),[g,X]=n.useState(null),[Z,T]=n.useState(null),[H,Q]=n.useState(!1),D=re.tools.contractDraft.useMutation(),ee=re.tools.saveContractDraft.useMutation(),te=ie.find(t=>t.value===l),pe=()=>[j,v,N,L,A,E,F,...Object.values(k)].reduce((a,i)=>a+i.length,0),ge=t=>{f(t),R({}),t==="employment"&&y("residential")},he=async()=>{if(!j.trim()||!v.trim()||!N.trim())return;const t=pe();if(t>c.maxInputChars){const a=r?`طول المدخلات (${t} حرف) يتجاوز الحد (${c.maxInputChars} حرف)`:`طول المدخلات (${t} حرف) يتجاوز حد الزوار (${c.maxInputChars} حرف)`;T(a),C.error(a);return}I(!1),T(null);try{const a=await D.mutateAsync({partyA:j,partyB:v,contractSubject:N,contractValue:L||void 0,duration:A||void 0,terms:E||void 0,jurisdiction:F||void 0,language:b,contractType:l,country:S,typeFields:Object.keys(k).length>0?k:void 0,rentSubType:l==="rent"?u:void 0,optionalClauses:P,customClause:G.trim()||void 0,vatApplicable:l==="rent"&&u==="commercial"?$:void 0,requestComplianceCheck:_});z({contractTitle:a.contractTitle,contractText:a.contractText,clauses:a.clauses,warnings:a.warnings,missingInfo:a.missingInfo,complianceResults:a.complianceResults}),X(a.resultUrl),I(!0),h({serviceKey:"contractDraft",title:s?"تم إنشاء العقد":"Contract drafted",message:s?"تمت صياغة العقد. راجعه أو نزّله أدناه.":"Your contract is ready. Review or download it below.",onLoop:se})}catch(a){const i=Ie(a);i?(T(i.tip?`${i.message} — ${i.tip}`:i.message),C.error(i.message)):p(a)}},be=async t=>{if(r){try{await ee.mutateAsync({title:t.contractTitle,text:t.contractText,contractType:l,country:S}),C.success(s?"✅ تم حفظ المسودة":"✅ Draft saved")}catch(i){p(i)}return}const a=JSON.parse(localStorage.getItem(de)??"[]");a.unshift({id:Date.now(),title:t.contractTitle,text:t.contractText,savedAt:new Date().toISOString(),type:l,country:S}),localStorage.setItem(de,JSON.stringify(a.slice(0,c.maxSavedDrafts
1))),C.success(s?"✅ تم حفظ المسودة":"✅ Draft saved")},se=()=>{M(""),J(""),V(""),W(""),Y(""),K(""),q(""),R({}),y("residential"),O({penalty:!1,confidentiality:!1,renewal:!1}),B(!1),U(""),I(!1),z(null),X(null),T(null)},ae=D.isPending,fe=j.trim()&&v.trim()&&N.trim()&&(l!=="rent"||u)&&!ae,ye=l==="rent"?s?"المؤجر":"Landlord":s?"صاحب العمل":"Employer",je=l==="rent"?s?"المستأجر":"Tenant":s?"الموظف":"Employee",ve=l==="rent"?s?"وصف العقار":"Property description":s?"المسمى الوظيفي":"Job title",Ne=l==="rent"?s?"قيمة الإيجار":"Rent amount":s?"الأجر":"Wage";return e.jsx(Le,{title:s?"صياغة العقود":"Contract Draft Generator",description:s?"قوالب عقود معتمدة (إيجار وعمل) — تعبئة حتمية بدون ذكاء اصطناعي في مسار الصياغة.":"Approved contract templates (lease & employment) — deterministic fill, no AI drafting.",icon:e.jsx(oe,{className:"w-6 h-6"}),creditCost:5,serviceKey:"contractDraft",iconBg:"bg-primary/15",iconBorder:"border-primary/20",iconColor:"text-primary",children:xe?o&&e.jsxs("div",{className:"space-y-4",children:[o.warnings.length>0&&e.jsxs("div",{className:"rounded-xl border border-orange-200 bg-orange-50 p-4",dir:"rtl",children:[e.jsxs("p",{className:"text-sm font-medium text-orange-800 mb-2",children:["⚠️ ",s?"تنبيهات قبل استخدام العقد:":"Warnings before using this contract:"]}),e.jsx("ul",{className:"space-y-1",children:o.warnings.map((t,a)=>e.jsxs("li",{className:"text-sm text-orange-700 flex gap-2",children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t})]},a))})]}),o.missingInfo.length>0&&e.jsxs("div",{className:"rounded-xl border border-blue-200 bg-blue-50 p-4",dir:"rtl",children:[e.jsxs("p",{className:"text-sm font-medium text-blue-800 mb-1",children:["💡 ",s?"معلومات إضافية ستُحسّن العقد:":"Additional info would improve the contract:"]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:o.missingInfo.map((t,a)=>e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs bg-blue-100 text-blue-700",children:t},a))})]}),o.complianceResults&&o.complianceResults.length>0&&e.jsxs("div",{className:"rounded-xl border p-4 space-y-2",dir:"rtl",children:[e.jsx("p",{className:"text-sm font-medium",children:s?"فحص الامتثال الاسترشادي":"Advisory compliance"}),e.jsx("ul",{className:"space-y-2 text-sm",children:o.complianceResults.map(t=>e.jsxs("li",{className:"border-b pb-2 last:border-0",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{children:t.clauseTitle}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${t.riskLevel==="high"?"bg-red-100 text-red-800":t.riskLevel==="medium"?"bg-orange-100 text-orange-800":"bg-green-100 text-green-800"}`,children:t.riskLevel})]}),t.citationDisplay?e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.citationDisplay.text}):e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s?"لا يوجد استشهاد نظامي معروض":"No statutory citation displayed"})]},t.clauseId))}),e.jsx(le,{})]}),e.jsxs("div",{className:"rounded-xl border overflow-hidden",children:[e.jsxs("div",{className:"p-4 bg-muted/50 border-b flex items-center justify-between",dir:"rtl",children:[e.jsx("h3",{className:"font-medium",children:o.contractTitle}),e.jsxs("button",{type:"button",onClick:()=>Pe(o.contractText).then(()=>C.success(s?"تم النسخ":"Copied")),className:"text-xs px-3 py-1.5 rounded-lg border bg-background hover:bg-muted/50",children:["📋 ",s?"نسخ":"Copy"]})]}),e.jsx("div",{className:"p-5 bg-white font-serif text-sm leading-8 whitespace-pre-wrap max-h-[500px] overflow-y-auto",dir:"rtl",children:o.contractText})]}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>g&&Oe(g,o.contractTitle),disabled:!g,className:"flex items-center gap-2 px-4 py-2 rounded-xl border bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100 text-sm font-medium disabled:opacity-50",children:["📝 ",s?"تحميل Word":"Download Word"]}),e.jsxs("button",{type:"button",onClick:async()=>
1{if(g){Q(!0);try{await $e(g,o.contractTitle,s)}catch(t){p(t)}finally{Q(!1)}}},disabled:!g||H,className:"flex items-center gap-2 px-4 py-2 rounded-xl border bg-red-50 text-red-700 border-red-200 hover:bg-red-100 text-sm font-medium disabled:opacity-50",children:["📄 ",H?s?"جاري التحويل...":"Converting...":s?"تحميل PDF":"Download PDF"]}),e.jsxs("button",{type:"button",onClick:()=>be(o),disabled:ee.isPending,className:"flex items-center gap-2 px-4 py-2 rounded-xl border bg-background hover:bg-muted/50 text-sm font-medium",children:["💾 ",s?"حفظ المسودة":"Save draft"]}),e.jsxs("button",{type:"button",onClick:se,className:"flex items-center gap-2 px-4 py-2 rounded-xl border bg-muted hover:bg-muted/80 text-sm font-medium",children:[e.jsx(ce,{className:"w-4 h-4"}),s?"عقد جديد":"New contract"]})]}),e.jsx(le,{})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-xl border bg-muted/30 p-4 text-sm",dir:"rtl",children:[e.jsxs("p",{className:"font-medium mb-2",children:["⚡ ",s?"حدود المعالجة":"Processing limits"]}),e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4 text-center",children:[{label:s?"صياغات/يوم":"Drafts/day",value:r?"30":"5"},{label:s?"أحرف المدخلات":"Input chars",value:r?"5000":"2000"},{label:s?"مهلة المعالجة":"Timeout",value:r?"90 ثا":"30 ثا"},{label:s?"حفظ مسودات":"Saved drafts",value:r?"50 (DB)":"5"}].map(t=>e.jsxs("div",{className:"rounded-lg bg-background border p-2",children:[e.jsx("div",{className:"font-bold text-primary",children:t.value}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.label})]},t.label))}),!r&&e.jsxs("p",{className:"text-xs text-center mt-2 text-muted-foreground",children:[e.jsx(Ce,{href:"/signup",className:"text-primary underline",children:s?"سجّل مجاناً":"Sign up free"})," ",s?"للحصول على حدود أعلى وحفظ دائم":"for higher limits and cloud draft saving"]})]}),e.jsxs("div",{dir:"rtl",children:[e.jsx(d,{className:"text-sm font-medium mb-2 block",children:s?"نوع العقد":"Contract Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 max-w-md",children:ie.map(t=>e.jsxs("button",{type:"button",onClick:()=>ge(t.value),className:`flex flex-col items-center gap-1 p-3 rounded-xl border-2 transition-all text-center ${l===t.value?"border-primary bg-primary/5 shadow-sm":"border-border hover:border-primary/40"}`,children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsx("span",{className:"text-xs font-medium",children:s?t.label:t.labelEn})]},t.value))})]}),l==="rent"&&e.jsxs("div",{dir:"rtl",children:[e.jsx(d,{className:"text-sm font-medium mb-2 block",children:s?"نوع الإيجار *":"Lease type *"}),e.jsx("div",{className:"flex gap-2 max-w-md",children:[{value:"residential",ar:"سكني",en:"Residential"},{value:"commercial",ar:"تجاري",en:"Commercial"}].map(t=>e.jsx("button",{type:"button",onClick:()=>y(t.value),className:`flex-1 py-2 rounded-lg text-sm font-medium border ${u===t.value?"bg-primary text-white border-primary":"bg-background border-border"}`,children:s?t.ar:t.en},t.value))}),u==="commercial"&&e.jsxs("label",{className:"flex items-center gap-2 mt-3 text-sm",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:t=>B(t.target.checked)}),s?"العقار خاضع لضريبة القيمة المضافة (زاتكا)":"Property subject to VAT (ZATCA)"]})]}),e.jsxs("div",{className:"rounded-xl border bg-muted/20 p-4 space-y-3",dir:"rtl",children:[e.jsx("p",{className:"text-sm font-medium",children:s?"بنود اختيارية":"Optional clauses"}),e.jsx("div",{className:"flex flex-wrap gap-4 text-sm",children:[{key:"penalty",ar:"غرامة تأخير",en:"Late penalty"},{key:"confidentiality",ar:"سرية",en:"Confidentiality"},{key:"renewal",ar:"تجديد",en:"Renewal"}].map(t=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:P[t.key],onChange:a=>O(i=>({...i,[t.key]:a.target.checked}))}),s?t.ar:t.en]},t.key))}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>me(t.target.checked)}),s?"فحص امتثال استرشادي (مقارنة بالمواد النظامية)":"Advisory compliance check"]})]}),e.jsxs("div",{className:"space-y-1.5",dir:"rtl",children:[e.jsx(d,{className:"text-sm font-medium",children:s?"بند مخصّص (يُدرج حرفياً)":"Custom clause (verbatim)"}),e.jsx(ne,{value:G,onChange:t=>U(t.target.value),placeholder:s?"نص البند كما كتبته — دون إعادة صياغة":"Your clause text as-is",rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s?"يُوسَم: بند مخصّص — لم تتم مراجعته قانونياً":"Tagged: custom — not legally reviewed"})]}),e.jsxs("div",{dir:"rtl",children:[e.jsx(d,{className:"text-sm font-medium mb-2 block",children:s?"البلد / القانون المطبق":"Country / Governing Law"}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-6",children:Object.values(Ee).map(t=>e.jsxs("button",{type:"button",onClick:()=>ue(t.country),className:`flex flex-col items-center gap-1 p-2 rounded-xl border-2 transition-all ${S===t.country?"border-primary bg-primary/5":"border-border hover:border-primary/40"}`,children:[e.jsx("span",{className:"text-xl",children:t.flag}),e.jsx("span",{className:"text-xs font-medium",children:t.nameAr.split(" ").pop()})]},t.country))})]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-sm font-medium mb-2 block",children:s?"لغة العقد":"Contract Language"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>w("ar"),className:`flex-1 py-2 rounded-lg text-sm font-medium border transition-colors ${b==="ar"?"bg-primary text-white border-primary":"bg-background border-border text-muted-foreground hover:border-primary/50"}`,children:s?"العربية":"Arabic"}),e.jsx("button",{type:"button",onClick:()=>w("en"),className:`flex-1 py-2 rounded-lg text-sm font-medium border transition-colors ${b==="en"?"bg-primary text-white border-primary":"bg-background border-border text-muted-foreground hover:border-primary/50"}`,children:s?"الإنجليزية":"English"})]})]}),te.fields.length>0&&e.jsxs("div",{className:"rounded-xl border bg-muted/20 p-4 space-y-3",dir:"rtl",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:s?"حقول نوع العقد":"Contract-type fields"}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:te.fields.map(t=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"text-xs",children:t}),e.jsx(x,{value:k[t]??"",onChange:a=>R(i=>({...i,[t]:a.target.value})),dir:"rtl"})]},t))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(d,{className:"text-sm font-medium",children:[ye," *"]}),e.jsx(x,{value:j,onChange:t=>M(t.target.value),placeholder:s?"مثال: أحمد محمد الغامدي":"e.g. Ahmed Mohammed Al-Ghamdi",dir:s?"rtl":"ltr"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(d,{className:"text-sm font-medium",children:[je," *"]}
1),e.jsx(x,{value:v,onChange:t=>J(t.target.value),placeholder:s?"مثال: شركة النور للتجارة":"e.g. Al-Noor Trading Company",dir:s?"rtl":"ltr"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(d,{className:"text-sm font-medium",children:[ve," *"]}),e.jsx(x,{value:N,onChange:t=>V(t.target.value),placeholder:s?"مثال: خدمات تطوير البرمجيات":"e.g. Software development services",dir:s?"rtl":"ltr"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"text-sm font-medium",children:Ne}),e.jsx(x,{value:L,onChange:t=>W(t.target.value),placeholder:s?"مثال: 50,000 ريال سعودي":"e.g. SAR 50,000",dir:s?"rtl":"ltr"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"text-sm font-medium",children:s?"المدة (اختياري)":"Duration (optional)"}),e.jsx(x,{value:A,onChange:t=>Y(t.target.value),placeholder:s?"مثال: 12 شهراً":"e.g. 12 months",dir:s?"rtl":"ltr"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"text-sm font-medium",children:s?"شروط خاصة (اختياري)":"Special Terms (optional)"}),e.jsx(ne,{value:E,onChange:t=>K(t.target.value),placeholder:s?"مثال: الدفع على 3 دفعات":"e.g. Payment in 3 installments",dir:s?"rtl":"ltr",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"text-sm font-medium",children:s?"الاختصاص القضائي (اختياري)":"Jurisdiction (optional)"}),e.jsx(x,{value:F,onChange:t=>q(t.target.value),placeholder:s?"مثال: محاكم الرياض":"e.g. Riyadh Courts",dir:s?"rtl":"ltr"})]}),(Z||D.error)&&e.jsx("p",{className:"text-sm text-destructive",children:Z??D.error?.message}),e.jsx(Te,{onClick:he,disabled:!fe,className:"w-full bg-primary hover:bg-primary text-white",size:"lg",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 me-2 animate-spin"}),s?"جاري الصياغة...":"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-4 h-4 me-2"}),s?"صياغة العقد":"Generate Contract"]})})]})})}export{Qe 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.