PageSourceSearch

https://app.syndicast.co.uk/assets/vendor/requirejs/require.js?v3.18.6

js syndicast.co.uk collected 2026-09-25 02:47:16 UTC 85,921 bytes, 2,129 lines download raw bytes

vendor: 5,570 bytes, lines 1-165
1/** vim: et:ts=4:sw=4:sts=4
2 * @license RequireJS 2.1.22 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
3 * Available via the MIT or new BSD license.
4 * see: http://github.com/jrburke/requirejs for details
5 */
6//Not using strict: uneven strict support in browsers, #392, and causes
7//problems with requirejs.exec()/transpiler plugins that may not be strict.
8/*jslint regexp: true, nomen: true, sloppy: true */
9/*global window, navigator, document, importScripts, setTimeout, opera */
10
11var requirejs, require, define;
12(function (global) {
13    var req, s, head, baseElement, dataMain, src,
14        interactiveScript, currentlyAddingScript, mainScript, subPath,
15        version = '2.1.22',
16        commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
17        cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
18        jsSuffixRegExp = /\.js$/,
19        currDirRegExp = /^\.\//,
20        op = Object.prototype,
21        ostring = op.toString,
22        hasOwn = op.hasOwnProperty,
23        ap = Array.prototype,
24        isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
25        isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
26        //PS3 indicates loaded and complete, but need to wait for complete
27        //specifically. Sequence is 'loading', 'loaded', execution,
28        // then 'complete'. The UA check is unfortunate, but not sure how
29        //to feature test w/o causing perf issues.
30        readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
31                      /^complete$/ : /^(complete|loaded)$/,
32        defContextName = '_',
33        //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
34        isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
35        contexts = {},
36        cfg = {},
37        globalDefQueue = [],
38        useInteractive = false;
39
40    function isFunction(it) {
41        return ostring.call(it) === '[object Function]';
42    }
43
44    function isArray(it) {
45        return ostring.call(it) === '[object Array]';
46    }
47
48    /**
49     * Helper function for iterating over an array. If the func returns
50     * a true value, it will break out of the loop.
51     */
52    function each(ary, func) {
53        if (ary) {
54            var i;
55            for (i = 0; i < ary.length; i += 1) {
56                if (ary[i] && func(ary[i], i, ary)) {
57                    break;
58                }
59            }
60        }
61    }
62
63    /**
64     * Helper function for iterating over an array backwards. If the func
65     * returns a true value, it will break out of the loop.
66     */
67    function eachReverse(ary, func) {
68        if (ary) {
69            var i;
70            for (i = ary.length - 1; i > -1; i -= 1) {
71                if (ary[i] && func(ary[i], i, ary)) {
72                    break;
73                }
74            }
75        }
76    }
77
78    function hasProp(obj, prop) {
79        return hasOwn.call(obj, prop);
80    }
81
82    function getOwn(obj, prop) {
83        return hasProp(obj, prop) && obj[prop];
84    }
85
86    /**
87     * Cycles over properties in an object and calls a function for each
88     * property value. If the function returns a truthy value, then the
89     * iteration is stopped.
90     */
91    function eachProp(obj, func) {
92        var prop;
93        for (prop in obj) {
94            if (hasProp(obj, prop)) {
95                if (func(obj[prop], prop)) {
96                    break;
97                }
98            }
99        }
100    }
101
102    /**
103     * Simple function to mix in properties from source into target,
104     * but only if target does not already have a property of the same name.
105     */
106    function mixin(target, source, force, deepStringMixin) {
107        if (source) {
108            eachProp(source, function (value, prop) {
109                if (force || !hasProp(target, prop)) {
110                    if (deepStringMixin && typeof value === 'object' && value &&
111                        !isArray(value) && !isFunction(value) &&
112                        !(value instanceof RegExp)) {
113
114                        if (!target[prop]) {
115                            target[prop] = {};
116                        }
117                        mixin(target[prop], value, force, deepStringMixin);
118                    } else {
119                        target[prop] = value;
120                    }
121                }
122            });
123        }
124        return target;
125    }
126
127    //Similar to Function.prototype.bind, but the 'this' object is specified
128    //first, since it is easier to read/figure out what 'this' will be.
129    function bind(obj, fn) {
130        return function () {
131            return fn.apply(obj, arguments);
132        };
133    }
134
135    function scripts() {
136        return document.getElementsByTagName('script');
137    }
138
139    function defaultOnError(err) {
140        throw err;
141    }
142
143    //Allow getting a global that is expressed in
144    //dot notation, like 'a.b.c'.
145    function getGlobal(value) {
146        if (!value) {
147            return value;
148        }
149        var g = global;
150        each(value.split('.'), function (part) {
151            g = g[part];
152        });
153        return g;
154    }
155
156    /**
157     * Constructs an error with a pointer to an URL with more information.
158     * @param {String} id the error ID that maps to an ID on a web page.
159     * @param {String} message human readable error.
160     * @param {Error} [err] the original error, if there is one.
161     *
162     * @returns {Error}
163     */
164    function makeError(id, msg, err, requireModules) {
165        var e = new Error(msg + '\nhttp
vendor: 27,045 bytes, lines 165-864
165://requirejs.org/docs/errors.html#' + id);
166        e.requireType = id;
167        e.requireModules = requireModules;
168        if (err) {
169            e.originalError = err;
170        }
171        return e;
172    }
173
174    if (typeof define !== 'undefined') {
175        //If a define is already in play via another AMD loader,
176        //do not overwrite.
177        return;
178    }
179
180    if (typeof requirejs !== 'undefined') {
181        if (isFunction(requirejs)) {
182            //Do not overwrite an existing requirejs instance.
183            return;
184        }
185        cfg = requirejs;
186        requirejs = undefined;
187    }
188
189    //Allow for a require config object
190    if (typeof require !== 'undefined' && !isFunction(require)) {
191        //assume it is a config object.
192        cfg = require;
193        require = undefined;
194    }
195
196    function newContext(contextName) {
197        var inCheckLoaded, Module, context, handlers,
198            checkLoadedTimeoutId,
199            config = {
200                //Defaults. Do not set a default for map
201                //config to speed up normalize(), which
202                //will run faster if there is no default.
203                waitSeconds: 7,
204                baseUrl: './',
205                paths: {},
206                bundles: {},
207                pkgs: {},
208                shim: {},
209                config: {}
210            },
211            registry = {},
212            //registry of just enabled modules, to speed
213            //cycle breaking code when lots of modules
214            //are registered, but not activated.
215            enabledRegistry = {},
216            undefEvents = {},
217            defQueue = [],
218            defined = {},
219            urlFetched = {},
220            bundlesMap = {},
221            requireCounter = 1,
222            unnormalizedCounter = 1;
223
224        /**
225         * Trims the . and .. from an array of path segments.
226         * It will keep a leading path segment if a .. will become
227         * the first path segment, to help with module name lookups,
228         * which act like paths, but can be remapped. But the end result,
229         * all paths that use this function should look normalized.
230         * NOTE: this method MODIFIES the input array.
231         * @param {Array} ary the array of path segments.
232         */
233        function trimDots(ary) {
234            var i, part;
235            for (i = 0; i < ary.length; i++) {
236                part = ary[i];
237                if (part === '.') {
238                    ary.splice(i, 1);
239                    i -= 1;
240                } else if (part === '..') {
241                    // If at the start, or previous value is still ..,
242                    // keep them so that when converted to a path it may
243                    // still work when converted to a path, even though
244                    // as an ID it is less than ideal. In larger point
245                    // releases, may be better to just kick out an error.
246                    if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {
247                        continue;
248                    } else if (i > 0) {
249                        ary.splice(i - 1, 2);
250                        i -= 2;
251                    }
252                }
253            }
254        }
255
256        /**
257         * Given a relative module name, like ./something, normalize it to
258         * a real name that can be mapped to a path.
259         * @param {String} name the relative name
260         * @param {String} baseName a real name that the name arg is relative
261         * to.
262         * @param {Boolean} applyMap apply the map config to the value. Should
263         * only be done if this normalization is for a dependency ID.
264         * @returns {String} normalized name
265         */
266        function normalize(name, baseName, applyMap) {
267            var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,
268                foundMap, foundI, foundStarMap, starI, normalizedBaseParts,
269                baseParts = (baseName && baseName.split('/')),
270                map = config.map,
271                starMap = map && map['*'];
272
273            //Adjust any relative paths.
274            if (name) {
275                name = name.split('/');
276                lastIndex = name.length - 1;
277
278                // If wanting node ID compatibility, strip .js from end
279                // of IDs. Have to do this here, and not in nameToUrl
280                // because node allows either .js or non .js to map
281                // to same file.
282                if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
283                    name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
284                }
285
286                // Starts with a '.' so need the baseName
287                if (name[0].charAt(0) === '.' && baseParts) {
288                    //Convert baseName to array, and lop off the last part,
289                    //so that . matches that 'directory' and not name of the baseName's
290                    //module. For instance, baseName of 'one/two/three', maps to
291                    //'one/two/three.js', but we want the directory, 'one/two' for
292                    //this normalization.
293                    normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
294                    name = normalizedBaseParts.concat(name);
295                }
296
297                trimDots(name);
298                name = name.join('/');
299            }
300
301            //Apply map config if available.
302            if (applyMap && map && (baseParts || starMap)) {
303                nameParts = name.split('/');
304
305                outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
306                    nameSegment = nameParts.slice(0, i).join('/');
307
308                    if (baseParts) {
309                        //Find the longest baseName segment match in the config.
310                        //So, do joins on the biggest to smallest lengths of baseParts.
311                        for (j = baseParts.length; j > 0; j -= 1) {
312                            mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
313
314                            //baseName segment has config, find if it has one for
315                            //this name.
316                            if (mapValue) {
317                                mapValue = getOwn(mapValue, nameSegment);
318                                if (mapValue) {
319                                    //Match, update name to the new value.
320                                    foundMap = mapValue;
321                                    foundI = i;
322                                    break outerLoop;
323                                }
324                            }
325                        }
326                    }
327
328                    //Check for a star map match, but just hold on to it,
329                    //if there is a shorter segment match later in a matching
330                    //config, then favor over this star map.
331                    if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
332                        foundStarMap = getOwn(starMap, nameSegment);
333                        starI = i;
334                    }
335                }
336
337                if (!foundMap && foundStarMap) {
338                    foundMap = foundStarMap;
339                    foundI = starI;
340                }
341
342                if (foundMap) {
343                    nameParts.splice(0, foundI, foundMap);
344                    name = nameParts.join('/');
345                }
346            }
347
348            // If the name points to a package's name, use
349            // the package main instead.
350            pkgMain = getOwn(config.pkgs, name);
351
352            return pkgMain ? pkgMain : name;
353        }
354
355        function removeScript(name) {
356            if (isBrowser) {
357                each(scripts(), function (scriptNode) {
358                    if (scriptNode.getAttribute('data-requiremodule') === name &&
359                            scriptNode.getAttribute('data-requirecontext') === context.contextName) {
360                        scriptNode.parentNode.removeChild(scriptNode);
361                        return true;
362                    }
363                });
364            }
365        }
366
367        function hasPathFallback(id) {
368            var pathConfig = getOwn(config.paths, id);
369            if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
370                //Pop off the first array value, since it failed, and
371                //retry
372                pathConfig.shift();
373                context.require.undef(id);
374
375                //Custom require that does not do map translation, since
376                //ID is "absolute", already mapped/resolved.
377                context.makeRequire(null, {
378                    skipMap: true
379                })([id]);
380
381                return true;
382            }
383        }
384
385        //Turns a plugin!resource to [plugin, resource]
386        //with the plugin being undefined if the name
387        //did not have a plugin prefix.
388        function splitPrefix(name) {
389            var prefix,
390                index = name ? name.indexOf('!') : -1;
391            if (index > -1) {
392                prefix = name.substring(0, index);
393                name = name.substring(index + 1, name.length);
394            }
395            return [prefix, name];
396        }
397
398        /**
399         * Creates a module mapping that includes plugin prefix, module
400         * name, and path. If parentModuleMap is provided it will
401         * also normalize the name via require.normalize()
402         *
403         * @param {String} name the module name
404         * @param {String} [parentModuleMap] parent module map
405         * for the module name, used to resolve relative names.
406         * @param {Boolean} isNormalized: is the ID already normalized.
407         * This is true if this call is done for a define() module ID.
408         * @param {Boolean} applyMap: apply the map config to the ID.
409         * Should only be true if this map is for a dependency.
410         *
411         * @returns {Object}
412         */
413        function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
414            var url, pluginModule, suffix, nameParts,
415                prefix = null,
416                parentName = parentModuleMap ? parentModuleMap.name : null,
417                originalName = name,
418                isDefine = true,
419                normalizedName = '';
420
421            //If no name, then it means it is a require call, generate an
422            //internal name.
423            if (!name) {
424                isDefine = false;
425                name = '_@r' + (requireCounter += 1);
426            }
427
428            nameParts = splitPrefix(name);
429            prefix = nameParts[0];
430            name = nameParts[1];
431
432            if (prefix) {
433                prefix = normalize(prefix, parentName, applyMap);
434                pluginModule = getOwn(defined, prefix);
435            }
436
437            //Account for relative paths if there is a base name.
438            if (name) {
439                if (prefix) {
440                    if (pluginModule && pluginModule.normalize) {
441                        //Plugin is loaded, use its normalize method.
442                        normalizedName = pluginModule.normalize(name, function (name) {
443                            return normalize(name, parentName, applyMap);
444                        });
445                    } else {
446                        // If nested plugin references, then do not try to
447                        // normalize, as it will not normalize correctly. This
448                        // places a restriction on resourceIds, and the longer
449                        // term solution is not to normalize until plugins are
450                        // loaded and all normalizations to allow for async
451                        // loading of a loader plugin. But for now, fixes the
452                        // common uses. Details in #1131
453                        normalizedName = name.indexOf('!') === -1 ?
454                                         normalize(name, parentName, applyMap) :
455                                         name;
456                    }
457                } else {
458                    //A regular module.
459                    normalizedName = normalize(name, parentName, applyMap);
460
461                    //Normalized name may be a plugin ID due to map config
462                    //application in normalize. The map config values must
463                    //already be normalized, so do not need to redo that part.
464                    nameParts = splitPrefix(normalizedName);
465                    prefix = nameParts[0];
466                    normalizedName = nameParts[1];
467                    isNormalized = true;
468
469                    url = context.nameToUrl(normalizedName);
470                }
471            }
472
473            //If the id is a plugin id that cannot be determined if it needs
474            //normalization, stamp it with a unique ID so two matching relative
475            //ids that may conflict can be separate.
476            suffix = prefix && !pluginModule && !isNormalized ?
477                     '_unnormalized' + (unnormalizedCounter += 1) :
478                     '';
479
480            return {
481                prefix: prefix,
482                name: normalizedName,
483                parentMap: parentModuleMap,
484                unnormalized: !!suffix,
485                url: url,
486                originalName: originalName,
487                isDefine: isDefine,
488                id: (prefix ?
489                        prefix + '!' + normalizedName :
490                        normalizedName) + suffix
491            };
492        }
493
494        function getModule(depMap) {
495            var id = depMap.id,
496                mod = getOwn(registry, id);
497
498            if (!mod) {
499                mod = registry[id] = new context.Module(depMap);
500            }
501
502            return mod;
503        }
504
505        function on(depMap, name, fn) {
506            var id = depMap.id,
507                mod = getOwn(registry, id);
508
509            if (hasProp(defined, id) &&
510                    (!mod || mod.defineEmitComplete)) {
511                if (name === 'defined') {
512                    fn(defined[id]);
513                }
514            } else {
515                mod = getModule(depMap);
516                if (mod.error && name === 'error') {
517                    fn(mod.error);
518                } else {
519                    mod.on(name, fn);
520                }
521            }
522        }
523
524        function onError(err, errback) {
525            var ids = err.requireModules,
526                notified = false;
527
528            if (errback) {
529                errback(err);
530            } else {
531                each(ids, function (id) {
532                    var mod = getOwn(registry, id);
533                    if (mod) {
534                        //Set error on module, so it skips timeout checks.
535                        mod.error = err;
536                        if (mod.events.error) {
537                            notified = true;
538                            mod.emit('error', err);
539                        }
540                    }
541                });
542
543                if (!notified) {
544                    req.onError(err);
545                }
546            }
547        }
548
549        /**
550         * Internal method to transfer globalQueue items to this context's
551         * defQueue.
552         */
553        function takeGlobalQueue() {
554            //Push all the globalDefQueue items into the context's defQueue
555            if (globalDefQueue.length) {
556                each(globalDefQueue, function(queueItem) {
557                    var id = queueItem[0];
558                    if (typeof id === 'string') {
559                        context.defQueueMap[id] = true;
560                    }
561                    defQueue.push(queueItem);
562                });
563                globalDefQueue = [];
564            }
565        }
566
567        handlers = {
568            'require': function (mod) {
569                if (mod.require) {
570                    return mod.require;
571                } else {
572                    return (mod.require = context.makeRequire(mod.map));
573                }
574            },
575            'exports': function (mod) {
576                mod.usingExports = true;
577                if (mod.map.isDefine) {
578                    if (mod.exports) {
579                        return (defined[mod.map.id] = mod.exports);
580                    } else {
581                        return (mod.exports = defined[mod.map.id] = {});
582                    }
583                }
584            },
585            'module': function (mod) {
586                if (mod.module) {
587                    return mod.module;
588                } else {
589                    return (mod.module = {
590                        id: mod.map.id,
591                        uri: mod.map.url,
592                        config: function () {
593                            return getOwn(config.config, mod.map.id) || {};
594                        },
595                        exports: mod.exports || (mod.exports = {})
596                    });
597                }
598            }
599        };
600
601        function cleanRegistry(id) {
602            //Clean up machinery used for waiting modules.
603            delete registry[id];
604            delete enabledRegistry[id];
605        }
606
607        function breakCycle(mod, traced, processed) {
608            var id = mod.map.id;
609
610            if (mod.error) {
611                mod.emit('error', mod.error);
612            } else {
613                traced[id] = true;
614                each(mod.depMaps, function (depMap, i) {
615                    var depId = depMap.id,
616                        dep = getOwn(registry, depId);
617
618                    //Only force things that have not completed
619                    //being defined, so still in the registry,
620                    //and only if it has not been matched up
621                    //in the module already.
622                    if (dep && !mod.depMatched[i] && !processed[depId]) {
623                        if (getOwn(traced, depId)) {
624                            mod.defineDep(i, defined[depId]);
625                            mod.check(); //pass false?
626                        } else {
627                            breakCycle(dep, traced, processed);
628                        }
629                    }
630                });
631                processed[id] = true;
632            }
633        }
634
635        function checkLoaded() {
636            var err, usingPathFallback,
637                waitInterval = config.waitSeconds * 1000,
638                //It is possible to disable the wait interval by using waitSeconds of 0.
639                expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
640                noLoads = [],
641                reqCalls = [],
642                stillLoading = false,
643                needCycleCheck = true;
644
645            //Do not bother if this call was a result of a cycle break.
646            if (inCheckLoaded) {
647                return;
648            }
649
650            inCheckLoaded = true;
651
652            //Figure out the state of all the modules.
653            eachProp(enabledRegistry, function (mod) {
654                var map = mod.map,
655                    modId = map.id;
656
657                //Skip things that are not enabled or in error state.
658                if (!mod.enabled) {
659                    return;
660                }
661
662                if (!map.isDefine) {
663                    reqCalls.push(mod);
664                }
665
666                if (!mod.error) {
667                    //If the module should be executed, and it has not
668                    //been inited and time is up, remember it.
669                    if (!mod.inited && expired) {
670                        if (hasPathFallback(modId)) {
671                            usingPathFallback = true;
672                            stillLoading = true;
673                        } else {
674                            noLoads.push(modId);
675                            removeScript(modId);
676                        }
677                    } else if (!mod.inited && mod.fetched && map.isDefine) {
678                        stillLoading = true;
679                        if (!map.prefix) {
680                            //No reason to keep looking for unfinished
681                            //loading. If the only stillLoading is a
682                            //plugin resource though, keep going,
683                            //because it may be that a plugin resource
684                            //is waiting on a non-plugin cycle.
685                            return (needCycleCheck = false);
686                        }
687                    }
688                }
689            });
690
691            if (expired && noLoads.length) {
692                //If wait time expired, throw error of unloaded modules.
693                err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
694                err.contextName = context.contextName;
695                return onError(err);
696            }
697
698            //Not expired, check for a cycle.
699            if (needCycleCheck) {
700                each(reqCalls, function (mod) {
701                    breakCycle(mod, {}, {});
702                });
703            }
704
705            //If still waiting on loads, and the waiting load is something
706            //other than a plugin resource, or there are still outstanding
707            //scripts, then just try back later.
708            if ((!expired || usingPathFallback) && stillLoading) {
709                //Something is still waiting to load. Wait for it, but only
710                //if a timeout is not already in effect.
711                if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
712                    checkLoadedTimeoutId = setTimeout(function () {
713                        checkLoadedTimeoutId = 0;
714                        checkLoaded();
715                    }, 50);
716                }
717            }
718
719            inCheckLoaded = false;
720        }
721
722        Module = function (map) {
723            this.events = getOwn(undefEvents, map.id) || {};
724            this.map = map;
725            this.shim = getOwn(config.shim, map.id);
726            this.depExports = [];
727            this.depMaps = [];
728            this.depMatched = [];
729            this.pluginMaps = {};
730            this.depCount = 0;
731
732            /* this.exports this.factory
733               this.depMaps = [],
734               this.enabled, this.fetched
735            */
736        };
737
738        Module.prototype = {
739            init: function (depMaps, factory, errback, options) {
740                options = options || {};
741
742                //Do not do more inits if already done. Can happen if there
743                //are multiple define calls for the same module. That is not
744                //a normal, common case, but it is also not unexpected.
745                if (this.inited) {
746                    return;
747                }
748
749                this.factory = factory;
750
751                if (errback) {
752                    //Register for errors on this module.
753                    this.on('error', errback);
754                } else if (this.events.error) {
755                    //If no errback already, but there are error listeners
756                    //on this module, set up an errback to pass to the deps.
757                    errback = bind(this, function (err) {
758                        this.emit('error', err);
759                    });
760                }
761
762                //Do a copy of the dependency array, so that
763                //source inputs are not modified. For example
764                //"shim" deps are passed in here directly, and
765                //doing a direct modification of the depMaps array
766                //would affect that config.
767                this.depMaps = depMaps && depMaps.slice(0);
768
769                this.errback = errback;
770
771                //Indicate this module has be initialized
772                this.inited = true;
773
774                this.ignore = options.ignore;
775
776                //Could have option to init this module in enabled mode,
777                //or could have been previously marked as enabled. However,
778                //the dependencies are not known until init is called. So
779                //if enabled previously, now trigger dependencies as enabled.
780                if (options.enabled || this.enabled) {
781                    //Enable this module and dependencies.
782                    //Will call this.check()
783                    this.enable();
784                } else {
785                    this.check();
786                }
787            },
788
789            defineDep: function (i, depExports) {
790                //Because of cycles, defined callback for a given
791                //export can be called more than once.
792                if (!this.depMatched[i]) {
793                    this.depMatched[i] = true;
794                    this.depCount -= 1;
795                    this.depExports[i] = depExports;
796                }
797            },
798
799            fetch: function () {
800                if (this.fetched) {
801                    return;
802                }
803                this.fetched = true;
804
805                context.startTime = (new Date()).getTime();
806
807                var map = this.map;
808
809                //If the manager is for a plugin managed resource,
810                //ask the plugin to load it now.
811                if (this.shim) {
812                    context.makeRequire(this.map, {
813                        enableBuildCallback: true
814                    })(this.shim.deps || [], bind(this, function () {
815                        return map.prefix ? this.callPlugin() : this.load();
816                    }));
817                } else {
818                    //Regular dependency.
819                    return map.prefix ? this.callPlugin() : this.load();
820                }
821            },
822
823            load: function () {
824                var url = this.map.url;
825
826                //Regular dependency.
827                if (!urlFetched[url]) {
828                    urlFetched[url] = true;
829                    context.load(this.map.id, url);
830                }
831            },
832
833            /**
834             * Checks if the module is ready to define itself, and if so,
835             * define it.
836             */
837            check: function () {
838                if (!this.enabled || this.enabling) {
839                    return;
840                }
841
842                var err, cjsModule,
843                    id = this.map.id,
844                    depExports = this.depExports,
845                    exports = this.exports,
846                    factory = this.factory;
847
848                if (!this.inited) {
849                    // Only fetch if not already in the defQueue.
850                    if (!hasProp(context.defQueueMap, id)) {
851                        this.fetch();
852                    }
853                } else if (this.error) {
854                    this.emit('error', this.error);
855                } else if (!this.defining) {
856                    //The factory could trigger another require call
857                    //that would result in checking this module to
858                    //define itself again. If already in the process
859                    //of doing that, skip this work.
860                    this.defining = true;
861
862                    if (this.depCount < 1 && !this.defined) {
863                        if (isFunction(factory)) {
864                            
vendor: 18,455 bytes, lines 864-1288
864try {
865                                exports = context.execCb(id, factory, depExports, exports);
866                            } catch (e) {
867                                err = e;
868                            }
869
870                            // Favor return value over exports. If node/cjs in play,
871                            // then will not have a return value anyway. Favor
872                            // module.exports assignment over exports object.
873                            if (this.map.isDefine && exports === undefined) {
874                                cjsModule = this.module;
875                                if (cjsModule) {
876                                    exports = cjsModule.exports;
877                                } else if (this.usingExports) {
878                                    //exports already set the defined value.
879                                    exports = this.exports;
880                                }
881                            }
882
883                            if (err) {
884                                // If there is an error listener, favor passing
885                                // to that instead of throwing an error. However,
886                                // only do it for define()'d  modules. require
887                                // errbacks should not be called for failures in
888                                // their callbacks (#699). However if a global
889                                // onError is set, use that.
890                                if ((this.events.error && this.map.isDefine) ||
891                                    req.onError !== defaultOnError) {
892                                    err.requireMap = this.map;
893                                    err.requireModules = this.map.isDefine ? [this.map.id] : null;
894                                    err.requireType = this.map.isDefine ? 'define' : 'require';
895                                    return onError((this.error = err));
896                                } else if (typeof console !== 'undefined' &&
897                                           console.error) {
898                                    // Log the error for debugging. If promises could be
899                                    // used, this would be different, but making do.
900                                    console.error(err);
901                                } else {
902                                    // Do not want to completely lose the error. While this
903                                    // will mess up processing and lead to similar results
904                                    // as bug 1440, it at least surfaces the error.
905                                    req.onError(err);
906                                }
907                            }
908                        } else {
909                            //Just a literal value
910                            exports = factory;
911                        }
912
913                        this.exports = exports;
914
915                        if (this.map.isDefine && !this.ignore) {
916                            defined[id] = exports;
917
918                            if (req.onResourceLoad) {
919                                var resLoadMaps = [];
920                                each(this.depMaps, function (depMap) {
921                                    resLoadMaps.push(depMap.normalizedMap || depMap);
922                                });
923                                req.onResourceLoad(context, this.map, resLoadMaps);
924                            }
925                        }
926
927                        //Clean up
928                        cleanRegistry(id);
929
930                        this.defined = true;
931                    }
932
933                    //Finished the define stage. Allow calling check again
934                    //to allow define notifications below in the case of a
935                    //cycle.
936                    this.defining = false;
937
938                    if (this.defined && !this.defineEmitted) {
939                        this.defineEmitted = true;
940                        this.emit('defined', this.exports);
941                        this.defineEmitComplete = true;
942                    }
943
944                }
945            },
946
947            callPlugin: function () {
948                var map = this.map,
949                    id = map.id,
950                    //Map already normalized the prefix.
951                    pluginMap = makeModuleMap(map.prefix);
952
953                //Mark this as a dependency for this plugin, so it
954                //can be traced for cycles.
955                this.depMaps.push(pluginMap);
956
957                on(pluginMap, 'defined', bind(this, function (plugin) {
958                    var load, normalizedMap, normalizedMod,
959                        bundleId = getOwn(bundlesMap, this.map.id),
960                        name = this.map.name,
961                        parentName = this.map.parentMap ? this.map.parentMap.name : null,
962                        localRequire = context.makeRequire(map.parentMap, {
963                            enableBuildCallback: true
964                        });
965
966                    //If current map is not normalized, wait for that
967                    //normalized name to load instead of continuing.
968                    if (this.map.unnormalized) {
969                        //Normalize the ID if the plugin allows it.
970                        if (plugin.normalize) {
971                            name = plugin.normalize(name, function (name) {
972                                return normalize(name, parentName, true);
973                            }) || '';
974                        }
975
976                        //prefix and name should already be normalized, no need
977                        //for applying map config again either.
978                        normalizedMap = makeModuleMap(map.prefix + '!' + name,
979                                                      this.map.parentMap);
980                        on(normalizedMap,
981                            'defined', bind(this, function (value) {
982                                this.map.normalizedMap = normalizedMap;
983                                this.init([], function () { return value; }, null, {
984                                    enabled: true,
985                                    ignore: true
986                                });
987                            }));
988
989                        normalizedMod = getOwn(registry, normalizedMap.id);
990                        if (normalizedMod) {
991                            //Mark this as a dependency for this plugin, so it
992                            //can be traced for cycles.
993                            this.depMaps.push(normalizedMap);
994
995                            if (this.events.error) {
996                                normalizedMod.on('error', bind(this, function (err) {
997                                    this.emit('error', err);
998                                }));
999                            }
1000                            normalizedMod.enable();
1001                        }
1002
1003                        return;
1004                    }
1005
1006                    //If a paths config, then just load that file instead to
1007                    //resolve the plugin, as it is built into that paths layer.
1008                    if (bundleId) {
1009                        this.map.url = context.nameToUrl(bundleId);
1010                        this.load();
1011                        return;
1012                    }
1013
1014                    load = bind(this, function (value) {
1015                        this.init([], function () { return value; }, null, {
1016                            enabled: true
1017                        });
1018                    });
1019
1020                    load.error = bind(this, function (err) {
1021                        this.inited = true;
1022                        this.error = err;
1023                        err.requireModules = [id];
1024
1025                        //Remove temp unnormalized modules for this module,
1026                        //since they will never be resolved otherwise now.
1027                        eachProp(registry, function (mod) {
1028                            if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
1029                                cleanRegistry(mod.map.id);
1030                            }
1031                        });
1032
1033                        onError(err);
1034                    });
1035
1036                    //Allow plugins to load other code without having to know the
1037                    //context or how to 'complete' the load.
1038                    load.fromText = bind(this, function (text, textAlt) {
1039                        /*jslint evil: true */
1040                        var moduleName = map.name,
1041                            moduleMap = makeModuleMap(moduleName),
1042                            hasInteractive = useInteractive;
1043
1044                        //As of 2.1.0, support just passing the text, to reinforce
1045                        //fromText only being called once per resource. Still
1046                        //support old style of passing moduleName but discard
1047                        //that moduleName in favor of the internal ref.
1048                        if (textAlt) {
1049                            text = textAlt;
1050                        }
1051
1052                        //Turn off interactive script matching for IE for any define
1053                        //calls in the text, then turn it back on at the end.
1054                        if (hasInteractive) {
1055                            useInteractive = false;
1056                        }
1057
1058                        //Prime the system by creating a module instance for
1059                        //it.
1060                        getModule(moduleMap);
1061
1062                        //Transfer any config to this other module.
1063                        if (hasProp(config.config, id)) {
1064                            config.config[moduleName] = config.config[id];
1065                        }
1066
1067                        try {
1068                            req.exec(text);
1069                        } catch (e) {
1070                            return onError(makeError('fromtexteval',
1071                                             'fromText eval for ' + id +
1072                                            ' failed: ' + e,
1073                                             e,
1074                                             [id]));
1075                        }
1076
1077                        if (hasInteractive) {
1078                            useInteractive = true;
1079                        }
1080
1081                        //Mark this as a dependency for the plugin
1082                        //resource
1083                        this.depMaps.push(moduleMap);
1084
1085                        //Support anonymous modules.
1086                        context.completeLoad(moduleName);
1087
1088                        //Bind the value of that module to the value for this
1089                        //resource ID.
1090                        localRequire([moduleName], load);
1091                    });
1092
1093                    //Use parentName here since the plugin's name is not reliable,
1094                    //could be some weird string with no path that actually wants to
1095                    //reference the parentName's path.
1096                    plugin.load(map.name, localRequire, load, config);
1097                }));
1098
1099                context.enable(pluginMap, this);
1100                this.pluginMaps[pluginMap.id] = pluginMap;
1101            },
1102
1103            enable: function () {
1104                enabledRegistry[this.map.id] = this;
1105                this.enabled = true;
1106
1107                //Set flag mentioning that the module is enabling,
1108                //so that immediate calls to the defined callbacks
1109                //for dependencies do not trigger inadvertent load
1110                //with the depCount still being zero.
1111                this.enabling = true;
1112
1113                //Enable each dependency
1114                each(this.depMaps, bind(this, function (depMap, i) {
1115                    var id, mod, handler;
1116
1117                    if (typeof depMap === 'string') {
1118                        //Dependency needs to be converted to a depMap
1119                        //and wired up to this module.
1120                        depMap = makeModuleMap(depMap,
1121                                               (this.map.isDefine ? this.map : this.map.parentMap),
1122                                               false,
1123                                               !this.skipMap);
1124                        this.depMaps[i] = depMap;
1125
1126                        handler = getOwn(handlers, depMap.id);
1127
1128                        if (handler) {
1129                            this.depExports[i] = handler(this);
1130                            return;
1131                        }
1132
1133                        this.depCount += 1;
1134
1135                        on(depMap, 'defined', bind(this, function (depExports) {
1136                            if (this.undefed) {
1137                                return;
1138                            }
1139                            this.defineDep(i, depExports);
1140                            this.check();
1141                        }));
1142
1143                        if (this.errback) {
1144                            on(depMap, 'error', bind(this, this.errback));
1145                        } else if (this.events.error) {
1146                            // No direct errback on this module, but something
1147                            // else is listening for errors, so be sure to
1148                            // propagate the error correctly.
1149                            on(depMap, 'error', bind(this, function(err) {
1150                                this.emit('error', err);
1151                            }));
1152                        }
1153                    }
1154
1155                    id = depMap.id;
1156                    mod = registry[id];
1157
1158                    //Skip special modules like 'require', 'exports', 'module'
1159                    //Also, don't call enable if it is already enabled,
1160                    //important in circular dependency cases.
1161                    if (!hasProp(handlers, id) && mod && !mod.enabled) {
1162                        context.enable(depMap, this);
1163                    }
1164                }));
1165
1166                //Enable each plugin that is used in
1167                //a dependency
1168                eachProp(this.pluginMaps, bind(this, function (pluginMap) {
1169                    var mod = getOwn(registry, pluginMap.id);
1170                    if (mod && !mod.enabled) {
1171                        context.enable(pluginMap, this);
1172                    }
1173                }));
1174
1175                this.enabling = false;
1176
1177                this.check();
1178            },
1179
1180            on: function (name, cb) {
1181                var cbs = this.events[name];
1182                if (!cbs) {
1183                    cbs = this.events[name] = [];
1184                }
1185                cbs.push(cb);
1186            },
1187
1188            emit: function (name, evt) {
1189                each(this.events[name], function (cb) {
1190                    cb(evt);
1191                });
1192                if (name === 'error') {
1193                    //Now that the error handler was triggered, remove
1194                    //the listeners, since this broken Module instance
1195                    //can stay around for a while in the registry.
1196                    delete this.events[name];
1197                }
1198            }
1199        };
1200
1201        function callGetModule(args) {
1202            //Skip modules already defined.
1203            if (!hasProp(defined, args[0])) {
1204                getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
1205            }
1206        }
1207
1208        function removeListener(node, func, name, ieName) {
1209            //Favor detachEvent because of IE9
1210            //issue, see attachEvent/addEventListener comment elsewhere
1211            //in this file.
1212            if (node.detachEvent && !isOpera) {
1213                //Probably IE. If not it will throw an error, which will be
1214                //useful to know.
1215                if (ieName) {
1216                    node.detachEvent(ieName, func);
1217                }
1218            } else {
1219                node.removeEventListener(name, func, false);
1220            }
1221        }
1222
1223        /**
1224         * Given an event from a script node, get the requirejs info from it,
1225         * and then removes the event listeners on the node.
1226         * @param {Event} evt
1227         * @returns {Object}
1228         */
1229        function getScriptData(evt) {
1230            //Using currentTarget instead of target for Firefox 2.0's sake. Not
1231            //all old browsers will be supported, but this one was easy enough
1232            //to support and still makes sense.
1233            var node = evt.currentTarget || evt.srcElement;
1234
1235            //Remove the listeners once here.
1236            removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
1237            removeListener(node, context.onScriptError, 'error');
1238
1239            return {
1240                node: node,
1241                id: node && node.getAttribute('data-requiremodule')
1242            };
1243        }
1244
1245        function intakeDefines() {
1246            var args;
1247
1248            //Any defined modules in the global queue, intake them now.
1249            takeGlobalQueue();
1250
1251            //Make sure any remaining defQueue items get properly processed.
1252            while (defQueue.length) {
1253                args = defQueue.shift();
1254                if (args[0] === null) {
1255                    return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
1256                        args[args.length - 1]));
1257                } else {
1258                    //args are id, deps, factory. Should be normalized by the
1259                    //define() function.
1260                    callGetModule(args);
1261                }
1262            }
1263            context.defQueueMap = {};
1264        }
1265
1266        context = {
1267            config: config,
1268            contextName: contextName,
1269            registry: registry,
1270            defined: defined,
1271            urlFetched: urlFetched,
1272            defQueue: defQueue,
1273            defQueueMap: {},
1274            Module: Module,
1275            makeModuleMap: makeModuleMap,
1276            nextTick: req.nextTick,
1277            onError: onError,
1278
1279            /**
1280             * Set a configuration for the context.
1281             * @param {Object} cfg config object to integrate.
1282             */
1283            configure: function (cfg) {
1284                //Make sure the baseUrl ends in a slash.
1285                if (cfg.baseUrl) {
1286                    if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
1287                        cfg.baseUrl += '/';
1288                    }
vendor: 16,459 bytes, lines 1288-1667
1288
1289                }
1290
1291                //Save off the paths since they require special processing,
1292                //they are additive.
1293                var shim = config.shim,
1294                    objs = {
1295                        paths: true,
1296                        bundles: true,
1297                        config: true,
1298                        map: true
1299                    };
1300
1301                eachProp(cfg, function (value, prop) {
1302                    if (objs[prop]) {
1303                        if (!config[prop]) {
1304                            config[prop] = {};
1305                        }
1306                        mixin(config[prop], value, true, true);
1307                    } else {
1308                        config[prop] = value;
1309                    }
1310                });
1311
1312                //Reverse map the bundles
1313                if (cfg.bundles) {
1314                    eachProp(cfg.bundles, function (value, prop) {
1315                        each(value, function (v) {
1316                            if (v !== prop) {
1317                                bundlesMap[v] = prop;
1318                            }
1319                        });
1320                    });
1321                }
1322
1323                //Merge shim
1324                if (cfg.shim) {
1325                    eachProp(cfg.shim, function (value, id) {
1326                        //Normalize the structure
1327                        if (isArray(value)) {
1328                            value = {
1329                                deps: value
1330                            };
1331                        }
1332                        if ((value.exports || value.init) && !value.exportsFn) {
1333                            value.exportsFn = context.makeShimExports(value);
1334                        }
1335                        shim[id] = value;
1336                    });
1337                    config.shim = shim;
1338                }
1339
1340                //Adjust packages if necessary.
1341                if (cfg.packages) {
1342                    each(cfg.packages, function (pkgObj) {
1343                        var location, name;
1344
1345                        pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
1346
1347                        name = pkgObj.name;
1348                        location = pkgObj.location;
1349                        if (location) {
1350                            config.paths[name] = pkgObj.location;
1351                        }
1352
1353                        //Save pointer to main module ID for pkg name.
1354                        //Remove leading dot in main, so main paths are normalized,
1355                        //and remove any trailing .js, since different package
1356                        //envs have different conventions: some use a module name,
1357                        //some use a file name.
1358                        config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
1359                                     .replace(currDirRegExp, '')
1360                                     .replace(jsSuffixRegExp, '');
1361                    });
1362                }
1363
1364                //If there are any "waiting to execute" modules in the registry,
1365                //update the maps for them, since their info, like URLs to load,
1366                //may have changed.
1367                eachProp(registry, function (mod, id) {
1368                    //If module already has init called, since it is too
1369                    //late to modify them, and ignore unnormalized ones
1370                    //since they are transient.
1371                    if (!mod.inited && !mod.map.unnormalized) {
1372                        mod.map = makeModuleMap(id, null, true);
1373                    }
1374                });
1375
1376                //If a deps array or a config callback is specified, then call
1377                //require with those args. This is useful when require is defined as a
1378                //config object before require.js is loaded.
1379                if (cfg.deps || cfg.callback) {
1380                    context.require(cfg.deps || [], cfg.callback);
1381                }
1382            },
1383
1384            makeShimExports: function (value) {
1385                function fn() {
1386                    var ret;
1387                    if (value.init) {
1388                        ret = value.init.apply(global, arguments);
1389                    }
1390                    return ret || (value.exports && getGlobal(value.exports));
1391                }
1392                return fn;
1393            },
1394
1395            makeRequire: function (relMap, options) {
1396                options = options || {};
1397
1398                function localRequire(deps, callback, errback) {
1399                    var id, map, requireMod;
1400
1401                    if (options.enableBuildCallback && callback && isFunction(callback)) {
1402                        callback.__requireJsBuild = true;
1403                    }
1404
1405                    if (typeof deps === 'string') {
1406                        if (isFunction(callback)) {
1407                            //Invalid call
1408                            return onError(makeError('requireargs', 'Invalid require call'), errback);
1409                        }
1410
1411                        //If require|exports|module are requested, get the
1412                        //value for them from the special handlers. Caveat:
1413                        //this only works while module is being defined.
1414                        if (relMap && hasProp(handlers, deps)) {
1415                            return handlers[deps](registry[relMap.id]);
1416                        }
1417
1418                        //Synchronous access to one module. If require.get is
1419                        //available (as in the Node adapter), prefer that.
1420                        if (req.get) {
1421                            return req.get(context, deps, relMap, localRequire);
1422                        }
1423
1424                        //Normalize module name, if it contains . or ..
1425                        map = makeModuleMap(deps, relMap, false, true);
1426                        id = map.id;
1427
1428                        if (!hasProp(defined, id)) {
1429                            return onError(makeError('notloaded', 'Module name "' +
1430                                        id +
1431                                        '" has not been loaded yet for context: ' +
1432                                        contextName +
1433                                        (relMap ? '' : '. Use require([])')));
1434                        }
1435                        return defined[id];
1436                    }
1437
1438                    //Grab defines waiting in the global queue.
1439                    intakeDefines();
1440
1441                    //Mark all the dependencies as needing to be loaded.
1442                    context.nextTick(function () {
1443                        //Some defines could have been added since the
1444                        //require call, collect them.
1445                        intakeDefines();
1446
1447                        requireMod = getModule(makeModuleMap(null, relMap));
1448
1449                        //Store if map config should be applied to this require
1450                        //call for dependencies.
1451                        requireMod.skipMap = options.skipMap;
1452
1453                        requireMod.init(deps, callback, errback, {
1454                            enabled: true
1455                        });
1456
1457                        checkLoaded();
1458                    });
1459
1460                    return localRequire;
1461                }
1462
1463                mixin(localRequire, {
1464                    isBrowser: isBrowser,
1465
1466                    /**
1467                     * Converts a module name + .extension into an URL path.
1468                     * *Requires* the use of a module name. It does not support using
1469                     * plain URLs like nameToUrl.
1470                     */
1471                    toUrl: function (moduleNamePlusExt) {
1472                        var ext,
1473                            index = moduleNamePlusExt.lastIndexOf('.'),
1474                            segment = moduleNamePlusExt.split('/')[0],
1475                            isRelative = segment === '.' || segment === '..';
1476
1477                        //Have a file extension alias, and it is not the
1478                        //dots from a relative path.
1479                        if (index !== -1 && (!isRelative || index > 1)) {
1480                            ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
1481                            moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
1482                        }
1483
1484                        return context.nameToUrl(normalize(moduleNamePlusExt,
1485                                                relMap && relMap.id, true), ext,  true);
1486                    },
1487
1488                    defined: function (id) {
1489                        return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
1490                    },
1491
1492                    specified: function (id) {
1493                        id = makeModuleMap(id, relMap, false, true).id;
1494                        return hasProp(defined, id) || hasProp(registry, id);
1495                    }
1496                });
1497
1498                //Only allow undef on top level require calls
1499                if (!relMap) {
1500                    localRequire.undef = function (id) {
1501                        //Bind any waiting define() calls to this context,
1502                        //fix for #408
1503                        takeGlobalQueue();
1504
1505                        var map = makeModuleMap(id, relMap, true),
1506                            mod = getOwn(registry, id);
1507
1508                        mod.undefed = true;
1509                        removeScript(id);
1510
1511                        delete defined[id];
1512                        delete urlFetched[map.url];
1513                        delete undefEvents[id];
1514
1515                        //Clean queued defines too. Go backwards
1516                        //in array so that the splices do not
1517                        //mess up the iteration.
1518                        eachReverse(defQueue, function(args, i) {
1519                            if (args[0] === id) {
1520                                defQueue.splice(i, 1);
1521                            }
1522                        });
1523                        delete context.defQueueMap[id];
1524
1525                        if (mod) {
1526                            //Hold on to listeners in case the
1527                            //module will be attempted to be reloaded
1528                            //using a different config.
1529                            if (mod.events.defined) {
1530                                undefEvents[id] = mod.events;
1531                            }
1532
1533                            cleanRegistry(id);
1534                        }
1535                    };
1536                }
1537
1538                return localRequire;
1539            },
1540
1541            /**
1542             * Called to enable a module if it is still in the registry
1543             * awaiting enablement. A second arg, parent, the parent module,
1544             * is passed in for context, when this method is overridden by
1545             * the optimizer. Not shown here to keep code compact.
1546             */
1547            enable: function (depMap) {
1548                var mod = getOwn(registry, depMap.id);
1549                if (mod) {
1550                    getModule(depMap).enable();
1551                }
1552            },
1553
1554            /**
1555             * Internal method used by environment adapters to complete a load event.
1556             * A load event could be a script load or just a load pass from a synchronous
1557             * load call.
1558             * @param {String} moduleName the name of the module to potentially complete.
1559             */
1560            completeLoad: function (moduleName) {
1561                var found, args, mod,
1562                    shim = getOwn(config.shim, moduleName) || {},
1563                    shExports = shim.exports;
1564
1565                takeGlobalQueue();
1566
1567                while (defQueue.length) {
1568                    args = defQueue.shift();
1569                    if (args[0] === null) {
1570                        args[0] = moduleName;
1571                        //If already found an anonymous module and bound it
1572                        //to this name, then this is some other anon module
1573                        //waiting for its completeLoad to fire.
1574                        if (found) {
1575                            break;
1576                        }
1577                        found = true;
1578                    } else if (args[0] === moduleName) {
1579                        //Found matching define call for this script!
1580                        found = true;
1581                    }
1582
1583                    callGetModule(args);
1584                }
1585                context.defQueueMap = {};
1586
1587                //Do this after the cycle of callGetModule in case the result
1588                //of those calls/init calls changes the registry.
1589                mod = getOwn(registry, moduleName);
1590
1591                if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
1592                    if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
1593                        if (hasPathFallback(moduleName)) {
1594                            return;
1595                        } else {
1596                            return onError(makeError('nodefine',
1597                                             'No define call for ' + moduleName,
1598                                             null,
1599                                             [moduleName]));
1600                        }
1601                    } else {
1602                        //A script that does not call define(), so just simulate
1603                        //the call for it.
1604                        callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
1605                    }
1606                }
1607
1608                checkLoaded();
1609            },
1610
1611            /**
1612             * Converts a module name to a file path. Supports cases where
1613             * moduleName may actually be just an URL.
1614             * Note that it **does not** call normalize on the moduleName,
1615             * it is assumed to have already been normalized. This is an
1616             * internal API, not a public one. Use toUrl for the public API.
1617             */
1618            nameToUrl: function (moduleName, ext, skipExt) {
1619                var paths, syms, i, parentModule, url,
1620                    parentPath, bundleId,
1621                    pkgMain = getOwn(config.pkgs, moduleName);
1622
1623                if (pkgMain) {
1624                    moduleName = pkgMain;
1625                }
1626
1627                bundleId = getOwn(bundlesMap, moduleName);
1628
1629                if (bundleId) {
1630                    return context.nameToUrl(bundleId, ext, skipExt);
1631                }
1632
1633                //If a colon is in the URL, it indicates a protocol is used and it is just
1634                //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
1635                //or ends with .js, then assume the user meant to use an url and not a module id.
1636                //The slash is important for protocol-less URLs as well as full paths.
1637                if (req.jsExtRegExp.test(moduleName)) {
1638                    //Just a plain path, not module name lookup, so just return it.
1639                    //Add extension if it is included. This is a bit wonky, only non-.js things pass
1640                    //an extension, this method probably needs to be reworked.
1641                    url = moduleName + (ext || '');
1642                } else {
1643                    //A module that needs to be converted to a path.
1644                    paths = config.paths;
1645
1646                    syms = moduleName.split('/');
1647                    //For each module name segment, see if there is a path
1648                    //registered for it. Start with most specific name
1649                    //and work up from it.
1650                    for (i = syms.length; i > 0; i -= 1) {
1651                        parentModule = syms.slice(0, i).join('/');
1652
1653                        parentPath = getOwn(paths, parentModule);
1654                        if (parentPath) {
1655                            //If an array, it means there are a few choices,
1656                            //Choose the one that is desired
1657                            if (isArray(parentPath)) {
1658                                parentPath = parentPath[0];
1659                            }
1660                            syms.splice(0, i, parentPath);
1661                            break;
1662                        }
1663                    }
1664
1665                    //Join the path parts together, then figure out if baseUrl is needed.
1666                    url = syms.join('/');
1667                    url += (ext || (/^data\:|
1667\?/.test(url) || skipExt ? '' : '.js'));
1668                    url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
1669                }
1670
1671                return config.urlArgs ? url +
1672                                        ((url.indexOf('?') === -1 ? '?' : '&') +
1673                                         config.urlArgs) : url;
1674            },
1675
1676            //Delegates to req.load. Broken out as a separate function to
1677            //allow overriding in the optimizer.
1678            load: function (id, url) {
1679                req.load(context, id, url);
1680            },
1681
1682            /**
1683             * Executes a module callback function. Broken out as a separate function
1684             * solely to allow the build system to sequence the files in the built
1685             * layer in the right sequence.
1686             *
1687             * @private
1688             */
vendor: 17,510 bytes, lines 1689-2129
1689            execCb: function (name, callback, args, exports) {
1690                return callback.apply(exports, args);
1691            },
1692
1693            /**
1694             * callback for script loads, used to check status of loading.
1695             *
1696             * @param {Event} evt the event from the browser for the script
1697             * that was loaded.
1698             */
1699            onScriptLoad: function (evt) {
1700                //Using currentTarget instead of target for Firefox 2.0's sake. Not
1701                //all old browsers will be supported, but this one was easy enough
1702                //to support and still makes sense.
1703                if (evt.type === 'load' ||
1704                        (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
1705                    //Reset interactive script so a script node is not held onto for
1706                    //to long.
1707                    interactiveScript = null;
1708
1709                    //Pull out the name of the module and the context.
1710                    var data = getScriptData(evt);
1711                    context.completeLoad(data.id);
1712                }
1713            },
1714
1715            /**
1716             * Callback for script errors.
1717             */
1718            onScriptError: function (evt) {
1719                var data = getScriptData(evt);
1720                if (!hasPathFallback(data.id)) {
1721                    var parents = [];
1722                    eachProp(registry, function(value, key) {
1723                        if (key.indexOf('_@r') !== 0) {
1724                            each(value.depMaps, function(depMap) {
1725                                if (depMap.id === data.id) {
1726                                    parents.push(key);
1727                                }
1728                                return true;
1729                            });
1730                        }
1731                    });
1732                    return onError(makeError('scripterror', 'Script error for "' + data.id +
1733                                             (parents.length ?
1734                                             '", needed by: ' + parents.join(', ') :
1735                                             '"'), evt, [data.id]));
1736                }
1737            }
1738        };
1739
1740        context.require = context.makeRequire();
1741        return context;
1742    }
1743
1744    /**
1745     * Main entry point.
1746     *
1747     * If the only argument to require is a string, then the module that
1748     * is represented by that string is fetched for the appropriate context.
1749     *
1750     * If the first argument is an array, then it will be treated as an array
1751     * of dependency string names to fetch. An optional function callback can
1752     * be specified to execute when all of those dependencies are available.
1753     *
1754     * Make a local req variable to help Caja compliance (it assumes things
1755     * on a require that are not standardized), and to give a short
1756     * name for minification/local scope use.
1757     */
1758    req = requirejs = function (deps, callback, errback, optional) {
1759
1760        //Find the right context, use default
1761        var context, config,
1762            contextName = defContextName;
1763
1764        // Determine if have config object in the call.
1765        if (!isArray(deps) && typeof deps !== 'string') {
1766            // deps is a config object
1767            config = deps;
1768            if (isArray(callback)) {
1769                // Adjust args if there are dependencies
1770                deps = callback;
1771                callback = errback;
1772                errback = optional;
1773            } else {
1774                deps = [];
1775            }
1776        }
1777
1778        if (config && config.context) {
1779            contextName = config.context;
1780        }
1781
1782        context = getOwn(contexts, contextName);
1783        if (!context) {
1784            context = contexts[contextName] = req.s.newContext(contextName);
1785        }
1786
1787        if (config) {
1788            context.configure(config);
1789        }
1790
1791        return context.require(deps, callback, errback);
1792    };
1793
1794    /**
1795     * Support require.config() to make it easier to cooperate with other
1796     * AMD loaders on globally agreed names.
1797     */
1798    req.config = function (config) {
1799        return req(config);
1800    };
1801
1802    /**
1803     * Execute something after the current tick
1804     * of the event loop. Override for other envs
1805     * that have a better solution than setTimeout.
1806     * @param  {Function} fn function to execute later.
1807     */
1808    req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
1809        setTimeout(fn, 4);
1810    } : function (fn) { fn(); };
1811
1812    /**
1813     * Export require as a global, but only if it does not already exist.
1814     */
1815    if (!require) {
1816        require = req;
1817    }
1818
1819    req.version = version;
1820
1821    //Used to filter out dependencies that are already paths.
1822    req.jsExtRegExp = /^\/|:|\?|\.js$/;
1823    req.isBrowser = isBrowser;
1824    s = req.s = {
1825        contexts: contexts,
1826        newContext: newContext
1827    };
1828
1829    //Create default context.
1830    req({});
1831
1832    //Exports some context-sensitive methods on global require.
1833    each([
1834        'toUrl',
1835        'undef',
1836        'defined',
1837        'specified'
1838    ], function (prop) {
1839        //Reference from contexts instead of early binding to default context,
1840        //so that during builds, the latest instance of the default context
1841        //with its config gets used.
1842        req[prop] = function () {
1843            var ctx = contexts[defContextName];
1844            return ctx.require[prop].apply(ctx, arguments);
1845        };
1846    });
1847
1848    if (isBrowser) {
1849        head = s.head = document.getElementsByTagName('head')[0];
1850        //If BASE tag is in play, using appendChild is a problem for IE6.
1851        //When that browser dies, this can be removed. Details in this jQuery bug:
1852        //http://dev.jquery.com/ticket/2709
1853        baseElement = document.getElementsByTagName('base')[0];
1854        if (baseElement) {
1855            head = s.head = baseElement.parentNode;
1856        }
1857    }
1858
1859    /**
1860     * Any errors that require explicitly generates will be passed to this
1861     * function. Intercept/override it if you want custom error handling.
1862     * @param {Error} err the error object.
1863     */
1864    req.onError = defaultOnError;
1865
1866    /**
1867     * Creates the node for the load command. Only used in browser envs.
1868     */
1869    req.createNode = function (config, moduleName, url) {
1870        var node = config.xhtml ?
1871                document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
1872                document.createElement('script');
1873        node.type = config.scriptType || 'text/javascript';
1874        node.charset = 'utf-8';
1875        node.async = true;
1876        return node;
1877    };
1878
1879    /**
1880     * Does the request to load a module for the browser case.
1881     * Make this a separate function to allow other environments
1882     * to override it.
1883     *
1884     * @param {Object} context the require context to find state.
1885     * @param {String} moduleName the name of the module.
1886     * @param {Object} url the URL to the module.
1887     */
1888    req.load = function (context, moduleName, url) {
1889        var config = (context && context.config) || {},
1890            node;
1891        if (isBrowser) {
1892            //In the browser so use a script tag
1893            node = req.createNode(config, moduleName, url);
1894            if (config.onNodeCreated) {
1895                config.onNodeCreated(node, config, moduleName, url);
1896            }
1897
1898            node.setAttribute('data-requirecontext', context.contextName);
1899            node.setAttribute('data-requiremodule', moduleName);
1900
1901            //Set up load listener. Test attachEvent first because IE9 has
1902            //a subtle issue in its addEventListener and script onload firings
1903            //that do not match the behavior of all other browsers with
1904            //addEventListener support, which fire the onload event for a
1905            //script right after the script execution. See:
1906            //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
1907            //UNFORTUNATELY Opera implements attachEvent but does not follow the script
1908            //script execution mode.
1909            if (node.attachEvent &&
1910                    //Check if node.attachEvent is artificially added by custom script or
1911                    //natively supported by browser
1912                    //read https://github.com/jrburke/requirejs/issues/187
1913                    //if we can NOT find [native code] then it must NOT natively supported.
1914                    //in IE8, node.attachEvent does not have toString()
1915                    //Note the test for "[native code" with no closing brace, see:
1916                    //https://github.com/jrburke/requirejs/issues/273
1917                    !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
1918                    !isOpera) {
1919                //Probably IE. IE (at least 6-8) do not fire
1920                //script onload right after executing the script, so
1921                //we cannot tie the anonymous define call to a name.
1922                //However, IE reports the script as being in 'interactive'
1923                //readyState at the time of the define call.
1924                useInteractive = true;
1925
1926                node.attachEvent('onreadystatechange', context.onScriptLoad);
1927                //It would be great to add an error handler here to catch
1928                //404s in IE9+. However, onreadystatechange will fire before
1929                //the error handler, so that does not help. If addEventListener
1930                //is used, then IE will fire error before load, but we cannot
1931                //use that pathway given the connect.microsoft.com issue
1932                //mentioned above about not doing the 'script execute,
1933                //then fire the script load event listener before execute
1934                //next script' that other browsers do.
1935                //Best hope: IE10 fixes the issues,
1936                //and then destroys all installs of IE 6-9.
1937                //node.attachEvent('onerror', context.onScriptError);
1938            } else {
1939                node.addEventListener('load', context.onScriptLoad, false);
1940                node.addEventListener('error', context.onScriptError, false);
1941            }
1942            node.src = url;
1943
1944            //For some cache cases in IE 6-8, the script executes before the end
1945            //of the appendChild execution, so to tie an anonymous define
1946            //call to the module name (which is stored on the node), hold on
1947            //to a reference to this node, but clear after the DOM insertion.
1948            currentlyAddingScript = node;
1949            if (baseElement) {
1950                head.insertBefore(node, baseElement);
1951            } else {
1952                head.appendChild(node);
1953            }
1954            currentlyAddingScript = null;
1955
1956            return node;
1957        } else if (isWebWorker) {
1958            try {
1959                //In a web worker, use importScripts. This is not a very
1960                //efficient use of importScripts, importScripts will block until
1961                //its script is downloaded and evaluated. However, if web workers
1962                //are in play, the expectation is that a build has been done so
1963                //that only one script needs to be loaded anyway. This may need
1964                //to be reevaluated if other use cases become common.
1965                importScripts(url);
1966
1967                //Account for anonymous modules
1968                context.completeLoad(moduleName);
1969            } catch (e) {
1970                context.onError(makeError('importscripts',
1971                                'importScripts failed for ' +
1972                                    moduleName + ' at ' + url,
1973                                e,
1974                                [moduleName]));
1975            }
1976        }
1977    };
1978
1979    function getInteractiveScript() {
1980        if (interactiveScript && interactiveScript.readyState === 'interactive') {
1981            return interactiveScript;
1982        }
1983
1984        eachReverse(scripts(), function (script) {
1985            if (script.readyState === 'interactive') {
1986                return (interactiveScript = script);
1987            }
1988        });
1989        return interactiveScript;
1990    }
1991
1992    //Look for a data-main script attribute, which could also adjust the baseUrl.
1993    if (isBrowser && !cfg.skipDataMain) {
1994        //Figure out baseUrl. Get it from the script tag with require.js in it.
1995        eachReverse(scripts(), function (script) {
1996            //Set the 'head' where we can append children by
1997            //using the script's parent.
1998            if (!head) {
1999                head = script.parentNode;
2000            }
2001
2002            //Look for a data-main attribute to set main script for the page
2003            //to load. If it is there, the path to data main becomes the
2004            //baseUrl, if it is not already set.
2005            dataMain = script.getAttribute('data-main');
2006            if (dataMain) {
2007                //Preserve dataMain in case it is a path (i.e. contains '?')
2008                mainScript = dataMain;
2009
2010                //Set final baseUrl if there is not already an explicit one.
2011                if (!cfg.baseUrl) {
2012                    //Pull off the directory of data-main for use as the
2013                    //baseUrl.
2014                    src = mainScript.split('/');
2015                    mainScript = src.pop();
2016                    subPath = src.length ? src.join('/')  + '/' : './';
2017
2018                    cfg.baseUrl = subPath;
2019                }
2020
2021                //Strip off any trailing .js since mainScript is now
2022                //like a module name.
2023                mainScript = mainScript.replace(jsSuffixRegExp, '');
2024
2025                //If mainScript is still a path, fall back to dataMain
2026                if (req.jsExtRegExp.test(mainScript)) {
2027                    mainScript = dataMain;
2028                }
2029
2030                //Put the data-main script in the files to load.
2031                cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
2032
2033                return true;
2034            }
2035        });
2036    }
2037
2038    /**
2039     * The function that handles definitions of modules. Differs from
2040     * require() in that a string for the module should be the first argument,
2041     * and the function to execute after dependencies are loaded should
2042     * return a value to define the module corresponding to the first argument's
2043     * name.
2044     */
2045    define = function (name, deps, callback) {
2046        var node, context;
2047
2048        //Allow for anonymous modules
2049        if (typeof name !== 'string') {
2050            //Adjust args appropriately
2051            callback = deps;
2052            deps = name;
2053            name = null;
2054        }
2055
2056        //This module may not have dependencies
2057        if (!isArray(deps)) {
2058            callback = deps;
2059            deps = null;
2060        }
2061
2062        //If no name, and callback is a function, then figure out if it a
2063        //CommonJS thing with dependencies.
2064        if (!deps && isFunction(callback)) {
2065            deps = [];
2066            //Remove comments from the callback string,
2067            //look for require calls, and pull them into the dependencies,
2068            //but only if there are function args.
2069            if (callback.length) {
2070                callback
2071                    .toString()
2072                    .replace(commentRegExp, '')
2073                    .replace(cjsRequireRegExp, function (match, dep) {
2074                        deps.push(dep);
2075                    });
2076
2077                //May be a CommonJS thing even without require calls, but still
2078                //could use exports, and module. Avoid doing exports and module
2079                //work though if it just needs require.
2080                //REQUIRES the function to expect the CommonJS variables in the
2081                //order listed below.
2082                deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
2083            }
2084        }
2085
2086        //If in IE 6-8 and hit an anonymous define() call, do the interactive
2087        //work.
2088        if (useInteractive) {
2089            node = currentlyAddingScript || getInteractiveScript();
2090            if (node) {
2091                if (!name) {
2092                    name = node.getAttribute('data-requiremodule');
2093                }
2094                context = contexts[node.getAttribute('data-requirecontext')];
2095            }
2096        }
2097
2098        //Always save off evaluating the def call until the script onload handler.
2099        //This allows multiple modules to be in a file without prematurely
2100        //tracing dependencies, and allows for anonymous module support,
2101        //where the module name is not known until the script onload event
2102        //occurs. If no context, use the global queue, and get it processed
2103        //in the onscript load callback.
2104        if (context) {
2105            context.defQueue.push([name, deps, callback]);
2106            context.defQueueMap[name] = true;
2107        } else {
2108            globalDefQueue.push([name, deps, callback]);
2109        }
2110    };
2111
2112    define.amd = {
2113        jQuery: true
2114    };
2115
2116    /**
2117     * Executes the text. Normally just uses eval, but can be modified
2118     * to use a better, environment-specific call. Only used for transpiling
2119     * loader plugins, not for plain JS modules.
2120     * @param {String} text the text to execute/evaluate.
2121     */
2122    req.exec = function (text) {
2123        /*jslint evil: true */
2124        return eval(text);
2125    };
2126
2127    //Set up with config info.
2128    req(cfg);
2129}(this));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.