(function (global) {
    "use strict";

    if (global.Detectizr && global.Detectizr.device) {
        global.Detectizr.device.type = "desktop";
    }

    global._ = global._ || {};
    global._.findWhere = global._.findWhere || function (items, attributes) {
        for (var index = 0; index < items.length; index += 1) {
            var item = items[index];
            var matches = true;

            for (var key in attributes) {
                if (Object.prototype.hasOwnProperty.call(attributes, key) && item[key] !== attributes[key]) {
                    matches = false;
                    break;
                }
            }

            if (matches) {
                return item;
            }
        }
    };

    // The supplied snapshot is missing later image assets; keep the first
    // interactive scene reachable instead of leaving the loading mask stuck.
    global.setTimeout(function () {
        var container = document.getElementById("preloader-container");
        if (container && container.style.display !== "none") {
            container.style.display = "none";
        }
    }, 30000);
}(window));
