import { View, Text } from "@react-pdf/renderer";
import { PDFTable, PDFTableRow, ConditionalPDFTableRow, EmptyTableRow, PDFCenteredTable, PDFCenteredTableRow, PDFTableRowLink } from "./PDFTableComponents";
import { PDFFormSection, PDFFormRow, PDFFormField, PDFInlineCheckboxGroup, PDFCheckbox, PDFCheckboxGrid, PDFHouseholdMemberRow, PDFLiabilityRow, PDFFormSectionTitle } from "./PDFFormComponents";
import { pdfStyles } from "./PDFStyles";

interface HomeImprovementPDFProps {
  formData: any;
}

export const HomeImprovementPDFContent = ({ formData }: HomeImprovementPDFProps) => {
  const hasMaintenanceNeeds = formData.maintenanceHeatingCooling || formData.maintenancePlumbing ||
    formData.maintenanceElectrical || formData.maintenanceAppliances || formData.maintenanceDoorsWindows ||
    formData.maintenanceFlooringWalls || formData.maintenancePest || formData.maintenanceSafety;
  console.log(formData);

  return (
    <>
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>AHC #1U36</Text>
        <Text style={pdfStyles.title}>Home Improvement Grant Program Application</Text>
        <Text style={pdfStyles.text}>Thank you for your interest in the Lackawanna Housing Development Corporation's (LHDC) "Home Improvement Program". If you decide to apply, please complete the required information within the following application and compile the required income verification documents as listed on the last page of this application packet (Exhibit "A"). The LHDC will only accept completed applications with 100% of documentation submitted. Once you have completed the application and have all of the required income documents, please call our office at (716) 823-5124, to schedule a meeting to submit the documents and application. The LHDC will additionally go over the approval process, inspection procedures, contractor selection, and any funding restrictions. If you have any questions please contact our office.</Text>
        <Text style={pdfStyles.text}>Funding for this program is provided by the New York State Division of Homes and Community Renewal (HCR) Affordable Housing Corporation (AHC). This owner-occupied, single-unit or two-unit, housing renovation program is offered by the Lackawanna Housing Development Corporation to moderate-to-low income homeowners in the city of Lackawanna with less than $15,000 in net assets (not including the value of the home to be improved). Generally, LHDC will support up to 80% of a Home Improvement Project of up to $15,000 per unit with a 20% match from homeowners. If cost is beyond $15,000 per unit the LHDC will fund up to $12,000 with the homeowner responsible for the rest. All eligible repairs are to be determined by the LHDC.</Text>
        <Text style={pdfStyles.text}>This program has a limited funding source, with no guarantee of how long funds will be available, when funds become unavailable a wait may be established as a result. Any waiting list developed for program funding will be based upon priority improvements and income status, ie: Highest renovation priority with lowest income will be first.</Text>
        <Text style={pdfStyles.text}>If you are funded through this funding program, all contracts for renovation work to be completed will be between you and the contractor you select to complete the work approved through this program. In addition, no work or activity can be initiated at your dwelling prior to authorization by the Lackawanna Housing Development Corporation. As a point of information, eligible contractors/workers are not assigned nor recommended by the Lackawanna Housing Development Corporation. There are contractors who have worked with the organization before and their names are listed on a contractor directory provided to each homeowner in the bid-phase of the program. Finally, when funded, our program works very efficiently and allows for approved repairs to be completed at your dwelling, which in turn allows you/your family to live within a decent, safe and improved environment. If you have any questions or concerns about this program, please contact us at 716-823-5124. We look forward to working with you!</Text>
      </View>

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>Home Improvement Program</Text>
        <Text style={pdfStyles.title}>Eligible Improvements include, but are not limited to</Text>
        <Text style={pdfStyles.text}> </Text>
        <Text style={pdfStyles.text}>• Roof replacement/Gutter and downspout replacement.</Text>
        <Text style={pdfStyles.text}>• Electrical repair; Upgrading of electrical service.</Text>
        <Text style={pdfStyles.text}>• Plumbing repair or replacement.</Text>
        <Text style={pdfStyles.text}>• Furnace replacement.</Text>
        <Text style={pdfStyles.text}>• Gas line/water line repair or replacement.</Text>
        <Text style={pdfStyles.text}>• Exterior or Storm Door replacement.</Text>
        <Text style={pdfStyles.text}>*Repair eligibility is determined by the LHDC staff*</Text>
      </View>

      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>Income Eligibility Schedule</Text>
        <Text style={pdfStyles.title}>Housing Renovation Program - 2025 HUD Income Limits</Text>
        <PDFCenteredTable>
          <PDFCenteredTableRow label="Number of Persons in Home" value="Max Income for Renovation Grant: " />
          <PDFCenteredTableRow label="1" value="$56,600" />
          <PDFCenteredTableRow label="2" value="$64,650" />
          <PDFCenteredTableRow label="3" value="$72,750" />
          <PDFCenteredTableRow label="4" value="$80,800" />
          <PDFCenteredTableRow label="5" value="$87,300" />
          <PDFCenteredTableRow label="6" value="$93,750" />
          <PDFCenteredTableRow label="7" value="$100,200" />
          <PDFCenteredTableRow label="8 or more" value="$106,700" isLast />
        </PDFCenteredTable>
      </View>
      <View break={true}>
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.title}>Lackawanna Housing Development Corporation</Text>
          <Text style={pdfStyles.title}>Housing Renovation Program Application</Text>
        </View>

        {/* Applicant Information */}
        <PDFFormSection number="1">
          <PDFFormRow>
            <PDFFormField label="Applicant's Name(s) [As on Deed/Title to Home" value={formData.applicantName} width="large" />
          </PDFFormRow>
          {formData.coApplicantName && (
            <PDFFormRow>
              <PDFFormField label="" value={formData.coApplicantName} width="large" />
            </PDFFormRow>
          )}
        </PDFFormSection>

        {/* Property Details */}
        <PDFFormSection number="2">
          <PDFFormRow>
            <PDFFormField label="Address of Property:" value={formData.applicantProperty} width="medium" />
            <PDFFormField label="E-Mail Address:" value={formData.email} width="medium" />
          </PDFFormRow>
        </PDFFormSection>

        <PDFFormSection number="3">
          <PDFFormRow>
            <PDFFormField label="Phone #: (Cell)" value={formData.phoneCell} width="small" />
            <PDFFormField label="(Work)" value={formData.phoneWork} width="small" />
            <PDFFormField label="(Home)" value={formData.phoneHome} width="small" />
          </PDFFormRow>
        </PDFFormSection>
      </View>

      {/* Household Members */}
      <PDFFormSection number="5">
        <Text style={{ fontSize: 10, marginBottom: 5, fontWeight: 'semibold' }}>Name(s) and age(s) of all persons who reside at the above address:</Text>
        {formData.householdMembers && formData.householdMembers.length > 0 ? (
          formData.householdMembers.map((member: any, index: number) => (
            <PDFHouseholdMemberRow key={index} name={member.name} relation={member.relationWithApplicant} age={member.age} />
          ))
        ) : (
          <>
            <PDFHouseholdMemberRow name="" relation="" age="" />
            <PDFHouseholdMemberRow name="" relation="" age="" />
          </>
        )}
      </PDFFormSection>

      <PDFFormSection number="6">
        <PDFInlineCheckboxGroup
          label="Do you currently reside at this address?"
          options={[
            { label: 'Yes', checked: formData.resideAddress === 'yes' },
            { label: 'No', checked: formData.resideAddress === 'no' },
          ]}
        />
      </PDFFormSection>

      <PDFFormSection number="7">
        <PDFFormRow>
          <PDFFormField label="How long have you owned the property?" value={formData.propertyOwnedDuration} width="medium" />
        </PDFFormRow>
      </PDFFormSection>

      <PDFFormSection number="8">
        <PDFInlineCheckboxGroup
          label="Are your Town\County\School Taxes Paid to Date?"
          options={[
            { label: 'Yes', checked: formData.taxesPaid === 'yes' },
            { label: 'No', checked: formData.taxesPaid === 'no' },
          ]}
        />
      </PDFFormSection>

      {/* Employment */}
      <PDFFormSection number="9">
        <Text style={{ fontSize: 10, marginBottom: 10, fontWeight: 'semibold' }}>Current Employment:</Text>
        <PDFFormRow>
          <PDFFormField label="Employer's Name:" value={formData.applicantEmployerName || formData.employerApplicant} width="medium" />
          <PDFFormField label="Co-applicant  Name:" value={formData.coapplicantEmployerName || formData.employerCoApplicant} width="medium" />
        </PDFFormRow>
        <PDFFormRow>
          <PDFFormField label="Employer's Address:" value={formData.applicantEmployerAddress} width="medium" />
          <PDFFormField label=" Co-applicant  Address:" value={formData.coapplicantEmployerAddress} width="medium" />
        </PDFFormRow>
      </PDFFormSection>

<Text style={pdfStyles.title}> </Text>
    {/* <View break></View> */}
    <View></View>
      {/* Renovation Details */}
      <PDFFormSection number="10" >
        <PDFFormRow>
          <PDFFormField label="What Renovation Improvements are you applying for?:" value={formData.renovationDetails || formData.maintenanceDescription} width="large" />
        </PDFFormRow>

        {/* Maintenance checkboxes - 3 per row */}
        <Text style={{ fontSize: 10, fontWeight: 'semibold', marginTop: 8, marginBottom: 6 }}>Maintenance Requests:</Text>
        <PDFCheckboxGrid items={[
          { label: 'Heating / Cooling', checked: !!formData.maintenanceHeatingCooling },
          { label: 'Plumbing', checked: !!formData.maintenancePlumbing },
          { label: 'Electrical', checked: !!formData.maintenanceElectrical },
          { label: 'Appliances', checked: !!formData.maintenanceAppliances },
          { label: 'Doors / Windows', checked: !!formData.maintenanceDoorsWindows },
          { label: 'Flooring / Walls', checked: !!formData.maintenanceFlooringWalls },
          { label: 'Pest Concerns', checked: !!formData.maintenancePest },
          { label: 'Safety Issue', checked: !!formData.maintenanceSafety },
          { label: 'Other (specify)', checked: !!formData.maintenanceOtherText },
        ]} />
        {formData.maintenanceOtherText && (
          <PDFFormRow>
            <PDFFormField label="" value={formData.maintenanceOtherText} width="large" />
          </PDFFormRow>
        )}
      </PDFFormSection>

      {/* Household & Financial Information */}
      <PDFFormSection number="11">
        <PDFFormRow>
          <PDFFormField label="Gross annual income for entire household: (See Exhibit 'A' for required income documentation)" value={`$${formData.grossAnnualIncome || '0'}`} width="medium" />
        </PDFFormRow>
        {formData.householdMembers && formData.householdMembers.some((m: any) => m.hasIncome === 'yes' && m.incomes?.length > 0) && (
          <View style={{ marginTop: 10 }}>
            {/* Header Row */}
            <View style={{ flexDirection: 'row', borderBottomWidth: 1, borderBottomColor: '#000', paddingBottom: 3, marginBottom: 4 }}>
              <Text style={{ width: 30, fontSize: 9, fontWeight: 'semibold' }}>Sr No</Text>
              <Text style={{ flex: 2, fontSize: 9, fontWeight: 'semibold', marginLeft: 8 }}>Name of Household Member</Text>
              <Text style={{ flex: 2, fontSize: 9, fontWeight: 'semibold' }}>Income Type</Text>
              <Text style={{ flex: 1, fontSize: 9, fontWeight: 'semibold' }}>Income Amount</Text>
            </View>
            {/* Data Rows */}
            {(() => {
              let srNo = 0;
              const rows: any[] = [];
              let totalAmount = 0;
              formData.householdMembers.forEach((member: any) => {
                if (member.hasIncome === 'yes' && member.incomes?.length > 0) {
                  member.incomes.forEach((income: any, incomeIdx: number) => {
                    const isFirstRow = incomeIdx === 0;
                    if (isFirstRow) srNo++;
                    const amount = parseFloat(income.incomeAmount) || 0;
                    totalAmount += amount;
                    rows.push(
                      <View key={`${member.name}-${incomeIdx}`} style={{ flexDirection: 'row', borderBottomWidth: 0, paddingVertical: 3 }}>
                        <Text style={{ width: 30, fontSize: 9 }}>{isFirstRow ? srNo : ''}</Text>
                        <Text style={{ flex: 2, fontSize: 9, marginLeft: 8 }}>{isFirstRow ? member.name : ''}</Text>
                        <Text style={{ flex: 2, fontSize: 9 }}>{income.incomeType}</Text>
                        <Text style={{ flex: 1, fontSize: 9 }}>${income.incomeAmount || '0'}</Text>
                      </View>
                    );
                  });
                }
              });
              rows.push(
                <View key="total" style={{ flexDirection: 'row', borderTopWidth: 1, borderTopColor: '#000', paddingVertical: 3, marginTop: 2 }}>
                  <Text style={{ width: 30, fontSize: 9 }}></Text>
                  <Text style={{ flex: 2, fontSize: 9, fontWeight: 'semibold', marginLeft: 8 }}>Total</Text>
                  <Text style={{ flex: 2, fontSize: 9 }}></Text>
                  <Text style={{ flex: 1, fontSize: 9, fontWeight: 'semibold' }}>${totalAmount.toFixed(2)}</Text>
                </View>
              );
              return rows;
            })()}
          </View>
        )}
      </PDFFormSection>

      <PDFFormSection number="12">
        <PDFFormRow>
          <PDFFormField label="Total number of persons residing in dwelling:" value={formData.totalPersons} width="medium" />
        </PDFFormRow>
      </PDFFormSection>

      <PDFFormSection number="13">
        <PDFFormRow>
          <PDFFormField label="Number of children (under 18) within the dwelling:" value={formData.childrenUnder18} width="medium" />
        </PDFFormRow>
      </PDFFormSection>

      {/* Liabilities */}
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>Liabilities</Text>

        <PDFFormRow>
          <View style={{ flexDirection: 'row', flex: 1 }}>
            <View style={{ flex: 1 }}>
              <PDFInlineCheckboxGroup
                label="Mortgage Payment(s):"
                options={[
                  { label: 'YES', checked: formData.hasMortgage === 'yes' },
                  { label: 'NO', checked: formData.hasMortgage === 'no' },
                ]}
              />
            </View>
            <View style={{ flex: 1 }}>
              <PDFFormField label="Payment Amount(s):" value={`$${formData.mortgageAmount || ''}`} width="large" />
            </View>
          </View>
        </PDFFormRow>

        {formData.hasMortgage === 'yes' && (
          <>
            <PDFFormRow>
              <View style={{ flexDirection: 'row', flex: 1 }}>
                <View style={{ flex: 1 }}>
                  <PDFInlineCheckboxGroup
                    label="Payment Status:"
                    options={[
                      { label: 'Current', checked: formData.paymentStatus === 'current' },
                      { label: 'In Default', checked: formData.paymentStatus === 'default' },
                    ]}
                  />
                </View>
                <View style={{ flex: 1 }}>
                  <PDFFormField label="Current Mortgage Balance(s):" value={`$${formData.mortgageBalance || ''}`} width="large" />
                </View>

              </View>
            </PDFFormRow>

            <PDFFormRow>
              <PDFFormField label="Mortgagee:" value={formData.mortgagee} width="medium" />
            </PDFFormRow>
          </>
        )}
      </View>

      {/* Monthly Liabilities */}
      <View style={pdfStyles.section}>
        <PDFFormSectionTitle title="Monthly Liabilities Owed (Student, Auto, CC, personal):" />
        {formData.monthlyLiabilities && formData.monthlyLiabilities.length > 0 ? (
          formData.monthlyLiabilities.map((liability: any, index: number) => (
            <PDFLiabilityRow key={index} payee={liability.payeeName || liability.payee} amount={`$${liability.amount || '0'}`} />
          ))
        ) : formData.payees && formData.payees.length > 0 ? (
          formData.payees.map((payee: any, index: number) => (
            <PDFLiabilityRow key={index} payee={payee.payeeName || payee.payee} amount={`$${payee.amount || '0'}`} />
          ))
        ) : (
          <>
            <PDFLiabilityRow payee="" amount="" />
            <PDFLiabilityRow payee="" amount="" />
          </>
        )}
      </View>

      {/* Certifications */}
      <View style={pdfStyles.section} break>
        <Text style={pdfStyles.title}>Home Improvement Program - Required Certifications</Text>

        <Text style={pdfStyles.text}>I hereby certify that I/We am/are the owner(s) and occupant(s) of the property to be included within the LHDC Home Improvement Grant Program. To the best of my knowledge, all of the information provided above is true and accurate. I agree to cooperate with the LHDC which is administering this program and to comply with their specified rules and procedures.</Text>

        <Text style={pdfStyles.text}>I understand that any contract for renovation work paid for in whole or in part by a Home Improvement Grant from this program will be between the contractor(s) and myself\ourselves, and that I should not sign any contract for work under this program until authorized to do so by the LHDC. liability, or damage which might arise from my relationship with the contractor through this program. In addition, I understand that any contract for work to be completed at my/our home through a LHDC Home Improvement Grant is between the Contractor I/We have selected and myself/ourselves.</Text>

        <Text style={pdfStyles.text}>The above information is true and accurate to the best of my knowledge. I am aware that Section 1001 of Title 18 of the United States code makes it a criminal offense to make willful false statements or misrepresentations to any department or agency of the United States as to matters within its jurisdiction. In addition, I also certify that all information provided in this program application and all financial information provided to the LHDC is true and accurate. If upon further review, information that was provided to the LHDC for program purposes is found to be false, I understand that criminal proceedings will be commenced.</Text>

        <Text style={pdfStyles.text}>The LHDC and the New York State Affordable Housing Corporation are NOT responsible or liable for any breach of contract, faulty workmanship, accident liability, installation, performance, workmanship, liability, or damages which might arise from my participation in this program. Upkeep of the device(s) installed through my participation with this program is my/our responsibility. My\Our signature(s) below indicates my/our understanding of this statement.</Text>

        <Text style={pdfStyles.text}>I understand that if this application is approved and I receive a grant from the LHDC, a mortgage will be placed on my property by the New York State Affordable Housing Corporation as a condition of receiving said grant. The mortgage guarantees repayment upon the sale or transfer of my property or upon death of the applicant(s).</Text>

        <Text style={pdfStyles.text}>I understand that while in the grant recapture period, I must complete and return a yearly Continued Occupancy Affidavit to the LHDC. Additionally, I understand that the AHC in the care of LHDC will be added as a mortgagee to my homeowner's insurance which must be in effect throughout the duration of my grant recapture period.</Text>

        <PDFFormRow>
          <PDFFormField
            label="Signature(s):"
            value={formData.certificationSignerName || ''}
            signatureImage={formData.certificationSignature || formData.certification_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.certificationDateTime ? new Date(formData.certificationDateTime).toLocaleDateString() : ''} width="medium" paddingTop={formData.certificationSignature || formData.certification_signature ? 38 : 0} />
        </PDFFormRow>

        <PDFFormRow>
       <PDFFormField
            label="Signature(s):"
            value={formData.certificationCoApplicantSignerName || ''}
            signatureImage={formData.certificationCoApplicantSignature || formData.certification_coapplicant_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.certificationCoApplicantDateTime ? new Date(formData.certificationCoApplicantDateTime).toLocaleDateString() : ''} width="medium" paddingTop={formData.certificationCoApplicantSignature || formData.certification_coapplicant_signature ? 38 : 0} />
        </PDFFormRow>

        <Text style={{ fontSize: 10, marginTop: 10, marginBottom: 5, fontWeight: 'bold' }} break>STATE OF NEW YORK</Text>
        <Text style={{ fontSize: 10, marginBottom: 10, fontWeight: 'bold' }}>COUNTY OF ERIESS:</Text>

        <Text style={pdfStyles.text}>
          {"On the "}<Text style={{ fontWeight: 'bold' }}>{formData.notaryDay || '______'}</Text>
          {" day of "}<Text style={{ fontWeight: 'bold' }}>{formData.notaryMonth || '______'}</Text>
          {", in the year "}<Text style={{ fontWeight: 'bold' }}>{formData.notaryYear || '_______'}</Text>
          {", before me, the undersigned, a notary public in and for said state, personally appeared "}
          <Text style={{ fontWeight: 'bold' }}>{formData.notaryAppearedName || '_______________________________'}</Text>
          {", personally known to me or proved to me on the basis of satisfactory evidence to be the individual(s) whose name(s) is/are subscribed to the within instrument and acknowledged to me that he/she/they executed the same in his/her/their capacity(ies), and that by his/her/their signature(s) on the instrument, the individual(s), or the person upon behalf of which the individual(s) acted, executed the instrument."}
        </Text>

        <PDFFormRow>
          <PDFFormField label="Notary Public" value="" width="medium" />
        </PDFFormRow>
      </View>

      {/* Authorization to Receive and Verify Employment Information */}
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>"AUTHORIZATION TO RECEIVE AND VERIFY EMPLOYMENT INFORMATION"</Text>

        <Text style={pdfStyles.text}>I\We hereby consent to the sharing among you of any employment information which we obtain for the purpose of processing my\our application for the LHDC Home Improvement Grant Program. I\We waive any rights which I\We may have to keep that information confidential so long as it is shared only among you for determining my/our eligibility to receive a grant through this program. I\We also agree to hold harmless the LHDC from any claims for damages for use of that information in the manner provided by this waiver.</Text>

        <Text style={{ fontSize: 10, marginBottom: 5 }}>NOTICE TO APPLICANT: to process this application. By signing this form, you consent to employers sharing employment information about you</Text>

         <PDFFormRow>
          <PDFFormField
            label="Signature(s):"
            value={formData.employmentAuthSignerName || ''}
            signatureImage={formData.employmentAuthSignature || formData.employment_auth_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.employmentAuthDateTime ? new Date(formData.employmentAuthDateTime).toLocaleDateString() : ''} width="medium"  paddingTop={formData.employmentAuthDateTime || formData.employment_auth_datetime ? 38 : 0}/>
        </PDFFormRow>

        <PDFFormRow>
         <PDFFormField
            label="Signature(s):"
            value={formData.employmentAuthCoApplicantSignerName || ''}
            signatureImage={formData.employmentAuthCoApplicantSignature || formData.employment_auth_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.employmentAuthCoApplicantDateTime ? new Date(formData.employmentAuthCoApplicantDateTime).toLocaleDateString() : ''} width="medium"  paddingTop={formData.employmentAuthCoApplicantDateTime || formData.employment_auth_coapplicant_datetime ? 38 : 0}/>
        </PDFFormRow>
      </View>

      {/* Authorization of Inspection */}
      <View style={pdfStyles.section} break>
        <Text style={pdfStyles.title}>"AUTHORIZATION OF INSPECTION"</Text>

        <Text style={pdfStyles.text}>I hereby grant the Lackawanna Housing Development Corporation permission to inspect my property and to be on my property located at:</Text>

        <PDFFormRow>
          <PDFFormField label="" value={formData.applicantProperty || ''} width="large" />
        </PDFFormRow>

        <Text style={pdfStyles.text}>for the purpose of evaluating program needs and for all other program procedures and purposes. I also agree to hold harmless the LHDC from any claims for damages resulting from such access to my property through this program.</Text>

         <PDFFormRow>
          <PDFFormField
            label="Signature(s):"
            value={formData.inspectionAuthSignerName || ''}
            signatureImage={formData.inspectionAuthSignature || formData.inspection_auth_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.inspectionAuthDateTime ? new Date(formData.inspectionAuthDateTime).toLocaleDateString() : ''} width="medium"  paddingTop={formData.inspectionAuthDateTime || formData.inspection_auth_datetime ? 38 : 0}/>
        </PDFFormRow>

        <PDFFormRow>  
        <PDFFormField
            label="Signature(s):"
            value={formData.inspectionAuthCoApplicantSignerName || ''}
            signatureImage={formData.inspectionAuthCoApplicantSignature || formData.inspection_auth_coapplicant_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.inspectionAuthCoApplicantDateTime ? new Date(formData.inspectionAuthCoApplicantDateTime).toLocaleDateString() : ''} width="medium"  paddingTop={formData.inspectionAuthCoApplicantDateTime || formData.inspection_auth_coapplicant_datetime ? 38 : 0}/>
        </PDFFormRow>
      </View>
<View style={pdfStyles.section}></View>
      {/* Bid Responsibility */}
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>"BID RESPONSIBILITY"</Text>

        <Text style={pdfStyles.text}>I, the undersigned homeowner, acknowledge that I am responsible for obtaining bids from licensed and insured contractors. I understand that I will have four (4) weeks from the date I receive my bid packages to secure and submit three (3) contractor bids to the Lackawanna Housing Development Corporation (LHDC). Extensions will only be granted at the discretion of the LHDC.</Text>

          <PDFFormRow>
          <PDFFormField
            label="Signature(s):"
            value={formData.bidResponsibilitySignerName || ''}
            signatureImage={formData.bidResponsibilitySignature || formData.bid_responsibility_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.bidResponsibilityDateTime ? new Date(formData.bidResponsibilityDateTime).toLocaleDateString() : ''} width="medium"  paddingTop={formData.bidResponsibilityDateTime || formData.bid_responsibility_datetime ? 38 : 0}/>
        </PDFFormRow>
      </View>

      {/* Subordination of AHC Notes & Mortgages */}
      <View style={pdfStyles.section}>
        <Text style={pdfStyles.title}>Subordination of AHC Notes & Mortgages</Text>

        <Text style={pdfStyles.text}>The AHC will generally not subordinate it's Note and Mortgages to the lien of a subsequent Note and Mortgage Made to another lender, except under certain circumstances, such as:</Text>

        <Text style={pdfStyles.text}>The Subordination is needed to relieve a severe hardship that may occur due to the death of the homeowner, or in the event of a natural (e.g. fire or flood) or financial disaster (e.g. a prolonged disabling injury or other unforeseeable cause of involuntary and extended unemployment of loss of income),</Text>

        <Text style={pdfStyles.text}>The Subordination is necessary to obtain a straight refinanced mortgage with a lower interest-rate or term</Text>

        <Text style={pdfStyles.text}>AHC will determine in its sole discretion whether or not to issue such a Subordination.</Text>
        <Text style={pdfStyles.text}>AHC will not subordinate the lien position so that a homeowner can consolidate or pay off other debt, cash out, obtain a HELOC, or pay for home improvements.</Text>
        <Text style={pdfStyles.text}>AHC will not be subordinate to a variable interest rate.</Text>

        <Text style={pdfStyles.text}>In addition to basing its determination on whether the request fits the circumstances outlined above, AHC will consider the degree to which its agreement to subordinate the Note and Mortgage would expose AHC grant funds to increased risk. AHC will require information on the finances of the homeowner and the value of the mortgaged property in order to evaluate the extent of such increased risk.</Text>

        <Text style={pdfStyles.text}>The grantee/subgrantee should inform all home buyers or homeowners seeking to participate in an AHC project that AHC funds are subject to recapture in the event that the subsidized home is not occupied as the principal residence of the home buyer or homeowner for the applicable required minimum period, and that the AHC funds are immediately due and repayable in case of any default under the Note and Mortgage or other lender's loan affecting the mortgaged property.</Text>

        <PDFFormRow>
          <PDFFormField
            label="Applicant"
            value={formData.subordinationSignerName || ''}
            signatureImage={formData.subordinationSignature || formData.subordination_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.subordinationDateTime ? new Date(formData.subordinationDateTime).toLocaleDateString() : ''} width="medium"  paddingTop={formData.subordinationDateTime || formData.subordination_datetime ? 38 : 0}/>
        </PDFFormRow>

        <PDFFormRow>
            <PDFFormField
            label="Applicant"
            value={formData.subordinationCoApplicantSignerName || ''}
            signatureImage={formData.subordinationCoApplicantSignature || formData.subordination_coapplicant_signature}
            width="medium"
          />
          <PDFFormField label="Date:" value={formData.subordinationCoApplicantDateTime ? new Date(formData.subordinationCoApplicantDateTime).toLocaleDateString() : ''} width="medium"  paddingTop={formData.subordinationCoApplicantDateTime || formData.subordination_coapplicant_datetime ? 38 : 0}/>
        </PDFFormRow>
      </View>

      {/* Exhibit A - Required Documents */}
      <View style={pdfStyles.section} break>
        <Text style={pdfStyles.title}>EXHIBIT "A"</Text>
        <Text style={pdfStyles.title}>Lackawanna Housing Development Corporation Housing Renovation Program</Text>
        <Text style={pdfStyles.title}>Income Verification Required Documents (COPIES ONLY)</Text>

        <Text style={pdfStyles.text}>• Photo Identification</Text>
        <Text style={pdfStyles.text}>• Copy of deed to home.</Text>
        <Text style={pdfStyles.text}>• Copy of paid tax receipts; Town\County\School\Village. (Taxes must be current for program participation)</Text>
        <Text style={pdfStyles.text}>• Copy of Homeowner's Insurance Policy.</Text>
        <Text style={pdfStyles.text}>• Copy of latest federal and state income tax filings. (Including ALL Schedules and W-2's). If you did not file income taxes we need a non-filing tax transcript, call 800-908-9946 or fill out 4506-T or visit https://www.irs.gov/individuals/get-transcript and make an account to access transcript</Text>
        <Text style={pdfStyles.text}>• Verification of all checking and savings accounts, interest and annuity statements. (Provide last three months statements from your financial institution(s))</Text>

        <Text style={{ fontSize: 10, fontWeight: 'semibold', marginTop: 5, marginBottom: 3 }}>For all members of household who make income</Text>
        <Text style={pdfStyles.text}>• Verification of employment (four most recent pay stubs for all employed occupants).</Text>
        <Text style={pdfStyles.text}>• Verification of employment letter from employer</Text>

        <Text style={{ fontSize: 10, fontWeight: 'semibold', marginTop: 5, marginBottom: 3 }}>Verification of benefits: (Provide copies of notice of award or benefit for any/all that apply)</Text>
        <Text style={pdfStyles.text}>• Social Security</Text>
        <Text style={pdfStyles.text}>• Pension/Retirement</Text>
        <Text style={pdfStyles.text}>• SSI</Text>
        <Text style={pdfStyles.text}>• Disability</Text>
        <Text style={pdfStyles.text}>• Alimony/child support</Text>
        <Text style={pdfStyles.text}>• Veterans</Text>
        <Text style={pdfStyles.text}>• Unemployment</Text>
        <Text style={pdfStyles.text}>• Welfare</Text>
        <Text style={pdfStyles.text}>• Insurance dividends</Text>

        <Text style={pdfStyles.text}>• Verification of ALL land owned (Deed/title to property - real estate in addition to the property to be renovated shall require an evaluation of the additional property with the value to be included in determining the applicant's total assets).</Text>
        <Text style={pdfStyles.text}>• Verification of Certificates of Deposit (Produce all financial documentation).</Text>
        <Text style={pdfStyles.text}>• Verification of all annuities, insurance income, etc.</Text>
        <Text style={pdfStyles.text}>• Verification of liabilities (credit card statements, auto loans, student loans, etc.)</Text>
        <Text style={pdfStyles.text}>• Proof of residency (copy of (1) most recent utility bill i.e., water, wifi, gas, electric)</Text>
        <Text style={pdfStyles.text}>• Tenant residency affidavit (applicable to homeowners renting-out one of their unit)</Text>

        <Text style={{ fontSize: 10, fontWeight: 'semibold', marginTop: 10 }}>Please submit income documentation from the list above that applies to all members of your household</Text>
      </View>

      {/* Maintenance Needs */}
      {/* {(formData.maintenanceHeatingCooling || formData.maintenancePlumbing || formData.maintenanceElectrical ||
        formData.maintenanceAppliances || formData.maintenanceDoorsWindows || formData.maintenanceFlooringWalls ||
        formData.maintenancePest || formData.maintenanceSafety) && (
          <View style={pdfStyles.section}>
            <PDFFormSectionTitle title="Maintenance Needs" />
            <PDFTable>
              <ConditionalPDFTableRow condition={formData.maintenanceHeatingCooling} label="Heating/Cooling" value={formData.maintenanceHeatingCoolingText || 'Required'} />
              <ConditionalPDFTableRow condition={formData.maintenancePlumbing} label="Plumbing" value={formData.maintenancePlumbingText || 'Required'} />
              <ConditionalPDFTableRow condition={formData.maintenanceElectrical} label="Electrical" value={formData.maintenanceElectricalText || 'Required'} />
              <ConditionalPDFTableRow condition={formData.maintenanceAppliances} label="Appliances" value={formData.maintenanceAppliancesText || 'Required'} />
              <ConditionalPDFTableRow condition={formData.maintenanceDoorsWindows} label="Doors/Windows" value={formData.maintenanceDoorsWindowsText || 'Required'} />
              <ConditionalPDFTableRow condition={formData.maintenanceFlooringWalls} label="Flooring/Walls" value={formData.maintenanceFlooringWallsText || 'Required'} />
              <ConditionalPDFTableRow condition={formData.maintenancePest} label="Pest Control" value={formData.maintenancePestText || 'Required'} />
              <ConditionalPDFTableRow condition={formData.maintenanceSafety} label="Safety" value={formData.maintenanceSafetyText || 'Required'} />
              <ConditionalPDFTableRow condition={!!formData.maintenanceOtherText} label="Other" value={formData.maintenanceOtherText} isLast />
            </PDFTable>
          </View>
        )} */}

      {formData.documents && Array.isArray(formData.documents) && formData.documents.length > 0 && (
        <View style={pdfStyles.section}>
          <Text style={pdfStyles.sectionTitle}>Uploaded Documents</Text>
          <PDFTable>
            {formData.documents.map((doc: any, index: number) => (
              <PDFTableRowLink
                key={index}
                label={doc.documentType?.replace(/\($/, '').trim() || `Document ${index + 1}`}
                linkText={doc.originalName || 'Download'}
                linkUrl={`${process.env.NEXT_PUBLIC_EXPRESS_BACKEND_PUBLIC || 'http://localhost:3000'}/documents/${doc.fileName}`}
                isLast={index === formData.documents.length - 1}
              />
            ))}
          </PDFTable>
        </View>
      )}


    </>
  );
};
