$(document).ready((function(){"use strict";const t=$("#chatinput-form"),e=$("#chat-input"),n=$(".chat-conversation .chat").first();if(0===t.length||0===e.length||0===n.length)return void console.warn("Missing required elements: chatForm/chatInput/chatConversation");let i={name:"Eleanor Pena",image:"assets/images/users/avatar-7.png",email:"eleanorpena@gmail.com",phone:"+1 (555) 123-4567",position:"Software Engineer"};$(".rich-list-item").on("click",(function(t){t.preventDefault(),$(".rich-list-item").removeClass("active"),$(this).addClass("active");const e=$(this).find(".rich-list-title").text()||i.name,a=$(this).find("img"),s=$(this).data("email")||i.email,c=$(this).data("phone")||i.phone,o=$(this).data("position")||i.position,l=a.first().attr("src")||i.image;i={name:e,image:l,email:s,phone:c,position:o};const r=$(".chat-area > .card").first().find("> .d-flex > .w-100 > .p-4.border-bottom");r.find("a.fw-semibold").text(e),r.find(".avatar img").attr("src",l),n.find(".chat-item-start .chat-avatar img").each((function(){$(this).attr({src:l,alt:e})}));const m=$(".user-info");m.find(".avatar-xl img").attr("src",l),m.find("h5.mb-1").text(e),m.find(".bg-body-tertiary p.text-muted").text(o),m.find(".d-flex.align-items-center a.text-body").text(s),m.find(".d-flex.align-items-center p.text-body").text(c),a.length>1&&$(this).find("img").each((function(t){const e=$(this).attr("src");console.log("Group avatar image "+t+": "+e)}))}));const a=function(t){let e=t;for(;e.length;){const t=e.css("overflow-y");if(("auto"===t||"scroll"===t||"overlay"===t)&&e[0].scrollHeight>e[0].clientHeight)return e;e=e.parent()}return $(document.scrollingElement||document.documentElement)}(n);let s=!0;function c(){const t=a[0].scrollHeight-(a.scrollTop()+a.innerHeight());s=t<=150}function o(){a.stop().animate({scrollTop:a[0].scrollHeight},300)}function l(t){const e=t.find("img");if(0===e.length)return void(s&&o());let n=0;function i(){n++,n===e.length&&s&&o()}e.each((function(){this.complete?i():$(this).one("load error",i)})),setTimeout((()=>{s&&o()}),500)}function r(){const t=$.trim(e.val());if(!t)return;const a=$(`\n          <div class="chat-item chat-item-end">\n            <div class="chat-content">\n              <p class="chat-bubble">${t}\n                <i data-eva="done-all-outline" class="size-4 text-success align-middle blue-tick"></i>\n              </p>\n              <small class="chat-time text-muted">\n                ${(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}\n              </small>\n            </div>\n          </div>\n        `);n.append(a),e.val(""),l(a),setTimeout((()=>function(t){const e=$(`\n          <div class="chat-item chat-item-start">\n            <a href="#!" class="chat-avatar">\n              <div class="avatar-xs avatar avatar-circle">\n                <img src="${i.image}" alt="${i.name}" class="avatar-2xs">\n              </div>\n            </a>\n            <div class="chat-content">\n              <p class="chat-bubble">${t}</p>\n              <span class="chat-time text-muted fs-12">\n                ${(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}\n              </span>\n            </div>\n          </div>\n        `);n.append(e),l(e)}("Got your message!")),1e3)}a.on("scroll",c),$(window).on("resize",c),t.on("submit",(function(t){t.preventDefault(),r()})),t.find('[title="Send"]').on("click",(function(t){t.preventDefault(),r()})),c()}));