File: //proc/self/cwd/wp-content/plugins/allspice/dist/asx-bootstrap.js
(function () {
if (window.__ALLSPICE_BOOTSTRAP_INSTALLED) return;
window.__ALLSPICE_BOOTSTRAP_INSTALLED = true;
function cfg() {
return window.__ALLSPICE_BOOTSTRAP_CFG || null;
}
function hasAllspiceSlots(root) {
try {
var el = (root && root.querySelector)
? root.querySelector(
'[data-allspice-mode="premade"][data-allspice-button], ' +
'[data-allspice-id], ' +
'[data-allspice-action], ' +
'[class*="allspice-id--"], ' +
'.asx-floatwrap'
)
: null;
return !!el;
} catch (e) {
return false;
}
}
function ensurePageJs(src) {
if (!src) return;
try {
if (document.getElementById("allspice-widget-page-js")) return;
if (document.querySelector('script[src="' + src.replace(/"/g, '\\"') + '"]')) return;
var s = document.createElement("script");
s.id = "allspice-widget-page-js";
s.src = src;
s.async = true;
try { s.setAttribute("nowprocket", ""); } catch (e) {}
(document.head || document.documentElement).appendChild(s);
} catch (e) {}
}
function publishCachesOnce() {
var c = cfg();
if (!c || window.__ALLSPICE_BOOTSTRAP_CACHES_PUBLISHED) return;
window.__ALLSPICE_BOOTSTRAP_CACHES_PUBLISHED = true;
try {
if (typeof c.debug !== "undefined") window.__ALLSPICE_DEBUG = !!c.debug;
if (c.version) window.__ALLSPICE_VERSION = c.version;
if (c.page_base) window.__ALLSPICE_PAGE_BASE = c.page_base;
if (c.page_chunk_base) window.__ALLSPICE_PAGE_CHUNK_BASE = c.page_chunk_base;
if (c.page_src) window.__ALLSPICE_PAGE_SRC = c.page_src;
if (c.css_url) window.__ALLSPICE_CSS_URL = c.css_url;
if (c.umd_url) window.__ALLSPICE_UMD_URL = c.umd_url;
} catch (e) {}
try {
if (c.buttons_cache && !window.__ALLSPICE_BUTTONS_CACHE) {
window.__ALLSPICE_BUTTONS_CACHE = c.buttons_cache;
window.__ALLSPICE_CACHE_READY = window.__ALLSPICE_CACHE_READY || {};
window.__ALLSPICE_CACHE_READY.buttons = true;
try {
document.dispatchEvent(new CustomEvent("allspice:cacheReady", {
detail: { kind: "buttons" }
}));
} catch (e1) {}
}
} catch (e2) {}
try {
if (c.theme_policy && !window.__ALLSPICE_THEME_POLICY_CACHE) {
window.__ALLSPICE_THEME_POLICY_CACHE = c.theme_policy;
window.__ALLSPICE_CACHE_READY = window.__ALLSPICE_CACHE_READY || {};
window.__ALLSPICE_CACHE_READY.theme_policy = true;
try {
document.dispatchEvent(new CustomEvent("allspice:cacheReady", {
detail: { kind: "theme_policy" }
}));
} catch (e3) {}
}
} catch (e4) {}
try {
if (c.recipe_ctx && !window.__ALLSPICE_RECIPE_CTX) {
window.__ALLSPICE_RECIPE_CTX = c.recipe_ctx;
window.__ALLSPICE_CACHE_READY = window.__ALLSPICE_CACHE_READY || {};
window.__ALLSPICE_CACHE_READY.recipe_ctx = true;
try {
document.dispatchEvent(new CustomEvent("allspice:cacheReady", {
detail: { kind: "recipe_ctx" }
}));
} catch (e5) {}
}
} catch (e6) {}
}
function hasAllspiceHashHook(root) {
try {
var hash = String(window.location.hash || "");
if (hash.indexOf("#allspice-search") === 0 || hash.indexOf("#allspice-guided-cooking") === 0 || hash.indexOf("#allspice-recipe") === 0 || hash.indexOf("#allspice-groceries") === 0) {
return true;
}
var el = (root && root.querySelector)
? root.querySelector(
'a[href^="#allspice-search"], ' +
'a[href*="#allspice-search"], ' +
'a[href^="#allspice-guided-cooking"], ' +
'a[href*="#allspice-guided-cooking"], ' +
'a[href^="#allspice-recipe"], ' +
'a[href*="#allspice-recipe"], ' +
'a[href^="#allspice-groceries"], ' +
'a[href*="#allspice-groceries"]'
)
: null;
return !!el;
} catch (e) {
return false;
}
}
function startIfNeeded() {
var c = cfg();
if (!c) return;
var shouldStart = hasAllspiceSlots(document) || hasAllspiceHashHook(document);
if (!shouldStart) return;
publishCachesOnce();
// ensurePageJs(c.page_src);
}
try { startIfNeeded(); } catch (e) {}
try {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", startIfNeeded, { once: true });
}
} catch (e) {}
try {
var obs = new MutationObserver(function (mutList) {
for (var i = 0; i < mutList.length; i++) {
var m = mutList[i];
if (m.type === "childList" && m.addedNodes && m.addedNodes.length) {
if (hasAllspiceSlots(document) || hasAllspiceHashHook(document)) {
startIfNeeded();
try { obs.disconnect(); } catch (e) {}
break;
}
}
}
});
obs.observe(document.documentElement || document.body, {
childList: true,
subtree: true
});
} catch (e) {}
})();