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AAS,GAiBf,MAAM,UAAU,IAAI,OAjBI,CACxB,MAAM,EAAK,CAAE,WAAY,CAAC,GAE1B,KAAK,GAML,KAAK,cAAgB,eAAgB,EAAW,GAC5C,MAAM,EAAW,EAAE,cAAc,aAC3B,cAAc,EAAQ,EAAI,EAAU,EAAO,IAAI,IAAI,WAAY,EACzE,QAEM,cAAc,EAAQ,EAAI,EAAE,gBAAiB,EAAO,IAAI,IAAI,IACtE,CAE8B,IAC/B,MAAK,KACJ,MAAM,UAAU,IAAI,MAAM,GAElC,EAEJ,QAAQ,IAAM","file":"/npm/xframe@1.1.8/build/modules/xframe.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/xframe@1.1.8/build/modules/xframe.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nconst $ = require(\"jquery\");\r\nconst Exception = require(\"./exception\");\r\nconst Valid = require(\"./valid\");\r\n/** Events list */\r\nconst events = [\r\n    \"blur\",\r\n    \"focus\",\r\n    \"load\",\r\n    \"resize\",\r\n    \"scroll\",\r\n    \"unload\",\r\n    \"beforeunload\",\r\n    \"click\",\r\n    \"dblclick\",\r\n    \"mousedown\",\r\n    \"mouseup\",\r\n    \"mousemove\",\r\n    \"mouseover\",\r\n    \"mouseout\",\r\n    \"mouseenter\",\r\n    \"mouseleave\",\r\n    \"change\",\r\n    \"select\",\r\n    \"submit\",\r\n    \"keydown\",\r\n    \"keypress\",\r\n    \"keyup\"\r\n];\r\n/**\r\n * Get Component from url\r\n * @param config XFConfig\r\n * @param vm Virtual Memory\r\n * @param url Component url\r\n * @param name Component name\r\n */\r\nasync function getComponent(config, vm, url, name) {\r\n    const viewUrl = `${name ? `${url}/${name}` : url}/${config.app.filename.view}`;\r\n    const styleUrl = `${name ? `${url}/${name}` : url}/${config.app.filename.style}`;\r\n    const scriptUrl = `${name ? `${url}/${name}` : url}/${config.app.filename.script}`;\r\n    try {\r\n        const component = await Promise.all([$.get(viewUrl), $.get(styleUrl), $.get(scriptUrl)]);\r\n        return { view: component[0], style: component[1], script: component[2] };\r\n    }\r\n    catch {\r\n        throw Exception.get(\"003\", `Can not load \"${name ? name : \"XFrame App\"}\".`);\r\n    }\r\n}\r\nasync function loadEvent(config, vm, selector) {\r\n    let elements = selector.find(\"[xf-on]\");\r\n    for (let index = 0; index < elements.length; index++) {\r\n        const element = $(elements[index]);\r\n        const event = element.attr(\"xf-on\");\r\n        const component = element.attr(\"xf-load\");\r\n        const frame = element.attr(\"xf-into\");\r\n        if (event) {\r\n            if (events.includes(event)) {\r\n                if (component) {\r\n                    if (frame) {\r\n                        const frameSelector = $(`[xf-frame=\"${frame}\"]`);\r\n                        if (event == \"load\") {\r\n                            await pourComponent(config, vm, frameSelector, config.app.src.components, component);\r\n                        }\r\n                        else\r\n                            element.on(event, async () => await pourComponent(config, vm, frameSelector, config.app.src.components, component));\r\n                    }\r\n                    else\r\n                        throw Exception.get(\"005\", \"Frame undefined\");\r\n                }\r\n                else\r\n                    throw Exception.get(\"005\", \"Component undefined\");\r\n            }\r\n            else\r\n                throw Exception.get(\"005\", `Event \"${event}\" invalid`);\r\n        }\r\n        else\r\n            throw Exception.get(\"005\", \"Event undefined\");\r\n    }\r\n}\r\n/**\r\n * Pour Component into Selector\r\n * @param config XFConfig\r\n * @param vm Virtual Memory\r\n * @param selector jQuery Selector\r\n * @param url Component url\r\n * @param name Component name\r\n */\r\nasync function pourComponent(config, vm, selector, url, name) {\r\n    selector.html(config.app.extands.loading);\r\n    let component;\r\n    if (name) {\r\n        if (!Valid.hasComponent(vm, name)) {\r\n            vm.components[name] = await getComponent(config, vm, url, name);\r\n        }\r\n        component = vm.components[name];\r\n    }\r\n    else\r\n        component = await getComponent(config, vm, url);\r\n    selector.html(`<style>${component.style}</style>${component.view}`);\r\n    $(\"head\").append(`<script xf-temp=\"${name}\">${component.script}</script>`);\r\n    $(\"script[xf-temp]\").remove();\r\n    await loadEvent(config, vm, selector);\r\n}\r\n/**\r\n * Initialization\r\n * @param config XFConfig\r\n */\r\nfunction init(config) {\r\n    // Use jQuery or not\r\n    window.$ = window.jQuery = config.app.bundle.jquery ? $ : undefined;\r\n    // Load plugins\r\n    if (Valid.isPlugin(config.plugins)) {\r\n        Object.keys(config.plugins).forEach(async (name) => {\r\n            if (Valid.hasStyle(config.plugins, name)) {\r\n                config.plugins[name].style.forEach(async (url) => {\r\n                    try {\r\n                        $(\"head\").append(`<style xf-plugin=\"${name}\">${await $.get(url)}</style>`);\r\n                    }\r\n                    catch {\r\n                        throw Exception.get(\"004\");\r\n                    }\r\n                });\r\n            }\r\n            if (Valid.hasScript(config.plugins, name)) {\r\n                config.plugins[name].script.forEach(async (url) => {\r\n                    try {\r\n                        $(\"head\").append(`<script xf-temp=\"${name}\">${await $.get(url)}</script>`);\r\n                        $(`script[xf-temp]`).remove();\r\n                    }\r\n                    catch {\r\n                        throw Exception.get(\"004\", name);\r\n                    }\r\n                });\r\n            }\r\n        });\r\n    }\r\n    else\r\n        throw Exception.get(\"002\");\r\n}\r\n/** XFrame App class */\r\nclass App {\r\n    /**\r\n     * Create XFrame App\r\n     * @param url path url of XFConfig file\r\n     */\r\n    constructor(url) {\r\n        $.getJSON(url, async (config) => {\r\n            if (Valid.isConfig(config)) {\r\n                const vm = { components: {} };\r\n                // Initialization\r\n                init(config);\r\n                /**\r\n                 * Load Component into Frame\r\n                 * @param component Component\r\n                 * @param frame Frame\r\n                 */\r\n                this.loadComponent = async function (component, frame) {\r\n                    const selector = $(`[xf-frame=\"${frame}\"]`);\r\n                    await pourComponent(config, vm, selector, config.app.src.components, component);\r\n                };\r\n                // Load App\r\n                await pourComponent(config, vm, $(\"main[xf-app]\"), config.app.src.app);\r\n            }\r\n            else\r\n                throw Exception.get(\"001\");\r\n        }).fail(() => {\r\n            throw Exception.get(\"000\");\r\n        });\r\n    }\r\n}\r\nexports.App = App;\r\n"]}