{"id":2993,"date":"2026-06-03T09:47:13","date_gmt":"2026-06-03T09:47:13","guid":{"rendered":"https:\/\/www.nmvoitalia.it\/?page_id=2993"},"modified":"2026-06-03T09:52:39","modified_gmt":"2026-06-03T09:52:39","slug":"modulo-onboarding-depositari-e-grossisti","status":"publish","type":"page","link":"https:\/\/www.nmvoitalia.it\/en\/modulo-onboarding-depositari-e-grossisti\/","title":{"rendered":"Modulo onboarding Depositari e Grossisti"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"2993\" class=\"elementor elementor-2993\">\n\t\t\t\t<div class=\"elementor-element elementor-element-ef0222f e-grid e-con-boxed e-con e-parent\" data-id=\"ef0222f\" data-element_type=\"container\" data-e-type=\"container\" data-settings=\"{&quot;background_background&quot;:&quot;slideshow&quot;,&quot;background_slideshow_gallery&quot;:[{&quot;id&quot;:1737,&quot;url&quot;:&quot;https:\\\/\\\/www.nmvoitalia.it\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Sistema-di-Verifica.png&quot;}],&quot;background_slideshow_loop&quot;:&quot;yes&quot;,&quot;background_slideshow_slide_duration&quot;:5000,&quot;background_slideshow_slide_transition&quot;:&quot;fade&quot;,&quot;background_slideshow_transition_duration&quot;:500}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-d48fd85 elementor-widget__width-initial elementor-widget elementor-widget-heading\" data-id=\"d48fd85\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\">Modulo onboarding NMVS Depositari e Grossisti<\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-08e7940 e-flex e-con-boxed e-con e-parent\" data-id=\"08e7940\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-be70036 elementor-widget elementor-widget-shortcode\" data-id=\"be70036\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\">    <script type=\"text\/javascript\">\r\n        var nmvo_ajax_object = {\r\n            ajax_url: 'https:\/\/www.nmvoitalia.it\/wp-admin\/admin-ajax.php',\r\n            nonce: '37b6566b47',\r\n            redirect_url: '',\r\n            allowed_extensions: '.pdf',\r\n            attach_json: false,\r\n            attach_xlsx: true,\r\n            attach_pdf: true,\r\n            recaptcha_enabled: true,\r\n            recaptcha_site_key: '6LfPgPMsAAAAABoR9KsPWBMc6uNGnTFPY4o5JPC5',\r\n            translations: {\"draft\":\"Draft\",\"saved\":\"Salvato\",\"downloadJson\":\"Scarica JSON\",\"downloadPdf\":\"Scarica PDF\",\"downloadExcel\":\"Scarica Excel\",\"back\":\"Indietro\",\"saveDraft\":\"Salva bozza\",\"next\":\"Avanti\",\"finish\":\"Fine\",\"reset\":\"Reset\",\"draftSaved\":\"Bozza salvata\",\"stepOf\":\"Step\",\"of\":\"di\",\"remaining\":\"rimanenti\",\"required\":\"(obbl.)\",\"errFieldRequired\":\"Campo obbligatorio o non valido.\",\"errSelectRequired\":\"Selezione obbligatoria.\",\"errAttachmentRequired\":\"Allegato obbligatorio.\",\"errRequired\":\"Obbligatorio.\",\"selectPlaceholder\":\"\\u2014 Seleziona \\u2014\",\"yes\":\"S\\u00ec\",\"no\":\"No\",\"zipGenerating\":\"Generazione archivio ZIP in corso...\",\"zipSuccess\":\"Archivio ZIP scaricato con successo!\",\"zipError\":\"Errore durante la generazione dello ZIP:\",\"zipLibError\":\"Errore: libreria JSZip non caricata. Ricarica la pagina.\"}        };\r\n    <\/script>\r\n    <!doctype html>\n<html lang=\"it\">\n<head>\n  <meta charset=\"utf-8\" \/>\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" \/>\n  <title>NMVO Italia - Modulo Onboarding<\/title>\n  <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/jspdf@2.5.1\/dist\/jspdf.umd.min.js\"><\/script>\n  <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/xlsx@0.18.5\/dist\/xlsx.full.min.js\"><\/script>\n  <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/jszip@3.10.1\/dist\/jszip.min.js\"><\/script>\n  <style>\n    :root{\n      --nmvo-blue:#0052A5; --nmvo-blue-dark:#003d7a; --nmvo-blue-light:#0066CC;\n      --bg:#f5f7fa; --card:#ffffff; --muted:#6b7280; --text:#1f2937;\n      --accent:var(--nmvo-blue); --accent2:#0084d1; --danger:#dc3545;\n      --border:rgba(0,82,165,.15); --shadow: 0 4px 12px rgba(0,82,165,.1);\n      --radius: 8px; --font: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;\n    }\n    *{box-sizing:border-box}\n    body{\n      margin:0; font-family:var(--font);\n      background: var(--bg);\n      color:var(--text);\n      line-height:1.6;\n    }\n    a{color:var(--nmvo-blue); text-decoration:none} a:hover{text-decoration:underline; color:var(--nmvo-blue-dark)}\n    \n    \/* Header stile NMVO *\/\n    .topbar{\n      display:flex; align-items:center; justify-content:space-between;\n      padding:16px 24px; \n      background: linear-gradient(135deg, var(--nmvo-blue) 0%, var(--nmvo-blue-dark) 100%);\n      color:#ffffff;\n      box-shadow: 0 2px 8px rgba(0,82,165,.2);\n      position:sticky; top:0; z-index:10;\n    }\n    .brand{display:flex; gap:16px; align-items:center}\n    .logo{\n      width:50px;height:50px;border-radius:8px; \n      display:grid;place-items:center;\n      background: linear-gradient(135deg, rgba(255,255,255,.15) 0%, rgba(255,255,255,.05) 100%);\n      border: 2px solid rgba(255,255,255,.3);\n      color:#ffffff; \n      font-weight:900; \n      font-size:14px;\n      letter-spacing:1px;\n      position:relative;\n      overflow:hidden;\n    }\n    .logo::before{\n      content:''; position:absolute; inset:0;\n      background-image: \n        linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px),\n        linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);\n      background-size: 8px 8px;\n      opacity:0.5;\n    }\n    .logo::after{\n      content:'NMVO'; position:relative; z-index:1;\n    }\n    .titles .h1{font-size:18px;font-weight:700;line-height:1.2; color:#ffffff;}\n    .titles .h2{font-size:12px;color:rgba(255,255,255,.85);margin-top:4px; font-weight:400;}\n    .meta{display:flex; gap:10px; align-items:center}\n    .pill{\n      padding:6px 12px; \n      background: rgba(255,255,255,.2);\n      border:1px solid rgba(255,255,255,.3); \n      border-radius:999px; \n      font-size:12px; \n      color:#ffffff;\n      font-weight:600;\n    }\n    \/* Language selector: always show selected value clearly when closed *\/\n    #langSelect{\n      appearance: none;\n      -webkit-appearance: none;\n      -moz-appearance: none;\n      padding-right:28px;\n      min-width:120px;\n      background-image: url(\"data:image\/svg+xml,%3Csvg xmlns='http:\/\/www.w3.org\/2000\/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L2 4h8z'\/%3E%3C\/svg%3E\");\n      background-repeat: no-repeat;\n      background-position: right 10px center;\n      cursor: pointer;\n    }\n    #langSelect option{\n      color:#1f2937;\n      background:#ffffff;\n    }\n    .container{max-width: 1000px; margin: 0 auto; padding: 24px 20px 40px; display:grid; gap:16px;}\n    .card{\n      background: var(--card); \n      border: 1px solid var(--border); \n      border-radius: var(--radius); \n      box-shadow: var(--shadow); \n      padding: 24px;\n    }\n    .card.subtle{background: #f9fafb; border-color: rgba(0,82,165,.1);}\n    .progress{\n      height:8px; \n      background: #e5e7eb; \n      border-radius:999px; \n      overflow:hidden; \n      border:1px solid rgba(0,82,165,.1);\n    }\n    .progress__bar{\n      height:100%; \n      width:0%; \n      background: linear-gradient(90deg, var(--nmvo-blue) 0%, var(--nmvo-blue-light) 100%); \n      transition: width .3s ease;\n    }\n    .steps-list{\n      display:flex; \n      flex-wrap:wrap; \n      gap:8px; \n      margin-bottom:20px; \n      padding:12px; \n      background:var(--bg); \n      border-radius:var(--radius); \n      border:1px solid var(--border);\n    }\n    .step-item{\n      display:flex; \n      align-items:center; \n      gap:6px; \n      padding:6px 12px; \n      border-radius:6px; \n      font-size:13px; \n      font-weight:500; \n      transition:all .2s ease;\n      background:var(--card);\n      border:1px solid var(--border);\n      color:var(--text);\n    }\n    .step-item.completed{\n      background:#d1fae5; \n      border-color:#10b981; \n      color:#065f46;\n    }\n    .step-item.completed::before{\n      content:\"\u2713\"; \n      display:inline-block;\n      margin-right:4px;\n      font-weight:bold; \n      color:#10b981;\n    }\n    .step-item.current{\n      background:linear-gradient(135deg, var(--nmvo-blue) 0%, var(--nmvo-blue-light) 100%); \n      border-color:var(--nmvo-blue-dark); \n      color:#ffffff; \n      font-weight:600; \n      box-shadow:0 2px 8px rgba(0,82,165,.3);\n    }\n    .step-item.pending{\n      background:#f9fafb; \n      border-color:#e5e7eb; \n      color:var(--muted);\n    }\n    .step-item.not-applicable{\n      background:#f3f4f6; \n      border-color:#d1d5db; \n      color:#9ca3af; \n      opacity:0.6; \n      text-decoration:none; \n      cursor:not-allowed;\n    }\n    .steps{display:flex; justify-content:space-between; align-items:baseline; margin-top:16px; gap:10px; flex-wrap:wrap;}\n    .step{font-weight:700; color:var(--nmvo-blue); font-size:18px;} \n    .stepcount{color:var(--muted); font-size:13px; font-weight:500;}\n    .stepalert{width:100%; color:var(--danger); font-size:13px; font-weight:700; display:none;}\n    .nav{display:flex; justify-content:space-between; align-items:center; margin-top:20px; gap:12px;}\n    .nav__right{display:flex; gap:10px; align-items:center}\n    button{\n      border:1px solid var(--border); \n      border-radius: 8px; \n      padding:12px 20px;\n      background: #ffffff; \n      color: var(--text); \n      cursor:pointer; \n      font-weight:600;\n      font-size:14px;\n      transition: all .2s ease;\n    }\n    button:hover{\n      background: #f9fafb; \n      border-color: var(--nmvo-blue);\n      transform: translateY(-1px);\n      box-shadow: 0 2px 8px rgba(0,82,165,.15);\n    } \n    button:disabled{opacity:.5; cursor:not-allowed; transform:none;}\n    button.primary{\n      background: linear-gradient(135deg, var(--nmvo-blue) 0%, var(--nmvo-blue-dark) 100%); \n      color:#ffffff; \n      border-color: transparent;\n      box-shadow: 0 2px 8px rgba(0,82,165,.25);\n    }\n    button.primary:hover{\n      background: linear-gradient(135deg, var(--nmvo-blue-dark) 0%, var(--nmvo-blue) 100%);\n      box-shadow: 0 4px 12px rgba(0,82,165,.3);\n    }\n    button.ghost{\n      background: transparent; \n      border-color: transparent;\n      color:var(--nmvo-blue);\n    }\n    button.ghost:hover{\n      background: rgba(0,82,165,.05);\n      border-color: rgba(0,82,165,.1);\n    }\n    fieldset{\n      border:1px solid var(--border); \n      border-radius: 8px; \n      padding: 20px; \n      margin: 20px 0;\n      background: #fafbfc;\n    }\n    legend{\n      padding: 0 12px; \n      color: var(--nmvo-blue); \n      font-size: 13px; \n      letter-spacing: .3px;\n      font-weight:700;\n      text-transform:uppercase;\n    }\n    .grid{display:grid; grid-template-columns: repeat(12, 1fr); gap: 10px;}\n    .col-12{grid-column: span 12} .col-8{grid-column: span 8} .col-6{grid-column: span 6}\n    .col-4{grid-column: span 4} .col-3{grid-column: span 3} .col-2{grid-column: span 2}\n    label{\n      display:block; \n      font-size:13px; \n      color: var(--text); \n      margin-bottom:8px;\n      font-weight:600;\n    }\n    input, select, textarea{\n      width:100%; \n      max-width:100%;\n      min-width:0;\n      box-sizing:border-box;\n      padding:12px 14px; \n      border-radius: 6px;\n      border:1px solid var(--border); \n      background: #ffffff;\n      color: var(--text); \n      outline:none;\n      font-size:14px;\n      font-family:var(--font);\n      transition: all .2s ease;\n    }\n    input[type=\"file\"]{\n      padding:8px;\n      cursor:pointer;\n    }\n    input[type=\"file\"]:hover{\n      border-color: var(--nmvo-blue-light);\n    }\n    input[type=\"file\"]:focus{\n      border-color: var(--nmvo-blue); \n      box-shadow: 0 0 0 3px rgba(0,82,165,.1);\n    }\n    \/* Checkbox pi\u00f9 grandi e visibili *\/\n    input[type=\"checkbox\"]{\n      width: 20px;\n      height: 20px;\n      cursor: pointer;\n      margin-right: 8px;\n      flex-shrink: 0;\n    }\n    input:hover, select:hover, textarea:hover{\n      border-color: var(--nmvo-blue-light);\n    }\n    textarea{min-height:100px; resize: vertical}\n    input:focus, select:focus, textarea:focus{\n      border-color: var(--nmvo-blue); \n      box-shadow: 0 0 0 3px rgba(0,82,165,.1);\n      outline:none;\n    }\n    select{\n      cursor:pointer;\n      background-image: url(\"data:image\/svg+xml,%3Csvg xmlns='http:\/\/www.w3.org\/2000\/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230052A5' d='M6 9L1 4h10z'\/%3E%3C\/svg%3E\");\n      background-repeat: no-repeat;\n      background-position: right 12px center;\n      padding-right: 36px;\n      appearance: none;\n    }\n    .checkrow{\n      display:flex; \n      gap:12px; \n      align-items:flex-start; \n      padding:14px; \n      border:1px solid var(--border); \n      border-radius: 8px; \n      background: #ffffff;\n      transition: all .2s ease;\n    }\n    .checkrow:hover{\n      border-color: var(--nmvo-blue-light);\n      background: #fafbfc;\n    }\n    .checkrow input{width:auto; margin-top:4px; cursor:pointer;}\n    .small{font-size:12px; color: var(--muted); font-weight:400;}\n    .err{\n      margin-top:6px; \n      color: var(--danger); \n      font-size: 12px; \n      display:none;\n      font-weight:500;\n    }\n    .err.show{display:block}\n    .sectionhint{\n      margin-top:10px; \n      color: var(--muted); \n      font-size:13px;\n      line-height:1.5;\n    }\n    .sectionhint strong{color:var(--nmvo-blue);}\n    .usercard{\n      border:1px solid var(--border); \n      border-radius: 8px; \n      padding: 16px; \n      background: #ffffff; \n      margin-top:12px;\n      transition: all .2s ease;\n    }\n    .usercard:hover{\n      border-color: var(--nmvo-blue-light);\n      box-shadow: 0 2px 8px rgba(0,82,165,.1);\n    }\n    .userhead{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px;}\n    .badge{\n      font-size:11px; \n      padding:5px 10px; \n      border-radius:6px; \n      background: rgba(0,82,165,.1); \n      border:1px solid rgba(0,82,165,.2); \n      color: var(--nmvo-blue);\n      font-weight:600;\n    }\n    .footer{\n      max-width:1000px; \n      margin:0 auto; \n      padding: 20px 20px 30px; \n      color: var(--muted); \n      display:flex; \n      gap:10px; \n      align-items:center;\n      font-size:13px;\n      border-top:1px solid var(--border);\n      margin-top:40px;\n    }\n    .sep{opacity:.5; color:var(--muted);}\n    .hint{\n      margin-top: 16px; \n      padding: 16px; \n      border-radius: 8px; \n      border:1px solid rgba(0,82,165,.2); \n      color: var(--text); \n      background: linear-gradient(135deg, rgba(0,82,165,.05) 0%, rgba(0,132,209,.03) 100%);\n      font-size:13px;\n      line-height:1.6;\n    }\n    .hint strong{color:var(--nmvo-blue);}\n    .kbd{\n      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; \n      font-size: 11px; \n      padding: 3px 7px; \n      border-radius: 4px; \n      border:1px solid var(--border); \n      background: #f9fafb; \n      color: var(--text);\n    }\n    pre{\n      white-space:pre-wrap; \n      word-break:break-word;\n      background: #f9fafb;\n      padding:16px;\n      border-radius:8px;\n      border:1px solid var(--border);\n      font-size:12px;\n      line-height:1.6;\n    }\n    \n    \/* Hero banner style simile al sito *\/\n    .card{\n      position:relative;\n    }\n    .card::before{\n      content: '';\n      position: absolute;\n      top: 0;\n      left: 0;\n      right: 0;\n      height: 4px;\n      background: linear-gradient(90deg, var(--nmvo-blue) 0%, var(--nmvo-blue-light) 50%, var(--nmvo-blue) 100%);\n      border-radius: 8px 8px 0 0;\n    }\n  <\/style>\n  <!-- Google reCAPTCHA v2 con callback esplicito -->\n  <script src=\"https:\/\/www.google.com\/recaptcha\/api.js?onload=onRecaptchaLoad&render=explicit\" async defer><\/script>\n<\/head>\n<body>\n  <main class=\"container\" style=\"margin-top:40px;\">\n    <section class=\"card\" style=\"padding-top:28px;\">\n      <div class=\"steps-list\" id=\"stepsList\"><\/div>\n      <div class=\"progress\"><div class=\"progress__bar\" id=\"progressBar\"><\/div><\/div>\n      <div class=\"steps\">\n        <div class=\"step\" id=\"stepTitle\">\u2014<\/div>\n        <div class=\"stepcount\" id=\"stepCount\">\u2014<\/div>\n        <div class=\"stepalert\" id=\"stepAlert\"><\/div>\n      <\/div>\n\n      <form id=\"wizardForm\" novalidate><\/form>\n\n      <!-- reCAPTCHA widget (visibile solo all'ultimo step) -->\n      <div id=\"recaptchaContainer\" style=\"display:none;margin:24px 0;padding:20px;background:#f9fafb;border:1px solid var(--border);border-radius:var(--radius);text-align:center;\">\n        <p style=\"margin:0 0 16px 0;font-size:14px;color:var(--muted);font-weight:500;\">Verifica di sicurezza<\/p>\n        <div id=\"recaptchaWidget\" class=\"g-recaptcha\" style=\"display:inline-block;\"><\/div>\n        <div id=\"recaptchaError\" style=\"color:var(--danger);font-size:14px;margin-top:12px;display:none;font-weight:600;\">\n          \u26a0\ufe0f Completa la verifica \"Non sono un robot\" per procedere\n        <\/div>\n        <div id=\"recaptchaLoading\" style=\"color:var(--muted);font-size:13px;margin-top:12px;\">\n          Caricamento verifica reCAPTCHA in corso...\n        <\/div>\n      <\/div>\n\n      <div class=\"nav\">\n        <button class=\"ghost\" id=\"backBtn\" type=\"button\">Indietro<\/button>\n        <div class=\"nav__right\">\n          <button class=\"primary\" id=\"nextBtn\" type=\"button\">Avanti<\/button>\n        <\/div>\n      <\/div>\n    <\/section>\n\n    <section class=\"card subtle\">\n      <details open>\n        <summary>Note<\/summary>\n        <p class=\"small\">\n          I dati personali inseriti sono trattati da NMVO Italia s.c.a.r.l. ai sensi del GDPR esclusivamente per la gestione della richiesta e delle attivit\u00e0 di onboarding. Informativa completa: <a href=\"https:\/\/www.nmvoitalia.it\/privacy-policy\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.nmvoitalia.it\/privacy-policy\/<\/a>\n        <\/p>\n      <\/details>\n    <\/section>\n  <\/main>\n\n  <footer class=\"footer\">\n    <span>\u00a9 NMVO Italia<\/span><span class=\"sep\">\u2022<\/span>\n    <a href=\"#\" id=\"resetLink\">Reset<\/a>\n  <\/footer>\n\n  <script>\n    const STORAGE_KEY = \"nmvo_onboarding_wizard_it_v1\";\n\n    const $ = (sel) => document.querySelector(sel);\n\n    \/\/ reCAPTCHA widget ID e stato (globali)\n    let recaptchaWidgetId = null;\n    let recaptchaReady = false;\n\n    \/\/ Callback chiamato quando reCAPTCHA \u00e8 pronto\n    window.onRecaptchaLoad = function() {\n      recaptchaReady = true;\n      console.log('reCAPTCHA caricato e pronto');\n      \/\/ Se siamo gi\u00e0 all'ultimo step, renderizza il widget\n      renderRecaptchaIfNeeded();\n    };\n\n    \/\/ Funzione per renderizzare il widget reCAPTCHA se necessario\n    function renderRecaptchaIfNeeded() {\n      const recaptchaEnabled = typeof nmvo_ajax_object !== 'undefined' && nmvo_ajax_object.recaptcha_enabled;\n      if (!recaptchaEnabled || !nmvo_ajax_object.recaptcha_site_key) {\n        return;\n      }\n\n      const recaptchaWidget = document.getElementById('recaptchaWidget');\n      if (!recaptchaWidget) {\n        return;\n      }\n\n      \/\/ Renderizza solo se grecaptcha \u00e8 disponibile, non \u00e8 gi\u00e0 stato renderizzato e il container \u00e8 visibile\n      if (recaptchaReady && recaptchaWidgetId === null && recaptchaWidget.innerHTML === '') {\n        try {\n          recaptchaWidgetId = grecaptcha.render('recaptchaWidget', {\n            'sitekey': nmvo_ajax_object.recaptcha_site_key,\n            'theme': 'light'\n          });\n          console.log('Widget reCAPTCHA renderizzato con ID:', recaptchaWidgetId);\n          \n          \/\/ Nascondi il messaggio di caricamento\n          const loadingMsg = document.getElementById('recaptchaLoading');\n          if (loadingMsg) {\n            loadingMsg.style.display = 'none';\n          }\n        } catch(e) {\n          console.error('Errore rendering reCAPTCHA:', e);\n          \/\/ Mostra un messaggio di errore\n          const loadingMsg = document.getElementById('recaptchaLoading');\n          if (loadingMsg) {\n            loadingMsg.innerHTML = '\u26a0\ufe0f Errore caricamento reCAPTCHA. Ricarica la pagina.';\n            loadingMsg.style.color = 'var(--danger)';\n          }\n        }\n      }\n    }\n\n    \/\/ Rileva la lingua corrente da TranslatePress o WordPress\n    function detectCurrentLanguage() {\n      \/\/ 1. Controlla se TranslatePress ha salvato la lingua in localStorage\n      const trpLang = localStorage.getItem('trp-current-language');\n      if (trpLang) {\n        console.log('Lingua rilevata da TranslatePress localStorage:', trpLang);\n        return trpLang.startsWith('en') ? 'en' : 'it';\n      }\n      \n      \/\/ 2. Controlla l'attributo lang dell'elemento html\n      const htmlLang = document.documentElement.lang;\n      if (htmlLang) {\n        console.log('Lingua rilevata da HTML lang attribute:', htmlLang);\n        return htmlLang.startsWith('en') ? 'en' : 'it';\n      }\n      \n      \/\/ 3. Controlla l'URL per codici lingua (es: \/en\/, \/en-us\/)\n      const urlPath = window.location.pathname;\n      if (\/\\\/en[-_]\/.test(urlPath) || \/\\\/en\\\/\/.test(urlPath)) {\n        console.log('Lingua rilevata da URL: en');\n        return 'en';\n      }\n      \n      \/\/ 4. Controlla il cookie di TranslatePress\n      const cookies = document.cookie.split(';');\n      for (let cookie of cookies) {\n        const [name, value] = cookie.trim().split('=');\n        if (name === 'pll_language' || name === 'wp-wpml_current_language') {\n          console.log('Lingua rilevata da cookie:', value);\n          return value.startsWith('en') ? 'en' : 'it';\n        }\n      }\n      \n      \/\/ 5. Fallback alla lingua salvata in localStorage del form\n      const savedLang = localStorage.getItem(\"nmvo_onboarding_lang\");\n      if (savedLang) {\n        console.log('Lingua rilevata da form localStorage:', savedLang);\n        return savedLang;\n      }\n      \n      \/\/ 6. Default: italiano\n      console.log('Nessuna lingua rilevata, uso default: it');\n      return 'it';\n    }\n\n    \/\/ Formatta data in formato YYYY-MM-DD HH:mm:ss con timezone di Roma\n    function formatDateForExcel(date) {\n      const d = date instanceof Date ? date : new Date(date);\n      \/\/ Converti al timezone di Roma (Europe\/Rome)\n      const options = {\n        timeZone: 'Europe\/Rome',\n        year: 'numeric',\n        month: '2-digit',\n        day: '2-digit',\n        hour: '2-digit',\n        minute: '2-digit',\n        second: '2-digit',\n        hour12: false\n      };\n      const parts = new Intl.DateTimeFormat('it-IT', options).formatToParts(d);\n      const get = (type) => parts.find(p => p.type === type)?.value || '';\n      return `${get('year')}-${get('month')}-${get('day')} ${get('hour')}:${get('minute')}:${get('second')}`;\n    }\n\n    const loadedData = loadDraft();\n    const defaultData = {\n      meta: { createdAt: formatDateForExcel(new Date()), version: \"1.0\", form: \"NMVOItalia-FRM-010\" },\n      requestor: { firstName:\"\", lastName:\"\", company:\"\", email:\"\", phone:\"\", phonePrefix:\"+39\" },\n      request: { requestFor:\"\", clientStatus:\"\", nmvsClientId:\"\", effectiveDate:\"\", referenceTicket:\"\", noAccountChanges:false, hasIntegrationChanges:false, noAnagraficaChanges:false, allChanges:false },\n      company: { clientName:\"\", clientIdExisting:\"\", codiceIdentificativoSitoLogistico:[\"\"], piva:\"\", endUserType:\"\", endUserTypeOther:\"\", street:\"\", zip:\"\", city:\"\", country:\"\" },\n      mainContact: { firstLastName:\"\", email:\"\", company:\"\", division:\"\", street:\"\", zip:\"\", city:\"\", country:\"\", phone:\"\" },\n      integration: { hasExternalSystem:null, providerCompany:\"\", softwareName:\"\", version:\"\", proofBaselineTesting:\"\", attachments:[] },\n      users: [],\n      terms: {\n        baselineTestAck:false,\n        trainingDocs:{ guiManual:false, ncaReports:false, generalReports:false },\n        readTermsArvato:false,\n        provideAccurateData:false,\n        complyObligations:false,\n        handleUnavailability:false,\n        acceptControlsAuditTrail:false,\n        liabilityAck:false,\n        cooperateOnboarding:false,\n        declarationsAck:false,\n        authorizations:{ wholesaleArt100:false, designatedWholesaler:false, other:false, otherText:\"\", attachments:[], useExistingAuthorizations:false },\n        legitCheckAck:false,\n        acceptAll:false\n      },\n      approval: { role:\"\", name:\"\", date:\"\", signature:\"\" }\n    };\n    const state = {\n      step: 0,\n      data: loadedData ? (()=>{\n        const d = { ...defaultData, ...loadedData, requestor: loadedData.requestor || defaultData.requestor };\n        if (d.company) {\n          \/\/ Backward compatibility: migra eventuale vecchio campo codiceSis su codiceIdentificativoSitoLogistico\n          if (Array.isArray(d.company.codiceIdentificativoSitoLogistico)) {\n            \/\/ ok\n          } else if (Array.isArray(d.company.codiceSis)) {\n            d.company.codiceIdentificativoSitoLogistico = d.company.codiceSis;\n            delete d.company.codiceSis;\n          } else if (typeof d.company.codiceSis === \"string\") {\n            d.company.codiceIdentificativoSitoLogistico = [d.company.codiceSis || \"\"];\n            delete d.company.codiceSis;\n          } else if (typeof d.company.codiceIdentificativoSitoLogistico === \"string\") {\n            d.company.codiceIdentificativoSitoLogistico = [d.company.codiceIdentificativoSitoLogistico || \"\"];\n          } else if (!Array.isArray(d.company.codiceIdentificativoSitoLogistico)) {\n            d.company.codiceIdentificativoSitoLogistico = [\"\"];\n          }\n        }\n        if (!d.mainContact) {\n          d.mainContact = { firstLastName:\"\", email:\"\", company:\"\", division:\"\", street:\"\", zip:\"\", city:\"\", country:\"\", phone:\"\" };\n          if (d.company && d.company.emailContact) {\n            d.mainContact.email = d.company.emailContact;\n            delete d.company.emailContact;\n          }\n        }\n        if (Array.isArray(d.users)) {\n          d.users = d.users.map(u => {\n            if (!u) return u;\n            \/\/ migra vecchio campo division su codiceIdentificativoSitoLogistico\n            if (u.codiceIdentificativoSitoLogistico === undefined && typeof u.division === \"string\") {\n              u.codiceIdentificativoSitoLogistico = u.division;\n              delete u.division;\n            }\n            return u;\n          });\n        }\n        return d;\n      })() : defaultData,\n      lang: detectCurrentLanguage(),\n      files: { integration: [], auth: [] }\n    };\n\n    const translations = {\n      it: {\n        pageTitle: \"NMVO Italia - Modulo Onboarding\",\n        wizardTitle: \"NMVO Italia - Modulo Onboarding\",\n        wizardSubtitle: \"Basato su NMVOItalia-FRM-010 (NMVOItalia-SOP-016) \u2014 versione web\",\n        draft: \"Draft\",\n        saved: \"Salvato\",\n        downloadJson: \"Scarica JSON\",\n        downloadPdf: \"Scarica PDF\",\n        downloadExcel: \"Scarica Excel\",\n        back: \"Indietro\",\n        saveDraft: \"Salva bozza\",\n        next: \"Avanti\",\n        finish: \"Fine\",\n        reset: \"Reset\",\n        privacyNote: \"Note\",\n        privacyText: \"I dati personali inseriti sono trattati da NMVO Italia s.c.a.r.l. ai sensi del GDPR esclusivamente per la gestione della richiesta e delle attivit\u00e0 di onboarding. Informativa completa: <a href='https:\/\/www.nmvoitalia.it\/privacy-policy\/' target='_blank' rel='noopener noreferrer'>https:\/\/www.nmvoitalia.it\/privacy-policy\/<\/a>\",\n        draftSaved: \"Bozza salvata\",\n        completed: \"Completato\",\n        confirmReset: \"Vuoi cancellare la bozza e resettare il wizard?\",\n        stepOf: \"Step\",\n        of: \"di\",\n        remaining: \"rimanenti\",\n        required: \"(obbl.)\",\n        errFieldRequired: \"Campo obbligatorio o non valido.\",\n        errSelectRequired: \"Selezione obbligatoria.\",\n        errAttachmentRequired: \"Allegato obbligatorio.\",\n        errRequired: \"Obbligatorio.\",\n        langIt: \"Italiano\",\n        langEn: \"English\",\n        step0Title: \"1) Dati del richiedente\",\n        step1Title: \"2) Panoramica richiesta\",\n        step2Title: \"3) Dati azienda\",\n        step3Title: \"4) Integrazione tecnica (se applicabile)\",\n        step4Title: \"5) Account End-User (utenti)\",\n        step4AdminNotice: \"NON RICOMPILARE PER ADMIN INSERITO IN SEZIONE 3B, SOLO NUOVI REGULAR O ALTRI ADMIN\",\n        step5Title: \"6) Termini, condizioni e autorizzazioni\",\n        step6Title: \"7) Riepilogo e invio\",\n        section1Legend: \"Sezione 1 \u2014 Dati del richiedente\",\n        section1Hint: \"Inserire nel seguente modulo le informazioni della persona che sta per procedere alla compilazione della richiesta di Onboarding ad NMVS.\",\n        firstName: \"Nome\",\n        lastName: \"Cognome\",\n        company: \"Azienda\",\n        email: \"Email\",\n        phoneContact: \"Contatto telefonico\",\n        placeholderFirst: \"es. Mario\",\n        placeholderLast: \"es. Rossi\",\n        placeholderCompany: \"es. Azienda S.p.A.\",\n        placeholderEmail: \"es. mario.rossi@azienda.it\",\n        placeholderPhone: \"es. 123 456 7890\",\n        section1RequestLegend: \"Sezione 1 \u2014 Request Overview\",\n        requestType: \"Tipo di richiesta\",\n        selectPlaceholder: \"\u2014 Seleziona \u2014\",\n        newOnboarding: \"Nuovo onboarding Client\",\n        updateClient: \"Aggiornamento dati Client esistente\",\n        updateClientAdminNotice: \"Nota: la richiesta di aggiornamento Client NON SERVE per aggiungere nuovi user o cambiare anagrafica\/ruoli agli user gi\u00e0 esistenti sul sistema. Se il Client risulta gia' creato, sar\u00e0 SEMPRE responsabilita' dell'ADMIN mantenere aggiornati i propri user a sistema.\",\n        nmvsClientId: \"NMVS Client ID\",\n        placeholderNmvsId: \"es. PharmaIT123\",\n        referenceTicket: \"Riferimento \/ ticket (se presente)\",\n        placeholderTicket: \"es. INC-1234\",\n        noAccountChanges: \"Questa richiesta NON include modifiche agli account End-User.\",\n        noAccountChangesHelp: \"Se selezionato, lo step utenti verr\u00e0 saltato.\",\n        hasIntegrationChanges: \"Questa richiesta NON include modifiche ai dati di integrazione tecnica.\",\n        hasIntegrationChangesHelp: \"Se selezionato, lo step integrazione tecnica verr\u00e0 saltato.\",\n        noAnagraficaChanges: \"Questa richiesta NON include modifiche all'anagrafica cliente\",\n        noAnagraficaChangesHelp: \"Se selezionato, lo step di verifica anagrafica verr\u00e0 saltato.\",\n        allChanges: \"\u00c8 necessario richiedere modifiche all'anagrafica cliente e ai dati di integrazione tecnica\",\n        allChangesHelp: \"Se selezionato, gli altri checkbox verranno disattivati.\",\n        selectOneOption: \"Selezionare almeno un'opzione.\",\n        section3Legend: \"Sezione 3a - Company Information\",\n        clientName: \"Ragione sociale (Client Name)\",\n        clientIdExisting: \"Client ID (solo se esistente)\",\n        codiceSis: \"Codice identificativo Sito Logistico\",\n        placeholderCodice: \"es. 001234\",\n        piva: \"P.IVA\",\n        placeholderPiva: \"es. IT12345678901\",\n        endUserType: \"Tipo di End-User\",\n        wholesaler: \"Depositario \/ Grossista (Wholesaler)\",\n        dispenser: \"Altro soggetto autorizzato al dispensing\",\n        nca: \"Autorit\u00e0 competente (NCA)\",\n        other: \"Specificare tipo di autorizzazione\",\n        specifyOther: \"Specificare (se 'Altro')\",\n        mainContactLegend: \"Sezione 3b - Contatto principale del Client (Main Client Contact)\",\n        mainContactHint: \"I dati di questo contatto saranno utilizzati per creare il primo utente ADMIN del client nel sistema NMVS (creazione automatica in caso di nuovo onboarding).\",\n        mainContactAdminWarning: \"<strong>Attenzione - L'ADMIN del Client avr\u00e0 le seguenti responsabilit\u00e0:<\/strong><ul><li>creare nuovi user<\/li><li>fornire password temporanea di primo accesso durante la fase di creazione user<\/li><li>modificare anagrafica user<\/li><li>convertire ruolo user Regular in Admin<\/li><li>sbloccare user temporaneamente bloccato<\/li><li>bloccare propri user<\/li><\/ul>Per ogni dubbio consultare la pagina informativa su Onboarding Wholesaler sul sito <a href=\\\"https:\/\/www.nmvoitalia.it\/\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">www.nmvoitalia.it<\/a>\",\n        mcFirstLastName: \"Nome e cognome\",\n        mcEmail: \"Email\",\n        mcPlaceholderEmail: \"es. ufficio.qualita@azienda.it\",\n        mcCompany: \"Ragione sociale (se diversa dal Client)\",\n        mcDivision: \"Codice identificativo Sito Logistico\",\n        mcStreet: \"Indirizzo (via\/piazza)\",\n        mcZip: \"CAP\",\n        mcCity: \"Citt\u00e0\",\n        mcCountry: \"Paese\",\n        mcPhone: \"Telefono\",\n        mcPlaceholderPhone: \"es. 123 456 7890\",\n        street: \"Indirizzo (via\/piazza)\",\n        zip: \"CAP\",\n        placeholderZip: \"00100\",\n        city: \"Citt\u00e0\",\n        country: \"Paese\",\n        placeholderCountry: \"Italia\",\n        section4Legend: \"Sezione 4 \u2014 Integrated Client \/ External System\",\n        hasExternalSystem: \"\u00c8 presente un sistema esterno da integrare con NMVS Italia?\",\n        yes: \"S\u00ec\",\n        no: \"No\",\n        integrationHint: \"Compilare solo se \u00e8 presente un sistema esterno integrato con NMVS (es. L4 via web service).\",\n        providerCompany: \"Software Company (provider)\",\n        placeholderProvider: \"es. SAP, Tracelink, Antares\",\n        softwareName: \"Nome software\",\n        placeholderSoftware: \"es. Seavision L4, Diamind\",\n        version: \"Versione\",\n        placeholderVersion: \"es. 7.2.1\",\n        baselineProof: \"Evidenza baseline testing (Arvato SWS-NMVS)\",\n        baselineProofHelp: \"Per integrazioni tecniche \u00e8 richiesta evidenza baseline testing completato (portale Arvato). Link: https:\/\/sws-nmvs.eu\/register\",\n        baselineProofPlaceholder: \"Inserire riferimento (ID test, link, note).\",\n        integrationAttachments: \"Allega obbligatoriamente la documentazione relativa al Baseline Testing del software indicato caricata sul Software Supplier Portal (https:\/\/sws-nmvs.eu\/register), unitamente a qualsiasi altra documentazione relativa all'integrazione se disponibile.\",\n        integrationAttachmentsHelp: \"Caricare uno o pi\u00f9 documenti relativi all'integrazione (es. documentazione tecnica, certificati, ecc.)\",\n        explanationNoExternal: \"Il Cliente non utilizza sistemi esterni integrati con il NMVS.\\nLe operazioni previste dalla normativa vigente in materia di serializzazione dei medicinali saranno pertanto effettuate tramite accesso diretto al sistema NMVS, secondo le modalit\u00e0 e i profili autorizzativi previsti.\",\n        explanationYesExternal: \"Il Cliente utilizza un sistema esterno integrato come sistema applicativo principale per l'interazione con il NMVS.\\nTale sistema esterno \u00e8 impiegato per l'esecuzione delle operazioni rilevanti ai fini della normativa sulla serializzazione, mediante integrazione tecnica con il NMVS. L'accesso diretto al sistema NMVS rimane comunque disponibile e valido e pu\u00f2 essere utilizzato come modalit\u00e0 di accesso secondaria, anche a fini di continuit\u00e0 operativa o in caso di indisponibilit\u00e0 del sistema esterno.\",\n        errIntegrationAttachment: \"Allegato obbligatorio quando \u00e8 presente un sistema esterno.\",\n        section5Legend: \"Sezione 5 \u2014 Client End-User Accounts\",\n        section5Hint: \"Inserire almeno 1 utente con ruolo Regular.\",\n        addUser: \"+ Aggiungi utente\",\n        totalUsers: \"Totale utenti:\",\n        userN: \"Utente #\",\n        remove: \"Rimuovi\",\n        requestTypeLabel: \"Tipo richiesta\",\n        newAccount: \"Nuovo account\",\n        updateAccount: \"Aggiorna account\",\n        retireAccount: \"Ritira account\",\n        userIdLabel: \"User ID (obbl. per update\/retire)\",\n        userIdPlaceholder: \"ID account nel NMVS Core (se applicabile)\",\n        errUserIdRequired: \"Obbligatorio per update\/retire.\",\n        firstLastName: \"Nome e cognome\",\n        errEmailInvalid: \"Email non valida.\",\n        companyLabel: \"Company (se diversa dal Client)\",\n        division: \"Codice identificativo Sito Logistico\",\n        noUsersHint: \"Nessun utente inserito. Usa \\\"Aggiungi utente\\\".\",\n        toastAddUser: \"Aggiungi almeno un utente oppure seleziona 'nessuna modifica account' allo step 1.\",\n        toastAdminRequired: \"Serve almeno 1 utente con ruolo ADMIN.\",\n        toastRegularRequired: \"Serve almeno 1 utente con ruolo Regular.\",\n        section6Legend: \"Sezione 6 \u2014 Termini e condizioni (T&C)\",\n        arvatoPortal: \"Portale Arvato (baseline test + documentazione):\",\n        baselineTestAckLabel: \"Se collego NMVS tramite sistema esterno (Integrated Client), user\u00f2 solo software testato\/approvato (baseline test completato su Software Supplier Portal di Arvato).\",\n        authorizationsTitle: \"Autorizzazioni (selezionare almeno una)\",\n        authorizationsExamples: \"Ad esempio: autorizzazione AIFA\/Ministero della Salute come depositario o grossista; eventuale licenza di distribuzione all\u2019ingrosso; altra documentazione ufficiale che attesti il diritto ad operare nella supply chain farmaceutica.\",\n        authOtherAddHint: \"clicca qui per aggiungere un altro documento\",\n        useExistingAuthorizations: \"Valgono le autorizzazioni gi\u00e0 fornite in fase di onboarding iniziale\",\n        authWholesale: \"Autorizzazione distribuzione all'ingrosso (Art. 100, c.1 D.Lgs 219\/2006).\",\n        authDesignated: \"Autorizzazione come Designated Wholesaler (se applicabile).\",\n        specifyOtherAuth: \"Specificare altra autorizzazione\",\n        authAttachments: \"Allegati documentazione autorizzazioni\",\n        authAttachmentsHelp: \"Caricare uno o pi\u00f9 documenti che attestano le autorizzazioni selezionate (obbligatorio se \u00e8 stata selezionata almeno un'autorizzazione)\",\n        declarationsTitle: \"Dichiarazioni\",\n        declarationsList: \"Procedendo con l\\'invio del modulo, il richiedente dichiara di aver letto e di accettare integralmente i <a href='https:\/\/www.nmvoitalia.it\/wp-content\/uploads\/2026\/05\/NMVO_Italia_TC_NMVS.pdf' target='_blank' rel='noopener noreferrer'><strong>Termini e Condizioni di NMVO Italia<\/strong><\/a> relativi all\\'onboarding e all\\'utilizzo del sistema NMVS e le seguenti clausole nello specifico: Clause: 5.3 (DURATION, SUSPENSION OF SERVICE, TERMINATION), Clauses 12.1, 12.2, 12.3, 12.4, 12.5 (LIMITATION OF WARRANTY AND LIABILITY); Clause 15.2 (CHOICE OF LAW AND JURISDICTION).\",\n        toastSelectAuth: \"Seleziona almeno un'autorizzazione.\",\n        errAuthAttachment: \"Allegato obbligatorio quando \u00e8 selezionata almeno un'autorizzazione.\",\n        section7Legend: \"Sezione 7 \u2014 Riepilogo e invio\",\n        summaryTitle: \"Riepilogo Richiesta Onboarding NMVS\",\n        generatedOn: \"Generato il\",\n        section1Data: \"1. Dati del Richiedente\",\n        section2Request: \"2. Panoramica Richiesta\",\n        requestTypeLabelSummary: \"Tipo di richiesta:\",\n        section3Company: \"3. Dati Azienda\",\n        legalName: \"Ragione sociale:\",\n        codiceSisLabel: \"Codice identificativo Sito Logistico:\",\n        addSite: \"+ Aggiungi sito\/stabilimento\",\n        endUserTypeLabel: \"Tipo di End-User:\",\n        mainContactSummaryTitle: \"Contatto principale del Client\",\n        mcNameLabel: \"Nome e cognome:\",\n        mcEmailLabel: \"Email:\",\n        mcCompanyLabel: \"Company:\",\n        mcDivisionLabel: \"Sito Logistico:\",\n        mcPhoneLabel: \"Telefono:\",\n        address: \"Indirizzo\",\n        section4Integration: \"4. Integrazione Tecnica\",\n        externalSystemPresent: \"Sistema esterno presente:\",\n        softwareCompany: \"Software Company:\",\n        softwareNameLabel: \"Nome software:\",\n        versionLabel: \"Versione:\",\n        baselineTestingEvidence: \"Evidenza baseline testing:\",\n        section5Users: \"5. Account End-User\",\n        noUsersEntered: \"Nessun utente inserito.\",\n        requestTypeCol: \"Tipo richiesta:\",\n        userID: \"User ID:\",\n        firstLastNameCol: \"Nome e cognome:\",\n        emailCol: \"Email:\",\n        phoneCol: \"Telefono\",\n        companyCol: \"Company:\",\n        divisionCol: \"Codice identificativo Sito Logistico:\",\n        roleCol: \"Ruolo:\",\n        section6Terms: \"6. Termini e Condizioni\",\n        declarations: \"Dichiarazioni:\",\n        accepted: \"\u2713 Accettate\",\n        authArt100: \"Autorizzazione Art. 100:\",\n        otherAuthorizations: \"Altre autorizzazioni:\",\n        section7Attachments: \"7. Allegati\",\n        integrationDocs: \"Documentazione Integrazione Tecnica:\",\n        authDocs: \"Documentazione Autorizzazioni:\",\n        attachmentN: \"Allegato\",\n        pageOf: \"Pagina\",\n        pdfDownloaded: \"PDF scaricato con successo\",\n        excelDownloaded: \"Excel scaricato con successo\",\n        excelError: \"Errore: libreria Excel non caricata. Ricarica la pagina.\",\n        excelGenError: \"Errore durante la generazione dell'Excel:\",\n        fileSelected: \"File selezionati:\",\n        zipGenerating: \"Generazione archivio ZIP in corso...\",\n        zipSuccess: \"Archivio ZIP scaricato con successo!\",\n        zipError: \"Errore durante la generazione dello ZIP:\",\n        zipLibError: \"Errore: libreria JSZip non caricata. Ricarica la pagina.\",\n        instructionTitle: \"Procedura completata con successo!\",\n        instructionSubtitle: \"Il file ZIP contenente tutta la documentazione \u00e8 stato scaricato.\",\n        instructionZipContents: \"Contenuto del file ZIP:\",\n        instructionFileJson: \"Modulo compilato (JSON)\",\n        instructionFilePdf: \"Modulo compilato (PDF)\",\n        instructionFileExcel: \"Modulo compilato (Excel)\",\n        instructionFolderIntegration: \"Allegati integrazione tecnica\",\n        instructionFolderAuth: \"Allegati autorizzazioni\",\n        instructionEmailTitle: \"Prossimo passo\",\n        instructionEmailText: \"Inviare il file ZIP scaricato (con tutti i file contenuti) a NMVO Italia al seguente indirizzo email:\",\n        instructionEmailNote: \"Assicurarsi di allegare il file ZIP completo alla email. Non \u00e8 necessario estrarre i file dall'archivio.\",\n        instructionBackBtn: \"Torna al wizard\",\n        attachmentWarning: \"Attenzione: i file allegati durante la compilazione non sono pi\u00f9 disponibili in memoria (la pagina \u00e8 stata ricaricata). Saranno inclusi solo i file generati (JSON, PDF, Excel). Ricaricare il modulo e ripetere l'upload degli allegati se necessario.\",\n        successTitle: \"Richiesta inviata con successo!\",\n        successConfirmation: \"\u2713 La tua richiesta \u00e8 stata inviata automaticamente via email.\",\n        close: \"Chiudi\"\n      },\n      en: {\n        pageTitle: \"NMVO Italia - Modulo Onboarding\",\n        wizardTitle: \"NMVO Italia - Modulo Onboarding\",\n        wizardSubtitle: \"Based on NMVOItalia-FRM-010 (NMVOItalia-SOP-016) \u2014 web version\",\n        draft: \"Draft\",\n        saved: \"Saved\",\n        downloadJson: \"Download JSON\",\n        downloadPdf: \"Download PDF\",\n        downloadExcel: \"Download Excel\",\n        back: \"Back\",\n        saveDraft: \"Save draft\",\n        next: \"Next\",\n        finish: \"Finish\",\n        reset: \"Reset\",\n        privacyNote: \"Note\",\n        privacyText: \"Personal data entered is processed by NMVO Italia s.c.a.r.l. in accordance with GDPR exclusively for managing the request and onboarding activities. Full privacy policy: <a href='https:\/\/www.nmvoitalia.it\/privacy-policy\/' target='_blank' rel='noopener noreferrer'>https:\/\/www.nmvoitalia.it\/privacy-policy\/<\/a>\",\n        draftSaved: \"Draft saved\",\n        completed: \"Completed\",\n        confirmReset: \"Do you want to clear the draft and reset the wizard?\",\n        stepOf: \"Step\",\n        of: \"of\",\n        remaining: \"remaining\",\n        required: \"(required)\",\n        errFieldRequired: \"Required or invalid field.\",\n        errSelectRequired: \"Selection required.\",\n        errAttachmentRequired: \"Attachment required.\",\n        errRequired: \"Required.\",\n        langIt: \"Italiano\",\n        langEn: \"English\",\n        step0Title: \"1) Requester data\",\n        step1Title: \"2) Request overview\",\n        step2Title: \"3) Company data\",\n        step3Title: \"4) Technical integration (if applicable)\",\n        step4Title: \"5) End-User accounts\",\n        step4AdminNotice: \"DO NOT FILL OUT FOR ADMIN ALREADY ENTERED IN SECTION 3B, ONLY NEW REGULAR OR OTHER ADMINS\",\n        step5Title: \"6) Terms, conditions and authorizations\",\n        step6Title: \"7) Summary and submit\",\n        section1Legend: \"Section 1 \u2014 Requester data\",\n        section1Hint: \"Enter in the form below the information of the person who is about to complete the NMVS onboarding request.\",\n        firstName: \"First name\",\n        lastName: \"Last name\",\n        company: \"Company\",\n        email: \"Email\",\n        phoneContact: \"Phone contact\",\n        placeholderFirst: \"e.g. John\",\n        placeholderLast: \"e.g. Smith\",\n        placeholderCompany: \"e.g. Company Inc.\",\n        placeholderEmail: \"e.g. john.smith@company.com\",\n        placeholderPhone: \"e.g. 123 456 7890\",\n        section1RequestLegend: \"Section 1 \u2014 Request overview\",\n        requestType: \"Request type\",\n        selectPlaceholder: \"\u2014 Select \u2014\",\n        newOnboarding: \"New Client onboarding\",\n        updateClient: \"Update existing Client data\",\n        updateClientAdminNotice: \"Note: this form is not for changing or adding new users in the system. If the client already exists, the admin is responsible for keeping their users up to date in the system.\",\n        nmvsClientId: \"NMVS Client ID\",\n        placeholderNmvsId: \"e.g. PharmaIT123\",\n        referenceTicket: \"Reference \/ ticket (if any)\",\n        placeholderTicket: \"e.g. INC-1234\",\n        noAccountChanges: \"This request does NOT include End-User account changes.\",\n        noAccountChangesHelp: \"If selected, the users step will be skipped.\",\n        hasIntegrationChanges: \"This request does NOT include technical integration data changes.\",\n        hasIntegrationChangesHelp: \"If selected, the technical integration step will be skipped.\",\n        noAnagraficaChanges: \"This request does NOT include client profile changes\",\n        noAnagraficaChangesHelp: \"If selected, the profile verification step will be skipped.\",\n        allChanges: \"This request must include changes to client profile and technical integration data.\",\n        allChangesHelp: \"If selected, the other checkboxes will be disabled.\",\n        selectOneOption: \"Select at least one option.\",\n        section3Legend: \"Section 3 \u2014 Company information\",\n        clientName: \"Legal name (Client name)\",\n        clientIdExisting: \"Client ID (if existing)\",\n        codiceSis: \"Logistics site identifier code\",\n        placeholderCodice: \"e.g. 001234\",\n        piva: \"VAT number\",\n        placeholderPiva: \"e.g. IT12345678901\",\n        endUserType: \"End-User type\",\n        wholesaler: \"Depositary \/ Wholesaler\",\n        dispenser: \"Other entity authorized for dispensing\",\n        nca: \"Competent Authority (NCA)\",\n        other: \"Specify type of authorization\",\n        specifyOther: \"Specify (if 'Other')\",\n        mainContactLegend: \"Main Client Contact\",\n        mainContactHint: \"This contact's data will be used to create the first ADMIN user for this client in the NMVS system (automatically created for new onboarding).\",\n        mcFirstLastName: \"First and last name\",\n        mcEmail: \"Email\",\n        mcPlaceholderEmail: \"e.g. quality@company.com\",\n        mcCompany: \"Company name (if different from Client)\",\n        mcDivision: \"Division\",\n        mcStreet: \"Street\",\n        mcZip: \"Zip\",\n        mcCity: \"City\",\n        mcCountry: \"Country\",\n        mcPhone: \"Phone\",\n        mcPlaceholderPhone: \"e.g. 123 456 7890\",\n        street: \"Address (street\/square)\",\n        zip: \"ZIP\/Postal code\",\n        placeholderZip: \"00100\",\n        city: \"City\",\n        country: \"Country\",\n        placeholderCountry: \"Italy\",\n        section4Legend: \"Section 4 \u2014 Integrated Client \/ External system\",\n        hasExternalSystem: \"Is there an external system to integrate with NMVS Italy?\",\n        yes: \"Yes\",\n        no: \"No\",\n        integrationHint: \"Complete only if an external system integrated with NMVS is present (e.g. L4 via web service).\",\n        providerCompany: \"Software company (provider)\",\n        placeholderProvider: \"e.g. SAP, Tracelink, Antares\",\n        softwareName: \"Software name\",\n        placeholderSoftware: \"e.g. Seavision L4, Diamind\",\n        version: \"Version\",\n        placeholderVersion: \"e.g. 7.2.1\",\n        baselineProof: \"Baseline testing evidence (Arvato SWS-NMVS)\",\n        baselineProofHelp: \"For technical integrations, baseline testing completion evidence is required (Arvato portal). Link: https:\/\/sws-nmvs.eu\/register\",\n        baselineProofPlaceholder: \"Enter reference (test ID, link, notes).\",\n        integrationAttachments: \"Attach mandatorily the documentation related to the Baseline Testing of the indicated software uploaded on the Software Supplier Portal (https:\/\/sws-nmvs.eu\/register), together with any other integration-related documentation if available.\",\n        integrationAttachmentsHelp: \"Upload one or more documents related to integration (e.g. technical documentation, certificates)\",\n        explanationNoExternal: \"The Client does not use external systems integrated with NMVS.\\nOperations required by current legislation on medicinal product serialization will therefore be carried out via direct access to the NMVS system, according to the applicable modalities and authorization profiles.\",\n        explanationYesExternal: \"The Client uses an integrated external system as the main application for interaction with NMVS.\\nThis external system is used to perform operations relevant to serialization legislation, through technical integration with NMVS. Direct access to NMVS remains available and valid as a secondary access mode, including for operational continuity or external system unavailability.\",\n        errIntegrationAttachment: \"Attachment required when an external system is present.\",\n        section5Legend: \"Section 5 \u2014 Client End-User accounts\",\n        section5Hint: \"Enter at least 1 user with Regular role.\",\n        addUser: \"+ Add user\",\n        totalUsers: \"Total users:\",\n        userN: \"User #\",\n        remove: \"Remove\",\n        requestTypeLabel: \"Request type\",\n        newAccount: \"New account\",\n        updateAccount: \"Update account\",\n        retireAccount: \"Retire account\",\n        userIdLabel: \"User ID (required for update\/retire)\",\n        userIdPlaceholder: \"Account ID in NMVS Core (if applicable)\",\n        errUserIdRequired: \"Required for update\/retire.\",\n        firstLastName: \"Full name\",\n        errEmailInvalid: \"Invalid email.\",\n        companyLabel: \"Company (if different from Client)\",\n        division: \"Logistics site identifier code\",\n        noUsersHint: \"No users entered. Use \\\"Add user\\\".\",\n        toastAddUser: \"Add at least one user or select 'no account changes' in step 1.\",\n        toastAdminRequired: \"At least 1 user with ADMIN role is required.\",\n        toastRegularRequired: \"At least 1 user with Regular role is required.\",\n        section6Legend: \"Section 6 \u2014 Terms and conditions (T&C)\",\n        arvatoPortal: \"Arvato portal (baseline test + documentation):\",\n        baselineTestAckLabel: \"If I connect to NMVS via external system (Integrated Client), I will use only tested\/approved software (baseline test completed on Arvato Software Supplier Portal).\",\n        authorizationsTitle: \"Authorizations (select at least one)\",\n        authorizationsExamples: \"For example: AIFA\/Ministry of Health authorization as depositary or wholesaler; any wholesale distribution licence; other official documentation proving the right to operate in the pharmaceutical supply chain.\",\n        authOtherAddHint: \"click here to add another document\",\n        useExistingAuthorizations: \"Authorizations already provided during initial onboarding apply\",\n        authWholesale: \"Wholesale distribution authorization (Art. 100, c.1 Legislative Decree 219\/2006).\",\n        authDesignated: \"Authorization as Designated Wholesaler (if applicable).\",\n        specifyOtherAuth: \"Specify other authorization\",\n        authAttachments: \"Authorization documentation attachments\",\n        authAttachmentsHelp: \"Upload one or more documents certifying the selected authorizations (required if at least one authorization is selected)\",\n        declarationsTitle: \"Declarations\",\n        declarationsList: \"By submitting this form, the requester declares to have read and to fully accept the <a href='https:\/\/www.nmvoitalia.it\/wp-content\/uploads\/2026\/05\/NMVO_Italia_TC_NMVS.pdf' target='_blank' rel='noopener noreferrer'><strong>NMVO Italia Terms and Conditions<\/strong><\/a> regarding onboarding and use of the NMVS system and specifically the following clauses: Clause: 5.3 (DURATION, SUSPENSION OF SERVICE, TERMINATION), Clauses 12.1, 12.2, 12.3, 12.4, 12.5 (LIMITATION OF WARRANTY AND LIABILITY); Clause 15.2 (CHOICE OF LAW AND JURISDICTION).\",\n        toastSelectAuth: \"Select at least one authorization.\",\n        errAuthAttachment: \"Attachment required when at least one authorization is selected.\",\n        section7Legend: \"Section 7 \u2014 Summary and submit\",\n        summaryTitle: \"NMVS Onboarding Request Summary\",\n        generatedOn: \"Generated on\",\n        section1Data: \"1. Requester data\",\n        section2Request: \"2. Request overview\",\n        requestTypeLabelSummary: \"Request type:\",\n        section3Company: \"3. Company data\",\n        legalName: \"Legal name:\",\n        codiceSisLabel: \"Logistics site identifier code:\",\n        addSite: \"+ Add site\",\n        endUserTypeLabel: \"End-User type:\",\n        mainContactSummaryTitle: \"Main Client Contact\",\n        mcNameLabel: \"Full name:\",\n        mcEmailLabel: \"Email:\",\n        mcCompanyLabel: \"Company:\",\n        mcDivisionLabel: \"Division:\",\n        mcPhoneLabel: \"Phone:\",\n        address: \"Address\",\n        section4Integration: \"4. Technical integration\",\n        externalSystemPresent: \"External system present:\",\n        softwareCompany: \"Software company:\",\n        softwareNameLabel: \"Software name:\",\n        versionLabel: \"Version:\",\n        baselineTestingEvidence: \"Baseline testing evidence:\",\n        section5Users: \"5. End-User accounts\",\n        noUsersEntered: \"No users entered.\",\n        requestTypeCol: \"Request type:\",\n        userID: \"User ID:\",\n        firstLastNameCol: \"Full name:\",\n        emailCol: \"Email:\",\n        phoneCol: \"Phone:\",\n        companyCol: \"Company:\",\n        divisionCol: \"Logistics site identifier code:\",\n        roleCol: \"Role:\",\n        section6Terms: \"6. Terms and conditions\",\n        declarations: \"Declarations:\",\n        accepted: \"\u2713 Accepted\",\n        authArt100: \"Art. 100 authorization:\",\n        otherAuthorizations: \"Other authorizations:\",\n        section7Attachments: \"7. Attachments\",\n        integrationDocs: \"Technical integration documentation:\",\n        authDocs: \"Authorization documentation:\",\n        attachmentN: \"Attachment\",\n        pageOf: \"Page\",\n        pdfDownloaded: \"PDF downloaded successfully\",\n        excelDownloaded: \"Excel downloaded successfully\",\n        excelError: \"Error: Excel library not loaded. Reload the page.\",\n        excelGenError: \"Error generating Excel:\",\n        fileSelected: \"Selected files:\",\n        zipGenerating: \"Generating ZIP archive...\",\n        zipSuccess: \"ZIP archive downloaded successfully!\",\n        zipError: \"Error generating ZIP:\",\n        zipLibError: \"Error: JSZip library not loaded. Reload the page.\",\n        instructionTitle: \"Procedure completed successfully!\",\n        instructionSubtitle: \"The ZIP file containing all documentation has been downloaded.\",\n        instructionZipContents: \"ZIP file contents:\",\n        instructionFileJson: \"Completed form (JSON)\",\n        instructionFilePdf: \"Completed form (PDF)\",\n        instructionFileExcel: \"Completed form (Excel)\",\n        instructionFolderIntegration: \"Technical integration attachments\",\n        instructionFolderAuth: \"Authorization attachments\",\n        instructionEmailTitle: \"Next step\",\n        instructionEmailText: \"Send the downloaded ZIP file (with all contained files) to NMVO Italy at the following email address:\",\n        instructionEmailNote: \"Make sure to attach the complete ZIP file to the email. There is no need to extract files from the archive.\",\n        instructionBackBtn: \"Back to wizard\",\n        attachmentWarning: \"Warning: attachment files uploaded during form compilation are no longer available in memory (the page was reloaded). Only generated files (JSON, PDF, Excel) will be included. Reload the form and re-upload attachments if needed.\",\n        successTitle: \"Request submitted successfully!\",\n        successConfirmation: \"\u2713 Your request has been sent automatically via email.\",\n        close: \"Close\"\n      }\n    };\n\n    function t(key) {\n      \/\/ Prima prova con le traduzioni interne in base alla lingua corrente\n      if (translations[state.lang] && translations[state.lang][key]) {\n        return translations[state.lang][key];\n      }\n      \n      \/\/ Se non trovato nella lingua corrente e siamo in italiano, prova WordPress (TranslatePress)\n      if (state.lang === 'it' && typeof nmvo_ajax_object !== 'undefined' && nmvo_ajax_object.translations && nmvo_ajax_object.translations[key]) {\n        return nmvo_ajax_object.translations[key];\n      }\n      \n      \/\/ Fallback finale: italiano o la chiave stessa\n      return translations.it?.[key] ?? key;\n    }\n\n    function updateStaticText() {\n      document.title = t(\"pageTitle\");\n      const backBtn = $(\"#backBtn\");\n      if (backBtn) backBtn.textContent = t(\"back\");\n      \/\/ Il testo del pulsante \"Next\" viene aggiornato in render() in base allo step corrente\n      const resetLink = $(\"#resetLink\");\n      if (resetLink) resetLink.textContent = t(\"reset\");\n      const privacySummary = document.querySelector(\".card.subtle details summary\");\n      if (privacySummary) privacySummary.textContent = t(\"privacyNote\");\n      const privacyP = document.querySelector(\".card.subtle details .small\");\n      if (privacyP) privacyP.innerHTML = t(\"privacyText\");\n      document.documentElement.lang = state.lang === \"en\" ? \"en\" : \"it\";\n      \n      \/\/ Debug: mostra la lingua corrente nella console\n      console.log('Lingua corrente:', state.lang, '- Esempio traduzione \"next\":', t(\"next\"));\n    }\n\n    const steps = [\n      { id:\"s0\", titleKey:\"step0Title\", render:step0, validate:val0 },\n      { id:\"s1\", titleKey:\"step1Title\", render:step1, validate:val1 },\n      { \n        id:\"s2\", \n        titleKey:\"step2Title\", \n        render:step2, \n        validate:val2,\n        \/\/ Nascosto per \"update_client\" se noAnagraficaChanges \u00e8 true (non se allChanges)\n        hidden:() => {\n          if(state.data.request.requestFor===\"update_client\" && state.data.request.allChanges) return false;\n          if(state.data.request.requestFor===\"update_client\" && state.data.request.noAnagraficaChanges===true) return true;\n          return false;\n        }\n      },\n      { \n        id:\"s3\", \n        titleKey:\"step3Title\", \n        render:step3, \n        validate:val3,\n        \/\/ Nascosto per \"update_client\" se il checkbox \u00e8 selezionato (non se allChanges)\n        hidden:() => {\n          if(state.data.request.requestFor===\"update_client\" && state.data.request.allChanges) return false;\n          if(state.data.request.requestFor===\"update_client\") return state.data.request.hasIntegrationChanges;\n          return false;\n        }\n      },\n      { \n        id:\"s4\", \n        titleKey:\"step4Title\", \n        render:step4, \n        validate:val4,\n        \/\/ Nascosto per \"Aggiornamento dati client\": per questo tipo di richiesta non si gestiscono End-User\n        hidden:() => state.data.request.requestFor===\"update_client\"\n      },\n      { id:\"s5\", titleKey:\"step5Title\", render:step5, validate:val5 },\n      { id:\"s6\", titleKey:\"step6Title\", render:step6, validate:() => true }\n    ];\n\n    function initEventListeners(){\n      $(\"#backBtn\").addEventListener(\"click\", prev);\n      $(\"#nextBtn\").addEventListener(\"click\", next);\n      $(\"#resetLink\").addEventListener(\"click\", (e) => {\n        e.preventDefault();\n        if(confirm(t(\"confirmReset\"))){\n          localStorage.removeItem(STORAGE_KEY);\n          location.reload();\n        }\n      });\n    }\n\n    document.addEventListener(\"DOMContentLoaded\", () => {\n      initEventListeners();\n      updateStaticText();\n      render();\n      \n      \/\/ Listener per rilevare cambio lingua da TranslatePress\n      \/\/ TranslatePress cambia l'attributo lang dell'elemento html quando l'utente cambia lingua\n      const observer = new MutationObserver((mutations) => {\n        mutations.forEach((mutation) => {\n          if (mutation.type === 'attributes' && mutation.attributeName === 'lang') {\n            const newLang = document.documentElement.lang;\n            const detectedLang = newLang.startsWith('en') ? 'en' : 'it';\n            if (state.lang !== detectedLang) {\n              console.log('Cambio lingua rilevato da TranslatePress:', detectedLang);\n              state.lang = detectedLang;\n              localStorage.setItem(\"nmvo_onboarding_lang\", detectedLang);\n              updateStaticText();\n              render();\n            }\n          }\n        });\n      });\n      \n      observer.observe(document.documentElement, {\n        attributes: true,\n        attributeFilter: ['lang']\n      });\n    });\n\n    function visibleSteps(){ return steps.filter(s => !s.hidden || !s.hidden()); }\n\n    function getStepStatus(step, currentVisibleStepIndex){\n      \/\/ Se lo step \u00e8 nascosto\/non applicabile\n      if(step.hidden && step.hidden()) {\n        return 'not-applicable';\n      }\n      \n      \/\/ Trova l'indice dello step corrente negli step visibili\n      const vs = visibleSteps();\n      const stepVisibleIndex = vs.findIndex(s => s.id === step.id);\n      \n      if(stepVisibleIndex === -1) {\n        return 'not-applicable';\n      }\n      \n      if(stepVisibleIndex < currentVisibleStepIndex) {\n        return 'completed';\n      } else if(stepVisibleIndex === currentVisibleStepIndex) {\n        return 'current';\n      } else {\n        return 'pending';\n      }\n    }\n\n    function renderStepsList(){\n      const stepsListEl = $(\"#stepsList\");\n      if(!stepsListEl) return;\n      \n      const vs = visibleSteps();\n      const currentStep = vs[state.step];\n      if(!currentStep) return;\n      \n      stepsListEl.innerHTML = \"\";\n      \n      steps.forEach((step) => {\n        const status = getStepStatus(step, state.step);\n        const stepItem = document.createElement(\"div\");\n        stepItem.className = `step-item ${status}`;\n        stepItem.textContent = step.titleKey ? t(step.titleKey) : step.title;\n        stepsListEl.appendChild(stepItem);\n      });\n    }\n\n    function render(){\n      try {\n        const vs = visibleSteps();\n        const cur = vs[state.step] || vs[0];\n        if(!cur || !cur.render) {\n          console.error(\"Step non valido o funzione render mancante\", cur);\n          return;\n        }\n        \n        \/\/ Renderizza l'elenco degli step\n        renderStepsList();\n        \n        $(\"#stepTitle\").textContent = cur.titleKey ? t(cur.titleKey) : cur.title;\n        const remaining = vs.length - (state.step + 1);\n        $(\"#stepCount\").textContent = `${t(\"stepOf\")} ${state.step+1} ${t(\"of\")} ${vs.length}${remaining > 0 ? ` (${remaining} ${t(\"remaining\")})` : ''}`;\n        const stepAlertEl = $(\"#stepAlert\");\n        if(stepAlertEl){\n          if(cur.id === \"s4\"){\n            stepAlertEl.textContent = t(\"step4AdminNotice\");\n            stepAlertEl.style.display = \"block\";\n          } else {\n            stepAlertEl.style.display = \"none\";\n          }\n        }\n        $(\"#progressBar\").style.width = `${Math.round(((state.step+1)\/vs.length)*100)}%`;\n\n        const form = $(\"#wizardForm\");\n        if(!form) {\n          console.error(\"Form non trovato\");\n          return;\n        }\n        form.innerHTML = \"\";\n        cur.render(form);\n\n        $(\"#backBtn\").disabled = state.step===0;\n        $(\"#nextBtn\").textContent = (state.step===vs.length-1) ? t(\"finish\") : t(\"next\");\n\n        \/\/ Gestione reCAPTCHA: mostra solo all'ultimo step se abilitato\n        const isLastStep = state.step === vs.length - 1;\n        const recaptchaContainer = $(\"#recaptchaContainer\");\n        const recaptchaEnabled = typeof nmvo_ajax_object !== 'undefined' && nmvo_ajax_object.recaptcha_enabled;\n        \n        if (recaptchaContainer) {\n          if (isLastStep && recaptchaEnabled && nmvo_ajax_object.recaptcha_site_key) {\n            recaptchaContainer.style.display = 'block';\n            \/\/ Tenta di renderizzare il widget (se grecaptcha \u00e8 pronto)\n            renderRecaptchaIfNeeded();\n          } else {\n            recaptchaContainer.style.display = 'none';\n          }\n        }\n      } catch(e) {\n        console.error(\"Errore in render():\", e);\n      }\n    }\n\n    function next(){\n      const vs = visibleSteps();\n      const cur = vs[state.step];\n      if(cur.validate && !cur.validate()) return;\n      \n      \/\/ Validazione reCAPTCHA all'ultimo step (se abilitato)\n      const isLastStep = state.step === vs.length - 1;\n      const recaptchaEnabled = typeof nmvo_ajax_object !== 'undefined' && nmvo_ajax_object.recaptcha_enabled;\n      \n      if (isLastStep && recaptchaEnabled) {\n        console.log('Validazione reCAPTCHA:', {\n          recaptchaReady: recaptchaReady,\n          recaptchaWidgetId: recaptchaWidgetId,\n          grecaptchaAvailable: typeof grecaptcha !== 'undefined'\n        });\n        \n        const recaptchaResponse = typeof grecaptcha !== 'undefined' && recaptchaWidgetId !== null ? grecaptcha.getResponse(recaptchaWidgetId) : '';\n        const recaptchaError = $(\"#recaptchaError\");\n        \n        if (!recaptchaResponse || recaptchaResponse.length === 0) {\n          \/\/ reCAPTCHA non completato\n          console.warn('reCAPTCHA non completato o non caricato');\n          if (recaptchaError) {\n            recaptchaError.style.display = 'block';\n          }\n          \/\/ Scrolla verso il reCAPTCHA per mostrarlo all'utente\n          const recaptchaContainer = $(\"#recaptchaContainer\");\n          if (recaptchaContainer) {\n            recaptchaContainer.scrollIntoView({ behavior: 'smooth', block: 'center' });\n          }\n          return; \/\/ Blocca l'invio\n        } else {\n          \/\/ reCAPTCHA completato, nascondi l'errore\n          console.log('reCAPTCHA completato con successo');\n          if (recaptchaError) {\n            recaptchaError.style.display = 'none';\n          }\n        }\n      }\n      \n      saveDraft();\n      if(state.step < vs.length-1){ state.step++; render(); }\n      else finishWizard();\n    }\n    function prev(){ if(state.step>0){ state.step--; render(); } }\n\n    function field(id,label,{type=\"text\",value=\"\",required=false,col=6,placeholder=\"\",help=\"\",style=\"\"}={}){\n      const d=document.createElement(\"div\"); d.className=`col-${col}`;\n      d.innerHTML=`\n        <label for=\"${id}\">${label}${required?` <span class=\"small\">${esc(t(\"required\"))}<\/span>`:\"\"}<\/label>\n        <input id=\"${id}\" type=\"${type}\" value=\"${esc(value)}\" placeholder=\"${esc(placeholder)}\" ${style?`style=\"${style}\"`:\"\"}  ${required?\"required\":\"\"}\/>\n        ${help?`<div class=\"sectionhint\">${help}<\/div>`:\"\"}\n        <div class=\"err\" id=\"${id}__err\">${esc(t(\"errFieldRequired\"))}<\/div>`;\n      return d;\n    }\n    function textarea(id,label,{value=\"\",required=false,col=12,placeholder=\"\",help=\"\"}={}){\n      const d=document.createElement(\"div\"); d.className=`col-${col}`;\n      d.innerHTML=`\n        <label for=\"${id}\">${label}${required?` <span class=\"small\">${esc(t(\"required\"))}<\/span>`:\"\"}<\/label>\n        <textarea id=\"${id}\" ${required?\"required\":\"\"} placeholder=\"${esc(placeholder)}\">${esc(value)}<\/textarea>\n        ${help?`<div class=\"sectionhint\">${help}<\/div>`:\"\"}\n        <div class=\"err\" id=\"${id}__err\">${esc(t(\"errFieldRequired\"))}<\/div>`;\n      return d;\n    }\n    function select(id,label,options,{value=\"\",required=false,col=6,help=\"\"}={}){\n      const d=document.createElement(\"div\"); d.className=`col-${col}`;\n      d.innerHTML=`\n        <label for=\"${id}\">${label}${required?` <span class=\"small\">${esc(t(\"required\"))}<\/span>`:\"\"}<\/label>\n        <select id=\"${id}\" ${required?\"required\":\"\"}>\n          ${options.map(([v,optLabel])=>`<option value=\"${esc(v)}\" ${v===value?\"selected\":\"\"}>${esc(optLabel)}<\/option>`).join(\"\")}\n        <\/select>\n        ${help?`<div class=\"sectionhint\">${help}<\/div>`:\"\"}\n        <div class=\"err\" id=\"${id}__err\">${esc(t(\"errSelectRequired\"))}<\/div>`;\n      return d;\n    }\n    function fileInput(id,label,{required=false,col=12,help=\"\",accept=\"\"}={}){\n      const d=document.createElement(\"div\"); d.className=`col-${col}`;\n      d.innerHTML=`\n        <label for=\"${id}\">${label}${required?` <span class=\"small\">${esc(t(\"required\"))}<\/span>`:\"\"}<\/label>\n        <input id=\"${id}\" type=\"file\" multiple ${required?\"required\":\"\"} ${accept?`accept=\"${esc(accept)}\"`:\"\"}\/>\n        <div id=\"${id}__list\" style=\"margin-top:8px;\"><\/div>\n        ${help?`<div class=\"sectionhint\">${help}<\/div>`:\"\"}\n        <div class=\"err\" id=\"${id}__err\">${esc(t(\"errAttachmentRequired\"))}<\/div>`;\n      return d;\n    }\n    function checkbox(id,label,checked=false,help=\"\"){\n      const d=document.createElement(\"div\"); d.className=\"checkrow\";\n      d.innerHTML=`\n        <input type=\"checkbox\" id=\"${id}\" ${checked?\"checked\":\"\"}\/>\n        <div>\n          <label for=\"${id}\" style=\"margin:0;color:var(--text);font-size:13px;line-height:1.8;\">${label}<\/label>\n          ${help?`<div class=\"small\">${help}<\/div>`:\"\"}\n          <div class=\"err\" id=\"${id}__err\">${esc(t(\"errRequired\"))}<\/div>\n        <\/div>`;\n      return d;\n    }\n    function showErr(id,on,msg){\n      const e=document.getElementById(id+\"__err\");\n      if(!e) return;\n      if(msg) e.textContent=msg;\n      e.classList.toggle(\"show\",!!on);\n    }\n    function requireText(el){\n      const ok=!!el.value.trim(); showErr(el.id,!ok); return ok;\n    }\n    function requireEmail(el){\n      const v=el.value.trim(); const ok=!!v && \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/.test(v);\n      showErr(el.id,!ok); return ok;\n    }\n    function requireSelect(el){ const ok=!!el.value; showErr(el.id,!ok); return ok; }\n    \n    \/\/ Funzione per validare le estensioni dei file caricati\n    function validateFileExtensions(files) {\n      \/\/ Ottieni le estensioni permesse dalla configurazione\n      const allowedExtensions = (nmvo_ajax_object.allowed_extensions || '.pdf').toLowerCase();\n      \/\/ Rimuovi eventuali spazi per sicurezza\n      const allowedArray = allowedExtensions.replace(\/\\s+\/g, '').split(',').map(ext => ext.trim()).filter(ext => ext);\n      \n      const invalidFiles = [];\n      \n      for (let file of files) {\n        const fileName = file.name.toLowerCase();\n        const fileExt = '.' + fileName.split('.').pop();\n        \n        \/\/ Controlla se l'estensione del file \u00e8 nelle estensioni permesse\n        const isValid = allowedArray.some(allowedExt => fileExt === allowedExt);\n        \n        if (!isValid) {\n          invalidFiles.push(file.name);\n        }\n      }\n      \n      if (invalidFiles.length > 0) {\n        const allowedList = allowedArray.join(', ');\n        const invalidList = invalidFiles.join(', ');\n        alert(`\u274c Errore: I seguenti file hanno estensioni non permesse:\\n\\n${invalidList}\\n\\nEstensioni permesse: ${allowedList}`);\n        return false;\n      }\n      \n      return true;\n    }\n    function requireDate(el){ const ok=!!el.value; showErr(el.id,!ok); return ok; }\n    function requireCheck(id){\n      const el=document.getElementById(id); const ok=!!el && el.checked;\n      const e=document.getElementById(id+\"__err\"); if(e) e.classList.toggle(\"show\",!ok);\n      return ok;\n    }\n\n    \/\/ STEP 0 - Dati del richiedente\n    function step0(root){\n      \/\/ Assicurati che requestor esista\n      if(!state.data.requestor) {\n        state.data.requestor = { firstName:\"\", lastName:\"\", company:\"\", email:\"\", phone:\"\", phonePrefix:\"+39\" };\n      }\n      if(!state.data.requestor.phonePrefix) {\n        state.data.requestor.phonePrefix = \"+39\";\n      }\n      \n      const fs=document.createElement(\"fieldset\"); fs.innerHTML=`<legend>${t(\"section1Legend\")}<\/legend>`;\n      const hint=document.createElement(\"div\"); hint.className=\"sectionhint\";\n      hint.style.marginBottom=\"20px\";\n      hint.innerHTML=`<strong>${t(\"section1Hint\")}<\/strong>`;\n      fs.appendChild(hint);\n\n      const g=document.createElement(\"div\"); g.className=\"grid\";\n\n      g.appendChild(field(\"requestorFirstName\",t(\"firstName\"),{value:state.data.requestor.firstName||\"\",required:true,col:6,placeholder:t(\"placeholderFirst\")}));\n      g.appendChild(field(\"requestorLastName\",t(\"lastName\"),{value:state.data.requestor.lastName||\"\",required:true,col:6,placeholder:t(\"placeholderLast\")}));\n      g.appendChild(field(\"requestorCompany\",t(\"company\"),{value:state.data.requestor.company||\"\",required:true,col:12,placeholder:t(\"placeholderCompany\")}));\n      g.appendChild(field(\"requestorEmail\",t(\"email\"),{type:\"email\",value:state.data.requestor.email||\"\",required:true,col:6,placeholder:t(\"placeholderEmail\")}));\n      \n      \/\/ Campo telefono con selettore paese\n      const phoneCol = document.createElement(\"div\");\n      phoneCol.className = \"col-6\";\n      phoneCol.innerHTML = `\n        <label for=\"requestorPhone\">${t(\"phoneContact\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n        <div style=\"display:flex;gap:8px;align-items:stretch;\">\n          <select id=\"requestorPhonePrefix\" style=\"width:90px;flex-shrink:0;\" required>\n            <option value=\"+39\" ${state.data.requestor.phonePrefix===\"+39\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf9 +39<\/option>\n            <option value=\"+1\" ${state.data.requestor.phonePrefix===\"+1\"?\"selected\":\"\"}>\ud83c\uddfa\ud83c\uddf8 +1<\/option>\n            <option value=\"+33\" ${state.data.requestor.phonePrefix===\"+33\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddf7 +33<\/option>\n            <option value=\"+49\" ${state.data.requestor.phonePrefix===\"+49\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddea +49<\/option>\n            <option value=\"+44\" ${state.data.requestor.phonePrefix===\"+44\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\udde7 +44<\/option>\n            <option value=\"+34\" ${state.data.requestor.phonePrefix===\"+34\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\uddf8 +34<\/option>\n            <option value=\"+41\" ${state.data.requestor.phonePrefix===\"+41\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\udded +41<\/option>\n            <option value=\"+43\" ${state.data.requestor.phonePrefix===\"+43\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddf9 +43<\/option>\n            <option value=\"+32\" ${state.data.requestor.phonePrefix===\"+32\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddea +32<\/option>\n            <option value=\"+31\" ${state.data.requestor.phonePrefix===\"+31\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddf1 +31<\/option>\n            <option value=\"+351\" ${state.data.requestor.phonePrefix===\"+351\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf9 +351<\/option>\n            <option value=\"+30\" ${state.data.requestor.phonePrefix===\"+30\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf7 +30<\/option>\n            <option value=\"+46\" ${state.data.requestor.phonePrefix===\"+46\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddea +46<\/option>\n            <option value=\"+47\" ${state.data.requestor.phonePrefix===\"+47\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddf4 +47<\/option>\n            <option value=\"+45\" ${state.data.requestor.phonePrefix===\"+45\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddf0 +45<\/option>\n            <option value=\"+358\" ${state.data.requestor.phonePrefix===\"+358\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddee +358<\/option>\n            <option value=\"+353\" ${state.data.requestor.phonePrefix===\"+353\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddea +353<\/option>\n            <option value=\"+48\" ${state.data.requestor.phonePrefix===\"+48\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf1 +48<\/option>\n            <option value=\"+420\" ${state.data.requestor.phonePrefix===\"+420\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddff +420<\/option>\n            <option value=\"+36\" ${state.data.requestor.phonePrefix===\"+36\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddfa +36<\/option>\n            <option value=\"+40\" ${state.data.requestor.phonePrefix===\"+40\"?\"selected\":\"\"}>\ud83c\uddf7\ud83c\uddf4 +40<\/option>\n            <option value=\"+385\" ${state.data.requestor.phonePrefix===\"+385\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddf7 +385<\/option>\n            <option value=\"+386\" ${state.data.requestor.phonePrefix===\"+386\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddee +386<\/option>\n            <option value=\"+421\" ${state.data.requestor.phonePrefix===\"+421\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf0 +421<\/option>\n            <option value=\"+7\" ${state.data.requestor.phonePrefix===\"+7\"?\"selected\":\"\"}>\ud83c\uddf7\ud83c\uddfa +7<\/option>\n            <option value=\"+86\" ${state.data.requestor.phonePrefix===\"+86\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf3 +86<\/option>\n            <option value=\"+81\" ${state.data.requestor.phonePrefix===\"+81\"?\"selected\":\"\"}>\ud83c\uddef\ud83c\uddf5 +81<\/option>\n            <option value=\"+91\" ${state.data.requestor.phonePrefix===\"+91\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf3 +91<\/option>\n            <option value=\"+55\" ${state.data.requestor.phonePrefix===\"+55\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddf7 +55<\/option>\n            <option value=\"+52\" ${state.data.requestor.phonePrefix===\"+52\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddfd +52<\/option>\n            <option value=\"+61\" ${state.data.requestor.phonePrefix===\"+61\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddfa +61<\/option>\n            <option value=\"+27\" ${state.data.requestor.phonePrefix===\"+27\"?\"selected\":\"\"}>\ud83c\uddff\ud83c\udde6 +27<\/option>\n            <option value=\"+971\" ${state.data.requestor.phonePrefix===\"+971\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddea +971<\/option>\n            <option value=\"+966\" ${state.data.requestor.phonePrefix===\"+966\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\udde6 +966<\/option>\n            <option value=\"+90\" ${state.data.requestor.phonePrefix===\"+90\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf7 +90<\/option>\n            <option value=\"+972\" ${state.data.requestor.phonePrefix===\"+972\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf1 +972<\/option>\n            <option value=\"+20\" ${state.data.requestor.phonePrefix===\"+20\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\uddec +20<\/option>\n            <option value=\"+212\" ${state.data.requestor.phonePrefix===\"+212\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\udde6 +212<\/option>\n            <option value=\"+234\" ${state.data.requestor.phonePrefix===\"+234\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddec +234<\/option>\n            <option value=\"+254\" ${state.data.requestor.phonePrefix===\"+254\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddea +254<\/option>\n            <option value=\"+65\" ${state.data.requestor.phonePrefix===\"+65\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddec +65<\/option>\n            <option value=\"+60\" ${state.data.requestor.phonePrefix===\"+60\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddfe +60<\/option>\n            <option value=\"+66\" ${state.data.requestor.phonePrefix===\"+66\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\udded +66<\/option>\n            <option value=\"+84\" ${state.data.requestor.phonePrefix===\"+84\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddf3 +84<\/option>\n            <option value=\"+62\" ${state.data.requestor.phonePrefix===\"+62\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\udde9 +62<\/option>\n            <option value=\"+63\" ${state.data.requestor.phonePrefix===\"+63\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\udded +63<\/option>\n            <option value=\"+82\" ${state.data.requestor.phonePrefix===\"+82\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddf7 +82<\/option>\n            <option value=\"+886\" ${state.data.requestor.phonePrefix===\"+886\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddfc +886<\/option>\n            <option value=\"+852\" ${state.data.requestor.phonePrefix===\"+852\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddf0 +852<\/option>\n            <option value=\"+64\" ${state.data.requestor.phonePrefix===\"+64\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddff +64<\/option>\n            <option value=\"+54\" ${state.data.requestor.phonePrefix===\"+54\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddf7 +54<\/option>\n            <option value=\"+56\" ${state.data.requestor.phonePrefix===\"+56\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf1 +56<\/option>\n            <option value=\"+57\" ${state.data.requestor.phonePrefix===\"+57\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf4 +57<\/option>\n            <option value=\"+51\" ${state.data.requestor.phonePrefix===\"+51\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddea +51<\/option>\n            <option value=\"+58\" ${state.data.requestor.phonePrefix===\"+58\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddea +58<\/option>\n            <option value=\"+593\" ${state.data.requestor.phonePrefix===\"+593\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\udde8 +593<\/option>\n            <option value=\"+595\" ${state.data.requestor.phonePrefix===\"+595\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddfe +595<\/option>\n            <option value=\"+598\" ${state.data.requestor.phonePrefix===\"+598\"?\"selected\":\"\"}>\ud83c\uddfa\ud83c\uddfe +598<\/option>\n            <option value=\"+506\" ${state.data.requestor.phonePrefix===\"+506\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf7 +506<\/option>\n            <option value=\"+507\" ${state.data.requestor.phonePrefix===\"+507\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\udde6 +507<\/option>\n            <option value=\"+502\" ${state.data.requestor.phonePrefix===\"+502\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf9 +502<\/option>\n            <option value=\"+504\" ${state.data.requestor.phonePrefix===\"+504\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddf3 +504<\/option>\n            <option value=\"+505\" ${state.data.requestor.phonePrefix===\"+505\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddee +505<\/option>\n            <option value=\"+503\" ${state.data.requestor.phonePrefix===\"+503\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddfb +503<\/option>\n            <option value=\"+501\" ${state.data.requestor.phonePrefix===\"+501\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddff +501<\/option>\n            <option value=\"+592\" ${state.data.requestor.phonePrefix===\"+592\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddfe +592<\/option>\n            <option value=\"+597\" ${state.data.requestor.phonePrefix===\"+597\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf7 +597<\/option>\n            <option value=\"+594\" ${state.data.requestor.phonePrefix===\"+594\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddeb +594<\/option>\n            <option value=\"+596\" ${state.data.requestor.phonePrefix===\"+596\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf6 +596<\/option>\n            <option value=\"+590\" ${state.data.requestor.phonePrefix===\"+590\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf5 +590<\/option>\n            <option value=\"+508\" ${state.data.requestor.phonePrefix===\"+508\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf2 +508<\/option>\n            <option value=\"+687\" ${state.data.requestor.phonePrefix===\"+687\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\udde8 +687<\/option>\n            <option value=\"+689\" ${state.data.requestor.phonePrefix===\"+689\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddeb +689<\/option>\n            <option value=\"+681\" ${state.data.requestor.phonePrefix===\"+681\"?\"selected\":\"\"}>\ud83c\uddfc\ud83c\uddeb +681<\/option>\n            <option value=\"+676\" ${state.data.requestor.phonePrefix===\"+676\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf4 +676<\/option>\n            <option value=\"+678\" ${state.data.requestor.phonePrefix===\"+678\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddfa +678<\/option>\n            <option value=\"+679\" ${state.data.requestor.phonePrefix===\"+679\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddef +679<\/option>\n            <option value=\"+685\" ${state.data.requestor.phonePrefix===\"+685\"?\"selected\":\"\"}>\ud83c\uddfc\ud83c\uddf8 +685<\/option>\n            <option value=\"+677\" ${state.data.requestor.phonePrefix===\"+677\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\udde7 +677<\/option>\n            <option value=\"+675\" ${state.data.requestor.phonePrefix===\"+675\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddec +675<\/option>\n            <option value=\"+691\" ${state.data.requestor.phonePrefix===\"+691\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddf2 +691<\/option>\n            <option value=\"+692\" ${state.data.requestor.phonePrefix===\"+692\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\udded +692<\/option>\n            <option value=\"+680\" ${state.data.requestor.phonePrefix===\"+680\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddfc +680<\/option>\n            <option value=\"+683\" ${state.data.requestor.phonePrefix===\"+683\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddfa +683<\/option>\n            <option value=\"+682\" ${state.data.requestor.phonePrefix===\"+682\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf0 +682<\/option>\n            <option value=\"+684\" ${state.data.requestor.phonePrefix===\"+684\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddf8 +684<\/option>\n            <option value=\"+686\" ${state.data.requestor.phonePrefix===\"+686\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddee +686<\/option>\n            <option value=\"+688\" ${state.data.requestor.phonePrefix===\"+688\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddfb +688<\/option>\n            <option value=\"+690\" ${state.data.requestor.phonePrefix===\"+690\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf0 +690<\/option>\n            <option value=\"+850\" ${state.data.requestor.phonePrefix===\"+850\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddf5 +850<\/option>\n            <option value=\"+93\" ${state.data.requestor.phonePrefix===\"+93\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddeb +93<\/option>\n            <option value=\"+355\" ${state.data.requestor.phonePrefix===\"+355\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddf1 +355<\/option>\n            <option value=\"+213\" ${state.data.requestor.phonePrefix===\"+213\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddff +213<\/option>\n            <option value=\"+376\" ${state.data.requestor.phonePrefix===\"+376\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\udde9 +376<\/option>\n            <option value=\"+244\" ${state.data.requestor.phonePrefix===\"+244\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddf4 +244<\/option>\n            <option value=\"+1268\" ${state.data.requestor.phonePrefix===\"+1268\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddec +1268<\/option>\n            <option value=\"+54\" ${state.data.requestor.phonePrefix===\"+54\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddf7 +54<\/option>\n            <option value=\"+374\" ${state.data.requestor.phonePrefix===\"+374\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddf2 +374<\/option>\n            <option value=\"+297\" ${state.data.requestor.phonePrefix===\"+297\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddfc +297<\/option>\n            <option value=\"+61\" ${state.data.requestor.phonePrefix===\"+61\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddfa +61<\/option>\n            <option value=\"+994\" ${state.data.requestor.phonePrefix===\"+994\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddff +994<\/option>\n            <option value=\"+1242\" ${state.data.requestor.phonePrefix===\"+1242\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddf8 +1242<\/option>\n            <option value=\"+973\" ${state.data.requestor.phonePrefix===\"+973\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\udded +973<\/option>\n            <option value=\"+880\" ${state.data.requestor.phonePrefix===\"+880\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\udde9 +880<\/option>\n            <option value=\"+1246\" ${state.data.requestor.phonePrefix===\"+1246\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\udde7 +1246<\/option>\n            <option value=\"+375\" ${state.data.requestor.phonePrefix===\"+375\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddfe +375<\/option>\n            <option value=\"+501\" ${state.data.requestor.phonePrefix===\"+501\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddff +501<\/option>\n            <option value=\"+229\" ${state.data.requestor.phonePrefix===\"+229\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddef +229<\/option>\n            <option value=\"+1441\" ${state.data.requestor.phonePrefix===\"+1441\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddf2 +1441<\/option>\n            <option value=\"+975\" ${state.data.requestor.phonePrefix===\"+975\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddf9 +975<\/option>\n            <option value=\"+591\" ${state.data.requestor.phonePrefix===\"+591\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddf4 +591<\/option>\n            <option value=\"+387\" ${state.data.requestor.phonePrefix===\"+387\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\udde6 +387<\/option>\n            <option value=\"+267\" ${state.data.requestor.phonePrefix===\"+267\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddfc +267<\/option>\n            <option value=\"+55\" ${state.data.requestor.phonePrefix===\"+55\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddf7 +55<\/option>\n            <option value=\"+246\" ${state.data.requestor.phonePrefix===\"+246\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf4 +246<\/option>\n            <option value=\"+1284\" ${state.data.requestor.phonePrefix===\"+1284\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddec +1284<\/option>\n            <option value=\"+673\" ${state.data.requestor.phonePrefix===\"+673\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddf3 +673<\/option>\n            <option value=\"+359\" ${state.data.requestor.phonePrefix===\"+359\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddec +359<\/option>\n            <option value=\"+226\" ${state.data.requestor.phonePrefix===\"+226\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddeb +226<\/option>\n            <option value=\"+257\" ${state.data.requestor.phonePrefix===\"+257\"?\"selected\":\"\"}>\ud83c\udde7\ud83c\uddee +257<\/option>\n            <option value=\"+855\" ${state.data.requestor.phonePrefix===\"+855\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\udded +855<\/option>\n            <option value=\"+237\" ${state.data.requestor.phonePrefix===\"+237\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf2 +237<\/option>\n            <option value=\"+1\" ${state.data.requestor.phonePrefix===\"+1\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\udde6 +1<\/option>\n            <option value=\"+238\" ${state.data.requestor.phonePrefix===\"+238\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddfb +238<\/option>\n            <option value=\"+1345\" ${state.data.requestor.phonePrefix===\"+1345\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddfe +1345<\/option>\n            <option value=\"+236\" ${state.data.requestor.phonePrefix===\"+236\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddeb +236<\/option>\n            <option value=\"+235\" ${state.data.requestor.phonePrefix===\"+235\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\udde9 +235<\/option>\n            <option value=\"+56\" ${state.data.requestor.phonePrefix===\"+56\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf1 +56<\/option>\n            <option value=\"+86\" ${state.data.requestor.phonePrefix===\"+86\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf3 +86<\/option>\n            <option value=\"+61\" ${state.data.requestor.phonePrefix===\"+61\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddfd +61<\/option>\n            <option value=\"+61\" ${state.data.requestor.phonePrefix===\"+61\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\udde8 +61<\/option>\n            <option value=\"+57\" ${state.data.requestor.phonePrefix===\"+57\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf4 +57<\/option>\n            <option value=\"+269\" ${state.data.requestor.phonePrefix===\"+269\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddf2 +269<\/option>\n            <option value=\"+242\" ${state.data.requestor.phonePrefix===\"+242\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddec +242<\/option>\n            <option value=\"+243\" ${state.data.requestor.phonePrefix===\"+243\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\udde9 +243<\/option>\n            <option value=\"+682\" ${state.data.requestor.phonePrefix===\"+682\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf0 +682<\/option>\n            <option value=\"+506\" ${state.data.requestor.phonePrefix===\"+506\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddf7 +506<\/option>\n            <option value=\"+225\" ${state.data.requestor.phonePrefix===\"+225\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddee +225<\/option>\n            <option value=\"+385\" ${state.data.requestor.phonePrefix===\"+385\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddf7 +385<\/option>\n            <option value=\"+53\" ${state.data.requestor.phonePrefix===\"+53\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddfa +53<\/option>\n            <option value=\"+357\" ${state.data.requestor.phonePrefix===\"+357\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddfe +357<\/option>\n            <option value=\"+420\" ${state.data.requestor.phonePrefix===\"+420\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\uddff +420<\/option>\n            <option value=\"+45\" ${state.data.requestor.phonePrefix===\"+45\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddf0 +45<\/option>\n            <option value=\"+253\" ${state.data.requestor.phonePrefix===\"+253\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddef +253<\/option>\n            <option value=\"+1767\" ${state.data.requestor.phonePrefix===\"+1767\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddf2 +1767<\/option>\n            <option value=\"+1809\" ${state.data.requestor.phonePrefix===\"+1809\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddf4 +1809<\/option>\n            <option value=\"+593\" ${state.data.requestor.phonePrefix===\"+593\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\udde8 +593<\/option>\n            <option value=\"+20\" ${state.data.requestor.phonePrefix===\"+20\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\uddec +20<\/option>\n            <option value=\"+503\" ${state.data.requestor.phonePrefix===\"+503\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddfb +503<\/option>\n            <option value=\"+240\" ${state.data.requestor.phonePrefix===\"+240\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf6 +240<\/option>\n            <option value=\"+291\" ${state.data.requestor.phonePrefix===\"+291\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\uddf7 +291<\/option>\n            <option value=\"+372\" ${state.data.requestor.phonePrefix===\"+372\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\uddea +372<\/option>\n            <option value=\"+251\" ${state.data.requestor.phonePrefix===\"+251\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\uddf9 +251<\/option>\n            <option value=\"+500\" ${state.data.requestor.phonePrefix===\"+500\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddf0 +500<\/option>\n            <option value=\"+298\" ${state.data.requestor.phonePrefix===\"+298\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddf4 +298<\/option>\n            <option value=\"+679\" ${state.data.requestor.phonePrefix===\"+679\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddef +679<\/option>\n            <option value=\"+358\" ${state.data.requestor.phonePrefix===\"+358\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddee +358<\/option>\n            <option value=\"+33\" ${state.data.requestor.phonePrefix===\"+33\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddf7 +33<\/option>\n            <option value=\"+594\" ${state.data.requestor.phonePrefix===\"+594\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddeb +594<\/option>\n            <option value=\"+689\" ${state.data.requestor.phonePrefix===\"+689\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddeb +689<\/option>\n            <option value=\"+241\" ${state.data.requestor.phonePrefix===\"+241\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\udde6 +241<\/option>\n            <option value=\"+220\" ${state.data.requestor.phonePrefix===\"+220\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf2 +220<\/option>\n            <option value=\"+995\" ${state.data.requestor.phonePrefix===\"+995\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddea +995<\/option>\n            <option value=\"+49\" ${state.data.requestor.phonePrefix===\"+49\"?\"selected\":\"\"}>\ud83c\udde9\ud83c\uddea +49<\/option>\n            <option value=\"+233\" ${state.data.requestor.phonePrefix===\"+233\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\udded +233<\/option>\n            <option value=\"+350\" ${state.data.requestor.phonePrefix===\"+350\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddee +350<\/option>\n            <option value=\"+30\" ${state.data.requestor.phonePrefix===\"+30\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf7 +30<\/option>\n            <option value=\"+299\" ${state.data.requestor.phonePrefix===\"+299\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf1 +299<\/option>\n            <option value=\"+1473\" ${state.data.requestor.phonePrefix===\"+1473\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\udde9 +1473<\/option>\n            <option value=\"+590\" ${state.data.requestor.phonePrefix===\"+590\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf5 +590<\/option>\n            <option value=\"+1671\" ${state.data.requestor.phonePrefix===\"+1671\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddfa +1671<\/option>\n            <option value=\"+502\" ${state.data.requestor.phonePrefix===\"+502\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf9 +502<\/option>\n            <option value=\"+44\" ${state.data.requestor.phonePrefix===\"+44\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddec +44<\/option>\n            <option value=\"+224\" ${state.data.requestor.phonePrefix===\"+224\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddf3 +224<\/option>\n            <option value=\"+245\" ${state.data.requestor.phonePrefix===\"+245\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddfc +245<\/option>\n            <option value=\"+592\" ${state.data.requestor.phonePrefix===\"+592\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\uddfe +592<\/option>\n            <option value=\"+509\" ${state.data.requestor.phonePrefix===\"+509\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddf9 +509<\/option>\n            <option value=\"+39\" ${state.data.requestor.phonePrefix===\"+39\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\udde6 +39<\/option>\n            <option value=\"+504\" ${state.data.requestor.phonePrefix===\"+504\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddf3 +504<\/option>\n            <option value=\"+852\" ${state.data.requestor.phonePrefix===\"+852\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddf0 +852<\/option>\n            <option value=\"+36\" ${state.data.requestor.phonePrefix===\"+36\"?\"selected\":\"\"}>\ud83c\udded\ud83c\uddfa +36<\/option>\n            <option value=\"+354\" ${state.data.requestor.phonePrefix===\"+354\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf8 +354<\/option>\n            <option value=\"+91\" ${state.data.requestor.phonePrefix===\"+91\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf3 +91<\/option>\n            <option value=\"+62\" ${state.data.requestor.phonePrefix===\"+62\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\udde9 +62<\/option>\n            <option value=\"+98\" ${state.data.requestor.phonePrefix===\"+98\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf7 +98<\/option>\n            <option value=\"+964\" ${state.data.requestor.phonePrefix===\"+964\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf6 +964<\/option>\n            <option value=\"+353\" ${state.data.requestor.phonePrefix===\"+353\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddea +353<\/option>\n            <option value=\"+972\" ${state.data.requestor.phonePrefix===\"+972\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf1 +972<\/option>\n            <option value=\"+39\" ${state.data.requestor.phonePrefix===\"+39\"?\"selected\":\"\"}>\ud83c\uddee\ud83c\uddf9 +39<\/option>\n            <option value=\"+1876\" ${state.data.requestor.phonePrefix===\"+1876\"?\"selected\":\"\"}>\ud83c\uddef\ud83c\uddf2 +1876<\/option>\n            <option value=\"+81\" ${state.data.requestor.phonePrefix===\"+81\"?\"selected\":\"\"}>\ud83c\uddef\ud83c\uddf5 +81<\/option>\n            <option value=\"+44\" ${state.data.requestor.phonePrefix===\"+44\"?\"selected\":\"\"}>\ud83c\uddef\ud83c\uddea +44<\/option>\n            <option value=\"+962\" ${state.data.requestor.phonePrefix===\"+962\"?\"selected\":\"\"}>\ud83c\uddef\ud83c\uddf4 +962<\/option>\n            <option value=\"+7\" ${state.data.requestor.phonePrefix===\"+7\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddff +7<\/option>\n            <option value=\"+254\" ${state.data.requestor.phonePrefix===\"+254\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddea +254<\/option>\n            <option value=\"+686\" ${state.data.requestor.phonePrefix===\"+686\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddee +686<\/option>\n            <option value=\"+965\" ${state.data.requestor.phonePrefix===\"+965\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddfc +965<\/option>\n            <option value=\"+996\" ${state.data.requestor.phonePrefix===\"+996\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddec +996<\/option>\n            <option value=\"+856\" ${state.data.requestor.phonePrefix===\"+856\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\udde6 +856<\/option>\n            <option value=\"+371\" ${state.data.requestor.phonePrefix===\"+371\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddfb +371<\/option>\n            <option value=\"+961\" ${state.data.requestor.phonePrefix===\"+961\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\udde7 +961<\/option>\n            <option value=\"+266\" ${state.data.requestor.phonePrefix===\"+266\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddf8 +266<\/option>\n            <option value=\"+231\" ${state.data.requestor.phonePrefix===\"+231\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddf7 +231<\/option>\n            <option value=\"+218\" ${state.data.requestor.phonePrefix===\"+218\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddfe +218<\/option>\n            <option value=\"+423\" ${state.data.requestor.phonePrefix===\"+423\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddee +423<\/option>\n            <option value=\"+370\" ${state.data.requestor.phonePrefix===\"+370\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddf9 +370<\/option>\n            <option value=\"+352\" ${state.data.requestor.phonePrefix===\"+352\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddfa +352<\/option>\n            <option value=\"+853\" ${state.data.requestor.phonePrefix===\"+853\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf4 +853<\/option>\n            <option value=\"+389\" ${state.data.requestor.phonePrefix===\"+389\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf0 +389<\/option>\n            <option value=\"+261\" ${state.data.requestor.phonePrefix===\"+261\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddec +261<\/option>\n            <option value=\"+265\" ${state.data.requestor.phonePrefix===\"+265\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddfc +265<\/option>\n            <option value=\"+60\" ${state.data.requestor.phonePrefix===\"+60\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddfe +60<\/option>\n            <option value=\"+960\" ${state.data.requestor.phonePrefix===\"+960\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddfb +960<\/option>\n            <option value=\"+223\" ${state.data.requestor.phonePrefix===\"+223\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf1 +223<\/option>\n            <option value=\"+356\" ${state.data.requestor.phonePrefix===\"+356\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf9 +356<\/option>\n            <option value=\"+692\" ${state.data.requestor.phonePrefix===\"+692\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\udded +692<\/option>\n            <option value=\"+596\" ${state.data.requestor.phonePrefix===\"+596\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf6 +596<\/option>\n            <option value=\"+222\" ${state.data.requestor.phonePrefix===\"+222\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf7 +222<\/option>\n            <option value=\"+230\" ${state.data.requestor.phonePrefix===\"+230\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddfa +230<\/option>\n            <option value=\"+262\" ${state.data.requestor.phonePrefix===\"+262\"?\"selected\":\"\"}>\ud83c\uddfe\ud83c\uddf9 +262<\/option>\n            <option value=\"+52\" ${state.data.requestor.phonePrefix===\"+52\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddfd +52<\/option>\n            <option value=\"+691\" ${state.data.requestor.phonePrefix===\"+691\"?\"selected\":\"\"}>\ud83c\uddeb\ud83c\uddf2 +691<\/option>\n            <option value=\"+373\" ${state.data.requestor.phonePrefix===\"+373\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\udde9 +373<\/option>\n            <option value=\"+377\" ${state.data.requestor.phonePrefix===\"+377\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\udde8 +377<\/option>\n            <option value=\"+382\" ${state.data.requestor.phonePrefix===\"+382\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddea +382<\/option>\n            <option value=\"+212\" ${state.data.requestor.phonePrefix===\"+212\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\udde6 +212<\/option>\n            <option value=\"+258\" ${state.data.requestor.phonePrefix===\"+258\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddff +258<\/option>\n            <option value=\"+95\" ${state.data.requestor.phonePrefix===\"+95\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf2 +95<\/option>\n            <option value=\"+264\" ${state.data.requestor.phonePrefix===\"+264\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\udde6 +264<\/option>\n            <option value=\"+674\" ${state.data.requestor.phonePrefix===\"+674\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddf7 +674<\/option>\n            <option value=\"+977\" ${state.data.requestor.phonePrefix===\"+977\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddf5 +977<\/option>\n            <option value=\"+31\" ${state.data.requestor.phonePrefix===\"+31\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddf1 +31<\/option>\n            <option value=\"+687\" ${state.data.requestor.phonePrefix===\"+687\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\udde8 +687<\/option>\n            <option value=\"+64\" ${state.data.requestor.phonePrefix===\"+64\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddff +64<\/option>\n            <option value=\"+505\" ${state.data.requestor.phonePrefix===\"+505\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddee +505<\/option>\n            <option value=\"+227\" ${state.data.requestor.phonePrefix===\"+227\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddea +227<\/option>\n            <option value=\"+234\" ${state.data.requestor.phonePrefix===\"+234\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddec +234<\/option>\n            <option value=\"+683\" ${state.data.requestor.phonePrefix===\"+683\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddfa +683<\/option>\n            <option value=\"+850\" ${state.data.requestor.phonePrefix===\"+850\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddf5 +850<\/option>\n            <option value=\"+1670\" ${state.data.requestor.phonePrefix===\"+1670\"?\"selected\":\"\"}>\ud83c\uddf2\ud83c\uddf5 +1670<\/option>\n            <option value=\"+47\" ${state.data.requestor.phonePrefix===\"+47\"?\"selected\":\"\"}>\ud83c\uddf3\ud83c\uddf4 +47<\/option>\n            <option value=\"+968\" ${state.data.requestor.phonePrefix===\"+968\"?\"selected\":\"\"}>\ud83c\uddf4\ud83c\uddf2 +968<\/option>\n            <option value=\"+92\" ${state.data.requestor.phonePrefix===\"+92\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf0 +92<\/option>\n            <option value=\"+680\" ${state.data.requestor.phonePrefix===\"+680\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddfc +680<\/option>\n            <option value=\"+970\" ${state.data.requestor.phonePrefix===\"+970\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf8 +970<\/option>\n            <option value=\"+507\" ${state.data.requestor.phonePrefix===\"+507\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\udde6 +507<\/option>\n            <option value=\"+675\" ${state.data.requestor.phonePrefix===\"+675\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddec +675<\/option>\n            <option value=\"+595\" ${state.data.requestor.phonePrefix===\"+595\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddfe +595<\/option>\n            <option value=\"+51\" ${state.data.requestor.phonePrefix===\"+51\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddea +51<\/option>\n            <option value=\"+63\" ${state.data.requestor.phonePrefix===\"+63\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\udded +63<\/option>\n            <option value=\"+48\" ${state.data.requestor.phonePrefix===\"+48\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf1 +48<\/option>\n            <option value=\"+351\" ${state.data.requestor.phonePrefix===\"+351\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf9 +351<\/option>\n            <option value=\"+1787\" ${state.data.requestor.phonePrefix===\"+1787\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf7 +1787<\/option>\n            <option value=\"+974\" ${state.data.requestor.phonePrefix===\"+974\"?\"selected\":\"\"}>\ud83c\uddf6\ud83c\udde6 +974<\/option>\n            <option value=\"+262\" ${state.data.requestor.phonePrefix===\"+262\"?\"selected\":\"\"}>\ud83c\uddf7\ud83c\uddea +262<\/option>\n            <option value=\"+40\" ${state.data.requestor.phonePrefix===\"+40\"?\"selected\":\"\"}>\ud83c\uddf7\ud83c\uddf4 +40<\/option>\n            <option value=\"+7\" ${state.data.requestor.phonePrefix===\"+7\"?\"selected\":\"\"}>\ud83c\uddf7\ud83c\uddfa +7<\/option>\n            <option value=\"+250\" ${state.data.requestor.phonePrefix===\"+250\"?\"selected\":\"\"}>\ud83c\uddf7\ud83c\uddfc +250<\/option>\n            <option value=\"+290\" ${state.data.requestor.phonePrefix===\"+290\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\udded +290<\/option>\n            <option value=\"+1869\" ${state.data.requestor.phonePrefix===\"+1869\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddf3 +1869<\/option>\n            <option value=\"+1758\" ${state.data.requestor.phonePrefix===\"+1758\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\udde8 +1758<\/option>\n            <option value=\"+508\" ${state.data.requestor.phonePrefix===\"+508\"?\"selected\":\"\"}>\ud83c\uddf5\ud83c\uddf2 +508<\/option>\n            <option value=\"+1784\" ${state.data.requestor.phonePrefix===\"+1784\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\udde8 +1784<\/option>\n            <option value=\"+685\" ${state.data.requestor.phonePrefix===\"+685\"?\"selected\":\"\"}>\ud83c\uddfc\ud83c\uddf8 +685<\/option>\n            <option value=\"+378\" ${state.data.requestor.phonePrefix===\"+378\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf2 +378<\/option>\n            <option value=\"+239\" ${state.data.requestor.phonePrefix===\"+239\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf9 +239<\/option>\n            <option value=\"+966\" ${state.data.requestor.phonePrefix===\"+966\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\udde6 +966<\/option>\n            <option value=\"+221\" ${state.data.requestor.phonePrefix===\"+221\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf3 +221<\/option>\n            <option value=\"+381\" ${state.data.requestor.phonePrefix===\"+381\"?\"selected\":\"\"}>\ud83c\uddf7\ud83c\uddf8 +381<\/option>\n            <option value=\"+248\" ${state.data.requestor.phonePrefix===\"+248\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\udde8 +248<\/option>\n            <option value=\"+232\" ${state.data.requestor.phonePrefix===\"+232\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf1 +232<\/option>\n            <option value=\"+65\" ${state.data.requestor.phonePrefix===\"+65\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddec +65<\/option>\n            <option value=\"+421\" ${state.data.requestor.phonePrefix===\"+421\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf0 +421<\/option>\n            <option value=\"+386\" ${state.data.requestor.phonePrefix===\"+386\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddee +386<\/option>\n            <option value=\"+677\" ${state.data.requestor.phonePrefix===\"+677\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\udde7 +677<\/option>\n            <option value=\"+252\" ${state.data.requestor.phonePrefix===\"+252\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf4 +252<\/option>\n            <option value=\"+27\" ${state.data.requestor.phonePrefix===\"+27\"?\"selected\":\"\"}>\ud83c\uddff\ud83c\udde6 +27<\/option>\n            <option value=\"+82\" ${state.data.requestor.phonePrefix===\"+82\"?\"selected\":\"\"}>\ud83c\uddf0\ud83c\uddf7 +82<\/option>\n            <option value=\"+211\" ${state.data.requestor.phonePrefix===\"+211\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf8 +211<\/option>\n            <option value=\"+34\" ${state.data.requestor.phonePrefix===\"+34\"?\"selected\":\"\"}>\ud83c\uddea\ud83c\uddf8 +34<\/option>\n            <option value=\"+94\" ${state.data.requestor.phonePrefix===\"+94\"?\"selected\":\"\"}>\ud83c\uddf1\ud83c\uddf0 +94<\/option>\n            <option value=\"+249\" ${state.data.requestor.phonePrefix===\"+249\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\udde9 +249<\/option>\n            <option value=\"+597\" ${state.data.requestor.phonePrefix===\"+597\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddf7 +597<\/option>\n            <option value=\"+47\" ${state.data.requestor.phonePrefix===\"+47\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddef +47<\/option>\n            <option value=\"+268\" ${state.data.requestor.phonePrefix===\"+268\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddff +268<\/option>\n            <option value=\"+46\" ${state.data.requestor.phonePrefix===\"+46\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddea +46<\/option>\n            <option value=\"+41\" ${state.data.requestor.phonePrefix===\"+41\"?\"selected\":\"\"}>\ud83c\udde8\ud83c\udded +41<\/option>\n            <option value=\"+963\" ${state.data.requestor.phonePrefix===\"+963\"?\"selected\":\"\"}>\ud83c\uddf8\ud83c\uddfe +963<\/option>\n            <option value=\"+886\" ${state.data.requestor.phonePrefix===\"+886\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddfc +886<\/option>\n            <option value=\"+992\" ${state.data.requestor.phonePrefix===\"+992\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddef +992<\/option>\n            <option value=\"+255\" ${state.data.requestor.phonePrefix===\"+255\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddff +255<\/option>\n            <option value=\"+66\" ${state.data.requestor.phonePrefix===\"+66\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\udded +66<\/option>\n            <option value=\"+670\" ${state.data.requestor.phonePrefix===\"+670\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf1 +670<\/option>\n            <option value=\"+228\" ${state.data.requestor.phonePrefix===\"+228\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddec +228<\/option>\n            <option value=\"+690\" ${state.data.requestor.phonePrefix===\"+690\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf0 +690<\/option>\n            <option value=\"+676\" ${state.data.requestor.phonePrefix===\"+676\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf4 +676<\/option>\n            <option value=\"+1868\" ${state.data.requestor.phonePrefix===\"+1868\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf9 +1868<\/option>\n            <option value=\"+216\" ${state.data.requestor.phonePrefix===\"+216\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf3 +216<\/option>\n            <option value=\"+90\" ${state.data.requestor.phonePrefix===\"+90\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf7 +90<\/option>\n            <option value=\"+993\" ${state.data.requestor.phonePrefix===\"+993\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddf2 +993<\/option>\n            <option value=\"+1649\" ${state.data.requestor.phonePrefix===\"+1649\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\udde8 +1649<\/option>\n            <option value=\"+688\" ${state.data.requestor.phonePrefix===\"+688\"?\"selected\":\"\"}>\ud83c\uddf9\ud83c\uddfb +688<\/option>\n            <option value=\"+256\" ${state.data.requestor.phonePrefix===\"+256\"?\"selected\":\"\"}>\ud83c\uddfa\ud83c\uddec +256<\/option>\n            <option value=\"+380\" ${state.data.requestor.phonePrefix===\"+380\"?\"selected\":\"\"}>\ud83c\uddfa\ud83c\udde6 +380<\/option>\n            <option value=\"+971\" ${state.data.requestor.phonePrefix===\"+971\"?\"selected\":\"\"}>\ud83c\udde6\ud83c\uddea +971<\/option>\n            <option value=\"+44\" ${state.data.requestor.phonePrefix===\"+44\"?\"selected\":\"\"}>\ud83c\uddec\ud83c\udde7 +44<\/option>\n            <option value=\"+1\" ${state.data.requestor.phonePrefix===\"+1\"?\"selected\":\"\"}>\ud83c\uddfa\ud83c\uddf8 +1<\/option>\n            <option value=\"+598\" ${state.data.requestor.phonePrefix===\"+598\"?\"selected\":\"\"}>\ud83c\uddfa\ud83c\uddfe +598<\/option>\n            <option value=\"+998\" ${state.data.requestor.phonePrefix===\"+998\"?\"selected\":\"\"}>\ud83c\uddfa\ud83c\uddff +998<\/option>\n            <option value=\"+678\" ${state.data.requestor.phonePrefix===\"+678\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddfa +678<\/option>\n            <option value=\"+58\" ${state.data.requestor.phonePrefix===\"+58\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddea +58<\/option>\n            <option value=\"+84\" ${state.data.requestor.phonePrefix===\"+84\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddf3 +84<\/option>\n            <option value=\"+1284\" ${state.data.requestor.phonePrefix===\"+1284\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddec +1284<\/option>\n            <option value=\"+1340\" ${state.data.requestor.phonePrefix===\"+1340\"?\"selected\":\"\"}>\ud83c\uddfb\ud83c\uddee +1340<\/option>\n            <option value=\"+681\" ${state.data.requestor.phonePrefix===\"+681\"?\"selected\":\"\"}>\ud83c\uddfc\ud83c\uddeb +681<\/option>\n            <option value=\"+967\" ${state.data.requestor.phonePrefix===\"+967\"?\"selected\":\"\"}>\ud83c\uddfe\ud83c\uddea +967<\/option>\n            <option value=\"+260\" ${state.data.requestor.phonePrefix===\"+260\"?\"selected\":\"\"}>\ud83c\uddff\ud83c\uddf2 +260<\/option>\n            <option value=\"+263\" ${state.data.requestor.phonePrefix===\"+263\"?\"selected\":\"\"}>\ud83c\uddff\ud83c\uddfc +263<\/option>\n          <\/select>\n          <input id=\"requestorPhone\" type=\"tel\" value=\"${esc(state.data.requestor.phone||\"\")}\" placeholder=\"${esc(t(\"placeholderPhone\"))}\" required style=\"flex:2;min-width:200px;\" pattern=\"[0-9\\s\\(\\)\\-]+\" inputmode=\"numeric\"\/>\n        <\/div>\n        <div class=\"err\" id=\"requestorPhone__err\">${esc(t(\"errFieldRequired\"))}<\/div>`;\n      g.appendChild(phoneCol);\n\n      fs.appendChild(g); root.appendChild(fs);\n\n      $(\"#requestorFirstName\").addEventListener(\"input\",(e)=>state.data.requestor.firstName=e.target.value.trim());\n      $(\"#requestorLastName\").addEventListener(\"input\",(e)=>state.data.requestor.lastName=e.target.value.trim());\n      $(\"#requestorCompany\").addEventListener(\"input\",(e)=>state.data.requestor.company=e.target.value.trim());\n      $(\"#requestorEmail\").addEventListener(\"input\",(e)=>state.data.requestor.email=e.target.value.trim());\n      $(\"#requestorPhonePrefix\").addEventListener(\"change\",(e)=>{\n        state.data.requestor.phonePrefix=e.target.value;\n      });\n      $(\"#requestorPhone\").addEventListener(\"input\",(e)=>{\n        \/\/ Permetti solo numeri, spazi, trattini e parentesi\n        e.target.value = e.target.value.replace(\/[^0-9\\s\\-\\(\\)]\/g, \"\");\n        state.data.requestor.phone=e.target.value.trim();\n      });\n    }\n    function val0(){\n      let ok=true;\n      ok &= requireText($(\"#requestorFirstName\"));\n      ok &= requireText($(\"#requestorLastName\"));\n      ok &= requireText($(\"#requestorCompany\"));\n      ok &= requireEmail($(\"#requestorEmail\"));\n      ok &= requireText($(\"#requestorPhone\"));\n      return !!ok;\n    }\n\n    \/\/ STEP 1\n    function step1(root){\n      const fs=document.createElement(\"fieldset\"); fs.innerHTML=`<legend>${t(\"section1RequestLegend\")}<\/legend>`;\n      const g=document.createElement(\"div\"); g.className=\"grid\";\n\n      g.appendChild(select(\"requestFor\",t(\"requestType\"),[\n        [\"\",t(\"selectPlaceholder\")],\n        [\"new_onboarding\",t(\"newOnboarding\")],\n        [\"update_client\",t(\"updateClient\")]\n      ],{value:state.data.request.requestFor,required:true,col:6}));\n\n      \/\/ Mostra gli altri campi solo se \u00e8 stato selezionato un tipo di richiesta\n      if(state.data.request.requestFor && state.data.request.requestFor!==\"\") {\n        \/\/ NMVS Client ID non mostrato per \"Nuovo onboarding Client\"\n        \/\/ Obbligatorio per \"update_client\"\n        if(state.data.request.requestFor!==\"new_onboarding\") {\n          const isRequired = state.data.request.requestFor===\"update_client\";\n          g.appendChild(field(\"nmvsClientId\",t(\"nmvsClientId\"),{value:state.data.request.nmvsClientId,required:isRequired,col:6,placeholder:t(\"placeholderNmvsId\")}));\n        }\n        g.appendChild(field(\"referenceTicket\",t(\"referenceTicket\"),{value:state.data.request.referenceTicket,col:12,placeholder:t(\"placeholderTicket\")}));\n\n        \/\/ Campo per update_client: nessuna modifica anagrafica (primo)\n        if(state.data.request.requestFor===\"update_client\") {\n          const wrap3=document.createElement(\"div\"); wrap3.className=\"col-12\";\n          wrap3.appendChild(checkbox(\"noAnagraficaChanges\",t(\"noAnagraficaChanges\"),!!state.data.request.noAnagraficaChanges,t(\"noAnagraficaChangesHelp\")));\n          g.appendChild(wrap3);\n        }\n\n        \/\/ Campo per update_client: modifiche ai dati di integrazione (secondo)\n        if(state.data.request.requestFor===\"update_client\") {\n          const wrap2=document.createElement(\"div\"); wrap2.className=\"col-12\";\n          wrap2.appendChild(checkbox(\"hasIntegrationChanges\",t(\"hasIntegrationChanges\"),!!state.data.request.hasIntegrationChanges,t(\"hasIntegrationChangesHelp\")));\n          g.appendChild(wrap2);\n        }\n\n        \/\/ Include tutte le modifiche: se selezionato disattiva gli altri checkbox\n        if(state.data.request.requestFor===\"update_client\") {\n          const wrap4=document.createElement(\"div\"); wrap4.className=\"col-12\";\n          wrap4.appendChild(checkbox(\"allChanges\",t(\"allChanges\"),!!state.data.request.allChanges,t(\"allChangesHelp\")));\n          g.appendChild(wrap4);\n          const errRow=document.createElement(\"div\"); errRow.className=\"col-12\";\n          errRow.innerHTML=`<div class=\"err\" id=\"checkboxGroup__err\">${esc(t(\"selectOneOption\"))}<\/div>`;\n          g.appendChild(errRow);\n        }\n      }\n\n      fs.appendChild(g); root.appendChild(fs);\n      if(state.data.request.requestFor===\"update_client\"){\n        const updateClientNote=document.createElement(\"div\");\n        updateClientNote.className=\"sectionhint\";\n        updateClientNote.style.color=\"var(--danger)\";\n        updateClientNote.style.fontWeight=\"600\";\n        updateClientNote.textContent=t(\"updateClientAdminNotice\");\n        root.appendChild(updateClientNote);\n      }\n\n      $(\"#requestFor\").addEventListener(\"change\",(e)=>{ \n        state.data.request.requestFor=e.target.value; \n        if(state.data.request.requestFor!==\"update_client\") {\n          state.data.request.hasIntegrationChanges=false;\n          state.data.request.noAnagraficaChanges=false;\n          state.data.request.allChanges=false;\n        }\n        render(); \n      });\n      const nmvsClientIdEl = $(\"#nmvsClientId\");\n      if(nmvsClientIdEl) {\n        nmvsClientIdEl.addEventListener(\"input\",(e)=>{ state.data.request.nmvsClientId=e.target.value.trim(); });\n      }\n      const referenceTicketEl = $(\"#referenceTicket\");\n      if(referenceTicketEl) {\n        referenceTicketEl.addEventListener(\"input\",(e)=>{ state.data.request.referenceTicket=e.target.value.trim(); });\n      }\n      const hasIntegrationChangesEl = $(\"#hasIntegrationChanges\");\n      if(hasIntegrationChangesEl) {\n        hasIntegrationChangesEl.addEventListener(\"change\",(e)=>{ \n          state.data.request.hasIntegrationChanges=e.target.checked;\n          if(e.target.checked) state.data.request.allChanges=false;\n          render(); \n        });\n      }\n      const noAnagraficaChangesEl = $(\"#noAnagraficaChanges\");\n      if(noAnagraficaChangesEl) {\n        noAnagraficaChangesEl.addEventListener(\"change\",(e)=>{ \n          state.data.request.noAnagraficaChanges=e.target.checked;\n          if(e.target.checked) state.data.request.allChanges=false;\n          render(); \n        });\n      }\n      const allChangesEl = $(\"#allChanges\");\n      if(allChangesEl) {\n        allChangesEl.addEventListener(\"change\",(e)=>{ \n          state.data.request.allChanges=e.target.checked;\n          if(e.target.checked) {\n            state.data.request.hasIntegrationChanges=false;\n            state.data.request.noAnagraficaChanges=false;\n          }\n          render(); \n        });\n      }\n      \/\/ Disattiva gli altri checkbox quando \"include tutte\" \u00e8 selezionato\n      if(state.data.request.requestFor===\"update_client\" && state.data.request.allChanges) {\n        [\"hasIntegrationChanges\",\"noAnagraficaChanges\"].forEach(id=>{\n          const el=document.getElementById(id); if(el) el.disabled=true;\n        });\n      }\n      \/\/ Disattiva \"include tutte\" quando \u00e8 selezionato almeno uno degli altri\n      if(state.data.request.requestFor===\"update_client\" && (state.data.request.hasIntegrationChanges||state.data.request.noAnagraficaChanges)) {\n        const allEl=document.getElementById(\"allChanges\"); if(allEl) allEl.disabled=true;\n      }\n    }\n    function val1(){\n      let ok=true;\n      ok &= requireSelect($(\"#requestFor\"));\n      \/\/ NMVS Client ID obbligatorio per update_client\n      const requestFor = $(\"#requestFor\").value;\n      if(requestFor===\"update_client\") {\n        const nmvsClientIdEl = $(\"#nmvsClientId\");\n        if(nmvsClientIdEl) {\n          ok &= requireText(nmvsClientIdEl);\n        }\n        \/\/ Almeno un checkbox deve essere selezionato\n        const allChangesEl = document.getElementById(\"allChanges\");\n        const hasIntEl = document.getElementById(\"hasIntegrationChanges\");\n        const noAnagEl = document.getElementById(\"noAnagraficaChanges\");\n        const atLeastOne = !!(allChangesEl&&allChangesEl.checked) || !!(hasIntEl&&hasIntEl.checked) || !!(noAnagEl&&noAnagEl.checked);\n        const checkboxGroupErr = document.getElementById(\"checkboxGroup__err\");\n        if(checkboxGroupErr) checkboxGroupErr.classList.toggle(\"show\",!atLeastOne);\n        if(!atLeastOne) ok=false;\n      }\n      return !!ok;\n    }\n\n    \/\/ STEP 2\n    function step2(root){\n      const fs=document.createElement(\"fieldset\"); fs.innerHTML=`<legend>${t(\"section3Legend\")}<\/legend>`;\n      const g=document.createElement(\"div\"); g.className=\"grid\";\n\n      g.appendChild(field(\"clientName\",t(\"clientName\"),{value:state.data.company.clientName,required:true,col:12}));\n\n      const codiceSisArr = Array.isArray(state.data.company.codiceIdentificativoSitoLogistico) ? state.data.company.codiceIdentificativoSitoLogistico : [state.data.company.codiceIdentificativoSitoLogistico || \"\"];\n      const codiceSisWrap = document.createElement(\"div\"); codiceSisWrap.className=\"col-12\"; codiceSisWrap.id=\"codiceSisWrap\";\n      codiceSisWrap.innerHTML=`<label>${t(\"codiceSis\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>`;\n      const codiceSisList = document.createElement(\"div\"); codiceSisList.className=\"codiceSis-list\";\n      codiceSisArr.forEach((val,i)=>{\n        const row = document.createElement(\"div\"); row.className=\"grid\"; row.style.marginBottom=\"8px\";\n        const colInput = document.createElement(\"div\"); colInput.className=\"col-6\";\n        colInput.innerHTML = `<input id=\"codiceSis_${i}\" type=\"text\" value=\"${esc(val)}\" placeholder=\"${esc(t(\"placeholderCodice\"))}\" data-codice-sis-idx=\"${i}\"\/>`;\n        const colBtn = document.createElement(\"div\"); colBtn.className=\"col-6\"; colBtn.style.display=\"flex\"; colBtn.style.alignItems=\"flex-end\";\n        colBtn.innerHTML = codiceSisArr.length > 1 ? `<button type=\"button\" class=\"ghost\" data-codice-sis-remove=\"${i}\">${t(\"remove\")}<\/button>` : \"\";\n        row.appendChild(colInput); row.appendChild(colBtn); codiceSisList.appendChild(row);\n      });\n      codiceSisWrap.appendChild(codiceSisList);\n      const addBtn = document.createElement(\"button\"); addBtn.type=\"button\"; addBtn.className=\"ghost\"; addBtn.id=\"addCodiceSisBtn\"; addBtn.textContent=t(\"addSite\");\n      codiceSisWrap.appendChild(addBtn);\n      const errDiv = document.createElement(\"div\"); errDiv.className=\"err\"; errDiv.id=\"codiceSis__err\"; errDiv.textContent=t(\"errFieldRequired\");\n      codiceSisWrap.appendChild(errDiv);\n      g.appendChild(codiceSisWrap);\n      g.appendChild(field(\"piva\",t(\"piva\"),{value:state.data.company.piva,required:true,col:6,placeholder:t(\"placeholderPiva\")}));\n\n      g.appendChild(select(\"endUserType\",t(\"endUserType\"),[\n        [\"wholesaler\",t(\"wholesaler\")]\n      ],{value:state.data.company.endUserType || \"wholesaler\",required:true,col:6}));\n\n      g.appendChild(field(\"compStreet\",t(\"street\"),{value:state.data.company.street,required:true,col:12}));\n      g.appendChild(field(\"compZip\",t(\"zip\"),{value:state.data.company.zip,required:true,col:4,placeholder:t(\"placeholderZip\")}));\n\n      \/\/ Citt\u00e0 - aggiungo manualmente per forzare size\n      const compCityDiv = document.createElement('div');\n      compCityDiv.className = 'col-4';\n      compCityDiv.innerHTML = `\n        <label for=\"compCity\">${t(\"city\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n        <input id=\"compCity\" type=\"text\" value=\"${esc(state.data.company.city||'')}\" required style=\"width:100%!important\" size=\"50\"\/>\n        <div class=\"err\" id=\"compCity__err\">${esc(t(\"errFieldRequired\"))}<\/div>`;\n      g.appendChild(compCityDiv);\n      \n      \/\/ Paese - aggiungo manualmente per forzare size\n      const compCountryDiv = document.createElement('div');\n      compCountryDiv.className = 'col-4';\n      compCountryDiv.innerHTML = `\n        <label for=\"compCountry\">${t(\"country\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n        <input id=\"compCountry\" type=\"text\" value=\"${esc(state.data.company.country||'')}\" placeholder=\"${esc(t(\"placeholderCountry\"))}\" required style=\"width:100%!important\" size=\"50\"\/>\n        <div class=\"err\" id=\"compCountry__err\">${esc(t(\"errFieldRequired\"))}<\/div>`;\n      g.appendChild(compCountryDiv);\n\n      fs.appendChild(g); root.appendChild(fs);\n\n      \/\/ --- 3B Main Client Contact ---\n      \/\/ Mostra la sezione 3B solo se NON \u00e8 un aggiornamento di un client esistente\n      if(state.data.request.requestFor!==\"update_client\") {\n        const fs2=document.createElement(\"fieldset\");\n        fs2.innerHTML=`<legend>${t(\"mainContactLegend\")}<\/legend><p class=\"sectionhint\">${t(\"mainContactHint\")}<\/p>`;\n        const g2=document.createElement(\"div\"); g2.className=\"grid\";\n\n        g2.appendChild(field(\"mcFirstLastName\",t(\"mcFirstLastName\"),{value:state.data.mainContact.firstLastName,required:true,col:6}));\n        g2.appendChild(field(\"mcEmail\",t(\"mcEmail\"),{type:\"email\",value:state.data.mainContact.email,required:true,col:6,placeholder:t(\"mcPlaceholderEmail\")}));\n        g2.appendChild(field(\"mcCompany\",t(\"mcCompany\"),{value:state.data.mainContact.company,required:true,col:6}));\n        g2.appendChild(field(\"mcDivision\",t(\"mcDivision\"),{value:state.data.mainContact.division,required:true,col:6}));\n        g2.appendChild(field(\"mcStreet\",t(\"mcStreet\"),{value:state.data.mainContact.street,required:true,col:12}));\n        g2.appendChild(field(\"mcZip\",t(\"mcZip\"),{value:state.data.mainContact.zip,required:true,col:4,placeholder:t(\"placeholderZip\")}));\n        \n        \/\/ Citt\u00e0 MC - aggiungo manualmente per forzare size\n        const mcCityDiv = document.createElement('div');\n        mcCityDiv.className = 'col-4';\n        mcCityDiv.innerHTML = `\n          <label for=\"mcCity\">${t(\"mcCity\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n          <input id=\"mcCity\" type=\"text\" value=\"${esc(state.data.mainContact.city||'')}\" required style=\"width:100%!important\" size=\"50\"\/>\n          <div class=\"err\" id=\"mcCity__err\">${esc(t(\"errFieldRequired\"))}<\/div>`;\n        g2.appendChild(mcCityDiv);\n        \n        \/\/ Paese MC - aggiungo manualmente per forzare size\n        const mcCountryDiv = document.createElement('div');\n        mcCountryDiv.className = 'col-4';\n        mcCountryDiv.innerHTML = `\n          <label for=\"mcCountry\">${t(\"mcCountry\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n          <input id=\"mcCountry\" type=\"text\" value=\"${esc(state.data.mainContact.country||'')}\" placeholder=\"${esc(t(\"placeholderCountry\"))}\" required style=\"width:100%!important\" size=\"50\"\/>\n          <div class=\"err\" id=\"mcCountry__err\">${esc(t(\"errFieldRequired\"))}<\/div>`;\n        g2.appendChild(mcCountryDiv);\n        g2.appendChild(field(\"mcPhone\",t(\"mcPhone\"),{value:state.data.mainContact.phone,required:true,col:6,placeholder:t(\"mcPlaceholderPhone\")}));\n\n        fs2.appendChild(g2);\n        const adminWarning=document.createElement(\"div\");\n        adminWarning.className=\"sectionhint\";\n        adminWarning.innerHTML=t(\"mainContactAdminWarning\");\n        fs2.appendChild(adminWarning);\n        root.appendChild(fs2);\n      }\n\n      \/\/ --- Event listeners: Company ---\n      $(\"#clientName\").addEventListener(\"input\",(e)=>state.data.company.clientName=e.target.value.trim());\n      codiceSisWrap.querySelectorAll(\"[id^=codiceSis_]\").forEach(inp=>inp.addEventListener(\"input\",(e)=>{\n        const i=parseInt(e.target.getAttribute(\"data-codice-sis-idx\"),10);\n        if(!Number.isNaN(i)&&state.data.company.codiceIdentificativoSitoLogistico[i]!==undefined) state.data.company.codiceIdentificativoSitoLogistico[i]=e.target.value.trim();\n      }));\n      codiceSisWrap.querySelectorAll(\"[data-codice-sis-remove]\").forEach(btn=>btn.addEventListener(\"click\",(e)=>{\n        const i=parseInt(e.target.getAttribute(\"data-codice-sis-remove\"),10);\n        if(!Number.isNaN(i)&&state.data.company.codiceIdentificativoSitoLogistico.length>1){ state.data.company.codiceIdentificativoSitoLogistico.splice(i,1); render(); }\n      }));\n      $(\"#addCodiceSisBtn\").addEventListener(\"click\",()=>{ state.data.company.codiceIdentificativoSitoLogistico.push(\"\"); render(); });\n      $(\"#piva\").addEventListener(\"input\",(e)=>state.data.company.piva=e.target.value.trim());\n      $(\"#endUserType\").addEventListener(\"change\",(e)=>{ state.data.company.endUserType=e.target.value; render(); });\n      $(\"#compStreet\").addEventListener(\"input\",(e)=>state.data.company.street=e.target.value.trim());\n      $(\"#compZip\").addEventListener(\"input\",(e)=>state.data.company.zip=e.target.value.trim());\n      $(\"#compCity\").addEventListener(\"input\",(e)=>state.data.company.city=e.target.value.trim());\n      $(\"#compCountry\").addEventListener(\"input\",(e)=>state.data.company.country=e.target.value.trim());\n\n      \/\/ --- Event listeners: Main Client Contact ---\n      $(\"#mcFirstLastName\").addEventListener(\"input\",(e)=>state.data.mainContact.firstLastName=e.target.value.trim());\n      $(\"#mcEmail\").addEventListener(\"input\",(e)=>state.data.mainContact.email=e.target.value.trim());\n      $(\"#mcCompany\").addEventListener(\"input\",(e)=>state.data.mainContact.company=e.target.value.trim());\n      $(\"#mcDivision\").addEventListener(\"input\",(e)=>state.data.mainContact.division=e.target.value.trim());\n      $(\"#mcStreet\").addEventListener(\"input\",(e)=>state.data.mainContact.street=e.target.value.trim());\n      $(\"#mcZip\").addEventListener(\"input\",(e)=>state.data.mainContact.zip=e.target.value.trim());\n      $(\"#mcCity\").addEventListener(\"input\",(e)=>state.data.mainContact.city=e.target.value.trim());\n      $(\"#mcCountry\").addEventListener(\"input\",(e)=>state.data.mainContact.country=e.target.value.trim());\n      $(\"#mcPhone\").addEventListener(\"input\",(e)=>state.data.mainContact.phone=e.target.value.trim());\n    }\n    function val2(){\n      let ok=true;\n      ok &= requireText($(\"#clientName\"));\n      const codiceSisInputs = document.querySelectorAll(\"#codiceSisWrap [id^=codiceSis_]\");\n      const atLeastOneCodiceSis = Array.from(codiceSisInputs).some(inp=>inp.value && inp.value.trim()!==\"\");\n      ok &= (showErr(\"codiceSis\", !atLeastOneCodiceSis), atLeastOneCodiceSis);\n      ok &= requireText($(\"#piva\"));\n      ok &= requireSelect($(\"#endUserType\"));\n      ok &= requireText($(\"#compStreet\"));\n      ok &= requireText($(\"#compZip\"));\n      ok &= requireText($(\"#compCity\"));\n      ok &= requireText($(\"#compCountry\"));\n      \/\/ Valida i campi della sezione 3B solo se visibile (non update_client)\n      if(state.data.request.requestFor!==\"update_client\") {\n        ok &= requireText($(\"#mcFirstLastName\"));\n        ok &= requireEmail($(\"#mcEmail\"));\n        ok &= requireText($(\"#mcCompany\"));\n        ok &= requireText($(\"#mcDivision\"));\n        ok &= requireText($(\"#mcStreet\"));\n        ok &= requireText($(\"#mcZip\"));\n        ok &= requireText($(\"#mcCity\"));\n        ok &= requireText($(\"#mcCountry\"));\n        ok &= requireText($(\"#mcPhone\"));\n      }\n      return !!ok;\n    }\n\n    \/\/ STEP 3\n    function step3(root){\n      const fs=document.createElement(\"fieldset\"); fs.innerHTML=`<legend>${t(\"section4Legend\")}<\/legend>`;\n      const hint=document.createElement(\"div\"); hint.className=\"sectionhint\";\n      hint.innerHTML=t(\"integrationHint\");\n      fs.appendChild(hint);\n\n      const g=document.createElement(\"div\"); g.className=\"grid\";\n      g.appendChild(select(\"hasExternalSystem\",t(\"hasExternalSystem\"),[\n        [\"\",t(\"selectPlaceholder\")],[\"yes\",t(\"yes\")],[\"no\",t(\"no\")]\n      ],{value:state.data.integration.hasExternalSystem===true?\"yes\":state.data.integration.hasExternalSystem===false?\"no\":\"\",required:true,col:12}));\n\n      \/\/ Spiegazione per \"No\" (dopo la riga select, visibile quando selezione = No)\n      const explanationNo = document.createElement(\"div\");\n      explanationNo.id = \"explanationNoExternalSystem\";\n      explanationNo.className = \"col-12\";\n      explanationNo.style.display = \"none\";\n      explanationNo.style.marginTop = \"16px\";\n      explanationNo.style.padding = \"12px\";\n      explanationNo.style.backgroundColor = \"var(--bg-secondary, #f5f5f5)\";\n      explanationNo.style.borderRadius = \"4px\";\n      explanationNo.style.fontSize = \"13px\";\n      explanationNo.style.color = \"var(--text, #333)\";\n      explanationNo.style.lineHeight = \"1.6\";\n      explanationNo.innerHTML = t(\"explanationNoExternal\").replace(\/\\n\/g, \"<br>\");\n      g.appendChild(explanationNo);\n\n      \/\/ Spiegazione per \"S\u00ec\" (dopo la riga select, visibile quando selezione = S\u00ec)\n      const explanationYes = document.createElement(\"div\");\n      explanationYes.id = \"explanationYesExternalSystem\";\n      explanationYes.className = \"col-12\";\n      explanationYes.style.display = \"none\";\n      explanationYes.style.marginTop = \"16px\";\n      explanationYes.style.padding = \"12px\";\n      explanationYes.style.backgroundColor = \"var(--bg-secondary, #f5f5f5)\";\n      explanationYes.style.borderRadius = \"4px\";\n      explanationYes.style.fontSize = \"13px\";\n      explanationYes.style.color = \"var(--text, #333)\";\n      explanationYes.style.lineHeight = \"1.6\";\n      explanationYes.innerHTML = t(\"explanationYesExternal\").replace(\/\\n\/g, \"<br>\");\n      g.appendChild(explanationYes);\n\n      g.appendChild(field(\"providerCompany\",t(\"providerCompany\"),{value:state.data.integration.providerCompany,col:6,placeholder:t(\"placeholderProvider\")}));\n      g.appendChild(field(\"softwareName\",t(\"softwareName\"),{value:state.data.integration.softwareName,col:6,placeholder:t(\"placeholderSoftware\")}));\n      g.appendChild(field(\"softwareVersion\",t(\"version\"),{value:state.data.integration.version,col:6,placeholder:t(\"placeholderVersion\")}));\n\n      g.appendChild(textarea(\"baselineProof\",t(\"baselineProof\"),{\n        value:state.data.integration.proofBaselineTesting,\n        help:t(\"baselineProofHelp\"),\n        placeholder:t(\"baselineProofPlaceholder\")\n      }));\n\n      g.appendChild(fileInput(\"integrationAttachments\",t(\"integrationAttachments\"),{\n        required:false,\n        col:12,\n        help:t(\"integrationAttachmentsHelp\"),\n        accept: nmvo_ajax_object.allowed_extensions || '.pdf'\n      }));\n\n      fs.appendChild(g);\n      root.appendChild(fs);\n\n      const toggle = () => {\n        const value = $(\"#hasExternalSystem\").value;\n        const yes = value === \"yes\";\n        const no = value === \"no\";\n        \n        [\"providerCompany\",\"softwareName\",\"softwareVersion\",\"baselineProof\",\"integrationAttachments\"].forEach(id=>{\n          const w=document.getElementById(id).closest(\"div\");\n          if(w) w.style.display=yes?\"\":\"none\";\n        });\n        const attInput = $(\"#integrationAttachments\");\n        if(attInput) attInput.required = yes;\n        \n        \/\/ Mostra\/nascondi spiegazioni\n        if(explanationNo) explanationNo.style.display = no ? \"block\" : \"none\";\n        if(explanationYes) explanationYes.style.display = yes ? \"block\" : \"none\";\n      };\n\n      $(\"#hasExternalSystem\").addEventListener(\"change\",(e)=>{\n        state.data.integration.hasExternalSystem = e.target.value===\"yes\" ? true : e.target.value===\"no\" ? false : null;\n        toggle();\n      });\n      toggle(); \/\/ Inizializza lo stato al caricamento\n      $(\"#providerCompany\").addEventListener(\"input\",(e)=>state.data.integration.providerCompany=e.target.value.trim());\n      $(\"#softwareName\").addEventListener(\"input\",(e)=>state.data.integration.softwareName=e.target.value.trim());\n      $(\"#softwareVersion\").addEventListener(\"input\",(e)=>state.data.integration.version=e.target.value.trim());\n      $(\"#baselineProof\").addEventListener(\"input\",(e)=>state.data.integration.proofBaselineTesting=e.target.value.trim());\n      \n      const attInput = $(\"#integrationAttachments\");\n      const attList = $(\"#integrationAttachments__list\");\n      if(attInput) {\n        attInput.addEventListener(\"change\",(e)=>{\n          const files = Array.from(e.target.files);\n          \n          \/\/ Valida le estensioni dei file\n          if (files.length > 0 && !validateFileExtensions(files)) {\n            e.target.value = ''; \/\/ Pulisci l'input\n            state.data.integration.attachments = [];\n            state.files.integration = [];\n            updateAttachmentList(attList, []);\n            return;\n          }\n          \n          state.data.integration.attachments = files.map(f => ({\n            name: f.name,\n            size: f.size,\n            type: f.type,\n            lastModified: f.lastModified\n          }));\n          state.files.integration = files;\n          updateAttachmentList(attList, files);\n        });\n        \/\/ Mostra i file gi\u00e0 selezionati se presenti\n        if(state.data.integration.attachments && state.data.integration.attachments.length > 0) {\n          const fileNames = state.data.integration.attachments.map(a => a.name).join(\", \");\n          if(attList) attList.innerHTML = `<div class=\"small\" style=\"color:var(--muted);\">${t(\"fileSelected\")} ${esc(fileNames)}<\/div>`;\n        }\n      }\n\n      toggle();\n    }\n    function updateAttachmentList(listEl, files){\n      if(!listEl) return;\n      if(files.length === 0) {\n        listEl.innerHTML = \"\";\n        return;\n      }\n      const items = files.map(f => {\n        const sizeKB = (f.size \/ 1024).toFixed(2);\n        return `<div style=\"display:flex;align-items:center;gap:8px;padding:6px;background:#f9fafb;border-radius:4px;margin-top:4px;\">\n          <span style=\"font-size:12px;color:var(--nmvo-blue);\">\ud83d\udcce<\/span>\n          <span style=\"font-size:12px;flex:1;\">${esc(f.name)}<\/span>\n          <span style=\"font-size:11px;color:var(--muted);\">${sizeKB} KB<\/span>\n        <\/div>`;\n      }).join(\"\");\n      listEl.innerHTML = items;\n    }\n    function val3(){\n      let ok=true;\n      ok &= requireSelect($(\"#hasExternalSystem\"));\n      if($(\"#hasExternalSystem\").value===\"yes\"){\n        ok &= requireText($(\"#providerCompany\"));\n        ok &= requireText($(\"#softwareName\"));\n        ok &= requireText($(\"#softwareVersion\"));\n        ok &= requireText($(\"#baselineProof\"));\n        const attInput = $(\"#integrationAttachments\");\n        if(attInput) {\n          const hasFiles = attInput.files && attInput.files.length > 0;\n          if(!hasFiles) {\n            showErr(\"integrationAttachments\", true, t(\"errIntegrationAttachment\"));\n            ok = false;\n          } else {\n            showErr(\"integrationAttachments\", false);\n          }\n        }\n      } else {\n        [\"providerCompany\",\"softwareName\",\"softwareVersion\",\"baselineProof\",\"integrationAttachments\"].forEach(id=>showErr(id,false));\n      }\n      return !!ok;\n    }\n\n    \/\/ STEP 4\n    function blankUser(){ return {requestType:\"new\",userId:\"\",firstName:\"\",lastName:\"\",email:\"\",phone:\"\",companyName:\"\",codiceIdentificativoSitoLogistico:\"\",street:\"\",zip:\"\",city:\"\",country:\"\",role:\"\"}; }\n\n    function step4(root){\n      const fs=document.createElement(\"fieldset\"); fs.innerHTML=`<legend>${t(\"section5Legend\")}<\/legend>`;\n      const hint=document.createElement(\"div\"); hint.className=\"sectionhint\";\n      hint.innerHTML=t(\"section5Hint\");\n      fs.appendChild(hint);\n\n      const actions=document.createElement(\"div\"); actions.className=\"nav\"; actions.style.marginTop=\"10px\";\n      actions.innerHTML=`<button type=\"button\" class=\"ghost\" id=\"addUserBtn\">${t(\"addUser\")}<\/button>\n                         <div class=\"small\">${t(\"totalUsers\")} <strong id=\"userCount\">${state.data.users.length}<\/strong><\/div>`;\n      fs.appendChild(actions);\n\n      const list=document.createElement(\"div\"); list.id=\"userList\"; fs.appendChild(list);\n      root.appendChild(fs);\n\n      $(\"#addUserBtn\").addEventListener(\"click\",()=>{ state.data.users.push(blankUser()); render(); });\n      renderUsers();\n    }\n\n    function renderUsers(){\n      const list=$(\"#userList\"); if(!list) return;\n      list.innerHTML=\"\"; $(\"#userCount\").textContent=String(state.data.users.length);\n\n      if(state.data.users.length===0){\n        const e=document.createElement(\"div\"); e.className=\"sectionhint\"; e.textContent=t(\"noUsersHint\");\n        list.appendChild(e); return;\n      }\n\n      state.data.users.forEach((u,idx)=>{\n        \/\/ In sezione 5 \u00e8 sempre creazione nuovo account\n        u.requestType=\"new\";\n        u.userId=\"\";\n        const card=document.createElement(\"div\"); card.className=\"usercard\";\n        card.innerHTML=`\n          <div class=\"userhead\">\n            <div style=\"display:flex;gap:10px;align-items:center\">\n              <span class=\"badge\">${t(\"userN\")}${idx+1}<\/span>\n              <span class=\"small\">${esc((u.firstName||\"\")+\" \"+(u.lastName||\"\")||\"\u2014\")}<\/span>\n            <\/div>\n            <button type=\"button\" class=\"ghost\" data-del=\"${idx}\">${t(\"remove\")}<\/button>\n          <\/div>\n          <div class=\"grid\">\n            <div class=\"col-6\">\n              <label>${t(\"firstName\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"firstName\" value=\"${esc(u.firstName||\"\")}\"\/>\n              <div class=\"err\" id=\"u_${idx}_firstName__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n            <div class=\"col-6\">\n              <label>${t(\"lastName\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"lastName\" value=\"${esc(u.lastName||\"\")}\"\/>\n              <div class=\"err\" id=\"u_${idx}_lastName__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n\n            <div class=\"col-6\">\n              <label>${t(\"email\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"email\" type=\"email\" value=\"${esc(u.email||\"\")}\"\/>\n              <div class=\"err\" id=\"u_${idx}_email__err\">${esc(t(\"errEmailInvalid\"))}<\/div>\n            <\/div>\n\n            <div class=\"col-6\">\n              <label>${t(\"phoneCol\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"phone\" value=\"${esc(u.phone||\"\")}\"\/>\n              <div class=\"err\" id=\"u_${idx}_phone__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n            <div class=\"col-12\">\n              <label>${t(\"division\")}${u.role===\"regular\" ? ` <span class=\"small\">${esc(t(\"required\"))}<\/span>` : \"\"}<\/label>\n              <input data-i=\"${idx}\" data-k=\"codiceIdentificativoSitoLogistico\" value=\"${esc(u.codiceIdentificativoSitoLogistico||u.division||\"\")}\"\/>\n              <div class=\"err\" id=\"u_${idx}_division__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n\n            <div class=\"col-12\">\n              <label>${t(\"address\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"street\" value=\"${esc(u.street||\"\")}\"\/>\n              <div class=\"err\" id=\"u_${idx}_street__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n            <div class=\"col-4\">\n              <label>${t(\"zip\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"zip\" value=\"${esc(u.zip||\"\")}\"\/>\n              <div class=\"err\" id=\"u_${idx}_zip__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n            <div class=\"col-4\">\n              <label>${t(\"city\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"city\" value=\"${esc(u.city||\"\")}\" style=\"width:100%!important\" size=\"50\"\/>\n              <div class=\"err\" id=\"u_${idx}_city__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n            <div class=\"col-4\">\n              <label>${t(\"country\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <input data-i=\"${idx}\" data-k=\"country\" value=\"${esc(u.country||\"\")}\" style=\"width:100%!important\" size=\"50\"\/>\n              <div class=\"err\" id=\"u_${idx}_country__err\">${esc(t(\"errFieldRequired\"))}<\/div>\n            <\/div>\n\n            <div class=\"col-12\">\n              <label>${t(\"roleCol\")} <span class=\"small\">${esc(t(\"required\"))}<\/span><\/label>\n              <select data-i=\"${idx}\" data-k=\"role\">\n                <option value=\"\">${esc(t(\"selectPlaceholder\"))}<\/option>\n                <option value=\"admin\" ${u.role===\"admin\"?\"selected\":\"\"}>ADMIN<\/option>\n                <option value=\"regular\" ${u.role===\"regular\"?\"selected\":\"\"}>Regular<\/option>\n              <\/select>\n              <div class=\"err\" id=\"u_${idx}_role__err\">${esc(t(\"errSelectRequired\"))}<\/div>\n            <\/div>\n          <\/div>\n        `;\n\n        card.querySelector(\"[data-del]\").addEventListener(\"click\",()=>{\n          state.data.users.splice(idx,1); render();\n        });\n\n        card.querySelectorAll(\"input,select\").forEach(el=>{\n          el.addEventListener(\"input\",onUserChange);\n          el.addEventListener(\"change\",onUserChange);\n        });\n\n        list.appendChild(card);\n      });\n    }\n\n    function onUserChange(e){\n      const idx=parseInt(e.target.getAttribute(\"data-i\"),10);\n      const key=e.target.getAttribute(\"data-k\");\n      if(Number.isNaN(idx)||!key) return;\n      state.data.users[idx][key]=e.target.value.trim();\n      if(key===\"role\"){\n        const card=e.target.closest(\".usercard\");\n        const divLabel=card&&card.querySelector('input[data-k=\"codiceIdentificativoSitoLogistico\"]');\n        const lbl=divLabel&&divLabel.previousElementSibling;\n        if(lbl) lbl.innerHTML=state.data.users[idx].role===\"regular\" ? t(\"division\")+\" <span class=\\\"small\\\">\"+t(\"required\")+\"<\/span>\" : t(\"division\");\n      }\n    }\n\n    function uErr(idx,key,on){\n      const el=document.getElementById(`u_${idx}_${key}__err`);\n      if(el) el.classList.toggle(\"show\",!!on);\n    }\n    function val4(){\n      if(state.data.users.length===0){\n        toast(t(\"toastAddUser\"));\n        return false;\n      }\n      let ok=true;\n      let hasRegular=false;\n      state.data.users.forEach((u,idx)=>{\n        uErr(idx,\"firstName\",!u.firstName); ok &= !!u.firstName;\n        uErr(idx,\"lastName\",!u.lastName); ok &= !!u.lastName;\n        const emOk = !!u.email && \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/.test(u.email);\n        uErr(idx,\"email\",!emOk); ok &= emOk;\n\n        uErr(idx,\"phone\",!u.phone); ok &= !!u.phone;\n        uErr(idx,\"street\",!u.street); ok &= !!u.street;\n        uErr(idx,\"zip\",!u.zip); ok &= !!u.zip;\n        uErr(idx,\"city\",!u.city); ok &= !!u.city;\n        uErr(idx,\"country\",!u.country); ok &= !!u.country;\n\n        const divisionRequired = u.role===\"regular\";\n        const userDivision = (u.codiceIdentificativoSitoLogistico ?? u.division) || \"\";\n        uErr(idx,\"division\", divisionRequired && !userDivision.trim()); ok &= (!divisionRequired || !!userDivision.trim());\n\n        uErr(idx,\"role\",!u.role); ok &= !!u.role;\n        if(u.role===\"regular\") hasRegular=true;\n      });\n      if(!hasRegular){ toast(t(\"toastRegularRequired\")); ok=false; }\n      return !!ok;\n    }\n\n    \/\/ STEP 5\n    function step5(root){\n      const fs=document.createElement(\"fieldset\"); fs.innerHTML=`<legend>${t(\"section6Legend\")}<\/legend>`;\n      const intro=document.createElement(\"div\"); intro.className=\"sectionhint\";\n      intro.innerHTML=`${t(\"arvatoPortal\")} <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/sws-nmvs.eu\/register\">https:\/\/sws-nmvs.eu\/register<\/a>`;\n      fs.appendChild(intro);\n\n      const list=document.createElement(\"div\"); list.style.display=\"grid\"; list.style.gap=\"10px\"; list.style.marginTop=\"10px\";\n      list.appendChild(checkbox(\"baselineTestAck\",t(\"baselineTestAckLabel\"),state.data.terms.baselineTestAck));\n      \/\/ list.appendChild(checkbox(\"liabilityAck\",\"Riconosco la responsabilit\u00e0 esclusiva dell\u2019utente esecutore; NMVO Italia non \u00e8 responsabile per atti fraudolenti\/illeciti.\",state.data.terms.liabilityAck));\n\n      const h3=document.createElement(\"div\"); h3.className=\"sectionhint\"; h3.innerHTML=`<strong>${t(\"authorizationsTitle\")}<\/strong><br>${t(\"authorizationsExamples\")}`;\n      list.appendChild(h3);\n      \n      \/\/ Checkbox per update_client: valgono le autorizzazioni gi\u00e0 fornite\n      const isNewOnboarding = state.data.request.requestFor===\"new_onboarding\";\n      if(state.data.request.requestFor===\"update_client\") {\n        list.appendChild(checkbox(\"useExistingAuthorizations\",t(\"useExistingAuthorizations\"),state.data.terms.authorizations.useExistingAuthorizations));\n      }\n      \n      \/\/ Per new_onboarding non mostriamo pi\u00f9 il checkbox \"Specificare tipo di autorizzazione\":\n      \/\/ il blocco di testo \u00e8 sempre visibile e considerato come autorizzazione \"other\".\n      if(!isNewOnboarding){\n        list.appendChild(checkbox(\"auth_other\",t(\"other\"),state.data.terms.authorizations.other));\n      } else {\n        state.data.terms.authorizations.other = true;\n      }\n      const authSelectErr=document.createElement(\"div\"); authSelectErr.className=\"err\"; authSelectErr.id=\"authorizationsSelect__err\"; authSelectErr.textContent=t(\"toastSelectAuth\"); list.appendChild(authSelectErr);\n      \n      const g=document.createElement(\"div\"); g.className=\"grid\"; g.id=\"auth_otherText_container\";\n      \/\/ Nascondi il blocco solo se non c'\u00e8 selezione (per new_onboarding \u00e8 sempre visibile)\n      const showOtherBlock = isNewOnboarding || state.data.terms.authorizations.other;\n      if(!showOtherBlock) {\n        g.style.display=\"none\";\n      }\n      const col=document.createElement(\"div\"); col.className=\"col-12\";\n      \/\/ Label con pulsante \"+\" e testo di aiuto\n      const lbl=document.createElement(\"label\");\n      lbl.htmlFor=\"auth_otherText_0\";\n      const addBtn=document.createElement(\"button\");\n      addBtn.type=\"button\";\n      addBtn.id=\"auth_otherText_add\";\n      addBtn.className=\"ghost\";\n      addBtn.textContent=\"+\";\n      lbl.appendChild(addBtn);\n      const addHint=document.createElement(\"span\");\n      addHint.style.marginLeft=\"8px\";\n      addHint.textContent=t(\"authOtherAddHint\");\n      lbl.appendChild(addHint);\n      col.appendChild(lbl);\n      \/\/ Contenitore delle righe di testo aggiuntive\n      const listText=document.createElement(\"div\");\n      listText.id=\"auth_otherText_list\";\n      const existingTexts=(state.data.terms.authorizations.otherText||\"\").split(\"\\n\");\n      const initialTexts=existingTexts.length>0?existingTexts:[\"\"];\n      initialTexts.forEach((txt,idx)=>{\n        const inp=document.createElement(\"input\");\n        inp.type=\"text\";\n        inp.id=`auth_otherText_${idx}`;\n        inp.value=txt;\n        inp.placeholder=\"...\";\n        inp.style.display=\"block\";\n        inp.style.marginTop=\"4px\";\n        listText.appendChild(inp);\n      });\n      col.appendChild(listText);\n      \/\/ Messaggio di errore riutilizzando l'id esistente\n      const errDiv=document.createElement(\"div\");\n      errDiv.className=\"err\";\n      errDiv.id=\"auth_otherText__err\";\n      errDiv.textContent=t(\"specifyOtherAuth\");\n      col.appendChild(errDiv);\n      g.appendChild(col);\n      list.appendChild(g);\n      \n      const gAtt=document.createElement(\"div\"); gAtt.className=\"grid\"; gAtt.id=\"authAttachments_container\"; gAtt.style.marginTop=\"10px\";\n      \/\/ Inizialmente nascondi il campo allegati (verr\u00e0 mostrato quando si seleziona un'autorizzazione)\n      gAtt.style.display = \"none\";\n      gAtt.appendChild(fileInput(\"authAttachments\",t(\"authAttachments\"),{\n        accept: nmvo_ajax_object.allowed_extensions || '.pdf',\n        required:false,\n        col:12,\n        help:t(\"authAttachmentsHelp\")\n      }));\n      list.appendChild(gAtt);\n\n      const h2=document.createElement(\"div\"); h2.className=\"sectionhint\"; h2.innerHTML=`<strong>${t(\"declarationsTitle\")}<\/strong>`;\n      list.appendChild(h2);\n      const declarationsText = t(\"declarationsList\");\n      list.appendChild(checkbox(\"declarationsAck\",declarationsText,state.data.terms.declarationsAck));\n\n      fs.appendChild(list); root.appendChild(fs);\n\n      $(\"#baselineTestAck\").addEventListener(\"change\",(e)=>state.data.terms.baselineTestAck=e.target.checked);\n      $(\"#declarationsAck\").addEventListener(\"change\",(e)=>{\n        const checked = e.target.checked;\n        state.data.terms.declarationsAck = checked;\n        \/\/ Mantieni i valori individuali per retrocompatibilit\u00e0\n        state.data.terms.readTermsArvato = checked;\n        state.data.terms.provideAccurateData = checked;\n        state.data.terms.complyObligations = checked;\n        state.data.terms.handleUnavailability = checked;\n        state.data.terms.acceptControlsAuditTrail = checked;\n        state.data.terms.liabilityAck = checked;\n        state.data.terms.cooperateOnboarding = checked;\n      });\n      \n      \/\/ Definisci authAttInput PRIMA degli event listener per poterlo usare in updateAuthAttachmentRequirement\n      const authAttInput = $(\"#authAttachments\");\n      const authAttList = $(\"#authAttachments__list\");\n      \n      const useExistingAuthEl = $(\"#useExistingAuthorizations\");\n      function hideAuthSelectErr(){\n        const isNewOnboarding = state.data.request.requestFor===\"new_onboarding\";\n        const hasOtherText = !!(state.data.terms.authorizations.otherText && state.data.terms.authorizations.otherText.trim());\n        const hasOther = isNewOnboarding ? hasOtherText : state.data.terms.authorizations.other;\n        const hasAnyAuth = state.data.terms.authorizations.wholesaleArt100 || state.data.terms.authorizations.designatedWholesaler || hasOther;\n        const hasAny = state.data.terms.authorizations.useExistingAuthorizations || hasAnyAuth;\n        showErr(\"authorizationsSelect\", !hasAny);\n      }\n      if(useExistingAuthEl) {\n        useExistingAuthEl.addEventListener(\"change\",(e)=>{\n          const checked = e.target.checked;\n          state.data.terms.authorizations.useExistingAuthorizations = checked;\n          \/\/ Se seleziono \"valgono le autorizzazioni gi\u00e0 fornite\", disattivo l'altra opzione\n          if(checked){\n            const authOtherElLocal = $(\"#auth_other\");\n            if(authOtherElLocal){\n              authOtherElLocal.checked = false;\n            }\n            state.data.terms.authorizations.other = false;\n            \/\/ Nascondi e pulisci i testi \"other\"\n            const authOtherTextContainer = document.getElementById(\"auth_otherText_container\");\n            if(authOtherTextContainer) {\n              authOtherTextContainer.style.display = \"none\";\n            }\n            const listEl = document.getElementById(\"auth_otherText_list\");\n            if(listEl) {\n              listEl.querySelectorAll(\"input[id^='auth_otherText_']\").forEach(inp => inp.value=\"\");\n            }\n            state.data.terms.authorizations.otherText = \"\";\n            syncOtherTextFromInputs();\n          }\n          updateAuthAttachmentRequirement();\n          hideAuthSelectErr();\n        });\n      }\n      const authWholesaleEl = $(\"#auth_wholesale\");\n      if(authWholesaleEl){\n        authWholesaleEl.addEventListener(\"change\",(e)=>{\n          state.data.terms.authorizations.wholesaleArt100=e.target.checked;\n          updateAuthAttachmentRequirement();\n          hideAuthSelectErr();\n        });\n      }\n      const authDesignatedEl = $(\"#auth_designated\");\n      if(authDesignatedEl){\n        authDesignatedEl.addEventListener(\"change\",(e)=>{\n          state.data.terms.authorizations.designatedWholesaler=e.target.checked;\n          updateAuthAttachmentRequirement();\n          hideAuthSelectErr();\n        });\n      }\n      const authOtherEl = $(\"#auth_other\");\n      if(authOtherEl){\n        authOtherEl.addEventListener(\"change\",(e)=>{\n          const checked = e.target.checked;\n          state.data.terms.authorizations.other = checked;\n          const authOtherTextContainer = document.getElementById(\"auth_otherText_container\");\n          if(authOtherTextContainer) {\n            authOtherTextContainer.style.display = checked ? \"block\" : \"none\";\n          }\n          \/\/ Se seleziono \"Specificare tipo di autorizzazione\", disattivo \"useExistingAuthorizations\"\n          if(checked){\n            const useExistingAuthElLocal = $(\"#useExistingAuthorizations\");\n            if(useExistingAuthElLocal){\n              useExistingAuthElLocal.checked = false;\n            }\n            state.data.terms.authorizations.useExistingAuthorizations = false;\n          } else {\n            \/\/ Se il checkbox viene deselezionato, pulisci i campi\n            const listEl = document.getElementById(\"auth_otherText_list\");\n            if(listEl) {\n              listEl.querySelectorAll(\"input[id^='auth_otherText_']\").forEach(inp => inp.value=\"\");\n            }\n            state.data.terms.authorizations.otherText = \"\";\n            syncOtherTextFromInputs();\n          }\n          updateAuthAttachmentRequirement();\n          hideAuthSelectErr();\n        });\n      }\n      \/\/ Gestione dinamica delle righe di testo aggiuntive per le autorizzazioni \"other\"\n      function syncOtherTextFromInputs(){\n        const listEl = document.getElementById(\"auth_otherText_list\");\n        if(!listEl) return;\n        const inputs = Array.from(listEl.querySelectorAll(\"input[id^='auth_otherText_']\"));\n        const values = inputs.map(inp => inp.value.trim());\n        state.data.terms.authorizations.otherText = values.join(\"\\n\").trim();\n      }\n      \/\/ Collega gli handler agli input esistenti e al pulsante \"+\"\n      (function initAuthOtherTextInputs(){\n        const listEl = document.getElementById(\"auth_otherText_list\");\n        if(!listEl) return;\n        const inputs = Array.from(listEl.querySelectorAll(\"input[id^='auth_otherText_']\"));\n        inputs.forEach(inp=>{\n          inp.addEventListener(\"input\",syncOtherTextFromInputs);\n        });\n        const addBtnEl = document.getElementById(\"auth_otherText_add\");\n        if(addBtnEl){\n          addBtnEl.addEventListener(\"click\",()=>{\n            const idx = listEl.querySelectorAll(\"input[id^='auth_otherText_']\").length;\n            const inp=document.createElement(\"input\");\n            inp.type=\"text\";\n            inp.id=`auth_otherText_${idx}`;\n            inp.placeholder=\"...\";\n            inp.style.display=\"block\";\n            inp.style.marginTop=\"4px\";\n            listEl.appendChild(inp);\n            inp.addEventListener(\"input\",syncOtherTextFromInputs);\n            inp.focus();\n          });\n        }\n      })();\n      if(authAttInput) {\n        authAttInput.addEventListener(\"change\",(e)=>{\n          const files = Array.from(e.target.files);\n          \n          \/\/ Valida le estensioni dei file\n          if (files.length > 0 && !validateFileExtensions(files)) {\n            e.target.value = ''; \/\/ Pulisci l'input\n            state.data.terms.authorizations.attachments = [];\n            state.files.auth = [];\n            updateAttachmentList(authAttList, []);\n            return;\n          }\n          \n          state.data.terms.authorizations.attachments = files.map(f => ({\n            name: f.name,\n            size: f.size,\n            type: f.type,\n            lastModified: f.lastModified\n          }));\n          state.files.auth = files;\n          updateAttachmentList(authAttList, files);\n        });\n        \/\/ Mostra i file gi\u00e0 selezionati se presenti\n        if(state.data.terms.authorizations.attachments && state.data.terms.authorizations.attachments.length > 0) {\n          const fileNames = state.data.terms.authorizations.attachments.map(a => a.name).join(\", \");\n          if(authAttList) authAttList.innerHTML = `<div class=\"small\" style=\"color:var(--muted);\">${t(\"fileSelected\")} ${esc(fileNames)}<\/div>`;\n        }\n      }\n      \n      function updateAuthAttachmentRequirement(){\n        const hasAuth = state.data.terms.authorizations.wholesaleArt100 || \n                        state.data.terms.authorizations.designatedWholesaler || \n                        state.data.terms.authorizations.other;\n        \/\/ useExisting \u00e8 true solo se il checkbox esiste ed \u00e8 selezionato (solo per update_client)\n        const useExisting = state.data.terms.authorizations.useExistingAuthorizations === true;\n        \/\/ Gli allegati sono richiesti solo se ci sono autorizzazioni selezionate E non si usa \"useExistingAuthorizations\"\n        \/\/ Se useExisting \u00e8 true, nascondi sempre il campo allegati (non serve allegare nulla)\n        \/\/ Per new_onboarding, useExisting sar\u00e0 sempre false\/undefined, quindi requiresAttachment = hasAuth\n        const requiresAttachment = hasAuth && !useExisting;\n        \n        \/\/ Nascondi\/mostra il container degli allegati\n        const authAttContainer = document.getElementById(\"authAttachments_container\");\n        if(authAttContainer) {\n          \/\/ Se useExisting \u00e8 selezionato, nascondi sempre il campo allegati\n          if(useExisting) {\n            authAttContainer.style.display = \"none\";\n            if(authAttInput) {\n              authAttInput.required = false;\n              \/\/ Pulisci anche i file selezionati quando si nasconde\n              authAttInput.value = \"\";\n              \/\/ Pulisci anche lo stato dei file\n              if(state.data.terms.authorizations.attachments) {\n                state.data.terms.authorizations.attachments = [];\n              }\n              state.files.auth = [];\n              \/\/ Pulisci anche la lista visuale dei file\n              if(authAttList) {\n                authAttList.innerHTML = \"\";\n              }\n            }\n          } else {\n            \/\/ Altrimenti mostra\/nascondi in base a requiresAttachment\n            \/\/ Per new_onboarding: mostra se hasAuth \u00e8 true\n            \/\/ Per update_client senza useExisting: mostra se hasAuth \u00e8 true\n            \/\/ Usa \"grid\" perch\u00e9 il container ha la classe \"grid\" che usa display:grid\n            authAttContainer.style.display = requiresAttachment ? \"grid\" : \"none\";\n            if(authAttInput) {\n              authAttInput.required = requiresAttachment;\n            }\n          }\n        } else {\n          \/\/ Debug: se il container non viene trovato, potrebbe essere un problema di timing\n          console.warn(\"authAttachments_container non trovato\");\n        }\n      }\n      updateAuthAttachmentRequirement();\n      showErr(\"authorizationsSelect\", false);\n      \n    }\n    function val5(){\n      let ok=true;\n      ok &= requireCheck(\"declarationsAck\");\n      const hasAuth = state.data.terms.authorizations.wholesaleArt100 || \n                      state.data.terms.authorizations.designatedWholesaler || \n                      state.data.terms.authorizations.other;\n      const useExisting = state.data.terms.authorizations.useExistingAuthorizations === true;\n      \/\/ Se non ci sono autorizzazioni selezionate e non si usa \"useExistingAuthorizations\", errore\n      if(!hasAuth && !useExisting){ showErr(\"authorizationsSelect\", true); toast(t(\"toastSelectAuth\")); ok=false; }\n      else { showErr(\"authorizationsSelect\", false); }\n      if(state.data.terms.authorizations.other && !state.data.terms.authorizations.otherText.trim()){\n        showErr(\"auth_otherText\",true,t(\"specifyOtherAuth\"));\n        ok=false;\n      }\n      \/\/ Validazione allegati autorizzazioni: richiesti solo se ci sono autorizzazioni selezionate E non si usa \"useExistingAuthorizations\"\n      if(hasAuth && !useExisting) {\n        const authAttInput = $(\"#authAttachments\");\n        const hasFilesFromInput = authAttInput && authAttInput.files && authAttInput.files.length > 0;\n        const hasFilesFromState = state.data.terms.authorizations.attachments && state.data.terms.authorizations.attachments.length > 0;\n        const hasFiles = hasFilesFromInput || hasFilesFromState;\n        if(!hasFiles) {\n          showErr(\"authAttachments\", true, t(\"errAuthAttachment\"));\n          ok = false;\n        } else {\n          showErr(\"authAttachments\", false);\n        }\n      } else {\n        showErr(\"authAttachments\", false);\n      }\n      return !!ok;\n    }\n\n    \/\/ STEP 6\n    function step6(root){\n      const fs=document.createElement(\"fieldset\"); fs.innerHTML=`<legend>${t(\"section7Legend\")}<\/legend>`;\n      const summary=document.createElement(\"div\");\n      summary.id=\"summaryPreview\";\n      summary.style.cssText=\"background:#ffffff;padding:30px;border-radius:8px;border:1px solid var(--border);max-width:100%;font-family:var(--font);line-height:1.8;color:var(--text);\";\n      fs.appendChild(summary);\n      root.appendChild(fs);\n      \n      updateSummary();\n    }\n    function updateSummary(){\n      const el=$(\"#summaryPreview\");\n      if(!el) return;\n      \n      const d = state.data;\n      \n      \/\/ Riempi automaticamente il campo \"companyName\" degli utenti se vuoto\n      \/\/ Usa la ragione sociale (clientName) dalla Tab 3 come default\n      const defaultCompany = d.company?.clientName || '';\n      if (d.users && d.users.length > 0) {\n        d.users.forEach(user => {\n          if (!user.companyName || user.companyName.trim() === '') {\n            user.companyName = defaultCompany;\n          }\n        });\n      }\n      \n      const formatDate = (dateStr) => {\n        if(!dateStr) return \"\u2014\";\n        try {\n          return new Date(dateStr).toLocaleDateString(\"it-IT\", {year: 'numeric', month: 'long', day: 'numeric'});\n        } catch { return dateStr; }\n      };\n      const formatDateTime = (dateStr) => {\n        if(!dateStr) return \"\u2014\";\n        try {\n          const date = new Date(dateStr);\n          return date.toLocaleString(\"it-IT\", {\n            year: 'numeric', \n            month: 'long', \n            day: 'numeric',\n            hour: '2-digit',\n            minute: '2-digit',\n            second: '2-digit'\n          });\n        } catch { return dateStr; }\n      };\n      const formatFileSize = (bytes) => {\n        if(!bytes) return \"\";\n        if(bytes < 1024) return bytes + \" B\";\n        if(bytes < 1024 * 1024) return (bytes \/ 1024).toFixed(2) + \" KB\";\n        return (bytes \/ (1024 * 1024)).toFixed(2) + \" MB\";\n      };\n      \n      const requestForLabels = {\n        \"new_onboarding\": t(\"newOnboarding\"),\n        \"update_client\": t(\"updateClient\")\n      };\n      \n      const endUserTypeLabels = {\n        \"wholesaler\": t(\"wholesaler\"),\n        \"dispenser\": t(\"dispenser\"),\n        \"nca\": t(\"nca\"),\n        \"other\": t(\"other\")\n      };\n      \n      const roleLabels = {\n        \"admin\": \"ADMIN\",\n        \"regular\": \"Regular\"\n      };\n      \n      let html = `\n        <div style=\"margin-bottom:30px;padding-bottom:20px;border-bottom:2px solid var(--nmvo-blue);\">\n          <h2 style=\"color:var(--nmvo-blue);margin:0 0 10px 0;font-size:24px;\">${t(\"summaryTitle\")}<\/h2>\n          <p style=\"color:var(--muted);margin:0;font-size:14px;\">${t(\"generatedOn\")} ${formatDateTime(d.meta.createdAt)}<\/p>\n          <p style=\"color:var(--muted);margin:5px 0 0 0;font-size:12px;\">Timestamp: ${new Date().toISOString()}<\/p>\n        <\/div>\n        \n        <div style=\"margin-bottom:30px;\">\n          <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"section1Data\")}<\/h3>\n          <table style=\"width:100%;border-collapse:collapse;\">\n            <tr><td style=\"padding:8px 0;width:200px;font-weight:600;color:var(--text);\">${t(\"firstName\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.requestor.firstName||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"lastName\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.requestor.lastName||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"company\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.requestor.company||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"email\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.requestor.email||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"phoneCol\")}:<\/td><td style=\"padding:8px 0;\">${esc((d.requestor.phonePrefix||\"\") + \" \" + (d.requestor.phone||\"\u2014\"))}<\/td><\/tr>\n          <\/table>\n        <\/div>\n        \n        <div style=\"margin-bottom:30px;\">\n          <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"section2Request\")}<\/h3>\n          <table style=\"width:100%;border-collapse:collapse;\">\n            <tr><td style=\"padding:8px 0;width:200px;font-weight:600;\">${t(\"requestTypeLabelSummary\")}<\/td><td style=\"padding:8px 0;\">${esc(requestForLabels[d.request.requestFor]||d.request.requestFor||\"\u2014\")}<\/td><\/tr>\n            ${d.request.nmvsClientId ? `<tr><td style=\"padding:8px 0;font-weight:600;\">NMVS Client ID:<\/td><td style=\"padding:8px 0;\">${esc(d.request.nmvsClientId)}<\/td><\/tr>` : \"\"}\n            ${d.request.referenceTicket ? `<tr><td style=\"padding:8px 0;font-weight:600;\">Riferimento \/ ticket:<\/td><td style=\"padding:8px 0;\">${esc(d.request.referenceTicket)}<\/td><\/tr>` : \"\"}\n          <\/table>\n        <\/div>\n        \n        <div style=\"margin-bottom:30px;\">\n          <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"section3Company\")}<\/h3>\n          <table style=\"width:100%;border-collapse:collapse;\">\n            <tr><td style=\"padding:8px 0;width:200px;font-weight:600;\">${t(\"legalName\")}<\/td><td style=\"padding:8px 0;\">${esc(d.company.clientName||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"codiceSisLabel\")}<\/td><td style=\"padding:8px 0;\">${esc((() => {\n              const raw = d.company.codiceIdentificativoSitoLogistico ?? d.company.codiceSis;\n              return Array.isArray(raw) ? raw.filter(Boolean).join(\", \") || \"\u2014\" : (raw || \"\u2014\");\n            })())}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"piva\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.company.piva||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"endUserTypeLabel\")}<\/td><td style=\"padding:8px 0;\">${esc((endUserTypeLabels[d.company.endUserType]||d.company.endUserType||\"\u2014\") + (d.company.endUserTypeOther ? ` - ${esc(d.company.endUserTypeOther)}` : \"\"))}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"address\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.company.street||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"zip\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.company.zip||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"city\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.company.city||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"country\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.company.country||\"\u2014\")}<\/td><\/tr>\n          <\/table>\n        <\/div>\n\n        <div style=\"margin-bottom:30px;\">\n          <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"mainContactSummaryTitle\")}<\/h3>\n          <table style=\"width:100%;border-collapse:collapse;\">\n            <tr><td style=\"padding:8px 0;width:200px;font-weight:600;\">${t(\"mcNameLabel\")}<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.firstLastName||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"mcEmailLabel\")}<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.email||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"mcCompanyLabel\")}<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.company||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"mcDivisionLabel\")}<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.division||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"address\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.street||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"zip\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.zip||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"city\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.city||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"country\")}:<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.country||\"\u2014\")}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"mcPhoneLabel\")}<\/td><td style=\"padding:8px 0;\">${esc(d.mainContact&&d.mainContact.phone||\"\u2014\")}<\/td><\/tr>\n          <\/table>\n        <\/div>\n      `;\n      \n      if(d.integration.hasExternalSystem !== null) {\n        html += `\n          <div style=\"margin-bottom:30px;\">\n            <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"section4Integration\")}<\/h3>\n            <table style=\"width:100%;border-collapse:collapse;\">\n              <tr><td style=\"padding:8px 0;width:200px;font-weight:600;\">${t(\"externalSystemPresent\")}<\/td><td style=\"padding:8px 0;\">${d.integration.hasExternalSystem === true ? t(\"yes\") : d.integration.hasExternalSystem === false ? t(\"no\") : \"\u2014\"}<\/td><\/tr>\n              ${d.integration.hasExternalSystem === true ? `\n                <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"softwareCompany\")}<\/td><td style=\"padding:8px 0;\">${esc(d.integration.providerCompany||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"softwareNameLabel\")}<\/td><td style=\"padding:8px 0;\">${esc(d.integration.softwareName||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"versionLabel\")}<\/td><td style=\"padding:8px 0;\">${esc(d.integration.version||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"baselineTestingEvidence\")}<\/td><td style=\"padding:8px 0;\">${esc(d.integration.proofBaselineTesting||\"\u2014\")}<\/td><\/tr>\n              ` : \"\"}\n            <\/table>\n          <\/div>\n        `;\n      }\n      \n      if(d.request.requestFor !== \"update_client\") {\n        html += `\n          <div style=\"margin-bottom:30px;\">\n            <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"section5Users\")}<\/h3>\n            ${d.users.length === 0 ? `<p style=\"color:var(--muted);\">${t(\"noUsersEntered\")}<\/p>` : \"\"}\n        `;\n        \n        d.users.forEach((u, idx) => {\n          const requestTypeLabels = {\"new\": t(\"newAccount\"), \"update\": t(\"updateAccount\"), \"retire\": t(\"retireAccount\")};\n          html += `\n            <div style=\"margin-bottom:20px;padding:15px;background:#f9fafb;border-radius:8px;border:1px solid var(--border);\">\n              <h4 style=\"color:var(--nmvo-blue);margin:0 0 10px 0;font-size:16px;\">${t(\"userN\")}${idx+1}<\/h4>\n              <table style=\"width:100%;border-collapse:collapse;\">\n                <tr><td style=\"padding:6px 0;width:180px;font-weight:600;\">${t(\"requestTypeCol\")}<\/td><td style=\"padding:6px 0;\">${esc(requestTypeLabels[u.requestType]||u.requestType||\"\u2014\")}<\/td><\/tr>\n                ${u.userId ? `<tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"userID\")}<\/td><td style=\"padding:6px 0;\">${esc(u.userId)}<\/td><\/tr>` : \"\"}\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"firstName\")}:<\/td><td style=\"padding:6px 0;\">${esc(u.firstName||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"lastName\")}:<\/td><td style=\"padding:6px 0;\">${esc(u.lastName||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"emailCol\")}<\/td><td style=\"padding:6px 0;\">${esc(u.email||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"phoneCol\")}<\/td><td style=\"padding:6px 0;\">${esc(u.phone||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"companyCol\")}<\/td><td style=\"padding:6px 0;\">${esc(u.companyName||\"\u2014\")}<\/td><\/tr>\n                ${(u.codiceIdentificativoSitoLogistico || u.division) ? `<tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"divisionCol\")}<\/td><td style=\"padding:6px 0;\">${esc(u.codiceIdentificativoSitoLogistico || u.division)}<\/td><\/tr>` : \"\"}\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"address\")}:<\/td><td style=\"padding:6px 0;\">${esc(u.street||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"zip\")}:<\/td><td style=\"padding:6px 0;\">${esc(u.zip||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"city\")}:<\/td><td style=\"padding:6px 0;\">${esc(u.city||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"country\")}:<\/td><td style=\"padding:6px 0;\">${esc(u.country||\"\u2014\")}<\/td><\/tr>\n                <tr><td style=\"padding:6px 0;font-weight:600;\">${t(\"roleCol\")}<\/td><td style=\"padding:6px 0;\">${esc(roleLabels[u.role]||u.role||\"\u2014\")}<\/td><\/tr>\n              <\/table>\n            <\/div>\n          `;\n        });\n        \n        html += `<\/div>`;\n      }\n      \n      html += `\n        <div style=\"margin-bottom:30px;\">\n          <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"section6Terms\")}<\/h3>\n          <table style=\"width:100%;border-collapse:collapse;\">\n            <tr><td style=\"padding:8px 0;width:200px;font-weight:600;\">${t(\"declarations\")}<\/td><td style=\"padding:8px 0;\">${d.terms.declarationsAck ? t(\"accepted\") : \"\u2014\"}<\/td><\/tr>\n            <tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"authArt100\")}<\/td><td style=\"padding:8px 0;\">${d.terms.authorizations.wholesaleArt100 ? t(\"yes\") : \"\u2014\"}<\/td><\/tr>\n            ${d.terms.authorizations.designatedWholesaler ? `<tr><td style=\"padding:8px 0;font-weight:600;\">Designated Wholesaler:<\/td><td style=\"padding:8px 0;\">${t(\"yes\")}<\/td><\/tr>` : \"\"}\n            ${d.terms.authorizations.other ? `<tr><td style=\"padding:8px 0;font-weight:600;\">${t(\"otherAuthorizations\")}<\/td><td style=\"padding:8px 0;\">${esc(d.terms.authorizations.otherText||\"\u2713 S\u00ec\")}<\/td><\/tr>` : \"\"}\n          <\/table>\n        <\/div>\n      `;\n      \n      \/\/ Sezione Allegati\n      const hasIntegrationAttachments = d.integration.attachments && d.integration.attachments.length > 0;\n      const hasAuthAttachments = d.terms.authorizations.attachments && d.terms.authorizations.attachments.length > 0;\n      \n      if(hasIntegrationAttachments || hasAuthAttachments) {\n        html += `\n          <div style=\"margin-bottom:30px;\">\n            <h3 style=\"color:var(--nmvo-blue);margin:0 0 15px 0;font-size:18px;padding-bottom:8px;border-bottom:1px solid var(--border);\">${t(\"section7Attachments\")}<\/h3>\n            <table style=\"width:100%;border-collapse:collapse;\">\n        `;\n        \n        if(hasIntegrationAttachments) {\n          html += `\n            <tr>\n              <td colspan=\"2\" style=\"padding:12px 0 8px 0;font-weight:600;color:var(--nmvo-blue);border-top:1px solid var(--border);\">${t(\"integrationDocs\")}<\/td>\n            <\/tr>\n          `;\n          d.integration.attachments.forEach((att, idx) => {\n            html += `\n              <tr>\n                <td style=\"padding:6px 0 6px 20px;width:200px;\">${t(\"attachmentN\")} ${idx+1}:<\/td>\n                <td style=\"padding:6px 0;\">\n                  <span style=\"font-weight:600;\">${esc(att.name)}<\/span>\n                  ${att.size ? ` <span style=\"color:var(--muted);font-size:13px;\">(${formatFileSize(att.size)})<\/span>` : \"\"}\n                <\/td>\n              <\/tr>\n            `;\n          });\n        }\n        \n        if(hasAuthAttachments) {\n          html += `\n            <tr>\n              <td colspan=\"2\" style=\"padding:12px 0 8px 0;font-weight:600;color:var(--nmvo-blue);border-top:1px solid var(--border);\">${t(\"authDocs\")}<\/td>\n            <\/tr>\n          `;\n          d.terms.authorizations.attachments.forEach((att, idx) => {\n            html += `\n              <tr>\n                <td style=\"padding:6px 0 6px 20px;width:200px;\">${t(\"attachmentN\")} ${idx+1}:<\/td>\n                <td style=\"padding:6px 0;\">\n                  <span style=\"font-weight:600;\">${esc(att.name)}<\/span>\n                  ${att.size ? ` <span style=\"color:var(--muted);font-size:13px;\">(${formatFileSize(att.size)})<\/span>` : \"\"}\n                <\/td>\n              <\/tr>\n            `;\n          });\n        }\n        \n        html += `\n            <\/table>\n          <\/div>\n        `;\n      }\n      \n      el.innerHTML = html;\n    }\n\n    \/\/ Utility functions\n    function esc(str){\n      if(!str) return \"\";\n      const div=document.createElement(\"div\");\n      div.textContent=str;\n      return div.innerHTML;\n    }\n\n    function toast(msg){\n      const t=document.createElement(\"div\");\n      t.textContent=msg;\n      t.style.cssText=\"position:fixed;top:20px;right:20px;background:var(--danger);color:white;padding:12px 16px;border-radius:8px;z-index:9999;box-shadow:var(--shadow);\";\n      document.body.appendChild(t);\n      setTimeout(()=>t.remove(),3000);\n    }\n\n    function saveDraft(){\n      try{\n        localStorage.setItem(STORAGE_KEY,JSON.stringify(state.data));\n      }catch(e){console.error(\"Save failed\",e);}\n    }\n\n    function loadDraft(){\n      try{\n        const s=localStorage.getItem(STORAGE_KEY);\n        if(s) return JSON.parse(s);\n      }catch(e){console.error(\"Load failed\",e);}\n      return null;\n    }\n\n    function sanitizeClientName(name){\n      if(!name) return \"CLIENT\";\n      const trimmed = name.trim();\n      if(!trimmed) return \"CLIENT\";\n      return trimmed\n        .toLowerCase()\n        .replace(\/\\s+\/g,\"-\")\n        .replace(\/[^a-z0-9\\-]+\/g,\"\")\n        .substring(0,40);\n    }\n\n    function generateJsonBlob(){\n      \/\/ Crea una copia dei dati per non modificare lo state originale\n      const dataCopy = JSON.parse(JSON.stringify(state.data));\n      \n      \/\/ Riempi automaticamente il campo \"companyName\" degli utenti se vuoto\n      \/\/ Usa la ragione sociale (clientName) dalla Tab 3 come default\n      const defaultCompany = dataCopy.company?.clientName || '';\n      if (dataCopy.users && dataCopy.users.length > 0) {\n        dataCopy.users.forEach(user => {\n          if (!user.companyName || user.companyName.trim() === '') {\n            user.companyName = defaultCompany;\n          }\n        });\n      }\n      \n      return new Blob([JSON.stringify(dataCopy,null,2)],{type:\"application\/json\"});\n    }\n\n    function downloadJson(){\n      const blob=generateJsonBlob();\n      const clientSlug = sanitizeClientName(state.data.requestor && state.data.requestor.company);\n      const url=URL.createObjectURL(blob);\n      const a=document.createElement(\"a\");\n      a.href=url;\n      a.download=`nmvo-onboarding-${clientSlug}-${new Date().toISOString().split(\"T\")[0]}.json`;\n      a.click();\n      URL.revokeObjectURL(url);\n    }\n\n    function buildPdfDoc(){\n      const { jsPDF } = window.jspdf;\n      const doc = new jsPDF();\n      const margin = 20;\n      let y = margin;\n      const lineHeight = 7;\n      const pageHeight = doc.internal.pageSize.height;\n      \n      const d = state.data;\n      \n      \/\/ Riempi automaticamente il campo \"companyName\" degli utenti se vuoto\n      \/\/ Usa la ragione sociale (clientName) dalla Tab 3 come default\n      const defaultCompany = d.company?.clientName || '';\n      if (d.users && d.users.length > 0) {\n        d.users.forEach(user => {\n          if (!user.companyName || user.companyName.trim() === '') {\n            user.companyName = defaultCompany;\n          }\n        });\n      }\n      \n      const formatDateTime = (dateStr) => {\n        if(!dateStr) return \"\u2014\";\n        try {\n          const date = new Date(dateStr);\n          return date.toLocaleString(\"it-IT\", {\n            year: 'numeric', \n            month: 'long', \n            day: 'numeric',\n            hour: '2-digit',\n            minute: '2-digit',\n            second: '2-digit'\n          });\n        } catch { return dateStr; }\n      };\n      const formatFileSize = (bytes) => {\n        if(!bytes) return \"\";\n        if(bytes < 1024) return bytes + \" B\";\n        if(bytes < 1024 * 1024) return (bytes \/ 1024).toFixed(2) + \" KB\";\n        return (bytes \/ (1024 * 1024)).toFixed(2) + \" MB\";\n      };\n      \n      \/\/ Header\n      doc.setFontSize(20);\n      doc.setFont(\"helvetica\", \"bold\");\n      doc.setTextColor(0, 82, 165); \/\/ NMVO blue\n      doc.text(t(\"summaryTitle\"), margin, y);\n      y += lineHeight * 1.5;\n      \n      doc.setFontSize(10);\n      doc.setFont(\"helvetica\", \"normal\");\n      doc.setTextColor(107, 114, 128); \/\/ muted color\n      doc.text(`${t(\"generatedOn\")} ${formatDateTime(d.meta.createdAt)}`, margin, y);\n      y += lineHeight;\n      doc.setFontSize(9);\n      doc.text(`Timestamp: ${new Date().toISOString()}`, margin, y);\n      y += lineHeight * 2;\n      \n      \/\/ Linea separatrice\n      doc.setDrawColor(0, 82, 165);\n      doc.setLineWidth(0.5);\n      doc.line(margin, y, doc.internal.pageSize.width - margin, y);\n      y += lineHeight * 2;\n      \n      \/\/ Funzione helper per aggiungere testo con gestione pagina\n      const addText = (label, value, isBold = false, indent = 0) => {\n        if(y > pageHeight - 30) {\n          doc.addPage();\n          y = margin;\n        }\n        doc.setFont(\"helvetica\", isBold ? \"bold\" : \"normal\");\n        doc.setFontSize(10);\n        doc.setTextColor(31, 41, 55); \/\/ text color\n        const labelX = margin + indent;\n        const valueX = margin + indent + 55; \/\/ distanza orizzontale maggiore tra etichetta e valore\n        if(label) {\n          const fullLabel = label + \":\";\n          const isLongLogisticsLabel =\n            fullLabel.startsWith(\"Codice identificativo Sito Logistico\") ||\n            fullLabel.startsWith(\"Logistics site identifier code\");\n\n          if (isLongLogisticsLabel) {\n            \/\/ Etichetta su pi\u00f9 righe, valore sulla riga successiva\n            doc.setFont(\"helvetica\", \"bold\");\n            const labelLines = doc.splitTextToSize(fullLabel, 80);\n            doc.text(labelLines, labelX, y);\n            doc.setFont(\"helvetica\", \"normal\");\n\n            const valueLines = doc.splitTextToSize(value || \"\u2014\", 170 - indent);\n            const valueY = y + (labelLines.length * lineHeight);\n            doc.text(valueLines, valueX, valueY);\n            y = valueY + (valueLines.length * lineHeight) + (lineHeight * 0.3);\n            return;\n          } else {\n            doc.setFont(\"helvetica\", \"bold\");\n            doc.text(fullLabel, labelX, y);\n            doc.setFont(\"helvetica\", \"normal\");\n          }\n        }\n        const lines = doc.splitTextToSize(value || \"\u2014\", 170 - indent);\n        \/\/ Valori allineati verticalmente all'etichetta, con pi\u00f9 spazio tra le righe\n        doc.text(lines, label ? valueX : labelX, y);\n        y += (lines.length * lineHeight) + (label ? lineHeight * 0.5 : 0);\n      };\n      \n      const addSection = (title) => {\n        if(y > pageHeight - 40) {\n          doc.addPage();\n          y = margin;\n        }\n        y += lineHeight;\n        doc.setFontSize(14);\n        doc.setFont(\"helvetica\", \"bold\");\n        doc.setTextColor(0, 82, 165); \/\/ NMVO blue\n        doc.text(title, margin, y);\n        y += lineHeight;\n        \/\/ Linea sotto il titolo\n        doc.setDrawColor(0, 82, 165);\n        doc.setLineWidth(0.3);\n        doc.line(margin, y, margin + 50, y);\n        y += lineHeight * 1.5;\n      };\n      \n      addSection(t(\"section1Data\"));\n      addText(t(\"firstName\"), d.requestor.firstName || \"\u2014\");\n      addText(t(\"lastName\"), d.requestor.lastName || \"\u2014\");\n      addText(t(\"company\"), d.requestor.company || \"\u2014\");\n      addText(t(\"email\"), d.requestor.email || \"\u2014\");\n      addText(t(\"phoneCol\"), (d.requestor.phonePrefix || \"\") + \" \" + (d.requestor.phone || \"\u2014\"));\n      \n      addSection(t(\"section2Request\"));\n      const requestForLabelsPdf = {\n        \"new_onboarding\": t(\"newOnboarding\"),\n        \"update_client\": t(\"updateClient\")\n      };\n      addText(t(\"requestTypeLabelSummary\").replace(\":\", \"\"), requestForLabelsPdf[d.request.requestFor] || d.request.requestFor || \"\u2014\");\n      if(d.request.nmvsClientId) {\n        addText(t(\"nmvsClientId\"), d.request.nmvsClientId);\n      }\n      if(d.request.referenceTicket) {\n        addText(t(\"referenceTicket\").replace(\" (se presente)\", \"\"), d.request.referenceTicket);\n      }\n      \n      addSection(t(\"section3Company\"));\n      addText(t(\"legalName\").replace(\":\", \"\"), d.company.clientName || \"\u2014\");\n      const codiciLogisticiRaw = d.company.codiceIdentificativoSitoLogistico ?? d.company.codiceSis;\n      addText(t(\"codiceSisLabel\").replace(\":\", \"\"), Array.isArray(codiciLogisticiRaw) ? codiciLogisticiRaw.filter(Boolean).join(\", \") || \"\u2014\" : (codiciLogisticiRaw || \"\u2014\"));\n      addText(t(\"piva\"), d.company.piva || \"\u2014\");\n      const endUserTypeLabelsPdf = {\n        \"wholesaler\": t(\"wholesaler\"),\n        \"dispenser\": t(\"dispenser\"),\n        \"nca\": t(\"nca\"),\n        \"other\": t(\"other\")\n      };\n      addText(t(\"endUserTypeLabel\").replace(\":\", \"\"), (endUserTypeLabelsPdf[d.company.endUserType] || d.company.endUserType || \"\u2014\") + \n        (d.company.endUserTypeOther ? ` - ${d.company.endUserTypeOther}` : \"\"));\n      addText(t(\"address\"), d.company.street || \"\u2014\");\n      addText(t(\"zip\"), d.company.zip || \"\u2014\");\n      addText(t(\"city\"), d.company.city || \"\u2014\");\n      addText(t(\"country\"), d.company.country || \"\u2014\");\n\n      addSection(t(\"mainContactSummaryTitle\"));\n      addText(t(\"mcNameLabel\").replace(\":\", \"\"), d.mainContact && d.mainContact.firstLastName || \"\u2014\");\n      addText(t(\"mcEmailLabel\").replace(\":\", \"\"), d.mainContact && d.mainContact.email || \"\u2014\");\n      addText(t(\"mcCompanyLabel\").replace(\":\", \"\"), d.mainContact && d.mainContact.company || \"\u2014\");\n      addText(t(\"mcDivisionLabel\").replace(\":\", \"\"), d.mainContact && d.mainContact.division || \"\u2014\");\n      addText(t(\"address\"), d.mainContact && d.mainContact.street || \"\u2014\");\n      addText(t(\"zip\"), d.mainContact && d.mainContact.zip || \"\u2014\");\n      addText(t(\"city\"), d.mainContact && d.mainContact.city || \"\u2014\");\n      addText(t(\"country\"), d.mainContact && d.mainContact.country || \"\u2014\");\n      addText(t(\"mcPhoneLabel\").replace(\":\", \"\"), d.mainContact && d.mainContact.phone || \"\u2014\");\n      \n      if(d.integration.hasExternalSystem !== null) {\n        addSection(t(\"section4Integration\"));\n        addText(t(\"externalSystemPresent\").replace(\":\", \"\"), d.integration.hasExternalSystem === true ? t(\"yes\") : \n          d.integration.hasExternalSystem === false ? t(\"no\") : \"\u2014\");\n        if(d.integration.hasExternalSystem === true) {\n          addText(t(\"softwareCompany\").replace(\":\", \"\"), d.integration.providerCompany || \"\u2014\");\n          addText(t(\"softwareNameLabel\").replace(\":\", \"\"), d.integration.softwareName || \"\u2014\");\n          addText(t(\"versionLabel\").replace(\":\", \"\"), d.integration.version || \"\u2014\");\n          addText(t(\"baselineTestingEvidence\").replace(\":\", \"\"), d.integration.proofBaselineTesting || \"\u2014\");\n        }\n      }\n      \n      if(d.request.requestFor !== \"update_client\") {\n        addSection(t(\"section5Users\"));\n        if(d.users.length === 0) {\n          addText(\"\", t(\"noUsersEntered\"));\n        } else {\n          d.users.forEach((u, idx) => {\n            if(y > pageHeight - 50) {\n              doc.addPage();\n              y = margin;\n            }\n            doc.setFontSize(12);\n            doc.setFont(\"helvetica\", \"bold\");\n            doc.setTextColor(0, 82, 165);\n            doc.text(`${t(\"userN\")}${idx + 1}`, margin, y);\n            y += lineHeight * 1.5;\n            const requestTypeLabelsPdfU = {\"new\": t(\"newAccount\"), \"update\": t(\"updateAccount\"), \"retire\": t(\"retireAccount\")};\n            addText(t(\"requestTypeCol\").replace(\":\", \"\"), requestTypeLabelsPdfU[u.requestType] || u.requestType || \"\u2014\", false, 0);\n            if(u.userId) addText(t(\"userID\").replace(\":\", \"\"), u.userId, false, 0);\n            addText(t(\"firstLastNameCol\").replace(\":\", \"\"), ((u.firstName || '') + ' ' + (u.lastName || '')).trim() || \"\u2014\", false, 0);\n            addText(t(\"emailCol\").replace(\":\", \"\"), u.email || \"\u2014\", false, 0);\n            addText(t(\"phoneCol\").replace(\":\", \"\"), u.phone || \"\u2014\", false, 0);\n            addText(t(\"companyCol\").replace(\":\", \"\"), u.companyName || \"\u2014\", false, 0);\n            const userDivision = (u.codiceIdentificativoSitoLogistico || u.division);\n            if(userDivision) addText(t(\"divisionCol\").replace(\":\", \"\"), userDivision, false, 0);\n            addText(t(\"address\"), u.street || \"\u2014\", false, 0);\n            addText(t(\"zip\"), u.zip || \"\u2014\", false, 0);\n            addText(t(\"city\"), u.city || \"\u2014\", false, 0);\n            addText(t(\"country\"), u.country || \"\u2014\", false, 0);\n            addText(t(\"roleCol\").replace(\":\", \"\"), u.role === \"admin\" ? \"ADMIN\" : u.role === \"regular\" ? \"Regular\" : u.role || \"\u2014\", false, 0);\n            y += lineHeight;\n          });\n        }\n      }\n      \n      addSection(t(\"section6Terms\"));\n      addText(t(\"declarations\").replace(\":\", \"\"), d.terms.declarationsAck ? t(\"accepted\") : \"\u2014\");\n      addText(t(\"authArt100\").replace(\":\", \"\"), d.terms.authorizations.wholesaleArt100 ? t(\"yes\") : \"\u2014\");\n      if(d.terms.authorizations.designatedWholesaler) addText(\"Designated Wholesaler\", t(\"yes\"));\n      if(d.terms.authorizations.other) {\n        addText(t(\"otherAuthorizations\").replace(\":\", \"\"), d.terms.authorizations.otherText || t(\"yes\"));\n      }\n      \n      const hasIntegrationAttachments = d.integration.attachments && d.integration.attachments.length > 0;\n      const hasAuthAttachments = d.terms.authorizations.attachments && d.terms.authorizations.attachments.length > 0;\n      \n      if(hasIntegrationAttachments || hasAuthAttachments) {\n        addSection(t(\"section7Attachments\"));\n        if(hasIntegrationAttachments) {\n          doc.setFont(\"helvetica\", \"bold\");\n          doc.setTextColor(0, 82, 165);\n          doc.setFontSize(10);\n          doc.text(t(\"integrationDocs\") + \":\", margin, y);\n          y += lineHeight * 1.2;\n          d.integration.attachments.forEach((att, idx) => {\n            addText(`${t(\"attachmentN\")} ${idx+1}`, att.name + (att.size ? ` (${formatFileSize(att.size)})` : \"\"), false, 0);\n          });\n          y += lineHeight;\n        }\n        if(hasAuthAttachments) {\n          if(hasIntegrationAttachments) {\n            doc.setDrawColor(200, 200, 200);\n            doc.setLineWidth(0.2);\n            doc.line(margin, y, doc.internal.pageSize.width - margin, y);\n            y += lineHeight;\n          }\n          doc.setFont(\"helvetica\", \"bold\");\n          doc.setTextColor(0, 82, 165);\n          doc.setFontSize(10);\n          doc.text(t(\"authDocs\") + \":\", margin, y);\n          y += lineHeight * 1.2;\n          d.terms.authorizations.attachments.forEach((att, idx) => {\n            addText(`${t(\"attachmentN\")} ${idx+1}`, att.name + (att.size ? ` (${formatFileSize(att.size)})` : \"\"), false, 0);\n          });\n        }\n      }\n      \n      const totalPages = doc.internal.pages.length - 1;\n      for(let i = 1; i <= totalPages; i++) {\n        doc.setPage(i);\n        doc.setFontSize(8);\n        doc.text(`${t(\"pageOf\")} ${i} ${t(\"of\")} ${totalPages}`, margin, pageHeight - 10);\n      }\n      \n      return doc;\n    }\n\n    function generatePdfBlob(){\n      const doc = buildPdfDoc();\n      return doc.output(\"blob\");\n    }\n\n    function downloadPdf(){\n      const doc = buildPdfDoc();\n      const clientSlug = sanitizeClientName(state.data.requestor && state.data.requestor.company);\n      const filename = `nmvo-onboarding-${clientSlug}-${new Date().toISOString().split(\"T\")[0]}.pdf`;\n      doc.save(filename);\n      toast(t(\"pdfDownloaded\"));\n    }\n\n    \/\/ Funzione per generare Client ID dalla ragione sociale\n    \/\/ Converte in maiuscolo e mantiene solo caratteri alfanumerici (lettere e numeri)\n    function generateClientId(clientName) {\n      if (!clientName || typeof clientName !== 'string') return '';\n      \/\/ Rimuovi tutti i caratteri non alfanumerici e converti in maiuscolo\n      return clientName\n        .toUpperCase()\n        .replace(\/[^A-Z0-9]\/g, '');\n    }\n\n    function buildExcelWorkbook(){\n      \/\/ Prova window.XLSX o XLSX globale\n      const XLSXLib = window.XLSX || (typeof XLSX !== 'undefined' ? XLSX : null);\n      if (!XLSXLib || typeof XLSXLib !== 'object' || !XLSXLib.utils || !XLSXLib.utils.aoa_to_sheet) {\n        console.error('XLSX status:', {\n          windowXLSX: typeof window.XLSX,\n          globalXLSX: typeof XLSX,\n          XLSXLib: XLSXLib,\n          hasUtils: XLSXLib && XLSXLib.utils\n        });\n        throw new Error(\"XLSX library not available\");\n      }\n\n      const d = state.data;\n\n      \/\/ Genera e popola automaticamente il Client ID dalla Ragione Sociale\n      \/\/ Converte la ragione sociale in formato alfanumerico maiuscolo\n      if (d.company && d.company.clientName) {\n        d.company.clientIdExisting = generateClientId(d.company.clientName);\n      }\n\n      const flattenObject = (obj, prefix = '', result = {}) => {\n        for (const key in obj) {\n          if (obj.hasOwnProperty(key)) {\n            const newKey = prefix ? `${prefix}.${key}` : key;\n            const value = obj[key];\n\n            if (value === null || value === undefined) {\n              result[newKey] = '';\n            } else if (Array.isArray(value)) {\n              if (value.length === 0) {\n                result[newKey] = '';\n              } else {\n                \/\/ Caso speciale: codiceIdentificativoSitoLogistico viene concatenato con \" - \"\n                if (newKey === 'company.codiceIdentificativoSitoLogistico') {\n                  try {\n                    \/\/ Filtra e converti tutti gli elementi a stringhe\n                    const filtered = value\n                      .filter(v => v !== null && v !== undefined && v !== '')\n                      .map(v => String(v));\n                    result[newKey] = filtered.length > 0 ? filtered.join(' - ') : '';\n                  } catch (error) {\n                    console.error('Errore concatenazione codiceIdentificativoSitoLogistico:', error, 'value:', value);\n                    result[newKey] = '';\n                  }\n                } else {\n                  value.forEach((item, idx) => {\n                    if (typeof item === 'object' && item !== null) {\n                      flattenObject(item, `${newKey}[${idx}]`, result);\n                    } else {\n                      result[`${newKey}[${idx}]`] = String(item);\n                    }\n                  });\n                }\n              }\n            } else if (typeof value === 'object' && value !== null && !(value instanceof Date)) {\n              flattenObject(value, newKey, result);\n            } else if (value instanceof Date) {\n              result[newKey] = formatDateForExcel(value);\n            } else if (typeof value === 'boolean') {\n              result[newKey] = value ? 'S\u00ec' : 'No';\n            } else {\n              result[newKey] = String(value);\n            }\n          }\n        }\n        return result;\n      };\n\n      \/\/ --- Sheet 1: Onboarding (dati statici, senza users) ---\n      const dataWithoutUsers = {};\n      for (const section in d) {\n        if (section !== 'users') dataWithoutUsers[section] = d[section];\n      }\n      const flattened = flattenObject(dataWithoutUsers);\n      const onbHeaders = Object.keys(flattened).filter(h => h && h !== 'undefined');\n      const onbValues = onbHeaders.map(key => flattened[key] ?? '');\n      const wsOnb = XLSXLib.utils.aoa_to_sheet([onbHeaders, onbValues]);\n      wsOnb['!cols'] = onbHeaders.map(() => ({ wch: 30 }));\n\n      \/\/ --- Sheet 2: Users (una riga per utente, header senza prefisso) ---\n      \/\/ Riempi automaticamente il campo \"companyName\" degli utenti se vuoto\n      \/\/ Usa la ragione sociale (clientName) dalla Tab 3 come default\n      const defaultCompany = d.company?.clientName || '';\n      if (d.users && d.users.length > 0) {\n        d.users.forEach(user => {\n          if (!user.companyName || user.companyName.trim() === '') {\n            user.companyName = defaultCompany;\n          }\n        });\n      }\n      \n      const userFields = [\n        'requestType','userId','firstName','lastName','email','phone',\n        'companyName','codiceIdentificativoSitoLogistico','street','zip','city','country','role'\n      ];\n      const userRows = (d.users || []).map(u =>\n        userFields.map(f => {\n          if (f === 'companyName') {\n            const clientId = d.company?.clientIdExisting;\n            return clientId === null || clientId === undefined ? '' : String(clientId);\n          }\n          const v = u[f];\n          if (v === null || v === undefined) return '';\n          if (typeof v === 'boolean') return v ? 'S\u00ec' : 'No';\n          return String(v);\n        })\n      );\n      const wsUsers = XLSXLib.utils.aoa_to_sheet([userFields, ...userRows]);\n      \/\/ Larghezze colonne identiche al file server (nmvo.xlsx)\n      wsUsers['!cols'] = [\n        { wch: 15 },  \/\/ requestType\n        { wch: 20 },  \/\/ userId\n        { wch: 20 },  \/\/ firstName\n        { wch: 20 },  \/\/ lastName\n        { wch: 35 },  \/\/ email\n        { wch: 20 },  \/\/ phone\n        { wch: 30 },  \/\/ companyName\n        { wch: 35 },  \/\/ codiceIdentificativoSitoLogistico\n        { wch: 40 },  \/\/ street\n        { wch: 15 },  \/\/ zip\n        { wch: 35 },  \/\/ city\n        { wch: 20 },  \/\/ country\n        { wch: 25 }   \/\/ role\n      ];\n\n      const wb = XLSXLib.utils.book_new();\n      XLSXLib.utils.book_append_sheet(wb, wsOnb, 'Onboarding');\n      XLSXLib.utils.book_append_sheet(wb, wsUsers, 'Users');\n      return { wb, XLSXLib };\n    }\n\n    function generateExcelBlob(){\n      const { wb, XLSXLib } = buildExcelWorkbook();\n      const wbout = XLSXLib.write(wb, { bookType:'xlsx', type:'array' });\n      return new Blob([wbout], { type:'application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });\n    }\n\n    function downloadExcel(){\n      try {\n        const { wb, XLSXLib } = buildExcelWorkbook();\n        const clientSlug = sanitizeClientName(state.data.requestor && state.data.requestor.company);\n        const filename = `nmvo-onboarding-${clientSlug}-${new Date().toISOString().split(\"T\")[0]}.xlsx`;\n        XLSXLib.writeFile(wb, filename);\n        toast(t(\"excelDownloaded\"));\n      } catch (error) {\n        console.error(\"Errore durante la generazione dell'Excel:\", error);\n        toast(t(\"excelGenError\") + \" \" + error.message);\n      }\n    }\n\n    async function finishWizard(){\n      if(typeof JSZip === 'undefined'){\n        toast(t(\"zipLibError\"));\n        return;\n      }\n\n      toast(t(\"zipGenerating\"));\n      const dateStr = new Date().toISOString().split(\"T\")[0];\n      const clientSlug = sanitizeClientName(state.data.requestor && state.data.requestor.company);\n\n      try {\n        console.log('Generazione JSON...');\n        const jsonBlob = generateJsonBlob();\n        console.log('JSON OK');\n        \n        console.log('Generazione PDF...');\n        const pdfBlob = generatePdfBlob();\n        console.log('PDF OK');\n        \n        console.log('Generazione Excel...');\n        console.log('Dati company.codiceIdentificativoSitoLogistico:', state.data.company.codiceIdentificativoSitoLogistico);\n        const excelBlob = generateExcelBlob();\n        console.log('Excel OK');\n\n        const zip = new JSZip();\n        \n        \/\/ Includi i file nello ZIP solo se abilitati dal backend\n        if (typeof nmvo_ajax_object !== 'undefined') {\n          if (nmvo_ajax_object.attach_json) {\n            zip.file(`nmvo-onboarding-${clientSlug}-${dateStr}.json`, jsonBlob);\n            console.log('JSON aggiunto allo ZIP');\n          }\n          if (nmvo_ajax_object.attach_pdf) {\n            zip.file(`nmvo-onboarding-${clientSlug}-${dateStr}.pdf`, pdfBlob);\n            console.log('PDF aggiunto allo ZIP');\n          }\n          if (nmvo_ajax_object.attach_xlsx) {\n            zip.file(`nmvo-onboarding-${clientSlug}-${dateStr}.xlsx`, excelBlob);\n            console.log('Excel aggiunto allo ZIP');\n          }\n        } else {\n          \/\/ Fallback: se nmvo_ajax_object non \u00e8 definito, includi tutto\n          zip.file(`nmvo-onboarding-${clientSlug}-${dateStr}.json`, jsonBlob);\n          zip.file(`nmvo-onboarding-${clientSlug}-${dateStr}.pdf`, pdfBlob);\n          zip.file(`nmvo-onboarding-${clientSlug}-${dateStr}.xlsx`, excelBlob);\n        }\n\n        const hasIntMeta = state.data.integration.attachments && state.data.integration.attachments.length > 0;\n        const hasAuthMeta = state.data.terms.authorizations.attachments && state.data.terms.authorizations.attachments.length > 0;\n        const hasIntFiles = state.files.integration.length > 0;\n        const hasAuthFiles = state.files.auth.length > 0;\n\n        let attachmentWarningNeeded = false;\n        if(hasIntMeta && !hasIntFiles) attachmentWarningNeeded = true;\n        if(hasAuthMeta && !hasAuthFiles) attachmentWarningNeeded = true;\n\n        if(hasIntFiles){\n          const folder = zip.folder(\"allegati-integrazione\");\n          for(const f of state.files.integration) folder.file(f.name, f);\n        }\n        if(hasAuthFiles){\n          const folder = zip.folder(\"allegati-autorizzazioni\");\n          for(const f of state.files.auth) folder.file(f.name, f);\n        }\n\n        const zipBlob = await zip.generateAsync({ type:\"blob\" });\n        const fileName = `nmvo-onboarding-${clientSlug}-${dateStr}.zip`;\n\n        \/\/ Invia lo ZIP al backend WordPress\n        if (typeof nmvo_ajax_object !== 'undefined') {\n          toast(\"Invio in corso...\");\n          \n          \/\/ Riempi automaticamente il campo \"companyName\" degli utenti se vuoto\n          \/\/ Usa la ragione sociale (clientName) dalla Tab 3 come default\n          if (state.data.users && state.data.users.length > 0) {\n            const defaultCompany = state.data.company?.clientName || '';\n            state.data.users.forEach(user => {\n              if (!user.companyName || user.companyName.trim() === '') {\n                user.companyName = defaultCompany;\n              }\n            });\n          }\n          \n          const formData = new FormData();\n          formData.append('action', 'nmvo_onboarding_submit');\n          formData.append('nonce', nmvo_ajax_object.nonce);\n          formData.append('zip_file', zipBlob, fileName);\n          formData.append('form_data', JSON.stringify(state.data));\n          \n          \/\/ Aggiungi token reCAPTCHA se abilitato\n          if (nmvo_ajax_object.recaptcha_enabled && typeof grecaptcha !== 'undefined') {\n            const recaptchaToken = grecaptcha.getResponse(recaptchaWidgetId);\n            formData.append('recaptcha_token', recaptchaToken);\n          }\n          \n          console.log('Invio al server:', {\n            url: nmvo_ajax_object.ajax_url,\n            zipSize: zipBlob.size,\n            fileName: fileName\n          });\n          \n          try {\n            const response = await fetch(nmvo_ajax_object.ajax_url, {\n              method: 'POST',\n              body: formData\n            });\n            \n            console.log('Risposta server ricevuta:', {\n              status: response.status,\n              statusText: response.statusText,\n              contentType: response.headers.get('content-type')\n            });\n            \n            \/\/ Verifica che la risposta sia OK\n            if (!response.ok) {\n              throw new Error(`Errore HTTP: ${response.status} ${response.statusText}`);\n            }\n            \n            \/\/ Verifica che la risposta sia JSON\n            const contentType = response.headers.get('content-type');\n            if (!contentType || !contentType.includes('application\/json')) {\n              const textResponse = await response.text();\n              console.error('Risposta non-JSON dal server:', textResponse.substring(0, 500));\n              throw new Error('Il server ha restituito una risposta non valida. Controlla i log PHP.');\n            }\n            \n            const result = await response.json();\n            console.log('Risultato parsed:', result);\n            \n            if (result.success) {\n              \/\/ Pulisci la bozza salvata\n              localStorage.removeItem(STORAGE_KEY);\n              \n              \/\/ Successo: redirect alla Thank You Page se configurata\n              if (nmvo_ajax_object.redirect_url && nmvo_ajax_object.redirect_url !== '') {\n                window.location.href = nmvo_ajax_object.redirect_url;\n              } else {\n                \/\/ Fallback: mostra messaggio inline se non c'\u00e8 redirect URL\n                showSuccessPage(result.data.message, attachmentWarningNeeded);\n              }\n            } else {\n              console.error('Server ha restituito errore:', result.data);\n              toast(\"Errore: \" + (result.data.message || \"Errore sconosciuto\"));\n              showErrorPage(result.data.message || \"Errore durante l'invio\");\n            }\n          } catch (error) {\n            console.error(\"Errore durante l'invio:\", error);\n            console.error(\"Stack trace:\", error.stack);\n            toast(\"Errore durante l'invio: \" + error.message);\n            showErrorPage(\"Errore di connessione durante l'invio. Riprova pi\u00f9 tardi.\\n\\nDettagli tecnici: \" + error.message);\n          }\n        } else {\n          \/\/ Se non siamo in WordPress, mostra errore\n          toast(\"Errore: ambiente non configurato correttamente\");\n          showErrorPage(\"Il form deve essere utilizzato all'interno di WordPress\");\n        }\n\n      } catch(error) {\n        console.error(\"Errore durante la generazione dello ZIP:\", error);\n        toast(t(\"zipError\") + \" \" + error.message);\n      }\n    }\n\n    function showSuccessPage(message, showAttachmentWarning){\n      const mainEl = document.querySelector(\"main.container\");\n      const footerEl = document.querySelector(\"footer.footer\");\n      const savedMainHtml = mainEl.innerHTML;\n      if(footerEl) footerEl.style.display = \"none\";\n\n      const dateStr = new Date().toISOString().split(\"T\")[0];\n      const clientSlug = sanitizeClientName(state.data.requestor && state.data.requestor.company);\n      const hasInt = state.files.integration.length > 0 || (state.data.integration.attachments && state.data.integration.attachments.length > 0);\n      const hasAuth = state.files.auth.length > 0 || (state.data.terms.authorizations.attachments && state.data.terms.authorizations.attachments.length > 0);\n\n      let filesListHtml = `\n        <li>nmvo-onboarding-${clientSlug}-${dateStr}.json \u2014 ${esc(t(\"instructionFileJson\"))}<\/li>\n        <li>nmvo-onboarding-${clientSlug}-${dateStr}.pdf \u2014 ${esc(t(\"instructionFilePdf\"))}<\/li>\n        <li>nmvo-onboarding-${clientSlug}-${dateStr}.xlsx \u2014 ${esc(t(\"instructionFileExcel\"))}<\/li>`;\n      if(hasInt) filesListHtml += `<li><strong>allegati-integrazione\/<\/strong> \u2014 ${esc(t(\"instructionFolderIntegration\"))}<\/li>`;\n      if(hasAuth) filesListHtml += `<li><strong>allegati-autorizzazioni\/<\/strong> \u2014 ${esc(t(\"instructionFolderAuth\"))}<\/li>`;\n\n      const warningHtml = showAttachmentWarning ? `\n        <div style=\"background:#fff3cd;border:1px solid #ffc107;border-radius:var(--radius);padding:12px 16px;margin-bottom:20px;color:#856404;font-size:13px;\">\n          ${esc(t(\"attachmentWarning\"))}\n        <\/div>` : \"\";\n\n      mainEl.innerHTML = `\n        <section class=\"card\" style=\"max-width:700px;margin:40px auto;text-align:center;padding:40px;\">\n          <div style=\"font-size:56px;margin-bottom:16px;color:#10b981;\">&#10004;<\/div>\n          <h1 style=\"color:var(--nmvo-blue);margin:0 0 8px 0;font-size:24px;\">${esc(t(\"successTitle\"))}<\/h1>\n          <p style=\"color:var(--muted);margin:0 0 24px 0;\">${esc(message)}<\/p>\n          ${warningHtml}\n          <div style=\"background:#e8f5f1;border:1px solid #10b981;border-radius:var(--radius);padding:24px;margin-bottom:24px;\">\n            <p style=\"margin:0;font-size:14px;color:#065f46;\">\n              ${esc(t(\"successConfirmation\"))}\n            <\/p>\n          <\/div>\n          <button class=\"primary\" type=\"button\" id=\"backToHomeBtn\" style=\"margin-top:8px;\">${esc(t(\"close\"))}<\/button>\n        <\/section>`;\n\n      document.getElementById(\"backToHomeBtn\").addEventListener(\"click\", ()=>{\n        if(footerEl) footerEl.style.display = \"\";\n        localStorage.removeItem(STORAGE_KEY);\n        location.reload();\n      });\n    }\n    \n    function showErrorPage(errorMessage){\n      const mainEl = document.querySelector(\"main.container\");\n      const footerEl = document.querySelector(\"footer.footer\");\n      const savedMainHtml = mainEl.innerHTML;\n      if(footerEl) footerEl.style.display = \"none\";\n\n      mainEl.innerHTML = `\n        <section class=\"card\" style=\"max-width:700px;margin:40px auto;text-align:center;padding:40px;\">\n          <div style=\"font-size:56px;margin-bottom:16px;color:#dc3545;\">&#10008;<\/div>\n          <h1 style=\"color:var(--danger);margin:0 0 8px 0;font-size:24px;\">Errore durante l'invio<\/h1>\n          <p style=\"color:var(--muted);margin:0 0 24px 0;\">${esc(errorMessage)}<\/p>\n          <div style=\"background:#fff3cd;border:1px solid #ffc107;border-radius:var(--radius);padding:24px;margin-bottom:24px;\">\n            <p style=\"margin:0;font-size:14px;color:#856404;\">\n              Si \u00e8 verificato un problema durante l'invio della tua richiesta.<br>\n              Per favore riprova pi\u00f9 tardi o contatta l'assistenza.\n            <\/p>\n          <\/div>\n          <button class=\"primary\" type=\"button\" id=\"backToWizardBtn\" style=\"margin-top:8px;\">Torna al modulo<\/button>\n        <\/section>`;\n\n      document.getElementById(\"backToWizardBtn\").addEventListener(\"click\", ()=>{\n        mainEl.innerHTML = savedMainHtml;\n        if(footerEl) footerEl.style.display = \"\";\n        state.step = visibleSteps().length - 1;\n        initEventListeners();\n        render();\n      });\n    }\n\n    function showInstructionPage(showAttachmentWarning){\n      const mainEl = document.querySelector(\"main.container\");\n      const footerEl = document.querySelector(\"footer.footer\");\n      const savedMainHtml = mainEl.innerHTML;\n      if(footerEl) footerEl.style.display = \"none\";\n\n      const dateStr = new Date().toISOString().split(\"T\")[0];\n      const clientSlug = sanitizeClientName(state.data.requestor && state.data.requestor.company);\n      const hasInt = state.files.integration.length > 0 || (state.data.integration.attachments && state.data.integration.attachments.length > 0);\n      const hasAuth = state.files.auth.length > 0 || (state.data.terms.authorizations.attachments && state.data.terms.authorizations.attachments.length > 0);\n\n      let filesListHtml = `\n        <li>nmvo-onboarding-${clientSlug}-${dateStr}.json \u2014 ${esc(t(\"instructionFileJson\"))}<\/li>\n        <li>nmvo-onboarding-${clientSlug}-${dateStr}.pdf \u2014 ${esc(t(\"instructionFilePdf\"))}<\/li>\n        <li>nmvo-onboarding-${clientSlug}-${dateStr}.xlsx \u2014 ${esc(t(\"instructionFileExcel\"))}<\/li>`;\n      if(hasInt) filesListHtml += `<li><strong>allegati-integrazione\/<\/strong> \u2014 ${esc(t(\"instructionFolderIntegration\"))}<\/li>`;\n      if(hasAuth) filesListHtml += `<li><strong>allegati-autorizzazioni\/<\/strong> \u2014 ${esc(t(\"instructionFolderAuth\"))}<\/li>`;\n\n      const warningHtml = showAttachmentWarning ? `\n        <div style=\"background:#fff3cd;border:1px solid #ffc107;border-radius:var(--radius);padding:12px 16px;margin-bottom:20px;color:#856404;font-size:13px;\">\n          ${esc(t(\"attachmentWarning\"))}\n        <\/div>` : \"\";\n\n      mainEl.innerHTML = `\n        <section class=\"card\" style=\"max-width:700px;margin:40px auto;text-align:center;padding:40px;\">\n          <div style=\"font-size:56px;margin-bottom:16px;\">&#10004;<\/div>\n          <h1 style=\"color:var(--nmvo-blue);margin:0 0 8px 0;font-size:24px;\">${esc(t(\"instructionTitle\"))}<\/h1>\n          <p style=\"color:var(--muted);margin:0 0 24px 0;\">${esc(t(\"instructionSubtitle\"))}<\/p>\n          ${warningHtml}\n          <div style=\"text-align:left;background:var(--bg);border-radius:var(--radius);padding:16px 20px;margin-bottom:24px;\">\n            <strong style=\"display:block;margin-bottom:8px;\">${esc(t(\"instructionZipContents\"))}<\/strong>\n            <ul style=\"margin:0;padding-left:20px;line-height:1.8;font-size:13px;color:var(--text);\">\n              ${filesListHtml}\n            <\/ul>\n          <\/div>\n          <div style=\"background:var(--nmvo-blue);color:white;border-radius:var(--radius);padding:24px;margin-bottom:24px;\">\n            <h2 style=\"margin:0 0 12px 0;font-size:18px;\">${esc(t(\"instructionEmailTitle\"))}<\/h2>\n            <p style=\"margin:0 0 16px 0;font-size:14px;opacity:0.9;\">${esc(t(\"instructionEmailText\"))}<\/p>\n            <a href=\"mailto:nmvs_account_setup@nmvo-italia.it\" style=\"display:inline-block;background:white;color:var(--nmvo-blue);font-weight:700;font-size:16px;padding:12px 24px;border-radius:var(--radius);text-decoration:none;\">\n              nmvs_account_setup@nmvo-italia.it\n            <\/a>\n            <p style=\"margin:16px 0 0 0;font-size:12px;opacity:0.75;\">${esc(t(\"instructionEmailNote\"))}<\/p>\n          <\/div>\n          <button class=\"ghost\" type=\"button\" id=\"backToWizardBtn\" style=\"margin-top:8px;\">${esc(t(\"instructionBackBtn\"))}<\/button>\n        <\/section>`;\n\n      document.getElementById(\"backToWizardBtn\").addEventListener(\"click\", ()=>{\n        mainEl.innerHTML = savedMainHtml;\n        if(footerEl) footerEl.style.display = \"\";\n        state.step = visibleSteps().length - 1;\n        initEventListeners();\n        render();\n      });\n    }\n  <\/script>\n<\/body>\n<\/html>\n<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Modulo onboarding NMVS Depositari e Grossisti<\/p>","protected":false},"author":8,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_eb_attr":"","footnotes":""},"class_list":["post-2993","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/pages\/2993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/comments?post=2993"}],"version-history":[{"count":14,"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/pages\/2993\/revisions"}],"predecessor-version":[{"id":3179,"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/pages\/2993\/revisions\/3179"}],"wp:attachment":[{"href":"https:\/\/www.nmvoitalia.it\/en\/wp-json\/wp\/v2\/media?parent=2993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}