{"id":1106,"date":"2026-09-06T06:55:30","date_gmt":"2026-09-06T06:55:30","guid":{"rendered":"https:\/\/webdigital.lv\/?page_id=1106"},"modified":"2026-10-07T12:21:20","modified_gmt":"2026-10-07T12:21:20","slug":"support-chat","status":"publish","type":"page","link":"https:\/\/webdigital.lv\/en\/support-chat\/","title":{"rendered":"Support Chat"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1106\" class=\"elementor elementor-1106 elementor-719\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-c0a845e e-con e-atomic-element e-flexbox-base e-default-div e-ae0d2b4 \" data-id=\"c0a845e\" data-element_type=\"e-flexbox\" data-e-type=\"e-flexbox\" data-interaction-id=\"c0a845e\" data-e-type=\"e-flexbox\" data-id=\"c0a845e\">\n    \t\t<div class=\"elementor-element elementor-element-0f15999 elementor-widget elementor-widget-html\" data-id=\"0f15999\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t\t<section class=\"wdsupport-page\">\n<style>\n.wdsupport-page,.wdsupport-page *{box-sizing:border-box}\n.wdsupport-page{\n  --o:#f54e31;--ink:#171717;--muted:#6d6d67;--line:#e6e6e0;--soft:#f7f7f3;\n  --warm:#fff4ef;--green:#35bd72;\n  min-height:100vh;padding:34px 28px;\n  background:radial-gradient(circle at 86% 10%,rgba(245,78,49,.10),transparent 26%),linear-gradient(180deg,#fff,#fafaf7);\n  color:var(--ink);font-family:Manrope,Arial,sans-serif\n}\n.wdsupport-page__in{max-width:1390px;margin:0 auto}\n.wdsupport-page__top{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:22px}\n.wdsupport-page__back{display:inline-flex;align-items:center;gap:8px;color:var(--ink);text-decoration:none;font-size:8.5px;font-weight:900}\n.wdsupport-page__brand{display:flex;align-items:center;gap:10px}\n.wdsupport-page__logo{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;background:var(--ink);color:#fff;font-size:11px;font-weight:900}\n.wdsupport-page__brand-text strong{display:block;font-size:10px}\n.wdsupport-page__brand-text span{display:flex;align-items:center;gap:6px;margin-top:2px;color:#81817b;font-size:7px;font-weight:850}\n.wdsupport-page__brand-text i{width:6px;height:6px;border-radius:50%;background:var(--green);box-shadow:0 0 0 4px rgba(53,189,114,.12)}\n.wdsupport-page__grid{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(330px,.65fr);gap:18px;align-items:stretch}\n\n\/* CHAT *\/\n.wdsupport-chat{min-height:700px;display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--line);border-radius:22px;background:#fff;box-shadow:0 18px 55px rgba(0,0,0,.06)}\n.wdsupport-chat__head{min-height:74px;padding:0 20px;display:flex;align-items:center;justify-content:space-between;gap:20px;border-bottom:1px solid var(--line)}\n.wdsupport-chat__head-left small{display:block;color:var(--o);font-size:7.5px;font-weight:900;letter-spacing:.1em;text-transform:uppercase}\n.wdsupport-chat__head-left h1{margin:4px 0 0;font-size:22px;line-height:1.05;letter-spacing:-.04em}\n.wdsupport-chat__online{display:flex;align-items:center;gap:8px;padding:8px 11px;border-radius:999px;background:#f5f8f5;font-size:7.5px;font-weight:900}\n.wdsupport-chat__online i{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 0 4px rgba(53,189,114,.12)}\n.wdsupport-chat__notice{padding:9px 18px;background:var(--warm);border-bottom:1px solid #ffddd4;color:#765e57;font-size:7.8px;line-height:1.5}\n.wdsupport-chat__messages{flex:1;overflow-y:auto;padding:22px;background:#fafaf7}\n.wdsupport-chat__msg{max-width:78%;margin-bottom:11px;padding:11px 13px;border-radius:14px;font-size:10px;line-height:1.55;white-space:pre-wrap;word-break:break-word}\n.wdsupport-chat__msg--assistant{margin-right:auto;background:#fff;border:1px solid var(--line);color:#33332f;border-bottom-left-radius:5px}\n.wdsupport-chat__msg--user{margin-left:auto;background:var(--ink);color:#fff;border-bottom-right-radius:5px}\n.wdsupport-chat__msg--system{margin:10px auto;max-width:90%;background:#eef8f2;border:1px solid #cfe8d9;color:#356346;text-align:center;font-size:8.5px}\n.wdsupport-chat__typing{display:none;margin-bottom:10px;color:#92928c;font-size:8px;font-weight:800}\n.wdsupport-chat__typing.is-visible{display:block}\n.wdsupport-chat__composer{padding:13px;display:grid;grid-template-columns:1fr auto;gap:8px;border-top:1px solid var(--line);background:#fff}\n.wdsupport-chat__input{min-height:48px;max-height:130px;padding:12px 13px;border:1px solid #deded8;border-radius:11px;background:#fafaf8;color:var(--ink);resize:none;outline:none;font:inherit;font-size:10px;line-height:1.45}\n.wdsupport-chat__input:focus{border-color:var(--o);background:#fff;box-shadow:0 0 0 3px rgba(245,78,49,.08)}\n.wdsupport-chat__send{width:48px;height:48px;border:0;border-radius:11px;background:var(--o);color:#fff;cursor:pointer;font-size:17px;font-weight:900}\n.wdsupport-chat__send:disabled{opacity:.55;cursor:wait}\n\n\/* SIDE *\/\n.wdsupport-side{display:grid;gap:12px}\n.wdsupport-side__card{padding:20px;border:1px solid var(--line);border-radius:18px;background:#fff}\n.wdsupport-side__card--dark{background:#171717;color:#fff;border-color:#171717}\n.wdsupport-side__ey{display:block;margin-bottom:10px;color:var(--o);font-size:7.5px;font-weight:900;letter-spacing:.1em;text-transform:uppercase}\n.wdsupport-side__card h2{margin:0;font-size:22px;line-height:1.05;letter-spacing:-.04em}\n.wdsupport-side__card p{margin:8px 0 0;color:var(--muted);font-size:9px;line-height:1.5}\n.wdsupport-side__card--dark p{color:#b6b6b0}\n.wdsupport-side__steps{margin-top:17px;display:grid;gap:10px}\n.wdsupport-side__step{display:grid;grid-template-columns:auto 1fr;gap:10px;align-items:start}\n.wdsupport-side__num{width:28px;height:28px;border-radius:9px;display:grid;place-items:center;background:#fff3ee;color:var(--o);font-size:7.5px;font-weight:900}\n.wdsupport-side__step strong{display:block;font-size:9.5px;line-height:1.3}\n.wdsupport-side__step span{display:block;margin-top:3px;color:var(--muted);font-size:7.8px;line-height:1.4}\n.wdsupport-side__pay{margin-top:14px;padding-top:14px;border-top:1px solid rgba(255,255,255,.10)}\n.wdsupport-side__pay strong{display:block;font-size:10px}\n.wdsupport-side__pay span{display:block;margin-top:4px;color:#b6b6b0;font-size:8px;line-height:1.45}\n.wdsupport-side__secure{margin-top:14px;width:100%;min-height:42px;border:0;border-radius:10px;background:var(--o);color:#fff;cursor:pointer;font-family:inherit;font-size:8.5px;font-weight:900;transition:.2s ease}\n.wdsupport-side__secure:disabled{background:#373737;color:#8f8f8a;cursor:not-allowed;box-shadow:none}\n.wdsupport-side__secure-state{margin-top:8px;color:#aaa9a4;font-size:7.6px;line-height:1.45}\n.wdsupport-side__secure-state.is-ready{color:#8fe0ad}\n.wdsupport-side__contact{display:flex;align-items:center;justify-content:space-between;gap:15px}\n.wdsupport-side__contact div small{display:block;color:#95958f;font-size:7px;font-weight:900;letter-spacing:.08em;text-transform:uppercase}\n.wdsupport-side__contact div strong{display:block;margin-top:3px;font-size:11px}\n.wdsupport-side__contact a{color:var(--ink);text-decoration:none;font-size:10px;font-weight:900}\n\n\/* SECURE ACCESS MODAL *\/\n.wdsecure{position:fixed;inset:0;z-index:999999;display:none;align-items:center;justify-content:center;padding:18px;font-family:Manrope,Arial,sans-serif}\n.wdsecure.is-open{display:flex}\n.wdsecure__backdrop{position:absolute;inset:0;background:rgba(10,10,10,.72);backdrop-filter:blur(7px);-webkit-backdrop-filter:blur(7px)}\n.wdsecure__dialog{position:relative;z-index:2;width:min(100%,700px);max-height:calc(100dvh - 36px);overflow:auto;border-radius:22px;background:#fff;box-shadow:0 30px 100px rgba(0,0,0,.28)}\n.wdsecure__head{padding:22px 22px 16px;border-bottom:1px solid var(--line);position:relative}\n.wdsecure__ey{color:var(--o);font-size:7.5px;font-weight:900;letter-spacing:.1em;text-transform:uppercase}\n.wdsecure__head h2{margin:7px 42px 6px 0;font-size:27px;line-height:1.05;letter-spacing:-.045em}\n.wdsecure__head p{margin:0;max-width:580px;color:var(--muted);font-size:9px;line-height:1.5}\n.wdsecure__close{position:absolute;right:16px;top:16px;width:36px;height:36px;border:0;border-radius:10px;background:#f3f3ef;cursor:pointer;font-size:21px}\n.wdsecure__form{padding:20px 22px 22px;display:grid;gap:12px}\n.wdsecure__two{display:grid;grid-template-columns:1fr 1fr;gap:12px}\n.wdsecure label{display:block;margin-bottom:6px;color:#555550;font-size:7.3px;font-weight:900;letter-spacing:.07em;text-transform:uppercase}\n.wdsecure input,.wdsecure select,.wdsecure textarea{width:100%;border:1px solid #deded8;border-radius:10px;background:#fafaf8;color:#171717;outline:none;font-family:inherit;font-size:10px}\n.wdsecure input,.wdsecure select{height:44px;padding:0 12px}\n.wdsecure textarea{min-height:90px;padding:11px 12px;resize:vertical}\n.wdsecure input:focus,.wdsecure select:focus,.wdsecure textarea:focus{border-color:var(--o);background:#fff;box-shadow:0 0 0 3px rgba(245,78,49,.08)}\n.wdsecure__warning{padding:10px 12px;border-radius:10px;background:#fff4ef;color:#745f58;font-size:8px;line-height:1.45}\n.wdsecure__submit{min-height:46px;border:0;border-radius:10px;background:#171717;color:#fff;font-family:inherit;font-size:8.8px;font-weight:900;cursor:pointer}\n.wdsecure__submit:disabled{opacity:.55;cursor:wait}\n\n.wdsecure__consent{\n  display:grid!important;\n  grid-template-columns:18px 1fr;\n  gap:9px;\n  align-items:start;\n  margin:0!important;\n  padding:11px 12px;\n  border:1px solid #e2e2dc;\n  border-radius:10px;\n  background:#fafaf8;\n  color:#555550!important;\n  font-size:8px!important;\n  font-weight:700!important;\n  line-height:1.45;\n  letter-spacing:0!important;\n  text-transform:none!important;\n  cursor:pointer;\n}\n.wdsecure__consent input{\n  width:16px!important;\n  height:16px!important;\n  margin:1px 0 0!important;\n  padding:0!important;\n  accent-color:var(--o);\n}\n\n.wdsecure__result{display:none;padding:12px;border-radius:10px;background:#eef8f2;border:1px solid #cfe8d9;color:#356346;font-size:9px;line-height:1.5}\n.wdsecure__result.is-visible{display:block}\nbody.wdsecure-open{overflow:hidden}\n\n@media(max-width:980px){\n  .wdsupport-page__grid{grid-template-columns:1fr}\n  .wdsupport-chat{min-height:650px}\n}\n@media(max-width:700px){\n  .wdsupport-page{padding:18px 12px}\n  .wdsupport-page__top{margin-bottom:14px}\n  .wdsupport-chat{min-height:calc(100dvh - 120px);border-radius:16px}\n  .wdsupport-chat__head{min-height:68px;padding:0 15px}\n  .wdsupport-chat__head-left h1{font-size:19px}\n  .wdsupport-chat__messages{padding:15px}\n  .wdsupport-chat__msg{max-width:90%}\n  .wdsecure{padding:0}\n  .wdsecure__dialog{width:100%;height:100dvh;max-height:none;border-radius:0}\n  .wdsecure__two{grid-template-columns:1fr}\n}\n<\/style>\n\n<div class=\"wdsupport-page__in\">\n\n  <div class=\"wdsupport-page__top\">\n    <a class=\"wdsupport-page__back\" href=\"\/atra-palidziba\/\">\u2190 Back to Emergency Support<\/a>\n\n    <div class=\"wdsupport-page__brand\">\n      <div class=\"wdsupport-page__logo\">W<\/div>\n      <div class=\"wdsupport-page__brand-text\">\n        <strong>WebDigital Support<\/strong>\n        <span><i><\/i> 24\/7 technical support<\/span>\n      <\/div>\n    <\/div>\n  <\/div>\n\n  <div class=\"wdsupport-page__grid\">\n\n    <main class=\"wdsupport-chat\">\n      <div class=\"wdsupport-chat__head\">\n        <div class=\"wdsupport-chat__head-left\">\n          <small>RAPID TECHNICAL ASSISTANCE<\/small>\n          <h1>Describe what happened.<\/h1>\n        <\/div>\n        <div class=\"wdsupport-chat__online\"><i><\/i> ONLINE<\/div>\n      <\/div>\n\n      <div class=\"wdsupport-chat__notice\">\n        Do not write chatting passwords, API keys or other sensitive access data. If access is required, use the secure access form.\n      <\/div>\n\n      <div class=\"wdsupport-chat__messages\" id=\"wdSupportMessages\">\n        <div class=\"wdsupport-chat__msg wdsupport-chat__msg--assistant\">\n          Hello! Describe what happened to your website. If possible, specify also the website address.\n        <\/div>\n        <div class=\"wdsupport-chat__typing\" id=\"wdSupportTyping\">WebDigital Support is written...<\/div>\n      <\/div>\n\n      <form class=\"wdsupport-chat__composer\" id=\"wdSupportForm\">\n        <textarea class=\"wdsupport-chat__input\" id=\"wdSupportInput\" rows=\"1\" placeholder=\"Describe the problem...\" required><\/textarea>\n        <button class=\"wdsupport-chat__send\" id=\"wdSupportSend\" type=\"submit\" aria-label=\"Submit\">\u2192<\/button>\n      <\/form>\n    <\/main>\n\n    <aside class=\"wdsupport-side\">\n\n      <div class=\"wdsupport-side__card\">\n        <span class=\"wdsupport-side__ey\">HOW IT WORKS<\/span>\n        <h2>You do not need to know the technical cause.<\/h2>\n        <p>At first, it is enough to have a website address and a brief description of what you see or what no longer works.<\/p>\n\n        <div class=\"wdsupport-side__steps\">\n          <div class=\"wdsupport-side__step\">\n            <div class=\"wdsupport-side__num\">01<\/div>\n            <div><strong>Describe the problem<\/strong><span>Specify the address of the site and the situation.<\/span><\/div>\n          <\/div>\n          <div class=\"wdsupport-side__step\">\n            <div class=\"wdsupport-side__num\">02<\/div>\n            <div><strong>Collect information<\/strong><span>We set the priority and the next step.<\/span><\/div>\n          <\/div>\n          <div class=\"wdsupport-side__step\">\n            <div class=\"wdsupport-side__num\">03<\/div>\n            <div><strong>Access if necessary<\/strong><span>Give access data only in a secure form.<\/span><\/div>\n          <\/div>\n          <div class=\"wdsupport-side__step\">\n            <div class=\"wdsupport-side__num\">04<\/div>\n            <div><strong>Coordination of costs<\/strong><span>Before starting the paid work, we agree on the price.<\/span><\/div>\n          <\/div>\n        <\/div>\n      <\/div>\n\n      <div class=\"wdsupport-side__card wdsupport-side__card--dark\">\n        <span class=\"wdsupport-side__ey\">SECURE ACCESS<\/span>\n        <h2>Should I check WordPress or Hosting?<\/h2>\n        <p>Do not send access data via chat. Use the encrypted form if necessary for diagnostics.<\/p>\n\n        <div class=\"wdsupport-side__pay\">\n          <strong>Ambulance is a paid service<\/strong>\n          <span>Describing the problem in the chat does not cause payment obligations.<\/span>\n        <\/div>\n\n        <button class=\"wdsupport-side__secure\" type=\"button\" id=\"wdSecureAccessButton\" disabled>\n          \ud83d\udd12 Access sharing is not yet enabled\n        <\/button>\n\n        <div class=\"wdsupport-side__secure-state\" id=\"wdSecureAccessState\">\n          The secure form will become available if you request technical access during a WebDigital Support conversation.\n        <\/div>\n      <\/div>\n\n      <div class=\"wdsupport-side__card\">\n        <div class=\"wdsupport-side__contact\">\n          <div><small>OR CALL<\/small><strong>WebDigital Support<\/strong><\/div>\n          <a href=\"tel:+37120433366\">+371 20 433 366<\/a>\n        <\/div>\n      <\/div>\n\n    <\/aside>\n\n  <\/div>\n<\/div>\n\n<!-- SECURE ACCESS MODAL -->\n<div class=\"wdsecure\" id=\"wdSecureModal\" aria-hidden=\"true\">\n  <div class=\"wdsecure__backdrop js-wdsecure-close\"><\/div>\n\n  <div class=\"wdsecure__dialog\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"wdSecureTitle\">\n    <div class=\"wdsecure__head\">\n      <div class=\"wdsecure__ey\">SAFE TRANSFER OF ACCESS DATA<\/div>\n      <h2 id=\"wdSecureTitle\">Send access data securely.<\/h2>\n      <p>\n        The data is not added to the public chat conversation. You will receive a reference number when you send it.\n      <\/p>\n      <button class=\"wdsecure__close js-wdsecure-close\" type=\"button\" aria-label=\"Close\">\u00d7<\/button>\n    <\/div>\n\n    <form class=\"wdsecure__form\" id=\"wdSecureForm\">\n\n      <div class=\"wdsecure__two\">\n        <div>\n          <label for=\"wdSecureName\">Name, surname<\/label>\n          <input id=\"wdSecureName\" name=\"client_name\" type=\"text\" autocomplete=\"name\" placeholder=\"J\u0101nis B\u0113rzi\u0146\u0161\" required>\n        <\/div>\n\n        <div>\n          <label for=\"wdSecureEmail\">Email<\/label>\n          <input id=\"wdSecureEmail\" name=\"client_email\" type=\"email\" autocomplete=\"email\" placeholder=\"janis@uznemums.lv\" required>\n        <\/div>\n      <\/div>\n\n      <div class=\"wdsecure__two\">\n        <div>\n          <label for=\"wdSecurePhone\">Phone<\/label>\n          <input id=\"wdSecurePhone\" name=\"client_phone\" type=\"tel\" autocomplete=\"tel\" placeholder=\"+371 2X XXX XXX\" required>\n        <\/div>\n\n        <div>\n          <label for=\"wdSecureDomain\">Home \/ Domain<\/label>\n          <input id=\"wdSecureDomain\" name=\"domain\" type=\"text\" placeholder=\"example.lv\" required>\n        <\/div>\n      <\/div>\n\n      <div class=\"wdsecure__two\">\n        <div>\n          <label for=\"wdSecureType\">Type of access<\/label>\n          <select id=\"wdSecureType\" name=\"access_type\" required>\n            <option value=\"\">Select<\/option>\n            <option value=\"WordPress\">WordPress<\/option>\n            <option value=\"Hosting\">Hosting<\/option>\n            <option value=\"FTP\">FTP \/ SFTP<\/option>\n            <option value=\"Other\">Other<\/option>\n          <\/select>\n        <\/div>\n\n        <div>\n          <label for=\"wdSecureUsername\">Username \/ Email<\/label>\n          <input id=\"wdSecureUsername\" name=\"username\" type=\"text\" autocomplete=\"off\" required>\n        <\/div>\n      <\/div>\n\n      <div>\n        <label for=\"wdSecurePassword\">Password<\/label>\n        <input id=\"wdSecurePassword\" name=\"password\" type=\"password\" autocomplete=\"new-password\" required>\n      <\/div>\n\n      <div>\n        <label for=\"wdSecureNote\">Note (optional)<\/label>\n        <textarea id=\"wdSecureNote\" name=\"note\" placeholder=\"For example: WordPress administrator access\"><\/textarea>\n      <\/div>\n\n      <label class=\"wdsecure__consent\">\n        <input id=\"wdSecureConsent\" name=\"consent\" type=\"checkbox\" value=\"1\" required>\n        <span>\n          I declare that I have the right to transfer this access data and agree to its processing for the provision of technical support.\n        <\/span>\n      <\/label>\n\n      <div class=\"wdsecure__warning\">\n        The access data sent in the secure form is stored encrypted and is only intended to solve a technical problem.\n      <\/div>\n\n      <div class=\"wdsecure__result\" id=\"wdSecureResult\"><\/div>\n\n      <button class=\"wdsecure__submit\" id=\"wdSecureSubmit\" type=\"submit\">\n        Safe to send access data to it\n      <\/button>\n\n    <\/form>\n  <\/div>\n<\/div>\n\n<script>\n(function(){\n\n  var messages = document.getElementById('wdSupportMessages');\n  var form = document.getElementById('wdSupportForm');\n  var input = document.getElementById('wdSupportInput');\n  var send = document.getElementById('wdSupportSend');\n  var typing = document.getElementById('wdSupportTyping');\n\n  var secureButton = document.getElementById('wdSecureAccessButton');\n  var secureModal = document.getElementById('wdSecureModal');\n  var secureForm = document.getElementById('wdSecureForm');\n  var secureSubmit = document.getElementById('wdSecureSubmit');\n  var secureResult = document.getElementById('wdSecureResult');\n  var securePassword = document.getElementById('wdSecurePassword');\n  var secureState = document.getElementById('wdSecureAccessState');\n  var secureAccessRequested = false;\n\n  var historyKey = 'webdigital_support_chat_history_v2';\n\n  function getVisitorId(){\n    var key = 'webdigital_support_visitor_id';\n    var id = localStorage.getItem(key);\n\n    if(!id){\n      id = 'wd_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2,10);\n      localStorage.setItem(key,id);\n    }\n\n    return id;\n  }\n\n  function getHistory(){\n    try{\n      var raw = localStorage.getItem(historyKey);\n      var data = raw ? JSON.parse(raw) : [];\n      return Array.isArray(data) ? data : [];\n    }catch(e){\n      return [];\n    }\n  }\n\n  function saveHistory(history){\n    try{\n      localStorage.setItem(historyKey,JSON.stringify(history.slice(-50)));\n    }catch(e){}\n  }\n\n  function supportTicketPayload(){\n    var history = getHistory();\n\n    return {\n      visitor_id:getVisitorId(),\n      messages:history\n        .filter(function(item){\n          return item && (item.role === 'user' || item.role === 'assistant') && item.text;\n        })\n        .map(function(item){\n          return {\n            role:item.role,\n            content:String(item.text)\n          };\n        })\n    };\n  }\n\n  function syncSupportTicket(useBeacon){ return; \/* Notifications are handled by the server. *\/\n    if(!hasEmailAndPhone()) return;\n\n    var payload = supportTicketPayload();\n    if(!payload.messages.length) return;\n\n    var body = JSON.stringify(payload);\n    var endpoint = '\/wp-json\/webdigital-ai\/v1\/support';\n\n    if(useBeacon && navigator.sendBeacon){\n      try{\n        var blob = new Blob([body],{type:'application\/json'});\n        navigator.sendBeacon(endpoint,blob);\n        return;\n      }catch(e){}\n    }\n\n    fetch(endpoint,{\n      method:'POST',\n      credentials:'same-origin',\n      keepalive:true,\n      headers:{'Content-Type':'application\/json'},\n      body:body\n    }).catch(function(){\n      \/* Chat must keep working even if ticket sync fails. *\/\n    });\n  }\n\n  function addMessage(role,text,save){\n    var el = document.createElement('div');\n    el.className = 'wdsupport-chat__msg wdsupport-chat__msg--' + role;\n    el.textContent = text;\n    messages.insertBefore(el,typing);\n    messages.scrollTop = messages.scrollHeight;\n\n    if(save !== false && (role === 'user' || role === 'assistant')){\n      var history = getHistory();\n      history.push({role:role,text:text,time:Date.now()});\n      saveHistory(history);\n    }\n\n    if(role === 'assistant' && assistantRequestedAccess(text)){\n      secureAccessRequested = true;\n    }\n\n    setTimeout(updateSecureGate,0);\n  }\n\n\n  function userMessagesText(){\n    return getHistory()\n      .filter(function(item){ return item && item.role === 'user' && item.text; })\n      .map(function(item){ return String(item.text); })\n      .join('\\n');\n  }\n\n  function hasEmailAndPhone(){\n    var txt = userMessagesText();\n\n    var hasEmail = \/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\/i.test(txt);\n\n    \/*\n     * Flexible phone check: +371..., 2xxxxxxx, etc.\n     * Require at least 7 digits in a phone-like sequence.\n     *\/\n    var phoneMatches = txt.match(\/(?:\\+?\\d[\\d\\s().-]{5,}\\d)\/g) || [];\n    var hasPhone = phoneMatches.some(function(v){\n      return (v.match(\/\\d\/g) || []).length >= 7;\n    });\n\n    return hasEmail && hasPhone;\n  }\n\n  function assistantRequestedAccess(text){\n    var t = String(text || '').toLowerCase();\n\n    return (\n      \/nepiecie\u0161am.{0,35}piek\u013cuv\/i.test(t) ||\n      \/vajadz.{0,35}piek\u013cuv\/i.test(t) ||\n      \/b\u016bs nepiecie\u0161ama.{0,30}piek\u013cuv\/i.test(t) ||\n      \/l\u016bdzu.{0,35}nodod.{0,30}piek\u013cuv\/i.test(t) ||\n      \/dro\u0161.{0,25}piek\u013cuv.{0,30}form\/i.test(t) ||\n      \/\u043d\u0443\u0436\u0435\u043d.{0,30}\u0434\u043e\u0441\u0442\u0443\u043f\/i.test(t) ||\n      \/\u043d\u0443\u0436\u043d.{0,30}\u0434\u043e\u0441\u0442\u0443\u043f\/i.test(t) ||\n      \/\u043f\u043e\u043d\u0430\u0434\u043e\u0431.{0,30}\u0434\u043e\u0441\u0442\u0443\u043f\/i.test(t) ||\n      \/\u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442.{0,30}\u0434\u043e\u0441\u0442\u0443\u043f\/i.test(t) ||\n      \/\u043f\u0435\u0440\u0435\u0434\u0430.{0,35}\u0434\u043e\u0441\u0442\u0443\u043f\/i.test(t) ||\n      \/need.{0,30}access\/i.test(t) ||\n      \/require.{0,30}access\/i.test(t) ||\n      \/need.{0,30}credentials\/i.test(t) ||\n      \/secure.{0,25}access.{0,30}form\/i.test(t)\n    );\n  }\n\n  function scanHistoryForAccessRequest(){\n    secureAccessRequested = getHistory().some(function(item){\n      return item && item.role === 'assistant' && assistantRequestedAccess(item.text);\n    });\n  }\n\n  function prefillSecureContacts(){\n    var txt = userMessagesText();\n\n    var emailMatch = txt.match(\/[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\/i);\n    var phoneMatches = txt.match(\/(?:\\+?\\d[\\d\\s().-]{5,}\\d)\/g) || [];\n    var phone = '';\n\n    phoneMatches.some(function(v){\n      if((v.match(\/\\d\/g) || []).length >= 7){\n        phone = v.trim();\n        return true;\n      }\n      return false;\n    });\n\n    var emailInput = document.getElementById('wdSecureEmail');\n    var phoneInput = document.getElementById('wdSecurePhone');\n\n    if(emailInput && !emailInput.value && emailMatch){\n      emailInput.value = emailMatch[0];\n    }\n\n    if(phoneInput && !phoneInput.value && phone){\n      phoneInput.value = phone;\n    }\n  }\n\n  function updateSecureGate(){\n    if(!secureButton || !secureState) return;\n\n    scanHistoryForAccessRequest();\n\n    if(!secureAccessRequested){\n      secureButton.disabled = true;\n      secureButton.textContent = '\ud83d\udd12 Access sharing is not yet available';\n      secureState.textContent = 'The secure form will become available when WebDigital Support requests technical access during this conversation.';\n      secureState.classList.remove('is-ready');\n      return;\n    }\n\n    if(!hasEmailAndPhone()){\n      secureButton.disabled = true;\n      secureButton.textContent = '\ud83d\udd12 Vispirms nor\u0101diet kontaktinform\u0101ciju \u010dat\u0101';\n      secureState.textContent = 'To enable secure access sharing, provide your email address and phone number in the chat.';\n      secureState.classList.remove('is-ready');\n      return;\n    }\n\n    secureButton.disabled = false;\n    secureButton.textContent = '\ud83d\udd10 Share access details securely';\n    secureState.textContent = 'WebDigital Support has requested technical access. The secure form is now available.';\n    secureState.classList.add('is-ready');\n  }\n\n  function restoreHistory(){\n    var history = getHistory();\n    if(!history.length) return;\n\n    var first = messages.querySelector('.wdsupport-chat__msg--assistant');\n    if(first) first.remove();\n\n    history.forEach(function(item){\n      if(item && (item.role === 'user' || item.role === 'assistant') && item.text){\n        addMessage(item.role,String(item.text),false);\n      }\n    });\n  }\n\n  restoreHistory();\n  updateSecureGate();\n\n  \/* Recover\/sync an existing conversation when contact data is already present. *\/\n  setTimeout(function(){\n    syncSupportTicket(false);\n  },700);\n\n  window.addEventListener('pagehide',function(){\n    syncSupportTicket(true);\n  });\n\n  if(input && form){\n    input.addEventListener('keydown',function(e){\n      if(e.key === 'Enter' && !e.shiftKey){\n        e.preventDefault();\n        form.requestSubmit();\n      }\n    });\n\n    form.addEventListener('submit',async function(e){\n      e.preventDefault();\n\n      var message = input.value.trim();\n      if(!message || send.disabled) return;\n\n      addMessage('user',message,true);\n      updateSecureGate();\n      input.value = '';\n      send.disabled = true;\n      typing.classList.add('is-visible');\n\n      try{\n        var response = await fetch('\/wp-json\/webdigital-consultant\/v1\/support-chat',{\n          method:'POST',\n          credentials:'same-origin',\n          headers:{'Content-Type':'application\/json'},\n          body:JSON.stringify({\n            visitor_id:getVisitorId(),\n            message:message,\n            page_url:window.location.href\n          })\n        });\n\n        var data = await response.json();\n\n        if(!response.ok){\n          throw new Error('HTTP ' + response.status);\n        }\n\n        var reply = data.reply || data.message || data.response || '';\n\n        if(!reply){\n          throw new Error('Empty response');\n        }\n\n        addMessage('assistant',reply,true);\n\n        \/* Send the current full chat to the support ticket endpoint once contacts exist. *\/\n        syncSupportTicket(false);\n\n      }catch(err){\n        addMessage('assistant','We could not get a response. Please try again or call +371 20 433 366.',true);\n\n        \/* Even if AI reply fails, do not lose a lead that already provided contacts. *\/\n        syncSupportTicket(false);\n      }finally{\n        typing.classList.remove('is-visible');\n        send.disabled = false;\n        input.focus();\n      }\n    });\n  }\n\n  function openSecure(){\n    updateSecureGate();\n\n    if(!secureButton || secureButton.disabled){\n      return;\n    }\n\n    prefillSecureContacts();\n    secureModal.classList.add('is-open');\n    secureModal.setAttribute('aria-hidden','false');\n    document.body.classList.add('wdsecure-open');\n    secureResult.classList.remove('is-visible');\n    secureResult.textContent = '';\n\n    setTimeout(function(){\n      var first = document.getElementById('wdSecureDomain');\n      if(first) first.focus();\n    },100);\n  }\n\n  function closeSecure(){\n    secureModal.classList.remove('is-open');\n    secureModal.setAttribute('aria-hidden','true');\n    document.body.classList.remove('wdsecure-open');\n\n    if(securePassword){\n      securePassword.value = '';\n    }\n  }\n\n  if(secureButton){\n    secureButton.addEventListener('click',function(){\n      if(!secureButton.disabled){\n        openSecure();\n      }\n    });\n  }\n\n  document.addEventListener('click',function(e){\n    if(e.target.closest('.js-wdsecure-close')){\n      e.preventDefault();\n      closeSecure();\n    }\n  });\n\n  document.addEventListener('keydown',function(e){\n    if(e.key === 'Escape' && secureModal.classList.contains('is-open')){\n      closeSecure();\n    }\n  });\n\n  if(secureForm){\n    secureForm.addEventListener('submit',async function(e){\n      e.preventDefault();\n\n      if(secureSubmit.disabled) return;\n\n      var fd = new FormData(secureForm);\n\n      var payload = {\n        visitor_id:getVisitorId(),\n        page_url:window.location.href,\n        client_name:String(fd.get('client_name') || '').trim(),\n        client_email:String(fd.get('client_email') || '').trim(),\n        client_phone:String(fd.get('client_phone') || '').trim(),\n        domain:String(fd.get('domain') || '').trim(),\n        access_type:String(fd.get('access_type') || '').trim(),\n        username:String(fd.get('username') || '').trim(),\n        password:String(fd.get('password') || ''),\n        note:String(fd.get('note') || '').trim(),\n        consent:fd.get('consent') === '1'\n      };\n\n      secureSubmit.disabled = true;\n      secureResult.classList.remove('is-visible');\n      secureResult.textContent = '';\n\n      try{\n        var response = await fetch('\/wp-json\/webdigital-ai\/v1\/secure-access',{\n          method:'POST',\n          credentials:'same-origin',\n          headers:{'Content-Type':'application\/json'},\n          body:JSON.stringify(payload)\n        });\n\n        var data = await response.json();\n\n        if(!response.ok){\n          throw new Error(data.error || data.message || 'HTTP ' + response.status);\n        }\n\n        var ref =\n          data.reference ||\n          data.reference_id ||\n          data.ref ||\n          data.id ||\n          '';\n\n        securePassword.value = '';\n\n        secureResult.textContent = ref\n          ? 'Access details sent securely. Reference number: ' + ref\n          : 'Access details sent securely.';\n\n        secureResult.classList.add('is-visible');\n\n        if(messages){\n          addMessage(\n            'system',\n            ref\n              ? 'Secure access details sent. Reference number: ' + ref\n              : 'Secure access details sent.',\n            false\n          );\n        }\n\n        \/* Clear secret-bearing fields after successful transfer *\/\n        document.getElementById('wdSecureName').value = '';\n        document.getElementById('wdSecureEmail').value = '';\n        document.getElementById('wdSecurePhone').value = '';\n        document.getElementById('wdSecureUsername').value = '';\n        document.getElementById('wdSecureNote').value = '';\n        document.getElementById('wdSecureConsent').checked = false;\n\n      }catch(err){\n        var msg = err && err.message ? err.message : '';\n        var publicMsg = 'Your access details could not be sent. Please check the required fields and try again.';\n        if(msg === 'Invalid email') publicMsg = 'Please check your email address.';\n        if(msg === 'Required fields are missing') publicMsg = 'Please complete all required fields and confirm your consent.';\n        if(msg === 'Too many requests') publicMsg = 'Too many attempts. Please try again later.';\n        secureResult.textContent = publicMsg;\n        secureResult.classList.add('is-visible');\n      }finally{\n        secureSubmit.disabled = false;\n      }\n    });\n  }\n\n})();\n<\/script>\n\n<\/section>\t\t\t\t<\/div>\n\t\t\n<\/div>\n\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u2190 Back to Emergency Support W WebDigital Support 24\/7 technical support RAPID TECHNICAL ASSISTANCE Describe what happened. ONLINE Do not write chatting passwords, API keys or other sensitive access data. If access is required, use the secure access form. Hello! Describe what happened to your website. If possible, specify also the website address. WebDigital Support [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"elementor_header_footer","meta":{"footnotes":""},"class_list":["post-1106","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/pages\/1106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":2,"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/pages\/1106\/revisions"}],"predecessor-version":[{"id":2013,"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/pages\/1106\/revisions\/2013"}],"wp:attachment":[{"href":"https:\/\/webdigital.lv\/en\/wp-json\/wp\/v2\/media?parent=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}