PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
| Dir : /home/distinctdesign/codenwebz.com/website-design-3/js/ |
| Server: Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 IP: 162.0.232.53 |
| Dir : /home/distinctdesign/codenwebz.com/website-design-3/js/ada-chat-widget.js |
// Initial widget ADA fix for LeadConnector chat-widget shadow root
const leadConnectorInitialSelectionAdaPatch = () => {
const widgetSelector = 'chat-widget';
const observedRootNodes = new WeakSet();
const processedSelectionButtonElements = new WeakSet();
const getNestedShadowRoots = (rootNode) => {
const nestedShadowRoots = [];
rootNode.querySelectorAll('*').forEach((possibleHostElement) => {
if (possibleHostElement.shadowRoot) {
nestedShadowRoots.push(possibleHostElement.shadowRoot);
}
});
return nestedShadowRoots;
};
const patchInitialSelectionButtons = (rootNode) => {
rootNode.querySelectorAll('ion-button.chat-selection-button').forEach((selectionButtonElement) => {
const buttonTextElement = selectionButtonElement.querySelector('.chat-selection-button-text');
const buttonTextContent = buttonTextElement ? buttonTextElement.textContent.trim() : '';
if (selectionButtonElement.getAttribute('role') !== 'button') {
selectionButtonElement.setAttribute('role', 'button');
}
if (selectionButtonElement.getAttribute('tabindex') !== '0') {
selectionButtonElement.setAttribute('tabindex', '0');
}
if (buttonTextContent && selectionButtonElement.getAttribute('aria-label') !== buttonTextContent) {
selectionButtonElement.setAttribute('aria-label', buttonTextContent);
}
selectionButtonElement.querySelectorAll('svg').forEach((selectionButtonIconElement) => {
if (selectionButtonIconElement.getAttribute('aria-hidden') !== 'true') {
selectionButtonIconElement.setAttribute('aria-hidden', 'true');
}
if (selectionButtonIconElement.getAttribute('focusable') !== 'false') {
selectionButtonIconElement.setAttribute('focusable', 'false');
}
});
if (!processedSelectionButtonElements.has(selectionButtonElement)) {
selectionButtonElement.addEventListener('keydown', (keyboardEvent) => {
const pressedKey = keyboardEvent.key;
if (pressedKey === 'Enter' || pressedKey === ' ') {
keyboardEvent.preventDefault();
selectionButtonElement.click();
}
});
processedSelectionButtonElements.add(selectionButtonElement);
}
});
};
const patchRootNode = (rootNode) => {
patchInitialSelectionButtons(rootNode);
getNestedShadowRoots(rootNode).forEach((nestedShadowRoot) => {
patchRootNode(nestedShadowRoot);
watchRootNode(nestedShadowRoot);
});
};
const watchRootNode = (rootNode) => {
if (observedRootNodes.has(rootNode)) {
return;
}
patchRootNode(rootNode);
const rootNodeObserver = new MutationObserver((mutationRecords) => {
const hasRelevantMutation = mutationRecords.some((mutationRecord) => {
return mutationRecord.type === 'childList';
});
if (hasRelevantMutation) {
patchRootNode(rootNode);
}
});
rootNodeObserver.observe(rootNode, {
childList: true,
subtree: true
});
observedRootNodes.add(rootNode);
};
const connectWidgets = () => {
document.querySelectorAll(widgetSelector).forEach((widgetElement) => {
if (widgetElement.shadowRoot) {
watchRootNode(widgetElement.shadowRoot);
}
});
};
connectWidgets();
const documentObserver = new MutationObserver(() => {
connectWidgets();
});
documentObserver.observe(document.documentElement, {
childList: true,
subtree: true
});
};
leadConnectorInitialSelectionAdaPatch();
// SMS form ADA fix for LeadConnector chat-widget shadow root
// ** //
const leadConnectorAdaPatch = () => {
const widgetSelector = 'chat-widget';
const processedShadowRoots = new WeakSet();
const processedConsentCheckboxElements = new WeakSet();
const processedSendButtonElements = new WeakSet();
const processedStyleRoots = new WeakSet();
const processedBackButtonElements = new WeakSet();
const processedCloseButtonElements = new WeakSet();
const observedConsentCheckboxElements = new WeakSet();
let patchFrameIsQueued = false;
const ensureLegalMessageId = (legalMessageElement) => {
let legalMessageId = legalMessageElement.getAttribute('id');
if (!legalMessageId) {
legalMessageId = `lc-legal-msg-${Math.random().toString(36).slice(2, 10)}`;
legalMessageElement.setAttribute('id', legalMessageId);
}
return legalMessageId;
};
const updateConsentCheckboxState = (consentCheckboxElement) => {
const isChecked = consentCheckboxElement.classList.contains('checkbox-checked')
|| consentCheckboxElement.getAttribute('aria-checked') === 'true';
if (consentCheckboxElement.getAttribute('role') !== 'checkbox') {
consentCheckboxElement.setAttribute('role', 'checkbox');
}
if (consentCheckboxElement.getAttribute('tabindex') !== '0') {
consentCheckboxElement.setAttribute('tabindex', '0');
}
if (consentCheckboxElement.getAttribute('aria-checked') !== (isChecked ? 'true' : 'false')) {
consentCheckboxElement.setAttribute('aria-checked', isChecked ? 'true' : 'false');
}
};
const patchConsentCheckbox = (shadowRoot) => {
shadowRoot.querySelectorAll('.lc_legal-text').forEach((legalTextContainerElement) => {
const consentCheckboxElement = legalTextContainerElement.querySelector('ion-checkbox');
const legalMessageElement = legalTextContainerElement.querySelector('.lc_legal-msg');
if (!consentCheckboxElement || !legalMessageElement) {
return;
}
const legalMessageId = ensureLegalMessageId(legalMessageElement);
updateConsentCheckboxState(consentCheckboxElement);
if (consentCheckboxElement.getAttribute('aria-labelledby') !== legalMessageId) {
consentCheckboxElement.setAttribute('aria-labelledby', legalMessageId);
}
if (!processedConsentCheckboxElements.has(consentCheckboxElement)) {
consentCheckboxElement.addEventListener('keydown', (keyboardEvent) => {
const pressedKey = keyboardEvent.key;
if (pressedKey === ' ' || pressedKey === 'Enter') {
keyboardEvent.preventDefault();
consentCheckboxElement.click();
}
});
processedConsentCheckboxElements.add(consentCheckboxElement);
}
if (!observedConsentCheckboxElements.has(consentCheckboxElement)) {
const consentCheckboxObserver = new MutationObserver(() => {
updateConsentCheckboxState(consentCheckboxElement);
});
consentCheckboxObserver.observe(consentCheckboxElement, {
attributes: true,
attributeFilter: ['class', 'aria-checked']
});
observedConsentCheckboxElements.add(consentCheckboxElement);
}
});
};
const patchSendButton = (shadowRoot) => {
shadowRoot.querySelectorAll('#lc_text-widget--send-btn').forEach((sendButtonElement) => {
if (sendButtonElement.getAttribute('aria-label') !== 'Send message') {
sendButtonElement.setAttribute('aria-label', 'Send message');
}
sendButtonElement.querySelectorAll('svg').forEach((sendButtonIconElement) => {
if (sendButtonIconElement.getAttribute('aria-hidden') !== 'true') {
sendButtonIconElement.setAttribute('aria-hidden', 'true');
}
if (sendButtonIconElement.getAttribute('focusable') !== 'false') {
sendButtonIconElement.setAttribute('focusable', 'false');
}
});
processedSendButtonElements.add(sendButtonElement);
});
};
const patchFocusStyles = (shadowRoot) => {
if (processedStyleRoots.has(shadowRoot)) {
return;
}
const focusStyleElement = document.createElement('style');
focusStyleElement.setAttribute('data-ada-lc-focus-styles', '1');
focusStyleElement.textContent = `
#lc_text-widget--send-btn:focus,
#lc_text-widget--send-btn:focus-visible {
outline: 1px solid #fff;
outline-offset: -3px;
}
.lc_text-widget--text-input-input:focus,
.lc_text-widget--text-input-input:focus-visible {
outline: auto;
}
`;
shadowRoot.appendChild(focusStyleElement);
processedStyleRoots.add(shadowRoot);
};
const patchBackButton = (shadowRoot) => {
shadowRoot.querySelectorAll('.lc_text-widget--back-button').forEach((backButtonElement) => {
if (backButtonElement.getAttribute('role') !== 'button') {
backButtonElement.setAttribute('role', 'button');
}
if (backButtonElement.getAttribute('tabindex') !== '0') {
backButtonElement.setAttribute('tabindex', '0');
}
if (!backButtonElement.getAttribute('aria-label')) {
backButtonElement.setAttribute('aria-label', 'Back');
}
if (!processedBackButtonElements.has(backButtonElement)) {
backButtonElement.addEventListener('keydown', (keyboardEvent) => {
const pressedKey = keyboardEvent.key;
if (pressedKey === 'Enter' || pressedKey === ' ') {
keyboardEvent.preventDefault();
backButtonElement.click();
}
});
processedBackButtonElements.add(backButtonElement);
}
});
};
const patchCloseButton = (shadowRoot) => {
shadowRoot.querySelectorAll('.lc_text-widget_heading_close--btn').forEach((closeButtonElement) => {
if (closeButtonElement.getAttribute('role') !== 'button') {
closeButtonElement.setAttribute('role', 'button');
}
if (closeButtonElement.getAttribute('tabindex') !== '0') {
closeButtonElement.setAttribute('tabindex', '0');
}
if (!closeButtonElement.getAttribute('aria-label')) {
closeButtonElement.setAttribute('aria-label', 'Close');
}
closeButtonElement.querySelectorAll('svg').forEach((closeButtonIconElement) => {
if (closeButtonIconElement.getAttribute('aria-hidden') !== 'true') {
closeButtonIconElement.setAttribute('aria-hidden', 'true');
}
if (closeButtonIconElement.getAttribute('focusable') !== 'false') {
closeButtonIconElement.setAttribute('focusable', 'false');
}
});
if (!processedCloseButtonElements.has(closeButtonElement)) {
closeButtonElement.addEventListener('keydown', (keyboardEvent) => {
const pressedKey = keyboardEvent.key;
if (pressedKey === 'Enter' || pressedKey === ' ') {
keyboardEvent.preventDefault();
closeButtonElement.click();
}
});
processedCloseButtonElements.add(closeButtonElement);
}
});
};
const patchShadowRoot = (shadowRoot) => {
patchConsentCheckbox(shadowRoot);
patchSendButton(shadowRoot);
patchBackButton(shadowRoot);
patchCloseButton(shadowRoot);
patchFocusStyles(shadowRoot);
};
const queueShadowRootPatch = (shadowRoot) => {
if (patchFrameIsQueued) {
return;
}
patchFrameIsQueued = true;
requestAnimationFrame(() => {
patchFrameIsQueued = false;
patchShadowRoot(shadowRoot);
});
};
const watchWidgetShadowRoot = (widgetElement) => {
if (!widgetElement.shadowRoot || processedShadowRoots.has(widgetElement.shadowRoot)) {
return;
}
patchShadowRoot(widgetElement.shadowRoot);
const shadowRootObserver = new MutationObserver((mutationRecords) => {
const hasRelevantMutation = mutationRecords.some((mutationRecord) => {
return mutationRecord.type === 'childList';
});
if (hasRelevantMutation) {
queueShadowRootPatch(widgetElement.shadowRoot);
}
});
shadowRootObserver.observe(widgetElement.shadowRoot, {
childList: true,
subtree: true
});
processedShadowRoots.add(widgetElement.shadowRoot);
};
const connectWidgets = () => {
document.querySelectorAll(widgetSelector).forEach((widgetElement) => {
watchWidgetShadowRoot(widgetElement);
});
};
connectWidgets();
const documentObserver = new MutationObserver(() => {
connectWidgets();
});
documentObserver.observe(document.documentElement, {
childList: true,
subtree: true
});
};
leadConnectorAdaPatch();
(() => {
// What this does (optimized):
// - Observes each discovered OPEN shadowRoot (needed for nested shadow trees).
// - On mutations, only processes added nodes and only patches relevant elements.
// - Avoids repeated full-root scans.
const widgetSelector = 'chat-widget';
const observedShadowRoots = new WeakSet();
const observedWidgetElements = new WeakSet();
const patchSendButtonElement = (sendButtonElement) => {
if (sendButtonElement.getAttribute('aria-label') !== 'Send message') {
sendButtonElement.setAttribute('aria-label', 'Send message');
}
sendButtonElement.querySelectorAll('svg').forEach((sendButtonIconElement) => {
if (sendButtonIconElement.getAttribute('aria-hidden') !== 'true') {
sendButtonIconElement.setAttribute('aria-hidden', 'true');
}
if (sendButtonIconElement.getAttribute('focusable') !== 'false') {
sendButtonIconElement.setAttribute('focusable', 'false');
}
});
};
const patchChatPaneElement = (chatPaneElement) => {
if (chatPaneElement.getAttribute('role') !== 'log') {
chatPaneElement.setAttribute('role', 'log');
}
if (chatPaneElement.getAttribute('aria-live') !== 'polite') {
chatPaneElement.setAttribute('aria-live', 'polite');
}
if (chatPaneElement.getAttribute('aria-relevant') !== 'additions text') {
chatPaneElement.setAttribute('aria-relevant', 'additions text');
}
if (chatPaneElement.getAttribute('aria-atomic') !== 'false') {
chatPaneElement.setAttribute('aria-atomic', 'false');
}
if (!chatPaneElement.getAttribute('aria-label')) {
chatPaneElement.setAttribute('aria-label', 'Live chat messages');
}
};
const patchWithinRoot = (rootNode) => {
rootNode.querySelectorAll('.live-chat-send-button').forEach(patchSendButtonElement);
rootNode.querySelectorAll('chat-pane').forEach(patchChatPaneElement);
};
const discoverShadowRootsWithinNode = (nodeElement) => {
if (!nodeElement || nodeElement.nodeType !== Node.ELEMENT_NODE) {
return;
}
const elementQueue = [nodeElement];
while (elementQueue.length) {
const currentElement = elementQueue.shift();
if (currentElement.shadowRoot) {
observeShadowRoot(currentElement.shadowRoot);
patchWithinRoot(currentElement.shadowRoot);
}
currentElement.querySelectorAll('*').forEach((childElement) => {
elementQueue.push(childElement);
});
}
};
const handleAddedNode = (addedNode) => {
if (addedNode.nodeType !== Node.ELEMENT_NODE) {
return;
}
const addedElement = /** @type {Element} */ (addedNode);
if (addedElement.matches('.live-chat-send-button')) {
patchSendButtonElement(addedElement);
}
if (addedElement.matches('chat-pane')) {
patchChatPaneElement(addedElement);
}
addedElement.querySelectorAll('.live-chat-send-button').forEach(patchSendButtonElement);
addedElement.querySelectorAll('chat-pane').forEach(patchChatPaneElement);
discoverShadowRootsWithinNode(addedElement);
};
const observeShadowRoot = (shadowRoot) => {
if (observedShadowRoots.has(shadowRoot)) {
return;
}
observedShadowRoots.add(shadowRoot);
patchWithinRoot(shadowRoot);
const shadowRootObserver = new MutationObserver((mutationRecordList) => {
mutationRecordList.forEach((mutationRecord) => {
if (mutationRecord.type === 'childList') {
mutationRecord.addedNodes.forEach(handleAddedNode);
}
if (mutationRecord.type === 'attributes') {
const targetElement = mutationRecord.target;
if (targetElement && targetElement.nodeType === Node.ELEMENT_NODE) {
const targetAsElement = /** @type {Element} */ (targetElement);
if (targetAsElement.matches('.live-chat-send-button')) {
patchSendButtonElement(targetAsElement);
}
if (targetAsElement.matches('chat-pane')) {
patchChatPaneElement(targetAsElement);
}
}
}
});
});
shadowRootObserver.observe(shadowRoot, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['class', 'aria-label', 'role', 'aria-live', 'aria-relevant', 'aria-atomic', 'disabled']
});
// Discover nested roots once per root (initial connect).
shadowRoot.querySelectorAll('*').forEach((childElement) => {
if (childElement.shadowRoot) {
observeShadowRoot(childElement.shadowRoot);
}
});
};
const observeWidgetElement = (widgetElement) => {
if (!observedWidgetElements.has(widgetElement)) {
observedWidgetElements.add(widgetElement);
}
if (widgetElement.shadowRoot) {
observeShadowRoot(widgetElement.shadowRoot);
}
};
const connectWidgets = () => {
document.querySelectorAll(widgetSelector).forEach(observeWidgetElement);
};
connectWidgets();
const documentObserver = new MutationObserver(() => {
connectWidgets();
});
documentObserver.observe(document.documentElement, {
childList: true,
subtree: true
});
})();
(() => {
// What this does:
// - Watches every discovered OPEN shadowRoot under <chat-widget>.
// - When a .lc_text-widget_sub-heading appears, it:
// - sets role="status" and aria-live="polite"
// - adds tabindex="-1" (only if missing)
// - focuses it once (only the first time for that element)
const widgetSelector = 'chat-widget';
const targetSelector = '.lc_text-widget_sub-heading';
const observedShadowRoots = new WeakSet();
const observedWidgetElements = new WeakSet();
const focusedTargets = new WeakSet();
const patchTargetElement = (targetElement) => {
if (targetElement.getAttribute('role') !== 'status') {
targetElement.setAttribute('role', 'status');
}
if (targetElement.getAttribute('aria-live') !== 'polite') {
targetElement.setAttribute('aria-live', 'polite');
}
const tabindexValue = targetElement.getAttribute('tabindex');
const hasTabindex = tabindexValue !== null;
if (!hasTabindex) {
targetElement.setAttribute('tabindex', '-1');
}
const alreadyFocusedThisElement = focusedTargets.has(targetElement);
if (!alreadyFocusedThisElement) {
focusedTargets.add(targetElement);
const maxFocusAttempts = 12;
const focusAttemptDelayMs = 50;
let focusAttemptIndex = 0;
const attemptFocus = () => {
const isConnected = targetElement.isConnected === true;
const hasLayoutBox = targetElement.getClientRects().length > 0;
if (isConnected && hasLayoutBox) {
targetElement.focus({ preventScroll: true });
}
focusAttemptIndex += 1;
const shouldRetry = !(isConnected && hasLayoutBox) && focusAttemptIndex < maxFocusAttempts;
if (shouldRetry) {
setTimeout(attemptFocus, focusAttemptDelayMs);
}
};
requestAnimationFrame(() => {
setTimeout(attemptFocus, 0);
});
}
};
const patchWithinRootNode = (rootNode) => {
rootNode.querySelectorAll(targetSelector).forEach(patchTargetElement);
};
const discoverShadowRootsWithinNode = (nodeElement) => {
if (!nodeElement || nodeElement.nodeType !== Node.ELEMENT_NODE) {
return;
}
const elementQueue = [nodeElement];
while (elementQueue.length) {
const currentElement = elementQueue.shift();
if (currentElement.shadowRoot) {
observeShadowRoot(currentElement.shadowRoot);
patchWithinRootNode(currentElement.shadowRoot);
}
currentElement.querySelectorAll('*').forEach((childElement) => {
elementQueue.push(childElement);
});
}
};
const handleAddedNode = (addedNode) => {
if (addedNode.nodeType !== Node.ELEMENT_NODE) {
return;
}
const addedElement = /** @type {Element} */ (addedNode);
if (addedElement.matches(targetSelector)) {
patchTargetElement(addedElement);
}
addedElement.querySelectorAll(targetSelector).forEach(patchTargetElement);
discoverShadowRootsWithinNode(addedElement);
};
const observeShadowRoot = (shadowRoot) => {
if (observedShadowRoots.has(shadowRoot)) {
return;
}
observedShadowRoots.add(shadowRoot);
patchWithinRootNode(shadowRoot);
const shadowRootObserver = new MutationObserver((mutationRecordList) => {
mutationRecordList.forEach((mutationRecord) => {
if (mutationRecord.type === 'childList') {
mutationRecord.addedNodes.forEach(handleAddedNode);
}
if (mutationRecord.type === 'attributes') {
const mutationTarget = mutationRecord.target;
if (mutationTarget && mutationTarget.nodeType === Node.ELEMENT_NODE) {
const mutationTargetElement = /** @type {Element} */ (mutationTarget);
if (mutationTargetElement.matches(targetSelector)) {
patchTargetElement(mutationTargetElement);
}
}
}
});
});
shadowRootObserver.observe(shadowRoot, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['class', 'role', 'aria-live', 'tabindex']
});
shadowRoot.querySelectorAll('*').forEach((childElement) => {
if (childElement.shadowRoot) {
observeShadowRoot(childElement.shadowRoot);
}
});
};
const observeWidgetElement = (widgetElement) => {
if (!observedWidgetElements.has(widgetElement)) {
observedWidgetElements.add(widgetElement);
}
if (widgetElement.shadowRoot) {
observeShadowRoot(widgetElement.shadowRoot);
}
};
const connectWidgets = () => {
document.querySelectorAll(widgetSelector).forEach(observeWidgetElement);
};
connectWidgets();
const documentObserver = new MutationObserver(() => {
connectWidgets();
});
documentObserver.observe(document.documentElement, {
childList: true,
subtree: true
});
})();