PageSourceSearch

https://www.calrest.org/sites/default/themes/dtheme/bower_components/requirejs/require.js

js calrest.org collected 2026-09-24 19:58:14 UTC 83,715 bytes, 2,087 lines download raw bytes

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