import React, { Fragment } from 'react';
import { Typography } from '@mui/material';

/** Shared legal text for in-app ToS acknowledge and public read-only page. */
const TermsOfServiceDocument = (): JSX.Element => (
  <Fragment>
    <Typography variant="caption" color="text.secondary" display="block" sx={{ mb: 1 }}>
      Last Updated: July 27, 2026
    </Typography>

    <Typography variant="body1" paragraph>
      Welcome to Hesychia (hesychia.ai)! These Terms of Service (&quot;Terms&quot;) are a legally binding
      agreement between you and AI ML Operations, LLC (&quot;we,&quot; &quot;us,&quot; or &quot;our&quot;) governing your access
      to and use of the Hesychia large language model chat service (the &quot;Service&quot;).
    </Typography>
    <Typography variant="body1" paragraph>
      <strong>Please read these Terms carefully.</strong> By accessing or using the Service, you agree
      to be bound by these Terms. If you do not agree, do not use the Service.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="acceptance">
      1. Acceptance of Terms
    </Typography>
    <Typography variant="body1" paragraph>
      By creating an account, signing in, or otherwise using the Service, you acknowledge that you have
      read, understood, and agree to be bound by these Terms. If you are using the Service on behalf of
      an organization, you represent that you have authority to bind that organization.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="data-confidentiality">
      2. Data Confidentiality and Privacy
    </Typography>
    <Typography variant="body1" paragraph>
      We respect your data. Information you enter into the Service is contained within your organization
      workspace and will not be sold, shared, or disclosed to third parties without your explicit consent,
      except as needed to operate the Service (for example, infrastructure providers under appropriate
      agreements) or as required by law. See also Section 6 (Analytics and Cookies).
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="acceptable-use">
      3. Acceptable Use
    </Typography>
    <Typography variant="body1" paragraph>
      You agree to use the Service for legitimate purposes only and to comply with all applicable laws
      and regulations. You must not use the Service to harass others, distribute malware, attempt
      unauthorized access, scrape or overload the Service, or generate content that violates law or
      third-party rights.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="intellectual-property">
      4. Intellectual Property
    </Typography>
    <Typography variant="body1" paragraph>
      All intellectual property rights in the Service, including the software and models we provide,
      remain the property of AI ML Operations, LLC or its licensors. Output you generate through the
      Service is for your use; AI ML Operations, LLC makes no claim of ownership over that output,
      subject to any rights of underlying model providers and applicable law.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="ai-disclaimer">
      5. Limitation of Liability and AI Disclaimer
    </Typography>
    <Typography variant="body1" paragraph>
      The Service provides AI-generated responses that may be inaccurate, incomplete, or inappropriate
      for your use case. You are solely responsible for reviewing outputs before relying on them.
      <strong>
        {' '}
        The Service is provided &quot;AS IS&quot; and &quot;AS AVAILABLE&quot; without warranties of any kind.
      </strong>{' '}
      To the fullest extent permitted by law, AI ML Operations, LLC is not liable for any damages,
      including consequential, incidental, or punitive damages, arising from your use of the Service
      or reliance on any AI-generated content.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="analytics">
      6. Analytics and Cookies
    </Typography>
    <Typography variant="body1" paragraph>
      We use privacy-focused analytics (Tianji, operated on our infrastructure) to understand how the
      Service is used, diagnose issues, and improve features. We do not use advertising cookies. Before
      optional behavioral analytics run on production or beta builds, we ask for your consent through a
      notice on the Service. You may accept or decline at that time.
    </Typography>
    <Typography variant="body1" component="div" paragraph>
      We always collect limited usage information such as:
      <ul>
        <li>Anonymous page views and general device or browser type</li>
        <li>Referral or campaign parameters (such as UTM tags) and referrer information when present</li>
      </ul>
      If you accept optional analytics, we may also collect:
      <ul>
        <li>
          Product actions (for example, sign-in, sign-up, checkout, conversation created, message sent —
          without message or document contents)
        </li>
        <li>
          When you are signed in, a stable account identifier (such as email) so we can understand
          authenticated usage
        </li>
      </ul>
    </Typography>
    <Typography variant="body1" paragraph>
      If you decline optional analytics, we still collect anonymous page views and referral data
      described above, but we do not collect optional product events or associate activity with your
      account. Strictly necessary storage used for security and core functionality (such as JWT
      authentication in local storage) is separate from optional analytics. You can change your
      analytics choice by clearing site data for Hesychia in your browser; the consent notice will
      appear again on your next visit.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="changes">
      7. Changes to Terms
    </Typography>
    <Typography variant="body1" paragraph>
      We may update these Terms from time to time. We will notify you of significant changes, and your
      continued use of the Service after changes take effect constitutes acceptance of the updated Terms.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="governing-law">
      8. Governing Law
    </Typography>
    <Typography variant="body1" paragraph>
      These Terms are governed by and construed in accordance with the laws of the United States and
      the State of Illinois, without regard to conflict-of-law principles.
    </Typography>

    <Typography variant="h5" component="h2" gutterBottom id="contact">
      9. Contact
    </Typography>
    <Typography variant="body1" paragraph>
      Questions about these Terms? Contact AI ML Operations, LLC via{' '}
      <a href="https://www.aimloperations.com">aimloperations.com</a> or your Hesychia account
      administrator.
    </Typography>
  </Fragment>
);

export default TermsOfServiceDocument;
